threepipe
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

README.md 20KB

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