threepipe
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import {
  2. _testFinish,
  3. IObject3D,
  4. LoadingScreenPlugin,
  5. PickingPlugin,
  6. ThreeViewer,
  7. TransformControlsPlugin,
  8. } from 'threepipe'
  9. import {TweakpaneUiPlugin} from '@threepipe/plugin-tweakpane'
  10. async function init() {
  11. const viewer = new ThreeViewer({
  12. canvas: document.getElementById('mcanvas') as HTMLCanvasElement,
  13. renderScale: 'auto',
  14. plugins: [LoadingScreenPlugin],
  15. })
  16. viewer.scene.setBackgroundColor(0x151822)
  17. const picking = viewer.addPluginSync(PickingPlugin)
  18. const transformControlsPlugin = viewer.addPluginSync(TransformControlsPlugin)
  19. await viewer.setEnvironmentMap('https://threejs.org/examples/textures/equirectangular/venice_sunset_1k.hdr')
  20. const model = await viewer.load<IObject3D>('https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf')
  21. const ui = viewer.addPluginSync(new TweakpaneUiPlugin(true))
  22. ui.setupPluginUi(TransformControlsPlugin, {expanded: true})
  23. ui.setupPluginUi(PickingPlugin)
  24. // Get the underlying transform controls (instance of TransformControls2)
  25. const transformControls = transformControlsPlugin.transformControls
  26. console.log(transformControls)
  27. // Transform controls plugin automatically tracks the selected object in the PickingPlugin and shows the transform controls
  28. picking.setSelectedObject(model)
  29. }
  30. init().finally(_testFinish)