Skip to content

Commit cf8860d

Browse files
committed
Fix publishing scenes with no models i.e. the e is not iterable error.
Fixes Hubs-Foundation#1137 Skip trying to remap the node refs for materials if there aren't any materials in the scene. Add the length of the JSON chunk to the header when there is no binary buffer so that a valid GLB file can be generated.
1 parent d98a535 commit cf8860d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/editor/Editor.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,11 @@ export default class Editor extends EventEmitter {
424424
}
425425

426426
this.remapNodeRefsInComponents(json.nodes, nodeDefs, uuidToIndexMap);
427-
this.remapNodeRefsInComponents(json.materials, nodeDefs, uuidToIndexMap);
427+
428+
// Account for scenes that don't contain any geometry/materials.
429+
if (json.materials !== undefined) {
430+
this.remapNodeRefsInComponents(json.materials, nodeDefs, uuidToIndexMap);
431+
}
428432
}
429433

430434
if (!json.extensions) {

src/editor/gltf/GLTFExporter.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,6 +1588,9 @@ class GLTFExporter {
15881588
});
15891589

15901590
pending.push(pendingBinChunk);
1591+
} else {
1592+
const totalByteLength = GLB_HEADER_BYTES + jsonChunkPrefix.byteLength + jsonChunk.byteLength;
1593+
headerView.setUint32(8, totalByteLength, true);
15911594
}
15921595

15931596
await Promise.all(pending);

0 commit comments

Comments
 (0)