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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. ## @threepipe/plugin-tweakpane
  2. [Tweakpane](https://tweakpane.github.io/docs/) UI plugin for ThreePipe
  3. [//]: # (todo: image)
  4. [Example](https://threepipe.org/examples/#tweakpane-ui-plugin/) —
  5. [Source Code](https://github.com/repalash/threepipe/blob/master/plugins/tweakpane/src/TweakpaneUiPlugin.ts) —
  6. [API Reference](https://threepipe.org/plugins/tweakpane/docs/classes/TweakpaneUiPlugin.html)
  7. [![NPM Package](https://img.shields.io/npm/v/@threepipe/plugin-tweakpane.svg)](https://www.npmjs.com/package/@threepipe/plugin-tweakpane)
  8. ```bash
  9. npm install @threepipe/plugin-tweakpane
  10. ```
  11. TweakpaneUiPlugin adds support for using [uiconfig-tweakpane](https://github.com/repalash/uiconfig-tweakpane)
  12. to create a configuration UI in applications using the [Tweakpane](https://tweakpane.github.io/docs/) library.
  13. The plugin takes the [uiconfig](https://github.com/repalash/uiconfig.js)
  14. that's defined in the viewer and all the objects to automatically render a UI in the browser.
  15. ```typescript
  16. import {IObject3D, ThreeViewer, TonemapPlugin} from 'threepipe'
  17. import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane'
  18. const viewer = new ThreeViewer({...})
  19. // Add the plugin
  20. const plugin = viewer.addPluginSync(new TweakpaneUiPlugin(true)) // true to show expanded the UI by default
  21. // Add the UI for the viewer
  22. plugin.appendChild(viewer.uiConfig)
  23. // Add UI for some plugins
  24. plugin.setupPlugins(TonemapPlugin, DropzonePlugin)
  25. ```
  26. ## @threepipe/plugin-blueprintjs
  27. [Blueprint.js](https://blueprintjs.com/) UI plugin for ThreePipe
  28. [//]: # (todo: image)
  29. [Example](https://threepipe.org/examples/#blueprintjs-ui-plugin/) —
  30. [Source Code](https://github.com/repalash/threepipe/blob/master/plugins/blueprintjs/src/BlueprintJsUiPlugin.ts) —
  31. [API Reference](https://threepipe.org/plugins/blueprintjs/docs/classes/BlueprintJsUiPlugin.html)
  32. [![NPM Package](https://img.shields.io/npm/v/@threepipe/plugin-blueprintjs.svg)](https://www.npmjs.com/package/@threepipe/plugin-blueprintjs)
  33. ```bash
  34. npm install @threepipe/plugin-blueprintjs
  35. ```
  36. BlueprintJsUiPlugin adds support for using [uiconfig-blueprint](https://github.com/repalash/uiconfig-blueprint)
  37. to create a configuration UI in applications using the [BlueprintJs](https://blueprintjs.com/) library.
  38. The plugin takes the [uiconfig](https://github.com/repalash/uiconfig.js)
  39. that's defined in the viewer and all the objects to automatically render a UI in the browser.
  40. ```typescript
  41. import {IObject3D, ThreeViewer, TonemapPlugin} from 'threepipe'
  42. import {BlueprintJsUiPlugin} from '@threepipe/plugin-blueprintjs'
  43. const viewer = new ThreeViewer({...})
  44. // Add the plugin
  45. const plugin = viewer.addPluginSync(new BlueprintJsUiPlugin(true)) // true to show expanded the UI by default
  46. // Add the UI for the viewer
  47. plugin.appendChild(viewer.uiConfig)
  48. // Add UI for some plugins
  49. plugin.setupPlugins(TonemapPlugin, DropzonePlugin)
  50. ```
  51. ## @threepipe/plugin-tweakpane-editor
  52. Tweakpane Editor Plugin for ThreePipe
  53. [//]: # (todo: image)
  54. [Example](https://threepipe.org/examples/#tweakpane-editor/) —
  55. [Source Code](https://github.com/repalash/threepipe/blob/master/plugins/tweakpane-editor/src/TweakpaneEditorPlugin.ts) —
  56. [API Reference](https://threepipe.org/plugins/tweakpane-editor/docs/classes/TweakpaneEditorPlugin.html)
  57. [![NPM Package](https://img.shields.io/npm/v/@threepipe/plugin-tweakpane-editor.svg)](https://www.npmjs.com/package/@threepipe/plugin-tweakpane-editor)
  58. ```bash
  59. npm install @threepipe/plugin-tweakpane-editor
  60. ```
  61. `TweakpaneEditorPlugin` uses `TweakpaneUiPlugin` and other custom ui to create an editor for editing viewer, plugins, model and material configurations in the browser.
  62. ```typescript
  63. import {IObject3D, ThreeViewer, TonemapPlugin} from 'threepipe'
  64. import {TweakpaneEditorPlugin} from '@threepipe/plugin-tweakpane-editor'
  65. const viewer = new ThreeViewer({...})
  66. viewer.addPluginSync(new TweakpaneUiPlugin(true))
  67. const editor = viewer.addPluginSync(new TweakpaneEditorPlugin())
  68. // Add some plugins to the viewer
  69. await viewer.addPlugins([
  70. new ViewerUiConfigPlugin(),
  71. // new SceneUiConfigPlugin(), // this is already in ViewerUiPlugin
  72. new DepthBufferPlugin(HalfFloatType, true, true),
  73. new NormalBufferPlugin(HalfFloatType, false),
  74. new RenderTargetPreviewPlugin(false),
  75. ])
  76. // Load the plugin UI in the editor and tweakpane ui with categories.
  77. editor.loadPlugins({
  78. ['Viewer']: [ViewerUiConfigPlugin, SceneUiConfigPlugin, DropzonePlugin, FullScreenPlugin],
  79. ['GBuffer']: [DepthBufferPlugin, NormalBufferPlugin],
  80. ['Post-processing']: [TonemapPlugin],
  81. ['Debug']: [RenderTargetPreviewPlugin],
  82. })
  83. ```
  84. ## @threepipe/plugin-configurator
  85. Configurator Plugin implementations with basic UI for Threepipe.
  86. Includes Material Configurator and Switch Node Configurator Plugins.
  87. [![NPM Package](https://img.shields.io/npm/v/@threepipe/plugin-configurator.svg)](https://www.npmjs.com/package/@threepipe/plugin-configurator)
  88. ```bash
  89. npm install @threepipe/plugin-configurator
  90. ```
  91. ### MaterialConfiguratorPlugin
  92. [//]: # (todo: image)
  93. [Example](https://threepipe.org/examples/#material-configurator-plugin/) —
  94. [Source Code](https://github.com/repalash/threepipe/blob/master/plugins/configurator/src/MaterialConfiguratorPlugin.ts) —
  95. [API Reference](https://threepipe.org/plugins/configurator/docs/classes/MaterialConfiguratorPlugin.html)
  96. MaterialConfiguratorPlugin adds a UI to configure and switch between different material variations.
  97. The variations of materials are mapped to material names or uuids in the scene.
  98. These variations can be applied to the materials in the scene. (This copies the properties to the same material instances instead of assigning new materials)
  99. The plugin interfaces with the picking plugin and also provides uiConfig to show and edit the variations.
  100. This functionality is inherited from [MaterialConfiguratorBasePlugin](https://threepipe.org/docs/classes/MaterialConfiguratorBasePlugin.html).
  101. Additionally, this plugin adds a simple Grid UI in the DOM over the viewer canvas to show various material variations and allow the user to apply them.
  102. The UI can also be used in the editor to edit the variations and apply them.
  103. To use, simply add the plugin in the viewer and configure using the created UI and UI Config. Note that `PickingPlugin` is required to be added before this to allow configurator.
  104. To create a custom configurator UI, use the `MaterialConfiguratorBasePlugin` directly and call the function `applyVariation`, `getPreview` and `addVariation` to apply and add variations respectively.
  105. [//]: # (TODO Add Example for custom UI)
  106. ### SwitchNodePlugin
  107. [//]: # (todo: image)
  108. [Example](https://threepipe.org/examples/#switch-node-plugin/) —
  109. [Source Code](https://github.com/repalash/threepipe/blob/master/plugins/configurator/src/SwitchNodePlugin.ts) —
  110. [API Reference](https://threepipe.org/plugins/configurator/docs/classes/SwitchNodePlugin.html)
  111. SwitchNodePlugin adds a UI to configure and switch between different different object variations within a switch node object.
  112. This plugin allows you to configure object variations with object names in a file and apply them in the scene.
  113. Each SwitchNode is a parent object with multiple direct children. Only one child is visible at a time.
  114. This works by toggling the `visible` property of the children of a parent object.
  115. The plugin interfaces with the picking plugin and also provides uiConfig to show and edit the variations.
  116. It also provides a function to create snapshot previews of individual variations. This creates a limited render of the object with the selected child visible.
  117. To get a proper render, its better to render it offline and set the image as a preview.
  118. This functionality is inherited from [SwitchNodeBasePlugin](https://threepipe.org/docs/classes/SwitchNodeBasePlugin.html).
  119. Additionally, this plugin adds a simple Grid UI in the DOM over the viewer canvas to show various material variations and allow the user to apply them.
  120. The UI can also be used in the editor to edit the variations and apply them.
  121. To use, simply add the plugin in the viewer and configure using the created UI and UI Config. Note that `PickingPlugin` is required to be added before this to allow configurator.
  122. To create a custom configurator UI, use the `SwitchNodeBasePlugin` directly and call the function `selectNode`, `getPreview` and `addNode` to apply and add variations respectively.
  123. [//]: # (TODO Add Example for custom UI)
  124. ## @threepipe/plugin-geometry-generator
  125. Exports [GeometryGeneratorPlugin](https://threepipe.org/plugins/geometry-generator/docs/classes/BlendLoadPlugin.html) with several Geometry generators to create parametric and updatable geometries like plane, circle, sphere, box, torus, cylinder, cone etc.
  126. [Example](https://threepipe.org/examples/#geometry-generator-plugin/) —
  127. [Source Code](https://github.com/repalash/threepipe/blob/master/plugins/geometry-generator/src/index.ts) —
  128. [API Reference](https://threepipe.org/plugins/geometry-generator/docs)
  129. [![NPM Package](https://img.shields.io/npm/v/@threepipe/plugin-geometry-generator.svg)](https://www.npmjs.com/package/@threepipe/plugin-geometry-generator)
  130. ```bash
  131. npm install @threepipe/plugin-geometry-generator
  132. ```
  133. The generated geometries/meshes include the parameters in the userData and can be re-generated by changing the parameters from the UI or the plugin API.
  134. Includes the following generator which inherit from [AGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/AGeometryGenerator.html):
  135. - **plane**: [PlaneGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/PlaneGeometryGenerator),
  136. - **sphere**: [SphereGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/SphereGeometryGenerator),
  137. - **box**: [BoxGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/BoxGeometryGenerator),
  138. - **circle**: [CircleGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/CircleGeometryGenerator),
  139. - **torus**: [TorusGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/TorusGeometryGenerator),
  140. - **cylinder**: [CylinderGeometryGenerator](https://threepipe.org/plugins/geometry-generator/docs/classes/CylinderGeometryGenerator),
  141. Sample Usage:
  142. ```typescript
  143. import {ThreeViewer, UnlitMaterial} from 'threepipe'
  144. import {GeometryGeneratorPlugin} from '@threepipe/plugin-geometry-generator'
  145. const viewer = new ThreeViewer({...})
  146. const generator = viewer.addPluginSync(GeometryGeneratorPlugin)
  147. const sphere = generator.generateObject('sphere', {radius: 3})
  148. viewer.scene.addObject(sphere)
  149. // to update the geometry
  150. generator.updateGeometry(sphere.geometry, {radius: 4, widthSegments: 100})
  151. // to add a custom generator
  152. generator.generators.custom = new CustomGenerator('custom') // Extend from AGeometryGenerator or implement GeometryGenerator interface
  153. // refresh the ui so the new generator is available to select.
  154. generator.uiConfig.uiRefresh?.()
  155. // change the material type for all objects
  156. generator.defaultMaterialClass = UnlitMaterial // by default its PhysicalMaterial
  157. viewer.scene.addObject(generator.generateObject('box', {width: 2, height: 2, depth: 2}))
  158. ```
  159. ## @threepipe/plugin-gltf-transform
  160. Exports [GLTFDracoExportPlugin](https://threepipe.org/plugins/gltf-transform/docs/classes/GLTFDracoExportPlugin.html) that extends the default gltf exporter to compress the file after export.
  161. [Example](https://threepipe.org/examples/#glb-draco-export/) —
  162. [Source Code](plugins/gltf-transform/src/index.ts) —
  163. [API Reference](https://threepipe.org/plugins/gltf-transform/docs)
  164. [![NPM Package](https://img.shields.io/npm/v/@threepipe/plugin-gltf-transform.svg)](https://www.npmjs.com/package/@threepipe/plugin-gltf-transform)
  165. ```bash
  166. npm install @threepipe/plugin-gltf-transform
  167. ```
  168. To use, simply add the plugin to the viewer and export using the `viewer.export` or `viewer.exportScene` functions. This also adds UI options to `AssetExporterPlugin` which are used when exporting using the plugin or using `viewer.exportScene`
  169. The plugin overloads the default gltf exporter in the asset manager with `GLTFDracoExporter`. Using the [gltf-transform](https://gltf-transform.donmccurdy.com/) library, it compresses the exported gltf file using the [khr_draco_mesh_compression](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_draco_mesh_compression/README.md) extension.
  170. Note - Only `glb` export supported right now.
  171. Sample Usage:
  172. ```typescript
  173. import {ThreeViewer, downloadBlob} from 'threepipe'
  174. import {GLTFDracoExportPlugin} from '@threepipe/plugin-gltf-transform'
  175. const viewer = new ThreeViewer({...})
  176. viewer.addPluginSync(GLTFDracoExportPlugin)
  177. await viewer.load('file.glb')
  178. const blob = await viewer.exportScene({
  179. compress: true, // this must be specified, by default it's false.
  180. viewerConfig: true, // to export with viewer, scene and plugin settings
  181. })
  182. // download the file
  183. downloadBlob(blob, 'scene.glb')
  184. ```
  185. ## @threepipe/plugins-extra-importers
  186. Exports several plugins to add support for various file types.
  187. [Example](https://threepipe.org/examples/#extra-importer-plugins/) —
  188. [Source Code](https://github.com/repalash/threepipe/blob/master/plugins/extra-importers/src/index.ts) —
  189. [API Reference](https://threepipe.org/plugins/extra-importers/docs)
  190. [![NPM Package](https://img.shields.io/npm/v/@threepipe/plugins-extra-importers.svg)](https://www.npmjs.com/package/@threepipe/plugins-extra-importers)
  191. ```bash
  192. npm install @threepipe/plugins-extra-importers
  193. ```
  194. This package exports several plugins to add support for several file types using the following plugins
  195. - [TDSLoadPlugin](https://threepipe.org/plugins/extra-importers/docs/classes/TDSLoadPlugin.html) - Load 3DS Max (.3ds) files
  196. - [ThreeMFLoadPlugin](https://threepipe.org/plugins/extra-importers/docs/classes/ThreeMFLoadPlugin.html) - Load 3MF (.3mf) files
  197. - [ColladaLoadPlugin](https://threepipe.org/plugins/extra-importers/docs/classes/ColladaLoadPlugin.html) - Load Collada (.dae) files
  198. - [AMFLoadPlugin](https://threepipe.org/plugins/extra-importers/docs/classes/AMFLoadPlugin.html) - Load AMF (.amf) files
  199. - [BVHLoadPlugin](https://threepipe.org/plugins/extra-importers/docs/classes/BVHLoadPlugin.html) - Load BVH (.bvh) files
  200. - [VOXLoadPlugin](https://threepipe.org/plugins/extra-importers/docs/classes/VOXLoadPlugin.html) - Load MagicaVoxel (.vox) files
  201. - [GCodeLoadPlugin](https://threepipe.org/plugins/extra-importers/docs/classes/GCodeLoadPlugin.html) - Load GCode (.gcode) files
  202. - [MDDLoadPlugin](https://threepipe.org/plugins/extra-importers/docs/classes/MDDLoadPlugin.html) - Load MDD (.mdd) files
  203. - [PCDLoadPlugin](https://threepipe.org/plugins/extra-importers/docs/classes/PCDLoadPlugin.html) - Load Point cloud data (.pcd) files
  204. - [TiltLoadPlugin](https://threepipe.org/plugins/extra-importers/docs/classes/TiltLoadPlugin.html) - Load Tilt Brush (.tilt) files
  205. - [VRMLLoadPlugin](https://threepipe.org/plugins/extra-importers/docs/classes/VRMLLoadPlugin.html) - Load VRML (.wrl) files
  206. - [MPDLoadPlugin](https://threepipe.org/plugins/extra-importers/docs/classes/MPDLoadPlugin.html) - Load LDraw (.mpd) files
  207. - [VTKLoadPlugin](https://threepipe.org/plugins/extra-importers/docs/classes/VTKLoadPlugin.html) - Load VTK (.vtk) files
  208. - [XYZLoadPlugin](https://threepipe.org/plugins/extra-importers/docs/classes/XYZLoadPlugin.html) - Load XYZ (.xyz) files
  209. To add all the plugins at once use `extraImporters`. This adds support for loading all the above file types.
  210. ```typescript
  211. import {ThreeViewer} from 'threepipe'
  212. import {extraImporters} from '@threepipe/plugins-extra-importers'
  213. const viewer = new ThreeViewer({...})
  214. viewer.addPluginsSync(extraImporters)
  215. // Now load any file as is.
  216. const model = await viewer.load<IObject3D>('file.3mf')
  217. // To load the file as a data url, use the correct mimetype
  218. const model1 = await viewer.load<IObject3D>('data:model/3mf;base64,...')
  219. ```
  220. Remove the `<IObject3D>` if using javascript and not typescript.
  221. ## @threepipe/plugin-network
  222. Network/Cloud related plugin implementations for Threepipe.
  223. Includes `AWSClientPlugin` and `TransfrSharePlugin`.
  224. [![NPM Package](https://img.shields.io/npm/v/@threepipe/plugin-network.svg)](https://www.npmjs.com/package/@threepipe/plugin-network)
  225. ```bash
  226. npm install @threepipe/plugin-network
  227. ```
  228. ### TransfrSharePlugin
  229. [//]: # (todo: image)
  230. [Example](https://threepipe.org/examples/#transfr-share-plugin/) &mdash;
  231. [Source Code](https://github.com/repalash/threepipe/blob/master/plugins/network/src/TransfrSharePlugin.ts) &mdash;
  232. [API Reference](https://threepipe.org/plugins/network/docs/classes/TransfrSharePlugin.html)
  233. TransfrSharePlugin provides functionality to export and upload the scene or an object as glb and provide link to share/preview/edit the files.
  234. It uses the options from the `AssetExporterPlugin` to export the scene or object, and can be configured using it's ui.
  235. Uses the free service [transfr.one](https://transfr.one/) by default which deletes the files after a certain time, but the url can be changed to a custom backend or a self-hosted version of transfr.
  236. ::: tip Note
  237. Since the uploaded files are publicly accessible by anyone by default, it is recommended to encrypt the file using the exporter options or use a secure backend.
  238. :::
  239. ```typescript
  240. import {ThreeViewer} from 'threepipe'
  241. import {TransfrSharePlugin} from '@threepipe/plugin-network'
  242. const viewer = new ThreeViewer({...})
  243. // Add the plugin
  244. const sharePlugin = viewer.addPluginSync(new TransfrSharePlugin())
  245. // when sharing, this query param is set to the model link
  246. sharePlugin.queryParam = 'm' // this is the default
  247. // used when clicking/calling Share page link
  248. sharePlugin.pageUrl = window.location.href // this is the default
  249. // used when clicking/calling Share viewer link
  250. sharePlugin.baseUrls.viewer = 'https://threepipe.org/examples/model-viewer/index.html'
  251. // used when clicking/calling Share editor link
  252. sharePlugin.baseUrls.editor = 'https://threepipe.org/examples/tweakpane-editor/index.html'
  253. // set to a custom server
  254. // sharePlugin.serverUrl = 'https://example.com/'
  255. // upload and get the link of the 3d model
  256. const link = await sharePlugin.getLink()
  257. // or upload and get the share link with a base page. And also copy to clipboard and shows a alert prompt(using viewer.dialog)
  258. const link2 = await sharePlugin.shareLink('https://example.com/custom_viewer')
  259. // or get the editor link directly
  260. const link3 = await sharePlugin.shareEditorLink()
  261. // to encrypt
  262. const assetExporterPlugin = viewer.getPlugin(AssetExporterPlugin) // this is a dependency, so automatically added
  263. assetExporterPlugin.encrypt = true
  264. // assetExporterPlugin.encryptKey = 'password' // user will be prompted for password when exporting if this is commented
  265. await sharePlugin.shareViewerLink()
  266. ```
  267. ### AWSClientPlugin
  268. [//]: # (todo: image)
  269. [Example](https://threepipe.org/examples/#aws-client-plugin/) &mdash;
  270. [Source Code](https://github.com/repalash/threepipe/blob/master/plugins/network/src/AWSClientPlugin.ts) &mdash;
  271. [API Reference](https://threepipe.org/plugins/network/docs/classes/AWSClientPlugin.html)
  272. Provides `fetch` function that performs a fetch request with AWS v4 signing.
  273. This is useful for connecting to AWS services like S3 directly from the client.
  274. It also interfaces with the `FileTransferPlugin` to directly upload file when exported with the viewer or the plugin.
  275. ::: danger Note
  276. Make sure to use keys with limited privileges and correct CORS settings.
  277. All the keys will be stored in plain text if `serializeSettings` is set to true
  278. :::
  279. ```typescript
  280. import {ThreeViewer} from 'threepipe'
  281. import {AWSClientPlugin} from '@threepipe/plugin-network'
  282. const viewer = new ThreeViewer({...})
  283. const awsPlugin = viewer.addPluginSync(new AWSClientPlugin())
  284. // set parameters and export. This can all be done from the UI also.
  285. awsPlugin.accessKeyId = '00000000000000000000'
  286. awsPlugin.accessKeySecret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
  287. awsPlugin.endpointURL = 'https://s3.amazonaws.com/bucket/'
  288. awsPlugin.pathPrefix = 'some/path/'
  289. // or load a json file with the parameters
  290. // the json file can be creating by entering the data in the UI and clicking the download preset json option.
  291. await viewer.load('file.json')
  292. // this will export the scene as glb
  293. const blob = await viewer.exportScene()
  294. // for a plugin config
  295. // blob = await viewer.export(viewer.getPlugin(GroundPlugin))
  296. // for a material
  297. // blob = await viewer.export(object.material)
  298. // for an object/mesh
  299. // blob = await viewer.export(object, {exportExt: 'glb'})
  300. // upload to s3. needs the parameters to be correct
  301. await viewer.exportBlob(blob, 'filename.glb')
  302. ```
  303. ::: tip Note
  304. CORS should be enabled for the S3 bucket on the domain where the viewer is hosted. This requirement can be bypassed during development by setting `AWSClientPlugin.USE_PROXY = true`. A free proxy is already set by default and can be changed by setting `AWSClientPlugin.PROXY_URL`.
  305. :::
  306. ## @threepipe/plugin-blend-importer
  307. Exports [BlendImporterPlugin](https://threepipe.org/plugins/blend-importer/docs/classes/BlendLoadPlugin.html) which adds support for loading .blend files.
  308. It uses [js.blend](https://github.com/acweathersby/js.blend) for parsing blend file structure.
  309. ::: warning Note
  310. This is still a WIP.
  311. :::
  312. Currently working: `Mesh`, `BufferGeometry` and basic `PointLight`.
  313. To be added: `PhysicalMaterial`, `UnlitMaterial` (similar to blender-gltf-io plugin)
  314. [Example](https://threepipe.org/examples/#blend-load/) &mdash;
  315. [Source Code](https://github.com/repalash/threepipe/blob/master/plugins/blend-importer/src/index.ts) &mdash;
  316. [API Reference](https://threepipe.org/plugins/blend-importer/docs)
  317. [![NPM Package](https://img.shields.io/npm/v/@threepipe/plugin-blend-importer.svg)](https://www.npmjs.com/package/@threepipe/plugin-blend-importer)
  318. ```bash
  319. npm install @threepipe/plugin-blend-importer
  320. ```
  321. ```typescript
  322. import {ThreeViewer} from 'threepipe'
  323. import {BlendLoadPlugin} from '@threepipe/plugin-blend-importer'
  324. const viewer = new ThreeViewer({...})
  325. viewer.addPluginSync(BlendLoadPlugin)
  326. // Now load any .blend file.
  327. const model = await viewer.load<IObject3D>('path/to/file.blend')
  328. // To load the file as a data url, use the correct mimetype
  329. const model1 = await viewer.load<IObject3D>('data:application/x-blender;base64,...')
  330. ```
  331. [//]: # ( TODO: The plugin should parse and references to other assets and find them relative to the .blend file or the current location.)
  332. ## @threepipe/plugin-gaussian-splatting
  333. Exports [GaussianSplattingPlugin](https://threepipe.org/plugins/gaussian-splatting/docs/classes/GaussianSplattingPlugin.html) which adds support for loading .blend files.
  334. It uses [`three-gaussian-splat`](https://github.com/repalash/threepipe/blob/master/plugins/gaussian-splatting/src/three-gaussian-splat), a rewrite of [@zappar/three-guassian-splat](https://github.com/zappar-xr/three-gaussian-splat) (and [gsplat.js](https://github.com/huggingface/gsplat.js) and [antimatter15/splat](https://github.com/antimatter15/splat)) for loading splat files and rendering gaussian splats.
  335. [Example](https://threepipe.org/examples/#splat-load/) &mdash;
  336. [Source Code](https://github.com/repalash/threepipe/blob/master/plugins/gaussian-splatting/src/index.ts) &mdash;
  337. [API Reference](https://threepipe.org/plugins/gaussian-splatting/docs)
  338. [![NPM Package](https://img.shields.io/npm/v/@threepipe/plugin-gaussian-splatting.svg)](https://www.npmjs.com/package/@threepipe/plugin-gaussian-splatting)
  339. ```bash
  340. npm install @threepipe/plugin-gaussian-splatting
  341. ```
  342. ::: warning Note
  343. This is still a WIP.
  344. :::
  345. Currently working:
  346. * Importing .splat files (just array buffer of gaussian splat attributes)
  347. * ThreeGaussianSplatPlugin (Same as GaussianSplattingPlugin), add importer and update events to the viewer
  348. * GaussianSplatMaterialExtension for adding gaussian splat functionality to any material like Unlit, Physical
  349. * GaussianSplatMesh a subclass of Mesh2 for holding the gaussian splat geometry and a material with gaussian splat extension. also handles basic raycast in the splat geometry. (assuming simple points)
  350. * GaussianSplatGeometry holds the geometry data and and the sort worker. Computes correct bounding box and sphere.
  351. * SplatLoader for loading splat files and creating the geometry and material.
  352. * GaussianSplatMaterialUnlit, GaussianSplatMaterialRaw
  353. * GaussianSplatMaterialPhysical, working but normals are hardcoded to 0,1,0
  354. TBD:
  355. * Exporting/embedding splat files into glb
  356. * Rendering to depth/gbuffer
  357. * Estimate normals/read from file
  358. * Lighting in GaussianSplatMaterialPhysical
  359. ```typescript
  360. import {ThreeViewer} from 'threepipe'
  361. import {GaussianSplattingPlugin} from '@threepipe/plugin-gaussian-splatting'
  362. const viewer = new ThreeViewer({...})
  363. viewer.addPluginSync(GaussianSplattingPlugin)
  364. // Now load any .splat file.
  365. const model = await viewer.load<GaussianSplatMesh>('path/to/file.splat')
  366. ```
  367. ## @threepipe/plugin-svg-renderer
  368. Exports [ThreeSVGRendererPlugin](https://threepipe.org/plugins/svg-renderer/docs/classes/ThreeSVGRendererPlugin.html) and [BasicSVGRendererPlugin](https://threepipe.org/plugins/svg-renderer/docs/classes/BasicSVGRendererPlugin.html) which provide support for rendering the 3d scene as [SVG(Scalable Vector Graphics)](https://developer.mozilla.org/en-US/docs/Web/SVG). The generated SVG is compatible with browser rendering and other software like figma, illustrator etc.
  369. [Example](https://threepipe.org/examples/#three-svg-renderer/) &mdash;
  370. [Source Code](https://github.com/repalash/threepipe/blob/master/plugins/svg-renderer/src/index.ts) &mdash;
  371. [API Reference](https://threepipe.org/plugins/svg-renderer/docs) &mdash;
  372. [GPLV3 License](https://github.com/repalash/threepipe/blob/master/plugins/svg-renderer/LICENSE)
  373. [![NPM Package](https://img.shields.io/npm/v/@threepipe/plugin-network.svg)](https://www.npmjs.com/package/@threepipe/plugin-svg-renderer)
  374. ```bash
  375. npm install @threepipe/plugin-svg-renderer
  376. ```
  377. ::: warning Note
  378. This is still a WIP. API might change a bit
  379. :::
  380. `ThreeSVGRendererPlugin` uses [`three-svg-renderer`](https://github.com/repalash/threepipe/blob/master/plugins/svg-renderer/src/three-svg-renderer), which is a modified version of [three-svg-renderer](https://www.npmjs.com/package/three-svg-renderer) (GPLV3 Licenced).
  381. The plugin renderers meshes in the viewer scene to svg objects by computing polygons and contours of the geometry in view space. Check [LokiResearch/three-svg-renderer](https://github.com/LokiResearch/three-svg-renderer?tab=readme-ov-file#references) for more details.
  382. In the modified version that is used here, support for some types of geometries is added and a rendered image in screen-space is used to create raster fill images for paths along with some other small changes. Check out the [Example](https://threepipe.org/examples/#three-svg-renderer/) for demo. See also [svg-geometry-playground example](https://threepipe.org/examples/#svg-geometry-playground/) for usage with other plugins `PickingPlugin`, `TransformControlsPlugin` and `GeometryGeneratorPlugin`.
  383. Note that this does not support all the features of three.js and may not work with all types of materials and geometries. Check the examples for a list of sample models that do and don't work.
  384. `BasicSVGRendererPlugin` is a sample plugin using [SVGRenderer](https://threejs.org/docs/index.html?q=svg#examples/en/renderers/SVGRenderer) from three.js addons. This renders all triangles in the scene to separate svg paths. Check the three.js docs for more details. Check out the [Example](https://threepipe.org/examples/#basic-svg-renderer/) for demo.
  385. ```typescript
  386. import {ThreeViewer} from 'threepipe'
  387. import {ThreeSVGRendererPlugin} from '@threepipe/plugin-svg-renderer'
  388. const viewer = new ThreeViewer({
  389. ...,
  390. rgbm: false, // this is required
  391. })
  392. const svgRender = viewer.addPluginSync(ThreeSVGRendererPlugin)
  393. svgRender.autoRender = true // automatically render when camera or any object changes.
  394. svgRender.autoMakeSvgObjects = true // automatically create SVG objects for all meshes in the scene.
  395. // svgRender.makeSVGObject(object) // manually create SVG object for an object. (if autoMakeSvgObjects is false)
  396. // Now load or generate any 3d model. Make sure its not very big. And the meshes are optimized.
  397. const model = await viewer.load<IOBject3D>('path/to/file.glb')
  398. // clear the background of the viewer
  399. viewer.scene.backgroundColor = null
  400. viewer.scene.background = null
  401. // disable damping to get better experience.
  402. viewer.scene.mainCamera.controls!.enableDamping = false
  403. // hide the canvas to see the underlying svg node.
  404. // note: do not set the display to none or remove the canvas as OrbitControls and other plugins might still be tracking the canvas.
  405. viewer.canvas.style.opacity = '0'
  406. // 3d pipeline can also be disabled like this if `drawImageFills` is `false` to get better performance. Do this only after loading the model.
  407. // await viewer.doOnce('postFrame') // wait for the first frame to be rendered (for autoScale etc)
  408. // viewer.renderManager.autoBuildPipeline = false
  409. // viewer.renderManager.pipeline = [] // this will disable main viewer rendering
  410. ```