ResetMatrixTool.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * ResetMatrixTool.js
  3. *
  4. * @author realor
  5. */
  6. import { Tool } from './Tool.js'
  7. import { Solid } from '../core/Solid.js'
  8. class ResetMatrixTool extends Tool {
  9. constructor(application, options) {
  10. super(application)
  11. this.name = 'reset_matrix'
  12. this.label = 'tool.reset_matrix.label'
  13. this.className = 'reset_matrix'
  14. this.immediate = true
  15. this.setOptions(options)
  16. }
  17. execute() {
  18. const application = this.application
  19. let object = application.selection.object
  20. if (object.geometry) {
  21. object.geometry.applyMatrix4(object.matrix)
  22. if (object instanceof Solid) {
  23. object.updateGeometry(object.geometry)
  24. }
  25. object.matrix.identity()
  26. object.matrix.decompose(object.position, object.quaternion, object.scale)
  27. object.updateMatrixWorld()
  28. application.notifyObjectsChanged(object, this)
  29. application.updateSelection()
  30. }
  31. }
  32. }
  33. export { ResetMatrixTool }