Skip to content

Commit 5088bf9

Browse files
committed
sanitize slot name before registering it
this avoids a slot being added multiple times if sanitization results in the same name which would break (e.g. "roof" and "roof_")
1 parent 0e266f4 commit 5088bf9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/utils/parser.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ function parse(gltf, { fileName = 'model', ...options } = {}) {
2525
const slot = child.userData?.prop;
2626
const hasSlot = (slot && typeof slot === "string" && slot.length > 0);
2727
if (hasSlot)
28-
slots[slot] ? slots[slot].push(child) : (slots[slot] = [child]);
28+
{
29+
const slotname = sanitizeSlotName(slot);
30+
slots[slotname] ? slots[slotname].push(child) : (slots[slotname] = [child]);
31+
}
2932
})
3033

3134
// Browse for duplicates
@@ -465,7 +468,7 @@ function parse(gltf, { fileName = 'model', ...options } = {}) {
465468
console.log('Error while parsing glTF', e)
466469
}
467470

468-
const slotParams = Object.keys(slots).length > 0 ? (Object.keys(slots).map(sanitizeSlotName).join(", ") + ", ") : "";
471+
const slotParams = Object.keys(slots).length > 0 ? (Object.keys(slots).join(", ") + ", ") : "";
469472

470473
const header = `/*
471474
${options.header ? options.header : 'Auto-generated by: https://github.com/pmndrs/gltfjsx'} ${

0 commit comments

Comments
 (0)