threepipe
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

introduction.md 6.8KB

11 månader sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. ---
  2. next:
  3. text: 'Getting Started'
  4. link: './getting-started'
  5. ---
  6. # Introduction
  7. A new way to work with three.js, 3D models and rendering on the web.
  8. [![NPM Package](https://img.shields.io/npm/v/threepipe.svg)](https://www.npmjs.com/package/threepipe)
  9. [![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/license/apache-2-0/)
  10. [//]: # (todo image)
  11. Threepipe provides a high-level API over three.js to create 3D model viewers, configurators. editors and other interactive 3D applications on websites.
  12. It can be used to quickly get into production-ready WebGL and 3D web graphics without getting into graphics and shaders. The framework is also fully customisable with an extensive API for experienced programmers to add features and make more cool stuff.
  13. <div class="tip custom-block" style="padding-top: 8px">
  14. Just want to try it out? Skip to the [Quickstart](./getting-started).
  15. </div>
  16. Key features include:
  17. - Simple, intuitive API for creating 3D model viewers/configurators/editors on web pages, with many built-in presets for common workflows and use-cases.
  18. - Companion [editor](https://editor.threepipe.org/) to create, edit and configure 3D scenes in the browser.
  19. - Modular architecture that allows you to easily extend the viewer, scene objects, materials, shaders, rendering, post-processing and serialization with custom functionality.
  20. - Plugin system along with a rich library of built-in plugins that allows you to easily add new features to the viewer.
  21. - [uiconfig](https://github.com/repalash/uiconfig.js) compatibility to automatically generate configuration UIs in the browser.
  22. - Modular rendering pipeline with built-in deferred rendering, post-processing, RGBM HDR rendering, etc.
  23. - Material extension framework to modify/inject/build custom shader code into existing materials at runtime from plugins.
  24. - Extendable asset import, export and management pipeline with built-in support for gltf, glb, obj+mtl, fbx, materials(pmat/bmat), json, zip, png, jpeg, svg, webp, ktx2, ply, 3dm and many more.
  25. - Built-in undo/redo support for user actions.
  26. - Automatic serialization of all viewer and plugin settings in GLB(with custom extensions) and JSON formats.
  27. - Automatic disposal of all three.js resources with built-in reference management.
  28. ## Examples
  29. Code samples and demos covering various usecases and test are present in the [examples](https://github.com/repalash/threepipe/tree/master/examples/) folder.
  30. Try them: https://threepipe.org/examples/
  31. View the source code by pressing the code button on the top left of the example page.
  32. To make changes and run the example, click on the Codepen Button <input type="image" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-1/cp-arrow-right.svg" width="35" height="35" style="margin-bottom: -0.6rem; cursor: unset;"> on the top right of the source code.
  33. ::: tip TUTORIALS
  34. There are some step-by-step tutorials to get you started if you are new to 3D or Threepipe.
  35. - [Create an interactive Device Showcase](https://tympanus.net/codrops/2024/08/07/interactive-3d-device-showcase-with-threepipe/) on codrops.
  36. :::
  37. ### Sample
  38. Here is what a sample `threepipe` code looks like -
  39. ```typescript
  40. import {
  41. ContactShadowGroundPlugin,
  42. IObject3D,
  43. LoadingScreenPlugin,
  44. ProgressivePlugin,
  45. SSAAPlugin,
  46. ThreeViewer
  47. } from 'threepipe';
  48. import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane';
  49. async function init() {
  50. const viewer = new ThreeViewer({
  51. // The canvas element where the scene will be rendered
  52. canvas: document.getElementById('threepipe-canvas') as HTMLCanvasElement,
  53. // Enable/Disable MSAA (Multi-Sample Anti-Aliasing)
  54. msaa: false,
  55. // Set the render scale automatically based on the device pixel ratio
  56. renderScale: "auto",
  57. // Enable/Disable tone mapping
  58. tonemap: true,
  59. // Add some plugins
  60. plugins: [
  61. // Show a loading screen while the model is downloading
  62. LoadingScreenPlugin,
  63. // Enable progressive rendering and SSAA
  64. ProgressivePlugin, SSAAPlugin,
  65. // Add a ground with contact shadows
  66. ContactShadowGroundPlugin
  67. ]
  68. });
  69. // Add a plugin with a debug UI for tweaking parameters
  70. const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true));
  71. // Load an environment map
  72. await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr', {
  73. // The environment map can also be used as the scene background
  74. setBackground: false,
  75. });
  76. // Load a 3D model with auto-center and auto-scale options
  77. const result = await viewer.load<IObject3D>('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf', {
  78. autoCenter: true,
  79. autoScale: true,
  80. });
  81. // Add some debug UI elements for tweaking parameters
  82. ui.setupPlugins(SSAAPlugin)
  83. ui.appendChild(viewer.scene.uiConfig)
  84. ui.appendChild(viewer.scene.mainCamera.uiConfig)
  85. // Every object, material, etc has a UI config that can be added to the UI to configure it.
  86. const model = result?.getObjectByName('node_damagedHelmet_-6514');
  87. if (model) ui.appendChild(model.uiConfig, {expanded: false});
  88. }
  89. init();
  90. ```
  91. The `ThreeViewer` class is used to create a new 3D viewer instance. It includes several components including a `Scene`, `Camera`(with `OrbitControls`), `Renderer`, `RenderManager`, `AssetManager`, and some default plugins(like `TonemapPlugin`). It is set up to provide a quickstart to create a three.js app with all the required components.
  92. Additionally, plugins like `LoadingScreenPlugin`, `ProgressivePlugin`, `SSAAPlugin`, and `ContactShadowGroundPlugin` are added to extend the functionality of the viewer.
  93. Check out this sample on CodePen: [threepipe-sample](https://codepen.io/repalash/pen/GRbEONZ?editors=0010)
  94. ## License
  95. The core framework([src](https://github.com/repalash/threepipe/tree/master/src), [dist](https://github.com/repalash/threepipe/tree/master/dist), [examples](https://github.com/repalash/threepipe/tree/master/examples) folders) and any [plugins](https://github.com/repalash/threepipe/tree/master/plugins) without a separate license are under the Free [Apache 2.0 license](https://github.com/repalash/threepipe/tree/master/LICENSE).
  96. Some plugins(in the [plugins](https://github.com/repalash/threepipe/tree/master/plugins) folder) might have different licenses. Check the individual plugin documentation and the source folder/files for more details.
  97. ## Status
  98. The project is in `beta` stage and under active development. Many features and integrations will be added but the core API will not change significantly in future releases.
  99. ## API Reference/Docs
  100. Check the list of all functions, classes and types in the [API Reference Docs](https://threepipe.org/docs/).
  101. ## Contributing
  102. Contributions to ThreePipe are welcome and encouraged! Feel free to open issues and pull requests on the [GitHub repository](https://github.com/repalash/threepipe).