applyTransformMatrix method
dynamic
applyTransformMatrix(
- dynamic transformation
Apply a transformation matrix, to the camera and gizmos @param {Object} transformation Object containing matrices to apply to camera and gizmos
Implementation
applyTransformMatrix(transformation) {
if (transformation['camera'] != null) {
_m4_1.copy(_cameraMatrixState).premultiply(transformation['camera']);
_m4_1.decompose(camera.position, camera.quaternion, camera.scale);
camera.updateMatrix();
//update camera up vector
if (_state == State2.rotate || _state == State2.zRotate || _state == State2.animationRotate) {
camera.up.copy(_upState).applyQuaternion(camera.quaternion);
}
}
if (transformation['gizmos'] != null) {
_m4_1.copy(_gizmoMatrixState).premultiply(transformation['gizmos']);
_m4_1.decompose(_gizmos.position, _gizmos.quaternion, _gizmos.scale);
_gizmos.updateMatrix();
}
if (_state == State2.scale || _state == State2.focus || _state == State2.animationFocus) {
_tbRadius = calculateTbRadius(camera);
if (adjustNearFar) {
var cameraDistance = camera.position.distanceTo(_gizmos.position);
var bb = Box3();
bb.setFromObject(_gizmos);
var sphere = Sphere();
bb.getBoundingSphere(sphere);
var adjustedNearPosition = Math.max(_nearPos0, sphere.radius + sphere.center.length());
var regularNearPosition = cameraDistance - _initialNear;
var minNearPos = Math.min(adjustedNearPosition, regularNearPosition);
camera.near = cameraDistance - minNearPos;
var adjustedFarPosition = Math.min(_farPos0, -sphere.radius + sphere.center.length());
var regularFarPosition = cameraDistance - _initialFar;
var minFarPos = Math.min(adjustedFarPosition, regularFarPosition);
camera.far = cameraDistance - minFarPos;
camera.updateProjectionMatrix();
} else {
var update = false;
if (camera.near != _initialNear) {
camera.near = _initialNear;
update = true;
}
if (camera.far != _initialFar) {
camera.far = _initialFar;
update = true;
}
if (update) {
camera.updateProjectionMatrix();
}
}
}
}