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.

пре 3 година
пре 3 година
пре 2 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 2 година
пре 1 година
пре 2 година
пре 1 година
пре 2 година
пре 1 година
пре 2 година
пре 2 година
пре 1 година
пре 2 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 1 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 1 година
пре 3 година
пре 3 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. # ThreePipe
  2. A new way to work with three.js, 3D models and rendering on the web.
  3. [ThreePipe](https://threepipe.org/) —
  4. [Github](https://github.com/repalash/threepipe) —
  5. [Examples](https://threepipe.org/examples/) —
  6. [API Reference](https://threepipe.org/docs/) —
  7. [WebGi](https://webgi.xyz/docs/)
  8. [![NPM Package](https://img.shields.io/npm/v/threepipe.svg)](https://www.npmjs.com/package/threepipe)
  9. [![Discord Server](https://img.shields.io/discord/956788102473584660?label=Discord&logo=discord)](https://discord.gg/apzU8rUWxY)
  10. [![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/license/apache-2-0/)
  11. [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/repalash.svg?style=social&label=Follow%20%40repalash)](https://twitter.com/repalash)
  12. ThreePipe is a 3D framework built on top of [three.js](https://threejs.org/) in TypeScript with a focus on rendering quality, modularity, and extensibility.
  13. Key features include:
  14. - Simple, intuitive API for creating 3D model viewers/configurators/editors on web pages, with many built-in presets for common workflows and use-cases.
  15. - Companion [editor](https://threepipe.org/examples/tweakpane-editor/) to create, edit and configure 3D scenes in the browser.
  16. - Modular architecture that allows you to easily extend the viewer, scene objects, materials, shaders, rendering, post-processing and serialization with custom functionality.
  17. - Plugin system along with a rich library of built-in plugins that allows you to easily add new features to the viewer.
  18. - [uiconfig](https://github.com/repalash/uiconfig.js) compatibility to automatically generate configuration UIs in the browser.
  19. - Modular rendering pipeline with built-in deferred rendering, post-processing, RGBM HDR rendering, etc.
  20. - Material extension framework to modify/inject/build custom shader code into existing materials at runtime from plugins.
  21. - 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.
  22. - Automatic serialization of all viewer and plugin settings in GLB(with custom extensions) and JSON formats.
  23. - Automatic disposal of all three.js resources with built-in reference management.
  24. ## Examples
  25. Code samples and demos covering various usecases and test are present in the [examples](./examples/) folder.
  26. Try them: https://threepipe.org/examples/
  27. View the source code by pressing the code button on the top left of the example page.
  28. To make changes and run the example, click on the CodePen button on the top right of the source code.
  29. ## Getting Started
  30. ### HTML/JS Quickstart (CDN)
  31. ```html
  32. <canvas id="three-canvas" style="width: 800px; height: 600px;"></canvas>
  33. <script type="module">
  34. import {ThreeViewer, DepthBufferPlugin} from 'https://threepipe.org/dist/index.mjs'
  35. const viewer = new ThreeViewer({canvas: document.getElementById('three-canvas')})
  36. // Add some plugins
  37. viewer.addPluginSync(new DepthBufferPlugin())
  38. // Load an environment map
  39. const envPromise = viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr')
  40. const modelPromise = viewer.load('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf', {
  41. autoCenter: true,
  42. autoScale: true,
  43. })
  44. Promise.all([envPromise, modelPromise]).then(([env, model]) => {
  45. console.log('Loaded', model, env, viewer)
  46. })
  47. </script>
  48. ```
  49. Check it in action: https://threepipe.org/examples/#html-js-sample/
  50. Check out the details about the [ThreeViewer API](https://threepipe.org/guide/viewer-api.html) and more [plugins](https://threepipe.org/guide/core-plugins.html).
  51. ### React
  52. A sample [react](https://react.dev) component in tsx to render a model with an environment map.
  53. ```tsx
  54. import React from 'react'
  55. function ThreeViewerComponent({src, env}: {src: string, env: string}) {
  56. const canvasRef = React.useRef(null)
  57. React.useEffect(() => {
  58. const viewer = new ThreeViewer({canvas: canvasRef.current})
  59. const envPromise = viewer.setEnvironmentMap(env)
  60. const modelPromise = viewer.load(src)
  61. Promise.all([envPromise, modelPromise]).then(([env, model]) => {
  62. console.log('Loaded', model, env, viewer)
  63. })
  64. return () => {
  65. viewer.dispose()
  66. }
  67. }, [])
  68. return (
  69. <canvas id="three-canvas" style={{width: 800, height: 600}} ref={canvasRef} />
  70. )
  71. }
  72. ```
  73. Check it in action: https://threepipe.org/examples/#react-tsx-sample/
  74. Other examples in js: https://threepipe.org/examples/#react-js-sample/ and jsx: https://threepipe.org/examples/#react-jsx-sample/
  75. ### Vue.js
  76. A sample [vue.js](https://vuejs.org/) component in js to render a model with an environment map.
  77. ```js
  78. const ThreeViewerComponent = {
  79. setup() {
  80. const canvasRef = ref(null);
  81. onMounted(() => {
  82. const viewer = new ThreeViewer({ canvas: canvasRef.value });
  83. const envPromise = viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr');
  84. const modelPromise = viewer.load('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf');
  85. Promise.all([envPromise, modelPromise]).then(([env, model]) => {
  86. console.log('Loaded', model, env, viewer)
  87. })
  88. onBeforeUnmount(() => {
  89. viewer.dispose();
  90. });
  91. });
  92. return { canvasRef };
  93. },
  94. };
  95. ```
  96. Check it in action: https://threepipe.org/examples/#vue-html-sample/
  97. Another example with Vue SFC(Single file component): https://threepipe.org/examples/#vue-sfc-sample/
  98. ### Svelte
  99. A sample [svelte](https://svelte.dev/) component in js to render a model with an environment map.
  100. ```html
  101. <script>
  102. import {onDestroy, onMount} from 'svelte';
  103. import {ThreeViewer} from 'threepipe';
  104. let canvasRef;
  105. let viewer;
  106. onMount(() => {
  107. viewer = new ThreeViewer({canvas: canvasRef});
  108. const envPromise = viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr');
  109. const modelPromise = viewer.load('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf');
  110. Promise.all([envPromise, modelPromise]).then(([env, model]) => {
  111. console.log('Loaded', model, env, viewer)
  112. })
  113. });
  114. onDestroy(() => viewer.dispose())
  115. </script>
  116. <canvas bind:this={canvasRef} id="three-canvas" style="width: 800px; height: 600px"></canvas>
  117. ```
  118. Check it in action: https://threepipe.org/examples/#svelte-sample/
  119. ### NPM/YARN
  120. ### Installation
  121. ```bash
  122. npm install threepipe
  123. ```
  124. ### Loading a 3D Model
  125. First, create a canvas element in your HTML page:
  126. ```html
  127. <canvas id="three-canvas" style="width: 800px; height: 600px;"></canvas>
  128. ```
  129. Then, import the viewer and create a new instance:
  130. ```typescript
  131. import {ThreeViewer, IObject3D} from 'threepipe'
  132. // Create a viewer
  133. const viewer = new ThreeViewer({canvas: document.getElementById('three-canvas') as HTMLCanvasElement})
  134. // Load an environment map
  135. await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr')
  136. // Load a model
  137. const result = await viewer.load<IObject3D>('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf', {
  138. autoCenter: true,
  139. autoScale: true,
  140. })
  141. ```
  142. That's it! You should now see a 3D model on your page.
  143. The 3D model can be opened in the [editor](https://threepipe.org/examples/tweakpane-editor/) to view and edit the scene settings, objects, materials, lights, cameras, post-processing, etc. and exported as a GLB file. All settings are automatically serialized and saved in the GLB file, which can be loaded into the viewer. Any plugins used in the editor can be added to the viewer to add the same functionality. The plugin data is automatically loaded(if the plugin is added) when the model is added to the scene.
  144. The viewer initializes with a Scene, Camera, Camera controls(Orbit Controls), several importers, exporters and a default rendering pipeline. Additional functionality can be added with plugins.
  145. Check out the GLTF Load example to see it in action or to check the JS equivalent code: https://threepipe.org/examples/#gltf-load/
  146. Check out the [Plugins](https://threepipe.org/guide/features.html#plugin-system) section to learn how to add additional functionality to the viewer.
  147. ## License
  148. 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).
  149. 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.
  150. ## Status
  151. The project is in `alpha` stage and under active development. Many features will be added but the core API will not change significantly in future releases.
  152. Check out [WebGi](https://webgi.xyz/docs) for an advanced tailor-made solution for e-commerce, jewelry, automobile, apparel, furniture etc.
  153. ## Table of Contents
  154. - [ThreePipe](#threepipe)
  155. - [Examples](https://threepipe.org/examples/)
  156. - [Table of Contents](#table-of-contents)
  157. - [Getting Started](#getting-started)
  158. - [HTML/JS Quickstart (CDN)](#htmljs-quickstart-cdn)
  159. - [React](#react)
  160. - [Vue.js](#vuejs)
  161. - [Svelte](#svelte)
  162. - [NPM/YARN Package](#npmyarn)
  163. - [Installation](#installation)
  164. - [Loading a 3D Model](#loading-a-3d-model)
  165. - [License](#license)
  166. - [Status](#status)
  167. - [Documentation (API Reference)](#documentation)
  168. - [Contributing](#contributing)
  169. - [Features](https://threepipe.org/guide/features.html)
  170. - [File Formats](https://threepipe.org/guide/features.html#file-formats)
  171. - [Loading files](https://threepipe.org/guide/features.html#loading-files)
  172. - [Exporting files](https://threepipe.org/guide/features.html#exporting-files)
  173. - [Render Pipeline](https://threepipe.org/guide/features.html#render-pipeline)
  174. - [Material Extension](https://threepipe.org/guide/features.html#material-extension)
  175. - [UI Configuration](https://threepipe.org/guide/features.html#ui-configuration)
  176. - [Serialization](https://threepipe.org/guide/features.html#serialization)
  177. - [Plugin System](https://threepipe.org/guide/features.html#plugin-system)
  178. - [Viewer API](https://threepipe.org/guide/viewer-api.html#viewer-api)
  179. - [ThreeViewer](https://threepipe.org/guide/viewer-api.html#threeviewer)
  180. - [RenderManager](https://threepipe.org/guide/viewer-api.html#rendermanager)
  181. - [RootScene](https://threepipe.org/guide/viewer-api.html#rootscene)
  182. - [ICamera](https://threepipe.org/guide/viewer-api.html#icamera)
  183. - [AssetManager](https://threepipe.org/guide/viewer-api.html#assetmanager)
  184. - [AssetImporter](https://threepipe.org/guide/viewer-api.html#assetimporter)
  185. - [AssetExporter](https://threepipe.org/guide/viewer-api.html#assetexporter)
  186. - [MaterialManager](https://threepipe.org/guide/viewer-api.html#materialmanager)
  187. - [Other classes and interfaces](https://threepipe.org/guide/viewer-api.html#other-classes-and-interfaces)
  188. - [Plugins](https://threepipe.org/guide/core-plugins.html#threepipe-plugins)
  189. - [TonemapPlugin](https://threepipe.org/plugin/TonemapPlugin.html) - Add tonemap to the final screen pass
  190. - [DropzonePlugin](https://threepipe.org/plugin/DropzonePlugin.html - Drag and drop local files to import and load
  191. - [ProgressivePlugin](https://threepipe.org/plugin/ProgressivePlugin.html) - Post-render pass to blend the last frame with the current frame
  192. - [SSAAPlugin](https://threepipe.org/plugin/SSAAPlugin.html) - Add Super Sample Anti-Aliasing by applying jitter to the camera.
  193. - [DepthBufferPlugin](https://threepipe.org/plugin/DepthBufferPlugin.html) - Pre-rendering of depth buffer
  194. - [NormalBufferPlugin](https://threepipe.org/plugin/NormalBufferPlugin.html) - Pre-rendering of normal buffer
  195. - [GBufferPlugin](https://threepipe.org/plugin/GBufferPlugin.html) - Pre-rendering of depth-normal and flags buffers in a single pass
  196. - [SSAOPlugin](https://threepipe.org/plugin/SSAOPlugin.html) - Add SSAO(Screen Space Ambient Occlusion) for physical materials.
  197. - [CanvasSnapshotPlugin](https://threepipe.org/plugin/CanvasSnapshotPlugin.html) - Add support for taking snapshots of the canvas
  198. - [PickingPlugin](https://threepipe.org/plugin/PickingPlugin.html) - Adds support for selecting objects in the viewer with user interactions and selection widgets
  199. - [AssetExporterPlugin](https://threepipe.org/plugin/AssetExporterPlugin.html) - Provides options and methods to export the scene, object GLB or Viewer Configuration.
  200. - [LoadingScreenPlugin](https://threepipe.org/plugin/LoadingScreenPlugin.html) - Shows a configurable loading screen overlay over the canvas.
  201. - [FullScreenPlugin](https://threepipe.org/plugin/FullScreenPlugin.html) - Adds support for moving the canvas or the container fullscreen mode in browsers
  202. - [InteractionPromptPlugin](https://threepipe.org/plugin/InteractionPromptPlugin.html) - Adds an animated hand icon over canvas to prompt the user to interact
  203. - [TransformControlsPlugin](https://threepipe.org/plugin/TransformControlsPlugin.html) - Adds support for moving, rotating and scaling objects in the viewer with interactive widgets
  204. - [ContactShadowGroundPlugin](https://threepipe.org/plugin/ContactShadowGroundPlugin.html) - Adds a ground plane at runtime with contact shadows
  205. - [GLTFAnimationPlugin](https://threepipe.org/plugin/GLTFAnimationPlugin.html) - Add support for playing and seeking gltf animations
  206. - [PopmotionPlugin](https://threepipe.org/plugin/PopmotionPlugin.html) - Integrates with popmotion.io library for animation/tweening
  207. - [CameraViewPlugin](https://threepipe.org/plugin/CameraViewPlugin.html) - Add support for saving, loading, animating, looping between camera views
  208. - [TransformAnimationPlugin](https://threepipe.org/plugin/TransformAnimationPlugin.html) - Add support for saving, loading, animating, between object transforms
  209. - [RenderTargetPreviewPlugin](https://threepipe.org/plugin/RenderTargetPreviewPlugin.html) - Preview any render target in a UI panel over the canvas
  210. - [GeometryUVPreviewPlugin](https://threepipe.org/plugin/GeometryUVPreviewPlugin.html) - Preview UVs of any geometry in a UI panel over the canvas
  211. - [FrameFadePlugin](https://threepipe.org/plugin/FrameFadePlugin.html) - Post-render pass to smoothly fade to a new rendered frame over time
  212. - [VignettePlugin](https://threepipe.org/plugin/VignettePlugin.html) - Add Vignette effect by patching the final screen pass
  213. - [ChromaticAberrationPlugin](https://threepipe.org/plugin/ChromaticAberrationPlugin.html) - Add Chromatic Aberration effect by patching the final screen pass
  214. - [FilmicGrainPlugin](https://threepipe.org/plugin/FilmicGrainPlugin.html) - Add Filmic Grain effect by patching the final screen pass
  215. - [NoiseBumpMaterialPlugin](https://threepipe.org/plugin/NoiseBumpMaterialPlugin.html) - Sparkle Bump/Noise Bump material extension for PhysicalMaterial
  216. - [CustomBumpMapPlugin](https://threepipe.org/plugin/CustomBumpMapPlugin.html) - Custom Bump Map material extension for PhysicalMaterial
  217. - [ClearcoatTintPlugin](https://threepipe.org/plugin/ClearcoatTintPlugin.html) - Clearcoat Tint material extension for PhysicalMaterial
  218. - [FragmentClippingExtensionPlugin](https://threepipe.org/plugin/FragmentClippingExtensionPlugin.html) - Fragment/SDF Clipping material extension for PhysicalMaterial
  219. - [ParallaxMappingPlugin](https://threepipe.org/plugin/ParallaxMappingPlugin.html) - Relief Parallax Bump Mapping extension for PhysicalMaterial
  220. - [HDRiGroundPlugin](https://threepipe.org/plugin/HDRiGroundPlugin.html) - Add support for ground projected hdri/skybox to the webgl background shader.
  221. - [VirtualCamerasPlugin](https://threepipe.org/plugin/VirtualCamerasPlugin.html) - Add support for rendering virtual cameras before the main one every frame.
  222. - [EditorViewWidgetPlugin](https://threepipe.org/plugin/EditorViewWidgetPlugin.html) - Adds an interactive ViewHelper/AxisHelper that syncs with the main camera.
  223. - [Object3DWidgetsPlugin](https://threepipe.org/plugin/Object3DWidgetsPlugin.html) - Automatically create light and camera helpers/gizmos when they are added to the scene.
  224. - [Object3DGeneratorPlugin](https://threepipe.org/plugin/Object3DGeneratorPlugin.html) - Provides UI and API to create scene objects like lights, cameras, meshes, etc.
  225. - [DeviceOrientationControlsPlugin](https://threepipe.org/plugin/DeviceOrientationControlsPlugin.html) - Adds a controlsMode to the mainCamera for device orientation controls(gyroscope rotation control).
  226. - [PointerLockControlsPlugin](https://threepipe.org/plugin/PointerLockControlsPlugin.html) - Adds a controlsMode to the mainCamera for pointer lock controls.
  227. - [ThreeFirstPersonControlsPlugin](https://threepipe.org/plugin/ThreeFirstPersonControlsPlugin.html) - Adds a controlsMode to the mainCamera for first person controls from threejs.
  228. - [GLTFKHRMaterialVariantsPlugin](https://threepipe.org/plugin/GLTFKHRMaterialVariantsPlugin.html) - Support using for variants from KHR_materials_variants extension in gltf models.
  229. - [Rhino3dmLoadPlugin](https://threepipe.org/plugin/Rhino3dmLoadPlugin.html) - Add support for loading .3dm files
  230. - [PLYLoadPlugin](https://threepipe.org/plugin/PLYLoadPlugin.html) - Add support for loading .ply files
  231. - [STLLoadPlugin](https://threepipe.org/plugin/STLLoadPlugin.html) - Add support for loading .stl files
  232. - [KTX2LoadPlugin](https://threepipe.org/plugin/KTX2LoadPlugin.html) - Add support for loading .ktx2 files
  233. - [KTXLoadPlugin](https://threepipe.org/plugin/KTXLoadPlugin.html) - Add support for loading .ktx files
  234. - [USDZLoadPlugin](https://threepipe.org/plugin/USDZLoadPlugin.html) - Add support for loading .usdz files
  235. - [GLTFMeshOptDecodePlugin](https://threepipe.org/plugin/GLTFMeshOptDecodePlugin.html) - Decode gltf files with EXT_meshopt_compression extension.
  236. - [SimplifyModifierPlugin](https://threepipe.org/plugin/SimplifyModifierPlugin.html) - Boilerplate for plugin to simplify geometries
  237. - [MeshOptSimplifyModifierPlugin](https://threepipe.org/plugin/MeshOptSimplifyModifierPlugin.html) - Simplify geometries using meshoptimizer library
  238. - [Packages](https://threepipe.org/guide/threepipe-packages.html)
  239. - [@threepipe/plugin-tweakpane](https://threepipe.org/package/plugin-tweakpane.html) Tweakpane UI Plugin
  240. - [@threepipe/plugin-blueprintjs](https://threepipe.org/package/plugin-blueprintjs.html) BlueprintJs UI Plugin
  241. - [@threepipe/plugin-tweakpane-editor](https://threepipe.org/package/plugin-tweakpane-editor.html) - Tweakpane Editor Plugin
  242. - [@threepipe/plugin-configurator](https://threepipe.org/package/plugin-configurator.html) - Provides Material Configurator and Switch Node Plugin to allow users to select variations
  243. - [@threepipe/plugin-gltf-transform](https://threepipe.org/package/plugin-gltf-transform.html) - Plugin to transform gltf models (draco compression)
  244. - [@threepipe/plugins-extra-importers](https://threepipe.org/package/plugins-extra-importers.html) - Plugin for loading more file types supported by loaders in three.js
  245. - [@threepipe/plugin-blend-importer](https://threepipe.org/package/plugin-blend-importer.html) - Blender to add support for loading .blend file
  246. - [@threepipe/plugin-geometry-generator](https://threepipe.org/package/plugin-geometry-generator.html) - Generate parametric geometry types that can be re-generated from UI/API.
  247. - [@threepipe/plugin-gaussian-splatting](https://threepipe.org/package/plugin-gaussian-splatting.html) - Gaussian Splatting plugin for loading and rendering splat files
  248. - [@threepipe/plugin-network](https://threepipe.org/package/plugin-network.html) - Network/Cloud related plugin implementations for Threepipe.
  249. - [@threepipe/plugin-svg-renderer](https://threepipe.org/package/plugin-svg-renderer.html) - Add support for exporting 3d scene as SVG.
  250. ## Documentation
  251. Check the list of all functions, classes and types in the [API Reference Docs](https://threepipe.org/docs/).
  252. ## Contributing
  253. Contributions to ThreePipe are welcome and encouraged! Feel free to open issues and pull requests on the GitHub repository.