|
@@ -852,7 +852,11 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
|
|
|
if (!this._geometry) {
|
|
|
return null;
|
|
|
}
|
|
|
- return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
|
|
|
+ let data = this._userInstancedBuffersStorage?.vertexBuffers[kind]?.getFloatData(this._geometry.getTotalVertices(), forceCopy || (copyWhenShared && this._geometry.meshes.length !== 1));
|
|
|
+ if (!data) {
|
|
|
+ data = this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
|
|
|
+ }
|
|
|
+ return data;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -877,7 +881,8 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
|
|
|
if (!this._geometry) {
|
|
|
return null;
|
|
|
}
|
|
|
- return this._geometry.getVertexBuffer(kind);
|
|
|
+
|
|
|
+ return this._userInstancedBuffersStorage?.vertexBuffers[kind] ?? this._geometry.getVertexBuffer(kind);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -905,7 +910,7 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
- return this._geometry.isVerticesDataPresent(kind);
|
|
|
+ return this._userInstancedBuffersStorage?.vertexBuffers[kind] !== undefined || this._geometry.isVerticesDataPresent(kind);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -932,7 +937,7 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
- return this._geometry.isVertexBufferUpdatable(kind);
|
|
|
+ return this._userInstancedBuffersStorage?.vertexBuffers[kind]?.isUpdatable() || this._geometry.isVertexBufferUpdatable(kind);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -963,7 +968,13 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
- return this._geometry.getVerticesDataKinds();
|
|
|
+ const kinds = this._geometry.getVerticesDataKinds();
|
|
|
+ if (this._userInstancedBuffersStorage) {
|
|
|
+ for (const kind in this._userInstancedBuffersStorage.vertexBuffers) {
|
|
|
+ kinds.push(kind);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return kinds;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1693,9 +1704,9 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
|
|
|
}
|
|
|
|
|
|
this._userInstancedBuffersStorage.vertexBuffers["world0"] = instancesBuffer.createVertexBuffer("world0", 0, 4);
|
|
|
- this._userInstancedBuffersStorage.vertexBuffers["world1"] = instancesBuffer.createVertexBuffer("world0", 4, 4);
|
|
|
- this._userInstancedBuffersStorage.vertexBuffers["world2"] = instancesBuffer.createVertexBuffer("world0", 8, 4);
|
|
|
- this._userInstancedBuffersStorage.vertexBuffers["world3"] = instancesBuffer.createVertexBuffer("world0", 12, 4);
|
|
|
+ this._userInstancedBuffersStorage.vertexBuffers["world1"] = instancesBuffer.createVertexBuffer("world1", 4, 4);
|
|
|
+ this._userInstancedBuffersStorage.vertexBuffers["world2"] = instancesBuffer.createVertexBuffer("world2", 8, 4);
|
|
|
+ this._userInstancedBuffersStorage.vertexBuffers["world3"] = instancesBuffer.createVertexBuffer("world3", 12, 4);
|
|
|
} else {
|
|
|
if (!this._instanceDataStorage.isFrozen) {
|
|
|
instancesBuffer!.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
|