Skip to content

Commit

Permalink
fix: GLTF DRACO decode bug (#141) (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
czizzy authored Apr 6, 2021
1 parent 58b9e27 commit 19a1f32
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions packages/draco/src/worker/worker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let decoderPending;
export default `let decoderPending;
let decoderConfig;
onmessage = function(e) {
Expand Down Expand Up @@ -72,7 +72,7 @@ function decodeGeometry(draco, decoder, decoderBuffer, taskConfig) {
// A Draco file may be created with default vertex attributes, whose attribute IDs
// are mapped 1:1 from their semantic name (POSITION, NORMAL, ...). Alternatively,
// a Draco file may contain a custom set of attributes, identified by known unique
// IDs. glTF files always do the latter, and `.drc` files typically do the former.
// IDs. glTF files always do the latter, and .drc files typically do the former.
if (taskConfig.useUniqueIDs) {
attributeID = attributeIDs[attributeName];
attribute = decoder.GetAttributeByUniqueId(dracoGeometry, attributeID);
Expand Down Expand Up @@ -107,6 +107,7 @@ function decodeGeometry(draco, decoder, decoderBuffer, taskConfig) {
decoder.GetTrianglesUInt32Array(dracoGeometry, dataSize, ptr);
index = new Uint32Array(draco.HEAPU32.buffer, ptr, numIndices).slice();
draco._free(ptr);
break;
default:
throw new Error("DRACODecoder: Unexpected index type.");
}
Expand Down Expand Up @@ -188,3 +189,4 @@ function decodeAttribute(draco, decoder, dracoGeometry, attributeName, attribute
itemSize: numComponents
};
}
`;
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const extensions = [".js", ".jsx", ".ts", ".tsx"];
const commonPlugins = [
resolve({ extensions, preferBuiltins: true }),
glslify({
include: [/\.glsl$/, "packages/**/worker/**/*.js"]
include: [/\.glsl$/]
}),
babel({
extensions,
Expand Down

0 comments on commit 19a1f32

Please sign in to comment.