|
@@ -46769,7 +46769,8 @@ var AxisDragGizmo = /** @class */ (function (_super) {
|
|
|
if (_this.attachedNode.position) { // Required for nodes like lights
|
|
|
_this.attachedNode.position.addInPlaceFromFloats(localDelta.x, localDelta.y, localDelta.z);
|
|
|
}
|
|
|
- _this.attachedNode.getWorldMatrix().addTranslationFromFloats(localDelta.x, localDelta.y, localDelta.z);
|
|
|
+ // use _worldMatrix to not force a matrix update when calling GetWorldMatrix especialy with Cameras
|
|
|
+ _this.attachedNode._worldMatrix.addTranslationFromFloats(localDelta.x, localDelta.y, localDelta.z);
|
|
|
_this.attachedNode.updateCache();
|
|
|
}
|
|
|
else {
|
|
@@ -46779,7 +46780,7 @@ var AxisDragGizmo = /** @class */ (function (_super) {
|
|
|
currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
|
|
|
localDelta.normalizeToRef(tmpVector);
|
|
|
tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
|
|
|
- _this.attachedNode.getWorldMatrix().addTranslationFromFloats(tmpVector.x, tmpVector.y, tmpVector.z);
|
|
|
+ _this.attachedNode._worldMatrix.addTranslationFromFloats(tmpVector.x, tmpVector.y, tmpVector.z);
|
|
|
_this.attachedNode.updateCache();
|
|
|
tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
|
|
|
_this.onSnapObservable.notifyObservers(tmpSnapEvent);
|
|
@@ -47876,6 +47877,10 @@ var CameraGizmo = /** @class */ (function (_super) {
|
|
|
this._cameraLinesMesh.scaling.x = 1 / this._rootMesh.scaling.x;
|
|
|
this._cameraLinesMesh.scaling.y = 1 / this._rootMesh.scaling.y;
|
|
|
this._cameraLinesMesh.scaling.z = 1 / this._rootMesh.scaling.z;
|
|
|
+ // take care of coordinate system in camera scene to properly display the mesh with the good Y axis orientation in this scene
|
|
|
+ this._cameraMesh.parent = null;
|
|
|
+ this._cameraMesh.rotation.y = Math.PI * 0.5 * (this._camera.getScene().useRightHandedSystem ? 1 : -1);
|
|
|
+ this._cameraMesh.parent = this._rootMesh;
|
|
|
};
|
|
|
/**
|
|
|
* Disposes of the camera gizmo
|
|
@@ -47912,7 +47917,6 @@ var CameraGizmo = /** @class */ (function (_super) {
|
|
|
cyl3.position.x = 0.6;
|
|
|
cyl3.rotation.z = Math.PI * 0.5;
|
|
|
root.scaling.scaleInPlace(CameraGizmo._Scale);
|
|
|
- root.rotation.y = -Math.PI * 0.5;
|
|
|
mesh.position.x = -0.9;
|
|
|
return root;
|
|
|
};
|
|
@@ -48000,6 +48004,9 @@ var Gizmo = /** @class */ (function () {
|
|
|
this._tempQuaternion = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 1);
|
|
|
this._tempVector = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
|
|
|
this._tempVector2 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
|
|
|
+ this._tempMatrix1 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
|
|
|
+ this._tempMatrix2 = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
|
|
|
+ this._rightHandtoLeftHandMatrix = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(Math.PI);
|
|
|
this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
|
|
|
this._rootMesh.rotationQuaternion = _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
|
|
|
this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
|
|
@@ -48136,16 +48143,26 @@ var Gizmo = /** @class */ (function () {
|
|
|
}
|
|
|
if (this._attachedNode._isCamera) {
|
|
|
var camera = this._attachedNode;
|
|
|
+ var worldMatrix;
|
|
|
+ var worldMatrixUC;
|
|
|
if (camera.parent) {
|
|
|
- var parentInv = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
|
|
|
- var localMat = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
|
|
|
- camera.parent.getWorldMatrix().invertToRef(parentInv);
|
|
|
- this._attachedNode.getWorldMatrix().multiplyToRef(parentInv, localMat);
|
|
|
- localMat.decompose(this._tempVector2, this._tempQuaternion, this._tempVector);
|
|
|
+ var parentInv = this._tempMatrix2;
|
|
|
+ camera.parent._worldMatrix.invertToRef(parentInv);
|
|
|
+ this._attachedNode._worldMatrix.multiplyToRef(parentInv, this._tempMatrix1);
|
|
|
+ worldMatrix = this._tempMatrix1;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ worldMatrix = this._attachedNode._worldMatrix;
|
|
|
+ }
|
|
|
+ if (camera.getScene().useRightHandedSystem) {
|
|
|
+ // avoid desync with RH matrix computation. Otherwise, rotation of PI around Y axis happens each frame resulting in axis flipped because worldMatrix is computed as inverse of viewMatrix.
|
|
|
+ this._rightHandtoLeftHandMatrix.multiplyToRef(worldMatrix, this._tempMatrix2);
|
|
|
+ worldMatrixUC = this._tempMatrix2;
|
|
|
}
|
|
|
else {
|
|
|
- this._attachedNode.getWorldMatrix().decompose(this._tempVector2, this._tempQuaternion, this._tempVector);
|
|
|
+ worldMatrixUC = worldMatrix;
|
|
|
}
|
|
|
+ worldMatrixUC.decompose(this._tempVector2, this._tempQuaternion, this._tempVector);
|
|
|
var inheritsTargetCamera = this._attachedNode.getClassName() === "FreeCamera"
|
|
|
|| this._attachedNode.getClassName() === "FlyCamera"
|
|
|
|| this._attachedNode.getClassName() === "ArcFollowCamera"
|
|
@@ -48161,11 +48178,11 @@ var Gizmo = /** @class */ (function () {
|
|
|
}
|
|
|
camera.position.copyFrom(this._tempVector);
|
|
|
}
|
|
|
- else if (this._attachedNode._isMesh || this._attachedNode.getClassName() === "AbstractMesh" || this._attachedNode.getClassName() === "TransformNode") {
|
|
|
+ else if (this._attachedNode._isMesh || this._attachedNode.getClassName() === "AbstractMesh" || this._attachedNode.getClassName() === "TransformNode" || this._attachedNode.getClassName() === "InstancedMesh") {
|
|
|
var transform = this._attachedNode;
|
|
|
if (transform.parent) {
|
|
|
- var parentInv = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
|
|
|
- var localMat = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
|
|
|
+ var parentInv = this._tempMatrix1;
|
|
|
+ var localMat = this._tempMatrix2;
|
|
|
transform.parent.getWorldMatrix().invertToRef(parentInv);
|
|
|
this._attachedNode._worldMatrix.multiplyToRef(parentInv, localMat);
|
|
|
localMat.decompose(transform.scaling, this._tempQuaternion, transform.position);
|
|
@@ -48184,8 +48201,8 @@ var Gizmo = /** @class */ (function () {
|
|
|
var bone = this._attachedNode;
|
|
|
var parent_1 = bone.getParent();
|
|
|
if (parent_1) {
|
|
|
- var invParent = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
|
|
|
- var boneLocalMatrix = new _Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
|
|
|
+ var invParent = this._tempMatrix1;
|
|
|
+ var boneLocalMatrix = this._tempMatrix2;
|
|
|
parent_1.getWorldMatrix().invertToRef(invParent);
|
|
|
bone.getWorldMatrix().multiplyToRef(invParent, boneLocalMatrix);
|
|
|
var lmat = bone.getLocalMatrix();
|