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 committed May 14, 2024
1 parent 19e941d commit c3d706f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
17 changes: 15 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# tests
test/data/test.png
tmp
!modules/zip/test/data/**/*.zip

# dists
dist/*
Expand All @@ -11,11 +12,23 @@ dist.min.js
# lock files
package-lock.json
*/**/package-lock.json
examples/**/yarn.lock

*/**/yarn.lock
!website/yarn.lock

*/**/.yarn/*
*/**/yarn-error.log

.yarn/*
!.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

tsconfig.tsbuildinfo

.reify-cache
.nyc_output/
coverage/
node_modules/
Expand Down
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 @@ -293,14 +293,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 @@ -350,8 +353,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 c3d706f

Please sign in to comment.