|
@@ -11793,7 +11793,7 @@ var BABYLON;
|
|
* Returns the current version of the framework
|
|
* Returns the current version of the framework
|
|
*/
|
|
*/
|
|
get: function () {
|
|
get: function () {
|
|
- return "3.3.0-beta.2";
|
|
|
|
|
|
+ return "3.3.0-beta.3";
|
|
},
|
|
},
|
|
enumerable: true,
|
|
enumerable: true,
|
|
configurable: true
|
|
configurable: true
|
|
@@ -33322,6 +33322,9 @@ var BABYLON;
|
|
position: instance.position.asArray(),
|
|
position: instance.position.asArray(),
|
|
scaling: instance.scaling.asArray()
|
|
scaling: instance.scaling.asArray()
|
|
};
|
|
};
|
|
|
|
+ if (instance.parent) {
|
|
|
|
+ serializationInstance.parentId = instance.parent.id;
|
|
|
|
+ }
|
|
if (instance.rotationQuaternion) {
|
|
if (instance.rotationQuaternion) {
|
|
serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
|
|
serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
|
|
}
|
|
}
|
|
@@ -93410,6 +93413,7 @@ var BABYLON;
|
|
_this._scaleDragSpeed = 0.2;
|
|
_this._scaleDragSpeed = 0.2;
|
|
_this._tmpQuaternion = new BABYLON.Quaternion();
|
|
_this._tmpQuaternion = new BABYLON.Quaternion();
|
|
_this._tmpVector = new BABYLON.Vector3(0, 0, 0);
|
|
_this._tmpVector = new BABYLON.Vector3(0, 0, 0);
|
|
|
|
+ _this._tmpRotationMatrix = new BABYLON.Matrix();
|
|
/**
|
|
/**
|
|
* If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
|
|
* If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
|
|
*/
|
|
*/
|
|
@@ -93450,7 +93454,13 @@ var BABYLON;
|
|
* Fired when a rotation sphere drag is ended
|
|
* Fired when a rotation sphere drag is ended
|
|
*/
|
|
*/
|
|
_this.onRotationSphereDragEndObservable = new BABYLON.Observable();
|
|
_this.onRotationSphereDragEndObservable = new BABYLON.Observable();
|
|
|
|
+ /**
|
|
|
|
+ * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
|
|
|
|
+ */
|
|
|
|
+ _this.scalePivot = null;
|
|
_this._existingMeshScale = new BABYLON.Vector3();
|
|
_this._existingMeshScale = new BABYLON.Vector3();
|
|
|
|
+ _this._oldPivotPoint = new BABYLON.Vector3();
|
|
|
|
+ _this._pivotTranslation = new BABYLON.Vector3();
|
|
// Do not update the gizmo's scale so it has a fixed size to the object its attached to
|
|
// Do not update the gizmo's scale so it has a fixed size to the object its attached to
|
|
_this._updateScale = false;
|
|
_this._updateScale = false;
|
|
_this._anchorMesh = new BABYLON.AbstractMesh("anchor", gizmoLayer.utilityLayerScene);
|
|
_this._anchorMesh = new BABYLON.AbstractMesh("anchor", gizmoLayer.utilityLayerScene);
|
|
@@ -93505,6 +93515,7 @@ var BABYLON;
|
|
_dragBehavior.onDragObservable.add(function (event) {
|
|
_dragBehavior.onDragObservable.add(function (event) {
|
|
_this.onRotationSphereDragObservable.notifyObservers({});
|
|
_this.onRotationSphereDragObservable.notifyObservers({});
|
|
if (_this.attachedMesh) {
|
|
if (_this.attachedMesh) {
|
|
|
|
+ _this.removeAndStorePivotPoint();
|
|
var worldDragDirection = startingTurnDirection;
|
|
var worldDragDirection = startingTurnDirection;
|
|
// Project the world right on to the drag plane
|
|
// Project the world right on to the drag plane
|
|
var toSub = event.dragPlaneNormal.scale(BABYLON.Vector3.Dot(event.dragPlaneNormal, worldDragDirection));
|
|
var toSub = event.dragPlaneNormal.scale(BABYLON.Vector3.Dot(event.dragPlaneNormal, worldDragDirection));
|
|
@@ -93538,6 +93549,7 @@ var BABYLON;
|
|
_this._anchorMesh.removeChild(_this.attachedMesh);
|
|
_this._anchorMesh.removeChild(_this.attachedMesh);
|
|
}
|
|
}
|
|
_this.updateBoundingBox();
|
|
_this.updateBoundingBox();
|
|
|
|
+ _this.restorePivotPoint();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
// Selection/deselection
|
|
// Selection/deselection
|
|
@@ -93572,19 +93584,33 @@ var BABYLON;
|
|
_dragBehavior.onDragObservable.add(function (event) {
|
|
_dragBehavior.onDragObservable.add(function (event) {
|
|
_this.onScaleBoxDragObservable.notifyObservers({});
|
|
_this.onScaleBoxDragObservable.notifyObservers({});
|
|
if (_this.attachedMesh) {
|
|
if (_this.attachedMesh) {
|
|
|
|
+ _this.removeAndStorePivotPoint();
|
|
var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
|
|
var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
|
|
var deltaScale = new BABYLON.Vector3(relativeDragDistance, relativeDragDistance, relativeDragDistance);
|
|
var deltaScale = new BABYLON.Vector3(relativeDragDistance, relativeDragDistance, relativeDragDistance);
|
|
deltaScale.scaleInPlace(_this._scaleDragSpeed);
|
|
deltaScale.scaleInPlace(_this._scaleDragSpeed);
|
|
_this.updateBoundingBox();
|
|
_this.updateBoundingBox();
|
|
- // Scale from the position of the opposite corner
|
|
|
|
- box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
|
|
|
|
- _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
|
|
|
|
|
|
+ if (_this.scalePivot) {
|
|
|
|
+ _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
|
|
|
|
+ // Move anchor to desired pivot point (Bottom left corner + dimension/2)
|
|
|
|
+ _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
|
|
|
|
+ BABYLON.Vector3.TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
|
|
|
|
+ _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
|
|
|
|
+ _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
|
|
|
|
+ BABYLON.Vector3.TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
|
|
|
|
+ _this._anchorMesh.position.addInPlace(_this._tmpVector);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ // Scale from the position of the opposite corner
|
|
|
|
+ box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
|
|
|
|
+ _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
|
|
|
|
+ }
|
|
_this._anchorMesh.addChild(_this.attachedMesh);
|
|
_this._anchorMesh.addChild(_this.attachedMesh);
|
|
_this._anchorMesh.scaling.addInPlace(deltaScale);
|
|
_this._anchorMesh.scaling.addInPlace(deltaScale);
|
|
if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
|
|
if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
|
|
_this._anchorMesh.scaling.subtractInPlace(deltaScale);
|
|
_this._anchorMesh.scaling.subtractInPlace(deltaScale);
|
|
}
|
|
}
|
|
_this._anchorMesh.removeChild(_this.attachedMesh);
|
|
_this._anchorMesh.removeChild(_this.attachedMesh);
|
|
|
|
+ _this.restorePivotPoint();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
// Selection/deselection
|
|
// Selection/deselection
|
|
@@ -93633,6 +93659,31 @@ var BABYLON;
|
|
_this.updateBoundingBox();
|
|
_this.updateBoundingBox();
|
|
return _this;
|
|
return _this;
|
|
}
|
|
}
|
|
|
|
+ BoundingBoxGizmo.prototype.removeAndStorePivotPoint = function () {
|
|
|
|
+ if (this.attachedMesh) {
|
|
|
|
+ // Save old pivot and set pivot to 0,0,0
|
|
|
|
+ this.attachedMesh.getPivotPointToRef(this._oldPivotPoint);
|
|
|
|
+ if (this._oldPivotPoint.equalsToFloats(0, 0, 0)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this.attachedMesh.setPivotMatrix(BABYLON.Matrix.IdentityReadOnly);
|
|
|
|
+ this._oldPivotPoint.subtractToRef(this.attachedMesh.getPivotPoint(), this._pivotTranslation);
|
|
|
|
+ this._tmpVector.copyFromFloats(1, 1, 1);
|
|
|
|
+ this._tmpVector.subtractInPlace(this.attachedMesh.scaling);
|
|
|
|
+ this._tmpVector.multiplyInPlace(this._pivotTranslation);
|
|
|
|
+ this.attachedMesh.position.addInPlace(this._tmpVector);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ BoundingBoxGizmo.prototype.restorePivotPoint = function () {
|
|
|
|
+ if (this.attachedMesh && !this._oldPivotPoint.equalsToFloats(0, 0, 0)) {
|
|
|
|
+ this.attachedMesh.setPivotPoint(this._oldPivotPoint);
|
|
|
|
+ this._oldPivotPoint.subtractToRef(this.attachedMesh.getPivotPoint(), this._pivotTranslation);
|
|
|
|
+ this._tmpVector.copyFromFloats(1, 1, 1);
|
|
|
|
+ this._tmpVector.subtractInPlace(this.attachedMesh.scaling);
|
|
|
|
+ this._tmpVector.multiplyInPlace(this._pivotTranslation);
|
|
|
|
+ this.attachedMesh.position.subtractInPlace(this._tmpVector);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
|
|
BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
|
|
if (value) {
|
|
if (value) {
|
|
// Reset anchor mesh to match attached mesh's scale
|
|
// Reset anchor mesh to match attached mesh's scale
|
|
@@ -93661,8 +93712,9 @@ var BABYLON;
|
|
* Updates the bounding box information for the Gizmo
|
|
* Updates the bounding box information for the Gizmo
|
|
*/
|
|
*/
|
|
BoundingBoxGizmo.prototype.updateBoundingBox = function () {
|
|
BoundingBoxGizmo.prototype.updateBoundingBox = function () {
|
|
- this._update();
|
|
|
|
if (this.attachedMesh) {
|
|
if (this.attachedMesh) {
|
|
|
|
+ this.removeAndStorePivotPoint();
|
|
|
|
+ this._update();
|
|
// Rotate based on axis
|
|
// Rotate based on axis
|
|
if (!this.attachedMesh.rotationQuaternion) {
|
|
if (!this.attachedMesh.rotationQuaternion) {
|
|
this.attachedMesh.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
|
|
this.attachedMesh.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
|
|
@@ -93752,6 +93804,7 @@ var BABYLON;
|
|
}
|
|
}
|
|
if (this.attachedMesh) {
|
|
if (this.attachedMesh) {
|
|
this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
|
|
this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
|
|
|
|
+ this.restorePivotPoint();
|
|
}
|
|
}
|
|
};
|
|
};
|
|
/**
|
|
/**
|