Skip to content

Commit

Permalink
fix: model mesh advanced data write bug
Browse files Browse the repository at this point in the history
  • Loading branch information
GuoLei1990 committed Jul 24, 2023
1 parent 462ed1d commit c6b10b8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/core/src/mesh/ModelMesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ export class ModelMesh extends Mesh {
this._updateVertexElements();

// If releaseData is false, we shouldn't update buffer data version
releaseData || (this._advancedDataSyncToBuffer = true);
this._advancedDataSyncToBuffer = true;

// Update internal vertex buffer if needed
this._updateInternalVertexBuffer(releaseData);
Expand Down Expand Up @@ -1296,6 +1296,14 @@ export class ModelMesh extends Mesh {

if (!isDestroy) {
this._vertexBufferBindings[this._internalVertexBufferIndex]?.buffer.markAsUnreadable();

// If release data, we need update buffer data version to ensure get data method can read buffer
const dataVersion = this._dataVersionCounter++;
const vertexBufferInfos = this._vertexBufferInfos;
for (let i = 0, n = vertexBufferInfos.length; i < n; i++) {
const vertexBufferInfo = vertexBufferInfos[i];
vertexBufferInfo && (vertexBufferInfo.dataVersion = dataVersion);
}
}
}

Expand Down

0 comments on commit c6b10b8

Please sign in to comment.