@relu-interactives/spatial-ecs 0.2.17 → 0.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/{System-BeuJ1xt5.d.cts → System-me3iAcMF.d.cts} +150 -1
  2. package/dist/{System-BeuJ1xt5.d.ts → System-me3iAcMF.d.ts} +150 -1
  3. package/dist/{Video-Cym2C52L.d.ts → Video-DHnxjGhW.d.ts} +17 -3
  4. package/dist/{Video-D4B-z74P.d.cts → Video-U9hAnf9y.d.cts} +17 -3
  5. package/dist/{chunk-EPK6MA7X.js → chunk-5U3YS4JD.js} +1809 -8
  6. package/dist/chunk-5U3YS4JD.js.map +1 -0
  7. package/dist/{chunk-GRUK5TNL.js → chunk-AXRCGF63.js} +3 -3
  8. package/dist/{chunk-GRUK5TNL.js.map → chunk-AXRCGF63.js.map} +1 -1
  9. package/dist/{chunk-CJW6K3CL.js → chunk-K6KMKKJ6.js} +62 -5
  10. package/dist/chunk-K6KMKKJ6.js.map +1 -0
  11. package/dist/{chunk-FTIQQK62.js → chunk-V7BNVTJW.js} +50 -3
  12. package/dist/chunk-V7BNVTJW.js.map +1 -0
  13. package/dist/{chunk-R2WMVXZZ.js → chunk-ZXGHKX7N.js} +5 -3
  14. package/dist/chunk-ZXGHKX7N.js.map +1 -0
  15. package/dist/components/index.cjs +47 -0
  16. package/dist/components/index.cjs.map +1 -1
  17. package/dist/components/index.d.cts +3 -2
  18. package/dist/components/index.d.ts +3 -2
  19. package/dist/components/index.js +1 -1
  20. package/dist/docs/guide/components/material.md +4 -0
  21. package/dist/docs/guide/components/physics.md +10 -0
  22. package/dist/docs/guide/getting-started/editor/assets-browser.md +1 -1
  23. package/dist/docs/guide/prefabs.md +152 -0
  24. package/dist/docs/guide/world-api.md +1 -1
  25. package/dist/factories/index.cjs +136 -64
  26. package/dist/factories/index.cjs.map +1 -1
  27. package/dist/factories/index.d.cts +5 -4
  28. package/dist/factories/index.d.ts +5 -4
  29. package/dist/factories/index.js +3 -3
  30. package/dist/{index-BfoOC2CG.d.cts → index-CZo5I5Gs.d.cts} +76 -4
  31. package/dist/{index-BoJ3_6a3.d.ts → index-D7FSg0Au.d.ts} +76 -4
  32. package/dist/index.cjs +6386 -4962
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +313 -7
  35. package/dist/index.d.ts +313 -7
  36. package/dist/index.js +407 -926
  37. package/dist/index.js.map +1 -1
  38. package/dist/systems/index.cjs +1386 -0
  39. package/dist/systems/index.cjs.map +1 -1
  40. package/dist/systems/index.d.cts +2 -2
  41. package/dist/systems/index.d.ts +2 -2
  42. package/dist/systems/index.js +3 -3
  43. package/dist/types.d.cts +1 -1
  44. package/dist/types.d.ts +1 -1
  45. package/dist/worldSnapshotUtils.cjs +3 -1
  46. package/dist/worldSnapshotUtils.cjs.map +1 -1
  47. package/dist/worldSnapshotUtils.d.cts +1 -1
  48. package/dist/worldSnapshotUtils.d.ts +1 -1
  49. package/dist/worldSnapshotUtils.js +1 -1
  50. package/package.json +4 -2
  51. package/dist/chunk-CJW6K3CL.js.map +0 -1
  52. package/dist/chunk-EPK6MA7X.js.map +0 -1
  53. package/dist/chunk-FTIQQK62.js.map +0 -1
  54. package/dist/chunk-R2WMVXZZ.js.map +0 -1
