|
@@ -12,6 +12,7 @@ import { ShapeBuilder } from "../../Meshes/Builders/shapeBuilder";
|
|
|
import { LinesBuilder } from "../../Meshes/Builders/linesBuilder";
|
|
|
import { LinesMesh } from '../../Meshes/linesMesh';
|
|
|
import { PhysicsRaycastResult } from "../physicsRaycastResult";
|
|
|
+import { Scalar } from "../../Maths/math.scalar"
|
|
|
|
|
|
declare var Ammo: any;
|
|
|
|
|
@@ -901,11 +902,11 @@ export class AmmoJSPlugin implements IPhysicsEnginePlugin {
|
|
|
switch (impostor.type) {
|
|
|
case PhysicsImpostor.SphereImpostor:
|
|
|
// Is there a better way to compare floats number? With an epsylon or with a Math function
|
|
|
- if (extendSize.x === extendSize.y && extendSize.x === extendSize.z) {
|
|
|
+ if (Scalar.WithinEpsilon(extendSize.x, extendSize.y, 0.0001) && Scalar.WithinEpsilon(extendSize.x, extendSize.z, 0.0001)) {
|
|
|
returnValue = new Ammo.btSphereShape(extendSize.x / 2);
|
|
|
} else {
|
|
|
// create a btMultiSphereShape because it's not possible to set a local scaling on a btSphereShape
|
|
|
- var positions = [new Ammo.btVector3(0,0,0)];
|
|
|
+ var positions = [new Ammo.btVector3(0, 0, 0)];
|
|
|
var radii = [1];
|
|
|
returnValue = new Ammo.btMultiSphereShape(positions, radii, 1);
|
|
|
returnValue.setLocalScaling(new Ammo.btVector3(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2));
|