Skip to content

@relu-interactives/spatial-ecs


@relu-interactives/spatial-ecs / index / canonicalizeComponentValue

Function: canonicalizeComponentValue() ​

ts
function canonicalizeComponentValue(
   componentName, 
   value, 
   idToNode): unknown;

Defined in: prefab/overrides.ts:177

Canonicalize a serialized component value into nodeId-space:

  • entity-id fields → {$node} (internal) or raw id (external)
  • ScriptComponent entries keep only {className, scriptUrl, enabled, data} (entityId/runtimeState/runtimeMessage are per-instance transients)
  • ScriptObjectComponent keeps only {scriptUrl, className, enabled, data} (runtimeState/runtimeMessage are per-instance transients)
  • Object3DRef keeps only {visibility} (the rest is a live object ref)

Keep the id-bearing field list in sync with snapshotIdUtils.ts.

Parameters ​

ParameterType
componentNamestring
valueunknown
idToNodeMap<number, string>

Returns ​

unknown