|
@@ -12953,7 +12953,7 @@ var BABYLON;
|
|
* Returns the current version of the framework
|
|
* Returns the current version of the framework
|
|
*/
|
|
*/
|
|
get: function () {
|
|
get: function () {
|
|
- return "4.0.0-alpha.9";
|
|
|
|
|
|
+ return "4.0.0-alpha.10";
|
|
},
|
|
},
|
|
enumerable: true,
|
|
enumerable: true,
|
|
configurable: true
|
|
configurable: true
|
|
@@ -20306,7 +20306,7 @@ var BABYLON;
|
|
if (this._cache.pivotMatrixUpdated) {
|
|
if (this._cache.pivotMatrixUpdated) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
- if (this.infiniteDistance !== this._cache.infiniteDistance) {
|
|
|
|
|
|
+ if (this.infiniteDistance) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
if (!this._cache.position.equals(this._position)) {
|
|
if (!this._cache.position.equals(this._position)) {
|
|
@@ -52719,7 +52719,10 @@ var BABYLON;
|
|
var camLeft = this._rigCameras[0];
|
|
var camLeft = this._rigCameras[0];
|
|
var camRight = this._rigCameras[1];
|
|
var camRight = this._rigCameras[1];
|
|
camLeft.beta = camRight.beta = this.beta;
|
|
camLeft.beta = camRight.beta = this.beta;
|
|
- camLeft.radius = camRight.radius = this.radius;
|
|
|
|
|
|
+ // This looks like being an issue in rig mode. Should be looked if
|
|
|
|
+ // further issues are found. but was modifying the view matrix twice
|
|
|
|
+ // Line below commented in order to fix http://www.html5gamedevs.com/topic/41454-confusion-about-camera-positions/
|
|
|
|
+ // camLeft.radius = camRight.radius = this.radius;
|
|
switch (this.cameraRigMode) {
|
|
switch (this.cameraRigMode) {
|
|
case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
|
|
case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
|
|
case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
|
|
case BABYLON.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
|
|
@@ -66602,68 +66605,81 @@ var BABYLON;
|
|
* Creates a new AxesViewer
|
|
* Creates a new AxesViewer
|
|
* @param scene defines the hosting scene
|
|
* @param scene defines the hosting scene
|
|
* @param scaleLines defines a number used to scale line length (1 by default)
|
|
* @param scaleLines defines a number used to scale line length (1 by default)
|
|
|
|
+ * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
|
|
|
|
+ * @param xAxis defines the node hierarchy used to render the x-axis
|
|
|
|
+ * @param yAxis defines the node hierarchy used to render the y-axis
|
|
|
|
+ * @param zAxis defines the node hierarchy used to render the z-axis
|
|
*/
|
|
*/
|
|
- function AxesViewer(scene, scaleLines) {
|
|
|
|
|
|
+ function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
|
|
if (scaleLines === void 0) { scaleLines = 1; }
|
|
if (scaleLines === void 0) { scaleLines = 1; }
|
|
|
|
+ if (renderingGroupId === void 0) { renderingGroupId = 2; }
|
|
|
|
+ this._tmpVector = new BABYLON.Vector3();
|
|
|
|
+ this._scaleLinesFactor = 4;
|
|
|
|
+ this._instanced = false;
|
|
/**
|
|
/**
|
|
* Gets or sets a number used to scale line length
|
|
* Gets or sets a number used to scale line length
|
|
*/
|
|
*/
|
|
this.scaleLines = 1;
|
|
this.scaleLines = 1;
|
|
this.scaleLines = scaleLines;
|
|
this.scaleLines = scaleLines;
|
|
- var greenColoredMaterial = new BABYLON.StandardMaterial("", scene);
|
|
|
|
- greenColoredMaterial.disableLighting = true;
|
|
|
|
- greenColoredMaterial.emissiveColor = BABYLON.Color3.Green().scale(0.5);
|
|
|
|
- var redColoredMaterial = new BABYLON.StandardMaterial("", scene);
|
|
|
|
- redColoredMaterial.disableLighting = true;
|
|
|
|
- redColoredMaterial.emissiveColor = BABYLON.Color3.Red().scale(0.5);
|
|
|
|
- var blueColoredMaterial = new BABYLON.StandardMaterial("", scene);
|
|
|
|
- blueColoredMaterial.disableLighting = true;
|
|
|
|
- blueColoredMaterial.emissiveColor = BABYLON.Color3.Blue().scale(0.5);
|
|
|
|
- this._xmesh = BABYLON.AxisDragGizmo._CreateArrow(scene, redColoredMaterial);
|
|
|
|
- this._ymesh = BABYLON.AxisDragGizmo._CreateArrow(scene, greenColoredMaterial);
|
|
|
|
- this._zmesh = BABYLON.AxisDragGizmo._CreateArrow(scene, blueColoredMaterial);
|
|
|
|
- this._xmesh.rotationQuaternion = new BABYLON.Quaternion();
|
|
|
|
- this._xmesh.scaling.scaleInPlace(4);
|
|
|
|
- this._ymesh.rotationQuaternion = new BABYLON.Quaternion();
|
|
|
|
- this._ymesh.scaling.scaleInPlace(4);
|
|
|
|
- this._zmesh.rotationQuaternion = new BABYLON.Quaternion();
|
|
|
|
- this._zmesh.scaling.scaleInPlace(4);
|
|
|
|
- AxesViewer._recursiveChangeRenderingGroupId(this._xmesh, 2);
|
|
|
|
- AxesViewer._recursiveChangeRenderingGroupId(this._ymesh, 2);
|
|
|
|
- AxesViewer._recursiveChangeRenderingGroupId(this._zmesh, 2);
|
|
|
|
|
|
+ if (!xAxis) {
|
|
|
|
+ var redColoredMaterial = new BABYLON.StandardMaterial("", scene);
|
|
|
|
+ redColoredMaterial.disableLighting = true;
|
|
|
|
+ redColoredMaterial.emissiveColor = BABYLON.Color3.Red().scale(0.5);
|
|
|
|
+ xAxis = BABYLON.AxisDragGizmo._CreateArrow(scene, redColoredMaterial);
|
|
|
|
+ }
|
|
|
|
+ if (!yAxis) {
|
|
|
|
+ var greenColoredMaterial = new BABYLON.StandardMaterial("", scene);
|
|
|
|
+ greenColoredMaterial.disableLighting = true;
|
|
|
|
+ greenColoredMaterial.emissiveColor = BABYLON.Color3.Green().scale(0.5);
|
|
|
|
+ yAxis = BABYLON.AxisDragGizmo._CreateArrow(scene, greenColoredMaterial);
|
|
|
|
+ }
|
|
|
|
+ if (!zAxis) {
|
|
|
|
+ var blueColoredMaterial = new BABYLON.StandardMaterial("", scene);
|
|
|
|
+ blueColoredMaterial.disableLighting = true;
|
|
|
|
+ blueColoredMaterial.emissiveColor = BABYLON.Color3.Blue().scale(0.5);
|
|
|
|
+ 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);
|
|
|
|
+ AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
|
|
|
|
+ AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
|
|
|
|
+ }
|
|
this.scene = scene;
|
|
this.scene = scene;
|
|
this.update(new BABYLON.Vector3(), BABYLON.Vector3.Right(), BABYLON.Vector3.Up(), BABYLON.Vector3.Forward());
|
|
this.update(new BABYLON.Vector3(), BABYLON.Vector3.Right(), BABYLON.Vector3.Up(), BABYLON.Vector3.Forward());
|
|
}
|
|
}
|
|
- Object.defineProperty(AxesViewer.prototype, "xAxisMesh", {
|
|
|
|
- /** Gets the mesh used to render x-axis */
|
|
|
|
|
|
+ Object.defineProperty(AxesViewer.prototype, "xAxis", {
|
|
|
|
+ /** Gets the node hierarchy used to render x-axis */
|
|
get: function () {
|
|
get: function () {
|
|
- return this._xmesh;
|
|
|
|
|
|
+ return this._xAxis;
|
|
},
|
|
},
|
|
enumerable: true,
|
|
enumerable: true,
|
|
configurable: true
|
|
configurable: true
|
|
});
|
|
});
|
|
- Object.defineProperty(AxesViewer.prototype, "yAxisMesh", {
|
|
|
|
- /** Gets the mesh used to render x-axis */
|
|
|
|
|
|
+ Object.defineProperty(AxesViewer.prototype, "yAxis", {
|
|
|
|
+ /** Gets the node hierarchy used to render y-axis */
|
|
get: function () {
|
|
get: function () {
|
|
- return this._ymesh;
|
|
|
|
|
|
+ return this._yAxis;
|
|
},
|
|
},
|
|
enumerable: true,
|
|
enumerable: true,
|
|
configurable: true
|
|
configurable: true
|
|
});
|
|
});
|
|
- Object.defineProperty(AxesViewer.prototype, "zAxisMesh", {
|
|
|
|
- /** Gets the mesh used to render x-axis */
|
|
|
|
|
|
+ Object.defineProperty(AxesViewer.prototype, "zAxis", {
|
|
|
|
+ /** Gets the node hierarchy used to render z-axis */
|
|
get: function () {
|
|
get: function () {
|
|
- return this._zmesh;
|
|
|
|
|
|
+ return this._zAxis;
|
|
},
|
|
},
|
|
enumerable: true,
|
|
enumerable: true,
|
|
configurable: true
|
|
configurable: true
|
|
});
|
|
});
|
|
- AxesViewer._recursiveChangeRenderingGroupId = function (mesh, id) {
|
|
|
|
- mesh.renderingGroupId = id;
|
|
|
|
- mesh.getChildMeshes().forEach(function (m) {
|
|
|
|
- AxesViewer._recursiveChangeRenderingGroupId(m, id);
|
|
|
|
- });
|
|
|
|
- };
|
|
|
|
/**
|
|
/**
|
|
* Force the viewer to update
|
|
* Force the viewer to update
|
|
* @param position defines the position of the viewer
|
|
* @param position defines the position of the viewer
|
|
@@ -66672,40 +66688,51 @@ var BABYLON;
|
|
* @param zaxis defines the z axis of the viewer
|
|
* @param zaxis defines the z axis of the viewer
|
|
*/
|
|
*/
|
|
AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
|
|
AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
|
|
- if (this._xmesh) {
|
|
|
|
- this._xmesh.position.copyFrom(position);
|
|
|
|
- var cross = BABYLON.Vector3.Cross(BABYLON.Vector3.Forward(), xaxis);
|
|
|
|
- this._xmesh.rotationQuaternion.set(cross.x, cross.y, cross.z, 1 + BABYLON.Vector3.Dot(BABYLON.Vector3.Forward(), xaxis));
|
|
|
|
- this._xmesh.rotationQuaternion.normalize();
|
|
|
|
- }
|
|
|
|
- if (this._ymesh) {
|
|
|
|
- this._ymesh.position.copyFrom(position);
|
|
|
|
- var cross = BABYLON.Vector3.Cross(BABYLON.Vector3.Forward(), yaxis);
|
|
|
|
- this._ymesh.rotationQuaternion.set(cross.x, cross.y, cross.z, 1 + BABYLON.Vector3.Dot(BABYLON.Vector3.Forward(), yaxis));
|
|
|
|
- this._ymesh.rotationQuaternion.normalize();
|
|
|
|
- }
|
|
|
|
- if (this._zmesh) {
|
|
|
|
- this._zmesh.position.copyFrom(position);
|
|
|
|
- var cross = BABYLON.Vector3.Cross(BABYLON.Vector3.Forward(), zaxis);
|
|
|
|
- this._zmesh.rotationQuaternion.set(cross.x, cross.y, cross.z, 1 + BABYLON.Vector3.Dot(BABYLON.Vector3.Forward(), zaxis));
|
|
|
|
- this._zmesh.rotationQuaternion.normalize();
|
|
|
|
- }
|
|
|
|
|
|
+ this._xAxis.position.copyFrom(position);
|
|
|
|
+ xaxis.scaleToRef(-1, this._tmpVector);
|
|
|
|
+ this._xAxis.setDirection(this._tmpVector);
|
|
|
|
+ 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.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
|
|
|
|
+ this._zAxis.position.copyFrom(position);
|
|
|
|
+ zaxis.scaleToRef(-1, this._tmpVector);
|
|
|
|
+ this._zAxis.setDirection(this._tmpVector);
|
|
|
|
+ this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
|
|
|
|
+ };
|
|
|
|
+ /**
|
|
|
|
+ * Creates an instance of this axes viewer.
|
|
|
|
+ * @returns a new axes viewer with instanced meshes
|
|
|
|
+ */
|
|
|
|
+ AxesViewer.prototype.createInstance = function () {
|
|
|
|
+ var xAxis = BABYLON.AxisDragGizmo._CreateArrowInstance(this.scene, this._xAxis);
|
|
|
|
+ var yAxis = BABYLON.AxisDragGizmo._CreateArrowInstance(this.scene, this._yAxis);
|
|
|
|
+ var zAxis = BABYLON.AxisDragGizmo._CreateArrowInstance(this.scene, this._zAxis);
|
|
|
|
+ var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
|
|
|
|
+ axesViewer._instanced = true;
|
|
|
|
+ return axesViewer;
|
|
};
|
|
};
|
|
/** Releases resources */
|
|
/** Releases resources */
|
|
AxesViewer.prototype.dispose = function () {
|
|
AxesViewer.prototype.dispose = function () {
|
|
- if (this._xmesh) {
|
|
|
|
- this._xmesh.dispose();
|
|
|
|
|
|
+ if (this._xAxis) {
|
|
|
|
+ this._xAxis.dispose(false, !this._instanced);
|
|
|
|
+ delete this._xAxis;
|
|
}
|
|
}
|
|
- if (this._ymesh) {
|
|
|
|
- this._ymesh.dispose();
|
|
|
|
|
|
+ if (this._yAxis) {
|
|
|
|
+ this._yAxis.dispose(false, !this._instanced);
|
|
|
|
+ delete this._yAxis;
|
|
}
|
|
}
|
|
- if (this._zmesh) {
|
|
|
|
- this._zmesh.dispose();
|
|
|
|
|
|
+ if (this._zAxis) {
|
|
|
|
+ this._zAxis.dispose(false, !this._instanced);
|
|
|
|
+ delete this._zAxis;
|
|
}
|
|
}
|
|
- this._xmesh = null;
|
|
|
|
- this._ymesh = null;
|
|
|
|
- this._zmesh = null;
|
|
|
|
- this.scene = null;
|
|
|
|
|
|
+ delete this.scene;
|
|
|
|
+ };
|
|
|
|
+ AxesViewer._SetRenderingGroupId = function (node, id) {
|
|
|
|
+ node.getChildMeshes().forEach(function (mesh) {
|
|
|
|
+ mesh.renderingGroupId = id;
|
|
|
|
+ });
|
|
};
|
|
};
|
|
return AxesViewer;
|
|
return AxesViewer;
|
|
}());
|
|
}());
|
|
@@ -67002,7 +67029,7 @@ var BABYLON;
|
|
* @returns true if visible otherwise, false
|
|
* @returns true if visible otherwise, false
|
|
*/
|
|
*/
|
|
DebugLayer.prototype.isVisible = function () {
|
|
DebugLayer.prototype.isVisible = function () {
|
|
- return this.BJSINSPECTOR.Inspector.IsVisible;
|
|
|
|
|
|
+ return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
|
|
};
|
|
};
|
|
/**
|
|
/**
|
|
* Hide the inspector and close its window.
|
|
* Hide the inspector and close its window.
|
|
@@ -103617,7 +103644,7 @@ var BABYLON;
|
|
var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
|
|
var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
|
|
arrow.lookAt(_this._rootMesh.position.subtract(dragAxis));
|
|
arrow.lookAt(_this._rootMesh.position.subtract(dragAxis));
|
|
arrow.scaling.scaleInPlace(1 / 3);
|
|
arrow.scaling.scaleInPlace(1 / 3);
|
|
- _this._rootMesh.addChild(arrow);
|
|
|
|
|
|
+ arrow.parent = _this._rootMesh;
|
|
var currentSnapDragDistance = 0;
|
|
var currentSnapDragDistance = 0;
|
|
var tmpVector = new BABYLON.Vector3();
|
|
var tmpVector = new BABYLON.Vector3();
|
|
var tmpSnapEvent = { snapDistance: 0 };
|
|
var tmpSnapEvent = { snapDistance: 0 };
|
|
@@ -103673,22 +103700,32 @@ var BABYLON;
|
|
}
|
|
}
|
|
/** @hidden */
|
|
/** @hidden */
|
|
AxisDragGizmo._CreateArrow = function (scene, material) {
|
|
AxisDragGizmo._CreateArrow = function (scene, material) {
|
|
- var arrow = new BABYLON.AbstractMesh("", scene);
|
|
|
|
- var arrowMesh = BABYLON.MeshBuilder.CreateCylinder("yPosMesh", { diameterTop: 0, height: 1.5, diameterBottom: 0.75, tessellation: 96 }, scene);
|
|
|
|
- var arrowTail = BABYLON.MeshBuilder.CreateLines("yPosMesh", { points: [new BABYLON.Vector3(0, 0, 0), new BABYLON.Vector3(0, 1.1, 0)] }, scene);
|
|
|
|
- arrowTail.color = material.emissiveColor;
|
|
|
|
- arrow.addChild(arrowMesh);
|
|
|
|
- arrow.addChild(arrowTail);
|
|
|
|
|
|
+ var arrow = new BABYLON.TransformNode("arrow", scene);
|
|
|
|
+ var cylinder = BABYLON.MeshBuilder.CreateCylinder("cylinder", { diameterTop: 0, height: 1.5, diameterBottom: 0.75, tessellation: 96 }, scene);
|
|
|
|
+ var line = BABYLON.MeshBuilder.CreateLines("line", { points: [new BABYLON.Vector3(0, 0, 0), new BABYLON.Vector3(0, 1.1, 0)] }, scene);
|
|
|
|
+ line.color = material.emissiveColor;
|
|
|
|
+ cylinder.parent = arrow;
|
|
|
|
+ line.parent = arrow;
|
|
// Position arrow pointing in its drag axis
|
|
// Position arrow pointing in its drag axis
|
|
- arrowMesh.scaling.scaleInPlace(0.05);
|
|
|
|
- arrowMesh.material = material;
|
|
|
|
- arrowMesh.rotation.x = Math.PI / 2;
|
|
|
|
- arrowMesh.position.z += 0.3;
|
|
|
|
- arrowTail.scaling.scaleInPlace(0.26);
|
|
|
|
- arrowTail.rotation.x = Math.PI / 2;
|
|
|
|
- arrowTail.material = material;
|
|
|
|
|
|
+ cylinder.scaling.scaleInPlace(0.05);
|
|
|
|
+ cylinder.material = material;
|
|
|
|
+ cylinder.rotation.x = Math.PI / 2;
|
|
|
|
+ cylinder.position.z += 0.3;
|
|
|
|
+ line.scaling.scaleInPlace(0.26);
|
|
|
|
+ line.rotation.x = Math.PI / 2;
|
|
|
|
+ line.material = material;
|
|
return arrow;
|
|
return arrow;
|
|
};
|
|
};
|
|
|
|
+ /** @hidden */
|
|
|
|
+ AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
|
|
|
|
+ var instance = new BABYLON.TransformNode("arrow", scene);
|
|
|
|
+ for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
|
|
|
|
+ var mesh = _a[_i];
|
|
|
|
+ var childInstance = mesh.createInstance(mesh.name);
|
|
|
|
+ childInstance.parent = instance;
|
|
|
|
+ }
|
|
|
|
+ return instance;
|
|
|
|
+ };
|
|
AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
|
|
AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
|
|
if (this.dragBehavior) {
|
|
if (this.dragBehavior) {
|
|
this.dragBehavior.enabled = value ? true : false;
|
|
this.dragBehavior.enabled = value ? true : false;
|