threepipe
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import {
  2. _testFinish,
  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. init().finally(_testFinish)