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

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