|
@@ -1468,6 +1468,10 @@ var BABYLON;
|
|
|
__extends(PointerInfoPre, _super);
|
|
|
function PointerInfoPre(type, event, localX, localY) {
|
|
|
var _this = _super.call(this, type, event) || this;
|
|
|
+ /**
|
|
|
+ * Ray from a pointer if availible (eg. 6dof controller)
|
|
|
+ */
|
|
|
+ _this.ray = null;
|
|
|
_this.skipOnPointerObservable = false;
|
|
|
_this.localPosition = new BABYLON.Vector2(localX, localY);
|
|
|
return _this;
|
|
@@ -25139,6 +25143,9 @@ var BABYLON;
|
|
|
*/
|
|
|
Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
|
|
|
var evt = new PointerEvent("pointermove", pointerEventInit);
|
|
|
+ if (this._checkPrePointerObservable(pickResult, evt, BABYLON.PointerEventTypes.POINTERMOVE)) {
|
|
|
+ return this;
|
|
|
+ }
|
|
|
return this._processPointerMove(pickResult, evt);
|
|
|
};
|
|
|
Scene.prototype._processPointerMove = function (pickResult, evt) {
|
|
@@ -25193,6 +25200,19 @@ var BABYLON;
|
|
|
}
|
|
|
return this;
|
|
|
};
|
|
|
+ Scene.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
|
|
|
+ var pi = new BABYLON.PointerInfoPre(type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
|
|
|
+ if (pickResult) {
|
|
|
+ pi.ray = pickResult.ray;
|
|
|
+ }
|
|
|
+ this.onPrePointerObservable.notifyObservers(pi, type);
|
|
|
+ if (pi.skipOnPointerObservable) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ };
|
|
|
/**
|
|
|
* Use this method to simulate a pointer down on a mesh
|
|
|
* The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
|
|
@@ -25202,6 +25222,9 @@ var BABYLON;
|
|
|
*/
|
|
|
Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
|
|
|
var evt = new PointerEvent("pointerdown", pointerEventInit);
|
|
|
+ if (this._checkPrePointerObservable(pickResult, evt, BABYLON.PointerEventTypes.POINTERDOWN)) {
|
|
|
+ return this;
|
|
|
+ }
|
|
|
return this._processPointerDown(pickResult, evt);
|
|
|
};
|
|
|
Scene.prototype._processPointerDown = function (pickResult, evt) {
|
|
@@ -25265,6 +25288,9 @@ var BABYLON;
|
|
|
var clickInfo = new ClickInfo();
|
|
|
clickInfo.singleClick = true;
|
|
|
clickInfo.ignore = true;
|
|
|
+ if (this._checkPrePointerObservable(pickResult, evt, BABYLON.PointerEventTypes.POINTERUP)) {
|
|
|
+ return this;
|
|
|
+ }
|
|
|
return this._processPointerUp(pickResult, evt, clickInfo);
|
|
|
};
|
|
|
Scene.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
|
|
@@ -25475,13 +25501,8 @@ var BABYLON;
|
|
|
this._onPointerMove = function (evt) {
|
|
|
_this._updatePointerPosition(evt);
|
|
|
// PreObservable support
|
|
|
- if (_this.onPrePointerObservable.hasObservers() && !_this._pointerCaptures[evt.pointerId]) {
|
|
|
- var type = evt.type === "mousewheel" || evt.type === "DOMMouseScroll" ? BABYLON.PointerEventTypes.POINTERWHEEL : BABYLON.PointerEventTypes.POINTERMOVE;
|
|
|
- var pi = new BABYLON.PointerInfoPre(type, evt, _this._unTranslatedPointerX, _this._unTranslatedPointerY);
|
|
|
- _this.onPrePointerObservable.notifyObservers(pi, type);
|
|
|
- if (pi.skipOnPointerObservable) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ if (_this._checkPrePointerObservable(null, evt, evt.type === "mousewheel" || evt.type === "DOMMouseScroll" ? BABYLON.PointerEventTypes.POINTERWHEEL : BABYLON.PointerEventTypes.POINTERMOVE)) {
|
|
|
+ return;
|
|
|
}
|
|
|
if (!_this.cameraToUseForPointers && !_this.activeCamera) {
|
|
|
return;
|
|
@@ -25503,13 +25524,8 @@ var BABYLON;
|
|
|
canvas.focus();
|
|
|
}
|
|
|
// PreObservable support
|
|
|
- if (_this.onPrePointerObservable.hasObservers()) {
|
|
|
- var type = BABYLON.PointerEventTypes.POINTERDOWN;
|
|
|
- var pi = new BABYLON.PointerInfoPre(type, evt, _this._unTranslatedPointerX, _this._unTranslatedPointerY);
|
|
|
- _this.onPrePointerObservable.notifyObservers(pi, type);
|
|
|
- if (pi.skipOnPointerObservable) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ if (_this._checkPrePointerObservable(null, evt, BABYLON.PointerEventTypes.POINTERDOWN)) {
|
|
|
+ return;
|
|
|
}
|
|
|
if (!_this.cameraToUseForPointers && !_this.activeCamera) {
|
|
|
return;
|
|
@@ -25566,28 +25582,19 @@ var BABYLON;
|
|
|
if (!clickInfo.ignore) {
|
|
|
if (!clickInfo.hasSwiped) {
|
|
|
if (clickInfo.singleClick && _this.onPrePointerObservable.hasSpecificMask(BABYLON.PointerEventTypes.POINTERTAP)) {
|
|
|
- var type = BABYLON.PointerEventTypes.POINTERTAP;
|
|
|
- var pi = new BABYLON.PointerInfoPre(type, evt, _this._unTranslatedPointerX, _this._unTranslatedPointerY);
|
|
|
- _this.onPrePointerObservable.notifyObservers(pi, type);
|
|
|
- if (pi.skipOnPointerObservable) {
|
|
|
+ if (_this._checkPrePointerObservable(null, evt, BABYLON.PointerEventTypes.POINTERTAP)) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
if (clickInfo.doubleClick && _this.onPrePointerObservable.hasSpecificMask(BABYLON.PointerEventTypes.POINTERDOUBLETAP)) {
|
|
|
- var type = BABYLON.PointerEventTypes.POINTERDOUBLETAP;
|
|
|
- var pi = new BABYLON.PointerInfoPre(type, evt, _this._unTranslatedPointerX, _this._unTranslatedPointerY);
|
|
|
- _this.onPrePointerObservable.notifyObservers(pi, type);
|
|
|
- if (pi.skipOnPointerObservable) {
|
|
|
+ if (_this._checkPrePointerObservable(null, evt, BABYLON.PointerEventTypes.POINTERDOUBLETAP)) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- var type = BABYLON.PointerEventTypes.POINTERUP;
|
|
|
- var pi = new BABYLON.PointerInfoPre(type, evt, _this._unTranslatedPointerX, _this._unTranslatedPointerY);
|
|
|
- _this.onPrePointerObservable.notifyObservers(pi, type);
|
|
|
- if (pi.skipOnPointerObservable) {
|
|
|
+ if (_this._checkPrePointerObservable(null, evt, BABYLON.PointerEventTypes.POINTERUP)) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
@@ -27827,8 +27834,10 @@ var BABYLON;
|
|
|
};
|
|
|
/**
|
|
|
* Render the scene
|
|
|
+ * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
|
|
|
*/
|
|
|
- Scene.prototype.render = function () {
|
|
|
+ Scene.prototype.render = function (updateCameras) {
|
|
|
+ if (updateCameras === void 0) { updateCameras = true; }
|
|
|
if (this.isDisposed) {
|
|
|
return;
|
|
|
}
|
|
@@ -27895,24 +27904,26 @@ var BABYLON;
|
|
|
this._gamepadManager._checkGamepadsStatus();
|
|
|
}
|
|
|
// Update Cameras
|
|
|
- if (this.activeCameras.length > 0) {
|
|
|
- for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
|
|
|
- var camera = this.activeCameras[cameraIndex];
|
|
|
- camera.update();
|
|
|
- if (camera.cameraRigMode !== BABYLON.Camera.RIG_MODE_NONE) {
|
|
|
- // rig cameras
|
|
|
- for (var index = 0; index < camera._rigCameras.length; index++) {
|
|
|
- camera._rigCameras[index].update();
|
|
|
+ if (updateCameras) {
|
|
|
+ if (this.activeCameras.length > 0) {
|
|
|
+ for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
|
|
|
+ var camera = this.activeCameras[cameraIndex];
|
|
|
+ camera.update();
|
|
|
+ if (camera.cameraRigMode !== BABYLON.Camera.RIG_MODE_NONE) {
|
|
|
+ // rig cameras
|
|
|
+ for (var index = 0; index < camera._rigCameras.length; index++) {
|
|
|
+ camera._rigCameras[index].update();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- else if (this.activeCamera) {
|
|
|
- this.activeCamera.update();
|
|
|
- if (this.activeCamera.cameraRigMode !== BABYLON.Camera.RIG_MODE_NONE) {
|
|
|
- // rig cameras
|
|
|
- for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
|
|
|
- this.activeCamera._rigCameras[index].update();
|
|
|
+ else if (this.activeCamera) {
|
|
|
+ this.activeCamera.update();
|
|
|
+ if (this.activeCamera.cameraRigMode !== BABYLON.Camera.RIG_MODE_NONE) {
|
|
|
+ // rig cameras
|
|
|
+ for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
|
|
|
+ this.activeCamera._rigCameras[index].update();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -86891,7 +86902,6 @@ var BABYLON;
|
|
|
this.utilityLayerScene = new BABYLON.Scene(originalScene.getEngine());
|
|
|
originalScene.getEngine().scenes.pop();
|
|
|
// Render directly on top of existing scene without clearing
|
|
|
- this.utilityLayerScene.clearColor = new BABYLON.Color4(0, 0, 0, 0);
|
|
|
this.utilityLayerScene.autoClear = false;
|
|
|
this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
|
|
|
if (_this.shouldRender) {
|
|
@@ -86907,7 +86917,7 @@ var BABYLON;
|
|
|
*/
|
|
|
UtilityLayerRenderer.prototype.render = function () {
|
|
|
this._updateCamera();
|
|
|
- this.utilityLayerScene.render();
|
|
|
+ this.utilityLayerScene.render(false);
|
|
|
};
|
|
|
/**
|
|
|
* Disposes of the renderer
|
|
@@ -86934,6 +86944,148 @@ var BABYLON;
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|
|
|
/**
|
|
|
+ * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
|
|
|
+ */
|
|
|
+ var Gizmo = /** @class */ (function () {
|
|
|
+ /**
|
|
|
+ * Creates a gizmo
|
|
|
+ * @param gizmoLayer The utility layer the gizmo will be added to
|
|
|
+ */
|
|
|
+ function Gizmo(/** The utility layer the gizmo will be added to */ gizmoLayer) {
|
|
|
+ var _this = this;
|
|
|
+ this.gizmoLayer = gizmoLayer;
|
|
|
+ this._rootMesh = new BABYLON.Mesh("gizmoRootNode", gizmoLayer.utilityLayerScene);
|
|
|
+ this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
|
|
|
+ if (_this.gizmoLayer.utilityLayerScene.activeCamera && _this.attachedMesh) {
|
|
|
+ var dist = _this.attachedMesh.position.subtract(_this.gizmoLayer.utilityLayerScene.activeCamera.position).length() / 5;
|
|
|
+ _this._rootMesh.scaling.set(dist, dist, dist);
|
|
|
+ }
|
|
|
+ if (_this.attachedMesh) {
|
|
|
+ _this._rootMesh.position.copyFrom(_this.attachedMesh.position);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Disposes of the gizmo
|
|
|
+ */
|
|
|
+ Gizmo.prototype.dispose = function () {
|
|
|
+ this._rootMesh.dispose();
|
|
|
+ if (this._beforeRenderObserver) {
|
|
|
+ this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ return Gizmo;
|
|
|
+ }());
|
|
|
+ BABYLON.Gizmo = Gizmo;
|
|
|
+})(BABYLON || (BABYLON = {}));
|
|
|
+
|
|
|
+//# sourceMappingURL=babylon.gizmo.js.map
|
|
|
+
|
|
|
+
|
|
|
+var BABYLON;
|
|
|
+(function (BABYLON) {
|
|
|
+ /**
|
|
|
+ * Single axis drag gizmo
|
|
|
+ */
|
|
|
+ var AxisDragGizmo = /** @class */ (function (_super) {
|
|
|
+ __extends(AxisDragGizmo, _super);
|
|
|
+ /**
|
|
|
+ * Creates an AxisDragGizmo
|
|
|
+ * @param gizmoLayer The utility layer the gizmo will be added to
|
|
|
+ * @param dragAxis The axis which the gizmo will be able to drag on
|
|
|
+ * @param color The color of the gizmo
|
|
|
+ */
|
|
|
+ function AxisDragGizmo(gizmoLayer, dragAxis, color) {
|
|
|
+ var _this = _super.call(this, gizmoLayer) || this;
|
|
|
+ // Create Material
|
|
|
+ var coloredMaterial = new BABYLON.StandardMaterial("", gizmoLayer.utilityLayerScene);
|
|
|
+ coloredMaterial.disableLighting = true;
|
|
|
+ coloredMaterial.emissiveColor = color;
|
|
|
+ // Build mesh on root node
|
|
|
+ var arrowMesh = BABYLON.MeshBuilder.CreateCylinder("yPosMesh", { diameterTop: 0, height: 2, tessellation: 96 }, gizmoLayer.utilityLayerScene);
|
|
|
+ var arrowTail = BABYLON.MeshBuilder.CreateCylinder("yPosMesh", { diameter: 0.03, height: 0.2, tessellation: 96 }, gizmoLayer.utilityLayerScene);
|
|
|
+ _this._rootMesh.addChild(arrowMesh);
|
|
|
+ _this._rootMesh.addChild(arrowTail);
|
|
|
+ // Position arrow pointing in its drag axis
|
|
|
+ arrowMesh.scaling.scaleInPlace(0.1);
|
|
|
+ arrowMesh.material = coloredMaterial;
|
|
|
+ arrowMesh.rotation.x = Math.PI / 2;
|
|
|
+ arrowMesh.position.z += 0.3;
|
|
|
+ arrowTail.rotation.x = Math.PI / 2;
|
|
|
+ arrowTail.material = coloredMaterial;
|
|
|
+ arrowTail.position.z += 0.2;
|
|
|
+ _this._rootMesh.lookAt(_this._rootMesh.position.subtract(dragAxis));
|
|
|
+ // Add drag behavior to handle events when the gizmo is dragged
|
|
|
+ _this._dragBehavior = new BABYLON.PointerDragBehavior({ dragAxis: dragAxis, pointerObservableScene: gizmoLayer.originalScene });
|
|
|
+ _this._dragBehavior.moveAttached = false;
|
|
|
+ _this._rootMesh.addBehavior(_this._dragBehavior);
|
|
|
+ _this._dragBehavior.onDragObservable.add(function (event) {
|
|
|
+ if (_this.attachedMesh) {
|
|
|
+ _this.attachedMesh.position.addInPlace(event.delta);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return _this;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Disposes of the gizmo
|
|
|
+ */
|
|
|
+ AxisDragGizmo.prototype.dispose = function () {
|
|
|
+ this._dragBehavior.detach();
|
|
|
+ _super.prototype.dispose.call(this);
|
|
|
+ };
|
|
|
+ return AxisDragGizmo;
|
|
|
+ }(BABYLON.Gizmo));
|
|
|
+ BABYLON.AxisDragGizmo = AxisDragGizmo;
|
|
|
+})(BABYLON || (BABYLON = {}));
|
|
|
+
|
|
|
+//# sourceMappingURL=babylon.axisDragGizmo.js.map
|
|
|
+
|
|
|
+
|
|
|
+var BABYLON;
|
|
|
+(function (BABYLON) {
|
|
|
+ /**
|
|
|
+ * Gizmo that enables dragging a mesh along 3 axis
|
|
|
+ */
|
|
|
+ var PositionGizmo = /** @class */ (function (_super) {
|
|
|
+ __extends(PositionGizmo, _super);
|
|
|
+ /**
|
|
|
+ * Creates a PositionGizmo
|
|
|
+ * @param gizmoLayer The utility layer the gizmo will be added to
|
|
|
+ */
|
|
|
+ function PositionGizmo(gizmoLayer) {
|
|
|
+ var _this = _super.call(this, gizmoLayer) || this;
|
|
|
+ _this._xDrag = new BABYLON.AxisDragGizmo(gizmoLayer, new BABYLON.Vector3(1, 0, 0), BABYLON.Color3.FromHexString("#00b894"));
|
|
|
+ _this._yDrag = new BABYLON.AxisDragGizmo(gizmoLayer, new BABYLON.Vector3(0, 1, 0), BABYLON.Color3.FromHexString("#d63031"));
|
|
|
+ _this._zDrag = new BABYLON.AxisDragGizmo(gizmoLayer, new BABYLON.Vector3(0, 0, 1), BABYLON.Color3.FromHexString("#0984e3"));
|
|
|
+ return _this;
|
|
|
+ }
|
|
|
+ Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
|
|
|
+ set: function (mesh) {
|
|
|
+ this._xDrag.attachedMesh = mesh;
|
|
|
+ this._yDrag.attachedMesh = mesh;
|
|
|
+ this._zDrag.attachedMesh = mesh;
|
|
|
+ },
|
|
|
+ enumerable: true,
|
|
|
+ configurable: true
|
|
|
+ });
|
|
|
+ /**
|
|
|
+ * Disposes of the gizmo
|
|
|
+ */
|
|
|
+ PositionGizmo.prototype.dispose = function () {
|
|
|
+ this._xDrag.dispose();
|
|
|
+ this._yDrag.dispose();
|
|
|
+ this._zDrag.dispose();
|
|
|
+ };
|
|
|
+ return PositionGizmo;
|
|
|
+ }(BABYLON.Gizmo));
|
|
|
+ BABYLON.PositionGizmo = PositionGizmo;
|
|
|
+})(BABYLON || (BABYLON = {}));
|
|
|
+
|
|
|
+//# sourceMappingURL=babylon.positionGizmo.js.map
|
|
|
+
|
|
|
+var BABYLON;
|
|
|
+(function (BABYLON) {
|
|
|
+ /**
|
|
|
* Defines a target to use with MorphTargetManager
|
|
|
* @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
|
|
|
*/
|
|
@@ -96444,7 +96596,7 @@ var BABYLON;
|
|
|
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
|
|
|
+ * @param options The drag axis or normal of the plane that will be dragged across. pointerObservableScene can be used to listen to drag events from another scene(eg. if the attached mesh is in an overlay scene).
|
|
|
*/
|
|
|
function PointerDragBehavior(options) {
|
|
|
this.options = options;
|
|
@@ -96504,6 +96656,9 @@ var BABYLON;
|
|
|
PointerDragBehavior.prototype.attach = function (ownerNode) {
|
|
|
var _this = this;
|
|
|
this._scene = ownerNode.getScene();
|
|
|
+ if (!this.options.pointerObservableScene) {
|
|
|
+ this.options.pointerObservableScene = this._scene;
|
|
|
+ }
|
|
|
this._attachedNode = ownerNode;
|
|
|
// Initialize drag plane to not interfere with existing scene
|
|
|
if (!PointerDragBehavior._planeScene) {
|
|
@@ -96515,32 +96670,44 @@ var BABYLON;
|
|
|
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 });
|
|
|
- }
|
|
|
+ var pickPredicate = function (m) {
|
|
|
+ return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
|
|
|
+ };
|
|
|
+ this._pointerObserver = this.options.pointerObservableScene.onPrePointerObservable.add(function (pointerInfoPre, eventState) {
|
|
|
+ // Check if attached mesh is picked
|
|
|
+ var pickInfo = pointerInfoPre.ray ? _this._scene.pickWithRay(pointerInfoPre.ray, pickPredicate) : _this._scene.pick(_this._scene.pointerX, _this._scene.pointerY, pickPredicate);
|
|
|
+ if (pickInfo) {
|
|
|
+ pickInfo.ray = pointerInfoPre.ray;
|
|
|
+ if (!pickInfo.ray) {
|
|
|
+ pickInfo.ray = _this.options.pointerObservableScene.createPickingRay(_this._scene.pointerX, _this._scene.pointerY, BABYLON.Matrix.Identity(), _this._scene.activeCamera);
|
|
|
+ }
|
|
|
+ if (pickInfo.hit) {
|
|
|
+ eventState.skipNextObservers = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (pointerInfoPre.type == BABYLON.PointerEventTypes.POINTERDOWN) {
|
|
|
+ if (!dragging && pickInfo && pickInfo.hit && pickInfo.pickedMesh && pickInfo.ray) {
|
|
|
+ _this._updateDragPlanePosition(pickInfo.ray);
|
|
|
+ var pickedPoint = _this._pickWithRayOnDragPlane(pickInfo.ray);
|
|
|
+ if (pickedPoint) {
|
|
|
+ dragging = true;
|
|
|
+ _this._draggingID = pointerInfoPre.event.pointerId;
|
|
|
+ lastPosition.copyFrom(pickedPoint);
|
|
|
+ _this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if (pointerInfo.type == BABYLON.PointerEventTypes.POINTERUP) {
|
|
|
- if (_this._draggingID == pointerInfo.event.pointerId) {
|
|
|
+ else if (pointerInfoPre.type == BABYLON.PointerEventTypes.POINTERUP) {
|
|
|
+ if (_this._draggingID == pointerInfoPre.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);
|
|
|
+ else if (pointerInfoPre.type == BABYLON.PointerEventTypes.POINTERMOVE) {
|
|
|
+ if (_this._draggingID == pointerInfoPre.event.pointerId && dragging && pickInfo && pickInfo.ray) {
|
|
|
+ var pickedPoint = _this._pickWithRayOnDragPlane(pickInfo.ray);
|
|
|
+ _this._updateDragPlanePosition(pickInfo.ray);
|
|
|
if (pickedPoint) {
|
|
|
// depending on the drag mode option drag accordingly
|
|
|
if (_this.options.dragAxis) {
|
|
@@ -96602,7 +96769,7 @@ var BABYLON;
|
|
|
*/
|
|
|
PointerDragBehavior.prototype.detach = function () {
|
|
|
if (this._pointerObserver) {
|
|
|
- this._scene.onPointerObservable.remove(this._pointerObserver);
|
|
|
+ this._scene.onPrePointerObservable.remove(this._pointerObserver);
|
|
|
}
|
|
|
};
|
|
|
return PointerDragBehavior;
|
|
@@ -108622,6 +108789,7 @@ var SceneManager = /** @class */ (function () {
|
|
|
this._mainColor = babylonjs_1.Color3.White();
|
|
|
this._reflectionColor = babylonjs_1.Color3.White();
|
|
|
this._white = babylonjs_1.Color3.White();
|
|
|
+ this._forceShadowUpdate = false;
|
|
|
this._processShadows = true;
|
|
|
this._groundEnabled = true;
|
|
|
this._groundMirrorEnabled = true;
|
|
@@ -108640,6 +108808,10 @@ var SceneManager = /** @class */ (function () {
|
|
|
_this.camera.alpha = (_this._viewer.configuration.camera && _this._viewer.configuration.camera.alpha) || _this.camera.alpha;
|
|
|
_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.scene.lights.filter(light => light instanceof ShadowLight).forEach(light => {
|
|
|
+ // casting ais safe, due to the constraints tested before
|
|
|
+ (<ShadowLight>light).setDirectionToTarget(center);
|
|
|
+ });*/
|
|
|
};
|
|
|
this._cameraBehaviorMapping = {};
|
|
|
this.models = [];
|
|
@@ -108669,9 +108841,10 @@ var SceneManager = /** @class */ (function () {
|
|
|
}
|
|
|
};
|
|
|
scene.registerBeforeRender(function () {
|
|
|
- if (scene.animatables && scene.animatables.length > 0) {
|
|
|
+ if (_this._forceShadowUpdate || (scene.animatables && scene.animatables.length > 0)) {
|
|
|
// make sure all models are loaded
|
|
|
updateShadows();
|
|
|
+ _this._forceShadowUpdate = false;
|
|
|
}
|
|
|
else if (!(_this.models.every(function (model) {
|
|
|
if (!model.shadowsRenderedAfterLoad) {
|
|
@@ -108958,6 +109131,14 @@ var SceneManager = /** @class */ (function () {
|
|
|
var mainColor = new babylonjs_1.Color3().copyFrom(newConfiguration.lab.environmentMainColor);
|
|
|
this.environmentHelper.setMainColor(mainColor);
|
|
|
}
|
|
|
+ if (newConfiguration.lab.globalLightRotation !== undefined) {
|
|
|
+ // rotate all lights that are shadow lights
|
|
|
+ this.scene.lights.filter(function (light) { return light instanceof babylonjs_1.ShadowLight; }).forEach(function (light) {
|
|
|
+ // casting and '!' are safe, due to the constraints tested before
|
|
|
+ _this.labs.rotateShadowLight(light, newConfiguration.lab.globalLightRotation);
|
|
|
+ });
|
|
|
+ this._forceShadowUpdate = true;
|
|
|
+ }
|
|
|
}
|
|
|
if (this._defaultRenderingPipeline && this._defaultRenderingPipeline.imageProcessing) {
|
|
|
this._defaultRenderingPipeline.imageProcessing.fromLinearSpace = true;
|
|
@@ -109282,7 +109463,7 @@ var SceneManager = /** @class */ (function () {
|
|
|
if (this.scene.imageProcessingConfiguration) {
|
|
|
this.scene.imageProcessingConfiguration.colorCurvesEnabled = true;
|
|
|
this.scene.imageProcessingConfiguration.vignetteEnabled = true;
|
|
|
- this.scene.imageProcessingConfiguration.toneMappingEnabled = !!cameraConfig.toneMappingEnabled;
|
|
|
+ this.scene.imageProcessingConfiguration.toneMappingEnabled = !!configuration_1.getConfigurationKey("camera.toneMappingEnabled", this._viewer.configuration);
|
|
|
}
|
|
|
helper_1.extendClassWithConfig(this.camera, cameraConfig);
|
|
|
this.onCameraConfiguredObservable.notifyObservers({
|
|
@@ -109452,7 +109633,8 @@ var SceneManager = /** @class */ (function () {
|
|
|
var _this = this;
|
|
|
if (lightsConfiguration === void 0) { lightsConfiguration = {}; }
|
|
|
// sanity check!
|
|
|
- if (!Object.keys(lightsConfiguration).length) {
|
|
|
+ var lightKeys = Object.keys(lightsConfiguration).filter(function (name) { return name !== 'globalRotation'; });
|
|
|
+ if (!lightKeys.length) {
|
|
|
if (!this.scene.lights.length)
|
|
|
this.scene.createDefaultLight(true);
|
|
|
}
|
|
@@ -109467,11 +109649,14 @@ var SceneManager = /** @class */ (function () {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- Object.keys(lightsConfiguration).forEach(function (name, idx) {
|
|
|
+ lightKeys.forEach(function (name, idx) {
|
|
|
var lightConfig = { type: 0 };
|
|
|
if (typeof lightsConfiguration[name] === 'object') {
|
|
|
lightConfig = lightsConfiguration[name];
|
|
|
}
|
|
|
+ if (typeof lightsConfiguration[name] === 'number') {
|
|
|
+ lightConfig.type = lightsConfiguration[name];
|
|
|
+ }
|
|
|
lightConfig.name = name;
|
|
|
var light;
|
|
|
// light is not already available
|
|
@@ -109484,6 +109669,9 @@ var SceneManager = /** @class */ (function () {
|
|
|
else {
|
|
|
// available? get it from the scene
|
|
|
light = _this.scene.getLightByName(name);
|
|
|
+ if (typeof lightsConfiguration[name] === 'boolean') {
|
|
|
+ lightConfig.type = light.getTypeID();
|
|
|
+ }
|
|
|
lightsAvailable_1 = lightsAvailable_1.filter(function (ln) { return ln !== name; });
|
|
|
if (lightConfig.type !== undefined && light.getTypeID() !== lightConfig.type) {
|
|
|
light.dispose();
|
|
@@ -110043,15 +110231,15 @@ var ViewerLabs = /** @class */ (function () {
|
|
|
this.environment = {
|
|
|
//irradiance
|
|
|
irradiancePolynomialCoefficients: {
|
|
|
- x: new BABYLON.Vector3(0, 0, 0),
|
|
|
- y: new BABYLON.Vector3(0, 0, 0),
|
|
|
- z: new BABYLON.Vector3(0, 0, 0),
|
|
|
- xx: new BABYLON.Vector3(0, 0, 0),
|
|
|
- yy: new BABYLON.Vector3(0, 0, 0),
|
|
|
- zz: new BABYLON.Vector3(0, 0, 0),
|
|
|
- yz: new BABYLON.Vector3(0, 0, 0),
|
|
|
- zx: new BABYLON.Vector3(0, 0, 0),
|
|
|
- xy: new BABYLON.Vector3(0, 0, 0)
|
|
|
+ x: new babylonjs_1.Vector3(0, 0, 0),
|
|
|
+ y: new babylonjs_1.Vector3(0, 0, 0),
|
|
|
+ z: new babylonjs_1.Vector3(0, 0, 0),
|
|
|
+ xx: new babylonjs_1.Vector3(0, 0, 0),
|
|
|
+ yy: new babylonjs_1.Vector3(0, 0, 0),
|
|
|
+ zz: new babylonjs_1.Vector3(0, 0, 0),
|
|
|
+ yz: new babylonjs_1.Vector3(0, 0, 0),
|
|
|
+ zx: new babylonjs_1.Vector3(0, 0, 0),
|
|
|
+ xy: new babylonjs_1.Vector3(0, 0, 0)
|
|
|
},
|
|
|
textureIntensityScale: 1.0
|
|
|
};
|
|
@@ -110092,7 +110280,7 @@ var ViewerLabs = /** @class */ (function () {
|
|
|
if (!this.environment)
|
|
|
return;
|
|
|
//set orientation
|
|
|
- var rotatquatRotationionY = babylonjs_1.Quaternion.RotationAxis(BABYLON.Axis.Y, rotationY || 0);
|
|
|
+ var rotatquatRotationionY = babylonjs_1.Quaternion.RotationAxis(babylonjs_1.Axis.Y, rotationY || 0);
|
|
|
// Add env texture to the scene.
|
|
|
if (this.environment.specularTexture) {
|
|
|
// IE crashes when disposing the old texture and setting a new one
|
|
@@ -110103,7 +110291,7 @@ var ViewerLabs = /** @class */ (function () {
|
|
|
this._sceneManager.scene.environmentTexture.level = this.environment.textureIntensityScale;
|
|
|
this._sceneManager.scene.environmentTexture.invertZ = true;
|
|
|
this._sceneManager.scene.environmentTexture.lodLevelInAlpha = true;
|
|
|
- var poly = this._sceneManager.scene.environmentTexture.sphericalPolynomial || new BABYLON.SphericalPolynomial();
|
|
|
+ var poly = this._sceneManager.scene.environmentTexture.sphericalPolynomial || new babylonjs_1.SphericalPolynomial();
|
|
|
poly.x = this.environment.irradiancePolynomialCoefficients.x;
|
|
|
poly.y = this.environment.irradiancePolynomialCoefficients.y;
|
|
|
poly.z = this.environment.irradiancePolynomialCoefficients.z;
|
|
@@ -110115,7 +110303,7 @@ var ViewerLabs = /** @class */ (function () {
|
|
|
poly.zz = this.environment.irradiancePolynomialCoefficients.zz;
|
|
|
this._sceneManager.scene.environmentTexture.sphericalPolynomial = poly;
|
|
|
//set orientation
|
|
|
- BABYLON.Matrix.FromQuaternionToRef(rotatquatRotationionY, this._sceneManager.scene.environmentTexture.getReflectionTextureMatrix());
|
|
|
+ babylonjs_1.Matrix.FromQuaternionToRef(rotatquatRotationionY, this._sceneManager.scene.environmentTexture.getReflectionTextureMatrix());
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -110135,6 +110323,21 @@ var ViewerLabs = /** @class */ (function () {
|
|
|
}
|
|
|
return returnUrl;
|
|
|
};
|
|
|
+ ViewerLabs.prototype.rotateShadowLight = function (shadowLight, amount, point, axis, target) {
|
|
|
+ if (point === void 0) { point = babylonjs_1.Vector3.Zero(); }
|
|
|
+ if (axis === void 0) { axis = babylonjs_1.Axis.Y; }
|
|
|
+ if (target === void 0) { target = babylonjs_1.Vector3.Zero(); }
|
|
|
+ axis.normalize();
|
|
|
+ point.subtractToRef(shadowLight.position, babylonjs_1.Tmp.Vector3[0]);
|
|
|
+ babylonjs_1.Matrix.TranslationToRef(babylonjs_1.Tmp.Vector3[0].x, babylonjs_1.Tmp.Vector3[0].y, babylonjs_1.Tmp.Vector3[0].z, babylonjs_1.Tmp.Matrix[0]);
|
|
|
+ babylonjs_1.Tmp.Matrix[0].invertToRef(babylonjs_1.Tmp.Matrix[2]);
|
|
|
+ babylonjs_1.Matrix.RotationAxisToRef(axis, amount, babylonjs_1.Tmp.Matrix[1]);
|
|
|
+ babylonjs_1.Tmp.Matrix[2].multiplyToRef(babylonjs_1.Tmp.Matrix[1], babylonjs_1.Tmp.Matrix[2]);
|
|
|
+ babylonjs_1.Tmp.Matrix[2].multiplyToRef(babylonjs_1.Tmp.Matrix[0], babylonjs_1.Tmp.Matrix[2]);
|
|
|
+ babylonjs_1.Tmp.Matrix[2].decompose(babylonjs_1.Tmp.Vector3[0], babylonjs_1.Tmp.Quaternion[0], babylonjs_1.Tmp.Vector3[1]);
|
|
|
+ shadowLight.position.addInPlace(babylonjs_1.Tmp.Vector3[1]);
|
|
|
+ shadowLight.setDirectionToTarget(target);
|
|
|
+ };
|
|
|
return ViewerLabs;
|
|
|
}());
|
|
|
exports.ViewerLabs = ViewerLabs;
|