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.

Object3DWidgetsPlugin.md 1.7KB

1 ano atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. ---
  2. prev:
  3. text: 'EditorViewWidgetPlugin'
  4. link: './EditorViewWidgetPlugin'
  5. next:
  6. text: 'Object3DGeneratorPlugin'
  7. link: './Object3DGeneratorPlugin'
  8. ---
  9. # Object3DWidgetsPlugin
  10. [//]: # (todo: image)
  11. [Example](https://threepipe.org/examples/#object3d-widgets-plugin/) —
  12. [Source Code](https://github.com/repalash/threepipe/blob/master/src/plugins/extras/Object3DWidgetsPlugin.ts) —
  13. [API Reference](https://threepipe.org/docs/classes/Object3DWidgetsPlugin.html)
  14. Object3DWidgetsPlugin adds support for light and camera helpers/gizmos in the viewer.
  15. A helper is automatically created when any supported light or camera is added to the scene.
  16. Simply add the plugin to the viewer to see the widget.
  17. Support for additional types of helpers can be added dynamically or by other plugins by pushing a helper constructor to the `Object3DWidgetsPlugin.helpers` array, and calling `Object3DWidgetsPlugin.refresh()`.
  18. The helper class prototype should implement the `IObject3DHelper` interface. Check `DirectionalLightHelper2` for an example.
  19. ```typescript
  20. import {ThreeViewer, Object3DWidgetsPlugin, Object3DGeneratorPlugin} from 'threepipe'
  21. const viewer = new ThreeViewer({...})
  22. // Add the plugin to add support
  23. const plugin = viewer.addPluginSync(new Object3DWidgetsPlugin())
  24. // Add some lights or cameras to the scene. (This can be done before adding the plugin as well)
  25. // Using Object3DGeneratorPlugin to create a camera and add it to the scene.
  26. const generator = viewer.getOrAddPluginSync(Object3DGeneratorPlugin)
  27. generator.generate('camera-perspective', {
  28. position: new Vector3(5, 5, 0),
  29. name: 'My Camera'
  30. })
  31. // to hide the widgets
  32. plugin.enabled = false
  33. // to add support for a custom helper
  34. plugin.helpers.push(MyCustomHelper)
  35. plugin.refresh()
  36. ```