@@ -468,6 +468,132 @@ type NormalizeContext = {
468
468
  declare function normalizeDebugValue(value: unknown, ctx: NormalizeContext): unknown;
469
469
  declare function cloneHistoryValue<T>(value: T, seen?: WeakMap<object, unknown>): T;
470
470
 
471
+ /**
472
+ * Snapshot-space entity-id walking/remapping.
473
+ *
474
+ * This module is the single source of truth for WHERE entity ids live inside
475
+ * a serialized world snapshot:
476
+ * - `ParentId.value`
477
+ * - `ScriptComponent.entries[].data` EntityInput (`{type:"entity", value}`)
478
+ * and ComponentInput (`{type:"component", value:{entityId, …}}`)
479
+ * - `InstancedMeshComponent.instanceEntityIds[]`
480
+ * - `InstanceSlotComponent.groupEntityId`
481
+ *
482
+ * Any new id-bearing component field must be added here — serialization,
483
+ * instantiation and the override differ all route through this walker.
484
+ */
485
+ type SubtreeSnapshot = {
486
+ entities: number[];
487
+ components: Array<{
488
+ component: string;
489
+ entries: Array<{
490
+ entityId: number;
491
+ value: unknown;
492
+ }>;
493
+ }>;
494
+ };
495
+ type ExternalRefWarning = {
496
+ /** Entity id (in the INPUT snapshot's id space) holding the reference. */
497
+ entityId: number;
498
+ component: string;
499
+ /** Slash-separated path of the reference inside the component value. */
500
+ path: string;
501
+ /** The referenced entity id that falls outside the id map. */
502
+ targetId: number;
503
+ };
504
+ type RemapSnapshotOptions = {
505
+ /**
506
+ * What to do with references to entities NOT present in the id map:
507
+ * - "null": replace the reference with null and record a warning
508
+ * (prefab-file serialization — external refs must not leak).
509
+ * - "keep": leave the raw id untouched and record a warning.
510
+ * Default: "keep".
511
+ */
512
+ externalRefPolicy?: "null" | "keep";
513
+ };
514
+ /**
515
+ * Return a deep-cloned snapshot with every entity id (entity list, entry
516
+ * keys, and all id-bearing component fields) remapped through `idMap`.
517
+ * References to ids missing from the map follow `externalRefPolicy` and are
518
+ * reported in `warnings` (with ids in the INPUT snapshot's id space).
519
+ */
520
+ declare function remapSnapshotEntityIds(snapshot: SubtreeSnapshot, idMap: Map<number, number>, options?: RemapSnapshotOptions): {
521
+ snapshot: SubtreeSnapshot;
522
+ warnings: ExternalRefWarning[];
523
+ };
524
+
525
+ declare const PREFAB_FILE_VERSION = 1;
526
+ /** Written for files containing NESTED instances (parse accepts either). */
527
+ declare const PREFAB_FILE_VERSION_NESTED = 2;
528
+ /** File version to write for a given snapshot: 2 iff it nests instances. */
529
+ declare function prefabFileVersionFor(snapshot: SubtreeSnapshot): number;
530
+ /**
531
+ * Envelope of a `.prefab` asset file (and, later, `.scene` assets — same
532
+ * shape with `type: "scene"`). `snapshot` is the same columnar world-snapshot
533
+ * format `hydrateWorldFromSnapshotDetailed` consumes, with entity ids
534
+ * renumbered 1..N and every entity carrying a `PrefabNode` identity.
535
+ */
536
+ type PrefabAsset = {
537
+ version: number;
538
+ type?: "prefab" | "scene";
539
+ name?: string;
540
+ snapshot: SubtreeSnapshot;
541
+ };
542
+ /** Validate untrusted JSON into a `PrefabAsset`, or null when malformed. */
543
+ declare function parsePrefabAsset(json: unknown): PrefabAsset | null;
544
+
545
+ type Vec3Like = {
546
+ x?: number;
547
+ y?: number;
548
+ z?: number;
549
+ };
550
+ /**
551
+ * Override how prefab asset URLs (the file URL itself AND every asset URL
552
+ * stored inside prefab files) are resolved before fetching. Published/preview
553
+ * runtimes register a resolver that maps the editor's `localasset://…/assets/x`
554
+ * URLs to `./assets/x`; the editor leaves it unset (identity — the
555
+ * `localasset://` protocol is fetchable there). Same pattern as
556
+ * {@link setDracoDecoderPath}. Pass null to restore identity.
557
+ */
558
+ declare function setPrefabAssetUrlResolver(resolver: ((url: string) => string) | null): void;
559
+ /**
560
+ * Fetch + parse (and cache) a `.prefab` asset. All strings inside the
561
+ * snapshot are passed through the registered URL resolver, so asset
562
+ * references load correctly in published/preview builds. Use this from
563
+ * preloaders to warm the same cache `spawnPrefab` reads.
564
+ */
565
+ declare function loadPrefab(url: string): Promise<PrefabAsset>;
566
+ /** Drop one cached prefab (or all when no url is given). */
567
+ declare function clearPrefabCache(url?: string): void;
568
+ type SpawnPrefabSource = string | {
569
+ path: string;
570
+ type?: string;
571
+ } | PrefabAsset;
572
+ type SpawnPrefabOptions = {
573
+ /** Parent the spawned root under this entity (default: world root). */
574
+ parentId?: EntityId | null;
575
+ /** Local-space spawn transform for the root (partial axes allowed). */
576
+ position?: Vec3Like;
577
+ rotation?: Vec3Like;
578
+ scale?: Vec3Like;
579
+ };
580
+ /**
581
+ * Instantiate a prefab into a live world at runtime.
582
+ *
583
+ * `source` may be a URL string, a script AssetInput (`{ path, type }`), or an
584
+ * already-loaded {@link PrefabAsset}. Resolves with the root entity id once
585
+ * all entities/components exist — heavyweight assets inside (models,
586
+ * textures, audio) continue loading reactively through their systems, using
587
+ * the shared model cache for repeat spawns.
588
+ */
589
+ declare function spawnPrefab(world: World, source: SpawnPrefabSource, options?: SpawnPrefabOptions): Promise<EntityId>;
590
+ /**
591
+ * Delete a spawned prefab instance: the root entity plus every descendant
592
+ * (children first). Returns the number of entities removed. `dispose`
593
+ * releases GPU resources not flagged as shared (safe with the model cache).
594
+ */
595
+ declare function despawnPrefab(world: World, rootId: EntityId, dispose?: boolean): number;
596
+
471
597
  type CreatePayload = {
472
598
  name?: string;
473
599
  transform?: TransformData;
@@ -867,6 +993,14 @@ declare class World {
867
993
  getEntityById(entityId: number): WorldEntityView | null;
868
994
  getEntitiesChildren(entityId: EntityId): WorldEntityView[];
869
995
  getEntitiesParent(entityId: EntityId): WorldEntityView | null;
996
+ /**
997
+ * Instantiate a prefab asset into this world at runtime — see
998
+ * {@link spawnPrefab}. Convenience wrapper so scripts and embedding apps
999
+ * can spawn without reaching for the object management system.
1000
+ */
1001
+ spawnPrefab(source: SpawnPrefabSource, options?: SpawnPrefabOptions): Promise<EntityId>;
1002
+ /** Remove a spawned prefab instance (root + descendants). */
1003
+ despawnPrefab(rootEntityId: EntityId): number;
870
1004
  getObjectManagementSystem(): ObjectManagementSystem;
871
1005
  /**
872
1006
  * Returns the singleton {@link Environment} component for the scene, or
@@ -959,6 +1093,21 @@ declare class World {
959
1093
  subscribe(listener: StoreListener): () => void;
960
1094
  getDebugSnapshot(maxDepth?: number): unknown;
961
1095
  getDebugSignature(maxDepth?: number): string;
1096
+ /**
1097
+ * Serialize ONLY the given entities into the same columnar
1098
+ * `{entities, components}` shape as {@link getDebugSnapshot} (no systems,
1099
+ * no selection). Used by prefab/scene subtree serialization.
1100
+ */
1101
+ getEntitiesSnapshot(entityIds: EntityId[], maxDepth?: number): {
1102
+ entities: number[];
1103
+ components: Array<{
1104
+ component: string;
1105
+ entries: Array<{
1106
+ entityId: number;
1107
+ value: unknown;
1108
+ }>;
1109
+ }>;
1110
+ };
962
1111
  createHistorySnapshot(): WorldHistorySnapshot;
963
1112
  applyHistorySnapshot(snapshot: WorldHistorySnapshot): void;
964
1113
  private emitStoreChanged;
@@ -969,4 +1118,4 @@ interface EcsSystem {
969
1118
  dispose?(world: World): void;
970
1119
  }
971
1120
 
972
- export { cloneHistoryValue as $, type AssetInput as A, type IntersectionResult as B, Component as C, DEFAULT_ENVIRONMENT_STATE as D, Environment as E, type FloatInput as F, KeyboardKeys as G, type SliderInput as H, InputSystem as I, type TextInput as J, type KeyboardKey as K, type ToggleInput as L, type MouseButton as M, TransformSyncSystem as N, ObjectManagementSystem as O, ParentId as P, type Vec3 as Q, RenderSystem as R, type SelectionListener as S, TransformComponent as T, type Vector2Input as U, type Vec3$1 as V, type WorldEntityView$1 as W, type Vector3Input as X, type AnyComponent as Y, DEBUG_CHANGE_IGNORED_SYSTEMS as Z, type WorldHistorySnapshot as _, DEFAULT_POSTPROCESSING_STATE as a, normalizeDebugValue as a0, type EnvironmentFogState as b, type EnvironmentFogType as c, type EnvironmentGradientEffect as d, type EnvironmentSkyboxState as e, type EnvironmentSkyboxType as f, type EnvironmentState as g, Postprocessing as h, type PostprocessingState as i, type TransformData as j, type EcsSystem as k, World as l, type ComponentClass as m, type ParentLookup as n, type EcsEntityKind as o, type CheckboxInput as p, type ColorInput as q, type ComponentFactory as r, type ComponentInput as s, type ComponentKind as t, type DropdownInput as u, type DropdownOption as v, type EcsComponentFactoryKind as w, type EcsEntityEditorKind as x, type EntityId as y, type EntityInput as z };
1121
+ export { type ToggleInput as $, type AssetInput as A, type EcsComponentFactoryKind as B, Component as C, DEFAULT_ENVIRONMENT_STATE as D, Environment as E, type EcsEntityEditorKind as F, type EntityInput as G, type FloatInput as H, InputSystem as I, type IntersectionResult as J, type KeyboardKey as K, KeyboardKeys as L, type MouseButton as M, PREFAB_FILE_VERSION as N, ObjectManagementSystem as O, ParentId as P, PREFAB_FILE_VERSION_NESTED as Q, type PrefabAsset as R, type SpawnPrefabSource as S, TransformComponent as T, type RemapSnapshotOptions as U, type Vec3$1 as V, type WorldEntityView$1 as W, RenderSystem as X, type SelectionListener as Y, type SliderInput as Z, type TextInput as _, DEFAULT_POSTPROCESSING_STATE as a, TransformSyncSystem as a0, type Vec3 as a1, type Vector2Input as a2, type Vector3Input as a3, clearPrefabCache as a4, despawnPrefab as a5, loadPrefab as a6, parsePrefabAsset as a7, prefabFileVersionFor as a8, remapSnapshotEntityIds as a9, setPrefabAssetUrlResolver as aa, spawnPrefab as ab, type AnyComponent as ac, DEBUG_CHANGE_IGNORED_SYSTEMS as ad, type WorldHistorySnapshot as ae, cloneHistoryValue as af, normalizeDebugValue as ag, type EnvironmentFogState as b, type EnvironmentFogType as c, type EnvironmentGradientEffect as d, type EnvironmentSkyboxState as e, type EnvironmentSkyboxType as f, type EnvironmentState as g, Postprocessing as h, type PostprocessingState as i, type TransformData as j, type EcsSystem as k, World as l, type SpawnPrefabOptions as m, type ComponentClass as n, type ParentLookup as o, type EcsEntityKind as p, type SubtreeSnapshot as q, type EntityId as r, type ExternalRefWarning as s, type CheckboxInput as t, type ColorInput as u, type ComponentFactory as v, type ComponentInput as w, type ComponentKind as x, type DropdownInput as y, type DropdownOption as z };
@@ -468,6 +468,132 @@ type NormalizeContext = {
468
468
  declare function normalizeDebugValue(value: unknown, ctx: NormalizeContext): unknown;
469
469
  declare function cloneHistoryValue<T>(value: T, seen?: WeakMap<object, unknown>): T;
470
470
 
471
+ /**
472
+ * Snapshot-space entity-id walking/remapping.
473
+ *
474
+ * This module is the single source of truth for WHERE entity ids live inside
475
+ * a serialized world snapshot:
476
+ * - `ParentId.value`
477
+ * - `ScriptComponent.entries[].data` EntityInput (`{type:"entity", value}`)
478
+ * and ComponentInput (`{type:"component", value:{entityId, …}}`)
479
+ * - `InstancedMeshComponent.instanceEntityIds[]`
480
+ * - `InstanceSlotComponent.groupEntityId`
481
+ *
482
+ * Any new id-bearing component field must be added here — serialization,
483
+ * instantiation and the override differ all route through this walker.
484
+ */
485
+ type SubtreeSnapshot = {
486
+ entities: number[];
487
+ components: Array<{
488
+ component: string;
489
+ entries: Array<{
490
+ entityId: number;
491
+ value: unknown;
492
+ }>;
493
+ }>;
494
+ };
495
+ type ExternalRefWarning = {
496
+ /** Entity id (in the INPUT snapshot's id space) holding the reference. */
497
+ entityId: number;
498
+ component: string;
499
+ /** Slash-separated path of the reference inside the component value. */
500
+ path: string;
501
+ /** The referenced entity id that falls outside the id map. */
502
+ targetId: number;
503
+ };
504
+ type RemapSnapshotOptions = {
505
+ /**
506
+ * What to do with references to entities NOT present in the id map:
507
+ * - "null": replace the reference with null and record a warning
508
+ * (prefab-file serialization — external refs must not leak).
509
+ * - "keep": leave the raw id untouched and record a warning.
510
+ * Default: "keep".
511
+ */
512
+ externalRefPolicy?: "null" | "keep";
513
+ };
514
+ /**
515
+ * Return a deep-cloned snapshot with every entity id (entity list, entry
516
+ * keys, and all id-bearing component fields) remapped through `idMap`.
517
+ * References to ids missing from the map follow `externalRefPolicy` and are
518
+ * reported in `warnings` (with ids in the INPUT snapshot's id space).
519
+ */
520
+ declare function remapSnapshotEntityIds(snapshot: SubtreeSnapshot, idMap: Map<number, number>, options?: RemapSnapshotOptions): {
521
+ snapshot: SubtreeSnapshot;
522
+ warnings: ExternalRefWarning[];
523
+ };
524
+
525
+ declare const PREFAB_FILE_VERSION = 1;
526
+ /** Written for files containing NESTED instances (parse accepts either). */
527
+ declare const PREFAB_FILE_VERSION_NESTED = 2;
528
+ /** File version to write for a given snapshot: 2 iff it nests instances. */
529
+ declare function prefabFileVersionFor(snapshot: SubtreeSnapshot): number;
530
+ /**
531
+ * Envelope of a `.prefab` asset file (and, later, `.scene` assets — same
532
+ * shape with `type: "scene"`). `snapshot` is the same columnar world-snapshot
533
+ * format `hydrateWorldFromSnapshotDetailed` consumes, with entity ids
534
+ * renumbered 1..N and every entity carrying a `PrefabNode` identity.
535
+ */
536
+ type PrefabAsset = {
537
+ version: number;
538
+ type?: "prefab" | "scene";
539
+ name?: string;
540
+ snapshot: SubtreeSnapshot;
541
+ };
542
+ /** Validate untrusted JSON into a `PrefabAsset`, or null when malformed. */
543
+ declare function parsePrefabAsset(json: unknown): PrefabAsset | null;
544
+
545
+ type Vec3Like = {
546
+ x?: number;
547
+ y?: number;
548
+ z?: number;
549
+ };
550
+ /**
551
+ * Override how prefab asset URLs (the file URL itself AND every asset URL
552
+ * stored inside prefab files) are resolved before fetching. Published/preview
553
+ * runtimes register a resolver that maps the editor's `localasset://…/assets/x`
554
+ * URLs to `./assets/x`; the editor leaves it unset (identity — the
555
+ * `localasset://` protocol is fetchable there). Same pattern as
556
+ * {@link setDracoDecoderPath}. Pass null to restore identity.
557
+ */
558
+ declare function setPrefabAssetUrlResolver(resolver: ((url: string) => string) | null): void;
559
+ /**
560
+ * Fetch + parse (and cache) a `.prefab` asset. All strings inside the
561
+ * snapshot are passed through the registered URL resolver, so asset
562
+ * references load correctly in published/preview builds. Use this from
563
+ * preloaders to warm the same cache `spawnPrefab` reads.
564
+ */
565
+ declare function loadPrefab(url: string): Promise<PrefabAsset>;
566
+ /** Drop one cached prefab (or all when no url is given). */
567
+ declare function clearPrefabCache(url?: string): void;
568
+ type SpawnPrefabSource = string | {
569
+ path: string;
570
+ type?: string;
571
+ } | PrefabAsset;
572
+ type SpawnPrefabOptions = {
573
+ /** Parent the spawned root under this entity (default: world root). */
574
+ parentId?: EntityId | null;
575
+ /** Local-space spawn transform for the root (partial axes allowed). */
576
+ position?: Vec3Like;
577
+ rotation?: Vec3Like;
578
+ scale?: Vec3Like;
579
+ };
580
+ /**
581
+ * Instantiate a prefab into a live world at runtime.
582
+ *
583
+ * `source` may be a URL string, a script AssetInput (`{ path, type }`), or an
584
+ * already-loaded {@link PrefabAsset}. Resolves with the root entity id once
585
+ * all entities/components exist — heavyweight assets inside (models,
586
+ * textures, audio) continue loading reactively through their systems, using
587
+ * the shared model cache for repeat spawns.
588
+ */
589
+ declare function spawnPrefab(world: World, source: SpawnPrefabSource, options?: SpawnPrefabOptions): Promise<EntityId>;
590
+ /**
591
+ * Delete a spawned prefab instance: the root entity plus every descendant
592
+ * (children first). Returns the number of entities removed. `dispose`
593
+ * releases GPU resources not flagged as shared (safe with the model cache).
594
+ */
595
+ declare function despawnPrefab(world: World, rootId: EntityId, dispose?: boolean): number;
596
+
471
597
  type CreatePayload = {
472
598
  name?: string;
473
599
  transform?: TransformData;
@@ -867,6 +993,14 @@ declare class World {
867
993
  getEntityById(entityId: number): WorldEntityView | null;
868
994
  getEntitiesChildren(entityId: EntityId): WorldEntityView[];
869
995
  getEntitiesParent(entityId: EntityId): WorldEntityView | null;
996
+ /**
997
+ * Instantiate a prefab asset into this world at runtime — see
998
+ * {@link spawnPrefab}. Convenience wrapper so scripts and embedding apps
999
+ * can spawn without reaching for the object management system.
1000
+ */
1001
+ spawnPrefab(source: SpawnPrefabSource, options?: SpawnPrefabOptions): Promise<EntityId>;
1002
+ /** Remove a spawned prefab instance (root + descendants). */
1003
+ despawnPrefab(rootEntityId: EntityId): number;
870
1004
  getObjectManagementSystem(): ObjectManagementSystem;
871
1005
  /**
872
1006
  * Returns the singleton {@link Environment} component for the scene, or
@@ -959,6 +1093,21 @@ declare class World {
959
1093
  subscribe(listener: StoreListener): () => void;
960
1094
  getDebugSnapshot(maxDepth?: number): unknown;
961
1095
  getDebugSignature(maxDepth?: number): string;
1096
+ /**
1097
+ * Serialize ONLY the given entities into the same columnar
1098
+ * `{entities, components}` shape as {@link getDebugSnapshot} (no systems,
1099
+ * no selection). Used by prefab/scene subtree serialization.
1100
+ */
1101
+ getEntitiesSnapshot(entityIds: EntityId[], maxDepth?: number): {
1102
+ entities: number[];
1103
+ components: Array<{
1104
+ component: string;
1105
+ entries: Array<{
1106
+ entityId: number;
1107
+ value: unknown;
1108
+ }>;
1109
+ }>;
1110
+ };
962
1111
  createHistorySnapshot(): WorldHistorySnapshot;
963
1112
  applyHistorySnapshot(snapshot: WorldHistorySnapshot): void;
964
1113
  private emitStoreChanged;
@@ -969,4 +1118,4 @@ interface EcsSystem {
969
1118
  dispose?(world: World): void;
970
1119
  }
971
1120
 
972
- export { cloneHistoryValue as $, type AssetInput as A, type IntersectionResult as B, Component as C, DEFAULT_ENVIRONMENT_STATE as D, Environment as E, type FloatInput as F, KeyboardKeys as G, type SliderInput as H, InputSystem as I, type TextInput as J, type KeyboardKey as K, type ToggleInput as L, type MouseButton as M, TransformSyncSystem as N, ObjectManagementSystem as O, ParentId as P, type Vec3 as Q, RenderSystem as R, type SelectionListener as S, TransformComponent as T, type Vector2Input as U, type Vec3$1 as V, type WorldEntityView$1 as W, type Vector3Input as X, type AnyComponent as Y, DEBUG_CHANGE_IGNORED_SYSTEMS as Z, type WorldHistorySnapshot as _, DEFAULT_POSTPROCESSING_STATE as a, normalizeDebugValue as a0, type EnvironmentFogState as b, type EnvironmentFogType as c, type EnvironmentGradientEffect as d, type EnvironmentSkyboxState as e, type EnvironmentSkyboxType as f, type EnvironmentState as g, Postprocessing as h, type PostprocessingState as i, type TransformData as j, type EcsSystem as k, World as l, type ComponentClass as m, type ParentLookup as n, type EcsEntityKind as o, type CheckboxInput as p, type ColorInput as q, type ComponentFactory as r, type ComponentInput as s, type ComponentKind as t, type DropdownInput as u, type DropdownOption as v, type EcsComponentFactoryKind as w, type EcsEntityEditorKind as x, type EntityId as y, type EntityInput as z };
1121
+ export { type ToggleInput as $, type AssetInput as A, type EcsComponentFactoryKind as B, Component as C, DEFAULT_ENVIRONMENT_STATE as D, Environment as E, type EcsEntityEditorKind as F, type EntityInput as G, type FloatInput as H, InputSystem as I, type IntersectionResult as J, type KeyboardKey as K, KeyboardKeys as L, type MouseButton as M, PREFAB_FILE_VERSION as N, ObjectManagementSystem as O, ParentId as P, PREFAB_FILE_VERSION_NESTED as Q, type PrefabAsset as R, type SpawnPrefabSource as S, TransformComponent as T, type RemapSnapshotOptions as U, type Vec3$1 as V, type WorldEntityView$1 as W, RenderSystem as X, type SelectionListener as Y, type SliderInput as Z, type TextInput as _, DEFAULT_POSTPROCESSING_STATE as a, TransformSyncSystem as a0, type Vec3 as a1, type Vector2Input as a2, type Vector3Input as a3, clearPrefabCache as a4, despawnPrefab as a5, loadPrefab as a6, parsePrefabAsset as a7, prefabFileVersionFor as a8, remapSnapshotEntityIds as a9, setPrefabAssetUrlResolver as aa, spawnPrefab as ab, type AnyComponent as ac, DEBUG_CHANGE_IGNORED_SYSTEMS as ad, type WorldHistorySnapshot as ae, cloneHistoryValue as af, normalizeDebugValue as ag, type EnvironmentFogState as b, type EnvironmentFogType as c, type EnvironmentGradientEffect as d, type EnvironmentSkyboxState as e, type EnvironmentSkyboxType as f, type EnvironmentState as g, Postprocessing as h, type PostprocessingState as i, type TransformData as j, type EcsSystem as k, World as l, type SpawnPrefabOptions as m, type ComponentClass as n, type ParentLookup as o, type EcsEntityKind as p, type SubtreeSnapshot as q, type EntityId as r, type ExternalRefWarning as s, type CheckboxInput as t, type ColorInput as u, type ComponentFactory as v, type ComponentInput as w, type ComponentKind as x, type DropdownInput as y, type DropdownOption as z };
@@ -1,5 +1,5 @@
1
1
  import * as THREE from 'three';
2
- import { C as Component, o as EcsEntityKind, x as EcsEntityEditorKind, y as EntityId } from './System-BeuJ1xt5.js';
2
+ import { C as Component, p as EcsEntityKind, F as EcsEntityEditorKind, r as EntityId } from './System-me3iAcMF.js';
3
3
  import * as RAPIER from '@dimforge/rapier3d-compat';
4
4
 
5
5
  interface StateMachine {
@@ -552,7 +552,7 @@ type ColliderState = {
552
552
  /** Rotation around local Z (radians). */
553
553
  z: number;
554
554
  };
555
- /** Half-extents for `cuboid` shape, in world units. */
555
+ /** FULL edge lengths for `cuboid` shape (NOT half-extents), in unscaled local units — multiplied by the entity world scale at collider build time. */
556
556
  size: {
557
557
  /** Half-extent along X. */
558
558
  x: number;
@@ -821,6 +821,7 @@ type MaterialValueState = {
821
821
  /** Whether mipmaps are generated for texture maps. */
822
822
  useMipmaps: boolean;
823
823
  };
824
+ declare function defaultMaterialValue(): MaterialValueState;
824
825
  /**
825
826
  * Material catalog for an entity. Tracks the live three.js materials
826
827
  * (`materials`, `material`) plus serialized authoring state (`values[]`)
@@ -842,7 +843,20 @@ declare class MaterialComponent extends Component {
842
843
  material: THREE.Material | null;
843
844
  /** Serialized authoring state (one entry per material in {@link materials}). Saved with the project. */
844
845
  values: MaterialValueState[];
846
+ /**
847
+ * Editor-managed material-asset linkage, one entry per slot (parallel to
848
+ * {@link values}). A `localasset://` URL of a `.material` asset file, or
849
+ * `null`/absent for a local (unlinked) material. The editor materializes the
850
+ * asset's values into {@link values} and keeps them in sync when the asset
851
+ * is edited — rendering and the runtime read only {@link values} and ignore
852
+ * this field. Saved with the project; survives material rebinds.
853
+ */
854
+ assetRefs: (string | null)[];
845
855
  constructor(materialOrMaterials?: THREE.Material | THREE.Material[]);
856
+ /** Link/unlink a slot to a material asset URL (editor bookkeeping only). */
857
+ setAssetRef(index: number, url: string | null): void;
858
+ /** The material-asset URL a slot is linked to, or null when local. */
859
+ getAssetRef(index: number): string | null;
846
860
  setMaterials(materialOrMaterials?: THREE.Material | THREE.Material[]): void;
847
861
  updateValue(index: number, patch: Partial<MaterialValueState>): void;
848
862
  resetValue(index: number): void;
@@ -1113,4 +1127,4 @@ declare class VideoComponent extends Component {
1113
1127
  stop(): void;
1114
1128
  }
1115
1129
 
1116
- export { type TransformSpaceValue as $, AnimationComponent as A, MeshGeometryComponent as B, CameraComponent as C, DEFAULT_COLLIDER_STATE as D, type EditableMeshObjectKind as E, type MeshGeometryParameters as F, type MeshGeometryParametersByKind as G, ModelComponent as H, ImageComponent as I, type PhysicsState as J, type PlaneMeshParameters as K, LightComponent as L, MaterialComponent as M, Name as N, Object3DRef as O, PhysicsComponent as P, type RadiusMeshParameters as Q, type RadiusHeightMeshParameters as R, type RigidbodyState as S, type RigidbodyType as T, ScriptComponent as U, type ScriptEntry as V, Selectable as W, SelectionTransformState as X, SpriteComponent as Y, type TextureFilteringValue as Z, type TransformModeValue as _, type AnimationComponentOptions as a, VideoComponent as a0, normalizePhysicsState as a1, type AnimationStateCallbacks as a2, AnimationStateMachine as a3, AnimationStateManager as a4, type StateMachine as a5, AudioComponent as b, type CameraComponentOptions as c, type CameraProjection as d, type CameraRuntimeType as e, type ColliderShape as f, type ColliderState as g, type CubeMeshParameters as h, DEFAULT_INSTANCED_MESH_PARAMETERS as i, DEFAULT_INSTANCE_TRANSFORM as j, DEFAULT_MESH_GEOMETRY_PARAMETERS as k, DEFAULT_PHYSICS_STATE as l, DEFAULT_RIGIDBODY_STATE as m, EntityType as n, ImageTarget as o, ImageTargetAnchor as p, type ImageTargetAnchorOptions as q, type ImageTargetReference as r, InstanceSlotComponent as s, type InstanceTransform as t, InstancedMeshComponent as u, type InstancedMeshKind as v, type LightValueState as w, type MaterialTypeValue as x, type MaterialValueState as y, MeshComponent as z };
1130
+ export { type TransformSpaceValue as $, AnimationComponent as A, MeshGeometryComponent as B, CameraComponent as C, DEFAULT_COLLIDER_STATE as D, type EditableMeshObjectKind as E, type MeshGeometryParameters as F, type MeshGeometryParametersByKind as G, ModelComponent as H, ImageComponent as I, type PhysicsState as J, type PlaneMeshParameters as K, LightComponent as L, MaterialComponent as M, Name as N, Object3DRef as O, PhysicsComponent as P, type RadiusMeshParameters as Q, type RadiusHeightMeshParameters as R, type RigidbodyState as S, type RigidbodyType as T, ScriptComponent as U, type ScriptEntry as V, Selectable as W, SelectionTransformState as X, SpriteComponent as Y, type TextureFilteringValue as Z, type TransformModeValue as _, type AnimationComponentOptions as a, VideoComponent as a0, defaultMaterialValue as a1, normalizePhysicsState as a2, type AnimationStateCallbacks as a3, AnimationStateMachine as a4, AnimationStateManager as a5, type StateMachine as a6, AudioComponent as b, type CameraComponentOptions as c, type CameraProjection as d, type CameraRuntimeType as e, type ColliderShape as f, type ColliderState as g, type CubeMeshParameters as h, DEFAULT_INSTANCED_MESH_PARAMETERS as i, DEFAULT_INSTANCE_TRANSFORM as j, DEFAULT_MESH_GEOMETRY_PARAMETERS as k, DEFAULT_PHYSICS_STATE as l, DEFAULT_RIGIDBODY_STATE as m, EntityType as n, ImageTarget as o, ImageTargetAnchor as p, type ImageTargetAnchorOptions as q, type ImageTargetReference as r, InstanceSlotComponent as s, type InstanceTransform as t, InstancedMeshComponent as u, type InstancedMeshKind as v, type LightValueState as w, type MaterialTypeValue as x, type MaterialValueState as y, MeshComponent as z };
@@ -1,5 +1,5 @@
1
1
  import * as THREE from 'three';
2
- import { C as Component, o as EcsEntityKind, x as EcsEntityEditorKind, y as EntityId } from './System-BeuJ1xt5.cjs';
2
+ import { C as Component, p as EcsEntityKind, F as EcsEntityEditorKind, r as EntityId } from './System-me3iAcMF.cjs';
3
3
  import * as RAPIER from '@dimforge/rapier3d-compat';
4
4
 
5
5
  interface StateMachine {
@@ -552,7 +552,7 @@ type ColliderState = {
552
552
  /** Rotation around local Z (radians). */
553
553
  z: number;
554
554
  };
555
- /** Half-extents for `cuboid` shape, in world units. */
555
+ /** FULL edge lengths for `cuboid` shape (NOT half-extents), in unscaled local units — multiplied by the entity world scale at collider build time. */
556
556
  size: {
557
557
  /** Half-extent along X. */
558
558
  x: number;
@@ -821,6 +821,7 @@ type MaterialValueState = {
821
821
  /** Whether mipmaps are generated for texture maps. */
822
822
  useMipmaps: boolean;
823
823
  };
824
+ declare function defaultMaterialValue(): MaterialValueState;
824
825
  /**
825
826
  * Material catalog for an entity. Tracks the live three.js materials
826
827
  * (`materials`, `material`) plus serialized authoring state (`values[]`)
@@ -842,7 +843,20 @@ declare class MaterialComponent extends Component {
842
843
  material: THREE.Material | null;
843
844
  /** Serialized authoring state (one entry per material in {@link materials}). Saved with the project. */
844
845
  values: MaterialValueState[];
846
+ /**
847
+ * Editor-managed material-asset linkage, one entry per slot (parallel to
848
+ * {@link values}). A `localasset://` URL of a `.material` asset file, or
849
+ * `null`/absent for a local (unlinked) material. The editor materializes the
850
+ * asset's values into {@link values} and keeps them in sync when the asset
851
+ * is edited — rendering and the runtime read only {@link values} and ignore
852
+ * this field. Saved with the project; survives material rebinds.
853
+ */
854
+ assetRefs: (string | null)[];
845
855
  constructor(materialOrMaterials?: THREE.Material | THREE.Material[]);
856
+ /** Link/unlink a slot to a material asset URL (editor bookkeeping only). */
857
+ setAssetRef(index: number, url: string | null): void;
858
+ /** The material-asset URL a slot is linked to, or null when local. */
859
+ getAssetRef(index: number): string | null;
846
860
  setMaterials(materialOrMaterials?: THREE.Material | THREE.Material[]): void;
847
861
  updateValue(index: number, patch: Partial<MaterialValueState>): void;
848
862
  resetValue(index: number): void;
@@ -1113,4 +1127,4 @@ declare class VideoComponent extends Component {
1113
1127
  stop(): void;
1114
1128
  }
1115
1129
 
1116
- export { type TransformSpaceValue as $, AnimationComponent as A, MeshGeometryComponent as B, CameraComponent as C, DEFAULT_COLLIDER_STATE as D, type EditableMeshObjectKind as E, type MeshGeometryParameters as F, type MeshGeometryParametersByKind as G, ModelComponent as H, ImageComponent as I, type PhysicsState as J, type PlaneMeshParameters as K, LightComponent as L, MaterialComponent as M, Name as N, Object3DRef as O, PhysicsComponent as P, type RadiusMeshParameters as Q, type RadiusHeightMeshParameters as R, type RigidbodyState as S, type RigidbodyType as T, ScriptComponent as U, type ScriptEntry as V, Selectable as W, SelectionTransformState as X, SpriteComponent as Y, type TextureFilteringValue as Z, type TransformModeValue as _, type AnimationComponentOptions as a, VideoComponent as a0, normalizePhysicsState as a1, type AnimationStateCallbacks as a2, AnimationStateMachine as a3, AnimationStateManager as a4, type StateMachine as a5, AudioComponent as b, type CameraComponentOptions as c, type CameraProjection as d, type CameraRuntimeType as e, type ColliderShape as f, type ColliderState as g, type CubeMeshParameters as h, DEFAULT_INSTANCED_MESH_PARAMETERS as i, DEFAULT_INSTANCE_TRANSFORM as j, DEFAULT_MESH_GEOMETRY_PARAMETERS as k, DEFAULT_PHYSICS_STATE as l, DEFAULT_RIGIDBODY_STATE as m, EntityType as n, ImageTarget as o, ImageTargetAnchor as p, type ImageTargetAnchorOptions as q, type ImageTargetReference as r, InstanceSlotComponent as s, type InstanceTransform as t, InstancedMeshComponent as u, type InstancedMeshKind as v, type LightValueState as w, type MaterialTypeValue as x, type MaterialValueState as y, MeshComponent as z };
1130
+ export { type TransformSpaceValue as $, AnimationComponent as A, MeshGeometryComponent as B, CameraComponent as C, DEFAULT_COLLIDER_STATE as D, type EditableMeshObjectKind as E, type MeshGeometryParameters as F, type MeshGeometryParametersByKind as G, ModelComponent as H, ImageComponent as I, type PhysicsState as J, type PlaneMeshParameters as K, LightComponent as L, MaterialComponent as M, Name as N, Object3DRef as O, PhysicsComponent as P, type RadiusMeshParameters as Q, type RadiusHeightMeshParameters as R, type RigidbodyState as S, type RigidbodyType as T, ScriptComponent as U, type ScriptEntry as V, Selectable as W, SelectionTransformState as X, SpriteComponent as Y, type TextureFilteringValue as Z, type TransformModeValue as _, type AnimationComponentOptions as a, VideoComponent as a0, defaultMaterialValue as a1, normalizePhysicsState as a2, type AnimationStateCallbacks as a3, AnimationStateMachine as a4, AnimationStateManager as a5, type StateMachine as a6, AudioComponent as b, type CameraComponentOptions as c, type CameraProjection as d, type CameraRuntimeType as e, type ColliderShape as f, type ColliderState as g, type CubeMeshParameters as h, DEFAULT_INSTANCED_MESH_PARAMETERS as i, DEFAULT_INSTANCE_TRANSFORM as j, DEFAULT_MESH_GEOMETRY_PARAMETERS as k, DEFAULT_PHYSICS_STATE as l, DEFAULT_RIGIDBODY_STATE as m, EntityType as n, ImageTarget as o, ImageTargetAnchor as p, type ImageTargetAnchorOptions as q, type ImageTargetReference as r, InstanceSlotComponent as s, type InstanceTransform as t, InstancedMeshComponent as u, type InstancedMeshKind as v, type LightValueState as w, type MaterialTypeValue as x, type MaterialValueState as y, MeshComponent as z };