瀏覽代碼

Fixing instanced meshes and worker collisions

The mesh is added to the scene before the source mesh was even set (and
is updated later). Without checking if the sourceMesh exists, it would
throw an exception at the first call of the constructor and will prevent
worker collisions to work with instances.
Raanan Weber 10 年之前
父節點
當前提交
eb43d187ab
共有 2 個文件被更改,包括 2 次插入2 次删除
  1. 1 1
      src/Collisions/babylon.collisionCoordinator.js
  2. 1 1
      src/Collisions/babylon.collisionCoordinator.ts

+ 1 - 1
src/Collisions/babylon.collisionCoordinator.js

@@ -180,7 +180,7 @@ var BABYLON;
                 geometryId = mesh.geometry ? mesh.geometry.id : null;
             }
             else if (mesh instanceof BABYLON.InstancedMesh) {
-                geometryId = mesh.sourceMesh.geometry ? mesh.sourceMesh.geometry.id : null;
+                geometryId = (mesh.sourceMesh && mesh.sourceMesh.geometry) ? mesh.sourceMesh.geometry.id : null;
             }
             return {
                 uniqueId: mesh.uniqueId,

+ 1 - 1
src/Collisions/babylon.collisionCoordinator.ts

@@ -158,7 +158,7 @@ module BABYLON {
             if (mesh instanceof Mesh) {
                 geometryId = (<Mesh>mesh).geometry ? (<Mesh>mesh).geometry.id : null;
             } else if (mesh instanceof InstancedMesh) {
-                geometryId = (<InstancedMesh>mesh).sourceMesh.geometry ? (<InstancedMesh>mesh).sourceMesh.geometry.id : null;
+                geometryId = ((<InstancedMesh>mesh).sourceMesh && (<InstancedMesh>mesh).sourceMesh.geometry) ? (<InstancedMesh>mesh).sourceMesh.geometry.id : null;
             }
 
             return {