|
@@ -11,172 +11,12 @@ var BABYLON;
|
|
function Mesh(name, scene) {
|
|
function Mesh(name, scene) {
|
|
_super.call(this, name, scene);
|
|
_super.call(this, name, scene);
|
|
// Members
|
|
// Members
|
|
- this.position = new BABYLON.Vector3(0, 0, 0);
|
|
|
|
- this.rotation = new BABYLON.Vector3(0, 0, 0);
|
|
|
|
- this.rotationQuaternion = null;
|
|
|
|
- this.scaling = new BABYLON.Vector3(1, 1, 1);
|
|
|
|
this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NONE;
|
|
this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NONE;
|
|
- this.material = null;
|
|
|
|
- this.isVisible = true;
|
|
|
|
- this.isPickable = true;
|
|
|
|
- this.visibility = 1.0;
|
|
|
|
- this.billboardMode = BABYLON.Mesh.BILLBOARDMODE_NONE;
|
|
|
|
- this.checkCollisions = false;
|
|
|
|
- this.receiveShadows = false;
|
|
|
|
- this._isDisposed = false;
|
|
|
|
- this.onDispose = null;
|
|
|
|
- this.skeleton = null;
|
|
|
|
- this.renderingGroupId = 0;
|
|
|
|
- this.infiniteDistance = false;
|
|
|
|
- this.showBoundingBox = false;
|
|
|
|
- // Cache
|
|
|
|
- this._positions = null;
|
|
|
|
- this._localScaling = BABYLON.Matrix.Zero();
|
|
|
|
- this._localRotation = BABYLON.Matrix.Zero();
|
|
|
|
- this._localTranslation = BABYLON.Matrix.Zero();
|
|
|
|
- this._localBillboard = BABYLON.Matrix.Zero();
|
|
|
|
- this._localPivotScaling = BABYLON.Matrix.Zero();
|
|
|
|
- this._localPivotScalingRotation = BABYLON.Matrix.Zero();
|
|
|
|
- this._localWorld = BABYLON.Matrix.Zero();
|
|
|
|
- this._worldMatrix = BABYLON.Matrix.Zero();
|
|
|
|
- this._rotateYByPI = BABYLON.Matrix.RotationY(Math.PI);
|
|
|
|
- this._collisionsTransformMatrix = BABYLON.Matrix.Zero();
|
|
|
|
- this._collisionsScalingMatrix = BABYLON.Matrix.Zero();
|
|
|
|
- this._absolutePosition = BABYLON.Vector3.Zero();
|
|
|
|
- this._isDirty = false;
|
|
|
|
- // Physics
|
|
|
|
- this._physicImpostor = BABYLON.PhysicsEngine.NoImpostor;
|
|
|
|
- this._pivotMatrix = BABYLON.Matrix.Identity();
|
|
|
|
- this._renderId = 0;
|
|
|
|
|
|
+ this.instances = new Array();
|
|
this._onBeforeRenderCallbacks = [];
|
|
this._onBeforeRenderCallbacks = [];
|
|
- this._animationStarted = false;
|
|
|
|
-
|
|
|
|
- scene.meshes.push(this);
|
|
|
|
|
|
+ this._visibleInstances = new BABYLON.SmartArray(32);
|
|
|
|
+ this._renderIdForInstances = -1;
|
|
}
|
|
}
|
|
- Object.defineProperty(Mesh, "BILLBOARDMODE_NONE", {
|
|
|
|
- get: function () {
|
|
|
|
- return Mesh._BILLBOARDMODE_NONE;
|
|
|
|
- },
|
|
|
|
- enumerable: true,
|
|
|
|
- configurable: true
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- Object.defineProperty(Mesh, "BILLBOARDMODE_X", {
|
|
|
|
- get: function () {
|
|
|
|
- return Mesh._BILLBOARDMODE_X;
|
|
|
|
- },
|
|
|
|
- enumerable: true,
|
|
|
|
- configurable: true
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- Object.defineProperty(Mesh, "BILLBOARDMODE_Y", {
|
|
|
|
- get: function () {
|
|
|
|
- return Mesh._BILLBOARDMODE_Y;
|
|
|
|
- },
|
|
|
|
- enumerable: true,
|
|
|
|
- configurable: true
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- Object.defineProperty(Mesh, "BILLBOARDMODE_Z", {
|
|
|
|
- get: function () {
|
|
|
|
- return Mesh._BILLBOARDMODE_Z;
|
|
|
|
- },
|
|
|
|
- enumerable: true,
|
|
|
|
- configurable: true
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- Object.defineProperty(Mesh, "BILLBOARDMODE_ALL", {
|
|
|
|
- get: function () {
|
|
|
|
- return Mesh._BILLBOARDMODE_ALL;
|
|
|
|
- },
|
|
|
|
- enumerable: true,
|
|
|
|
- configurable: true
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- Mesh.prototype.getBoundingInfo = function () {
|
|
|
|
- return this._boundingInfo;
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype.getWorldMatrix = function () {
|
|
|
|
- if (this._currentRenderId !== this.getScene().getRenderId()) {
|
|
|
|
- this.computeWorldMatrix();
|
|
|
|
- }
|
|
|
|
- return this._worldMatrix;
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype.rotate = function (axis, amount, space) {
|
|
|
|
- if (!this.rotationQuaternion) {
|
|
|
|
- this.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
|
|
|
|
- this.rotation = BABYLON.Vector3.Zero();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!space || space == 0 /* LOCAL */) {
|
|
|
|
- var rotationQuaternion = BABYLON.Quaternion.RotationAxis(axis, amount);
|
|
|
|
- this.rotationQuaternion = this.rotationQuaternion.multiply(rotationQuaternion);
|
|
|
|
- } else {
|
|
|
|
- if (this.parent) {
|
|
|
|
- var invertParentWorldMatrix = this.parent.getWorldMatrix().clone();
|
|
|
|
- invertParentWorldMatrix.invert();
|
|
|
|
-
|
|
|
|
- axis = BABYLON.Vector3.TransformNormal(axis, invertParentWorldMatrix);
|
|
|
|
- }
|
|
|
|
- rotationQuaternion = BABYLON.Quaternion.RotationAxis(axis, amount);
|
|
|
|
- this.rotationQuaternion = rotationQuaternion.multiply(this.rotationQuaternion);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype.translate = function (axis, distance, space) {
|
|
|
|
- var displacementVector = axis.scale(distance);
|
|
|
|
-
|
|
|
|
- if (!space || space == 0 /* LOCAL */) {
|
|
|
|
- var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
|
|
|
|
- this.setPositionWithLocalVector(tempV3);
|
|
|
|
- } else {
|
|
|
|
- this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype.getAbsolutePosition = function () {
|
|
|
|
- this.computeWorldMatrix();
|
|
|
|
- return this._absolutePosition;
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype.setAbsolutePosition = function (absolutePosition) {
|
|
|
|
- if (!absolutePosition) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var absolutePositionX;
|
|
|
|
- var absolutePositionY;
|
|
|
|
- var absolutePositionZ;
|
|
|
|
-
|
|
|
|
- if (absolutePosition.x === undefined) {
|
|
|
|
- if (arguments.length < 3) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- absolutePositionX = arguments[0];
|
|
|
|
- absolutePositionY = arguments[1];
|
|
|
|
- absolutePositionZ = arguments[2];
|
|
|
|
- } else {
|
|
|
|
- absolutePositionX = absolutePosition.x;
|
|
|
|
- absolutePositionY = absolutePosition.y;
|
|
|
|
- absolutePositionZ = absolutePosition.z;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (this.parent) {
|
|
|
|
- var invertParentWorldMatrix = this.parent.getWorldMatrix().clone();
|
|
|
|
- invertParentWorldMatrix.invert();
|
|
|
|
-
|
|
|
|
- var worldPosition = new BABYLON.Vector3(absolutePositionX, absolutePositionY, absolutePositionZ);
|
|
|
|
-
|
|
|
|
- this.position = BABYLON.Vector3.TransformCoordinates(worldPosition, invertParentWorldMatrix);
|
|
|
|
- } else {
|
|
|
|
- this.position.x = absolutePositionX;
|
|
|
|
- this.position.y = absolutePositionY;
|
|
|
|
- this.position.z = absolutePositionZ;
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
Mesh.prototype.getTotalVertices = function () {
|
|
Mesh.prototype.getTotalVertices = function () {
|
|
if (!this._geometry) {
|
|
if (!this._geometry) {
|
|
return 0;
|
|
return 0;
|
|
@@ -235,54 +75,12 @@ var BABYLON;
|
|
return this._geometry.getIndices();
|
|
return this._geometry.getIndices();
|
|
};
|
|
};
|
|
|
|
|
|
- Mesh.prototype.setPivotMatrix = function (matrix) {
|
|
|
|
- this._pivotMatrix = matrix;
|
|
|
|
- this._cache.pivotMatrixUpdated = true;
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype.getPivotMatrix = function () {
|
|
|
|
- return this._pivotMatrix;
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype._isSynchronized = function () {
|
|
|
|
- if (this._isDirty) {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (this.billboardMode !== Mesh.BILLBOARDMODE_NONE)
|
|
|
|
- return false;
|
|
|
|
-
|
|
|
|
- if (this._cache.pivotMatrixUpdated) {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (this.infiniteDistance) {
|
|
|
|
|
|
+ Mesh.prototype.isReady = function () {
|
|
|
|
+ if (this.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_LOADING) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- if (!this._cache.position.equals(this.position))
|
|
|
|
- return false;
|
|
|
|
-
|
|
|
|
- if (this.rotationQuaternion) {
|
|
|
|
- if (!this._cache.rotationQuaternion.equals(this.rotationQuaternion))
|
|
|
|
- return false;
|
|
|
|
- } else {
|
|
|
|
- if (!this._cache.rotation.equals(this.rotation))
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!this._cache.scaling.equals(this.scaling))
|
|
|
|
- return false;
|
|
|
|
-
|
|
|
|
- return true;
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype.isReady = function () {
|
|
|
|
- return this._isReady;
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype.isAnimated = function () {
|
|
|
|
- return this._animationStarted;
|
|
|
|
|
|
+ return _super.prototype.isReady.call(this);
|
|
};
|
|
};
|
|
|
|
|
|
Mesh.prototype.isDisposed = function () {
|
|
Mesh.prototype.isDisposed = function () {
|
|
@@ -290,22 +88,9 @@ var BABYLON;
|
|
};
|
|
};
|
|
|
|
|
|
// Methods
|
|
// Methods
|
|
- Mesh.prototype._initCache = function () {
|
|
|
|
- _super.prototype._initCache.call(this);
|
|
|
|
-
|
|
|
|
- this._cache.localMatrixUpdated = false;
|
|
|
|
- this._cache.position = BABYLON.Vector3.Zero();
|
|
|
|
- this._cache.scaling = BABYLON.Vector3.Zero();
|
|
|
|
- this._cache.rotation = BABYLON.Vector3.Zero();
|
|
|
|
- this._cache.rotationQuaternion = new BABYLON.Quaternion(0, 0, 0, 0);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype.markAsDirty = function (property) {
|
|
|
|
- if (property === "rotation") {
|
|
|
|
- this.rotationQuaternion = null;
|
|
|
|
- }
|
|
|
|
- this._currentRenderId = Number.MAX_VALUE;
|
|
|
|
- this._isDirty = true;
|
|
|
|
|
|
+ Mesh.prototype._activate = function (renderId) {
|
|
|
|
+ this._visibleInstances.reset();
|
|
|
|
+ _super.prototype._activate.call(this, renderId);
|
|
};
|
|
};
|
|
|
|
|
|
Mesh.prototype.refreshBoundingInfo = function () {
|
|
Mesh.prototype.refreshBoundingInfo = function () {
|
|
@@ -325,116 +110,13 @@ var BABYLON;
|
|
this._updateBoundingInfo();
|
|
this._updateBoundingInfo();
|
|
};
|
|
};
|
|
|
|
|
|
- Mesh.prototype._updateBoundingInfo = function () {
|
|
|
|
- this._boundingInfo = this._boundingInfo || new BABYLON.BoundingInfo(this._absolutePosition, this._absolutePosition);
|
|
|
|
-
|
|
|
|
- this._boundingInfo._update(this._worldMatrix);
|
|
|
|
-
|
|
|
|
- if (!this.subMeshes) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
|
|
|
|
- var subMesh = this.subMeshes[subIndex];
|
|
|
|
-
|
|
|
|
- subMesh.updateBoundingInfo(this._worldMatrix);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype.computeWorldMatrix = function (force) {
|
|
|
|
- if (!force && (this._currentRenderId == this.getScene().getRenderId() || this.isSynchronized(true))) {
|
|
|
|
- return this._worldMatrix;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- this._cache.position.copyFrom(this.position);
|
|
|
|
- this._cache.scaling.copyFrom(this.scaling);
|
|
|
|
- this._cache.pivotMatrixUpdated = false;
|
|
|
|
- this._currentRenderId = this.getScene().getRenderId();
|
|
|
|
- this._isDirty = false;
|
|
|
|
-
|
|
|
|
- // Scaling
|
|
|
|
- BABYLON.Matrix.ScalingToRef(this.scaling.x, this.scaling.y, this.scaling.z, this._localScaling);
|
|
|
|
-
|
|
|
|
- // Rotation
|
|
|
|
- if (this.rotationQuaternion) {
|
|
|
|
- this.rotationQuaternion.toRotationMatrix(this._localRotation);
|
|
|
|
- this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
|
|
|
|
- } else {
|
|
|
|
- BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._localRotation);
|
|
|
|
- this._cache.rotation.copyFrom(this.rotation);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Translation
|
|
|
|
- if (this.infiniteDistance && !this.parent) {
|
|
|
|
- var camera = this.getScene().activeCamera;
|
|
|
|
- var cameraWorldMatrix = camera.getWorldMatrix();
|
|
|
|
-
|
|
|
|
- var cameraGlobalPosition = new BABYLON.Vector3(cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
|
|
|
|
-
|
|
|
|
- BABYLON.Matrix.TranslationToRef(this.position.x + cameraGlobalPosition.x, this.position.y + cameraGlobalPosition.y, this.position.z + cameraGlobalPosition.z, this._localTranslation);
|
|
|
|
- } else {
|
|
|
|
- BABYLON.Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._localTranslation);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Composing transformations
|
|
|
|
- this._pivotMatrix.multiplyToRef(this._localScaling, this._localPivotScaling);
|
|
|
|
- this._localPivotScaling.multiplyToRef(this._localRotation, this._localPivotScalingRotation);
|
|
|
|
-
|
|
|
|
- // Billboarding
|
|
|
|
- if (this.billboardMode !== Mesh.BILLBOARDMODE_NONE) {
|
|
|
|
- var localPosition = this.position.clone();
|
|
|
|
- var zero = this.getScene().activeCamera.position.clone();
|
|
|
|
-
|
|
|
|
- if (this.parent && this.parent.position) {
|
|
|
|
- localPosition.addInPlace(this.parent.position);
|
|
|
|
- BABYLON.Matrix.TranslationToRef(localPosition.x, localPosition.y, localPosition.z, this._localTranslation);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ((this.billboardMode & Mesh.BILLBOARDMODE_ALL) === Mesh.BILLBOARDMODE_ALL) {
|
|
|
|
- zero = this.getScene().activeCamera.position;
|
|
|
|
- } else {
|
|
|
|
- if (this.billboardMode & BABYLON.Mesh.BILLBOARDMODE_X)
|
|
|
|
- zero.x = localPosition.x + BABYLON.Engine.Epsilon;
|
|
|
|
- if (this.billboardMode & BABYLON.Mesh.BILLBOARDMODE_Y)
|
|
|
|
- zero.y = localPosition.y + 0.001;
|
|
|
|
- if (this.billboardMode & BABYLON.Mesh.BILLBOARDMODE_Z)
|
|
|
|
- zero.z = localPosition.z + 0.001;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- BABYLON.Matrix.LookAtLHToRef(localPosition, zero, BABYLON.Vector3.Up(), this._localBillboard);
|
|
|
|
- this._localBillboard.m[12] = this._localBillboard.m[13] = this._localBillboard.m[14] = 0;
|
|
|
|
-
|
|
|
|
- this._localBillboard.invert();
|
|
|
|
-
|
|
|
|
- this._localPivotScalingRotation.multiplyToRef(this._localBillboard, this._localWorld);
|
|
|
|
- this._rotateYByPI.multiplyToRef(this._localWorld, this._localPivotScalingRotation);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Local world
|
|
|
|
- this._localPivotScalingRotation.multiplyToRef(this._localTranslation, this._localWorld);
|
|
|
|
-
|
|
|
|
- // Parent
|
|
|
|
- if (this.parent && this.parent.getWorldMatrix && this.billboardMode === BABYLON.Mesh.BILLBOARDMODE_NONE) {
|
|
|
|
- this._localWorld.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
|
|
|
|
- } else {
|
|
|
|
- this._worldMatrix.copyFrom(this._localWorld);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Bounding info
|
|
|
|
- this._updateBoundingInfo();
|
|
|
|
-
|
|
|
|
- // Absolute position
|
|
|
|
- this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
|
|
|
|
-
|
|
|
|
- return this._worldMatrix;
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
Mesh.prototype._createGlobalSubMesh = function () {
|
|
Mesh.prototype._createGlobalSubMesh = function () {
|
|
var totalVertices = this.getTotalVertices();
|
|
var totalVertices = this.getTotalVertices();
|
|
if (!totalVertices || !this.getIndices()) {
|
|
if (!totalVertices || !this.getIndices()) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ this.releaseSubMeshes();
|
|
this.subMeshes = [];
|
|
this.subMeshes = [];
|
|
return new BABYLON.SubMesh(0, 0, totalVertices, 0, this.getTotalIndices(), this);
|
|
return new BABYLON.SubMesh(0, 0, totalVertices, 0, this.getTotalIndices(), this);
|
|
};
|
|
};
|
|
@@ -448,12 +130,15 @@ var BABYLON;
|
|
var subdivisionSize = totalIndices / count;
|
|
var subdivisionSize = totalIndices / count;
|
|
var offset = 0;
|
|
var offset = 0;
|
|
|
|
|
|
|
|
+ this.releaseSubMeshes();
|
|
this.subMeshes = [];
|
|
this.subMeshes = [];
|
|
for (var index = 0; index < count; index++) {
|
|
for (var index = 0; index < count; index++) {
|
|
BABYLON.SubMesh.CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
|
|
BABYLON.SubMesh.CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
|
|
|
|
|
|
offset += subdivisionSize;
|
|
offset += subdivisionSize;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ this.synchronizeInstances();
|
|
};
|
|
};
|
|
|
|
|
|
Mesh.prototype.setVerticesData = function (data, kind, updatable) {
|
|
Mesh.prototype.setVerticesData = function (data, kind, updatable) {
|
|
@@ -502,30 +187,37 @@ var BABYLON;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
- // ANY
|
|
|
|
- Mesh.prototype.bindAndDraw = function (subMesh, effect, wireframe) {
|
|
|
|
- if (!this._geometry || !this._geometry.getVertexBuffers() || !this._geometry.getIndexBuffer()) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ Mesh.prototype._bind = function (subMesh, effect, wireframe) {
|
|
var engine = this.getScene().getEngine();
|
|
var engine = this.getScene().getEngine();
|
|
|
|
|
|
// Wireframe
|
|
// Wireframe
|
|
var indexToBind = this._geometry.getIndexBuffer();
|
|
var indexToBind = this._geometry.getIndexBuffer();
|
|
- var useTriangles = true;
|
|
|
|
|
|
|
|
if (wireframe) {
|
|
if (wireframe) {
|
|
indexToBind = subMesh.getLinesIndexBuffer(this.getIndices(), engine);
|
|
indexToBind = subMesh.getLinesIndexBuffer(this.getIndices(), engine);
|
|
- useTriangles = false;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// VBOs
|
|
// VBOs
|
|
engine.bindMultiBuffers(this._geometry.getVertexBuffers(), indexToBind, effect);
|
|
engine.bindMultiBuffers(this._geometry.getVertexBuffers(), indexToBind, effect);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ Mesh.prototype._draw = function (subMesh, useTriangles) {
|
|
|
|
+ if (!this._geometry || !this._geometry.getVertexBuffers() || !this._geometry.getIndexBuffer()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var engine = this.getScene().getEngine();
|
|
|
|
|
|
// Draw order
|
|
// Draw order
|
|
engine.draw(useTriangles, useTriangles ? subMesh.indexStart : 0, useTriangles ? subMesh.indexCount : subMesh.linesIndexCount);
|
|
engine.draw(useTriangles, useTriangles ? subMesh.indexStart : 0, useTriangles ? subMesh.indexCount : subMesh.linesIndexCount);
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ Mesh.prototype.bindAndDraw = function (subMesh, effect, wireframe) {
|
|
|
|
+ this._bind(subMesh, effect, wireframe);
|
|
|
|
+
|
|
|
|
+ this._draw(subMesh, !wireframe);
|
|
|
|
+ };
|
|
|
|
+
|
|
Mesh.prototype.registerBeforeRender = function (func) {
|
|
Mesh.prototype.registerBeforeRender = function (func) {
|
|
this._onBeforeRenderCallbacks.push(func);
|
|
this._onBeforeRenderCallbacks.push(func);
|
|
};
|
|
};
|
|
@@ -539,6 +231,22 @@ var BABYLON;
|
|
};
|
|
};
|
|
|
|
|
|
Mesh.prototype.render = function (subMesh) {
|
|
Mesh.prototype.render = function (subMesh) {
|
|
|
|
+ var renderSelf = true;
|
|
|
|
+ var scene = this.getScene();
|
|
|
|
+
|
|
|
|
+ // Managing instances
|
|
|
|
+ if (this._visibleInstances.length) {
|
|
|
|
+ if (this._renderIdForInstances === scene.getRenderId()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (scene.getRenderId() !== this._renderId) {
|
|
|
|
+ renderSelf = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this._renderIdForInstances = scene.getRenderId();
|
|
|
|
+
|
|
|
|
+ // Checking geometry state
|
|
if (!this._geometry || !this._geometry.getVertexBuffers() || !this._geometry.getIndexBuffer()) {
|
|
if (!this._geometry || !this._geometry.getVertexBuffers() || !this._geometry.getIndexBuffer()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -547,9 +255,6 @@ var BABYLON;
|
|
this._onBeforeRenderCallbacks[callbackIndex]();
|
|
this._onBeforeRenderCallbacks[callbackIndex]();
|
|
}
|
|
}
|
|
|
|
|
|
- // World
|
|
|
|
- var world = this.getWorldMatrix();
|
|
|
|
-
|
|
|
|
// Material
|
|
// Material
|
|
var effectiveMaterial = subMesh.getMaterial();
|
|
var effectiveMaterial = subMesh.getMaterial();
|
|
|
|
|
|
@@ -557,12 +262,33 @@ var BABYLON;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ var engine = scene.getEngine();
|
|
|
|
+ var effect = effectiveMaterial.getEffect();
|
|
|
|
+
|
|
|
|
+ // Bind
|
|
|
|
+ var wireFrame = engine.forceWireframe || effectiveMaterial.wireframe;
|
|
|
|
+ this._bind(subMesh, effect, wireFrame);
|
|
effectiveMaterial._preBind();
|
|
effectiveMaterial._preBind();
|
|
- effectiveMaterial.bind(world, this);
|
|
|
|
|
|
|
|
- // Bind and draw
|
|
|
|
- var engine = this.getScene().getEngine();
|
|
|
|
- this.bindAndDraw(subMesh, effectiveMaterial.getEffect(), engine.forceWireframe || effectiveMaterial.wireframe);
|
|
|
|
|
|
+ if (renderSelf) {
|
|
|
|
+ // World
|
|
|
|
+ var world = this.getWorldMatrix();
|
|
|
|
+ effectiveMaterial.bind(world, this);
|
|
|
|
+
|
|
|
|
+ // Draw
|
|
|
|
+ this._draw(subMesh, !wireFrame);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (var instanceIndex = 0; instanceIndex < this._visibleInstances.length; instanceIndex++) {
|
|
|
|
+ var instance = this._visibleInstances.data[instanceIndex];
|
|
|
|
+
|
|
|
|
+ // World
|
|
|
|
+ world = instance.getWorldMatrix();
|
|
|
|
+ effectiveMaterial.bind(world, this);
|
|
|
|
+
|
|
|
|
+ // Draw
|
|
|
|
+ this._draw(subMesh, !wireFrame);
|
|
|
|
+ }
|
|
|
|
|
|
// Unbind
|
|
// Unbind
|
|
effectiveMaterial.unbind();
|
|
effectiveMaterial.unbind();
|
|
@@ -607,15 +333,8 @@ var BABYLON;
|
|
return results;
|
|
return results;
|
|
};
|
|
};
|
|
|
|
|
|
- Mesh.prototype.isInFrustum = function (frustumPlanes) {
|
|
|
|
- if (this.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_LOADING) {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!this._boundingInfo.isInFrustum(frustumPlanes)) {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ Mesh.prototype._checkDelayState = function () {
|
|
|
|
+ var _this = this;
|
|
var that = this;
|
|
var that = this;
|
|
var scene = this.getScene();
|
|
var scene = this.getScene();
|
|
|
|
|
|
@@ -627,12 +346,24 @@ var BABYLON;
|
|
scene._addPendingData(that);
|
|
scene._addPendingData(that);
|
|
|
|
|
|
BABYLON.Tools.LoadFile(this.delayLoadingFile, function (data) {
|
|
BABYLON.Tools.LoadFile(this.delayLoadingFile, function (data) {
|
|
- that._delayLoadingFunction(JSON.parse(data), that);
|
|
|
|
- that.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_LOADED;
|
|
|
|
- scene._removePendingData(that);
|
|
|
|
|
|
+ _this._delayLoadingFunction(JSON.parse(data), _this);
|
|
|
|
+ _this.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_LOADED;
|
|
|
|
+ scene._removePendingData(_this);
|
|
}, function () {
|
|
}, function () {
|
|
}, scene.database);
|
|
}, scene.database);
|
|
}
|
|
}
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ Mesh.prototype.isInFrustum = function (frustumPlanes) {
|
|
|
|
+ if (this.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_LOADING) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this._checkDelayState();
|
|
|
|
|
|
return true;
|
|
return true;
|
|
};
|
|
};
|
|
@@ -667,26 +398,6 @@ var BABYLON;
|
|
};
|
|
};
|
|
|
|
|
|
// Geometry
|
|
// Geometry
|
|
- Mesh.prototype.setPositionWithLocalVector = function (vector3) {
|
|
|
|
- this.computeWorldMatrix();
|
|
|
|
-
|
|
|
|
- this.position = BABYLON.Vector3.TransformNormal(vector3, this._localWorld);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype.getPositionExpressedInLocalSpace = function () {
|
|
|
|
- this.computeWorldMatrix();
|
|
|
|
- var invLocalWorldMatrix = this._localWorld.clone();
|
|
|
|
- invLocalWorldMatrix.invert();
|
|
|
|
-
|
|
|
|
- return BABYLON.Vector3.TransformNormal(this.position, invLocalWorldMatrix);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype.locallyTranslate = function (vector3) {
|
|
|
|
- this.computeWorldMatrix();
|
|
|
|
-
|
|
|
|
- this.position = BABYLON.Vector3.TransformCoordinates(vector3, this._localWorld);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
Mesh.prototype.bakeTransformIntoVertices = function (transform) {
|
|
Mesh.prototype.bakeTransformIntoVertices = function (transform) {
|
|
// Position
|
|
// Position
|
|
if (!this.isVerticesDataPresent(BABYLON.VertexBuffer.PositionKind)) {
|
|
if (!this.isVerticesDataPresent(BABYLON.VertexBuffer.PositionKind)) {
|
|
@@ -716,24 +427,6 @@ var BABYLON;
|
|
this.setVerticesData(temp, BABYLON.VertexBuffer.NormalKind, this.getVertexBuffer(BABYLON.VertexBuffer.NormalKind).isUpdatable());
|
|
this.setVerticesData(temp, BABYLON.VertexBuffer.NormalKind, this.getVertexBuffer(BABYLON.VertexBuffer.NormalKind).isUpdatable());
|
|
};
|
|
};
|
|
|
|
|
|
- Mesh.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor) {
|
|
|
|
- /// <summary>Orients a mesh towards a target point. Mesh must be drawn facing user.</summary>
|
|
|
|
- /// <param name="targetPoint" type="BABYLON.Vector3">The position (must be in same space as current mesh) to look at</param>
|
|
|
|
- /// <param name="yawCor" type="Number">optional yaw (y-axis) correction in radians</param>
|
|
|
|
- /// <param name="pitchCor" type="Number">optional pitch (x-axis) correction in radians</param>
|
|
|
|
- /// <param name="rollCor" type="Number">optional roll (z-axis) correction in radians</param>
|
|
|
|
- /// <returns>Mesh oriented towards targetMesh</returns>
|
|
|
|
- yawCor = yawCor || 0; // default to zero if undefined
|
|
|
|
- pitchCor = pitchCor || 0;
|
|
|
|
- rollCor = rollCor || 0;
|
|
|
|
-
|
|
|
|
- var dv = targetPoint.subtract(this.position);
|
|
|
|
- var yaw = -Math.atan2(dv.z, dv.x) - Math.PI / 2;
|
|
|
|
- var len = Math.sqrt(dv.x * dv.x + dv.z * dv.z);
|
|
|
|
- var pitch = Math.atan2(dv.y, len);
|
|
|
|
- this.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(yaw + yawCor, pitch + pitchCor, rollCor);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
// Cache
|
|
// Cache
|
|
Mesh.prototype._resetPointsArrayCache = function () {
|
|
Mesh.prototype._resetPointsArrayCache = function () {
|
|
this._positions = null;
|
|
this._positions = null;
|
|
@@ -741,131 +434,21 @@ var BABYLON;
|
|
|
|
|
|
Mesh.prototype._generatePointsArray = function () {
|
|
Mesh.prototype._generatePointsArray = function () {
|
|
if (this._positions)
|
|
if (this._positions)
|
|
- return;
|
|
|
|
|
|
+ return true;
|
|
|
|
|
|
this._positions = [];
|
|
this._positions = [];
|
|
|
|
|
|
var data = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
|
|
var data = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);
|
|
- for (var index = 0; index < data.length; index += 3) {
|
|
|
|
- this._positions.push(BABYLON.Vector3.FromArray(data, index));
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- // Collisions
|
|
|
|
- Mesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
|
|
|
|
- this._generatePointsArray();
|
|
|
|
-
|
|
|
|
- // Transformation
|
|
|
|
- if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
|
|
|
|
- subMesh._lastColliderTransformMatrix = transformMatrix.clone();
|
|
|
|
- subMesh._lastColliderWorldVertices = [];
|
|
|
|
- subMesh._trianglePlanes = [];
|
|
|
|
- var start = subMesh.verticesStart;
|
|
|
|
- var end = (subMesh.verticesStart + subMesh.verticesCount);
|
|
|
|
- for (var i = start; i < end; i++) {
|
|
|
|
- subMesh._lastColliderWorldVertices.push(BABYLON.Vector3.TransformCoordinates(this._positions[i], transformMatrix));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Collide
|
|
|
|
- collider._collide(subMesh, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype._processCollisionsForSubModels = function (collider, transformMatrix) {
|
|
|
|
- for (var index = 0; index < this.subMeshes.length; index++) {
|
|
|
|
- var subMesh = this.subMeshes[index];
|
|
|
|
-
|
|
|
|
- // Bounding test
|
|
|
|
- if (this.subMeshes.length > 1 && !subMesh._checkCollision(collider))
|
|
|
|
- continue;
|
|
|
|
-
|
|
|
|
- this._collideForSubMesh(subMesh, transformMatrix, collider);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype._checkCollision = function (collider) {
|
|
|
|
- // Bounding box test
|
|
|
|
- if (!this._boundingInfo._checkCollision(collider))
|
|
|
|
- return;
|
|
|
|
-
|
|
|
|
- // Transformation matrix
|
|
|
|
- BABYLON.Matrix.ScalingToRef(1.0 / collider.radius.x, 1.0 / collider.radius.y, 1.0 / collider.radius.z, this._collisionsScalingMatrix);
|
|
|
|
- this._worldMatrix.multiplyToRef(this._collisionsScalingMatrix, this._collisionsTransformMatrix);
|
|
|
|
-
|
|
|
|
- this._processCollisionsForSubModels(collider, this._collisionsTransformMatrix);
|
|
|
|
- };
|
|
|
|
|
|
|
|
- Mesh.prototype.intersectsMesh = function (mesh, precise) {
|
|
|
|
- if (!this._boundingInfo || !mesh._boundingInfo) {
|
|
|
|
|
|
+ if (!data) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- return this._boundingInfo.intersects(mesh._boundingInfo, precise);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype.intersectsPoint = function (point) {
|
|
|
|
- if (!this._boundingInfo) {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return this._boundingInfo.intersectsPoint(point);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- // Picking
|
|
|
|
- Mesh.prototype.intersects = function (ray, fastCheck) {
|
|
|
|
- var pickingInfo = new BABYLON.PickingInfo();
|
|
|
|
-
|
|
|
|
- if (!this._boundingInfo || !ray.intersectsSphere(this._boundingInfo.boundingSphere) || !ray.intersectsBox(this._boundingInfo.boundingBox)) {
|
|
|
|
- return pickingInfo;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- this._generatePointsArray();
|
|
|
|
-
|
|
|
|
- var intersectInfo = null;
|
|
|
|
-
|
|
|
|
- for (var index = 0; index < this.subMeshes.length; index++) {
|
|
|
|
- var subMesh = this.subMeshes[index];
|
|
|
|
-
|
|
|
|
- // Bounding test
|
|
|
|
- if (this.subMeshes.length > 1 && !subMesh.canIntersects(ray))
|
|
|
|
- continue;
|
|
|
|
-
|
|
|
|
- var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck);
|
|
|
|
-
|
|
|
|
- if (currentIntersectInfo) {
|
|
|
|
- if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
|
|
|
|
- intersectInfo = currentIntersectInfo;
|
|
|
|
-
|
|
|
|
- if (fastCheck) {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (intersectInfo) {
|
|
|
|
- // Get picked point
|
|
|
|
- var world = this.getWorldMatrix();
|
|
|
|
- var worldOrigin = BABYLON.Vector3.TransformCoordinates(ray.origin, world);
|
|
|
|
- var direction = ray.direction.clone();
|
|
|
|
- direction.normalize();
|
|
|
|
- direction = direction.scale(intersectInfo.distance);
|
|
|
|
- var worldDirection = BABYLON.Vector3.TransformNormal(direction, world);
|
|
|
|
-
|
|
|
|
- var pickedPoint = worldOrigin.add(worldDirection);
|
|
|
|
-
|
|
|
|
- // Return result
|
|
|
|
- pickingInfo.hit = true;
|
|
|
|
- pickingInfo.distance = BABYLON.Vector3.Distance(worldOrigin, pickedPoint);
|
|
|
|
- pickingInfo.pickedPoint = pickedPoint;
|
|
|
|
- pickingInfo.pickedMesh = this;
|
|
|
|
- pickingInfo.bu = intersectInfo.bu;
|
|
|
|
- pickingInfo.bv = intersectInfo.bv;
|
|
|
|
- pickingInfo.faceId = intersectInfo.faceId;
|
|
|
|
- return pickingInfo;
|
|
|
|
|
|
+ for (var index = 0; index < data.length; index += 3) {
|
|
|
|
+ this._positions.push(BABYLON.Vector3.FromArray(data, index));
|
|
}
|
|
}
|
|
|
|
|
|
- return pickingInfo;
|
|
|
|
|
|
+ return true;
|
|
};
|
|
};
|
|
|
|
|
|
// Clone
|
|
// Clone
|
|
@@ -919,127 +502,11 @@ var BABYLON;
|
|
this._geometry.releaseForMesh(this);
|
|
this._geometry.releaseForMesh(this);
|
|
}
|
|
}
|
|
|
|
|
|
- // Physics
|
|
|
|
- if (this.getPhysicsImpostor() != BABYLON.PhysicsEngine.NoImpostor) {
|
|
|
|
- this.setPhysicsState(BABYLON.PhysicsEngine.NoImpostor);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Remove from scene
|
|
|
|
- var index = this.getScene().meshes.indexOf(this);
|
|
|
|
- this.getScene().meshes.splice(index, 1);
|
|
|
|
-
|
|
|
|
- if (!doNotRecurse) {
|
|
|
|
- for (index = 0; index < this.getScene().particleSystems.length; index++) {
|
|
|
|
- if (this.getScene().particleSystems[index].emitter == this) {
|
|
|
|
- this.getScene().particleSystems[index].dispose();
|
|
|
|
- index--;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Children
|
|
|
|
- var objects = this.getScene().meshes.slice(0);
|
|
|
|
- for (index = 0; index < objects.length; index++) {
|
|
|
|
- if (objects[index].parent == this) {
|
|
|
|
- objects[index].dispose();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- for (index = 0; index < this.getScene().meshes.length; index++) {
|
|
|
|
- var obj = this.getScene().meshes[index];
|
|
|
|
- if (obj.parent === this) {
|
|
|
|
- obj.parent = null;
|
|
|
|
- obj.computeWorldMatrix(true);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- this._isDisposed = true;
|
|
|
|
-
|
|
|
|
- // Callback
|
|
|
|
- if (this.onDispose) {
|
|
|
|
- this.onDispose();
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- // Physics
|
|
|
|
- Mesh.prototype.setPhysicsState = function (impostor, options) {
|
|
|
|
- var physicsEngine = this.getScene().getPhysicsEngine();
|
|
|
|
-
|
|
|
|
- if (!physicsEngine) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (impostor.impostor) {
|
|
|
|
- // Old API
|
|
|
|
- options = impostor;
|
|
|
|
- impostor = impostor.impostor;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- impostor = impostor || BABYLON.PhysicsEngine.NoImpostor;
|
|
|
|
-
|
|
|
|
- if (impostor === BABYLON.PhysicsEngine.NoImpostor) {
|
|
|
|
- physicsEngine._unregisterMesh(this);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- options.mass = options.mass || 0;
|
|
|
|
- options.friction = options.friction || 0.2;
|
|
|
|
- options.restitution = options.restitution || 0.9;
|
|
|
|
-
|
|
|
|
- this._physicImpostor = impostor;
|
|
|
|
- this._physicsMass = options.mass;
|
|
|
|
- this._physicsFriction = options.friction;
|
|
|
|
- this._physicRestitution = options.restitution;
|
|
|
|
-
|
|
|
|
- physicsEngine._registerMesh(this, impostor, options);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype.getPhysicsImpostor = function () {
|
|
|
|
- if (!this._physicImpostor) {
|
|
|
|
- return BABYLON.PhysicsEngine.NoImpostor;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return this._physicImpostor;
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype.getPhysicsMass = function () {
|
|
|
|
- if (!this._physicsMass) {
|
|
|
|
- return 0;
|
|
|
|
|
|
+ while (this.instances.length) {
|
|
|
|
+ this.instances[0].dispose();
|
|
}
|
|
}
|
|
|
|
|
|
- return this._physicsMass;
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype.getPhysicsFriction = function () {
|
|
|
|
- if (!this._physicsFriction) {
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return this._physicsFriction;
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype.getPhysicsRestitution = function () {
|
|
|
|
- if (!this._physicRestitution) {
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return this._physicRestitution;
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype.applyImpulse = function (force, contactPoint) {
|
|
|
|
- if (!this._physicImpostor) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- this.getScene().getPhysicsEngine()._applyImpulse(this, force, contactPoint);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- Mesh.prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2) {
|
|
|
|
- if (!this._physicImpostor) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- this.getScene().getPhysicsEngine()._createLink(this, otherMesh, pivot1, pivot2);
|
|
|
|
|
|
+ _super.prototype.dispose.call(this, doNotRecurse);
|
|
};
|
|
};
|
|
|
|
|
|
// Geometric tools
|
|
// Geometric tools
|
|
@@ -1120,10 +587,25 @@ var BABYLON;
|
|
|
|
|
|
// Updating submeshes
|
|
// Updating submeshes
|
|
this.subMeshes = [];
|
|
this.subMeshes = [];
|
|
|
|
+ this.releaseSubMeshes();
|
|
for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
|
|
for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
|
|
var previousOne = previousSubmeshes[submeshIndex];
|
|
var previousOne = previousSubmeshes[submeshIndex];
|
|
var subMesh = new BABYLON.SubMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
|
|
var subMesh = new BABYLON.SubMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ this.synchronizeInstances();
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // Instances
|
|
|
|
+ Mesh.prototype.createInstance = function (name) {
|
|
|
|
+ return new BABYLON.InstancedMesh(name, this);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ Mesh.prototype.synchronizeInstances = function () {
|
|
|
|
+ for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
|
|
|
|
+ var instance = this.instances[instanceIndex];
|
|
|
|
+ instance._syncSubMeshes();
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
// Statics
|
|
// Statics
|
|
@@ -1250,13 +732,8 @@ var BABYLON;
|
|
var minMaxVector = meshesOrMinMaxVector.min !== undefined ? meshesOrMinMaxVector : BABYLON.Mesh.MinMax(meshesOrMinMaxVector);
|
|
var minMaxVector = meshesOrMinMaxVector.min !== undefined ? meshesOrMinMaxVector : BABYLON.Mesh.MinMax(meshesOrMinMaxVector);
|
|
return BABYLON.Vector3.Center(minMaxVector.min, minMaxVector.max);
|
|
return BABYLON.Vector3.Center(minMaxVector.min, minMaxVector.max);
|
|
};
|
|
};
|
|
- Mesh._BILLBOARDMODE_NONE = 0;
|
|
|
|
- Mesh._BILLBOARDMODE_X = 1;
|
|
|
|
- Mesh._BILLBOARDMODE_Y = 2;
|
|
|
|
- Mesh._BILLBOARDMODE_Z = 4;
|
|
|
|
- Mesh._BILLBOARDMODE_ALL = 7;
|
|
|
|
return Mesh;
|
|
return Mesh;
|
|
- })(BABYLON.Node);
|
|
|
|
|
|
+ })(BABYLON.AbstractMesh);
|
|
BABYLON.Mesh = Mesh;
|
|
BABYLON.Mesh = Mesh;
|
|
})(BABYLON || (BABYLON = {}));
|
|
})(BABYLON || (BABYLON = {}));
|
|
//# sourceMappingURL=babylon.mesh.js.map
|
|
//# sourceMappingURL=babylon.mesh.js.map
|