threepipe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VirtualCamerasPlugin.md 1.7KB

1 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ---
  2. prev:
  3. text: 'HDRiGroundPlugin'
  4. link: './HDRiGroundPlugin'
  5. next:
  6. text: 'EditorViewWidgetPlugin'
  7. link: './EditorViewWidgetPlugin'
  8. ---
  9. # VirtualCamerasPlugin
  10. [//]: # (todo: image)
  11. [Example](https://threepipe.org/examples/#virtual-cameras-plugin/) —
  12. [Source Code](https://github.com/repalash/threepipe/blob/master/src/plugins/rendering/VirtualCamerasPlugin.ts) —
  13. [API Reference](https://threepipe.org/docs/classes/VirtualCamerasPlugin.html)
  14. VirtualCamerasPlugin adds support for rendering to multiple virtual cameras in the viewer. These cameras are rendered in preRender callback just before the main camera is rendered. The virtual cameras can be added to the plugin and removed from it.
  15. The feed to the virtual camera is rendered to a Render Target texture which can be accessed and re-rendered in the scene or used in other plugins.
  16. ```typescript
  17. import {ThreeViewer, VirtualCamerasPlugin} from 'threepipe'
  18. const viewer = new ThreeViewer({...})
  19. const virtualCameras = viewer.addPluginSync(new VirtualCamerasPlugin())
  20. const camera = new PerspectiveCamera2('orbit', viewer.canvas, false, 45, 1)
  21. camera.name = name
  22. camera.position.set(0, 5, 0)
  23. camera.target.set(0, 0.25, 0)
  24. camera.userData.autoLookAtTarget = true // automatically look at the target (in setDirty)
  25. camera.setDirty()
  26. camera.addEventListener('update', ()=>{
  27. viewer.setDirty() // if the camera is not added to the scene it wont update automatically when camera.setDirty is called(like from the UI)
  28. })
  29. const vCam = virtualCameras.addCamera(camera)
  30. console.log(vCam.target) // target is a WebGLRenderTarget/IRenderTarget
  31. ```
  32. Check the [virtual camera](https://threepipe.org/examples/#virtual-camera/) example for using the texture in the scene.