BabylonJS/Babylon.js · error · Error

Error parsing events

Error message

Error parsing events

What it means

Thrown in _parseEvents while mapping a custom event's `values` object: a key resolved to a null/undefined value entry. This guards against sparse or malformed event value objects in the glTF, which per spec should always map keys to a value descriptor (type + optional value).

Source

Thrown at packages/dev/loaders/src/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.ts:211

            value[0] = parseFloat(value[0]);
        }
        return { type: type.flowGraphType, value: dataTransform ? dataTransform(value, this) : value };
    }

    private _parseEvents() {
        if (!this._interactivityGraph.events) {
            return;
        }
        for (const event of this._interactivityGraph.events) {
            const converted: InteractivityEvent = {
                eventId: event.id || "internalEvent_" + this._internalEventsCounter++,
            };
            if (event.values) {
                converted.eventData = Object.keys(event.values).map((key) => {
                    const eventValue = event.values?.[key];
                    if (!eventValue) {
                        Logger.Error(["No value found for event key", key]);
                        throw new Error("Error parsing events");
                    }
                    const type = this._types[eventValue.type];
                    if (!type) {
                        Logger.Error(["No type found for event value", eventValue]);
                        throw new Error("Error parsing events");
                    }
                    const value = typeof eventValue.value !== "undefined" ? this._parseVariable(eventValue) : undefined;
                    return {
                        id: key,
                        type: type.flowGraphType,
                        eventData: true,
                        value,
                    };
                });
            }
            this._events.push(converted);
        }
    }

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Remove the null/empty key from the event's `values` object in the glTF asset
  2. Give the key a valid value descriptor `{ "type": <index>, "value": [...] }`
  3. Check the console log ("No value found for event key") to identify the offending key
  4. Re-export the asset with a current exporter to regenerate a clean events section

Example fix

// before
"values": { "speed": null }
// after
"values": { "speed": { "type": 0, "value": [0] } }
Defensive patterns

Strategy: validation

Validate before calling

for (const ev of graph.events ?? []) {
  for (const [key, val] of Object.entries(ev.values ?? {})) {
    if (val == null) throw new Error(`Event ${ev.id}: value for key '${key}' is null/empty`);
  }
}

Type guard

function hasValidEventValues(ev: { values?: Record<string, unknown> | null }): boolean {
  return !ev.values || Object.values(ev.values).every((v) => v != null);
}

Try / catch

try {
  const parser = new InteractivityGraphToFlowGraphParser(graph, gltf);
} catch (e) {
  if (e.message === 'Error parsing events') {
    console.warn('Malformed event values; dropping events and continuing');
    graph.events = undefined;
    return new InteractivityGraphToFlowGraphParser(graph, gltf);
  }
  throw e;
}

Prevention

When it happens

Trigger: An event's `values` object contains a key whose value is null, undefined, or empty (e.g. `{ "myParam": null }`) while the parser iterates Object.keys(event.values) and dereferences each entry.

Common situations: Hand-edited or tool-merged glTF files where an event value was deleted but its key left behind; exporters emitting explicit null entries; JSON merge patches leaving nulls.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/8053dd4234e3bc14. Report an issue: GitHub.