Explorar o código

Fix picking withs ubmeshes

David Catuhe %!s(int64=5) %!d(string=hai) anos
pai
achega
81ac7610a6
Modificáronse 2 ficheiros con 4 adicións e 1 borrados
  1. 2 0
      src/Collisions/pickingInfo.ts
  2. 2 1
      src/Meshes/abstractMesh.ts

+ 2 - 0
src/Collisions/pickingInfo.ts

@@ -36,6 +36,8 @@ export class PickingInfo {
     public bv = 0;
     /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
     public faceId = -1;
+    /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
+    public subMeshFaceId = -1;    
     /** Id of the the submesh that was picked */
     public subMeshId = 0;
     /** If a sprite was picked, this will be the sprite the pick collided with */

+ 2 - 1
src/Meshes/abstractMesh.ts

@@ -1552,7 +1552,8 @@ export class AbstractMesh extends TransformNode implements IDisposable, ICullabl
             pickingInfo.pickedMesh = this;
             pickingInfo.bu = intersectInfo.bu || 0;
             pickingInfo.bv = intersectInfo.bv || 0;
-            pickingInfo.faceId = intersectInfo.faceId;
+            pickingInfo.subMeshFaceId = intersectInfo.faceId;
+            pickingInfo.faceId = intersectInfo.faceId + subMeshes.data[intersectInfo.subMeshId].indexStart / (this.getClassName().indexOf("LinesMesh") !== -1 ? 2 : 3);
             pickingInfo.subMeshId = intersectInfo.subMeshId;
             return pickingInfo;
         }