|
@@ -19,6 +19,7 @@
|
|
public ambientColor = new BABYLON.Color3(0, 0, 0);
|
|
public ambientColor = new BABYLON.Color3(0, 0, 0);
|
|
public beforeRender: () => void;
|
|
public beforeRender: () => void;
|
|
public afterRender: () => void;
|
|
public afterRender: () => void;
|
|
|
|
+ public onDispose: () => void;
|
|
public beforeCameraRender: (camera: Camera) => void;
|
|
public beforeCameraRender: (camera: Camera) => void;
|
|
public afterCameraRender: (camera: Camera) => void;
|
|
public afterCameraRender: (camera: Camera) => void;
|
|
public forceWireframe = false;
|
|
public forceWireframe = false;
|
|
@@ -1077,6 +1078,10 @@
|
|
this._boundingBoxRenderer.dispose();
|
|
this._boundingBoxRenderer.dispose();
|
|
|
|
|
|
// Events
|
|
// Events
|
|
|
|
+ if (this.onDispose) {
|
|
|
|
+ this.onDispose();
|
|
|
|
+ }
|
|
|
|
+
|
|
this.detachControl();
|
|
this.detachControl();
|
|
|
|
|
|
// Detach cameras
|
|
// Detach cameras
|
|
@@ -1142,19 +1147,19 @@
|
|
}
|
|
}
|
|
|
|
|
|
// Collisions
|
|
// Collisions
|
|
- public _getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, finalPosition: Vector3): void {
|
|
|
|
|
|
+ public _getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, finalPosition: Vector3, excludedMesh: AbstractMesh = null): void {
|
|
position.divideToRef(collider.radius, this._scaledPosition);
|
|
position.divideToRef(collider.radius, this._scaledPosition);
|
|
velocity.divideToRef(collider.radius, this._scaledVelocity);
|
|
velocity.divideToRef(collider.radius, this._scaledVelocity);
|
|
|
|
|
|
collider.retry = 0;
|
|
collider.retry = 0;
|
|
collider.initialVelocity = this._scaledVelocity;
|
|
collider.initialVelocity = this._scaledVelocity;
|
|
collider.initialPosition = this._scaledPosition;
|
|
collider.initialPosition = this._scaledPosition;
|
|
- this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, finalPosition);
|
|
|
|
|
|
+ this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, finalPosition, excludedMesh);
|
|
|
|
|
|
finalPosition.multiplyInPlace(collider.radius);
|
|
finalPosition.multiplyInPlace(collider.radius);
|
|
}
|
|
}
|
|
|
|
|
|
- private _collideWithWorld(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, finalPosition: Vector3): void {
|
|
|
|
|
|
+ private _collideWithWorld(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, finalPosition: Vector3, excludedMesh: AbstractMesh = null): void {
|
|
var closeDistance = BABYLON.Engine.CollisionsEpsilon * 10.0;
|
|
var closeDistance = BABYLON.Engine.CollisionsEpsilon * 10.0;
|
|
|
|
|
|
if (collider.retry >= maximumRetry) {
|
|
if (collider.retry >= maximumRetry) {
|
|
@@ -1167,7 +1172,7 @@
|
|
// Check all meshes
|
|
// Check all meshes
|
|
for (var index = 0; index < this.meshes.length; index++) {
|
|
for (var index = 0; index < this.meshes.length; index++) {
|
|
var mesh = this.meshes[index];
|
|
var mesh = this.meshes[index];
|
|
- if (mesh.isEnabled() && mesh.checkCollisions) {
|
|
|
|
|
|
+ if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh) {
|
|
mesh._checkCollision(collider);
|
|
mesh._checkCollision(collider);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1187,7 +1192,7 @@
|
|
}
|
|
}
|
|
|
|
|
|
collider.retry++;
|
|
collider.retry++;
|
|
- this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition);
|
|
|
|
|
|
+ this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
|
|
}
|
|
}
|
|
|
|
|
|
// Octrees
|
|
// Octrees
|