@ignifx/core 0.9.0 → 0.10.0

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 (24) hide show
  1. package/dist/{environment-mr5wp69e.js → environment-BCjfp1jB.js} +2 -2
  2. package/dist/{environment-mr5wp69e.js.map → environment-BCjfp1jB.js.map} +1 -1
  3. package/dist/{ignifx-error-CRh89KUJ.js → ignifx-error-RpK-lWwE.js} +13 -2
  4. package/dist/ignifx-error-RpK-lWwE.js.map +1 -0
  5. package/dist/index.d.ts +1593 -677
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +2376 -238
  8. package/dist/index.js.map +1 -1
  9. package/dist/{material-plugin-BRnhfw7K.js → material-plugin-CWtV7DkH.js} +2 -2
  10. package/dist/{material-plugin-BRnhfw7K.js.map → material-plugin-CWtV7DkH.js.map} +1 -1
  11. package/dist/overlay-CjVgsfrm.js +239 -0
  12. package/dist/overlay-CjVgsfrm.js.map +1 -0
  13. package/dist/{post-effect-compiler-Rce26Eue.js → post-effect-compiler-pOvXae-i.js} +2 -2
  14. package/dist/{post-effect-compiler-Rce26Eue.js.map → post-effect-compiler-pOvXae-i.js.map} +1 -1
  15. package/dist/{shader-material-U6BKZ8D1.js → shader-material-B6wwFCKB.js} +2 -2
  16. package/dist/{shader-material-U6BKZ8D1.js.map → shader-material-B6wwFCKB.js.map} +1 -1
  17. package/dist/{shader-material-BIG3UDyu.js → shader-material-C4VjLTfV.js} +3 -3
  18. package/dist/{shader-material-BIG3UDyu.js.map → shader-material-C4VjLTfV.js.map} +1 -1
  19. package/dist/{shader-pragma-tw6AKaQD.js → shader-pragma-qO9_6sTd.js} +2 -2
  20. package/dist/{shader-pragma-tw6AKaQD.js.map → shader-pragma-qO9_6sTd.js.map} +1 -1
  21. package/dist/{surface-shader-Br17yysO.js → surface-shader-BaR7Kg-F.js} +4 -4
  22. package/dist/{surface-shader-Br17yysO.js.map → surface-shader-BaR7Kg-F.js.map} +1 -1
  23. package/package.json +1 -1
  24. package/dist/ignifx-error-CRh89KUJ.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -55,6 +55,8 @@ export declare const ErrorRange: {
55
55
  readonly terrain: "16";
56
56
  /** Particle systems, 3D and 2D. */
57
57
  readonly particles: "17";
58
+ /** The editor host package and its Vite plugin. */
59
+ readonly editorHost: "18";
58
60
  };
59
61
  /**
60
62
  * The union of the two-digit subsystem prefixes declared by `ErrorRange`.
@@ -127,6 +129,8 @@ export declare const CoreErrorCode: {
127
129
  readonly invalidTweenOptions: "IGX-0109";
128
130
  /** A tweened field is not a number, `Vec2`, `Vec3`, or `Quat`, or is not writable. */
129
131
  readonly tweenFieldNotTweenable: "IGX-0110";
132
+ /** A coroutine was started in an edit-mode app by a script whose class does not run in edit mode. */
133
+ readonly coroutineInEditMode: "IGX-0111";
130
134
  /** A component declared through `requires` is missing from the entity. */
131
135
  readonly requiredComponentMissing: "IGX-0201";
132
136
  /** A second instance of a component type that does not allow multiples was added. */
