|
@@ -19719,6 +19719,10 @@ var BABYLON;
|
|
|
_this._unIndexed = false;
|
|
|
/** @hidden */
|
|
|
_this._lightSources = new Array();
|
|
|
+ /**
|
|
|
+ * An event triggered when the mesh is rebuilt.
|
|
|
+ */
|
|
|
+ _this.onRebuildObservable = new BABYLON.Observable();
|
|
|
_this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
|
|
|
if (collidedMesh === void 0) { collidedMesh = null; }
|
|
|
//TODO move this to the collision coordinator!
|
|
@@ -20158,12 +20162,10 @@ var BABYLON;
|
|
|
};
|
|
|
/** @hidden */
|
|
|
AbstractMesh.prototype._rebuild = function () {
|
|
|
+ this.onRebuildObservable.notifyObservers(this);
|
|
|
if (this._occlusionQuery) {
|
|
|
this._occlusionQuery = null;
|
|
|
}
|
|
|
- if (this._edgesRenderer) {
|
|
|
- this._edgesRenderer._rebuild();
|
|
|
- }
|
|
|
if (!this.subMeshes) {
|
|
|
return;
|
|
|
}
|
|
@@ -20268,44 +20270,8 @@ var BABYLON;
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
- // Methods
|
|
|
- /**
|
|
|
- * Disables the mesh edge rendering mode
|
|
|
- * @returns the currentAbstractMesh
|
|
|
- */
|
|
|
- AbstractMesh.prototype.disableEdgesRendering = function () {
|
|
|
- if (this._edgesRenderer) {
|
|
|
- this._edgesRenderer.dispose();
|
|
|
- this._edgesRenderer = null;
|
|
|
- }
|
|
|
- return this;
|
|
|
- };
|
|
|
- /**
|
|
|
- * Enables the edge rendering mode on the mesh.
|
|
|
- * This mode makes the mesh edges visible
|
|
|
- * @param epsilon defines the maximal distance between two angles to detect a face
|
|
|
- * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
|
|
|
- * @returns the currentAbstractMesh
|
|
|
- * @see https://www.babylonjs-playground.com/#19O9TU#0
|
|
|
- */
|
|
|
- AbstractMesh.prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
|
|
|
- if (epsilon === void 0) { epsilon = 0.95; }
|
|
|
- if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
|
|
|
- this.disableEdgesRendering();
|
|
|
- this._edgesRenderer = new BABYLON.EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
|
|
|
- return this;
|
|
|
- };
|
|
|
- Object.defineProperty(AbstractMesh.prototype, "edgesRenderer", {
|
|
|
- /**
|
|
|
- * Gets the edgesRenderer associated with the mesh
|
|
|
- */
|
|
|
- get: function () {
|
|
|
- return this._edgesRenderer;
|
|
|
- },
|
|
|
- enumerable: true,
|
|
|
- configurable: true
|
|
|
- });
|
|
|
Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
|
|
|
+ // Methods
|
|
|
/**
|
|
|
* Returns true if the mesh is blocked. Implemented by child classes
|
|
|
*/
|
|
@@ -21018,11 +20984,6 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- // Edges
|
|
|
- if (this._edgesRenderer) {
|
|
|
- this._edgesRenderer.dispose();
|
|
|
- this._edgesRenderer = null;
|
|
|
- }
|
|
|
// SubMeshes
|
|
|
if (this.getClassName() !== "InstancedMesh") {
|
|
|
this.releaseSubMeshes();
|
|
@@ -21067,6 +21028,7 @@ var BABYLON;
|
|
|
this.onAfterWorldMatrixUpdateObservable.clear();
|
|
|
this.onCollideObservable.clear();
|
|
|
this.onCollisionPositionChangeObservable.clear();
|
|
|
+ this.onRebuildObservable.clear();
|
|
|
_super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
|
|
|
};
|
|
|
/**
|
|
@@ -23654,7 +23616,7 @@ var BABYLON;
|
|
|
}
|
|
|
this._opaqueSubMeshes.push(subMesh); // Opaque
|
|
|
}
|
|
|
- if (mesh._edgesRenderer !== null && mesh._edgesRenderer !== undefined && mesh._edgesRenderer.isEnabled) {
|
|
|
+ if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
|
|
|
this._edgesRenderers.push(mesh._edgesRenderer);
|
|
|
}
|
|
|
};
|
|
@@ -60319,21 +60281,6 @@ var BABYLON;
|
|
|
LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
|
|
|
return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
|
|
|
};
|
|
|
- /**
|
|
|
- * Enables the edge rendering mode on the mesh.
|
|
|
- * This mode makes the mesh edges visible
|
|
|
- * @param epsilon defines the maximal distance between two angles to detect a face
|
|
|
- * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
|
|
|
- * @returns the currentAbstractMesh
|
|
|
- * @see https://www.babylonjs-playground.com/#19O9TU#0
|
|
|
- */
|
|
|
- LinesMesh.prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
|
|
|
- if (epsilon === void 0) { epsilon = 0.95; }
|
|
|
- if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
|
|
|
- this.disableEdgesRendering();
|
|
|
- this._edgesRenderer = new BABYLON.LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
|
|
|
- return this;
|
|
|
- };
|
|
|
return LinesMesh;
|
|
|
}(BABYLON.Mesh));
|
|
|
BABYLON.LinesMesh = LinesMesh;
|
|
@@ -100625,6 +100572,34 @@ var BABYLON;
|
|
|
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|
|
|
+ BABYLON.AbstractMesh.prototype.disableEdgesRendering = function () {
|
|
|
+ if (this._edgesRenderer) {
|
|
|
+ this._edgesRenderer.dispose();
|
|
|
+ this._edgesRenderer = null;
|
|
|
+ }
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ BABYLON.AbstractMesh.prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
|
|
|
+ if (epsilon === void 0) { epsilon = 0.95; }
|
|
|
+ if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
|
|
|
+ this.disableEdgesRendering();
|
|
|
+ this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
|
|
|
+ return this;
|
|
|
+ };
|
|
|
+ Object.defineProperty(BABYLON.AbstractMesh.prototype, "edgesRenderer", {
|
|
|
+ get: function () {
|
|
|
+ return this._edgesRenderer;
|
|
|
+ },
|
|
|
+ enumerable: true,
|
|
|
+ configurable: true
|
|
|
+ });
|
|
|
+ BABYLON.LinesMesh.prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
|
|
|
+ if (epsilon === void 0) { epsilon = 0.95; }
|
|
|
+ if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
|
|
|
+ this.disableEdgesRendering();
|
|
|
+ this._edgesRenderer = new BABYLON.LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
|
|
|
+ return this;
|
|
|
+ };
|
|
|
/**
|
|
|
* FaceAdjacencies Helper class to generate edges
|
|
|
*/
|
|
@@ -100651,6 +100626,7 @@ var BABYLON;
|
|
|
if (epsilon === void 0) { epsilon = 0.95; }
|
|
|
if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
|
|
|
if (generateEdgesLines === void 0) { generateEdgesLines = true; }
|
|
|
+ var _this = this;
|
|
|
this.edgesWidthScalerForOrthographic = 1000.0;
|
|
|
this.edgesWidthScalerForPerspective = 50.0;
|
|
|
this._linesPositions = new Array();
|
|
@@ -100667,6 +100643,12 @@ var BABYLON;
|
|
|
if (generateEdgesLines) {
|
|
|
this._generateEdgesLines();
|
|
|
}
|
|
|
+ this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
|
|
|
+ _this._rebuild();
|
|
|
+ });
|
|
|
+ this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
|
|
|
+ _this.dispose();
|
|
|
+ });
|
|
|
}
|
|
|
EdgesRenderer.prototype._prepareRessources = function () {
|
|
|
if (this._lineShader) {
|
|
@@ -100697,6 +100679,8 @@ var BABYLON;
|
|
|
* Releases the required resources for the edges renderer
|
|
|
*/
|
|
|
EdgesRenderer.prototype.dispose = function () {
|
|
|
+ this._source.onRebuildObservable.remove(this._meshRebuildObserver);
|
|
|
+ this._source.onDisposeObservable.remove(this._meshDisposeObserver);
|
|
|
var buffer = this._buffers[BABYLON.VertexBuffer.PositionKind];
|
|
|
if (buffer) {
|
|
|
buffer.dispose();
|
|
@@ -100897,9 +100881,19 @@ var BABYLON;
|
|
|
this._ib = engine.createIndexBuffer(this._linesIndices);
|
|
|
this._indicesCount = this._linesIndices.length;
|
|
|
};
|
|
|
+ /**
|
|
|
+ * Checks wether or not the edges renderer is ready to render.
|
|
|
+ * @return true if ready, otherwise false.
|
|
|
+ */
|
|
|
+ EdgesRenderer.prototype.isReady = function () {
|
|
|
+ return this._lineShader.isReady();
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * Renders the edges of the attached mesh,
|
|
|
+ */
|
|
|
EdgesRenderer.prototype.render = function () {
|
|
|
var scene = this._source.getScene();
|
|
|
- if (!this._lineShader.isReady() || !scene.activeCamera) {
|
|
|
+ if (!this.isReady() || !scene.activeCamera) {
|
|
|
return;
|
|
|
}
|
|
|
var engine = scene.getEngine();
|