ZoomAllTool.js 938 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * ZoomAllTool.js
  3. *
  4. * @author realor
  5. */
  6. import { Tool } from './Tool.js'
  7. import { ObjectUtils } from '../utils/ObjectUtils.js'
  8. class ZoomAllTool extends Tool {
  9. //适应屏幕
  10. constructor(application, options) {
  11. super(application)
  12. this.name = 'zoom_all'
  13. this.label = 'tool.zoom_all.label'
  14. this.help = 'tool.zoom_all.help'
  15. this.className = 'zoom_all'
  16. this.immediate = true
  17. this.setOptions(options)
  18. }
  19. execute() {
  20. const application = this.application
  21. const container = application.container
  22. const aspect = container.clientWidth / container.clientHeight
  23. const camera = application.camera
  24. application.scene.updateMatrixWorld(true)
  25. ObjectUtils.zoomAll(camera, application.baseObject, aspect)
  26. application.notifyObjectsChanged(camera, this)
  27. }
  28. }
  29. export { ZoomAllTool }