Explorar o código

use getClassName instead of instanceof

Julien Barrois %!s(int64=6) %!d(string=hai) anos
pai
achega
7cc572e16e
Modificáronse 2 ficheiros con 3 adicións e 3 borrados
  1. 1 1
      src/Mesh/babylon.abstractMesh.ts
  2. 2 2
      src/Mesh/babylon.subMesh.ts

+ 1 - 1
src/Mesh/babylon.abstractMesh.ts

@@ -1361,7 +1361,7 @@ module BABYLON {
          */
         public intersects(ray: Ray, fastCheck?: boolean): PickingInfo {
             var pickingInfo = new PickingInfo();
-            const intersectionTreshold = this instanceof LinesMesh || this instanceof InstancedLinesMesh ? this.intersectionThreshold : 0;
+            const intersectionTreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? (this as any).intersectionTreshold : 0;
             const boundingInfo = this._boundingInfo;
             if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionTreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionTreshold)) {
                 return pickingInfo;

+ 2 - 2
src/Mesh/babylon.subMesh.ts

@@ -344,8 +344,8 @@ module BABYLON {
 
             // LineMesh first as it's also a Mesh...
             if (LinesMesh) {
-                if (this._mesh instanceof LinesMesh || this._mesh instanceof InstancedLinesMesh) {
-                    return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
+                if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
+                    return this._intersectLines(ray, positions, indices, (this._mesh as any).intersectionThreshold, fastCheck);
                 }
             }