Skip to content

Commit

Permalink
fix(draco): Ignore unknown attribute types (#2951)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibgreen authored Apr 5, 2024
1 parent 30e59e5 commit 03173b7
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions modules/draco/src/lib/draco-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,17 @@ export default class DracoParser {
for (const loaderAttribute of Object.values(loaderData.attributes)) {
const attributeName = this._deduceAttributeName(loaderAttribute, options);
loaderAttribute.name = attributeName;
const {value, size} = this._getAttributeValues(dracoGeometry, loaderAttribute);
attributes[attributeName] = {
value,
size,
byteOffset: loaderAttribute.byte_offset,
byteStride: loaderAttribute.byte_stride,
normalized: loaderAttribute.normalized
};
const values = this._getAttributeValues(dracoGeometry, loaderAttribute);
if (values) {
const {value, size} = values;
attributes[attributeName] = {
value,
size,
byteOffset: loaderAttribute.byte_offset,
byteStride: loaderAttribute.byte_stride,
normalized: loaderAttribute.normalized
};
}
}

return attributes;
Expand Down Expand Up @@ -349,8 +352,13 @@ export default class DracoParser {
_getAttributeValues(
dracoGeometry: Mesh | PointCloud,
attribute: DracoAttribute
): {value: TypedArray; size: number} {
): {value: TypedArray; size: number} | null {
const TypedArrayCtor = DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP[attribute.data_type];
if (!TypedArrayCtor) {
// eslint-disable-next-line no-console
console.warn(`DRACO: Unsupported attribute type ${attribute.data_type}`);
return null;
}
const numComponents = attribute.num_components;
const numPoints = dracoGeometry.num_points();
const numValues = numPoints * numComponents;
Expand Down

0 comments on commit 03173b7

Please sign in to comment.