threepipe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

introduction.md 6.8KB

1 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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://threepipe.org/examples/tweakpane-editor/) 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. - Automatic serialization of all viewer and plugin settings in GLB(with custom extensions) and JSON formats.
  26. - Automatic disposal of all three.js resources with built-in reference management.
  27. ## Examples
  28. Code samples and demos covering various usecases and test are present in the [examples](https://github.com/repalash/threepipe/tree/master/examples/) folder.
  29. Try them: https://threepipe.org/examples/
  30. View the source code by pressing the code button on the top left of the example page.
  31. 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.
  32. ::: tip TUTORIALS
  33. There are some step-by-step tutorials to get you started if you are new to 3D or Threepipe.
  34. - [Create an interactive Device Showcase](https://tympanus.net/codrops/2024/08/07/interactive-3d-device-showcase-with-threepipe/) on codrops.
  35. :::
  36. ### Sample
  37. Here is what a sample `threepipe` code looks like -
  38. ```typescript
  39. import {
  40. ContactShadowGroundPlugin,
  41. IObject3D,
  42. LoadingScreenPlugin,
  43. ProgressivePlugin,
  44. SSAAPlugin,
  45. ThreeViewer
  46. } from 'threepipe';
  47. import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane';
  48. async function init() {
  49. const viewer = new ThreeViewer({
  50. // The canvas element where the scene will be rendered
  51. canvas: document.getElementById('threepipe-canvas') as HTMLCanvasElement,
  52. // Enable/Disable MSAA (Multi-Sample Anti-Aliasing)
  53. msaa: false,
  54. // Set the render scale automatically based on the device pixel ratio
  55. renderScale: "auto",
  56. // Enable/Disable tone mapping
  57. tonemap: true,
  58. // Add some plugins
  59. plugins: [
  60. // Show a loading screen while the model is downloading
  61. LoadingScreenPlugin,
  62. // Enable progressive rendering and SSAA
  63. ProgressivePlugin, SSAAPlugin,
  64. // Add a ground with contact shadows
  65. ContactShadowGroundPlugin
  66. ]
  67. });
  68. // Add a plugin with a debug UI for tweaking parameters
  69. const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true));
  70. // Load an environment map
  71. await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr', {
  72. // The environment map can also be used as the scene background
  73. setBackground: false,
  74. });
  75. // Load a 3D model with auto-center and auto-scale options
  76. const result = await viewer.load<IObject3D>('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf', {
  77. autoCenter: true,
  78. autoScale: true,
  79. });
  80. // Add some debug UI elements for tweaking parameters
  81. ui.setupPlugins(SSAAPlugin)
  82. ui.appendChild(viewer.scene.uiConfig)
  83. ui.appendChild(viewer.scene.mainCamera.uiConfig)
  84. // Every object, material, etc has a UI config that can be added to the UI to configure it.
  85. const model = result?.getObjectByName('node_damagedHelmet_-6514');
  86. if (model) ui.appendChild(model.uiConfig, {expanded: false});
  87. }
  88. init();
  89. ```
  90. 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.
  91. Additionally plugins like `LoadingScreenPlugin`, `ProgressivePlugin`, `SSAAPlugin`, and `ContactShadowGroundPlugin` are added to extend the functionality of the viewer.
  92. Check out this sample on CodePen: [threepipe-sample](https://codepen.io/repalash/pen/GRbEONZ?editors=0010)
  93. ## License
  94. 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).
  95. 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.
  96. ## Status
  97. 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.
  98. ## API Reference/Docs
  99. Check the list of all functions, classes and types in the [API Reference Docs](https://threepipe.org/docs/).
  100. ## Contributing
  101. Contributions to ThreePipe are welcome and encouraged! Feel free to open issues and pull requests on the [GitHub repository](https://github.com/repalash/threepipe).