threepipe
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

script.ts 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import {
  2. _testFinish, _testStart,
  3. AssetExporterPlugin,
  4. IObject3D,
  5. LoadingScreenPlugin,
  6. SceneUiConfigPlugin,
  7. ThreeViewer,
  8. } from 'threepipe'
  9. import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane'
  10. import {AWSClientPlugin} from '@threepipe/plugin-network'
  11. async function init() {
  12. const viewer = new ThreeViewer({
  13. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  14. msaa: true,
  15. plugins: [SceneUiConfigPlugin, LoadingScreenPlugin],
  16. })
  17. viewer.getPlugin(LoadingScreenPlugin)!.minimizeOnSceneObjectLoad = false
  18. const awsPlugin = viewer.addPluginSync(new AWSClientPlugin())
  19. // set parameters and export. This can all be done from the UI also.
  20. awsPlugin.accessKeyId = '00000000000000000000'
  21. awsPlugin.accessKeySecret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
  22. awsPlugin.endpointURL = 'https://s3.amazonaws.com/bucket/'
  23. awsPlugin.pathPrefix = 'some/path/'
  24. // or load a json file with the parameters
  25. // the json file can be creating by entering the data in the UI and clicking the download preset json option.
  26. // await viewer.load('file.json')
  27. // export and upload
  28. // const blob = await viewer.exportScene()
  29. // this will upload to s3 if the plugin parameters are set up correctly
  30. // await viewer.exportBlob(blob, 'file.glb')
  31. const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true))
  32. await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr', {
  33. setBackground: true,
  34. })
  35. const modelUrl = 'https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf'
  36. const result = await viewer.load<IObject3D>(modelUrl, {
  37. autoCenter: true,
  38. autoScale: true,
  39. })
  40. ui.setupPluginUi(AssetExporterPlugin, {expanded: true})
  41. ui.setupPluginUi(AWSClientPlugin, {expanded: true})
  42. ui.setupPluginUi(SceneUiConfigPlugin)
  43. const model = result?.getObjectByName('node_damagedHelmet_-6514')
  44. const config = model?.uiConfig
  45. if (config) ui.appendChild(config)
  46. }
  47. _testStart()
  48. init().finally(_testFinish)