瀏覽代碼

More polish

breakin 4 年之前
父節點
當前提交
69dffffde0
共有 3 個文件被更改,包括 13 次插入13 次删除
  1. 3 3
      src/Meshes/geometry.ts
  2. 5 10
      src/Meshes/instancedMesh.ts
  3. 5 0
      src/Meshes/mesh.ts

+ 3 - 3
src/Meshes/geometry.ts

@@ -299,7 +299,7 @@ export class Geometry implements IGetSetVerticesData {
 
             var meshes = this._meshes;
             for (var index = 0; index < numOfMeshes; index++) {
-                meshes[index].invalidateInstanceVertexArrayObject();
+                meshes[index]._invalidateInstanceVertexArrayObject();
             }
         }
     }
@@ -679,7 +679,7 @@ export class Geometry implements IGetSetVerticesData {
         meshes.splice(index, 1);
 
         if (this._vertexArrayObjects) {
-            mesh.invalidateInstanceVertexArrayObject();
+            mesh._invalidateInstanceVertexArrayObject();
         }
 
         mesh._geometry = null;
@@ -704,7 +704,7 @@ export class Geometry implements IGetSetVerticesData {
         }
 
         if (this._vertexArrayObjects) {
-            mesh.invalidateInstanceVertexArrayObject();
+            mesh._invalidateInstanceVertexArrayObject();
         }
 
         var meshes = this._meshes;

+ 5 - 10
src/Meshes/instancedMesh.ts

@@ -493,7 +493,7 @@ declare module "./mesh" {
         /**
          * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).
          */
-        invalidateInstanceVertexArrayObject(): void;
+        _invalidateInstanceVertexArrayObject(): void;
 
         /**
          * true to use the edge renderer for all instances of this mesh
@@ -524,11 +524,6 @@ declare module "./abstractMesh" {
 Mesh.prototype.edgesShareWithInstances = false;
 
 Mesh.prototype.registerInstancedBuffer = function(kind: string, stride: number): void {
-    if (this.geometry?._vertexBuffers[kind] !== undefined) {
-        console.error('Mesh.registerInstancedBuffer; ignored', kind, ' since geometry already specifies it!');
-        return;
-    }
-
     // Creates the instancedBuffer field if not present
     if (!this.instancedBuffers) {
         this.instancedBuffers = {};
@@ -558,7 +553,7 @@ Mesh.prototype.registerInstancedBuffer = function(kind: string, stride: number):
         instance.instancedBuffers[kind] = null;
     }
 
-    this.invalidateInstanceVertexArrayObject();
+    this._invalidateInstanceVertexArrayObject();
 };
 
 Mesh.prototype._processInstancedBuffers = function(visibleInstances: InstancedMesh[], renderSelf: boolean) {
@@ -617,14 +612,14 @@ Mesh.prototype._processInstancedBuffers = function(visibleInstances: InstancedMe
         // Update vertex buffer
         if (!this._userInstancedBuffersStorage.vertexBuffers[kind]) {
             this._userInstancedBuffersStorage.vertexBuffers[kind] = new VertexBuffer(this.getEngine(), this._userInstancedBuffersStorage.data[kind], kind, true, false, stride, true);
-            this.invalidateInstanceVertexArrayObject();
+            this._invalidateInstanceVertexArrayObject();
         } else {
             this._userInstancedBuffersStorage.vertexBuffers[kind]!.updateDirectly(data, 0);
         }
     }
 };
 
-Mesh.prototype.invalidateInstanceVertexArrayObject = function() {
+Mesh.prototype._invalidateInstanceVertexArrayObject = function() {
     if (!this._userInstancedBuffersStorage || this._userInstancedBuffersStorage.vertexArrayObjects === undefined) {
         return;
     }
@@ -652,7 +647,7 @@ Mesh.prototype._disposeInstanceSpecificData = function() {
         }
     }
 
-    this.invalidateInstanceVertexArrayObject();
+    this._invalidateInstanceVertexArrayObject();
 
     this.instancedBuffers = {};
 };

+ 5 - 0
src/Meshes/mesh.ts

@@ -2435,6 +2435,11 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
         // Do nothing
     }
 
+    /** @hidden */
+    public _invalidateInstanceVertexArrayObject() {
+        // Do nothing
+    }
+
     /**
      * Modifies the mesh geometry according to a displacement map.
      * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.