|
@@ -25116,6 +25116,20 @@ var BABYLON;
|
|
this._alternateSceneUbo.addUniform("view", 16);
|
|
this._alternateSceneUbo.addUniform("view", 16);
|
|
};
|
|
};
|
|
// Pointers handling
|
|
// Pointers handling
|
|
|
|
+ Scene.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, predicate, fastCheck, camera) {
|
|
|
|
+ var result = this.pickSprite(x, y, predicate, fastCheck, camera);
|
|
|
|
+ if (result) {
|
|
|
|
+ result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ };
|
|
|
|
+ Scene.prototype._setRayOnPointerInfo = function (pointerInfo) {
|
|
|
|
+ if (pointerInfo.pickInfo) {
|
|
|
|
+ if (!pointerInfo.pickInfo.ray) {
|
|
|
|
+ pointerInfo.pickInfo.ray = this.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, BABYLON.Matrix.Identity(), this.activeCamera);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
/**
|
|
/**
|
|
* Use this method to simulate a pointer move on a mesh
|
|
* Use this method to simulate a pointer move on a mesh
|
|
* The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
|
|
* The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
|
|
@@ -25150,7 +25164,7 @@ var BABYLON;
|
|
else {
|
|
else {
|
|
this.setPointerOverMesh(null);
|
|
this.setPointerOverMesh(null);
|
|
// Sprites
|
|
// Sprites
|
|
- pickResult = this.pickSprite(this._unTranslatedPointerX, this._unTranslatedPointerY, this._spritePredicate, false, this.cameraToUseForPointers || undefined);
|
|
|
|
|
|
+ pickResult = this._pickSpriteButKeepRay(pickResult, this._unTranslatedPointerX, this._unTranslatedPointerY, this._spritePredicate, false, this.cameraToUseForPointers || undefined);
|
|
if (pickResult && pickResult.hit && pickResult.pickedSprite) {
|
|
if (pickResult && pickResult.hit && pickResult.pickedSprite) {
|
|
this.setPointerOverSprite(pickResult.pickedSprite);
|
|
this.setPointerOverSprite(pickResult.pickedSprite);
|
|
if (this._pointerOverSprite && this._pointerOverSprite.actionManager && this._pointerOverSprite.actionManager.hoverCursor) {
|
|
if (this._pointerOverSprite && this._pointerOverSprite.actionManager && this._pointerOverSprite.actionManager.hoverCursor) {
|
|
@@ -25173,6 +25187,7 @@ var BABYLON;
|
|
}
|
|
}
|
|
if (this.onPointerObservable.hasObservers()) {
|
|
if (this.onPointerObservable.hasObservers()) {
|
|
var pi = new BABYLON.PointerInfo(type, evt, pickResult);
|
|
var pi = new BABYLON.PointerInfo(type, evt, pickResult);
|
|
|
|
+ this._setRayOnPointerInfo(pi);
|
|
this.onPointerObservable.notifyObservers(pi, type);
|
|
this.onPointerObservable.notifyObservers(pi, type);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -25232,6 +25247,7 @@ var BABYLON;
|
|
}
|
|
}
|
|
if (this.onPointerObservable.hasObservers()) {
|
|
if (this.onPointerObservable.hasObservers()) {
|
|
var pi = new BABYLON.PointerInfo(type, evt, pickResult);
|
|
var pi = new BABYLON.PointerInfo(type, evt, pickResult);
|
|
|
|
+ this._setRayOnPointerInfo(pi);
|
|
this.onPointerObservable.notifyObservers(pi, type);
|
|
this.onPointerObservable.notifyObservers(pi, type);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -25261,6 +25277,7 @@ var BABYLON;
|
|
if (clickInfo.singleClick && !clickInfo.ignore && this.onPointerObservable.hasObservers()) {
|
|
if (clickInfo.singleClick && !clickInfo.ignore && this.onPointerObservable.hasObservers()) {
|
|
var type_1 = BABYLON.PointerEventTypes.POINTERPICK;
|
|
var type_1 = BABYLON.PointerEventTypes.POINTERPICK;
|
|
var pi = new BABYLON.PointerInfo(type_1, evt, pickResult);
|
|
var pi = new BABYLON.PointerInfo(type_1, evt, pickResult);
|
|
|
|
+ this._setRayOnPointerInfo(pi);
|
|
this.onPointerObservable.notifyObservers(pi, type_1);
|
|
this.onPointerObservable.notifyObservers(pi, type_1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -25289,17 +25306,20 @@ var BABYLON;
|
|
if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(BABYLON.PointerEventTypes.POINTERTAP)) {
|
|
if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(BABYLON.PointerEventTypes.POINTERTAP)) {
|
|
var type_2 = BABYLON.PointerEventTypes.POINTERTAP;
|
|
var type_2 = BABYLON.PointerEventTypes.POINTERTAP;
|
|
var pi = new BABYLON.PointerInfo(type_2, evt, pickResult);
|
|
var pi = new BABYLON.PointerInfo(type_2, evt, pickResult);
|
|
|
|
+ this._setRayOnPointerInfo(pi);
|
|
this.onPointerObservable.notifyObservers(pi, type_2);
|
|
this.onPointerObservable.notifyObservers(pi, type_2);
|
|
}
|
|
}
|
|
if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(BABYLON.PointerEventTypes.POINTERDOUBLETAP)) {
|
|
if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(BABYLON.PointerEventTypes.POINTERDOUBLETAP)) {
|
|
var type_3 = BABYLON.PointerEventTypes.POINTERDOUBLETAP;
|
|
var type_3 = BABYLON.PointerEventTypes.POINTERDOUBLETAP;
|
|
var pi = new BABYLON.PointerInfo(type_3, evt, pickResult);
|
|
var pi = new BABYLON.PointerInfo(type_3, evt, pickResult);
|
|
|
|
+ this._setRayOnPointerInfo(pi);
|
|
this.onPointerObservable.notifyObservers(pi, type_3);
|
|
this.onPointerObservable.notifyObservers(pi, type_3);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
var pi = new BABYLON.PointerInfo(type, evt, pickResult);
|
|
var pi = new BABYLON.PointerInfo(type, evt, pickResult);
|
|
|
|
+ this._setRayOnPointerInfo(pi);
|
|
this.onPointerObservable.notifyObservers(pi, type);
|
|
this.onPointerObservable.notifyObservers(pi, type);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -96416,6 +96436,182 @@ var BABYLON;
|
|
|
|
|
|
//# sourceMappingURL=babylon.autoRotationBehavior.js.map
|
|
//# sourceMappingURL=babylon.autoRotationBehavior.js.map
|
|
|
|
|
|
|
|
+var BABYLON;
|
|
|
|
+(function (BABYLON) {
|
|
|
|
+ /**
|
|
|
|
+ * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
|
|
|
|
+ */
|
|
|
|
+ var PointerDragBehavior = /** @class */ (function () {
|
|
|
|
+ /**
|
|
|
|
+ * Creates a pointer drag behavior that can be attached to a mesh
|
|
|
|
+ * @param options The drag axis or normal of the plane that will be dragged accross
|
|
|
|
+ */
|
|
|
|
+ function PointerDragBehavior(options) {
|
|
|
|
+ this.options = options;
|
|
|
|
+ this._draggingID = -1;
|
|
|
|
+ /**
|
|
|
|
+ * Fires each time the attached mesh is dragged with the pointer
|
|
|
|
+ */
|
|
|
|
+ this.onDragObservable = new BABYLON.Observable();
|
|
|
|
+ /**
|
|
|
|
+ * Fires each time a drag begins (eg. mouse down on mesh)
|
|
|
|
+ */
|
|
|
|
+ this.onDragStartObservable = new BABYLON.Observable();
|
|
|
|
+ /**
|
|
|
|
+ * Fires each time a drag ends (eg. mouse release after drag)
|
|
|
|
+ */
|
|
|
|
+ this.onDragEndObservable = new BABYLON.Observable();
|
|
|
|
+ /**
|
|
|
|
+ * If the attached mesh should be moved when dragged
|
|
|
|
+ */
|
|
|
|
+ this.moveAttached = true;
|
|
|
|
+ /**
|
|
|
|
+ * Mesh with the position where the drag plane should be placed
|
|
|
|
+ */
|
|
|
|
+ this._dragPlaneParent = null;
|
|
|
|
+ var optionCount = 0;
|
|
|
|
+ if (options.dragAxis) {
|
|
|
|
+ optionCount++;
|
|
|
|
+ }
|
|
|
|
+ if (options.dragPlaneNormal) {
|
|
|
|
+ optionCount++;
|
|
|
|
+ }
|
|
|
|
+ if (optionCount > 1) {
|
|
|
|
+ throw "Multiple drag modes specified in dragBehavior options. Only one expected";
|
|
|
|
+ }
|
|
|
|
+ if (optionCount < 1) {
|
|
|
|
+ throw "At least one drag mode option must be specified";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Object.defineProperty(PointerDragBehavior.prototype, "name", {
|
|
|
|
+ /**
|
|
|
|
+ * The name of the behavior
|
|
|
|
+ */
|
|
|
|
+ get: function () {
|
|
|
|
+ return "PointerDrag";
|
|
|
|
+ },
|
|
|
|
+ enumerable: true,
|
|
|
|
+ configurable: true
|
|
|
|
+ });
|
|
|
|
+ /**
|
|
|
|
+ * Initializes the behavior
|
|
|
|
+ */
|
|
|
|
+ PointerDragBehavior.prototype.init = function () { };
|
|
|
|
+ /**
|
|
|
|
+ * Attaches the drag behavior the passed in mesh
|
|
|
|
+ * @param ownerNode The mesh that will be dragged around once attached
|
|
|
|
+ */
|
|
|
|
+ PointerDragBehavior.prototype.attach = function (ownerNode) {
|
|
|
|
+ var _this = this;
|
|
|
|
+ this._scene = ownerNode.getScene();
|
|
|
|
+ this._attachedNode = ownerNode;
|
|
|
|
+ // Initialize drag plane to not interfere with existing scene
|
|
|
|
+ if (!PointerDragBehavior._planeScene) {
|
|
|
|
+ PointerDragBehavior._planeScene = new BABYLON.Scene(this._scene.getEngine());
|
|
|
|
+ this._scene.getEngine().scenes.pop();
|
|
|
|
+ }
|
|
|
|
+ this._dragPlane = BABYLON.Mesh.CreatePlane("pointerDragPlane", 1000, PointerDragBehavior._planeScene, false, BABYLON.Mesh.DOUBLESIDE);
|
|
|
|
+ // State of the drag
|
|
|
|
+ var dragging = false;
|
|
|
|
+ var lastPosition = new BABYLON.Vector3(0, 0, 0);
|
|
|
|
+ var delta = new BABYLON.Vector3(0, 0, 0);
|
|
|
|
+ this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo) {
|
|
|
|
+ if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERDOWN) {
|
|
|
|
+ if (!dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray) {
|
|
|
|
+ if (_this._attachedNode == pointerInfo.pickInfo.pickedMesh) {
|
|
|
|
+ _this._updateDragPlanePosition(pointerInfo.pickInfo.ray);
|
|
|
|
+ var pickedPoint = _this._pickWithRayOnDragPlane(pointerInfo.pickInfo.ray);
|
|
|
|
+ if (pickedPoint) {
|
|
|
|
+ dragging = true;
|
|
|
|
+ _this._draggingID = pointerInfo.event.pointerId;
|
|
|
|
+ lastPosition.copyFrom(pickedPoint);
|
|
|
|
+ _this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERUP) {
|
|
|
|
+ if (_this._draggingID == pointerInfo.event.pointerId) {
|
|
|
|
+ dragging = false;
|
|
|
|
+ _this._draggingID = -1;
|
|
|
|
+ _this.onDragEndObservable.notifyObservers({ dragPlanePoint: lastPosition });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERMOVE) {
|
|
|
|
+ if (_this._draggingID == pointerInfo.event.pointerId && dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {
|
|
|
|
+ var pickedPoint = _this._pickWithRayOnDragPlane(pointerInfo.pickInfo.ray);
|
|
|
|
+ _this._updateDragPlanePosition(pointerInfo.pickInfo.ray);
|
|
|
|
+ if (pickedPoint) {
|
|
|
|
+ // depending on the drag mode option drag accordingly
|
|
|
|
+ if (_this.options.dragAxis) {
|
|
|
|
+ //get the closest point on the dragaxis from the selected mesh to the picked point location
|
|
|
|
+ // https://www.opengl.org/discussion_boards/showthread.php/159717-Closest-point-on-a-Vector-to-a-point
|
|
|
|
+ _this.options.dragAxis.scaleToRef(BABYLON.Vector3.Dot(pickedPoint.subtract(lastPosition), _this.options.dragAxis), delta);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ pickedPoint.subtractToRef(lastPosition, delta);
|
|
|
|
+ }
|
|
|
|
+ if (_this.moveAttached) {
|
|
|
|
+ _this._attachedNode.position.addInPlace(delta);
|
|
|
|
+ }
|
|
|
|
+ _this.onDragObservable.notifyObservers({ delta: delta, dragPlanePoint: pickedPoint });
|
|
|
|
+ lastPosition.copyFrom(pickedPoint);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
+ PointerDragBehavior.prototype._pickWithRayOnDragPlane = function (ray) {
|
|
|
|
+ var _this = this;
|
|
|
|
+ if (!ray) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ var pickResult = PointerDragBehavior._planeScene.pickWithRay(ray, function (m) { return m == _this._dragPlane; });
|
|
|
|
+ if (pickResult && pickResult.hit && pickResult.pickedMesh && pickResult.pickedPoint) {
|
|
|
|
+ return pickResult.pickedPoint;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
|
|
|
|
+ PointerDragBehavior.prototype._updateDragPlanePosition = function (ray) {
|
|
|
|
+ var pointA = this._dragPlaneParent ? this._dragPlaneParent.position : this._attachedNode.position; // center
|
|
|
|
+ if (this.options.dragAxis) {
|
|
|
|
+ var camPos = ray.origin;
|
|
|
|
+ // Calculate plane normal in direction of camera but perpendicular to drag axis
|
|
|
|
+ var pointB = pointA.add(this.options.dragAxis); // towards drag axis
|
|
|
|
+ var pointC = pointA.add(camPos.subtract(pointA).normalize()); // towards camera
|
|
|
|
+ // Get perpendicular line from direction to camera and drag axis
|
|
|
|
+ var lineA = pointB.subtract(pointA);
|
|
|
|
+ var lineB = pointC.subtract(pointA);
|
|
|
|
+ var perpLine = BABYLON.Vector3.Cross(lineA, lineB);
|
|
|
|
+ // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
|
|
|
|
+ var norm = BABYLON.Vector3.Cross(lineA, perpLine).normalize();
|
|
|
|
+ this._dragPlane.position.copyFrom(pointA);
|
|
|
|
+ this._dragPlane.lookAt(pointA.add(norm));
|
|
|
|
+ }
|
|
|
|
+ else if (this.options.dragPlaneNormal) {
|
|
|
|
+ this._dragPlane.position.copyFrom(pointA);
|
|
|
|
+ this._dragPlane.lookAt(pointA.add(this.options.dragPlaneNormal));
|
|
|
|
+ }
|
|
|
|
+ this._dragPlane.computeWorldMatrix(true);
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * Detaches the behavior from the mesh
|
|
|
|
+ */
|
|
|
|
+ PointerDragBehavior.prototype.detach = function () {
|
|
|
|
+ if (this._pointerObserver) {
|
|
|
|
+ this._scene.onPointerObservable.remove(this._pointerObserver);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ return PointerDragBehavior;
|
|
|
|
+ }());
|
|
|
|
+ BABYLON.PointerDragBehavior = PointerDragBehavior;
|
|
|
|
+})(BABYLON || (BABYLON = {}));
|
|
|
|
+
|
|
|
|
+//# sourceMappingURL=babylon.pointerDragBehavior.js.map
|
|
|
|
+
|
|
|
|
|
|
var BABYLON;
|
|
var BABYLON;
|
|
(function (BABYLON) {
|
|
(function (BABYLON) {
|
|
@@ -108445,6 +108641,7 @@ var SceneManager = /** @class */ (function () {
|
|
_this.camera.beta = (_this._viewer.configuration.camera && _this._viewer.configuration.camera.beta) || _this.camera.beta;
|
|
_this.camera.beta = (_this._viewer.configuration.camera && _this._viewer.configuration.camera.beta) || _this.camera.beta;
|
|
_this.camera.radius = (_this._viewer.configuration.camera && _this._viewer.configuration.camera.radius) || _this.camera.radius;
|
|
_this.camera.radius = (_this._viewer.configuration.camera && _this._viewer.configuration.camera.radius) || _this.camera.radius;
|
|
};
|
|
};
|
|
|
|
+ this._cameraBehaviorMapping = {};
|
|
this.models = [];
|
|
this.models = [];
|
|
this.onCameraConfiguredObservable = new babylonjs_1.Observable();
|
|
this.onCameraConfiguredObservable = new babylonjs_1.Observable();
|
|
this.onLightsConfiguredObservable = new babylonjs_1.Observable();
|
|
this.onLightsConfiguredObservable = new babylonjs_1.Observable();
|
|
@@ -109065,8 +109262,8 @@ var SceneManager = /** @class */ (function () {
|
|
}
|
|
}
|
|
if (cameraConfig.behaviors) {
|
|
if (cameraConfig.behaviors) {
|
|
for (var name_1 in cameraConfig.behaviors) {
|
|
for (var name_1 in cameraConfig.behaviors) {
|
|
- if (cameraConfig.behaviors[name_1]) {
|
|
|
|
- this._setCameraBehavior(cameraConfig.behaviors[name_1]);
|
|
|
|
|
|
+ if (cameraConfig.behaviors[name_1] !== undefined) {
|
|
|
|
+ this._setCameraBehavior(name_1, cameraConfig.behaviors[name_1]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -109523,22 +109720,37 @@ var SceneManager = /** @class */ (function () {
|
|
this.scene.dispose();
|
|
this.scene.dispose();
|
|
}
|
|
}
|
|
};
|
|
};
|
|
- SceneManager.prototype._setCameraBehavior = function (behaviorConfig, payload) {
|
|
|
|
|
|
+ SceneManager.prototype._setCameraBehavior = function (name, behaviorConfig, payload) {
|
|
var behavior;
|
|
var behavior;
|
|
- var type = (typeof behaviorConfig !== "object") ? behaviorConfig : behaviorConfig.type;
|
|
|
|
|
|
+ var type;
|
|
|
|
+ if (typeof behaviorConfig === 'object') {
|
|
|
|
+ type = behaviorConfig.type;
|
|
|
|
+ }
|
|
|
|
+ else if (typeof behaviorConfig === 'number') {
|
|
|
|
+ type = behaviorConfig;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ type = this._cameraBehaviorMapping[name];
|
|
|
|
+ }
|
|
|
|
+ if (type === undefined)
|
|
|
|
+ return;
|
|
var config = (typeof behaviorConfig === "object") ? behaviorConfig : {};
|
|
var config = (typeof behaviorConfig === "object") ? behaviorConfig : {};
|
|
|
|
+ var enabled = true;
|
|
|
|
+ if (typeof behaviorConfig === 'boolean') {
|
|
|
|
+ enabled = behaviorConfig;
|
|
|
|
+ }
|
|
// constructing behavior
|
|
// constructing behavior
|
|
switch (type) {
|
|
switch (type) {
|
|
case 0 /* AUTOROTATION */:
|
|
case 0 /* AUTOROTATION */:
|
|
- this.camera.useAutoRotationBehavior = true;
|
|
|
|
|
|
+ this.camera.useAutoRotationBehavior = enabled;
|
|
behavior = this.camera.autoRotationBehavior;
|
|
behavior = this.camera.autoRotationBehavior;
|
|
break;
|
|
break;
|
|
case 1 /* BOUNCING */:
|
|
case 1 /* BOUNCING */:
|
|
- this.camera.useBouncingBehavior = true;
|
|
|
|
|
|
+ this.camera.useBouncingBehavior = enabled;
|
|
behavior = this.camera.bouncingBehavior;
|
|
behavior = this.camera.bouncingBehavior;
|
|
break;
|
|
break;
|
|
case 2 /* FRAMING */:
|
|
case 2 /* FRAMING */:
|
|
- this.camera.useFramingBehavior = true;
|
|
|
|
|
|
+ this.camera.useFramingBehavior = enabled;
|
|
behavior = this.camera.framingBehavior;
|
|
behavior = this.camera.framingBehavior;
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
@@ -109546,6 +109758,7 @@ var SceneManager = /** @class */ (function () {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
if (behavior) {
|
|
if (behavior) {
|
|
|
|
+ this._cameraBehaviorMapping[name] = type;
|
|
if (typeof behaviorConfig === "object") {
|
|
if (typeof behaviorConfig === "object") {
|
|
helper_1.extendClassWithConfig(behavior, behaviorConfig);
|
|
helper_1.extendClassWithConfig(behavior, behaviorConfig);
|
|
}
|
|
}
|