Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
Guard the viewer's dat.GUI dropdowns against a -1 selectedIndex
nirholas780424a1e4e3
diff --git a/src/viewer.js b/src/viewer.jsindex cbb6def77..cc0097142 100644--- a/src/viewer.js+++ b/src/viewer.js@@ -1351,6 +1351,28 @@ export class Viewer {hideable: true,}));+ // dat.GUI's OptionController change handler reads+ // `select.options[select.selectedIndex].value` with no guard, so a `change`+ // event fired while a dropdown sits at selectedIndex === -1 throws+ // "Cannot read properties of undefined (reading 'value')". A user can never+ // put a populated <select> in that state, but a programmatic deselect — an+ // automated form fuzzer or accessibility crawler dispatching synthetic+ // change events — can. Normalize the index in the capture phase, before+ // dat.GUI's own bubble-phase listener runs, so the control degrades to its+ // first option (or the event is dropped when there is nothing to select)+ // instead of crashing the whole viewer.+ gui.domElement.addEventListener(+ 'change',+ (e) => {+ const t = /** @type {HTMLSelectElement} */ (e.target);+ if (t && t.tagName === 'SELECT' && t.selectedIndex < 0) {+ if (t.options.length) t.selectedIndex = 0;+ else e.stopImmediatePropagation();+ }+ },+ true,+ );+// Display controls.const dispFolder = gui.addFolder('Display');const envBackgroundCtrl = dispFolder.add(this.state, 'background');