|
@@ -197,18 +197,17 @@ module BABYLON {
|
|
if (!this._intersectsWithSphere(impostor, origin, radius)) {
|
|
if (!this._intersectsWithSphere(impostor, origin, radius)) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (impostor.object.getClassName() !== 'Mesh') {
|
|
|
|
|
|
+
|
|
|
|
+ if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
- var impostorObject = <Mesh>impostor.object;
|
|
|
|
var impostorObjectCenter = impostor.getObjectCenter();
|
|
var impostorObjectCenter = impostor.getObjectCenter();
|
|
var direction = impostorObjectCenter.subtract(origin);
|
|
var direction = impostorObjectCenter.subtract(origin);
|
|
|
|
|
|
var ray = new Ray(origin, direction, radius);
|
|
var ray = new Ray(origin, direction, radius);
|
|
this._rays.push(ray);
|
|
this._rays.push(ray);
|
|
- var hit = ray.intersectsMesh(impostorObject);
|
|
|
|
|
|
+ var hit = ray.intersectsMesh(<AbstractMesh>impostor.object);
|
|
|
|
|
|
var contactPoint = hit.pickedPoint;
|
|
var contactPoint = hit.pickedPoint;
|
|
if (!contactPoint) {
|
|
if (!contactPoint) {
|
|
@@ -255,7 +254,7 @@ module BABYLON {
|
|
}
|
|
}
|
|
|
|
|
|
private _intersectsWithSphere(impostor: PhysicsImpostor, origin: Vector3, radius: number): boolean {
|
|
private _intersectsWithSphere(impostor: PhysicsImpostor, origin: Vector3, radius: number): boolean {
|
|
- var impostorObject = <Mesh>impostor.object;
|
|
|
|
|
|
+ var impostorObject = <AbstractMesh>impostor.object;
|
|
|
|
|
|
this._prepareSphere();
|
|
this._prepareSphere();
|
|
|
|
|
|
@@ -468,7 +467,7 @@ module BABYLON {
|
|
}
|
|
}
|
|
|
|
|
|
private _intersectsWithCylinder(impostor: PhysicsImpostor): boolean {
|
|
private _intersectsWithCylinder(impostor: PhysicsImpostor): boolean {
|
|
- var impostorObject = <Mesh>impostor.object;
|
|
|
|
|
|
+ var impostorObject = <AbstractMesh>impostor.object;
|
|
|
|
|
|
this._prepareCylinder();
|
|
this._prepareCylinder();
|
|
|
|
|
|
@@ -553,18 +552,17 @@ module BABYLON {
|
|
if (!this._intersectsWithCylinder(impostor)) {
|
|
if (!this._intersectsWithCylinder(impostor)) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (impostor.object.getClassName() !== 'Mesh') {
|
|
|
|
|
|
+
|
|
|
|
+ if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
- var impostorObject = <Mesh>impostor.object;
|
|
|
|
var impostorObjectCenter = impostor.getObjectCenter();
|
|
var impostorObjectCenter = impostor.getObjectCenter();
|
|
var originOnPlane = new Vector3(this._origin.x, impostorObjectCenter.y, this._origin.z); // the distance to the origin as if both objects were on a plane (Y-axis)
|
|
var originOnPlane = new Vector3(this._origin.x, impostorObjectCenter.y, this._origin.z); // the distance to the origin as if both objects were on a plane (Y-axis)
|
|
var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
|
|
var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
|
|
|
|
|
|
var ray = new Ray(originOnPlane, originToImpostorDirection, this._radius);
|
|
var ray = new Ray(originOnPlane, originToImpostorDirection, this._radius);
|
|
- var hit = ray.intersectsMesh(impostorObject);
|
|
|
|
|
|
+ var hit = ray.intersectsMesh(<AbstractMesh>impostor.object);
|
|
var contactPoint = hit.pickedPoint;
|
|
var contactPoint = hit.pickedPoint;
|
|
if (!contactPoint) {
|
|
if (!contactPoint) {
|
|
return null;
|
|
return null;
|
|
@@ -618,7 +616,7 @@ module BABYLON {
|
|
}
|
|
}
|
|
|
|
|
|
private _intersectsWithCylinder(impostor: PhysicsImpostor): boolean {
|
|
private _intersectsWithCylinder(impostor: PhysicsImpostor): boolean {
|
|
- var impostorObject = <Mesh>impostor.object;
|
|
|
|
|
|
+ var impostorObject = <AbstractMesh>impostor.object;
|
|
|
|
|
|
this._prepareCylinder();
|
|
this._prepareCylinder();
|
|
|
|
|