Guest User

Untitled

a guest
Dec 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. let position = new THREE.Vector3();
  2. position.applyMatrix4(transform)
  3.  
  4. // Get the position from the current transform matrix.
  5. let position = new THREE.Vector3();
  6. position.setFromMatrixPosition(transform); <===== A
  7.  
  8. // Create a matrix to do rotation of -90 degrees on the z axis.
  9. let rotateTransform = new THREE.Matrix4();
  10. rotateTransform.makeRotationFromEuler(new THREE.Euler(0, 0, MyHelper.ConvertToRadian(-90)));
  11.  
  12. // Apply the rotation
  13. transform.multiply(rotateTransform);
  14.  
  15. // Get the position again. Should be different result to above
  16. position.setFromMatrixPosition(transform); <===== B
  17.  
  18. // Try a different approach
  19. let transform3 = new THREE.Matrix4();
  20. let quat2 = new THREE.Quaternion();
  21. quat2.setFromEuler(new THREE.Euler(MyHelper.ConvertToRadian(-90),0 , 0));
  22. transform3.compose(new THREE.Vector3(0,0,0), quat2, new THREE.Vector3(0,0,0));
  23. transform.multiply(transform3);
  24. absPos.setFromMatrixPosition(transform); <====== C
Add Comment
Please, Sign In to add comment