Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate draco indices #5316

Merged
merged 1 commit into from
May 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/framework/parsers/glb-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -721,16 +721,19 @@ const createDracoMesh = (device, primitive, accessors, bufferViews, meshVariants
} else {
// create vertex buffer
const numVertices = decompressedData.vertices.byteLength / vertexFormat.size;
const indexFormat = numVertices <= 65535 ? INDEXFORMAT_UINT16 : INDEXFORMAT_UINT32;
const numIndices = decompressedData.indices.byteLength / (numVertices <= 65535 ? 2 : 4);

Debug.call(() => {
if (numVertices !== accessors[primitive.attributes.POSITION].count) {
Debug.warn('mesh has invalid draco sizes');
Debug.warn('mesh has invalid vertex count');
}
if (numIndices !== accessors[primitive.indices].count) {
Debug.warn('mesh has invalid index count');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still no way to print the glb name? Without it i's not super useful message.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope. user doesn't need to do anything anyway.

}
});
const vertexBuffer = new VertexBuffer(device, vertexFormat, numVertices, BUFFER_STATIC, decompressedData.vertices);

// create index buffer
const numIndices = accessors[primitive.indices].count;
const indexFormat = numVertices <= 65535 ? INDEXFORMAT_UINT16 : INDEXFORMAT_UINT32;
const vertexBuffer = new VertexBuffer(device, vertexFormat, numVertices, BUFFER_STATIC, decompressedData.vertices);
const indexBuffer = new IndexBuffer(device, indexFormat, numIndices, BUFFER_STATIC, decompressedData.indices);

result.vertexBuffer = vertexBuffer;
Expand Down