threepipe
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
3 лет назад
2 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
2 лет назад
2 лет назад
1 год назад
2 лет назад
2 лет назад
2 лет назад
2 лет назад
1 год назад
1 год назад
1 год назад
1 год назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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. ## Table of Contents
  30. - [ThreePipe](#threepipe)
  31. - [Examples](https://threepipe.org/examples/)
  32. - [Table of Contents](#table-of-contents)
  33. - [Getting Started](#getting-started)
  34. - [HTML/JS Quickstart (CDN)](#htmljs-quickstart-cdn)
  35. - [React](#react)
  36. - [Vue.js](#vuejs)
  37. - [Svelte](#svelte)
  38. - [NPM/YARN Package](#npmyarn)
  39. - [Installation](#installation)
  40. - [Loading a 3D Model](#loading-a-3d-model)
  41. - [License](#license)
  42. - [Status](#status)
  43. - [Documentation (API Reference)](#documentation)
  44. - [WebGi](#webgi)
  45. - [Contributing](#contributing)
  46. - [Features](#features)
  47. - [File Formats](#file-formats)
  48. - [Loading files](#loading-files)
  49. - [Exporting files](#exporting-files)
  50. - [Render Pipeline](#render-pipeline)
  51. - [Material Extension](#material-extension)
  52. - [UI Configuration](#ui-configuration)
  53. - [Serialization](#serialization)
  54. - [Plugin System](#plugin-system)
  55. - [Viewer API](#viewer-api)
  56. - [ThreeViewer](#threeviewer)
  57. - [RenderManager](#rendermanager)
  58. - [RootScene](#rootscene)
  59. - [ICamera](#icamera)
  60. - [AssetManager](#assetmanager)
  61. - [AssetImporter](#assetimporter)
  62. - [AssetExporter](#assetexporter)
  63. - [MaterialManager](#materialmanager)
  64. - [Other classes and interfaces](#other-classes-and-interfaces)
  65. - [Plugins](#threepipe-plugins)
  66. - [TonemapPlugin](#tonemapplugin) - Add tonemap to the final screen pass
  67. - [DropzonePlugin](#dropzoneplugin) - Drag and drop local files to import and load
  68. - [ProgressivePlugin](#progressiveplugin) - Post-render pass to blend the last frame with the current frame
  69. - [SSAAPlugin](#ssaaplugin) - Add Super Sample Anti-Aliasing by applying jitter to the camera.
  70. - [DepthBufferPlugin](#depthbufferplugin) - Pre-rendering of depth buffer
  71. - [NormalBufferPlugin](#normalbufferplugin) - Pre-rendering of normal buffer
  72. - [GBufferPlugin](#gbufferplugin) - Pre-rendering of depth-normal and flags buffers in a single pass
  73. - [SSAOPlugin](#ssaoplugin) - Add SSAO(Screen Space Ambient Occlusion) for physical materials.
  74. - [CanvasSnapshotPlugin](#canvassnapshotplugin) - Add support for taking snapshots of the canvas
  75. - [PickingPlugin](#pickingplugin) - Adds support for selecting objects in the viewer with user interactions and selection widgets
  76. - [AssetExporterPlugin](#assetexporterplugin) - Provides options and methods to export the scene, object GLB or Viewer Configuration.
  77. - [LoadingScreenPlugin](#loadingscreenplugin) - Shows a configurable loading screen overlay over the canvas.
  78. - [FullScreenPlugin](#fullscreenplugin) - Adds support for moving the canvas or the container fullscreen mode in browsers
  79. - [InteractionPromptPlugin](#interactionpromptplugin) - Adds an animated hand icon over canvas to prompt the user to interact
  80. - [TransformControlsPlugin](#transformcontrolsplugin) - Adds support for moving, rotating and scaling objects in the viewer with interactive widgets
  81. - [ContactShadowGroundPlugin](#contactshadowgroundplugin) - Adds a ground plane at runtime with contact shadows
  82. - [GLTFAnimationPlugin](#gltfanimationplugin) - Add support for playing and seeking gltf animations
  83. - [PopmotionPlugin](#popmotionplugin) - Integrates with popmotion.io library for animation/tweening
  84. - [CameraViewPlugin](#cameraviewplugin) - Add support for saving, loading, animating, looping between camera views
  85. - [TransformAnimationPlugin](#transformanimationplugin) - Add support for saving, loading, animating, between object transforms
  86. - [RenderTargetPreviewPlugin](#rendertargetpreviewplugin) - Preview any render target in a UI panel over the canvas
  87. - [GeometryUVPreviewPlugin](#geometryuvpreviewplugin) - Preview UVs of any geometry in a UI panel over the canvas
  88. - [FrameFadePlugin](#framefadeplugin) - Post-render pass to smoothly fade to a new rendered frame over time
  89. - [VignettePlugin](#vignetteplugin) - Add Vignette effect by patching the final screen pass
  90. - [ChromaticAberrationPlugin](#chromaticaberrationplugin) - Add Chromatic Aberration effect by patching the final screen pass
  91. - [FilmicGrainPlugin](#filmicgrainplugin) - Add Filmic Grain effect by patching the final screen pass
  92. - [NoiseBumpMaterialPlugin](#noisebumpmaterialplugin) - Sparkle Bump/Noise Bump material extension for PhysicalMaterial
  93. - [CustomBumpMapPlugin](#custombumpmapplugin) - Custom Bump Map material extension for PhysicalMaterial
  94. - [ClearcoatTintPlugin](#clearcoattintplugin) - Clearcoat Tint material extension for PhysicalMaterial
  95. - [FragmentClippingExtensionPlugin](#fragmentclippingextensionplugin) - Fragment/SDF Clipping material extension for PhysicalMaterial
  96. - [ParallaxMappingPlugin](#parallaxmappingplugin) - Relief Parallax Bump Mapping extension for PhysicalMaterial
  97. - [HDRiGroundPlugin](#hdrigroundplugin) - Add support for ground projected hdri/skybox to the webgl background shader.
  98. - [VirtualCamerasPlugin](#virtualcamerasplugin) - Add support for rendering virtual cameras before the main one every frame.
  99. - [EditorViewWidgetPlugin](#editorviewwidgetplugin) - Adds an interactive ViewHelper/AxisHelper that syncs with the main camera.
  100. - [Object3DWidgetsPlugin](#object3dwidgetsplugin) - Automatically create light and camera helpers/gizmos when they are added to the scene.
  101. - [Object3DGeneratorPlugin](#object3dwidgetsplugin) - Provides UI and API to create scene objects like lights, cameras, meshes, etc.
  102. - [DeviceOrientationControlsPlugin](#deviceorientationcontrolsplugin) - Adds a controlsMode to the mainCamera for device orientation controls(gyroscope rotation control).
  103. - [PointerLockControlsPlugin](#pointerlockcontrolsplugin) - Adds a controlsMode to the mainCamera for pointer lock controls.
  104. - [ThreeFirstPersonControlsPlugin](#threefirstpersoncontrolsplugin) - Adds a controlsMode to the mainCamera for first person controls from threejs.
  105. - [GLTFKHRMaterialVariantsPlugin](#gltfkhrmaterialvariantsplugin) - Support using for variants from KHR_materials_variants extension in gltf models.
  106. - [Rhino3dmLoadPlugin](#rhino3dmloadplugin) - Add support for loading .3dm files
  107. - [PLYLoadPlugin](#plyloadplugin) - Add support for loading .ply files
  108. - [STLLoadPlugin](#stlloadplugin) - Add support for loading .stl files
  109. - [KTX2LoadPlugin](#ktx2loadplugin) - Add support for loading .ktx2 files
  110. - [KTXLoadPlugin](#ktxloadplugin) - Add support for loading .ktx files
  111. - [USDZLoadPlugin](#usdzloadplugin) - Add support for loading .usdz files
  112. - [GLTFMeshOptDecodePlugin](#gltfmeshoptdecodeplugin) - Decode gltf files with EXT_meshopt_compression extension.
  113. - [SimplifyModifierPlugin](#simplifymodifierplugin) - Boilerplate for plugin to simplify geometries
  114. - [MeshOptSimplifyModifierPlugin](#meshoptsimplifymodifierplugin) - Simplify geometries using meshoptimizer library
  115. - [Packages](#threepipe-packages)
  116. - [@threepipe/plugin-tweakpane](#threepipeplugin-tweakpane) Tweakpane UI Plugin
  117. - [@threepipe/plugin-blueprintjs](#threepipeplugin-blueprintjs) BlueprintJs UI Plugin
  118. - [@threepipe/plugin-tweakpane-editor](#threepipeplugin-tweakpane-editor) - Tweakpane Editor Plugin
  119. - [@threepipe/plugin-configurator](#threepipeplugin-configurator) - Provides Material Configurator and Switch Node Plugin to allow users to select variations
  120. - [@threepipe/plugin-gltf-transform](#threepipeplugin-gltf-transform) - Plugin to transform gltf models (draco compression)
  121. - [@threepipe/plugins-extra-importers](#threepipeplugins-extra-importers) - Plugin for loading more file types supported by loaders in three.js
  122. - [@threepipe/plugin-blend-importer](#threepipeplugin-blend-importer) - Blender to add support for loading .blend file
  123. - [@threepipe/plugin-geometry-generator](#threepipeplugin-geometry-generator) - Generate parametric geometry types that can be re-generated from UI/API.
  124. - [@threepipe/plugin-gaussian-splatting](#threepipeplugin-gaussian-splatting) - Gaussian Splatting plugin for loading and rendering splat files
  125. - [@threepipe/plugin-network](#threepipeplugin-network) - Network/Cloud related plugin implementations for Threepipe.
  126. - [@threepipe/plugin-svg-renderer](#threepipeplugin-svg-renderer) - Add support for exporting 3d scene as SVG.
  127. ## Getting Started
  128. ### HTML/JS Quickstart (CDN)
  129. ```html
  130. <canvas id="three-canvas" style="width: 800px; height: 600px;"></canvas>
  131. <script type="module">
  132. import {ThreeViewer, DepthBufferPlugin} from 'https://threepipe.org/dist/index.mjs'
  133. const viewer = new ThreeViewer({canvas: document.getElementById('three-canvas')})
  134. // Add some plugins
  135. viewer.addPluginSync(new DepthBufferPlugin())
  136. // Load an environment map
  137. const envPromise = viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr')
  138. const modelPromise = viewer.load('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf', {
  139. autoCenter: true,
  140. autoScale: true,
  141. })
  142. Promise.all([envPromise, modelPromise]).then(([env, model]) => {
  143. console.log('Loaded', model, env, viewer)
  144. })
  145. </script>
  146. ```
  147. Check it in action: https://threepipe.org/examples/#html-js-sample/
  148. Check out the details about the [ThreeViewer API](#viewer-api) and more [plugins](#threepipe-plugins) below.
  149. ### React
  150. A sample [react](https://react.dev) component in tsx to render a model with an environment map.
  151. ```tsx
  152. import React from 'react'
  153. function ThreeViewerComponent({src, env}: {src: string, env: string}) {
  154. const canvasRef = React.useRef(null)
  155. React.useEffect(() => {
  156. const viewer = new ThreeViewer({canvas: canvasRef.current})
  157. const envPromise = viewer.setEnvironmentMap(env)
  158. const modelPromise = viewer.load(src)
  159. Promise.all([envPromise, modelPromise]).then(([env, model]) => {
  160. console.log('Loaded', model, env, viewer)
  161. })
  162. return () => {
  163. viewer.dispose()
  164. }
  165. }, [])
  166. return (
  167. <canvas id="three-canvas" style={{width: 800, height: 600}} ref={canvasRef} />
  168. )
  169. }
  170. ```
  171. Check it in action: https://threepipe.org/examples/#react-tsx-sample/
  172. Other examples in js: https://threepipe.org/examples/#react-js-sample/ and jsx: https://threepipe.org/examples/#react-jsx-sample/
  173. ### Vue.js
  174. A sample [vue.js](https://vuejs.org/) component in js to render a model with an environment map.
  175. ```js
  176. const ThreeViewerComponent = {
  177. setup() {
  178. const canvasRef = ref(null);
  179. onMounted(() => {
  180. const viewer = new ThreeViewer({ canvas: canvasRef.value });
  181. const envPromise = viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr');
  182. const modelPromise = viewer.load('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf');
  183. Promise.all([envPromise, modelPromise]).then(([env, model]) => {
  184. console.log('Loaded', model, env, viewer)
  185. })
  186. onBeforeUnmount(() => {
  187. viewer.dispose();
  188. });
  189. });
  190. return { canvasRef };
  191. },
  192. };
  193. ```
  194. Check it in action: https://threepipe.org/examples/#vue-html-sample/
  195. Another example with Vue SFC(Single file component): https://threepipe.org/examples/#vue-sfc-sample/
  196. ### Svelte
  197. A sample [svelte](https://svelte.dev/) component in js to render a model with an environment map.
  198. ```html
  199. <script>
  200. import {onDestroy, onMount} from 'svelte';
  201. import {ThreeViewer} from 'threepipe';
  202. let canvasRef;
  203. let viewer;
  204. onMount(() => {
  205. viewer = new ThreeViewer({canvas: canvasRef});
  206. const envPromise = viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr');
  207. const modelPromise = viewer.load('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf');
  208. Promise.all([envPromise, modelPromise]).then(([env, model]) => {
  209. console.log('Loaded', model, env, viewer)
  210. })
  211. });
  212. onDestroy(() => viewer.dispose())
  213. </script>
  214. <canvas bind:this={canvasRef} id="three-canvas" style="width: 800px; height: 600px"></canvas>
  215. ```
  216. Check it in action: https://threepipe.org/examples/#svelte-sample/
  217. ### NPM/YARN
  218. ### Installation
  219. ```bash
  220. npm install threepipe
  221. ```
  222. ### Loading a 3D Model
  223. First, create a canvas element in your HTML page:
  224. ```html
  225. <canvas id="three-canvas" style="width: 800px; height: 600px;"></canvas>
  226. ```
  227. Then, import the viewer and create a new instance:
  228. ```typescript
  229. import {ThreeViewer, IObject3D} from 'threepipe'
  230. // Create a viewer
  231. const viewer = new ThreeViewer({canvas: document.getElementById('three-canvas') as HTMLCanvasElement})
  232. // Load an environment map
  233. await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr')
  234. // Load a model
  235. const result = await viewer.load<IObject3D>('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf', {
  236. autoCenter: true,
  237. autoScale: true,
  238. })
  239. ```
  240. That's it! You should now see a 3D model on your page.
  241. 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.
  242. 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.
  243. Check out the GLTF Load example to see it in action or to check the JS equivalent code: https://threepipe.org/examples/#gltf-load/
  244. Check out the [Plugins](#plugin-system) section below to learn how to add additional functionality to the viewer.
  245. ## License
  246. 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).
  247. 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.
  248. ## Status
  249. 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.
  250. Check out [WebGi](https://webgi.xyz/) for an advanced tailor-made solution for e-commerce, jewelry, automobile, apparel, furniture etc.
  251. ## Documentation
  252. Check the list of all functions, classes and types in the [API Reference Docs](https://threepipe.org/docs/).
  253. ## Contributing
  254. Contributions to ThreePipe are welcome and encouraged! Feel free to open issues and pull requests on the GitHub repository.