|
@@ -91094,6 +91094,7 @@ var BABYLON;
|
|
|
function GizmoManager(scene) {
|
|
|
var _this = this;
|
|
|
this.scene = scene;
|
|
|
+ this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
|
|
|
this._pointerObserver = null;
|
|
|
this._attachedMesh = null;
|
|
|
this._boundingBoxColor = BABYLON.Color3.FromHexString("#0984e3");
|
|
@@ -91107,7 +91108,7 @@ var BABYLON;
|
|
|
* If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
|
|
|
*/
|
|
|
this.usePointerToAttachGizmos = true;
|
|
|
- this._gizmoSet = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
|
|
|
+ this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
|
|
|
// Instatiate/dispose gizmos based on pointer actions
|
|
|
this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo, state) {
|
|
|
if (!_this.usePointerToAttachGizmos) {
|
|
@@ -91154,9 +91155,9 @@ var BABYLON;
|
|
|
this._attachedMesh.removeBehavior(this._dragBehavior);
|
|
|
}
|
|
|
this._attachedMesh = mesh;
|
|
|
- for (var key in this._gizmoSet) {
|
|
|
- var gizmo = (this._gizmoSet[key]);
|
|
|
- if (gizmo) {
|
|
|
+ for (var key in this.gizmos) {
|
|
|
+ var gizmo = (this.gizmos[key]);
|
|
|
+ if (gizmo && this._gizmosEnabled[key]) {
|
|
|
gizmo.attachedMesh = mesh;
|
|
|
}
|
|
|
}
|
|
@@ -91166,69 +91167,69 @@ var BABYLON;
|
|
|
};
|
|
|
Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
|
|
|
get: function () {
|
|
|
- return this._gizmoSet.positionGizmo != null;
|
|
|
+ return this._gizmosEnabled.positionGizmo;
|
|
|
},
|
|
|
/**
|
|
|
* If the position gizmo is enabled
|
|
|
*/
|
|
|
set: function (value) {
|
|
|
if (value) {
|
|
|
- this._gizmoSet.positionGizmo = this._gizmoSet.positionGizmo || new BABYLON.PositionGizmo();
|
|
|
- this._gizmoSet.positionGizmo.updateGizmoRotationToMatchAttachedMesh = false;
|
|
|
- this._gizmoSet.positionGizmo.attachedMesh = this._attachedMesh;
|
|
|
+ this.gizmos.positionGizmo = this.gizmos.positionGizmo || new BABYLON.PositionGizmo();
|
|
|
+ this.gizmos.positionGizmo.updateGizmoRotationToMatchAttachedMesh = false;
|
|
|
+ this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
|
|
|
}
|
|
|
- else if (this._gizmoSet.positionGizmo) {
|
|
|
- this._gizmoSet.positionGizmo.dispose();
|
|
|
- this._gizmoSet.positionGizmo = null;
|
|
|
+ else if (this.gizmos.positionGizmo) {
|
|
|
+ this.gizmos.positionGizmo.attachedMesh = null;
|
|
|
}
|
|
|
+ this._gizmosEnabled.positionGizmo = value;
|
|
|
},
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
|
|
|
get: function () {
|
|
|
- return this._gizmoSet.rotationGizmo != null;
|
|
|
+ return this._gizmosEnabled.rotationGizmo;
|
|
|
},
|
|
|
/**
|
|
|
* If the rotation gizmo is enabled
|
|
|
*/
|
|
|
set: function (value) {
|
|
|
if (value) {
|
|
|
- this._gizmoSet.rotationGizmo = this._gizmoSet.rotationGizmo || new BABYLON.RotationGizmo();
|
|
|
- this._gizmoSet.rotationGizmo.updateGizmoRotationToMatchAttachedMesh = false;
|
|
|
- this._gizmoSet.rotationGizmo.attachedMesh = this._attachedMesh;
|
|
|
+ this.gizmos.rotationGizmo = this.gizmos.rotationGizmo || new BABYLON.RotationGizmo();
|
|
|
+ this.gizmos.rotationGizmo.updateGizmoRotationToMatchAttachedMesh = false;
|
|
|
+ this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
|
|
|
}
|
|
|
- else if (this._gizmoSet.rotationGizmo) {
|
|
|
- this._gizmoSet.rotationGizmo.dispose();
|
|
|
- this._gizmoSet.rotationGizmo = null;
|
|
|
+ else if (this.gizmos.rotationGizmo) {
|
|
|
+ this.gizmos.rotationGizmo.attachedMesh = null;
|
|
|
}
|
|
|
+ this._gizmosEnabled.rotationGizmo = value;
|
|
|
},
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
|
|
|
get: function () {
|
|
|
- return this._gizmoSet.scaleGizmo != null;
|
|
|
+ return this._gizmosEnabled.scaleGizmo;
|
|
|
},
|
|
|
/**
|
|
|
* If the scale gizmo is enabled
|
|
|
*/
|
|
|
set: function (value) {
|
|
|
if (value) {
|
|
|
- this._gizmoSet.scaleGizmo = this._gizmoSet.scaleGizmo || new BABYLON.ScaleGizmo();
|
|
|
- this._gizmoSet.scaleGizmo.attachedMesh = this._attachedMesh;
|
|
|
+ this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new BABYLON.ScaleGizmo();
|
|
|
+ this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
|
|
|
}
|
|
|
- else if (this._gizmoSet.scaleGizmo) {
|
|
|
- this._gizmoSet.scaleGizmo.dispose();
|
|
|
- this._gizmoSet.scaleGizmo = null;
|
|
|
+ else if (this.gizmos.scaleGizmo) {
|
|
|
+ this.gizmos.scaleGizmo.attachedMesh = null;
|
|
|
}
|
|
|
+ this._gizmosEnabled.scaleGizmo = value;
|
|
|
},
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
|
|
|
get: function () {
|
|
|
- return this._gizmoSet.boundingBoxGizmo != null;
|
|
|
+ return this._gizmosEnabled.boundingBoxGizmo;
|
|
|
},
|
|
|
/**
|
|
|
* If the boundingBox gizmo is enabled
|
|
@@ -91239,17 +91240,17 @@ var BABYLON;
|
|
|
this._boundingBoxUtilLayer = new BABYLON.UtilityLayerRenderer(this.scene);
|
|
|
this._boundingBoxUtilLayer.utilityLayerScene.autoClearDepthAndStencil = false;
|
|
|
}
|
|
|
- this._gizmoSet.boundingBoxGizmo = this._gizmoSet.boundingBoxGizmo || new BABYLON.BoundingBoxGizmo(this._boundingBoxColor, this._boundingBoxUtilLayer);
|
|
|
- this._gizmoSet.boundingBoxGizmo.attachedMesh = this._attachedMesh;
|
|
|
+ this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new BABYLON.BoundingBoxGizmo(this._boundingBoxColor, this._boundingBoxUtilLayer);
|
|
|
+ this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
|
|
|
if (this._attachedMesh) {
|
|
|
this._attachedMesh.removeBehavior(this._dragBehavior);
|
|
|
this._attachedMesh.addBehavior(this._dragBehavior);
|
|
|
}
|
|
|
}
|
|
|
- else if (this._gizmoSet.boundingBoxGizmo) {
|
|
|
- this._gizmoSet.boundingBoxGizmo.dispose();
|
|
|
- this._gizmoSet.boundingBoxGizmo = null;
|
|
|
+ else if (this.gizmos.boundingBoxGizmo) {
|
|
|
+ this.gizmos.boundingBoxGizmo.attachedMesh = null;
|
|
|
}
|
|
|
+ this._gizmosEnabled.boundingBoxGizmo = value;
|
|
|
},
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
@@ -91259,8 +91260,8 @@ var BABYLON;
|
|
|
*/
|
|
|
GizmoManager.prototype.dispose = function () {
|
|
|
this.scene.onPointerObservable.remove(this._pointerObserver);
|
|
|
- for (var key in this._gizmoSet) {
|
|
|
- var gizmo = (this._gizmoSet[key]);
|
|
|
+ for (var key in this.gizmos) {
|
|
|
+ var gizmo = (this.gizmos[key]);
|
|
|
if (gizmo) {
|
|
|
gizmo.dispose();
|
|
|
}
|