threepipe
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1 год назад
1 год назад
1234567891011121314151617181920212223242526272829303132333435363738394041
  1. ---
  2. prev:
  3. text: 'Object3DGeneratorPlugin'
  4. link: './Object3DGeneratorPlugin'
  5. next:
  6. text: 'PointerLockControlsPlugin'
  7. link: './PointerLockControlsPlugin'
  8. ---
  9. # DeviceOrientationControlsPlugin
  10. [//]: # (todo: image)
  11. [Example](https://threepipe.org/examples/#device-orientation-controls-plugin/) —
  12. [Source Code](https://github.com/repalash/threepipe/blob/master/src/plugins/interaction/DeviceOrientationControlsPlugin.ts) —
  13. [API Reference](https://threepipe.org/docs/classes/DeviceOrientationControlsPlugin.html)
  14. DeviceOrientationControlsPlugin enables controlling the main camera rotation in the scene with device orientation. This only works on devices which have a gyroscope(but can also be emulated in devtools in chrome).
  15. After the plugin is added, it adds support for setting `deviceOrientation` as the key in `scene.mainCamera.controlMode`.
  16. When the controls are started (for the first time), the current camera rotation is and the device orientation is saved and used as reference. To reset the saved device orientation, call `resetView` in the controls.
  17. Sample Usage
  18. ```typescript
  19. import {ThreeViewer, DeviceOrientationControlsPlugin, Mesh2} from 'threepipe'
  20. const viewer = new ThreeViewer({...})
  21. viewer.addPluginSync(DeviceOrientationControlsPlugin)
  22. // after some user action
  23. viewer.scene.mainCamera.controlsMode = 'deviceOrientation'
  24. // to reset the saved device orientation
  25. viewer.scene.mainCamera.controls.resetView()
  26. // switch back to default orbit controls
  27. viewer.scene.mainCamera.controlsMode = 'orbit'
  28. ```