Working with a three.js object in my scene, I utilize the THREE.TransformControls to rotate, scale, and move it. After positioning the object, I need to save the values of rotation, position, and scale. The code snippet below shows how I am currently retrieving these values:
// Position
$scope.scene.updateMatrixWorld(true);
var position = new THREE.Vector3();
position.getPositionFromMatrix( $scope.object.matrixWorld );
// Rotation
var rotation = new THREE.Euler();
$scope.object.getWorldRotation(rotation);
// Size
var size = new THREE.Box3().setFromObject($scope.object);
var x = (size.max.x - size.min.x);
var y = (size.max.y - size.min.y);
var z = (size.max.z - size.min.z);
However, when I save and reload the scene with these values, the object appears significantly different than expected. It seems that the functions are returning incorrect values for rotation, scale, and position. For instance, even though size.z should always be 0, it is showing a different value upon saving and printing it in the console.
Does anyone have any insights into why this might be happening?
Thank you for your assistance.