|
@@ -13794,23 +13794,29 @@ var BABYLON;
|
|
|
* @param clearColor defines the clear color
|
|
|
*/
|
|
|
Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
|
|
|
+ this.enableScissor(x, y, width, height);
|
|
|
+ this.clear(clearColor, true, true, true);
|
|
|
+ this.disableScissor();
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
|
|
|
+ * @param x defines the x-coordinate of the top left corner of the clear rectangle
|
|
|
+ * @param y defines the y-coordinate of the corner of the clear rectangle
|
|
|
+ * @param width defines the width of the clear rectangle
|
|
|
+ * @param height defines the height of the clear rectangle
|
|
|
+ */
|
|
|
+ Engine.prototype.enableScissor = function (x, y, width, height) {
|
|
|
var gl = this._gl;
|
|
|
- // Save state
|
|
|
- var curScissor = gl.getParameter(gl.SCISSOR_TEST);
|
|
|
- var curScissorBox = gl.getParameter(gl.SCISSOR_BOX);
|
|
|
// Change state
|
|
|
gl.enable(gl.SCISSOR_TEST);
|
|
|
gl.scissor(x, y, width, height);
|
|
|
- // Clear
|
|
|
- this.clear(clearColor, true, true, true);
|
|
|
- // Restore state
|
|
|
- gl.scissor(curScissorBox[0], curScissorBox[1], curScissorBox[2], curScissorBox[3]);
|
|
|
- if (curScissor === true) {
|
|
|
- gl.enable(gl.SCISSOR_TEST);
|
|
|
- }
|
|
|
- else {
|
|
|
- gl.disable(gl.SCISSOR_TEST);
|
|
|
- }
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Disable previously set scissor test rectangle
|
|
|
+ */
|
|
|
+ Engine.prototype.disableScissor = function () {
|
|
|
+ var gl = this._gl;
|
|
|
+ gl.disable(gl.SCISSOR_TEST);
|
|
|
};
|
|
|
/** @hidden */
|
|
|
Engine.prototype._viewport = function (x, y, width, height) {
|
|
@@ -20605,9 +20611,9 @@ var BABYLON;
|
|
|
if (yawCor === void 0) { yawCor = 0; }
|
|
|
if (pitchCor === void 0) { pitchCor = 0; }
|
|
|
if (rollCor === void 0) { rollCor = 0; }
|
|
|
- var yaw = -Math.atan2(localAxis.z, localAxis.x) - Math.PI / 2;
|
|
|
+ var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
|
|
|
var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
|
|
|
- var pitch = Math.atan2(localAxis.y, len);
|
|
|
+ var pitch = -Math.atan2(localAxis.y, len);
|
|
|
if (this.rotationQuaternion) {
|
|
|
BABYLON.Quaternion.RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
|
|
|
}
|
|
@@ -66648,7 +66654,6 @@ var BABYLON;
|
|
|
function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
|
|
|
if (scaleLines === void 0) { scaleLines = 1; }
|
|
|
if (renderingGroupId === void 0) { renderingGroupId = 2; }
|
|
|
- this._tmpVector = new BABYLON.Vector3();
|
|
|
this._scaleLinesFactor = 4;
|
|
|
this._instanced = false;
|
|
|
/**
|
|
@@ -66675,13 +66680,10 @@ var BABYLON;
|
|
|
zAxis = BABYLON.AxisDragGizmo._CreateArrow(scene, blueColoredMaterial);
|
|
|
}
|
|
|
this._xAxis = xAxis;
|
|
|
- this._xAxis.rotationQuaternion = new BABYLON.Quaternion();
|
|
|
this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
|
|
|
this._yAxis = yAxis;
|
|
|
- this._yAxis.rotationQuaternion = new BABYLON.Quaternion();
|
|
|
this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
|
|
|
this._zAxis = zAxis;
|
|
|
- this._zAxis.rotationQuaternion = new BABYLON.Quaternion();
|
|
|
this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
|
|
|
if (renderingGroupId != null) {
|
|
|
AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
|
|
@@ -66724,16 +66726,13 @@ var BABYLON;
|
|
|
*/
|
|
|
AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
|
|
|
this._xAxis.position.copyFrom(position);
|
|
|
- xaxis.scaleToRef(-1, this._tmpVector);
|
|
|
- this._xAxis.setDirection(this._tmpVector);
|
|
|
+ this._xAxis.setDirection(xaxis);
|
|
|
this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
|
|
|
this._yAxis.position.copyFrom(position);
|
|
|
- yaxis.scaleToRef(-1, this._tmpVector);
|
|
|
- this._yAxis.setDirection(this._tmpVector);
|
|
|
+ this._yAxis.setDirection(yaxis);
|
|
|
this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
|
|
|
this._zAxis.position.copyFrom(position);
|
|
|
- zaxis.scaleToRef(-1, this._tmpVector);
|
|
|
- this._zAxis.setDirection(this._tmpVector);
|
|
|
+ this._zAxis.setDirection(zaxis);
|
|
|
this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
|
|
|
};
|
|
|
/**
|
|
@@ -70760,7 +70759,7 @@ var BABYLON;
|
|
|
vertexData.applyToMesh(plane, options.updatable);
|
|
|
if (options.sourcePlane) {
|
|
|
plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
|
|
|
- plane.setDirection(options.sourcePlane.normal);
|
|
|
+ plane.setDirection(options.sourcePlane.normal.scale(-1));
|
|
|
}
|
|
|
return plane;
|
|
|
};
|
|
@@ -97792,7 +97791,7 @@ var BABYLON;
|
|
|
_this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new BABYLON.Quaternion());
|
|
|
}
|
|
|
if (!_this._options.disableBidirectionalTransformation) {
|
|
|
- _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePivotPoint(), _this._tmpQuat);
|
|
|
+ _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
|
|
|
}
|
|
|
_this._onBeforePhysicsStepCallbacks.forEach(function (func) {
|
|
|
func(_this);
|
|
@@ -100260,34 +100259,43 @@ var BABYLON;
|
|
|
var extendSize = impostor.getObjectExtendSize();
|
|
|
if (!ignoreChildren) {
|
|
|
var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
|
|
|
- if (meshChildren.length > 0) {
|
|
|
- returnValue = new Ammo.btCompoundShape();
|
|
|
- // Add shape of all children to the compound shape
|
|
|
- meshChildren.forEach(function (childMesh) {
|
|
|
- var childImpostor = childMesh.getPhysicsImpostor();
|
|
|
- if (childImpostor) {
|
|
|
- var shape = _this._createShape(childImpostor);
|
|
|
- // Position needs to be scaled based on parent's scaling
|
|
|
- var parentMat = childMesh.parent.getWorldMatrix().clone();
|
|
|
- var s = new BABYLON.Vector3();
|
|
|
- parentMat.decompose(s);
|
|
|
- _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
|
|
|
- _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
|
|
|
- _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
|
|
|
- returnValue.addChildShape(_this._tmpAmmoTransform, shape);
|
|
|
- childImpostor.dispose();
|
|
|
- }
|
|
|
- });
|
|
|
+ returnValue = new Ammo.btCompoundShape();
|
|
|
+ // Add shape of all children to the compound shape
|
|
|
+ var childrenAdded = 0;
|
|
|
+ meshChildren.forEach(function (childMesh) {
|
|
|
+ var childImpostor = childMesh.getPhysicsImpostor();
|
|
|
+ if (childImpostor) {
|
|
|
+ var shape = _this._createShape(childImpostor);
|
|
|
+ // Position needs to be scaled based on parent's scaling
|
|
|
+ var parentMat = childMesh.parent.getWorldMatrix().clone();
|
|
|
+ var s = new BABYLON.Vector3();
|
|
|
+ parentMat.decompose(s);
|
|
|
+ _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
|
|
|
+ _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
|
|
|
+ _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
|
|
|
+ returnValue.addChildShape(_this._tmpAmmoTransform, shape);
|
|
|
+ childImpostor.dispose();
|
|
|
+ childrenAdded++;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (childrenAdded > 0) {
|
|
|
// Add parents shape as a child if present
|
|
|
- var shape = this._createShape(impostor, true);
|
|
|
- if (shape) {
|
|
|
- this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
|
|
|
- this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
|
|
|
- this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
|
|
|
- returnValue.addChildShape(this._tmpAmmoTransform, shape);
|
|
|
+ if (impostor.type != BABYLON.PhysicsImpostor.NoImpostor) {
|
|
|
+ var shape = this._createShape(impostor, true);
|
|
|
+ if (shape) {
|
|
|
+ this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
|
|
|
+ this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
|
|
|
+ this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
|
|
|
+ returnValue.addChildShape(this._tmpAmmoTransform, shape);
|
|
|
+ }
|
|
|
}
|
|
|
return returnValue;
|
|
|
}
|
|
|
+ else {
|
|
|
+ // If no children with impostors create the actual shape below instead
|
|
|
+ Ammo.destroy(returnValue);
|
|
|
+ returnValue = null;
|
|
|
+ }
|
|
|
}
|
|
|
switch (impostor.type) {
|
|
|
case BABYLON.PhysicsImpostor.SphereImpostor:
|
|
@@ -100317,6 +100325,9 @@ var BABYLON;
|
|
|
// Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
|
|
|
returnValue = new Ammo.btSphereShape(extendSize.x / 2);
|
|
|
break;
|
|
|
+ default:
|
|
|
+ BABYLON.Tools.Warn("The impostor type is not currently supported by the ammo plugin.");
|
|
|
+ break;
|
|
|
}
|
|
|
return returnValue;
|
|
|
};
|
|
@@ -103549,13 +103560,13 @@ var BABYLON;
|
|
|
BABYLON.Vector3.CrossToRef(this._lineA, this._lookAt, this._lookAt);
|
|
|
this._lookAt.normalize();
|
|
|
this._dragPlane.position.copyFrom(this._pointA);
|
|
|
- this._pointA.subtractToRef(this._lookAt, this._lookAt);
|
|
|
+ this._pointA.addToRef(this._lookAt, this._lookAt);
|
|
|
this._dragPlane.lookAt(this._lookAt);
|
|
|
}
|
|
|
else if (this._options.dragPlaneNormal) {
|
|
|
this.useObjectOrienationForDragging ? BABYLON.Vector3.TransformCoordinatesToRef(this._options.dragPlaneNormal, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragPlaneNormal);
|
|
|
this._dragPlane.position.copyFrom(this._pointA);
|
|
|
- this._pointA.subtractToRef(this._localAxis, this._lookAt);
|
|
|
+ this._pointA.addToRef(this._localAxis, this._lookAt);
|
|
|
this._dragPlane.lookAt(this._lookAt);
|
|
|
}
|
|
|
else {
|
|
@@ -103785,7 +103796,7 @@ var BABYLON;
|
|
|
lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
|
|
|
// Set position and orientation of the controller
|
|
|
_this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
|
|
|
- _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.subtract(pointerInfo.pickInfo.ray.direction));
|
|
|
+ _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
|
|
|
// Attach the virtual drag mesh to the virtual origin mesh so it can be dragged
|
|
|
_this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
|
|
|
pickedMesh.computeWorldMatrix();
|
|
@@ -103849,7 +103860,7 @@ var BABYLON;
|
|
|
}
|
|
|
// Update the controller position
|
|
|
_this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
|
|
|
- _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.subtract(pointerInfo.pickInfo.ray.direction));
|
|
|
+ _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
|
|
|
_this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
|
|
|
// Move the virtualObjectsPosition into the picked mesh's space if needed
|
|
|
_this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
|
|
@@ -104355,7 +104366,7 @@ var BABYLON;
|
|
|
hoverMaterial.emissiveColor = color.add(new BABYLON.Color3(0.3, 0.3, 0.3));
|
|
|
// Build mesh on root node
|
|
|
var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
|
|
|
- arrow.lookAt(_this._rootMesh.position.subtract(dragAxis));
|
|
|
+ arrow.lookAt(_this._rootMesh.position.add(dragAxis));
|
|
|
arrow.scaling.scaleInPlace(1 / 3);
|
|
|
arrow.parent = _this._rootMesh;
|
|
|
var currentSnapDragDistance = 0;
|
|
@@ -104514,7 +104525,7 @@ var BABYLON;
|
|
|
arrowTail.scaling.scaleInPlace(0.26);
|
|
|
arrowTail.rotation.x = Math.PI / 2;
|
|
|
arrowTail.material = _this._coloredMaterial;
|
|
|
- arrow.lookAt(_this._rootMesh.position.subtract(dragAxis));
|
|
|
+ arrow.lookAt(_this._rootMesh.position.add(dragAxis));
|
|
|
_this._rootMesh.addChild(arrow);
|
|
|
arrow.scaling.scaleInPlace(1 / 3);
|
|
|
// Add drag behavior to handle events when the gizmo is dragged
|
|
@@ -104668,7 +104679,7 @@ var BABYLON;
|
|
|
rotationMesh.material = coloredMaterial;
|
|
|
rotationMesh.rotation.x = Math.PI / 2;
|
|
|
parentMesh.addChild(rotationMesh);
|
|
|
- parentMesh.lookAt(_this._rootMesh.position.subtract(planeNormal));
|
|
|
+ parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
|
|
|
_this._rootMesh.addChild(parentMesh);
|
|
|
parentMesh.scaling.scaleInPlace(1 / 3);
|
|
|
// Add drag behavior to handle events when the gizmo is dragged
|
|
@@ -105533,17 +105544,17 @@ var BABYLON;
|
|
|
if (i == 0) {
|
|
|
rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
|
|
|
rotateSpheres[index].position.addInPlace(new BABYLON.Vector3(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
|
|
|
- rotateSpheres[index].lookAt(BABYLON.Vector3.Cross(BABYLON.Vector3.Right(), rotateSpheres[index].position.normalizeToNew()).normalizeToNew().add(rotateSpheres[index].position));
|
|
|
+ rotateSpheres[index].lookAt(BABYLON.Vector3.Cross(rotateSpheres[index].position.normalizeToNew(), BABYLON.Vector3.Right()).normalizeToNew().add(rotateSpheres[index].position));
|
|
|
}
|
|
|
if (i == 1) {
|
|
|
rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
|
|
|
rotateSpheres[index].position.addInPlace(new BABYLON.Vector3(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
|
|
|
- rotateSpheres[index].lookAt(BABYLON.Vector3.Cross(BABYLON.Vector3.Up(), rotateSpheres[index].position.normalizeToNew()).normalizeToNew().add(rotateSpheres[index].position));
|
|
|
+ rotateSpheres[index].lookAt(BABYLON.Vector3.Cross(rotateSpheres[index].position.normalizeToNew(), BABYLON.Vector3.Up()).normalizeToNew().add(rotateSpheres[index].position));
|
|
|
}
|
|
|
if (i == 2) {
|
|
|
rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
|
|
|
rotateSpheres[index].position.addInPlace(new BABYLON.Vector3(-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
|
|
|
- rotateSpheres[index].lookAt(BABYLON.Vector3.Cross(BABYLON.Vector3.Forward(), rotateSpheres[index].position.normalizeToNew()).normalizeToNew().add(rotateSpheres[index].position));
|
|
|
+ rotateSpheres[index].lookAt(BABYLON.Vector3.Cross(rotateSpheres[index].position.normalizeToNew(), BABYLON.Vector3.Forward()).normalizeToNew().add(rotateSpheres[index].position));
|
|
|
}
|
|
|
if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
|
|
|
rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
|
|
@@ -109336,6 +109347,13 @@ var BABYLON;
|
|
|
if (this._interactionsEnabled) {
|
|
|
this._scene.registerBeforeRender(this.beforeRender);
|
|
|
}
|
|
|
+ if (this._displayLaserPointer) {
|
|
|
+ [this._leftController, this._rightController].forEach(function (controller) {
|
|
|
+ if (controller) {
|
|
|
+ controller._activatePointer();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
this._hasEnteredVR = true;
|
|
|
};
|
|
|
/**
|
|
@@ -109410,6 +109428,11 @@ var BABYLON;
|
|
|
}
|
|
|
// resize to update width and height when exiting vr exits fullscreen
|
|
|
this._scene.getEngine().resize();
|
|
|
+ [this._leftController, this._rightController].forEach(function (controller) {
|
|
|
+ if (controller) {
|
|
|
+ controller._deactivatePointer();
|
|
|
+ }
|
|
|
+ });
|
|
|
this._hasEnteredVR = false;
|
|
|
}
|
|
|
};
|
|
@@ -109547,7 +109570,9 @@ var BABYLON;
|
|
|
var controllerMesh = controller.webVRController.mesh;
|
|
|
if (controllerMesh) {
|
|
|
controller._interactionsEnabled = true;
|
|
|
- controller._activatePointer();
|
|
|
+ if (this.isInVRMode && this._displayLaserPointer) {
|
|
|
+ controller._activatePointer();
|
|
|
+ }
|
|
|
if (this.webVROptions.laserToggle) {
|
|
|
controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
|
|
|
// Enabling / disabling laserPointer
|