@@ -193,6 +197,8 @@ export declare const CoreErrorCode: {
193
197
  readonly assetLoadFailed: "IGX-0505";
194
198
  /** Two loaders were registered for the same asset type. */
195
199
  readonly duplicateAssetLoader: "IGX-0506";
200
+ /** A `.mesh.json` file names an unknown primitive, or an option the primitive does not take or cannot use. */
201
+ readonly invalidMeshFile: "IGX-0507";
196
202
  /** A serialized number was `NaN` or infinite. */
197
203
  readonly nonFiniteNumber: "IGX-0601";
198
204
  /** A serialized `$entity`/`$component` reference could not be resolved. */
@@ -265,6 +271,8 @@ export declare const CoreErrorCode: {
265
271
  readonly surfaceSamplerBudgetExceeded: "IGX-0726";
266
272
  /** An `InstancedMeshRenderer` declares a LOD partner with `gpuCulling` off, so the partner never draws. */
267
273
  readonly instancingLodWithoutCulling: "IGX-0727";
274
+ /** `app.renderer.openOverlay()` was called on a headless app, or before `app.start()` registered the render scene. */
275
+ readonly overlayNeedsRenderScene: "IGX-0728";
268
276
  /** The host exposes no Web Crypto implementation. */
269
277
  readonly cryptoUnavailable: "IGX-1420";
270
278
  /** A storage namespace name is not a legal namespace segment. */
@@ -1155,6 +1163,12 @@ interface Assets {
1155
1163
  * development hot reload does (`docs/architecture/05-assets-and-loading.md` §7); a handle that is
1156
1164
  * not loaded is left alone. The Vite plugin's HMR channel and the devtools Assets panel call it.
1157
1165
  *
1166
+ * @remarks
1167
+ * A call made while a reload of the same handle is running reloads once more after it, however
1168
+ * many calls arrive meanwhile, and only the newest value is delivered. A failed reload keeps the
1169
+ * value the handle had and reports an `IGX-0505` {@link AssetLoadError} naming the address through
1170
+ * `app.onError`.
1171
+ *
1158
1172
  * @param address - The asset's address.
1159
1173
  */
1160
1174
  reload(address: string): void;
@@ -1485,7 +1499,10 @@ interface FieldOptions {
1485
1499
  readonly min?: number;
1486
1500
  /** Highest accepted value for numeric kinds; validation reports `IGX-0606` above it. */
1487
1501
  readonly max?: number;
1488
- /** Increment used by the inspector's drag and spinner controls. */
1502
+ /**
1503
+ * Increment used by the inspector's drag and spinner controls. A `quat` field is edited as
1504
+ * intrinsic XYZ Euler angles, so its step is in degrees.
1505
+ */
1489
1506
  readonly step?: number;
1490
1507
  /** Hides the field from the inspector while still serializing it. */
1491
1508
  readonly hidden?: boolean;
@@ -1854,6 +1871,8 @@ interface ScriptClassInfo {
1854
1871
  readonly executionOrder: number;
1855
1872
  /** `static updateWhenPaused`, resolved at registration. */
1856
1873
  readonly updateWhenPaused: boolean;
1874
+ /** `static runInEditMode`, resolved at registration. */
1875
+ readonly runInEditMode: boolean;
1857
1876
  /** One bit per `ScriptCallbackKind`: set when the class implements that callback. */
1858
1877
  readonly callbacks: number;
1859
1878
  }
@@ -1930,17 +1949,35 @@ export declare class ComponentRegistry {
1930
1949
  *
1931
1950
  * @param type - The component class.
1932
1951
  * @param typeId - An explicit id, when the class does not declare one.
1952
+ * @param registrar - Who registers it, for example the extension's `name`; the first registrar of
1953
+ * an id is kept, and {@link ComponentRegistry.registrarOf} reports it.
1933
1954
  * @returns What the registry worked out about the class.
1934
1955
  * @throws IgnifxError with code `IGX-0203` when the id is already registered by another class, or
1935
1956
  * when the id is not `<namespace>/<Name>`.
1936
1957
  */
1937
- register(type: ConcreteComponentType, typeId?: string): ComponentClassInfo;
1958
+ register(type: ConcreteComponentType, typeId?: string, registrar?: string): ComponentClassInfo;
1938
1959
  /**
1939
1960
  * Registers several component classes.
1940
1961
  *
1941
1962
  * @param types - The component classes.
1963
+ * @param registrar - Who registers them, as for {@link ComponentRegistry.register}.
1964
+ */
1965
+ registerAll(types: readonly ConcreteComponentType[], registrar?: string): void;
1966
+ /**
1967
+ * Who registered a type id: the extension `name` an `ExtensionContext` registers under, or
1968
+ * whatever a direct caller of {@link ComponentRegistry.register} passed. A hot-reload
1969
+ * {@link ComponentRegistry.replace} keeps it.
1970
+ *
1971
+ * @param typeId - The namespaced id.
1972
+ * @returns The registrar, or `null` when the id was registered without one (as
1973
+ * `app.registerComponents` does) or is not registered.
1974
+ *
1975
+ * @example
1976
+ * ```ts
1977
+ * app.world.registry.registrarOf("ignifx/Camera"); // "@ignifx/core"
1978
+ * ```
1942
1979
  */
1943
- registerAll(types: readonly ConcreteComponentType[]): void;
1980
+ registrarOf(typeId: string): string | null;
1944
1981
  /**
1945
1982
  * Swaps the class registered under a `typeId` for a replacement, for script hot reload
1946
1983
  * (`docs/architecture/15-devtools-and-diagnostics.md` §5). The previous class's cached info is
@@ -3589,6 +3626,19 @@ export declare const VEC3_FORWARD: Vec3Like;
3589
3626
  export declare const VEC3_BACKWARD: Vec3Like;
3590
3627
  //#endregion
3591
3628
  //#region src/lite/node.d.ts
3629
+ /**
3630
+ * The ignifx identity written into a Lite node's metadata bag so picking results and physics bodies
3631
+ * resolve back to the owning entity (`docs/architecture/00-overview.md` §5,
3632
+ * `docs/architecture/02-scene-graph.md` §10).
3633
+ *
3634
+ * @internal
3635
+ */
3636
+ interface NodeTag {
3637
+ /** The dense runtime handle of the entity that owns the node. */
3638
+ readonly entity: number;
3639
+ /** The component that created the node, when the node is not the entity's own transform. */
3640
+ readonly component?: number;
3641
+ }
3592
3642
  /**
3593
3643
  * The Babylon Lite node an ignifx `Transform` wraps, re-exported under an ignifx name so that
3594
3644
  * feature code can name the type without importing `@babylonjs/lite`
@@ -3960,8 +4010,12 @@ export interface Transform {
3960
4010
  //#endregion
3961
4011
  //#region src/schema/describe.d.ts
3962
4012
  /**
3963
- * One field as the documentation harness sees it (`scripts/README.md`, "Schema discovery
3964
- * convention").
4013
+ * One field as the documentation harness and an external inspector see it (`scripts/README.md`,
4014
+ * "Schema discovery convention"; `docs/architecture/03-scripting-and-components.md` §3).
4015
+ *
4016
+ * Every member past `kind` is present only when the declaration states it: a field with no
4017
+ * `step` has no `step` here. The inspector members mirror {@link FieldOptions}; the others carry
4018
+ * what the field's kind declares: an enum's values, an asset's type, a nested field's own description.
3965
4019
  *
3966
4020
  * @public
3967
4021
  */
@@ -3972,6 +4026,43 @@ interface SchemaFieldDescription {
3972
4026
  readonly default?: JsonValue;
3973
4027
  /** The field's tooltip, when it declares one. */
3974
4028
  readonly description?: string;
4029
+ /** `FieldOptions.min`: the lowest accepted value of a numeric field. */
4030
+ readonly min?: number;
4031
+ /** `FieldOptions.max`: the highest accepted value of a numeric field. */
4032
+ readonly max?: number;
4033
+ /**
4034
+ * `FieldOptions.step`: the increment of the inspector's drag and spinner controls; in degrees for
4035
+ * a `quat` field, which an inspector edits as Euler angles.
4036
+ */
4037
+ readonly step?: number;
4038
+ /** `FieldOptions.hidden`: the inspector leaves the field out; it is still saved. */
4039
+ readonly hidden?: boolean;
4040
+ /** `FieldOptions.readonly`: the inspector shows the field but does not let it be edited. */
4041
+ readonly readonly?: boolean;
4042
+ /** `FieldOptions.group`: the inspector group the field folds into. */
4043
+ readonly group?: string;
4044
+ /** `FieldOptions.transient`: the field is never saved and takes its default on load. */
4045
+ readonly transient?: boolean;
4046
+ /** An `enum` field's accepted values, in declaration order. */
4047
+ readonly values?: readonly string[];
4048
+ /**
4049
+ * An `asset` field's asset type name (`asset(TextureAsset)` → `"texture"`), the `type` an asset
4050
+ * reference to it carries. Absent when the asset token names no type.
4051
+ */
4052
+ readonly assetType?: string;
4053
+ /**
4054
+ * A `componentRef` field's accepted component, as its `typeId`, or `null` when the class it was
4055
+ * declared with carries no `typeId`. Present on every `componentRef` field.
4056
+ */
4057
+ readonly componentType?: string | null;
4058
+ /** An `array` field's element, described the same way. */
4059
+ readonly item?: SchemaFieldDescription;
4060
+ /** A `record` field's sub-fields, in declaration order, described the same way. */
4061
+ readonly fields?: Readonly<Record<string, SchemaFieldDescription>>;
4062
+ /** A `map` field's entry value, described the same way. */
4063
+ readonly value?: SchemaFieldDescription;
4064
+ /** An `optional` field's non-`null` value, described the same way. */
4065
+ readonly inner?: SchemaFieldDescription;
3975
4066
  }
3976
4067
  /**
3977
4068
  * One component schema as the documentation harness sees it. `pnpm docs:schemas` reads a record of
@@ -3989,6 +4080,25 @@ interface SchemaDescription {
3989
4080
  readonly description?: string;
3990
4081
  /** Every declared field, in declaration order. */
3991
4082
  readonly fields: Readonly<Record<string, SchemaFieldDescription>>;
4083
+ /**
4084
+ * Whether an entity may hold more than one of the component (`static allowMultiple`, `true` when
4085
+ * the class declares nothing). Set by {@link describeRegisteredSchemas}, or by the caller through
4086
+ * {@link SchemaDescriptionMeta}; absent on file formats.
4087
+ */
4088
+ readonly allowMultiple?: boolean;
4089
+ /**
4090
+ * Who registered the component: the extension's `name` (the npm package name, for example
4091
+ * `@ignifx/3d`), or, for a class the game registered itself, its type id's namespace (`mygame`).
4092
+ * Set by {@link describeRegisteredSchemas}, or by the caller through {@link SchemaDescriptionMeta}.
4093
+ */
4094
+ readonly package?: string;
4095
+ /**
4096
+ * `true` for the one component every entity carries itself, `ignifx/Transform`: it is never in a
4097
+ * scene file's `components` list, an editor cannot add or remove it, and its fields are the
4098
+ * entity record's `transform` block, edited whole (the editor protocol's `setTransform`), not
4099
+ * prop by prop. Absent on every other component and on file formats.
4100
+ */
4101
+ readonly builtIn?: boolean;
3992
4102
  }
3993
4103
  /**
3994
4104
  * Optional overrides for {@link describeSchema}.
@@ -4002,6 +4112,12 @@ interface SchemaDescriptionMeta {
4002
4112
  readonly format?: string;
4003
4113
  /** A one-line summary of what the component does. */
4004
4114
  readonly description?: string;
4115
+ /** Whether an entity may hold more than one of the component, copied onto the description. */
4116
+ readonly allowMultiple?: boolean;
4117
+ /** The package or extension that registered the component, copied onto the description. */
4118
+ readonly package?: string;
4119
+ /** Whether the component is the entity's own built-in block, copied onto the description. */
4120
+ readonly builtIn?: boolean;
4005
4121
  }
4006
4122
  /**
4007
4123
  * A JSON Schema fragment. Kept as a plain JSON object because the generated document is assembled
@@ -4012,14 +4128,18 @@ interface SchemaDescriptionMeta {
4012
4128
  */
4013
4129
  type JsonSchemaObject = JsonObject;
4014
4130
  /**
4015
- * Describes a component schema in the shape the documentation harness consumes. A package exports
4016
- * a record of these keyed by `typeId`; `pnpm docs:schemas` reads it from the built entry point and
4017
- * regenerates the format pages and `ignifx.schemas.json` from it
4018
- * (`scripts/README.md`, `docs/architecture/16-docs-harness-and-skill.md` §3).
4131
+ * Describes a component schema in the shape the documentation harness and an external inspector
4132
+ * consume. A package exports a record of these keyed by `typeId`; `pnpm docs:schemas` reads it from
4133
+ * the built entry point and regenerates the format pages and `ignifx.schemas.json` from it
4134
+ * (`scripts/README.md`, `docs/architecture/16-docs-harness-and-skill.md` §3). Each field carries
4135
+ * its inspector options and what its kind declares ({@link SchemaFieldDescription}); to describe
4136
+ * an app's registered components with `allowMultiple` and `package` filled in, use
4137
+ * {@link describeRegisteredSchemas}.
4019
4138
  *
4020
4139
  * @param typeId - The component's namespaced registration id, for example `mygame/Mover`.
4021
4140
  * @param schema - The component's declared fields.
4022
- * @param meta - Overrides for the title, format grouping, and summary.
4141
+ * @param meta - Overrides for the title, format grouping, and summary, and the component's
4142
+ * `allowMultiple`, `package` and `builtIn` when the caller knows them.
4023
4143
  * @returns The description entry.
4024
4144
  *
4025
4145
  * @example
@@ -4144,6 +4264,12 @@ interface SceneFileOverride {
4144
4264
  * The `instance` entry that turns an entity into the root of an instanced scene — what other
4145
4265
  * engines call a prefab instance (ADR-0005).
4146
4266
  *
4267
+ * @remarks
4268
+ * When the instanced scene has exactly one root, the entity carrying the entry _is_ that root, as
4269
+ * with `world.instantiate`: it gets the root's components, then its own, and keeps its own uid,
4270
+ * name, and transform. A scene with several roots is expanded under the entity instead
4271
+ * (`docs/architecture/06-serialization-and-scene-format.md` §2).
4272
+ *
4147
4273
  * @public
4148
4274
  */
4149
4275
  interface SceneFileInstance {
@@ -4737,6 +4863,15 @@ export declare class SceneInstance {
4737
4863
  * @internal
4738
4864
  */
4739
4865
  addRoot(entity: Entity): void;
4866
+ /**
4867
+ * Moves a root to another place in the root list.
4868
+ *
4869
+ * @param entity - A root of this instance.
4870
+ * @param index - Its new index, already clamped to the list.
4871
+ *
4872
+ * @internal
4873
+ */
4874
+ moveRoot(entity: Entity, index: number): void;
4740
4875
  /**
4741
4876
  * Removes an entity from the root list.
4742
4877
  *
@@ -4763,12 +4898,13 @@ export declare class SceneInstance {
4763
4898
  * costs a call per frame and not defining it costs nothing.
4764
4899
  *
4765
4900
  * **The statics work the same way.** `typeId`, `schema`, `requires`, `allowMultiple`,
4766
- * `executionOrder`, and `updateWhenPaused` are not members of `Component` or `Script` either: a
4767
- * static declared on the base class is an override too, so `static typeId = "mygame/Mover"` would
4768
- * have needed an `override` modifier. Their shape lives on {@link ComponentStatics} and
4769
- * {@link ScriptStatics}, which the class-token types intersect, so a plain `static` on a subclass
4770
- * satisfies them structurally; `ComponentRegistry` reads each one once per class and applies the
4771
- * defaults (`executionOrder` `0`, `updateWhenPaused` `false`).
4901
+ * `executionOrder`, `updateWhenPaused`, and `runInEditMode` are not members of `Component` or
4902
+ * `Script` either: a static declared on the base class is an override too, so
4903
+ * `static typeId = "mygame/Mover"` would have needed an `override` modifier. Their shape lives on
4904
+ * {@link ComponentStatics} and {@link ScriptStatics}, which the class-token types intersect, so a
4905
+ * plain `static` on a subclass satisfies them structurally; `ComponentRegistry` reads each one once
4906
+ * per class and applies the defaults (`executionOrder` `0`, `updateWhenPaused` `false`,
4907
+ * `runInEditMode` `false`).
4772
4908
  *
4773
4909
  * @example
4774
4910
  * ```ts
@@ -4810,6 +4946,8 @@ export declare abstract class Script extends Component {
4810
4946
  *
4811
4947
  * @param routine - The generator to drive. Call the generator function: `this.spawnLoop()`.
4812
4948
  * @returns A handle for stopping it or waiting on it.
4949
+ * @throws IgnifxError with code `IGX-0111` in an edit-mode app when the class does not set
4950
+ * `static runInEditMode = true` (ADR-0028).
4813
4951
  *
4814
4952
  * @example
4815
4953
  * ```ts
@@ -7699,6 +7837,28 @@ interface ScenePresenter {
7699
7837
  * @internal
7700
7838
  */
7701
7839
  type LitePickInfo = PickingInfo;
7840
+ /**
7841
+ * Decides whether a mesh may be picked, from the ignifx tag that owns it and the mesh itself.
7842
+ *
7843
+ * @remarks
7844
+ * The tag is the one {@link readOwnerTag} finds, so a glTF mesh inside a `Model` is judged by the
7845
+ * model's entity. The mesh is passed only so a caller can compare it by identity against an earlier
7846
+ * hit; nothing outside `src/lite/**` reads it.
7847
+ *
7848
+ * @internal
7849
+ */
7850
+ type PickAccept = (tag: NodeTag | null, mesh: Mesh) => boolean;
7851
+ /**
7852
+ * The identity of one earlier hit, which a pick can be told to look through.
7853
+ *
7854
+ * @internal
7855
+ */
7856
+ interface PickedIdentity {
7857
+ /** The mesh that was hit. */
7858
+ readonly mesh: Mesh;
7859
+ /** The thin instance that was hit, or `-1` when the mesh has none. */
7860
+ readonly thinInstanceIndex: number;
7861
+ }
7702
7862
  //#endregion
7703
7863
  //#region src/lite/shadow.d.ts
7704
7864
  /**
@@ -7786,6 +7946,8 @@ interface MaterialCacheResets {
7786
7946
  readonly seen: WeakSet<() => void>;
7787
7947
  /** `true` when a function nobody had seen was pushed since the last rebuild started. */
7788
7948
  unconfirmed: boolean;
7949
+ /** How many rebuilds started over because a material swap landed in them; for diagnostics. */
7950
+ retries: number;
7789
7951
  }
7790
7952
  //#endregion
7791
7953
  //#region src/platform/webgpu.d.ts
@@ -7850,6 +8012,18 @@ export declare const RENDER_DIAGNOSTICS_GROUP = "render";
7850
8012
  * @public
7851
8013
  */
7852
8014
  export declare const RENDER_DIAGNOSTICS_COUNTERS: readonly string[];
8015
+ /**
8016
+ * A pick's options as Lite consumes them: a mesh predicate over the owning tag, and the earlier hits
8017
+ * to look through.
8018
+ *
8019
+ * @internal
8020
+ */
8021
+ interface PickPlan {
8022
+ /** Decides whether a mesh may be picked; `null` considers every mesh. */
8023
+ readonly accept: PickAccept | null;
8024
+ /** The earlier hits to ignore. */
8025
+ readonly hits: readonly PickedIdentity[];
8026
+ }
7853
8027
  /**
7854
8028
  * A rendering feature a project or an extension asks for
7855
8029
  * (`docs/architecture/07-rendering.md` §1.1).
@@ -7858,7 +8032,11 @@ export declare const RENDER_DIAGNOSTICS_COUNTERS: readonly string[];
7858
8032
  */
7859
8033
  type RenderingFeature = keyof RenderingFeatureSettings;
7860
8034
  /**
7861
- * What a GPU pick found (`docs/architecture/07-rendering.md` §3).
8035
+ * What a GPU pick or a render raycast found (`docs/architecture/07-rendering.md` §3).
8036
+ *
8037
+ * @remarks
8038
+ * A hit on any mesh resolves to the nearest node on its way to the root that an entity owns, so a
8039
+ * click on any part of a glTF `Model` names the model's entity and the `Model` component.
7862
8040
  *
7863
8041
  * @public
7864
8042
  */
@@ -7867,15 +8045,36 @@ interface RenderPick {
7867
8045
  readonly entity: Entity;
7868
8046
  /** The component that created the mesh, when it was not the entity's own transform. */
7869
8047
  readonly component: Component | null;
7870
- /** The world-space hit point, or `null` unless detailed picking is on. */
8048
+ /**
8049
+ * The world-space hit point. A GPU pick reads it from the depth of the winning pixel, a render
8050
+ * raycast from the triangle it hit; `null` only when the camera's matrix cannot be inverted.
8051
+ */
7871
8052
  readonly point: readonly [number, number, number] | null;
7872
- /** The world-space surface normal, or `null` unless detailed picking is on. */
8053
+ /** The world-space surface normal, or `null` from a GPU pick, which does not compute one. */
7873
8054
  readonly normal: readonly [number, number, number] | null;
7874
- /** How far along the ray the hit is, in metres. */
8055
+ /** How far the hit is from the camera (GPU pick) or the ray's origin (raycast), in metres. */
7875
8056
  readonly distance: number;
8057
+ /**
8058
+ * The name of the mesh the ray hit: for a `Model`, the name the glTF file gives that node or
8059
+ * primitive; for a `MeshRenderer`, its mesh's. `""` when the mesh has none.
8060
+ */
8061
+ readonly meshName: string;
8062
+ /**
8063
+ * Which instance of an `InstancedMeshRenderer` was hit, or `null` when the mesh is not instanced.
8064
+ * Lite's sub-mesh index is not reported: a glTF primitive is a mesh of its own in Lite, so
8065
+ * {@link RenderPick.meshName} already tells the parts of a model apart.
8066
+ */
8067
+ readonly thinInstanceIndex: number | null;
7876
8068
  }
7877
8069
  /**
7878
- * How a GPU pick is restricted (`docs/architecture/07-rendering.md` §3).
8070
+ * Something a pick looks through: an entity (every mesh it owns), a component (every mesh it
8071
+ * created), or an earlier hit (that mesh, or that one instance of an instanced mesh).
8072
+ *
8073
+ * @public
8074
+ */
8075
+ type RenderPickIgnore = Entity | Component | RenderPick;
8076
+ /**
8077
+ * How a GPU pick or a render raycast is restricted (`docs/architecture/07-rendering.md` §3).
7879
8078
  *
7880
8079
  * @public
7881
8080
  */
@@ -7888,6 +8087,22 @@ interface RenderPickOptions {
7888
8087
  * @returns `true` to consider the entity.
7889
8088
  */
7890
8089
  readonly filter?: (entity: Entity) => boolean;
8090
+ /**
8091
+ * What to look through: each entity, component or earlier hit listed neither occludes nor
8092
+ * returns. Passing the previous hit each time walks through the objects under one pixel from
8093
+ * front to back — an editor's click-to-cycle.
8094
+ *
8095
+ * @remarks
8096
+ * Only a GPU pick can skip one instance of an instanced mesh; `world.raycastRender` skips the
8097
+ * whole mesh. A hit from another app is not recognised and is skipped.
8098
+ *
8099
+ * **Limit (Babylon Lite 1.34).** Lite keeps one ignore entry per mesh. Several hits on instances
8100
+ * of one `InstancedMeshRenderer` are merged into a range when their indices are contiguous;
8101
+ * otherwise only the lowest index is skipped, and the pick can return a hit already in the list.
8102
+ * A loop that walks through a pixel must stop when a hit repeats (the same `entity`, `meshName`
8103
+ * and `thinInstanceIndex`), or it never gets past such a renderer.
8104
+ */
8105
+ readonly ignore?: readonly RenderPickIgnore[];
7891
8106
  }
7892
8107
  /**
7893
8108
  * A captured frame (`docs/architecture/07-rendering.md` §5).
@@ -7934,6 +8149,40 @@ interface RenderTaskTimings {
7934
8149
  /** The tasks, in frame execution order. Empty unless `status` is `"ok"`. */
7935
8150
  readonly tasks: readonly RenderTaskTiming[];
7936
8151
  }
8152
+ /**
8153
+ * The Babylon Lite scenes behind a {@link RenderOverlay}: the escape hatch an editor hands to Lite's
8154
+ * gizmo constructors, which take this shape as a `UtilityLayer` (`CONSTITUTION.md` §3.4).
8155
+ *
8156
+ * @remarks
8157
+ * Unstable: these are Lite's own objects, excluded from the stability guarantees of
8158
+ * `CONSTITUTION.md` Article IV.
8159
+ *
8160
+ * @beta
8161
+ */
8162
+ interface RenderOverlayLiteHandles {
8163
+ /** The overlay's own scene. What is added to it draws over the frame. */
8164
+ readonly scene: LiteScene;
8165
+ /** The render scene. The overlay scene uses its camera. */
8166
+ readonly mainScene: LiteScene;
8167
+ }
8168
+ /**
8169
+ * A Babylon Lite scene drawn over the finished frame, for an editor's gizmos, selection outlines,
8170
+ * and grids (`docs/architecture/07-rendering.md` §2.10, ADR-0031).
8171
+ *
8172
+ * @remarks
8173
+ * The overlay draws after everything else on the canvas, the render scene, its post-processing,
8174
+ * sprites and text included, at every `rendering.msaaSamples` setting. It has a depth buffer of its
8175
+ * own, cleared every frame, so what it holds is never hidden by the scene; within the overlay,
8176
+ * depth testing works as usual. It is drawn without MSAA. Screenshots include it.
8177
+ *
8178
+ * @beta
8179
+ */
8180
+ interface RenderOverlay {
8181
+ /** The overlay's Lite scenes (unstable, `CONSTITUTION.md` §3.4). */
8182
+ readonly lite: RenderOverlayLiteHandles;
8183
+ /** Stops drawing the overlay and releases its scene and everything in it. Calling it again does nothing. */
8184
+ dispose(): void;
8185
+ }
7937
8186
  /**
7938
8187
  * The rendering service, reached as `app.renderer`
7939
8188
  * (`docs/architecture/07-rendering.md` §1, §3, §5).
@@ -7941,7 +8190,9 @@ interface RenderTaskTimings {
7941
8190
  * @example
7942
8191
  * ```ts
7943
8192
  * app.renderer.resolutionScale = 0.75;
7944
- * const hit = await app.renderer.pickAsync(event.offsetX, event.offsetY);
8193
+ * // A DOM event is in CSS pixels; the renderer speaks the canvas's backing-store pixels.
8194
+ * const scale = canvas.width / canvas.clientWidth;
8195
+ * const hit = await app.renderer.pickAsync(event.offsetX * scale, event.offsetY * scale);
7945
8196
  * hit?.entity.name;
7946
8197
  * ```
7947
8198
  *
@@ -8004,14 +8255,20 @@ interface Renderer {
8004
8255
  *
8005
8256
  * @remarks
8006
8257
  * Coordinates are **backing-store pixels** — the canvas's `width`/`height`, the space
8007
- * `Camera.worldToScreen` answers in — not CSS pixels; multiply a DOM event's `offsetX`/`offsetY`
8008
- * by `devicePixelRatio` first. Picks are serialised per app: Lite's picker owns one set of staging
8009
- * buffers and chains each call onto the previous one's promise. A headless app has no picker and
8010
- * always misses.
8258
+ * `Camera.worldToScreen` answers in and `<Pointer>/position` reports — not CSS pixels. Multiply a
8259
+ * DOM event's `offsetX`/`offsetY` by `canvas.width / canvas.clientWidth` first. The renderer
8260
+ * converts to the CSS pixels Lite's picker takes, so the same call hits at every device pixel
8261
+ * ratio and resolution scale. The point is sampled exactly: whole numbers are pixel corners, so
8262
+ * add 0.5 for a pixel's centre.
8263
+ *
8264
+ * A hit on any mesh of a glTF `Model`, or of any renderable built from several Lite nodes,
8265
+ * resolves through the nearest node an entity owns. Picks are serialised per app: Lite's picker
8266
+ * owns one set of staging buffers and chains each call onto the previous one's promise. A
8267
+ * headless app has no picker and always misses.
8011
8268
  *
8012
8269
  * @param x - The backing-store pixel x, from the canvas's left edge.
8013
8270
  * @param y - The backing-store pixel y, from the canvas's top edge.
8014
- * @param options - An entity filter.
8271
+ * @param options - An entity filter, and what to look through.
8015
8272
  * @returns What was hit, or `null` for a miss.
8016
8273
  */
8017
8274
  pickAsync(x: number, y: number, options?: RenderPickOptions): Promise<RenderPick | null>;
@@ -8038,6 +8295,31 @@ interface Renderer {
8038
8295
  * which point Lite has compiled what it is going to compile.
8039
8296
  */
8040
8297
  requireFeature(feature: RenderingFeature): void;
8298
+ /**
8299
+ * Opens an overlay: a Babylon Lite scene drawn over the finished frame, for an editor's gizmos
8300
+ * and selection outlines (`docs/architecture/07-rendering.md` §2.10).
8301
+ *
8302
+ * @remarks
8303
+ * Add Lite meshes, or Lite's gizmos, to `overlay.lite.scene`. The overlay follows the render
8304
+ * scene's camera, draws over every other rendering context, and works at every MSAA setting and
8305
+ * on both render paths. Dispose it when it is no longer needed; `app.dispose()` disposes any that
8306
+ * are still open.
8307
+ *
8308
+ * @returns The overlay, drawing from the next frame.
8309
+ * @throws IgnifxError with code `IGX-0728` on a headless app or before `app.start()` has
8310
+ * registered the render scene, and `IGX-0106` when the app is disposed, also while the overlay
8311
+ * was opening.
8312
+ *
8313
+ * @example
8314
+ * ```ts
8315
+ * const overlay = await app.renderer.openOverlay();
8316
+ * // Lite code under src/lite/ adds gizmos to overlay.lite.scene.
8317
+ * overlay.dispose();
8318
+ * ```
8319
+ *
8320
+ * @beta
8321
+ */
8322
+ openOverlay(): Promise<RenderOverlay>;
8041
8323
  /**
8042
8324
  * Registers a probe that answers whether a rendering context **other than the render scene** is
8043
8325
  * drawing a world through a camera of its own.
@@ -8073,6 +8355,11 @@ declare class RendererImpl implements Renderer {
8073
8355
  needsCasterRebuild: boolean;
8074
8356
  /** `true` once a light gained or lost a shadow generator, so the next rebuild needs fresh layouts. */
8075
8357
  needsShadowLayoutReset: boolean;
8358
+ /**
8359
+ * `true` from the moment the render sync system queues a renderable rebuild until the last one it
8360
+ * owes has finished. A light waits for it to be `false` before it gains or loses a shadow generator.
8361
+ */
8362
+ isRebuildInFlight: boolean;
8076
8363
  /**
8077
8364
  * The PBR deformation kinds (`PBR_DEFORMER` bits) a full renderable build has already composed on
8078
8365
  * this engine. A kind missing from it gets fresh layouts on its first rebuild (`../lite/pbr-deformers.ts`).
@@ -8236,7 +8523,7 @@ declare class RendererImpl implements Renderer {
8236
8523
  *
8237
8524
  * @param x - The backing-store pixel x, from the canvas's left edge.
8238
8525
  * @param y - The backing-store pixel y, from the canvas's top edge.
8239
- * @param options - An entity filter.
8526
+ * @param options - An entity filter, and what to look through.
8240
8527
  * @returns What was hit, or `null` for a miss.
8241
8528
  */
8242
8529
  pickAsync(x: number, y: number, options?: RenderPickOptions): Promise<RenderPick | null>;
@@ -8260,6 +8547,14 @@ declare class RendererImpl implements Renderer {
8260
8547
  * @throws IgnifxError with code `IGX-0704` after the render scene has been registered.
8261
8548
  */
8262
8549
  requireFeature(feature: RenderingFeature): void;
8550
+ /**
8551
+ * Opens an overlay drawn over the finished frame.
8552
+ *
8553
+ * @returns The overlay.
8554
+ * @throws IgnifxError with code `IGX-0728` on a headless app or before the render scene is
8555
+ * registered, and `IGX-0106` when the app is disposed, also while the overlay was opening.
8556
+ */
8557
+ openOverlay(): Promise<RenderOverlay>;
8263
8558
  /**
8264
8559
  * Registers a probe that answers whether another rendering context has a camera of its own.
8265
8560
  *
@@ -8312,11 +8607,20 @@ declare class RendererImpl implements Renderer {
8312
8607
  width: number;
8313
8608
  height: number;
8314
8609
  }): void;
8610
+ /**
8611
+ * Turns a pick's options into the mesh predicate and the earlier hits Lite looks through.
8612
+ *
8613
+ * @param options - The caller's options.
8614
+ * @returns The predicate — `null` when every mesh may be picked — and the hits to ignore.
8615
+ *
8616
+ * @internal
8617
+ */
8618
+ planPick(options: RenderPickOptions | undefined): PickPlan;
8315
8619
  /**
8316
8620
  * Resolves a Lite pick result back to the entity and component that own the mesh.
8317
8621
  *
8318
8622
  * @param info - Lite's picking info, from the GPU picker or a CPU ray cast.
8319
- * @returns What was hit, or `null` for a miss or a mesh ignifx did not create.
8623
+ * @returns What was hit, or `null` for a miss or a mesh no entity owns.
8320
8624
  *
8321
8625
  * @internal
8322
8626
  */
@@ -8455,7 +8759,31 @@ declare class RendererImpl implements Renderer {
8455
8759
  */
8456
8760
  publishCounters(cameras: number, lights: number, meshes: number): void;
8457
8761
  /**
8458
- * Releases the picker and the warm-up probes. The core extension registers it as a disposer.
8762
+ * Runs a scene change now, or holds it until the render sync system's rebuild has finished when
8763
+ * one is in flight.
8764
+ *
8765
+ * @remarks
8766
+ * For a change a rebuild must not see half-way: one that changes how many shadow generators the
8767
+ * scene has. A rebuild reads them group by group against layouts cached without that number, so
8768
+ * a group built after the change gets a bind group the layout does not match.
8769
+ *
8770
+ * @param change - The change.
8771
+ *
8772
+ * @internal
8773
+ */
8774
+ afterRebuild(change: () => void): void;
8775
+ /**
8776
+ * Takes the changes {@link RendererImpl.afterRebuild} held back. The render sync system runs them
8777
+ * once its rebuild has finished. A disposed renderer hands back none: its scene is gone.
8778
+ *
8779
+ * @returns The changes, oldest first.
8780
+ *
8781
+ * @internal
8782
+ */
8783
+ takeHeldChanges(): (() => void)[];
8784
+ /**
8785
+ * Releases the open overlays, the picker and the warm-up probes. The core extension registers it
8786
+ * as a disposer.
8459
8787
  *
8460
8788
  * @internal
8461
8789
  */
@@ -9016,7 +9344,9 @@ interface RayVector {
9016
9344
  * @example
9017
9345
  * ```ts
9018
9346
  * const ray = createRay();
9019
- * camera.screenToRay(event.offsetX, event.offsetY, ray);
9347
+ * // A DOM event is in CSS pixels; the camera speaks the canvas's backing-store pixels.
9348
+ * const scale = canvas.width / canvas.clientWidth;
9349
+ * camera.screenToRay(event.offsetX * scale, event.offsetY * scale, ray);
9020
9350
  * ```
9021
9351
  *
9022
9352
  * @public
@@ -9087,7 +9417,9 @@ export declare class Camera extends Component implements ComponentHooks {
9087
9417
  * @remarks
9088
9418
  * Coordinates are backing-store pixels — the canvas's `width`/`height`, the space
9089
9419
  * {@link Camera.worldToScreen} answers in and `@ignifx/input` reports `<Pointer>/position` in — not
9090
- * CSS pixels; multiply a DOM event's `offsetX`/`offsetY` by `devicePixelRatio` first.
9420
+ * CSS pixels; multiply a DOM event's `offsetX`/`offsetY` by `canvas.width / canvas.clientWidth`
9421
+ * first (`devicePixelRatio` is that ratio only while `renderer.pixelRatio` and
9422
+ * `renderer.resolutionScale` leave it alone).
9091
9423
  *
9092
9424
  * @param x - The backing-store pixel x, from the canvas's left edge.
9093
9425
  * @param y - The backing-store pixel y, from the canvas's top edge.
@@ -9159,6 +9491,163 @@ export declare class Camera extends Component implements ComponentHooks {
9159
9491
  sync(renderer: RendererImpl): void;
9160
9492
  }
9161
9493
  //#endregion
9494
+ //#region src/serialization/load.d.ts
9495
+ /**
9496
+ * One recoverable problem found while a scene was being built. Nothing here stops the load: a file
9497
+ * degrades one field, one reference, or one layer rather than failing whole
9498
+ * (`docs/architecture/06-serialization-and-scene-format.md` §4).
9499
+ *
9500
+ * @public
9501
+ */
9502
+ interface SceneLoadIssue {
9503
+ /** The diagnostic code, for example `IGX-0602` or `IGX-0303`. */
9504
+ readonly code: string;
9505
+ /** The actionable sentence. */
9506
+ readonly message: string;
9507
+ }
9508
+ /**
9509
+ * Options accepted by {@link instantiateScene}.
9510
+ *
9511
+ * @public
9512
+ */
9513
+ interface InstantiateSceneOptions {
9514
+ /** The entity the scene's roots attach to; `null` or omitted makes them roots of `scene`. */
9515
+ readonly parent?: Entity | null;
9516
+ /** The instance that owns the new entities; defaults to the parent's, else `world.activeScene`. */
9517
+ readonly scene?: SceneInstance;
9518
+ /**
9519
+ * `true` treats the whole file as one instance: every entity gets a fresh uid and an
9520
+ * `Entity.prefab` link. This is what `world.instantiate` does; `world.loadScene` leaves it off so
9521
+ * that the scene's own entities keep the uids the file gave them
9522
+ * (`docs/architecture/02-scene-graph.md` §10).
9523
+ */
9524
+ readonly asInstance?: boolean;
9525
+ /** The handle the scene was loaded through, recorded on `Entity.prefab` when `asInstance`. */
9526
+ readonly assetHandle?: AssetHandle<SceneAsset> | null;
9527
+ /**
9528
+ * The entity that stands for the instance when `asInstance` is set and the file has more or fewer
9529
+ * than one root. `world.instantiate` creates it and passes it as both `parent` and `rootEntity`,
9530
+ * so that the call still answers with one entity.
9531
+ */
9532
+ readonly rootEntity?: Entity | null;
9533
+ /** `true` turns an `IGX-0604` hash mismatch from a diagnostic into a throw. */
9534
+ readonly strictInstanceHashes?: boolean;
9535
+ }
9536
+ /**
9537
+ * What {@link instantiateScene} produced.
9538
+ *
9539
+ * @public
9540
+ */
9541
+ interface SceneBuildResult {
9542
+ /** The entities that ended up parentless within the built subtree, in file order. */
9543
+ readonly roots: readonly Entity[];
9544
+ /** The file-local uid to runtime object table (`docs/architecture/02-scene-graph.md` §10). */
9545
+ readonly remap: UidRemap;
9546
+ /** Every recoverable problem, in discovery order. */
9547
+ readonly issues: readonly SceneLoadIssue[];
9548
+ }
9549
+ /**
9550
+ * Builds the entities of a scene asset into a world — steps 3 to 6 of the loading algorithm
9551
+ * (`docs/architecture/06-serialization-and-scene-format.md` §4). It is synchronous and does no I/O:
9552
+ * every asset the file references is already loaded, which is what a `SceneAsset` guarantees.
9553
+ *
9554
+ * @remarks
9555
+ * The mechanism that keeps `awake` honest is worth stating, because §4 step 6 and
9556
+ * `01-lifecycle-and-time.md` §4 state only the outcome. Entities are created with `active: false`,
9557
+ * so the enable transition computes "not effectively enabled" and queues nothing. Components are
9558
+ * attached with their schema defaults, then every component's props are decoded — that is where
9559
+ * `entityRef` and `componentRef` resolve, through a table that by then holds the whole scene. Only
9560
+ * then does a last pass write each entity's file `active` value in tree order, which is what queues
9561
+ * `awake` and `onEnable`, parents before children. Nothing observes the half-built scene, because
9562
+ * all of this runs in one synchronous block.
9563
+ *
9564
+ * @param world - The world to build into.
9565
+ * @param asset - The scene to build.
9566
+ * @param options - Where to attach the result, and how to treat instance hashes.
9567
+ * @returns The roots, the uid table, and every recoverable problem.
9568
+ * @throws IgnifxError with code `IGX-0302` on an instance cycle, `IGX-0307` when the file names an
9569
+ * unregistered component type, and `IGX-0604` when `strictInstanceHashes` is set and a recorded
9570
+ * instance hash does not match.
9571
+ *
9572
+ * @example
9573
+ * ```ts
9574
+ * const built = instantiateScene(world, sceneAsset, { scene: world.activeScene });
9575
+ * const player = built.remap.entity("01J9Z6M7E5S3A0V2Q4R8T1Y6WX");
9576
+ * ```
9577
+ *
9578
+ * @public
9579
+ */
9580
+ export declare function instantiateScene(world: World, asset: SceneAsset, options?: InstantiateSceneOptions): SceneBuildResult;
9581
+ /**
9582
+ * Options accepted by {@link addComponentFromRecord}.
9583
+ *
9584
+ * @public
9585
+ */
9586
+ interface AddComponentFromRecordOptions {
9587
+ /**
9588
+ * The component's index among the entity's components as a scene file lists them (the transform
9589
+ * and the components an instanced scene put on the entity do not count). Defaults to the end; a
9590
+ * value past the end is clamped to it.
9591
+ */
9592
+ readonly index?: number;
9593
+ /**
9594
+ * How `$entity`, `$component` and `$asset` values in the record's `props` resolve. Without one
9595
+ * every reference decodes as `null` and is reported (`IGX-0602`). An asset must already be loaded:
9596
+ * decoding never starts a load.
9597
+ */
9598
+ readonly references?: ReferenceDecoder;
9599
+ }
9600
+ /**
9601
+ * What {@link addComponentFromRecord} built.
9602
+ *
9603
+ * @public
9604
+ */
9605
+ interface ComponentBuildResult {
9606
+ /** The attached component, carrying the record's uid. */
9607
+ readonly component: Component;
9608
+ /** Every recoverable problem found while decoding `props`, in discovery order. */
9609
+ readonly issues: readonly SceneLoadIssue[];
9610
+ }
9611
+ /**
9612
+ * Attaches one component to a live entity from its scene file record, the way the scene loader
9613
+ * builds it: the record's registered type, its uid, its `enabled` flag, and its `props` decoded
9614
+ * against the schema (`docs/architecture/06-serialization-and-scene-format.md` §4).
9615
+ *
9616
+ * @remarks
9617
+ * This is the per-component step of {@link instantiateScene} for a world that already exists, which
9618
+ * is what an editor mirroring a document into a live world needs. The component is attached with
9619
+ * `entity.addComponent`, so `awake` follows that method's rules. The record's uid is adopted as is;
9620
+ * keeping it unique within the scene is the caller's job. Decoding never throws: a value that does
9621
+ * not match its field takes the field's default and is reported in `issues`.
9622
+ *
9623
+ * @param entity - The entity to attach to.
9624
+ * @param record - The component record, as a scene file writes it.
9625
+ * @param options - Where it goes among the entity's components, and how references resolve.
9626
+ * @returns The component and the decoding problems.
9627
+ * @throws IgnifxError with code `IGX-0307` when the record's type is not registered, and whatever
9628
+ * `entity.addComponent` throws (`IGX-0202` for a second instance of a single-instance class,
9629
+ * `IGX-0101` for a destroyed entity).
9630
+ *
9631
+ * @example
9632
+ * ```ts
9633
+ * const { component } = addComponentFromRecord(player, { uid: "01J9Z6M7E5S3A0V2Q4R8T1Y6WY", type: "game/Health", props: { max: 120 } });
9634
+ * ```
9635
+ *
9636
+ * @public
9637
+ */
9638
+ export declare function addComponentFromRecord(entity: Entity, record: SceneFileComponent, options?: AddComponentFromRecordOptions): ComponentBuildResult;
9639
+ /**
9640
+ * Checks that every scene a file instances — at any depth — is among the loaded dependencies, which
9641
+ * is what makes `world.instantiate` safe to be synchronous
9642
+ * (`docs/architecture/02-scene-graph.md` §2).
9643
+ *
9644
+ * @param asset - The scene to check.
9645
+ * @throws IgnifxError with code `IGX-0301` naming the first instanced scene that is not loaded.
9646
+ *
9647
+ * @public
9648
+ */
9649
+ export declare function assertSceneDependenciesLoaded(asset: SceneAsset): void;
9650
+ //#endregion
9162
9651
  //#region src/world/world.d.ts
9163
9652
  /**
9164
9653
  * The running simulation: the entity registry, the scene instances, and the lifecycle queues
@@ -9382,7 +9871,7 @@ export declare class World implements WorldHost {
9382
9871
  * answer.
9383
9872
  *
9384
9873
  * @param ray - The ray to cast.
9385
- * @param options - An entity filter.
9874
+ * @param options - An entity filter, and what to look through.
9386
9875
  * @returns What was hit, or `null` for a miss.
9387
9876
  *
9388
9877
  * @example
@@ -9462,6 +9951,60 @@ export declare class World implements WorldHost {
9462
9951
  * ```
9463
9952
  */
9464
9953
  loadScene(scene: AssetRef<SceneAsset> | string, options?: LoadSceneOptions): Promise<SceneInstance>;
9954
+ /**
9955
+ * Builds a scene from a file that is already in memory, the way {@link World.loadScene} builds one
9956
+ * from an address (`docs/architecture/02-scene-graph.md` §2).
9957
+ *
9958
+ * @remarks
9959
+ * Nothing is fetched for the file itself: it is validated, every asset it references is loaded
9960
+ * through `app.assets` (the scene loader's own walk), and it is published there at
9961
+ * `options.address` as a scene asset, so the instance's `asset` and everything that reads it
9962
+ * behave as for a loaded file. Entity and component uids are the file's. The instance holds the
9963
+ * asset and its dependencies and releases them when it is unloaded. The rest is
9964
+ * {@link World.loadScene}'s: the same modes, the same synchronous build, `awake` before the
9965
+ * promise settles, and `onSceneLoaded`.
9966
+ *
9967
+ * This is how a tool builds a scene it holds as an object, such as an editor's open document with
9968
+ * unsaved edits.
9969
+ *
9970
+ * @param file - The scene file object, as `serializeScene` or `JSON.parse` produces it.
9971
+ * @param options - The address to publish it at, the mode, cancellation, and an issue collector.
9972
+ * @returns The instance, once every entity exists, every reference is resolved, and `awake` has
9973
+ * run.
9974
+ * @throws IgnifxError with code `IGX-0308` when the object is not a scene file, `IGX-0603` for a
9975
+ * format version this build cannot read, and `IGX-0608` when it does not match the scene format;
9976
+ * nothing is unloaded then. `IGX-0502` when `options.signal` aborts, `IGX-0307` when the file
9977
+ * names an unregistered component type (the half-built instance is unloaded first), and
9978
+ * whatever the asset system throws for a dependency.
9979
+ *
9980
+ * @example
9981
+ * ```ts
9982
+ * const level = await world.loadSceneFile(file, { address: "levels/level01.scene.json" });
9983
+ * ```
9984
+ */
9985
+ loadSceneFile(file: SceneFile, options: LoadSceneFileOptions): Promise<SceneInstance>;
9986
+ /**
9987
+ * Creates an empty scene instance that is built in code rather than loaded from a file
9988
+ * (`docs/architecture/02-scene-graph.md` §3).
9989
+ *
9990
+ * @remarks
9991
+ * Entities join it through `createEntity(name, { scene })` or `moveEntityToScene`. A persistent
9992
+ * instance survives every `"single"` load, so it is where a tool keeps objects that must outlive
9993
+ * the levels it loads: an editor's cameras, grid and gizmo roots. Like any instance other than the
9994
+ * implicit `"default"` one, it can be unloaded with `unloadScene`. Creating it raises no
9995
+ * `onSceneLoaded`, because nothing was loaded; `serializeScene` writes it only when it is passed.
9996
+ *
9997
+ * @param name - The instance's name.
9998
+ * @param options - Whether it is persistent.
9999
+ * @returns The new, empty instance, appended to `scenes`.
10000
+ *
10001
+ * @example
10002
+ * ```ts
10003
+ * const tools = world.createScene("editor", { persistent: true });
10004
+ * const camera = world.createEntity("Editor Camera", { scene: tools });
10005
+ * ```
10006
+ */
10007
+ createScene(name: string, options?: CreateSceneOptions): SceneInstance;
9465
10008
  /**
9466
10009
  * Unloads a scene instance: `onUnloading` fires while its entities are still valid, its roots are
9467
10010
  * destroyed through the normal destroy path (children before parents, `onDisable` then
@@ -9715,6 +10258,46 @@ interface LoadSceneOptions {
9715
10258
  /** `true` turns an `IGX-0604` instance hash mismatch from a logged warning into a throw. */
9716
10259
  readonly strictInstanceHashes?: boolean;
9717
10260
  }
10261
+ /**
10262
+ * Options accepted by {@link World.loadSceneFile}.
10263
+ *
10264
+ * @public
10265
+ */
10266
+ interface LoadSceneFileOptions {
10267
+ /**
10268
+ * The address the scene is published at in `app.assets`, for example
10269
+ * `"levels/level01.scene.json"`, or a `memory:` address for a file that was never saved. It
10270
+ * replaces whatever the cache held there. The file is never fetched from it.
10271
+ */
10272
+ readonly address: string;
10273
+ /** The instance's name; defaults to the file's `name`. */
10274
+ readonly name?: string;
10275
+ /**
10276
+ * `"single"` (the default) unloads every instance that is not `persistent` first; `"additive"`
10277
+ * keeps them.
10278
+ */
10279
+ readonly mode?: "single" | "additive";
10280
+ /** Cancels the dependency loads; an abort rejects with `IGX-0502`. */
10281
+ readonly signal?: AbortSignal;
10282
+ /** Makes the instance `world.activeScene`. Defaults to `true` for `"single"`, `false` for `"additive"`. */
10283
+ readonly setActive?: boolean;
10284
+ /** `true` turns an `IGX-0604` instance hash mismatch from a logged warning into a throw. */
10285
+ readonly strictInstanceHashes?: boolean;
10286
+ /**
10287
+ * Receives every recoverable problem the build found (`SceneBuildResult.issues`), in order. They
10288
+ * are also written to the app log as warnings, as for `loadScene`.
10289
+ */
10290
+ readonly onIssue?: (issue: SceneLoadIssue) => void;
10291
+ }
10292
+ /**
10293
+ * Options accepted by {@link World.createScene}.
10294
+ *
10295
+ * @public
10296
+ */
10297
+ interface CreateSceneOptions {
10298
+ /** Whether the instance survives a `"single"` scene load. Defaults to `false`. */
10299
+ readonly persistent?: boolean;
10300
+ }
9718
10301
  /**
9719
10302
  * Options accepted by {@link World.instantiate} and {@link World.instantiateAsync}
9720
10303
  * (`docs/architecture/02-scene-graph.md` §2).
@@ -9908,6 +10491,27 @@ interface EntityInstanceLink {
9908
10491
  readonly asset: AssetHandle<SceneAsset> | null;
9909
10492
  /** The scene value, so the serializer can diff current state against it. */
9910
10493
  readonly scene: SceneAsset;
10494
+ /**
10495
+ * Set when the instance root *is* the instanced scene's single root, rather than a container
10496
+ * holding the scene's roots (`06-serialization-and-scene-format.md` §2).
10497
+ */
10498
+ readonly root: InstancedRoot | null;
10499
+ }
10500
+ /**
10501
+ * What an instance root that stands for its scene's single root took from that root.
10502
+ *
10503
+ * @internal
10504
+ */
10505
+ interface InstancedRoot {
10506
+ /** The uid of the root's record in the instanced file, which overrides address. */
10507
+ readonly sourceUid: string;
10508
+ /** Expanded component uid to the uid the instanced root's record gives that component. */
10509
+ readonly componentSourceUids: ReadonlyMap<string, string>;
10510
+ /**
10511
+ * Every component the instancing put on the entity, including those a variant's own instance
10512
+ * merged in; the serializer writes the others as the entry's own `components`.
10513
+ */
10514
+ readonly components: ReadonlySet<string>;
9911
10515
  }
9912
10516
  /**
9913
10517
  * The engine-owned state of one entity.
@@ -10107,6 +10711,11 @@ export declare class Entity {
10107
10711
  * The immovability hint: `true` promises that the transform will not change after `awake`, which
10108
10712
  * lets the 2D batcher, physics, and navmesh treat the entity as static.
10109
10713
  *
10714
+ * @remarks
10715
+ * It can be changed only in files or before `awake`; afterwards the setter throws `IGX-0101`. In an
10716
+ * edit-mode app it stays writable, because an editor's inspector edits it on loaded entities
10717
+ * (ADR-0028).
10718
+ *
10110
10719
  * @returns `true` when the entity is marked static.
10111
10720
  */
10112
10721
  get isStatic(): boolean;
@@ -10206,6 +10815,21 @@ export declare class Entity {
10206
10815
  * ```
10207
10816
  */
10208
10817
  setParent(parent: Entity | null, options?: SetParentOptions): void;
10818
+ /**
10819
+ * Moves the entity among its siblings: its parent's children, or its scene's roots when it has no
10820
+ * parent. Sibling order is the order a scene file lists entities in and the order `children`
10821
+ * reports.
10822
+ *
10823
+ * @param index - The entity's new index among its siblings. A value past either end is clamped
10824
+ * to that end, and a fraction is truncated.
10825
+ * @throws IgnifxError with code `IGX-0101` when the entity has been destroyed.
10826
+ *
10827
+ * @example
10828
+ * ```ts
10829
+ * weapon.setSiblingIndex(0); // first child of its parent
10830
+ * ```
10831
+ */
10832
+ setSiblingIndex(index: number): void;
10209
10833
  /**
10210
10834
  * Resolves a path relative to this entity — `"Body/Arm.L"`, `"../Sibling"`, `"/Root/Child"`.
10211
10835
  *
@@ -10697,8 +11321,8 @@ interface ComponentStatics {
10697
11321
  }
10698
11322
  /**
10699
11323
  * The static members a script class may declare: everything {@link ComponentStatics} allows plus
10700
- * the two scheduling flags (`docs/architecture/01-lifecycle-and-time.md` §3). Structural and
10701
- * optional for the reason given on {@link ComponentStatics}.
11324
+ * the scheduling flags (`docs/architecture/01-lifecycle-and-time.md` §3). Structural and optional
11325
+ * for the reason given on {@link ComponentStatics}.
10702
11326
  *
10703
11327
  * @public
10704
11328
  */
@@ -10713,6 +11337,22 @@ interface ScriptStatics extends ComponentStatics {
10713
11337
  * Defaults to `false`.
10714
11338
  */
10715
11339
  readonly updateWhenPaused?: boolean;
11340
+ /**
11341
+ * When `true`, the script receives its callbacks in an edit-mode app
11342
+ * (`createApp({ editMode: true })`, ADR-0028), as an editor camera or a tool script needs.
11343
+ * Defaults to `false`: in edit mode a script gets no `awake`, `update`, or any other callback.
11344
+ *
11345
+ * @example
11346
+ * ```ts
11347
+ * class EditorCamera extends Script {
11348
+ * static runInEditMode = true;
11349
+ * update(dt: number): void {
11350
+ * this.transform.translate({ x: 0, y: 0, z: dt });
11351
+ * }
11352
+ * }
11353
+ * ```
11354
+ */
11355
+ readonly runInEditMode?: boolean;
10716
11356
  }
10717
11357
  /**
10718
11358
  * A component class used as a **query token** — `entity.getComponent(Type)`,
@@ -12418,6 +13058,12 @@ interface SystemContext {
12418
13058
  * `updateWhenPaused` — so a system that animates checks `time.paused` itself.
12419
13059
  */
12420
13060
  readonly dt: number;
13061
+ /**
13062
+ * `true` when the scheduler is holding this system's clock: in an edit-mode app, for a system
13063
+ * registered with `editMode: "hold"` (ADR-0028). `dt` is `0` then, and a system that reads
13064
+ * `time` directly treats the frame as paused.
13065
+ */
13066
+ readonly isClockHeld: boolean;
12421
13067
  }
12422
13068
  /**
12423
13069
  * Engine-level logic that runs once per phase over many components, registered by an extension
@@ -12681,6 +13327,8 @@ interface CoroutineHost {
12681
13327
  * @param owner - The script whose enabled state gates the coroutine.
12682
13328
  * @param routine - The generator to drive.
12683
13329
  * @returns A handle for stopping it or waiting on it.
13330
+ * @throws IgnifxError with code `IGX-0111` in an edit-mode app when the owner's class does not
13331
+ * set `static runInEditMode = true`.
12684
13332
  */
12685
13333
  start(owner: Script, routine: Coroutine): CoroutineHandle;
12686
13334
  /**
@@ -12811,6 +13459,12 @@ interface App {
12811
13459
  readonly onError: Signal<ErrorReport>;
12812
13460
  /** `true` when the app runs on Lite's null engine with no render surface. */
12813
13461
  readonly isHeadless: boolean;
13462
+ /**
13463
+ * `true` when the app was created with `createApp({ editMode: true })`: an editor's scene view
13464
+ * (ADR-0028). Scripts get no callbacks unless their class sets `static runInEditMode = true`,
13465
+ * the fixed loop and physics do not run, and coroutines cannot start. Fixed for the app's life.
13466
+ */
13467
+ readonly isEditMode: boolean;
12814
13468
  /** `true` between `start()` and `stop()`/`dispose()`. */
12815
13469
  readonly isRunning: boolean;
12816
13470
  /** The `@ignifx/core` version this app was built from. */
@@ -12904,7 +13558,33 @@ interface RegisterSystemOptions {
12904
13558
  readonly phase: Phase;
12905
13559
  /** Ascending order within the phase; core uses `[-1000, 1000]`, extensions `[1001, 9999]`. */
12906
13560
  readonly order?: number;
13561
+ /**
13562
+ * What the system does in an edit-mode app (ADR-0028). Defaults to `"run"`. Ignored when the app
13563
+ * is not in edit mode.
13564
+ */
13565
+ readonly editMode?: SystemEditMode;
12907
13566
  }
13567
+ /**
13568
+ * What a system does in an edit-mode app (`createApp({ editMode: true })`, ADR-0028).
13569
+ *
13570
+ * - `"run"`: runs as it does in a game. Right for systems that turn component data into what is
13571
+ * drawn, heard, or laid out.
13572
+ * - `"hold"`: runs with `ctx.dt` set to `0` and `ctx.isClockHeld` set to `true`, so it shows its
13573
+ * current state without moving it forward.
13574
+ * - `"skip"`: does not run. Right for simulation, and for systems that would overwrite authored
13575
+ * data such as a transform.
13576
+ *
13577
+ * A `FixedUpdate` system never runs in edit mode, whatever it declares, because the fixed loop does
13578
+ * not run.
13579
+ *
13580
+ * @example
13581
+ * ```ts
13582
+ * ctx.registerSystem(new WindSystem(), { phase: Phase.Update, editMode: "skip" });
13583
+ * ```
13584
+ *
13585
+ * @public
13586
+ */
13587
+ type SystemEditMode = "run" | "hold" | "skip";
12908
13588
  /**
12909
13589
  * An extension's registration surface (`docs/architecture/04-extensions.md` §1). Everything an
12910
13590
  * extension contributes is declared here; nothing happens at module import time
@@ -13371,6 +14051,17 @@ interface CreateAppOptions {
13371
14051
  * rebuilds the live instances built from it.
13372
14052
  */
13373
14053
  readonly hotReload?: HotReloadOptions;
14054
+ /**
14055
+ * Builds the app for an editor's scene view (ADR-0028,
14056
+ * `docs/architecture/03-scripting-and-components.md` §10). Scripts get no lifecycle or frame
14057
+ * callbacks unless their class sets `static runInEditMode = true`; the fixed loop, physics, and
14058
+ * other simulation systems do not run; `startCoroutine` throws `IGX-0111` for a script that does
14059
+ * not run in edit mode. Systems that turn component data into what is drawn keep running. Fixed
14060
+ * for the app's life; `app.isEditMode` reports it.
14061
+ *
14062
+ * @defaultValue `false`
14063
+ */
14064
+ readonly editMode?: boolean;
13374
14065
  }
13375
14066
  /**
13376
14067
  * Creates a game (`docs/architecture/00-overview.md` §1, `04-extensions.md` §2).
@@ -13406,15 +14097,14 @@ export declare function createApp(options?: CreateAppOptions): Promise<App>;
13406
14097
  * `version` (`docs/architecture/04-extensions.md` §1).
13407
14098
  *
13408
14099
  * @remarks
13409
- * The literal is `"0.0.0"` in the repository and is stamped by the release pipeline: Changesets
13410
- * writes the real number into `package.json`, and the build replaces this constant with it
13411
- * (coding standards §12, `release.yml`). Reading the version from `package.json` at run time is not
13412
- * an option — that would be an import-time side effect and a bundler hazard
14100
+ * The build stamps it from `package.json`, where Changesets writes each release's number; code run
14101
+ * from source, such as this repository's tests, sees `"0.0.0"`. Reading `package.json` at run time
14102
+ * is not an option: that would be an import-time side effect and a bundler hazard
13413
14103
  * (`CONSTITUTION.md` §3.5).
13414
14104
  *
13415
14105
  * @public
13416
14106
  */
13417
- export declare const VERSION = "0.0.0";
14107
+ export declare const VERSION: string;
13418
14108
  //#endregion
13419
14109
  //#region src/assets/asset-ref.d.ts
13420
14110
  /**
@@ -15732,696 +16422,828 @@ export declare function createFontLoader(): AssetLoader<FontAsset>;
15732
16422
  */
15733
16423
  export declare function createMaterialLoader(): AssetLoader<MaterialAsset>;
15734
16424
  //#endregion
15735
- //#region src/lite/gpu/gltf.d.ts
16425
+ //#region src/render/mesh-asset.d.ts
15736
16426
  /**
15737
- * glTF half of the Babylon Lite adapter (`docs/architecture/07-rendering.md` §2.4): loading a
15738
- * `.glb` into an asset container, and instantiating that container under an entity node.
15739
- *
15740
- * Everything here is `@internal`. `loadGltf` uploads vertex buffers and textures, so the module is
15741
- * GPU-only.
15742
- *
15743
- * ## What a container holds (verified against `@babylonjs/lite@1.27.0`)
15744
- *
15745
- * `loadGltf(engine, source)` (`index.d.ts` 6821) — reached through the dynamically imported
15746
- * `./gltf-source.ts`, so that a game which loads no model carries no glTF parser — takes a URL, an
15747
- * `ArrayBuffer`, or a `Blob` and
15748
- * resolves to an `AssetContainer` (`index.d.ts` 653) whose `entities` is `[rootTransformNode]` for
15749
- * glTF. The ignifx asset layer fetches the bytes itself — that is where progress reporting and
15750
- * `AbortSignal` support live (`docs/architecture/05-assets-and-loading.md`) — and hands Lite an
15751
- * `ArrayBuffer`, so this adapter never fetches.
15752
- *
15753
- * ## Animation groups are stripped, not ticked
15754
- *
15755
- * `addToScene` pushes a container's `animationGroups` onto the scene and installs a before-render
15756
- * hook that calls `tickAnimation` for each one (`lib/scene/scene-core.js`). ADR-0003 says ignifx
15757
- * owns time, so {@link takeAnimationGroups} removes them from the container *before* it is added:
15758
- * Lite then registers no hook, and ignifx's animation system advances the clips itself.
15759
- *
15760
- * ## Instancing
15761
- *
15762
- * `cloneTransformNode` on the container root deep-clones the transform hierarchy while every mesh
15763
- * in it shares the original's `_gpu` wrapper and bumps its reference count
15764
- * (`lib/scene/transform-node.js`) — so N instances of a model upload one copy of the geometry. Lights
15765
- * inside the subtree are shallow-copied as plain objects rather than cloned; glTF cameras are only
15766
- * present at all when `enableGltfCameras()` ran before the load.
16427
+ * Mesh templates share geometry with renderer clones (ADR-0002).
16428
+ * Factories register a loaded handle with one caller-owned hold; release it when no longer needed.
16429
+ * Existing clones survive collection, but a disposed template cannot make new clones.
16430
+ * Headless mesh assets keep component state without GPU geometry.
15767
16431
  */
15768
16432
  /**
15769
- * The Babylon Lite asset container a `ModelAsset` holds, re-exported under an ignifx name
15770
- * (`CONSTITUTION.md` §3.4, coding standards §4).
15771
- *
15772
- * @remarks
15773
- * Unstable; excluded from the stability guarantees of `CONSTITUTION.md` Article IV.
16433
+ * The asset type primitives are registered under.
15774
16434
  *
15775
16435
  * @public
15776
16436
  */
15777
- type LiteAssetContainer = AssetContainer;
15778
- /**
15779
- * A Babylon Lite animation clip, re-exported under an ignifx name. `Model.animations` hands these
15780
- * to `@ignifx/3d`'s animator, which owns advancement (ADR-0003).
15781
- *
15782
- * @remarks
15783
- * Unstable; excluded from the stability guarantees of `CONSTITUTION.md` Article IV.
15784
- *
15785
- * @beta
15786
- */
15787
- type LiteAnimationGroup = AnimationGroup;
16437
+ export declare const MESH_ASSET_TYPE = "mesh";
15788
16438
  /**
15789
- * A Babylon Lite skeleton, re-exported under an ignifx name. Present on a container only when
15790
- * `enableBoneControl()` ran before the load (`index.d.ts` 653).
15791
- *
15792
- * @remarks
15793
- * Unstable; excluded from the stability guarantees of `CONSTITUTION.md` Article IV.
16439
+ * How {@link MeshAsset.box} sizes its box, in metres. Give `size` for a cube, or the three
16440
+ * dimensions.
15794
16441
  *
15795
- * @beta
16442
+ * @public
15796
16443
  */
15797
- type LiteSkeleton = Skeleton;
15798
- //#endregion
15799
- //#region src/render/model-asset.d.ts
16444
+ interface BoxMeshOptions {
16445
+ /** Edge length on every axis. */
16446
+ readonly size?: number;
16447
+ /** Size along X, overriding `size`. */
16448
+ readonly width?: number;
16449
+ /** Size along Y, overriding `size`. */
16450
+ readonly height?: number;
16451
+ /** Size along Z, overriding `size`. */
16452
+ readonly depth?: number;
16453
+ }
15800
16454
  /**
15801
- * `ModelAsset` (`docs/architecture/05-assets-and-loading.md` §5 and §6,
15802
- * `07-rendering.md` §2.4): the loaded glTF container a `Model` component instantiates.
15803
- *
15804
- * ## The container is a template, not a scene member
15805
- *
15806
- * `loadGltf` resolves to an `AssetContainer` whose `entities` is `[rootTransformNode]`
15807
- * (`index.d.ts` 653). ignifx never adds that container to a scene. Each `Model` clones it instead
15808
- * (`cloneTransformNode`), which deep-copies the transform hierarchy while every mesh shares the
15809
- * original's GPU buffers under a reference count — so ten instances of a model upload one copy of
15810
- * the geometry (`src/lite/gpu/gltf.ts`). Keeping the container out of the scene is also what makes
15811
- * the first instance cost the same as the tenth, and what lets the asset outlive any one of them.
15812
- *
15813
- * ## Animation groups are taken, not ticked
15814
- *
15815
- * `addToScene` would register a container's `animationGroups` with Lite's own animation manager and
15816
- * install a before-render hook for them. ADR-0003 says ignifx owns every clock, so the loader
15817
- * removes them from the container the moment it is loaded and the asset keeps them
15818
- * ({@link ModelAsset.animations}). Core exposes them and advances nothing; `@ignifx/3d`'s
15819
- * `Animator` is what plays them.
15820
- *
15821
- * ## Instance counting
15822
- *
15823
- * Instances are counted so the template's GPU resources live until the last instance and the asset
15824
- * handle are gone (`05-assets-and-loading.md` §6). {@link ModelAsset.retainInstance} and
15825
- * {@link ModelAsset.releaseInstance} are that counter; `Model` calls them, and
15826
- * {@link ModelAsset.instanceCount} is what a test asserts on.
15827
- *
15828
- * ## Headless
16455
+ * How {@link MeshAsset.sphere} tessellates its sphere.
15829
16456
  *
15830
- * `loadGltf` throws a `TypeError` under the null engine — it reaches for `engine._device` while
15831
- * uploading (ADR-0002 Validation) — so a headless load skips it entirely and produces an asset with
15832
- * `lite.container === null`. A `Model` that holds one keeps its fields, reports an empty `nodes`
15833
- * map, and touches no scene (`07-rendering.md` §6).
16457
+ * @public
15834
16458
  */
16459
+ interface SphereMeshOptions {
16460
+ /** Diameter on every axis, in metres. Lite defaults to 1. */
16461
+ readonly diameter?: number;
16462
+ /** Ring count; higher is smoother. Lite defaults to 32. */
16463
+ readonly segments?: number;
16464
+ }
15835
16465
  /**
15836
- * The asset type models are registered under.
16466
+ * How {@link MeshAsset.plane} sizes its quad, which lies in the XY plane facing `-Z`.
15837
16467
  *
15838
16468
  * @public
15839
16469
  */
15840
- export declare const MODEL_ASSET_TYPE = "model";
16470
+ interface PlaneMeshOptions {
16471
+ /** Edge length on both axes, in metres. */
16472
+ readonly size?: number;
16473
+ /** Width, overriding `size`. */
16474
+ readonly width?: number;
16475
+ /** Height, overriding `size`. */
16476
+ readonly height?: number;
16477
+ }
15841
16478
  /**
15842
- * The address suffixes that select the model loader.
16479
+ * How {@link MeshAsset.ground} sizes and subdivides its grid, which lies in the XZ plane facing
16480
+ * `+Y`.
15843
16481
  *
15844
16482
  * @public
15845
16483
  */
15846
- export declare const MODEL_FILE_EXTENSIONS: readonly string[];
16484
+ interface GroundMeshOptions {
16485
+ /** Size along X, in metres. */
16486
+ readonly width?: number;
16487
+ /** Size along Z, in metres. */
16488
+ readonly height?: number;
16489
+ /** Quads per side. */
16490
+ readonly subdivisions?: number;
16491
+ /** UV multiplier, for tiling a texture across the grid. */
16492
+ readonly uvScale?: readonly [number, number];
16493
+ }
15847
16494
  /**
15848
- * The Babylon Lite objects a {@link ModelAsset} owns. Unstable escape hatch
15849
- * (`docs/architecture/00-overview.md` §3).
16495
+ * How {@link MeshAsset.cylinder} sizes its cylinder, which stands along Y.
15850
16496
  *
15851
16497
  * @public
15852
16498
  */
15853
- interface ModelAssetLiteHandles {
15854
- /** The template container, or `null` under a headless app. */
15855
- readonly container: LiteAssetContainer | null;
16499
+ interface CylinderMeshOptions {
16500
+ /** Height along Y, in metres. */
16501
+ readonly height?: number;
16502
+ /** Diameter of both ends. */
16503
+ readonly diameter?: number;
16504
+ /** Diameter of the top cap, overriding `diameter` — a cone is `diameterTop: 0`. */
16505
+ readonly diameterTop?: number;
16506
+ /** Diameter of the bottom cap, overriding `diameter`. */
16507
+ readonly diameterBottom?: number;
16508
+ /** Radial segment count. */
16509
+ readonly tessellation?: number;
15856
16510
  }
15857
16511
  /**
15858
- * One instantiated copy of a model, as a `Model` component holds it.
16512
+ * How {@link MeshAsset.capsule} sizes its capsule, which stands along Y.
16513
+ *
16514
+ * @remarks
16515
+ * `height` is the **total** height including both caps, the same convention `@ignifx/physics` uses
16516
+ * for a capsule collider, so one pair of numbers describes both.
15859
16517
  *
15860
16518
  * @public
15861
16519
  */
15862
- interface ModelInstantiation {
15863
- /** The cloned container root, parented under the entity's node. */
15864
- readonly root: LiteSceneNode;
15865
- /** Every named node in the clone, keyed by its glTF node name. */
15866
- readonly nodes: ReadonlyMap<string, LiteSceneNode>;
16520
+ interface CapsuleMeshOptions {
16521
+ /** Total height including both caps, in metres. */
16522
+ readonly height?: number;
16523
+ /** Radius of the body and the caps. */
16524
+ readonly radius?: number;
16525
+ /** Radial segment count. */
16526
+ readonly tessellation?: number;
15867
16527
  }
15868
16528
  /**
15869
- * A loaded glTF or GLB file (`docs/architecture/05-assets-and-loading.md` §5).
16529
+ * How {@link MeshAsset.torus} sizes its ring, which lies in the XZ plane.
16530
+ *
16531
+ * @public
16532
+ */
16533
+ interface TorusMeshOptions {
16534
+ /** Outer diameter, in metres. */
16535
+ readonly diameter?: number;
16536
+ /** Tube thickness, in metres. */
16537
+ readonly thickness?: number;
16538
+ /** Segment count around the ring. */
16539
+ readonly tessellation?: number;
16540
+ }
16541
+ /**
16542
+ * The primitive shapes a `MeshAsset` factory and a `.mesh.json` file can build.
16543
+ *
16544
+ * @public
16545
+ */
16546
+ export declare const MESH_PRIMITIVES: readonly ["box", "sphere", "plane", "ground", "cylinder", "capsule", "torus"];
16547
+ /**
16548
+ * One of {@link MESH_PRIMITIVES}.
16549
+ *
16550
+ * @public
16551
+ */
16552
+ type MeshPrimitive = (typeof MESH_PRIMITIVES)[number];
16553
+ /**
16554
+ * A primitive and the options its factory takes: what a `.mesh.json` file declares.
16555
+ *
16556
+ * @public
16557
+ */
16558
+ type MeshPrimitiveDefinition = {
16559
+ readonly primitive: "box";
16560
+ readonly options: BoxMeshOptions;
16561
+ } | {
16562
+ readonly primitive: "sphere";
16563
+ readonly options: SphereMeshOptions;
16564
+ } | {
16565
+ readonly primitive: "plane";
16566
+ readonly options: PlaneMeshOptions;
16567
+ } | {
16568
+ readonly primitive: "ground";
16569
+ readonly options: GroundMeshOptions;
16570
+ } | {
16571
+ readonly primitive: "cylinder";
16572
+ readonly options: CylinderMeshOptions;
16573
+ } | {
16574
+ readonly primitive: "capsule";
16575
+ readonly options: CapsuleMeshOptions;
16576
+ } | {
16577
+ readonly primitive: "torus";
16578
+ readonly options: TorusMeshOptions;
16579
+ };
16580
+ /**
16581
+ * Raw vertex data for {@link MeshAsset.fromData}.
16582
+ *
16583
+ * @remarks
16584
+ * Lite keeps references to these arrays rather than copying them — they are what its CPU ray pick
16585
+ * and its bounds read (`lib/mesh/mesh-factories.js`). Mutating one behind Lite's back changes what
16586
+ * a pick reports without changing what the GPU draws; the sanctioned way to change geometry after
16587
+ * the fact is {@link MeshAsset.updatePositions} and its three siblings, which re-upload, keep this
16588
+ * copy in step, and re-fit the bounds.
16589
+ *
16590
+ * @public
16591
+ */
16592
+ interface MeshGeometryData {
16593
+ /** Three floats per vertex. */
16594
+ readonly positions: Float32Array;
16595
+ /** Three floats per vertex, one normal each. */
16596
+ readonly normals: Float32Array;
16597
+ /** Three indices per triangle. */
16598
+ readonly indices: Uint32Array;
16599
+ /** Two floats per vertex, or omitted for a mesh with no texture coordinates. */
16600
+ readonly uvs?: Float32Array;
16601
+ /**
16602
+ * Two floats per vertex for the second UV set (`uv2` in a shader), or omitted. Lightmaps, baked
16603
+ * ambient occlusion, and the parent-LOD height a terrain morph reads all ride here.
16604
+ */
16605
+ readonly uvs2?: Float32Array;
16606
+ /** Four floats per vertex — `xyz` plus a handedness `w` — or omitted. A normal map needs them. */
16607
+ readonly tangents?: Float32Array;
16608
+ /**
16609
+ * Four floats per vertex, linear RGBA, or omitted. A material has to be one that reads the colour
16610
+ * attribute; set `hasVertexAlpha` on the Lite mesh if the alpha is meant to blend.
16611
+ */
16612
+ readonly colors?: Float32Array;
16613
+ }
16614
+ /**
16615
+ * The Babylon Lite objects a {@link MeshAsset} owns. Unstable escape hatch
16616
+ * (`docs/architecture/00-overview.md` §3).
16617
+ *
16618
+ * @public
16619
+ */
16620
+ interface MeshAssetLiteHandles {
16621
+ /** The template mesh, or `null` under a headless app, which uploads no geometry. */
16622
+ readonly mesh: LiteMesh | null;
16623
+ }
16624
+ /**
16625
+ * A geometry template a `MeshRenderer` draws (`docs/architecture/07-rendering.md` §2.3).
16626
+ *
16627
+ * @remarks
16628
+ * Build one with a primitive factory or {@link MeshAsset.fromData}; each returns the handle the
16629
+ * `MeshRenderer.mesh` field takes. A `.mesh.json` file loads the same primitives by address
16630
+ * (`app.assets.load("meshes/crate.mesh.json")`), so a scene file can name one. A glTF mesh
16631
+ * arrives as part of a `ModelAsset` instead — a glTF is a tree of meshes, materials, and
16632
+ * animations, not one buffer.
15870
16633
  *
15871
16634
  * @example
15872
16635
  * ```ts
15873
- * const hero = await app.assets.loadAsync<ModelAsset>("models/hero.glb");
15874
- * hero.value.animations.map((clip) => clip.name);
16636
+ * const box = MeshAsset.box(app, { size: 2 }); // one reference, owned by this code
16637
+ * const cube = app.world.createEntity("Cube");
16638
+ * cube.addComponent(MeshRenderer, { mesh: box }); // the field takes no reference
16639
+ * // Once nothing draws the box any more:
16640
+ * box.release();
15875
16641
  * ```
15876
16642
  *
15877
16643
  * @public
15878
16644
  */
15879
- export declare class ModelAsset {
16645
+ export declare class MeshAsset {
15880
16646
  #private;
15881
- /** The type name the asset service registers models under. */
16647
+ /** The type name the asset service registers meshes under. */
15882
16648
  static assetType: string;
15883
- /** The address the model was loaded from. */
15884
- readonly address: string;
16649
+ /** A human-readable name, used in diagnostics and as the Lite mesh's name. */
16650
+ readonly name: string;
15885
16651
  /**
15886
- * The clips the file declared, stripped from the container so Lite never ticks them.
16652
+ * Wraps a template mesh. Use the static factories; the engine constructs assets.
16653
+ *
16654
+ * @param name - A human-readable name.
16655
+ * @param mesh - The template, or `null` when the app is headless.
16656
+ * @param scene - The scene the template is released through, or `null` when there is nothing to
16657
+ * release.
16658
+ * @param geometry - The vertex arrays the asset was built from, when it came from
16659
+ * {@link MeshAsset.fromData}; `null` for a primitive, whose arrays Lite generated and never
16660
+ * handed back. It is what makes the `update*` methods legal.
16661
+ * @param engine - The engine an update writes through, or `null` under a headless app.
16662
+ *
16663
+ * @internal
16664
+ */
16665
+ constructor(name: string, mesh: LiteMesh | null, scene: LiteScene | null, geometry?: MeshGeometryData | null, engine?: LiteEngine | null);
16666
+ /**
16667
+ * The Babylon Lite objects the asset owns. Unstable escape hatch
16668
+ * (`docs/architecture/00-overview.md` §3).
16669
+ *
16670
+ * @returns The template mesh, or `null` under a headless app.
16671
+ */
16672
+ get lite(): MeshAssetLiteHandles;
16673
+ /**
16674
+ * Whether the template's GPU buffers have been released.
16675
+ *
16676
+ * @returns `true` once {@link MeshAsset.dispose} has run.
16677
+ */
16678
+ get isDisposed(): boolean;
16679
+ /**
16680
+ * How many vertices the geometry has.
15887
16681
  *
15888
16682
  * @remarks
15889
- * Unstable: these are Lite's own animation groups, handed on to `@ignifx/3d`'s `Animator`, and
15890
- * they are excluded from the stability guarantees of `CONSTITUTION.md` Article IV. To core they
15891
- * are read-only metadata: nothing here advances or re-binds them.
16683
+ * Known for a mesh built with {@link MeshAsset.fromData} — headless included — and `0` for a
16684
+ * primitive: Lite generates a primitive's arrays internally and 1.27.0's `Mesh` exposes no vertex
16685
+ * count, only the opaque `MeshGPU` handle it says a user never touches (`index.d.ts` 7230).
15892
16686
  *
15893
- * @beta
16687
+ * @returns The vertex count, or `0`.
15894
16688
  */
15895
- readonly animations: readonly LiteAnimationGroup[];
16689
+ get vertexCount(): number;
15896
16690
  /**
15897
- * The skeletons the file declared. Empty unless the `boneControl` rendering feature was on before
15898
- * the load, because Lite builds them only then (`index.d.ts` 653).
16691
+ * How many indices the geometry has — three per triangle.
15899
16692
  *
15900
- * @beta
16693
+ * @returns The index count, or `0`; see {@link MeshAsset.vertexCount}.
15901
16694
  */
15902
- readonly skeletons: readonly LiteSkeleton[];
16695
+ get indexCount(): number;
15903
16696
  /**
15904
- * Wraps a loaded container. The `model` loader constructs these.
16697
+ * Re-uploads vertex positions and re-fits the bounds.
15905
16698
  *
15906
- * @param address - The address it was loaded from.
15907
- * @param container - The template container, or `null` when the app is headless.
15908
- * @param animations - The clips taken off the container.
15909
- * @param skeletons - The skeletons the loader found.
15910
- * @param scene - The scene the container is released through, or `null` when headless.
16699
+ * @remarks
16700
+ * Only a mesh from {@link MeshAsset.fromData} can be updated, and only while nothing has cloned it:
16701
+ * Lite refuses to write a vertex buffer with more than one owner, and a `MeshRenderer` clone is a
16702
+ * second owner.
15911
16703
  *
15912
- * @internal
16704
+ * Lite's `updateMeshPositions` writes the GPU buffer and stops there, so this also copies the range
16705
+ * into the asset's own position array — the one Lite retained and CPU picking reads — and rewrites
16706
+ * the bounds from the whole of it, `O(vertexCount)` per call. Passing the asset's own array skips
16707
+ * the copy.
16708
+ *
16709
+ * @param data - Three floats per vertex, read from index 0.
16710
+ * @param vertexOffset - The first vertex to overwrite. Defaults to `0`.
16711
+ * @param vertexCount - How many vertices to write. Defaults to as many as `data` holds.
16712
+ * @throws IgnifxError with code `IGX-0702` when the mesh did not come from
16713
+ * {@link MeshAsset.fromData}, or has been disposed.
16714
+ * @throws IgnifxError with code `IGX-0725` when the range falls outside the mesh or `data` is too
16715
+ * short for it.
16716
+ *
16717
+ * @example
16718
+ * ```ts
16719
+ * const grid = MeshAsset.fromData(app, "grid", { positions, normals, indices });
16720
+ * positions[1] += 0.5;
16721
+ * grid.value.updatePositions(positions);
16722
+ * ```
15913
16723
  */
15914
- constructor(address: string, container: LiteAssetContainer | null, animations: readonly LiteAnimationGroup[], skeletons: readonly LiteSkeleton[], scene: LiteScene | null);
16724
+ updatePositions(data: Float32Array, vertexOffset?: number, vertexCount?: number): void;
15915
16725
  /**
15916
- * The Babylon Lite objects the asset owns. Unstable escape hatch.
16726
+ * Re-uploads vertex normals.
15917
16727
  *
15918
- * @returns The template container, or `null` under a headless app.
16728
+ * @remarks
16729
+ * The same rules as {@link MeshAsset.updatePositions}, minus the bounds: a normal cannot move a
16730
+ * bounding box. The range is copied into the asset's own normal array so that a later
16731
+ * `updatePositions` sees a consistent mesh.
16732
+ *
16733
+ * @param data - Three floats per vertex.
16734
+ * @param vertexOffset - The first vertex to overwrite. Defaults to `0`.
16735
+ * @param vertexCount - How many vertices to write. Defaults to as many as `data` holds.
16736
+ * @throws IgnifxError with code `IGX-0702` or `IGX-0725`; see
16737
+ * {@link MeshAsset.updatePositions}.
15919
16738
  */
15920
- get lite(): ModelAssetLiteHandles;
16739
+ updateNormals(data: Float32Array, vertexOffset?: number, vertexCount?: number): void;
15921
16740
  /**
15922
- * How many `Model` components currently hold a copy of this template.
16741
+ * Re-uploads texture coordinates.
15923
16742
  *
15924
- * @returns The live instance count.
16743
+ * @remarks
16744
+ * Lite makes the upload a **no-op** when the mesh was created without UVs, rather than an error,
16745
+ * so a mesh whose `MeshGeometryData` named none silently ignores this. The range check still runs.
16746
+ *
16747
+ * @param data - Two floats per vertex.
16748
+ * @param vertexOffset - The first vertex to overwrite. Defaults to `0`.
16749
+ * @param vertexCount - How many vertices to write. Defaults to as many as `data` holds.
16750
+ * @throws IgnifxError with code `IGX-0702` or `IGX-0725`; see
16751
+ * {@link MeshAsset.updatePositions}.
15925
16752
  */
15926
- get instanceCount(): number;
16753
+ updateUvs(data: Float32Array, vertexOffset?: number, vertexCount?: number): void;
15927
16754
  /**
15928
- * Clones the template under an entity's node.
16755
+ * Re-uploads vertex colours.
15929
16756
  *
15930
- * @param parent - The entity's transform node, or `null` for world space.
15931
- * @returns The cloned root and its named nodes, or `null` when there is nothing to clone — a
15932
- * headless app, or a file that declared only lights.
16757
+ * @remarks
16758
+ * Four floats per vertex, linear RGBA. A no-op on the GPU when the mesh was created without
16759
+ * colours, exactly as {@link MeshAsset.updateUvs} is.
16760
+ *
16761
+ * @param data - Four floats per vertex.
16762
+ * @param vertexOffset - The first vertex to overwrite. Defaults to `0`.
16763
+ * @param vertexCount - How many vertices to write. Defaults to as many as `data` holds.
16764
+ * @throws IgnifxError with code `IGX-0702` or `IGX-0725`; see
16765
+ * {@link MeshAsset.updatePositions}.
15933
16766
  */
15934
- instantiate(parent: LiteSceneNode | null): ModelInstantiation | null;
15935
- /** Records that one more `Model` holds a copy. */
15936
- retainInstance(): void;
15937
- /** Records that one fewer `Model` holds a copy. Releasing below zero is a no-op. */
15938
- releaseInstance(): void;
16767
+ updateColors(data: Float32Array, vertexOffset?: number, vertexCount?: number): void;
15939
16768
  /**
15940
- * Releases the template's GPU resources.
16769
+ * Releases the template's GPU buffers.
15941
16770
  *
15942
16771
  * @remarks
15943
- * The container was never added to a scene, so the round trip `removeFromScene` needs is the same
15944
- * one `MeshAsset.dispose` performs: this hands it to the scene and takes it straight back out,
15945
- * which drops its share of every buffer. Clones still in a scene keep theirs. Calling it twice is
15946
- * a no-op, and it is a no-op under a headless app.
16772
+ * Lite exports no mesh disposer: a mesh's buffers are freed when it leaves its last scene, so the
16773
+ * adapter adds the template to a scene and takes it straight out again
16774
+ * (`src/lite/gpu/mesh.ts`). Clones still in a scene keep the shared buffers alive; what the
16775
+ * template loses is the ability to be cloned again. Calling it twice is a no-op, and it is a
16776
+ * no-op under a headless app, which has no buffers.
15947
16777
  */
15948
16778
  dispose(): void;
15949
16779
  /** Releases the template when the asset leaves a `using` block. */
15950
16780
  [Symbol.dispose](): void;
15951
- }
15952
- //#endregion
15953
- //#region src/render/loaders/model-loader.d.ts
15954
- /**
15955
- * The `model` asset loader (`docs/architecture/05-assets-and-loading.md` §5).
15956
- *
15957
- * ## Bytes, not a URL
15958
- *
15959
- * `loadGltf` accepts a URL, an `ArrayBuffer`, or a `Blob`. ignifx hands it an `ArrayBuffer` fetched
15960
- * through `ctx.fetchBytes`, because that is where progress reporting, `AbortSignal` support, the
15961
- * priority queue, and the retry policy live (§5). A `.glb` is one file, so this is lossless.
15962
- *
15963
- * A `.gltf` with **external** buffers and images is the one case where it is not: Lite would have to
15964
- * resolve those relative URLs itself, which it can only do when it did the fetching. This loader
15965
- * loads the container from bytes either way and therefore supports self-contained `.gltf` files and
15966
- * `.glb`; a `.gltf` with siblings fails inside Lite and surfaces as `IGX-0505`. `.glb` is what the
15967
- * asset pipeline produces, and the fix — passing the URL through for that one shape — is a
15968
- * three-line change whenever a project needs it.
15969
- *
15970
- * ## Headless
15971
- *
15972
- * `loadGltf` throws a `TypeError` under the null engine: it uploads while parsing and reaches for
15973
- * `engine._device` (ADR-0002 Validation). So a headless load skips it entirely and produces an
15974
- * asset with no container — the `gpu: null` shape §5 requires — rather than failing. The bytes are
15975
- * still fetched, so a headless test still exercises the address, the manifest, and the byte
15976
- * counters.
15977
- */
16781
+ /**
16782
+ * Creates a box template and publishes it.
16783
+ *
16784
+ * @param app - The app whose engine uploads the geometry and whose asset service holds the handle.
16785
+ * @param options - A uniform `size`, or per-axis dimensions.
16786
+ * @returns The handle, with one holder — the caller.
16787
+ *
16788
+ * @example
16789
+ * ```ts
16790
+ * const box = MeshAsset.box(app, { width: 2, height: 1, depth: 3 });
16791
+ * ```
16792
+ */
16793
+ static box(app: App, options?: BoxMeshOptions): AssetHandle<MeshAsset>;
16794
+ /**
16795
+ * Creates a sphere template and publishes it.
16796
+ *
16797
+ * @param app - The app that owns the engine and the asset service.
16798
+ * @param options - Diameter and ring count.
16799
+ * @returns The handle, with one holder.
16800
+ */
16801
+ static sphere(app: App, options?: SphereMeshOptions): AssetHandle<MeshAsset>;
16802
+ /**
16803
+ * Creates a quad template in the XY plane and publishes it.
16804
+ *
16805
+ * @param app - The app that owns the engine and the asset service.
16806
+ * @param options - A uniform `size`, or width and height.
16807
+ * @returns The handle, with one holder.
16808
+ */
16809
+ static plane(app: App, options?: PlaneMeshOptions): AssetHandle<MeshAsset>;
16810
+ /**
16811
+ * Creates a subdivided grid in the XZ plane and publishes it.
16812
+ *
16813
+ * @param app - The app that owns the engine and the asset service.
16814
+ * @param options - Width, depth, subdivisions, and UV scale.
16815
+ * @returns The handle, with one holder.
16816
+ */
16817
+ static ground(app: App, options?: GroundMeshOptions): AssetHandle<MeshAsset>;
16818
+ /**
16819
+ * Creates a cylinder template standing along Y and publishes it.
16820
+ *
16821
+ * @param app - The app that owns the engine and the asset service.
16822
+ * @param options - Height, diameters, and tessellation.
16823
+ * @returns The handle, with one holder.
16824
+ */
16825
+ static cylinder(app: App, options?: CylinderMeshOptions): AssetHandle<MeshAsset>;
16826
+ /**
16827
+ * Creates a capsule template standing along Y and publishes it.
16828
+ *
16829
+ * @param app - The app that owns the engine and the asset service.
16830
+ * @param options - Total height, radius, and tessellation.
16831
+ * @returns The handle, with one holder.
16832
+ */
16833
+ static capsule(app: App, options?: CapsuleMeshOptions): AssetHandle<MeshAsset>;
16834
+ /**
16835
+ * Creates a torus template in the XZ plane and publishes it.
16836
+ *
16837
+ * @param app - The app that owns the engine and the asset service.
16838
+ * @param options - Diameter, thickness, and tessellation.
16839
+ * @returns The handle, with one holder.
16840
+ */
16841
+ static torus(app: App, options?: TorusMeshOptions): AssetHandle<MeshAsset>;
16842
+ /**
16843
+ * Creates a template from raw vertex data and publishes it.
16844
+ *
16845
+ * @param app - The app that owns the engine and the asset service.
16846
+ * @param name - A human-readable name.
16847
+ * @param data - Positions, normals, indices, and any of the four optional attributes. Lite keeps
16848
+ * references to the arrays; a caller that means to edit them afterwards does so through the
16849
+ * `update*` methods, which keep Lite's own copy and its bounds in step.
16850
+ * @returns The handle, with one holder.
16851
+ *
16852
+ * @example
16853
+ * ```ts
16854
+ * const triangle = MeshAsset.fromData(app, "triangle", {
16855
+ * positions: Float32Array.from([0, 0, 0, 1, 0, 0, 0, 1, 0]),
16856
+ * normals: Float32Array.from([0, 0, -1, 0, 0, -1, 0, 0, -1]),
16857
+ * indices: Uint32Array.from([0, 1, 2]),
16858
+ * });
16859
+ * ```
16860
+ */
16861
+ static fromData(app: App, name: string, data: MeshGeometryData): AssetHandle<MeshAsset>;
16862
+ }
16863
+ //#endregion
16864
+ //#region src/render/loaders/mesh-loader.d.ts
15978
16865
  /**
15979
- * Builds the loader for `.glb` and `.gltf` addresses.
16866
+ * Builds the `mesh` loader: `.mesh.json` to `MeshAsset` (ADR-0029).
16867
+ *
16868
+ * @remarks
16869
+ * The file names a primitive and its options, and the loader builds it exactly as the matching
16870
+ * `MeshAsset` factory would. The mesh is named after the file's `name`, or its address. A headless
16871
+ * app builds no GPU geometry. A file that is not a mesh file fails the load with `IGX-0709`, a
16872
+ * format version other than 1 with `IGX-0603`, and an unknown primitive or a bad option with
16873
+ * `IGX-0507`. The same `mesh` type still holds the in-memory meshes the factories publish; the
16874
+ * loader's `unload` frees both kinds.
15980
16875
  *
15981
16876
  * @returns The loader to register with `ctx.registerAssetLoader`.
15982
16877
  *
15983
16878
  * @example
15984
16879
  * ```ts
15985
- * ctx.registerAssetLoader(createModelLoader());
16880
+ * ctx.registerAssetLoader(createMeshLoader());
15986
16881
  * ```
15987
16882
  *
15988
16883
  * @public
15989
16884
  */
15990
- export declare function createModelLoader(): AssetLoader<ModelAsset>;
16885
+ export declare function createMeshLoader(): AssetLoader<MeshAsset>;
15991
16886
  //#endregion
15992
- //#region src/render/loaders/texture-loader.d.ts
16887
+ //#region src/lite/gpu/gltf.d.ts
15993
16888
  /**
15994
- * The `texture` asset loader (`docs/architecture/05-assets-and-loading.md` §5).
16889
+ * glTF half of the Babylon Lite adapter (`docs/architecture/07-rendering.md` §2.4): loading a
16890
+ * `.glb` into an asset container, and instantiating that container under an entity node.
15995
16891
  *
15996
- * ## Lite fetches the bytes, not ignifx
16892
+ * Everything here is `@internal`. `loadGltf` uploads vertex buffers and textures, so the module is
16893
+ * GPU-only.
15997
16894
  *
15998
- * Every other GPU loader here reads through `ctx.fetchBytes`, which is what gives it progress,
15999
- * cancellation, and retries. A texture cannot: `loadTexture2D` takes a **URL** and decodes it with
16000
- * `createImageBitmap`, which is the browser's own hardware-accelerated decode path
16001
- * (`src/lite/gpu/texture.ts`). Handing it bytes would mean decoding a PNG in JavaScript. So the
16002
- * loader hands Lite `ctx.url` and reports its own coarse progress instead, and a texture's
16003
- * `AbortSignal` stops the *request* rather than the fetch. The trade is deliberate and it is the
16004
- * one place §5's "the three `fetch*` methods are the only network paths" does not hold; the
16005
- * alternative is worse.
16895
+ * ## What a container holds (verified against `@babylonjs/lite@1.27.0`)
16006
16896
  *
16007
- * ## Options come from the sidecar
16897
+ * `loadGltf(engine, source)` (`index.d.ts` 6821) — reached through the dynamically imported
16898
+ * `./gltf-source.ts`, so that a game which loads no model carries no glTF parser — takes a URL, an
16899
+ * `ArrayBuffer`, or a `Blob` and
16900
+ * resolves to an `AssetContainer` (`index.d.ts` 653) whose `entities` is `[rootTransformNode]` for
16901
+ * glTF. The ignifx asset layer fetches the bytes itself — that is where progress reporting and
16902
+ * `AbortSignal` support live (`docs/architecture/05-assets-and-loading.md`) — and hands Lite an
16903
+ * `ArrayBuffer`, so this adapter never fetches.
16008
16904
  *
16009
- * `.meta.json` sidecars carry per-asset import options (§7), the build copies them into the
16010
- * manifest entry, and `ctx.meta` is how a loader reads its own block. sRGB is the one that matters:
16011
- * a base-colour or emissive texture wants it, and a normal, ORM, or data map must not have it.
16905
+ * ## Animation groups are stripped, not ticked
16906
+ *
16907
+ * `addToScene` pushes a container's `animationGroups` onto the scene and installs a before-render
16908
+ * hook that calls `tickAnimation` for each one (`lib/scene/scene-core.js`). ADR-0003 says ignifx
16909
+ * owns time, so {@link takeAnimationGroups} removes them from the container *before* it is added:
16910
+ * Lite then registers no hook, and ignifx's animation system advances the clips itself.
16911
+ *
16912
+ * ## Instancing
16913
+ *
16914
+ * `cloneTransformNode` on the container root deep-clones the transform hierarchy while every mesh
16915
+ * in it shares the original's `_gpu` wrapper and bumps its reference count
16916
+ * (`lib/scene/transform-node.js`) — so N instances of a model upload one copy of the geometry. Lights
16917
+ * inside the subtree are shallow-copied as plain objects rather than cloned; glTF cameras are only
16918
+ * present at all when `enableGltfCameras()` ran before the load.
16012
16919
  */
16013
16920
  /**
16014
- * Builds the loader for `.png`, `.jpg`, `.jpeg`, `.webp`, `.ktx2`, and `.basis` addresses.
16015
- *
16016
- * @returns The loader to register with `ctx.registerAssetLoader`.
16921
+ * The Babylon Lite asset container a `ModelAsset` holds, re-exported under an ignifx name
16922
+ * (`CONSTITUTION.md` §3.4, coding standards §4).
16017
16923
  *
16018
- * @example
16019
- * ```ts
16020
- * ctx.registerAssetLoader(createTextureLoader());
16021
- * ```
16924
+ * @remarks
16925
+ * Unstable; excluded from the stability guarantees of `CONSTITUTION.md` Article IV.
16022
16926
  *
16023
16927
  * @public
16024
16928
  */
16025
- export declare function createTextureLoader(): AssetLoader<TextureAsset>;
16929
+ type LiteAssetContainer = AssetContainer;
16930
+ /**
16931
+ * A Babylon Lite animation clip, re-exported under an ignifx name. `Model.animations` hands these
16932
+ * to `@ignifx/3d`'s animator, which owns advancement (ADR-0003).
16933
+ *
16934
+ * @remarks
16935
+ * Unstable; excluded from the stability guarantees of `CONSTITUTION.md` Article IV.
16936
+ *
16937
+ * @beta
16938
+ */
16939
+ type LiteAnimationGroup = AnimationGroup;
16940
+ /**
16941
+ * A Babylon Lite skeleton, re-exported under an ignifx name. Present on a container only when
16942
+ * `enableBoneControl()` ran before the load (`index.d.ts` 653).
16943
+ *
16944
+ * @remarks
16945
+ * Unstable; excluded from the stability guarantees of `CONSTITUTION.md` Article IV.
16946
+ *
16947
+ * @beta
16948
+ */
16949
+ type LiteSkeleton = Skeleton;
16026
16950
  //#endregion
16027
- //#region src/render/mesh-asset.d.ts
16951
+ //#region src/render/model-asset.d.ts
16028
16952
  /**
16029
- * Mesh templates share geometry with renderer clones (ADR-0002).
16030
- * Factories register a loaded handle with one caller-owned hold; release it when no longer needed.
16031
- * Existing clones survive collection, but a disposed template cannot make new clones.
16032
- * Headless mesh assets keep component state without GPU geometry.
16953
+ * `ModelAsset` (`docs/architecture/05-assets-and-loading.md` §5 and §6,
16954
+ * `07-rendering.md` §2.4): the loaded glTF container a `Model` component instantiates.
16955
+ *
16956
+ * ## The container is a template, not a scene member
16957
+ *
16958
+ * `loadGltf` resolves to an `AssetContainer` whose `entities` is `[rootTransformNode]`
16959
+ * (`index.d.ts` 653). ignifx never adds that container to a scene. Each `Model` clones it instead
16960
+ * (`cloneTransformNode`), which deep-copies the transform hierarchy while every mesh shares the
16961
+ * original's GPU buffers under a reference count — so ten instances of a model upload one copy of
16962
+ * the geometry (`src/lite/gpu/gltf.ts`). Keeping the container out of the scene is also what makes
16963
+ * the first instance cost the same as the tenth, and what lets the asset outlive any one of them.
16964
+ *
16965
+ * ## Animation groups are taken, not ticked
16966
+ *
16967
+ * `addToScene` would register a container's `animationGroups` with Lite's own animation manager and
16968
+ * install a before-render hook for them. ADR-0003 says ignifx owns every clock, so the loader
16969
+ * removes them from the container the moment it is loaded and the asset keeps them
16970
+ * ({@link ModelAsset.animations}). Core exposes them and advances nothing; `@ignifx/3d`'s
16971
+ * `Animator` is what plays them.
16972
+ *
16973
+ * ## Instance counting
16974
+ *
16975
+ * Instances are counted so the template's GPU resources live until the last instance and the asset
16976
+ * handle are gone (`05-assets-and-loading.md` §6). {@link ModelAsset.retainInstance} and
16977
+ * {@link ModelAsset.releaseInstance} are that counter; `Model` calls them, and
16978
+ * {@link ModelAsset.instanceCount} is what a test asserts on.
16979
+ *
16980
+ * ## Headless
16981
+ *
16982
+ * `loadGltf` throws a `TypeError` under the null engine — it reaches for `engine._device` while
16983
+ * uploading (ADR-0002 Validation) — so a headless load skips it entirely and produces an asset with
16984
+ * `lite.container === null`. A `Model` that holds one keeps its fields, reports an empty `nodes`
16985
+ * map, and touches no scene (`07-rendering.md` §6).
16033
16986
  */
16034
16987
  /**
16035
- * The asset type primitives are registered under.
16988
+ * The asset type models are registered under.
16036
16989
  *
16037
16990
  * @public
16038
16991
  */
16039
- export declare const MESH_ASSET_TYPE = "mesh";
16992
+ export declare const MODEL_ASSET_TYPE = "model";
16040
16993
  /**
16041
- * How {@link MeshAsset.box} sizes its box, in metres. Give `size` for a cube, or the three
16042
- * dimensions.
16994
+ * The address suffixes that select the model loader.
16043
16995
  *
16044
16996
  * @public
16045
16997
  */
16046
- interface BoxMeshOptions {
16047
- /** Edge length on every axis. */
16048
- readonly size?: number;
16049
- /** Size along X, overriding `size`. */
16050
- readonly width?: number;
16051
- /** Size along Y, overriding `size`. */
16052
- readonly height?: number;
16053
- /** Size along Z, overriding `size`. */
16054
- readonly depth?: number;
16055
- }
16998
+ export declare const MODEL_FILE_EXTENSIONS: readonly string[];
16056
16999
  /**
16057
- * How {@link MeshAsset.sphere} tessellates its sphere.
17000
+ * The Babylon Lite objects a {@link ModelAsset} owns. Unstable escape hatch
17001
+ * (`docs/architecture/00-overview.md` §3).
16058
17002
  *
16059
17003
  * @public
16060
17004
  */
16061
- interface SphereMeshOptions {
16062
- /** Diameter on every axis, in metres. Lite defaults to 1. */
16063
- readonly diameter?: number;
16064
- /** Ring count; higher is smoother. Lite defaults to 32. */
16065
- readonly segments?: number;
17005
+ interface ModelAssetLiteHandles {
17006
+ /** The template container, or `null` under a headless app. */
17007
+ readonly container: LiteAssetContainer | null;
16066
17008
  }
16067
17009
  /**
16068
- * How {@link MeshAsset.plane} sizes its quad, which lies in the XY plane facing `-Z`.
17010
+ * One instantiated copy of a model, as a `Model` component holds it.
16069
17011
  *
16070
17012
  * @public
16071
17013
  */
16072
- interface PlaneMeshOptions {
16073
- /** Edge length on both axes, in metres. */
16074
- readonly size?: number;
16075
- /** Width, overriding `size`. */
16076
- readonly width?: number;
16077
- /** Height, overriding `size`. */
16078
- readonly height?: number;
16079
- }
16080
- /**
16081
- * How {@link MeshAsset.ground} sizes and subdivides its grid, which lies in the XZ plane facing
16082
- * `+Y`.
16083
- *
16084
- * @public
16085
- */
16086
- interface GroundMeshOptions {
16087
- /** Size along X, in metres. */
16088
- readonly width?: number;
16089
- /** Size along Z, in metres. */
16090
- readonly height?: number;
16091
- /** Quads per side. */
16092
- readonly subdivisions?: number;
16093
- /** UV multiplier, for tiling a texture across the grid. */
16094
- readonly uvScale?: readonly [number, number];
16095
- }
16096
- /**
16097
- * How {@link MeshAsset.cylinder} sizes its cylinder, which stands along Y.
16098
- *
16099
- * @public
16100
- */
16101
- interface CylinderMeshOptions {
16102
- /** Height along Y, in metres. */
16103
- readonly height?: number;
16104
- /** Diameter of both ends. */
16105
- readonly diameter?: number;
16106
- /** Diameter of the top cap, overriding `diameter` — a cone is `diameterTop: 0`. */
16107
- readonly diameterTop?: number;
16108
- /** Diameter of the bottom cap, overriding `diameter`. */
16109
- readonly diameterBottom?: number;
16110
- /** Radial segment count. */
16111
- readonly tessellation?: number;
16112
- }
16113
- /**
16114
- * How {@link MeshAsset.capsule} sizes its capsule, which stands along Y.
16115
- *
16116
- * @remarks
16117
- * `height` is the **total** height including both caps, the same convention `@ignifx/physics` uses
16118
- * for a capsule collider, so one pair of numbers describes both.
16119
- *
16120
- * @public
16121
- */
16122
- interface CapsuleMeshOptions {
16123
- /** Total height including both caps, in metres. */
16124
- readonly height?: number;
16125
- /** Radius of the body and the caps. */
16126
- readonly radius?: number;
16127
- /** Radial segment count. */
16128
- readonly tessellation?: number;
16129
- }
16130
- /**
16131
- * How {@link MeshAsset.torus} sizes its ring, which lies in the XZ plane.
16132
- *
16133
- * @public
16134
- */
16135
- interface TorusMeshOptions {
16136
- /** Outer diameter, in metres. */
16137
- readonly diameter?: number;
16138
- /** Tube thickness, in metres. */
16139
- readonly thickness?: number;
16140
- /** Segment count around the ring. */
16141
- readonly tessellation?: number;
16142
- }
16143
- /**
16144
- * Raw vertex data for {@link MeshAsset.fromData}.
16145
- *
16146
- * @remarks
16147
- * Lite keeps references to these arrays rather than copying them — they are what its CPU ray pick
16148
- * and its bounds read (`lib/mesh/mesh-factories.js`). Mutating one behind Lite's back changes what
16149
- * a pick reports without changing what the GPU draws; the sanctioned way to change geometry after
16150
- * the fact is {@link MeshAsset.updatePositions} and its three siblings, which re-upload, keep this
16151
- * copy in step, and re-fit the bounds.
16152
- *
16153
- * @public
16154
- */
16155
- interface MeshGeometryData {
16156
- /** Three floats per vertex. */
16157
- readonly positions: Float32Array;
16158
- /** Three floats per vertex, one normal each. */
16159
- readonly normals: Float32Array;
16160
- /** Three indices per triangle. */
16161
- readonly indices: Uint32Array;
16162
- /** Two floats per vertex, or omitted for a mesh with no texture coordinates. */
16163
- readonly uvs?: Float32Array;
16164
- /**
16165
- * Two floats per vertex for the second UV set (`uv2` in a shader), or omitted. Lightmaps, baked
16166
- * ambient occlusion, and the parent-LOD height a terrain morph reads all ride here.
16167
- */
16168
- readonly uvs2?: Float32Array;
16169
- /** Four floats per vertex — `xyz` plus a handedness `w` — or omitted. A normal map needs them. */
16170
- readonly tangents?: Float32Array;
16171
- /**
16172
- * Four floats per vertex, linear RGBA, or omitted. A material has to be one that reads the colour
16173
- * attribute; set `hasVertexAlpha` on the Lite mesh if the alpha is meant to blend.
16174
- */
16175
- readonly colors?: Float32Array;
16176
- }
16177
- /**
16178
- * The Babylon Lite objects a {@link MeshAsset} owns. Unstable escape hatch
16179
- * (`docs/architecture/00-overview.md` §3).
16180
- *
16181
- * @public
16182
- */
16183
- interface MeshAssetLiteHandles {
16184
- /** The template mesh, or `null` under a headless app, which uploads no geometry. */
16185
- readonly mesh: LiteMesh | null;
17014
+ interface ModelInstantiation {
17015
+ /** The cloned container root, parented under the entity's node. */
17016
+ readonly root: LiteSceneNode;
17017
+ /** Every named node in the clone, keyed by its glTF node name. */
17018
+ readonly nodes: ReadonlyMap<string, LiteSceneNode>;
16186
17019
  }
16187
17020
  /**
16188
- * A geometry template a `MeshRenderer` draws (`docs/architecture/07-rendering.md` §2.3).
16189
- *
16190
- * @remarks
16191
- * Build one with a primitive factory or {@link MeshAsset.fromData}; each returns the handle the
16192
- * `MeshRenderer.mesh` field takes. A mesh that came from a file arrives as part of a `ModelAsset`
16193
- * instead — a glTF is a tree of meshes, materials, and animations, not one buffer.
17021
+ * A loaded glTF or GLB file (`docs/architecture/05-assets-and-loading.md` §5).
16194
17022
  *
16195
17023
  * @example
16196
17024
  * ```ts
16197
- * const box = MeshAsset.box(app, { size: 2 }); // one reference, owned by this code
16198
- * const cube = app.world.createEntity("Cube");
16199
- * cube.addComponent(MeshRenderer, { mesh: box }); // the field takes no reference
16200
- * // Once nothing draws the box any more:
16201
- * box.release();
17025
+ * const hero = await app.assets.loadAsync<ModelAsset>("models/hero.glb");
17026
+ * hero.value.animations.map((clip) => clip.name);
16202
17027
  * ```
16203
17028
  *
16204
17029
  * @public
16205
17030
  */
16206
- export declare class MeshAsset {
17031
+ export declare class ModelAsset {
16207
17032
  #private;
16208
- /** The type name the asset service registers meshes under. */
17033
+ /** The type name the asset service registers models under. */
16209
17034
  static assetType: string;
16210
- /** A human-readable name, used in diagnostics and as the Lite mesh's name. */
16211
- readonly name: string;
16212
- /**
16213
- * Wraps a template mesh. Use the static factories; the engine constructs assets.
16214
- *
16215
- * @param name - A human-readable name.
16216
- * @param mesh - The template, or `null` when the app is headless.
16217
- * @param scene - The scene the template is released through, or `null` when there is nothing to
16218
- * release.
16219
- * @param geometry - The vertex arrays the asset was built from, when it came from
16220
- * {@link MeshAsset.fromData}; `null` for a primitive, whose arrays Lite generated and never
16221
- * handed back. It is what makes the `update*` methods legal.
16222
- * @param engine - The engine an update writes through, or `null` under a headless app.
16223
- *
16224
- * @internal
16225
- */
16226
- constructor(name: string, mesh: LiteMesh | null, scene: LiteScene | null, geometry?: MeshGeometryData | null, engine?: LiteEngine | null);
16227
- /**
16228
- * The Babylon Lite objects the asset owns. Unstable escape hatch
16229
- * (`docs/architecture/00-overview.md` §3).
16230
- *
16231
- * @returns The template mesh, or `null` under a headless app.
16232
- */
16233
- get lite(): MeshAssetLiteHandles;
16234
- /**
16235
- * Whether the template's GPU buffers have been released.
16236
- *
16237
- * @returns `true` once {@link MeshAsset.dispose} has run.
16238
- */
16239
- get isDisposed(): boolean;
17035
+ /** The address the model was loaded from. */
17036
+ readonly address: string;
16240
17037
  /**
16241
- * How many vertices the geometry has.
17038
+ * The clips the file declared, stripped from the container so Lite never ticks them.
16242
17039
  *
16243
17040
  * @remarks
16244
- * Known for a mesh built with {@link MeshAsset.fromData} — headless included — and `0` for a
16245
- * primitive: Lite generates a primitive's arrays internally and 1.27.0's `Mesh` exposes no vertex
16246
- * count, only the opaque `MeshGPU` handle it says a user never touches (`index.d.ts` 7230).
17041
+ * Unstable: these are Lite's own animation groups, handed on to `@ignifx/3d`'s `Animator`, and
17042
+ * they are excluded from the stability guarantees of `CONSTITUTION.md` Article IV. To core they
17043
+ * are read-only metadata: nothing here advances or re-binds them.
16247
17044
  *
16248
- * @returns The vertex count, or `0`.
17045
+ * @beta
16249
17046
  */
16250
- get vertexCount(): number;
17047
+ readonly animations: readonly LiteAnimationGroup[];
16251
17048
  /**
16252
- * How many indices the geometry has — three per triangle.
17049
+ * The skeletons the file declared. Empty unless the `boneControl` rendering feature was on before
17050
+ * the load, because Lite builds them only then (`index.d.ts` 653).
16253
17051
  *
16254
- * @returns The index count, or `0`; see {@link MeshAsset.vertexCount}.
17052
+ * @beta
16255
17053
  */
16256
- get indexCount(): number;
17054
+ readonly skeletons: readonly LiteSkeleton[];
16257
17055
  /**
16258
- * Re-uploads vertex positions and re-fits the bounds.
16259
- *
16260
- * @remarks
16261
- * Only a mesh from {@link MeshAsset.fromData} can be updated, and only while nothing has cloned it:
16262
- * Lite refuses to write a vertex buffer with more than one owner, and a `MeshRenderer` clone is a
16263
- * second owner.
16264
- *
16265
- * Lite's `updateMeshPositions` writes the GPU buffer and stops there, so this also copies the range
16266
- * into the asset's own position array — the one Lite retained and CPU picking reads — and rewrites
16267
- * the bounds from the whole of it, `O(vertexCount)` per call. Passing the asset's own array skips
16268
- * the copy.
17056
+ * Wraps a loaded container. The `model` loader constructs these.
16269
17057
  *
16270
- * @param data - Three floats per vertex, read from index 0.
16271
- * @param vertexOffset - The first vertex to overwrite. Defaults to `0`.
16272
- * @param vertexCount - How many vertices to write. Defaults to as many as `data` holds.
16273
- * @throws IgnifxError with code `IGX-0702` when the mesh did not come from
16274
- * {@link MeshAsset.fromData}, or has been disposed.
16275
- * @throws IgnifxError with code `IGX-0725` when the range falls outside the mesh or `data` is too
16276
- * short for it.
17058
+ * @param address - The address it was loaded from.
17059
+ * @param container - The template container, or `null` when the app is headless.
17060
+ * @param animations - The clips taken off the container.
17061
+ * @param skeletons - The skeletons the loader found.
17062
+ * @param scene - The scene the container is released through, or `null` when headless.
16277
17063
  *
16278
- * @example
16279
- * ```ts
16280
- * const grid = MeshAsset.fromData(app, "grid", { positions, normals, indices });
16281
- * positions[1] += 0.5;
16282
- * grid.value.updatePositions(positions);
16283
- * ```
17064
+ * @internal
16284
17065
  */
16285
- updatePositions(data: Float32Array, vertexOffset?: number, vertexCount?: number): void;
17066
+ constructor(address: string, container: LiteAssetContainer | null, animations: readonly LiteAnimationGroup[], skeletons: readonly LiteSkeleton[], scene: LiteScene | null);
16286
17067
  /**
16287
- * Re-uploads vertex normals.
16288
- *
16289
- * @remarks
16290
- * The same rules as {@link MeshAsset.updatePositions}, minus the bounds: a normal cannot move a
16291
- * bounding box. The range is copied into the asset's own normal array so that a later
16292
- * `updatePositions` sees a consistent mesh.
17068
+ * The Babylon Lite objects the asset owns. Unstable escape hatch.
16293
17069
  *
16294
- * @param data - Three floats per vertex.
16295
- * @param vertexOffset - The first vertex to overwrite. Defaults to `0`.
16296
- * @param vertexCount - How many vertices to write. Defaults to as many as `data` holds.
16297
- * @throws IgnifxError with code `IGX-0702` or `IGX-0725`; see
16298
- * {@link MeshAsset.updatePositions}.
17070
+ * @returns The template container, or `null` under a headless app.
16299
17071
  */
16300
- updateNormals(data: Float32Array, vertexOffset?: number, vertexCount?: number): void;
17072
+ get lite(): ModelAssetLiteHandles;
16301
17073
  /**
16302
- * Re-uploads texture coordinates.
16303
- *
16304
- * @remarks
16305
- * Lite makes the upload a **no-op** when the mesh was created without UVs, rather than an error,
16306
- * so a mesh whose `MeshGeometryData` named none silently ignores this. The range check still runs.
17074
+ * How many `Model` components currently hold a copy of this template.
16307
17075
  *
16308
- * @param data - Two floats per vertex.
16309
- * @param vertexOffset - The first vertex to overwrite. Defaults to `0`.
16310
- * @param vertexCount - How many vertices to write. Defaults to as many as `data` holds.
16311
- * @throws IgnifxError with code `IGX-0702` or `IGX-0725`; see
16312
- * {@link MeshAsset.updatePositions}.
17076
+ * @returns The live instance count.
16313
17077
  */
16314
- updateUvs(data: Float32Array, vertexOffset?: number, vertexCount?: number): void;
17078
+ get instanceCount(): number;
16315
17079
  /**
16316
- * Re-uploads vertex colours.
16317
- *
16318
- * @remarks
16319
- * Four floats per vertex, linear RGBA. A no-op on the GPU when the mesh was created without
16320
- * colours, exactly as {@link MeshAsset.updateUvs} is.
17080
+ * Clones the template under an entity's node.
16321
17081
  *
16322
- * @param data - Four floats per vertex.
16323
- * @param vertexOffset - The first vertex to overwrite. Defaults to `0`.
16324
- * @param vertexCount - How many vertices to write. Defaults to as many as `data` holds.
16325
- * @throws IgnifxError with code `IGX-0702` or `IGX-0725`; see
16326
- * {@link MeshAsset.updatePositions}.
17082
+ * @param parent - The entity's transform node, or `null` for world space.
17083
+ * @returns The cloned root and its named nodes, or `null` when there is nothing to clone — a
17084
+ * headless app, or a file that declared only lights.
16327
17085
  */
16328
- updateColors(data: Float32Array, vertexOffset?: number, vertexCount?: number): void;
17086
+ instantiate(parent: LiteSceneNode | null): ModelInstantiation | null;
17087
+ /** Records that one more `Model` holds a copy. */
17088
+ retainInstance(): void;
17089
+ /** Records that one fewer `Model` holds a copy. Releasing below zero is a no-op. */
17090
+ releaseInstance(): void;
16329
17091
  /**
16330
- * Releases the template's GPU buffers.
17092
+ * Releases the template's GPU resources.
16331
17093
  *
16332
17094
  * @remarks
16333
- * Lite exports no mesh disposer: a mesh's buffers are freed when it leaves its last scene, so the
16334
- * adapter adds the template to a scene and takes it straight out again
16335
- * (`src/lite/gpu/mesh.ts`). Clones still in a scene keep the shared buffers alive; what the
16336
- * template loses is the ability to be cloned again. Calling it twice is a no-op, and it is a
16337
- * no-op under a headless app, which has no buffers.
17095
+ * The container was never added to a scene, so the round trip `removeFromScene` needs is the same
17096
+ * one `MeshAsset.dispose` performs: this hands it to the scene and takes it straight back out,
17097
+ * which drops its share of every buffer. Clones still in a scene keep theirs. Calling it twice is
17098
+ * a no-op, and it is a no-op under a headless app.
16338
17099
  */
16339
17100
  dispose(): void;
16340
17101
  /** Releases the template when the asset leaves a `using` block. */
16341
17102
  [Symbol.dispose](): void;
16342
- /**
16343
- * Creates a box template and publishes it.
16344
- *
16345
- * @param app - The app whose engine uploads the geometry and whose asset service holds the handle.
16346
- * @param options - A uniform `size`, or per-axis dimensions.
16347
- * @returns The handle, with one holder — the caller.
16348
- *
16349
- * @example
16350
- * ```ts
16351
- * const box = MeshAsset.box(app, { width: 2, height: 1, depth: 3 });
16352
- * ```
16353
- */
16354
- static box(app: App, options?: BoxMeshOptions): AssetHandle<MeshAsset>;
16355
- /**
16356
- * Creates a sphere template and publishes it.
16357
- *
16358
- * @param app - The app that owns the engine and the asset service.
16359
- * @param options - Diameter and ring count.
16360
- * @returns The handle, with one holder.
16361
- */
16362
- static sphere(app: App, options?: SphereMeshOptions): AssetHandle<MeshAsset>;
16363
- /**
16364
- * Creates a quad template in the XY plane and publishes it.
16365
- *
16366
- * @param app - The app that owns the engine and the asset service.
16367
- * @param options - A uniform `size`, or width and height.
16368
- * @returns The handle, with one holder.
16369
- */
16370
- static plane(app: App, options?: PlaneMeshOptions): AssetHandle<MeshAsset>;
16371
- /**
16372
- * Creates a subdivided grid in the XZ plane and publishes it.
16373
- *
16374
- * @param app - The app that owns the engine and the asset service.
16375
- * @param options - Width, depth, subdivisions, and UV scale.
16376
- * @returns The handle, with one holder.
16377
- */
16378
- static ground(app: App, options?: GroundMeshOptions): AssetHandle<MeshAsset>;
16379
- /**
16380
- * Creates a cylinder template standing along Y and publishes it.
16381
- *
16382
- * @param app - The app that owns the engine and the asset service.
16383
- * @param options - Height, diameters, and tessellation.
16384
- * @returns The handle, with one holder.
16385
- */
16386
- static cylinder(app: App, options?: CylinderMeshOptions): AssetHandle<MeshAsset>;
16387
- /**
16388
- * Creates a capsule template standing along Y and publishes it.
16389
- *
16390
- * @param app - The app that owns the engine and the asset service.
16391
- * @param options - Total height, radius, and tessellation.
16392
- * @returns The handle, with one holder.
16393
- */
16394
- static capsule(app: App, options?: CapsuleMeshOptions): AssetHandle<MeshAsset>;
16395
- /**
16396
- * Creates a torus template in the XZ plane and publishes it.
16397
- *
16398
- * @param app - The app that owns the engine and the asset service.
16399
- * @param options - Diameter, thickness, and tessellation.
16400
- * @returns The handle, with one holder.
16401
- */
16402
- static torus(app: App, options?: TorusMeshOptions): AssetHandle<MeshAsset>;
16403
- /**
16404
- * Creates a template from raw vertex data and publishes it.
16405
- *
16406
- * @param app - The app that owns the engine and the asset service.
16407
- * @param name - A human-readable name.
16408
- * @param data - Positions, normals, indices, and any of the four optional attributes. Lite keeps
16409
- * references to the arrays; a caller that means to edit them afterwards does so through the
16410
- * `update*` methods, which keep Lite's own copy and its bounds in step.
16411
- * @returns The handle, with one holder.
16412
- *
16413
- * @example
16414
- * ```ts
16415
- * const triangle = MeshAsset.fromData(app, "triangle", {
16416
- * positions: Float32Array.from([0, 0, 0, 1, 0, 0, 0, 1, 0]),
16417
- * normals: Float32Array.from([0, 0, -1, 0, 0, -1, 0, 0, -1]),
16418
- * indices: Uint32Array.from([0, 1, 2]),
16419
- * });
16420
- * ```
16421
- */
16422
- static fromData(app: App, name: string, data: MeshGeometryData): AssetHandle<MeshAsset>;
16423
17103
  }
16424
17104
  //#endregion
17105
+ //#region src/render/loaders/model-loader.d.ts
17106
+ /**
17107
+ * The `model` asset loader (`docs/architecture/05-assets-and-loading.md` §5).
17108
+ *
17109
+ * ## Bytes, not a URL
17110
+ *
17111
+ * `loadGltf` accepts a URL, an `ArrayBuffer`, or a `Blob`. ignifx hands it an `ArrayBuffer` fetched
17112
+ * through `ctx.fetchBytes`, because that is where progress reporting, `AbortSignal` support, the
17113
+ * priority queue, and the retry policy live (§5). A `.glb` is one file, so this is lossless.
17114
+ *
17115
+ * A `.gltf` with **external** buffers and images is the one case where it is not: Lite would have to
17116
+ * resolve those relative URLs itself, which it can only do when it did the fetching. This loader
17117
+ * loads the container from bytes either way and therefore supports self-contained `.gltf` files and
17118
+ * `.glb`; a `.gltf` with siblings fails inside Lite and surfaces as `IGX-0505`. `.glb` is what the
17119
+ * asset pipeline produces, and the fix — passing the URL through for that one shape — is a
17120
+ * three-line change whenever a project needs it.
17121
+ *
17122
+ * ## Headless
17123
+ *
17124
+ * `loadGltf` throws a `TypeError` under the null engine: it uploads while parsing and reaches for
17125
+ * `engine._device` (ADR-0002 Validation). So a headless load skips it entirely and produces an
17126
+ * asset with no container — the `gpu: null` shape §5 requires — rather than failing. The bytes are
17127
+ * still fetched, so a headless test still exercises the address, the manifest, and the byte
17128
+ * counters.
17129
+ */
17130
+ /**
17131
+ * Builds the loader for `.glb` and `.gltf` addresses.
17132
+ *
17133
+ * @returns The loader to register with `ctx.registerAssetLoader`.
17134
+ *
17135
+ * @example
17136
+ * ```ts
17137
+ * ctx.registerAssetLoader(createModelLoader());
17138
+ * ```
17139
+ *
17140
+ * @public
17141
+ */
17142
+ export declare function createModelLoader(): AssetLoader<ModelAsset>;
17143
+ //#endregion
17144
+ //#region src/render/loaders/texture-loader.d.ts
17145
+ /**
17146
+ * The `texture` asset loader (`docs/architecture/05-assets-and-loading.md` §5).
17147
+ *
17148
+ * ## Lite fetches the bytes, not ignifx
17149
+ *
17150
+ * Every other GPU loader here reads through `ctx.fetchBytes`, which is what gives it progress,
17151
+ * cancellation, and retries. A texture cannot: `loadTexture2D` takes a **URL** and decodes it with
17152
+ * `createImageBitmap`, which is the browser's own hardware-accelerated decode path
17153
+ * (`src/lite/gpu/texture.ts`). Handing it bytes would mean decoding a PNG in JavaScript. So the
17154
+ * loader hands Lite `ctx.url` and reports its own coarse progress instead, and a texture's
17155
+ * `AbortSignal` stops the *request* rather than the fetch. The trade is deliberate and it is the
17156
+ * one place §5's "the three `fetch*` methods are the only network paths" does not hold; the
17157
+ * alternative is worse.
17158
+ *
17159
+ * ## Options come from the sidecar
17160
+ *
17161
+ * `.meta.json` sidecars carry per-asset import options (§7), the build copies them into the
17162
+ * manifest entry, and `ctx.meta` is how a loader reads its own block. sRGB is the one that matters:
17163
+ * a base-colour or emissive texture wants it, and a normal, ORM, or data map must not have it.
17164
+ */
17165
+ /**
17166
+ * Builds the loader for `.png`, `.jpg`, `.jpeg`, `.webp`, `.ktx2`, and `.basis` addresses.
17167
+ *
17168
+ * @returns The loader to register with `ctx.registerAssetLoader`.
17169
+ *
17170
+ * @example
17171
+ * ```ts
17172
+ * ctx.registerAssetLoader(createTextureLoader());
17173
+ * ```
17174
+ *
17175
+ * @public
17176
+ */
17177
+ export declare function createTextureLoader(): AssetLoader<TextureAsset>;
17178
+ //#endregion
17179
+ //#region src/render/mesh-file.d.ts
17180
+ /**
17181
+ * The `.mesh.json` file format (ADR-0029): one primitive and the options its `MeshAsset` factory
17182
+ * takes, so a scene file can name a primitive by address.
17183
+ *
17184
+ * ```json
17185
+ * { "format": "ignifx.mesh", "formatVersion": 1, "primitive": "box", "options": { "size": 1 } }
17186
+ * ```
17187
+ *
17188
+ * One table, {@link MESH_PRIMITIVE_OPTIONS}, drives the runtime check and the JSON Schema, so the
17189
+ * two cannot drift apart.
17190
+ */
17191
+ /**
17192
+ * The `format` header a `.mesh.json` carries.
17193
+ *
17194
+ * @public
17195
+ */
17196
+ export declare const MESH_FILE_FORMAT = "ignifx.mesh";
17197
+ /**
17198
+ * The only `.mesh.json` `formatVersion` this build reads.
17199
+ *
17200
+ * @public
17201
+ */
17202
+ export declare const MESH_FORMAT_VERSION = 1;
17203
+ /**
17204
+ * The address suffix that selects the mesh loader.
17205
+ *
17206
+ * @public
17207
+ */
17208
+ export declare const MESH_FILE_EXTENSION = ".mesh.json";
17209
+ /**
17210
+ * What a primitive option holds: a length in metres (finite, zero or more), a segment count
17211
+ * (a whole number, one or more), or a pair of finite numbers.
17212
+ *
17213
+ * @public
17214
+ */
17215
+ type MeshOptionKind = "length" | "count" | "pair";
17216
+ /**
17217
+ * For each primitive, every option its factory's options type declares, and what it holds.
17218
+ *
17219
+ * @public
17220
+ */
17221
+ type MeshPrimitiveOptionKinds = { readonly [P in MeshPrimitive]: { readonly [K in keyof Extract<MeshPrimitiveDefinition, {
17222
+ readonly primitive: P;
17223
+ }>["options"]]-?: MeshOptionKind; }; };
17224
+ /**
17225
+ * Every option each primitive takes, and what it holds. The keys are exactly the fields of the
17226
+ * factory's options type (`BoxMeshOptions`, …); the compiler checks that.
17227
+ *
17228
+ * @public
17229
+ */
17230
+ export declare const MESH_PRIMITIVE_OPTIONS: MeshPrimitiveOptionKinds;
17231
+ /**
17232
+ * The JSON Schema `@ignifx/vite-plugin` validates `.mesh.json` files against, built from
17233
+ * {@link MESH_PRIMITIVE_OPTIONS}.
17234
+ *
17235
+ * @returns The schema document.
17236
+ *
17237
+ * @example
17238
+ * ```ts
17239
+ * // vite.config.ts
17240
+ * ignifx({ schemas: { formats: { [MESH_FILE_FORMAT]: meshFileJsonSchema() } } });
17241
+ * ```
17242
+ *
17243
+ * @public
17244
+ */
17245
+ export declare function meshFileJsonSchema(): JsonSchemaObject;
17246
+ //#endregion
16425
17247
  //#region src/render/mesh-renderer.d.ts
16426
17248
  /**
16427
17249
  * The `MeshRenderer` component (`docs/architecture/07-rendering.md` §2.3): one clone of a
@@ -17420,11 +18242,19 @@ export declare class PostProcessStack extends Component implements ComponentHook
17420
18242
  *
17421
18243
  * The harness requires every key to be a namespaced `<package>/<Name>` type id
17422
18244
  * (`scripts/lib/schema-source.ts` rejects a key with no `/`), and it groups entries onto a page by
17423
- * their `format`. A *file* format is not a component and has no type id, so the three file formats
17424
- * below are keyed `ignifx/scene-file`, `ignifx/material-file`, and `ignifx/environment-file` while
17425
- * declaring `format: "ignifx.scene"`, `"ignifx.material"`, and `"ignifx.environment"`. The wave-1
18245
+ * their `format`. A *file* format is not a component and has no type id, so the file formats
18246
+ * below are keyed `ignifx/scene-file`, `ignifx/material-file`, `ignifx/environment-file`, and
18247
+ * `ignifx/mesh-file` while declaring `format: "ignifx.scene"`, `"ignifx.material"`,
18248
+ * `"ignifx.environment"`, and `"ignifx.mesh"`. The wave-1
17426
18249
  * hand-off asked for the key `"ignifx.scene"`; that key fails the namespacing check, and the
17427
18250
  * grouping — which is what actually decides the page — comes from `format` either way.
18251
+ *
18252
+ * ## The transform
18253
+ *
18254
+ * `ignifx/Transform` is described like a component, from `transformSchema()`, though its class
18255
+ * declares no schema: it is the scene file's per-entity `transform` block. Its entry is the only one
18256
+ * that sets `builtIn` (with `allowMultiple: false` and `package: "@ignifx/core"`), so an editor
18257
+ * shows it with the components but never offers to add or remove it.
17428
18258
  */
17429
18259
  /**
17430
18260
  * Describes every component and file format this package declares, for the documentation harness.
@@ -17458,105 +18288,14 @@ export declare function describeMaterialFileFormat(): SchemaDescription;
17458
18288
  * @public
17459
18289
  */
17460
18290
  export declare function describeEnvironmentFileFormat(): SchemaDescription;
17461
- //#endregion
17462
- //#region src/serialization/load.d.ts
17463
- /**
17464
- * One recoverable problem found while a scene was being built. Nothing here stops the load: a file
17465
- * degrades one field, one reference, or one layer rather than failing whole
17466
- * (`docs/architecture/06-serialization-and-scene-format.md` §4).
17467
- *
17468
- * @public
17469
- */
17470
- interface SceneLoadIssue {
17471
- /** The diagnostic code, for example `IGX-0602` or `IGX-0303`. */
17472
- readonly code: string;
17473
- /** The actionable sentence. */
17474
- readonly message: string;
17475
- }
17476
- /**
17477
- * Options accepted by {@link instantiateScene}.
17478
- *
17479
- * @public
17480
- */
17481
- interface InstantiateSceneOptions {
17482
- /** The entity the scene's roots attach to; `null` or omitted makes them roots of `scene`. */
17483
- readonly parent?: Entity | null;
17484
- /** The instance that owns the new entities; defaults to the parent's, else `world.activeScene`. */
17485
- readonly scene?: SceneInstance;
17486
- /**
17487
- * `true` treats the whole file as one instance: every entity gets a fresh uid and an
17488
- * `Entity.prefab` link. This is what `world.instantiate` does; `world.loadScene` leaves it off so
17489
- * that the scene's own entities keep the uids the file gave them
17490
- * (`docs/architecture/02-scene-graph.md` §10).
17491
- */
17492
- readonly asInstance?: boolean;
17493
- /** The handle the scene was loaded through, recorded on `Entity.prefab` when `asInstance`. */
17494
- readonly assetHandle?: AssetHandle<SceneAsset> | null;
17495
- /**
17496
- * The entity that stands for the instance when `asInstance` is set and the file has more or fewer
17497
- * than one root. `world.instantiate` creates it and passes it as both `parent` and `rootEntity`,
17498
- * so that the call still answers with one entity.
17499
- */
17500
- readonly rootEntity?: Entity | null;
17501
- /** `true` turns an `IGX-0604` hash mismatch from a diagnostic into a throw. */
17502
- readonly strictInstanceHashes?: boolean;
17503
- }
17504
- /**
17505
- * What {@link instantiateScene} produced.
17506
- *
17507
- * @public
17508
- */
17509
- interface SceneBuildResult {
17510
- /** The entities that ended up parentless within the built subtree, in file order. */
17511
- readonly roots: readonly Entity[];
17512
- /** The file-local uid to runtime object table (`docs/architecture/02-scene-graph.md` §10). */
17513
- readonly remap: UidRemap;
17514
- /** Every recoverable problem, in discovery order. */
17515
- readonly issues: readonly SceneLoadIssue[];
17516
- }
17517
- /**
17518
- * Builds the entities of a scene asset into a world — steps 3 to 6 of the loading algorithm
17519
- * (`docs/architecture/06-serialization-and-scene-format.md` §4). It is synchronous and does no I/O:
17520
- * every asset the file references is already loaded, which is what a `SceneAsset` guarantees.
17521
- *
17522
- * @remarks
17523
- * The mechanism that keeps `awake` honest is worth stating, because §4 step 6 and
17524
- * `01-lifecycle-and-time.md` §4 state only the outcome. Entities are created with `active: false`,
17525
- * so the enable transition computes "not effectively enabled" and queues nothing. Components are
17526
- * attached with their schema defaults, then every component's props are decoded — that is where
17527
- * `entityRef` and `componentRef` resolve, through a table that by then holds the whole scene. Only
17528
- * then does a last pass write each entity's file `active` value in tree order, which is what queues
17529
- * `awake` and `onEnable`, parents before children. Nothing observes the half-built scene, because
17530
- * all of this runs in one synchronous block.
17531
- *
17532
- * @param world - The world to build into.
17533
- * @param asset - The scene to build.
17534
- * @param options - Where to attach the result, and how to treat instance hashes.
17535
- * @returns The roots, the uid table, and every recoverable problem.
17536
- * @throws IgnifxError with code `IGX-0302` on an instance cycle, `IGX-0307` when the file names an
17537
- * unregistered component type, and `IGX-0604` when `strictInstanceHashes` is set and a recorded
17538
- * instance hash does not match.
17539
- *
17540
- * @example
17541
- * ```ts
17542
- * const built = instantiateScene(world, sceneAsset, { scene: world.activeScene });
17543
- * const player = built.remap.entity("01J9Z6M7E5S3A0V2Q4R8T1Y6WX");
17544
- * ```
17545
- *
17546
- * @public
17547
- */
17548
- export declare function instantiateScene(world: World, asset: SceneAsset, options?: InstantiateSceneOptions): SceneBuildResult;
17549
18291
  /**
17550
- * Checks that every scene a file instances — at any depth — is among the loaded dependencies, which
17551
- * is what makes `world.instantiate` safe to be synchronous
17552
- * (`docs/architecture/02-scene-graph.md` §2).
18292
+ * Describes the `ignifx.mesh` file format (ADR-0029).
17553
18293
  *
17554
- * @param asset - The scene to check.
17555
- * @throws IgnifxError with code `IGX-0301` naming the first instanced scene that is not loaded.
18294
+ * @returns The description of the top-level file fields.
17556
18295
  *
17557
18296
  * @public
17558
18297
  */
17559
- export declare function assertSceneDependenciesLoaded(asset: SceneAsset): void;
18298
+ export declare function describeMeshFileFormat(): SchemaDescription;
17560
18299
  //#endregion
17561
18300
  //#region src/serialization/overrides.d.ts
17562
18301
  /**
@@ -17670,6 +18409,43 @@ interface SceneLoaderOptions {
17670
18409
  * @public
17671
18410
  */
17672
18411
  export declare function createSceneLoader(options?: SceneLoaderOptions): AssetLoader<SceneAsset>;
18412
+ /**
18413
+ * Options accepted by {@link loadSceneDependencies}.
18414
+ *
18415
+ * @public
18416
+ */
18417
+ interface LoadSceneDependenciesOptions {
18418
+ /** Aborts every request; the handles already loaded are released before the promise rejects. */
18419
+ readonly signal?: AbortSignal;
18420
+ }
18421
+ /**
18422
+ * Loads every asset a scene file references — in `settings`, in every component's `props`, and in
18423
+ * every `instance.scene`, recursively through the scenes those pull in — the walk the scene loader
18424
+ * runs before it builds anything (`docs/architecture/06-serialization-and-scene-format.md` §4
18425
+ * step 2).
18426
+ *
18427
+ * @remarks
18428
+ * It is the half of the scene loader a file that is already in memory needs: pass the result to
18429
+ * `createSceneAsset` and the asset can be built synchronously with `instantiateScene`. Each handle
18430
+ * is returned with one holder, which the caller owns: release them all when the scene they serve
18431
+ * is gone. `world.loadSceneFile` does that for a whole scene.
18432
+ *
18433
+ * @param assets - The asset service to load through, normally `app.assets`.
18434
+ * @param file - The scene file.
18435
+ * @param options - Cancellation.
18436
+ * @returns The loaded handles, deduplicated by address, in the loader's order.
18437
+ * @throws Whatever the asset service rejects a load with (an `AssetLoadError`); every handle
18438
+ * loaded by then is released first.
18439
+ *
18440
+ * @example
18441
+ * ```ts
18442
+ * const dependencies = await loadSceneDependencies(app.assets, file);
18443
+ * const asset = await createSceneAsset("memory:scene/draft", file, dependencies);
18444
+ * ```
18445
+ *
18446
+ * @public
18447
+ */
18448
+ export declare function loadSceneDependencies(assets: Assets, file: SceneFile, options?: LoadSceneDependenciesOptions): Promise<readonly AssetHandle[]>;
17673
18449
  //#endregion
17674
18450
  //#region src/serialization/serialize.d.ts
17675
18451
  /**
@@ -17813,6 +18589,39 @@ interface SceneFileIssue {
17813
18589
  */
17814
18590
  export declare function validateSceneFile(value: unknown): readonly SceneFileIssue[];
17815
18591
  //#endregion
18592
+ //#region src/schema/describe-registry.d.ts
18593
+ /**
18594
+ * Describes every component an app has registered, the engine's, its extensions' and the game's,
18595
+ * the way {@link describeSchema} describes one, plus what only the registry knows: whether an
18596
+ * entity may hold more than one (`allowMultiple`) and which package registered it (`package`).
18597
+ * This is what an external inspector, such as the ignifx editor, is generated from.
18598
+ *
18599
+ * @remarks
18600
+ * `package` is the `name` of the extension whose `register(ctx)` registered the class, which is the
18601
+ * npm package name for a published extension (`@ignifx/core`, `@ignifx/3d`). A class the game
18602
+ * registered itself with `app.registerComponents` has no extension, so its `package` is its type
18603
+ * id's namespace: everything before the last `/` (`third-person` for `third-person/Beacon`).
18604
+ *
18605
+ * `ignifx/Transform` declares no schema on its class; it is described with {@link transformSchema}
18606
+ * and marked `builtIn`, because every entity carries exactly one and a scene file stores it as the
18607
+ * entity's `transform` block rather than in its `components`.
18608
+ *
18609
+ * @param registry - The registry to walk, usually `app.world.registry`.
18610
+ * @param curated - Titles, formats and summaries by type id, for example a package's own
18611
+ * `describeSchemas()`; a component without an entry is titled from its type id.
18612
+ * @returns The descriptions, keyed by type id, in registration order.
18613
+ *
18614
+ * @example
18615
+ * ```ts
18616
+ * const schemas = describeRegisteredSchemas(app.world.registry, describeSchemas());
18617
+ * schemas["ignifx/Camera"]?.package; // "@ignifx/core"
18618
+ * schemas["ignifx/Camera"]?.allowMultiple; // false
18619
+ * ```
18620
+ *
18621
+ * @public
18622
+ */
18623
+ export declare function describeRegisteredSchemas(registry: ComponentRegistry, curated?: Readonly<Record<string, SchemaDescriptionMeta>>): Readonly<Record<string, SchemaDescription>>;
18624
+ //#endregion
17816
18625
  //#region src/schema/field-kinds.d.ts
17817
18626
  /**
17818
18627
  * Declares a single-precision floating point field.
@@ -18352,6 +19161,83 @@ export declare function waitUntil(predicate: () => boolean): WaitInstruction;
18352
19161
  */
18353
19162
  export declare function waitWhile(predicate: () => boolean): WaitInstruction;
18354
19163
  //#endregion
19164
+ //#region src/settings/describe-settings.d.ts
19165
+ /**
19166
+ * The `format` every settings section description carries, so a consumer that merges settings and
19167
+ * component descriptions can tell them apart.
19168
+ *
19169
+ * @public
19170
+ */
19171
+ export declare const SETTINGS_DESCRIPTION_FORMAT = "settings";
19172
+ /**
19173
+ * Describes every project settings section an app has registered (core's own `layers`,
19174
+ * `sortingLayers`, `time`, `assets` and `rendering`, and every section an extension declared with
19175
+ * `ctx.registerSettings`) in the same shape {@link describeRegisteredSchemas} describes components.
19176
+ * This is what an external settings panel, such as the ignifx editor's, is generated from.
19177
+ *
19178
+ * @remarks
19179
+ * Each entry is keyed and titled by its section name, has `format: "settings"`
19180
+ * ({@link SETTINGS_DESCRIPTION_FORMAT}), and names the extension that registered it as `package`
19181
+ * (`@ignifx/core`, `@ignifx/physics`). A field's `default` is the value the owner registered for it,
19182
+ * which is what the project gets when it omits the field; a field the owner's defaults leave out has
19183
+ * no `default`, because the resolved section has no value for it either.
19184
+ *
19185
+ * Defaults are in the **settings form**, the form `createApp` reads, which differs from the scene
19186
+ * file's for vectors and colours: a `vec3` default is `{ "x": 0, "y": -9.81, "z": 0 }` and a `color`
19187
+ * default is `{ "r": 0, "g": 0, "b": 0, "a": 1 }`, not an array. A tool writes values back in this
19188
+ * form.
19189
+ *
19190
+ * The registration seam is `ctx.registerSettings(section, schema, defaults)`: an extension that
19191
+ * declares a section there is described here with no further work. A section is written in project
19192
+ * settings (`ignifx.settings.json` or `ignifx.config.ts`) as an object of these fields; a section
19193
+ * with exactly one field of a non-object kind (a number, string, enum or array, not a vector or
19194
+ * colour) may also be written as that field's value.
19195
+ *
19196
+ * @param app - The app whose sections to describe; its extensions have all registered by the time
19197
+ * `createApp` resolves.
19198
+ * @returns The descriptions, keyed by section name, in registration order.
19199
+ * @throws IgnifxError with code `IGX-0702` when `app` was not created by this copy of
19200
+ * `@ignifx/core`.
19201
+ *
19202
+ * @example
19203
+ * ```ts
19204
+ * const sections = describeSettings(app);
19205
+ * sections["time"]?.package; // "@ignifx/core"
19206
+ * sections["time"]?.fields["fixedDeltaTime"]?.default; // 0.016666666666666666
19207
+ * ```
19208
+ *
19209
+ * @public
19210
+ */
19211
+ export declare function describeSettings(app: App): Readonly<Record<string, SchemaDescription>>;
19212
+ /**
19213
+ * Generates the JSON Schema (draft 2020-12) of a project's settings object, the content of
19214
+ * `ignifx.settings.json`, from every section the app registered. Pass it to the Vite plugin as
19215
+ * `ignifx({ schemas: { settings } })` to validate the project settings at build time, or associate
19216
+ * it with `ignifx.settings.json` in a text editor.
19217
+ *
19218
+ * @remarks
19219
+ * The schema describes the settings form `createApp` reads (vectors as `{ x, y, z }`, colours as
19220
+ * `{ r, g, b, a }` with every channel required), so a document it accepts also passes `createApp`'s
19221
+ * own validation (`IGX-0408`). Every section is optional and a section omitted takes its defaults.
19222
+ * An unknown key inside a section is a violation. The top level stays open: a section this app did
19223
+ * not register, perhaps one of an extension it lacks, is left to `createApp`, which reports it
19224
+ * (`IGX-0407`), and to the Vite plugin, which warns about it.
19225
+ *
19226
+ * @param app - The app whose sections to describe.
19227
+ * @returns The object schema, one property per section.
19228
+ * @throws IgnifxError with code `IGX-0702` when `app` was not created by this copy of
19229
+ * `@ignifx/core`.
19230
+ *
19231
+ * @example
19232
+ * ```ts
19233
+ * const schema = settingsJsonSchema(app);
19234
+ * Object.keys(schema["properties"] ?? {}); // ["layers", "sortingLayers", "time", "assets", "rendering"]
19235
+ * ```
19236
+ *
19237
+ * @public
19238
+ */
19239
+ export declare function settingsJsonSchema(app: App): JsonSchemaObject;
19240
+ //#endregion
18355
19241
  //#region src/storage/memory-backend.d.ts
18356
19242
  /**
18357
19243
  * The in-memory storage backend: the default for a headless app, and the one every unit test in the
@@ -18523,6 +19409,36 @@ export declare class IndexedDbStorageBackend implements StorageBackend {
18523
19409
  dispose(): void;
18524
19410
  }
18525
19411
  //#endregion
19412
+ //#region src/transform/transform-schema.d.ts
19413
+ /**
19414
+ * The entity transform as a schema: the fields of a scene file's `transform` block, so an
19415
+ * inspector and its ops can treat the transform like any component
19416
+ * (`docs/architecture/06-serialization-and-scene-format.md` §2).
19417
+ *
19418
+ * @remarks
19419
+ * The schema **describes** the transform; {@link (Transform:class)} does not declare it. The class keeps
19420
+ * no schema because its `position` and `rotation` are world-space getters, while the file, this
19421
+ * schema, and the editor's `setTransform` op all carry **local** values. Every entity has exactly
19422
+ * one transform, which is never in a file's `components` list, so `describeSchemas()` and
19423
+ * `describeRegisteredSchemas()` mark `ignifx/Transform` as `builtIn`: it cannot be added or
19424
+ * removed, and its values are edited as the whole block, not with a per-prop op.
19425
+ *
19426
+ * `rotation` is a `quat` field: files and ops store a unit quaternion, and an inspector shows
19427
+ * intrinsic XYZ Euler angles in degrees (ADR-0011), so its `step` is in degrees.
19428
+ *
19429
+ * @returns A new schema: `position` (`vec3`, origin, step 0.01), `rotation` (`quat`, identity,
19430
+ * step 0.5 degrees), `scale` (`vec3`, one, step 0.01).
19431
+ *
19432
+ * @example
19433
+ * ```ts
19434
+ * const fields = describeSchema("ignifx/Transform", transformSchema()).fields;
19435
+ * fields["rotation"]?.default; // [0, 0, 0, 1]
19436
+ * ```
19437
+ *
19438
+ * @public
19439
+ */
19440
+ export declare function transformSchema(): Schema;
19441
+ //#endregion
18526
19442
  //#region src/tween/tween-system.d.ts
18527
19443
  /**
18528
19444
  * The `PostUpdate` system that advances `app.tweens` (`docs/architecture/01-lifecycle-and-time.md`
@@ -18543,5 +19459,5 @@ export declare class IndexedDbStorageBackend implements StorageBackend {
18543
19459
  */
18544
19460
  export declare const TWEEN_SYSTEM_ORDER = -100;
18545
19461
  //#endregion
18546
- export type { App, AppEvents, AppLiteHandles, AppSettings, ArrayFieldSpec, AssetFieldSpec, AssetHandle, AssetLoadErrorOptions, AssetLoader, AssetManifest, AssetManifestEntry, AssetProgress, AssetRef, AssetRefValue, AssetState, AssetTypeDefinition, AssetTypeToken, Assets, AssetsCreateOptions, AssetsSettings, BatchHandle, BloomEffectSettings, BoolFieldSpec, BoxMeshOptions, CameraProjection, CanvasAlphaMode, CapsuleMeshOptions, Clock, ColorFieldSpec, ColorLike, ComponentClassInfo, ComponentDefinition, ComponentHandle, ComponentHooks, ComponentInit, ComponentInitValue, ComponentRefFieldSpec, ComponentReplacement, ComponentStatics, ComponentType, ComponentTypeToken, ConcreteComponentType, ConnectOptions, ConsoleLike, ConsoleSinkOptions, Coroutine, CoroutineHandle, CoroutineHost, CoroutineYield, CreateAppOptions, CreateEntityOptions, CurveFieldSpec, CurveKey, CurveValue, CustomEffectInit, CustomEffectSettings, CustomFieldCodec, CustomFieldSpec, CylinderMeshOptions, DecodeResult, DeferredQueue, DeviceLostInfo, DiagnosticsGroup, DiagnosticsOptions, Disconnect, EasingFunction, EasingName, EntityHandle, EntityOverrideField, EntityPrefabLink, EntityRefFieldSpec, EnumFieldSpec, EnvironmentAssetLiteHandles, EnvironmentDefinition, EnvironmentFogMode, EnvironmentFogSettings, EnvironmentSkyboxSettings, ErrorCode, ErrorCodeDescription, ErrorCodeRegistry, ErrorContext, ErrorFormatMode, ErrorReport, Extension, ExtensionContext, FetchLike, FieldDefinition, FieldOptions, FieldSpec, FieldsOf, FileStorageOptions, FontAssetLiteHandles, FrameSample, FrameState, GpuAdapterInfo, GroundMeshOptions, HotReloadHost, HotReloadKind, HotReloadModule, HotReloadOptions, HotReloadPolicy, HotReloadReport, HotReloadStatics, IgnifxErrorOptions, IgnifxUniformName, ImageProcessingEffectSettings, ImageProcessingSettings, InstanceRange, InstancedMeshLod, InstancedMeshRendererLiteHandles, InstantiateOptions, InstantiateSceneOptions, JsonArray, JsonObject, JsonSchemaObject, JsonValue, LayerMaskFieldSpec, LayersSettings, LightShadowSettings, LightType, LiteAnimationGroup, LiteAssetContainer, LiteCamera, LiteEngine, LiteEnvironmentTextures, LiteFont, AdapterLight as LiteLight, LiteMaterial, LiteMaterialPluginPoint, LiteMesh, LitePbrMaterial, LiteScene, LiteSceneNode, LiteShaderMaterial, LiteShadowGenerator, LiteSkeleton, LiteStandardMaterial, LiteStorageBuffer, LiteSystemUniformName, LiteTexture2D, LoadOptions, LoadProgress, LoadSceneOptions, LoaderContext, LogRecord, LogSink, LogThreshold, Logger, LoggerOptions, ManualClock, MapFieldSpec, Mat4Elements, Mat4Like, MaterialAlphaMode, MaterialAssetLiteHandles, MaterialDefinition, MaterialKind, MaterialPluginDefinition, MaterialPluginDefinitionInit, MemorySink, MeshAssetLiteHandles, MeshGeometryData, ModelAssetLiteHandles, ModelInstantiation, MutableQuat, MutableVec2, MutableVec3, MutableVec4, NumberFieldSpec, OptionalFieldSpec, OverridePath, PartialFieldsOf, PbrMaterialDefinition, PhaseIndex, PixelTextureOptions, PlaneMeshOptions, PlatformInfo, PlatformKind, PlatformOs, ProfileScope, QuatLike, RandomSource, Ray, RayVector, RecordFieldSpec, ReferenceDecoder, ReferenceEncoder, RegisterAssetOptions, RegisterComponentOptions, RegisterSystemOptions, RenderCapture, RenderPick, RenderPickOptions, RenderSurface, RenderTaskTiming, RenderTaskTimings, Renderer, RenderingFeature, RenderingFeatureSettings, RenderingSettings, SceneAsset, SceneBuildResult, SceneFile, SceneFileAssetRef, SceneFileComponent, SceneFileEntity, SceneFileInstance, SceneFileIssue, SceneFileOverride, SceneFileTransform, SceneLoadIssue, SceneLoaderOptions, Schema, SchemaDescription, SchemaDescriptionMeta, SchemaFieldDescription, SchemaIssue, ScriptCallbacks, ScriptClassInfo, ScriptDefinition, ScriptStatics, SerializeIssue, SerializeSceneOptions, ServiceClassKey, ServiceKey, ServiceNameKey, ServiceRegistry, SetParentOptions, SettingsInput, ShaderAttributeName, ShaderBlendMode, ShaderCullMode, ShaderDeclaration, ShaderDefineDeclaration, ShaderInstancingMode, ShaderKind, ShaderMaterialDefinition, ShaderMaterialDefinitionInput, ShaderPipelineState, ShaderStorageDeclaration, ShaderTextureDeclaration, ShaderTextureFallback, ShaderUniformDeclaration, ShaderUniformType, ShadowTechniqueName, SignalHandler, SignalLike, SignalOptions, SignalOwner, SmaaEffectSettings, SortingLayersSettings, SphereMeshOptions, StandardMaterialDefinition, Storage, StorageBackend, StorageBufferAssetLiteHandles, StoredValue, StoredValueKind, StringFieldSpec, SurfaceHookName, SurfaceHostCapabilities, SurfaceHostFamily, SurfaceShaderBinding, SurfaceShaderInit, SurfaceShaderReference, System, SystemContext, TextureAssetLiteHandles, TextureImportOptions, Time, TimeSettings, ToneMappingCurve, TorusMeshOptions, TweenOptions, TweenProps, TweenTargetValue, TweenValueKind, TweenableValue, Tweens, UlidFactoryOptions, Vec2Like, Vec3Like, Vec4Like, VectorFieldSpec, WaitInstruction, WebGpuInfo, WorldLiteHandles };
19462
+ export type { AddComponentFromRecordOptions, App, AppEvents, AppLiteHandles, AppSettings, ArrayFieldSpec, AssetFieldSpec, AssetHandle, AssetLoadErrorOptions, AssetLoader, AssetManifest, AssetManifestEntry, AssetProgress, AssetRef, AssetRefValue, AssetState, AssetTypeDefinition, AssetTypeToken, Assets, AssetsCreateOptions, AssetsSettings, BatchHandle, BloomEffectSettings, BoolFieldSpec, BoxMeshOptions, CameraProjection, CanvasAlphaMode, CapsuleMeshOptions, Clock, ColorFieldSpec, ColorLike, ComponentBuildResult, ComponentClassInfo, ComponentDefinition, ComponentHandle, ComponentHooks, ComponentInit, ComponentInitValue, ComponentRefFieldSpec, ComponentReplacement, ComponentStatics, ComponentType, ComponentTypeToken, ConcreteComponentType, ConnectOptions, ConsoleLike, ConsoleSinkOptions, Coroutine, CoroutineHandle, CoroutineHost, CoroutineYield, CreateAppOptions, CreateEntityOptions, CreateSceneOptions, CurveFieldSpec, CurveKey, CurveValue, CustomEffectInit, CustomEffectSettings, CustomFieldCodec, CustomFieldSpec, CylinderMeshOptions, DecodeResult, DeferredQueue, DeviceLostInfo, DiagnosticsGroup, DiagnosticsOptions, Disconnect, EasingFunction, EasingName, EntityHandle, EntityOverrideField, EntityPrefabLink, EntityRefFieldSpec, EnumFieldSpec, EnvironmentAssetLiteHandles, EnvironmentDefinition, EnvironmentFogMode, EnvironmentFogSettings, EnvironmentSkyboxSettings, ErrorCode, ErrorCodeDescription, ErrorCodeRegistry, ErrorContext, ErrorFormatMode, ErrorReport, Extension, ExtensionContext, FetchLike, FieldDefinition, FieldOptions, FieldSpec, FieldsOf, FileStorageOptions, FontAssetLiteHandles, FrameSample, FrameState, GpuAdapterInfo, GroundMeshOptions, HotReloadHost, HotReloadKind, HotReloadModule, HotReloadOptions, HotReloadPolicy, HotReloadReport, HotReloadStatics, IgnifxErrorOptions, IgnifxUniformName, ImageProcessingEffectSettings, ImageProcessingSettings, InstanceRange, InstancedMeshLod, InstancedMeshRendererLiteHandles, InstantiateOptions, InstantiateSceneOptions, JsonArray, JsonObject, JsonSchemaObject, JsonValue, LayerMaskFieldSpec, LayersSettings, LightShadowSettings, LightType, LiteAnimationGroup, LiteAssetContainer, LiteCamera, LiteEngine, LiteEnvironmentTextures, LiteFont, AdapterLight as LiteLight, LiteMaterial, LiteMaterialPluginPoint, LiteMesh, LitePbrMaterial, LiteScene, LiteSceneNode, LiteShaderMaterial, LiteShadowGenerator, LiteSkeleton, LiteStandardMaterial, LiteStorageBuffer, LiteSystemUniformName, LiteTexture2D, LoadOptions, LoadProgress, LoadSceneDependenciesOptions, LoadSceneFileOptions, LoadSceneOptions, LoaderContext, LogRecord, LogSink, LogThreshold, Logger, LoggerOptions, ManualClock, MapFieldSpec, Mat4Elements, Mat4Like, MaterialAlphaMode, MaterialAssetLiteHandles, MaterialDefinition, MaterialKind, MaterialPluginDefinition, MaterialPluginDefinitionInit, MemorySink, MeshAssetLiteHandles, MeshGeometryData, MeshOptionKind, MeshPrimitive, MeshPrimitiveDefinition, MeshPrimitiveOptionKinds, ModelAssetLiteHandles, ModelInstantiation, MutableQuat, MutableVec2, MutableVec3, MutableVec4, NumberFieldSpec, OptionalFieldSpec, OverridePath, PartialFieldsOf, PbrMaterialDefinition, PhaseIndex, PixelTextureOptions, PlaneMeshOptions, PlatformInfo, PlatformKind, PlatformOs, ProfileScope, QuatLike, RandomSource, Ray, RayVector, RecordFieldSpec, ReferenceDecoder, ReferenceEncoder, RegisterAssetOptions, RegisterComponentOptions, RegisterSystemOptions, RenderCapture, RenderOverlay, RenderOverlayLiteHandles, RenderPick, RenderPickIgnore, RenderPickOptions, RenderSurface, RenderTaskTiming, RenderTaskTimings, Renderer, RenderingFeature, RenderingFeatureSettings, RenderingSettings, SceneAsset, SceneBuildResult, SceneFile, SceneFileAssetRef, SceneFileComponent, SceneFileEntity, SceneFileInstance, SceneFileIssue, SceneFileOverride, SceneFileTransform, SceneLoadIssue, SceneLoaderOptions, Schema, SchemaDescription, SchemaDescriptionMeta, SchemaFieldDescription, SchemaIssue, ScriptCallbacks, ScriptClassInfo, ScriptDefinition, ScriptStatics, SerializeIssue, SerializeSceneOptions, ServiceClassKey, ServiceKey, ServiceNameKey, ServiceRegistry, SetParentOptions, SettingsInput, ShaderAttributeName, ShaderBlendMode, ShaderCullMode, ShaderDeclaration, ShaderDefineDeclaration, ShaderInstancingMode, ShaderKind, ShaderMaterialDefinition, ShaderMaterialDefinitionInput, ShaderPipelineState, ShaderStorageDeclaration, ShaderTextureDeclaration, ShaderTextureFallback, ShaderUniformDeclaration, ShaderUniformType, ShadowTechniqueName, SignalHandler, SignalLike, SignalOptions, SignalOwner, SmaaEffectSettings, SortingLayersSettings, SphereMeshOptions, StandardMaterialDefinition, Storage, StorageBackend, StorageBufferAssetLiteHandles, StoredValue, StoredValueKind, StringFieldSpec, SurfaceHookName, SurfaceHostCapabilities, SurfaceHostFamily, SurfaceShaderBinding, SurfaceShaderInit, SurfaceShaderReference, System, SystemContext, SystemEditMode, TextureAssetLiteHandles, TextureImportOptions, Time, TimeSettings, ToneMappingCurve, TorusMeshOptions, TweenOptions, TweenProps, TweenTargetValue, TweenValueKind, TweenableValue, Tweens, UlidFactoryOptions, Vec2Like, Vec3Like, Vec4Like, VectorFieldSpec, WaitInstruction, WebGpuInfo, WorldLiteHandles };
18547
19463
  //# sourceMappingURL=index.d.ts.map