@ignifx/core 0.9.0 → 0.11.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.
- package/decoders/babylon.ktx2Decoder.js +1 -0
- package/decoders/babylonjs-ktx2decoder.LICENSE.md +71 -0
- package/decoders/meshopt_decoder.js +199 -0
- package/decoders/meshoptimizer.LICENSE.md +21 -0
- package/decoders/msc_basis_transcoder.js +22 -0
- package/decoders/msc_basis_transcoder.wasm +0 -0
- package/decoders/scoped-babylonjs-ktx2decoder.LICENSE.md +396 -0
- package/decoders/scoped-babylonjs-ktx2decoder.NOTICE.md +15 -0
- package/decoders/uastc_astc.wasm +0 -0
- package/decoders/uastc_bc7.wasm +0 -0
- package/decoders/uastc_r8_unorm.wasm +0 -0
- package/decoders/uastc_rg8_unorm.wasm +0 -0
- package/decoders/uastc_rgba8_srgb_v2.wasm +0 -0
- package/decoders/uastc_rgba8_unorm_v2.wasm +0 -0
- package/decoders/vendored.json +96 -0
- package/decoders/zstddec.wasm +0 -0
- package/dist/decoders-CHJ7vduE.js +82 -0
- package/dist/decoders-CHJ7vduE.js.map +1 -0
- package/dist/{environment-mr5wp69e.js → environment-BCjfp1jB.js} +2 -2
- package/dist/{environment-mr5wp69e.js.map → environment-BCjfp1jB.js.map} +1 -1
- package/dist/{ignifx-error-CRh89KUJ.js → ignifx-error-RpK-lWwE.js} +13 -2
- package/dist/ignifx-error-RpK-lWwE.js.map +1 -0
- package/dist/index.d.ts +1682 -680
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2675 -240
- package/dist/index.js.map +1 -1
- package/dist/{material-plugin-BRnhfw7K.js → material-plugin-CWtV7DkH.js} +2 -2
- package/dist/{material-plugin-BRnhfw7K.js.map → material-plugin-CWtV7DkH.js.map} +1 -1
- package/dist/overlay-CjVgsfrm.js +239 -0
- package/dist/overlay-CjVgsfrm.js.map +1 -0
- package/dist/{post-effect-compiler-Rce26Eue.js → post-effect-compiler-pOvXae-i.js} +2 -2
- package/dist/{post-effect-compiler-Rce26Eue.js.map → post-effect-compiler-pOvXae-i.js.map} +1 -1
- package/dist/{shader-material-U6BKZ8D1.js → shader-material-B6wwFCKB.js} +2 -2
- package/dist/{shader-material-U6BKZ8D1.js.map → shader-material-B6wwFCKB.js.map} +1 -1
- package/dist/{shader-material-BIG3UDyu.js → shader-material-C4VjLTfV.js} +3 -3
- package/dist/{shader-material-BIG3UDyu.js.map → shader-material-C4VjLTfV.js.map} +1 -1
- package/dist/{shader-pragma-tw6AKaQD.js → shader-pragma-qO9_6sTd.js} +2 -2
- package/dist/{shader-pragma-tw6AKaQD.js.map → shader-pragma-qO9_6sTd.js.map} +1 -1
- package/dist/{surface-shader-Br17yysO.js → surface-shader-BaR7Kg-F.js} +4 -4
- package/dist/{surface-shader-Br17yysO.js.map → surface-shader-BaR7Kg-F.js.map} +1 -1
- package/package.json +20 -2
- package/LICENSE +0 -201
- package/dist/ignifx-error-CRh89KUJ.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { a as CORE_ERROR_MESSAGES, c as THIRD_PARTY_ERROR_PREFIX, i as isIgnifxError, l as isValidErrorCode, n as assertNever, o as CoreErrorCode, r as formatErrorMessage, s as ErrorRange, t as IgnifxError } from "./ignifx-error-
|
|
1
|
+
import { a as CORE_ERROR_MESSAGES, c as THIRD_PARTY_ERROR_PREFIX, i as isIgnifxError, l as isValidErrorCode, n as assertNever, o as CoreErrorCode, r as formatErrorMessage, s as ErrorRange, t as IgnifxError } from "./ignifx-error-RpK-lWwE.js";
|
|
2
2
|
import { _ as smoothStep, a as clamp, c as deltaAngleDegrees, d as lerpAngleDegrees, f as moveTowards, g as sign, h as repeat, i as approximately, l as inverseLerp, m as radToDeg, n as EPSILON, o as clamp01, p as pingPong, r as RAD_TO_DEG, s as degToRad, t as DEG_TO_RAD, u as lerp, v as wrapAngleDegrees } from "./math-utils-BcDnL-gi.js";
|
|
3
3
|
import { $ as basisToQuatToRef, A as setMeshReceiveShadows, B as localPosition, C as overrideSubtreeMaterials, D as setMeshId, E as setMeshBounds, F as updateMeshPositions$1, G as readWorldMatrix, H as localScale, I as updateMeshUvs$1, J as setNodeSelfVisible, K as reparentKeepingWorld, L as createNode, M as setMeshSubtreeVisible, N as updateMeshColors$1, O as setMeshMaterial, P as updateMeshNormals$1, Q as Mat4, R as disposeNode, S as disposeMeshTemplate, T as removeMeshFromScene, U as parentNode, V as localRotation, W as readNodeTag, X as worldMatrixVersion, Y as tagNode, Z as MAT4_IDENTITY, _ as createMeshFromGeometry, a as VEC3_ONE, b as createTorusMesh, c as VEC3_ZERO, d as cloneMeshUnderNode, f as collectSubtreeMeshes, g as createGroundMesh, h as createCylinderMesh, i as VEC3_LEFT, j as setMeshRenderOrder, k as setMeshPickable, l as Vec3, m as createCapsuleMesh, n as VEC3_DOWN, o as VEC3_RIGHT, p as createBoxMesh, q as setNodeName, r as VEC3_FORWARD, s as VEC3_UP, t as VEC3_BACKWARD, u as addMeshToScene, v as createPlaneMesh, w as recomputeMeshBounds, x as detachMeshBounds, y as createSphereMesh, z as linkParent } from "./vec3-T2PasQZv.js";
|
|
4
4
|
import { t as Color } from "./color-DrR6GFTd.js";
|
|
5
|
-
import { a as readSceneImageProcessing, c as setSceneEnvironmentRotation, l as setSceneFog, n as installSceneEnvironment, o as setSceneClearColor, r as loadSceneEnvironment, s as setSceneEnvironmentBlur, t as TONE_MAPPING_NAMES, u as setSceneImageProcessingOptions } from "./environment-
|
|
6
|
-
import { a as defineMaterialPlugin, c as MATERIAL_ALPHA_MODES, d as createStandardMaterialFromProps, f as markMaterialDirty, g as setPbrMetallicRoughness, h as setPbrBaseColor, i as MATERIAL_PLUGIN_SAMPLER_BUDGET, l as createDefaultMaterial, m as setMaterialAlpha, n as MATERIAL_PLUGIN_DEFAULT_PRIORITY, o as isLiteMaterialPluginPoint, r as MATERIAL_PLUGIN_RESERVED_NAMES, t as LITE_MATERIAL_PLUGIN_POINTS, u as createPbrMaterialFromProps } from "./material-plugin-
|
|
5
|
+
import { a as readSceneImageProcessing, c as setSceneEnvironmentRotation, l as setSceneFog, n as installSceneEnvironment, o as setSceneClearColor, r as loadSceneEnvironment, s as setSceneEnvironmentBlur, t as TONE_MAPPING_NAMES, u as setSceneImageProcessingOptions } from "./environment-BCjfp1jB.js";
|
|
6
|
+
import { a as defineMaterialPlugin, c as MATERIAL_ALPHA_MODES, d as createStandardMaterialFromProps, f as markMaterialDirty, g as setPbrMetallicRoughness, h as setPbrBaseColor, i as MATERIAL_PLUGIN_SAMPLER_BUDGET, l as createDefaultMaterial, m as setMaterialAlpha, n as MATERIAL_PLUGIN_DEFAULT_PRIORITY, o as isLiteMaterialPluginPoint, r as MATERIAL_PLUGIN_RESERVED_NAMES, t as LITE_MATERIAL_PLUGIN_POINTS, u as createPbrMaterialFromProps } from "./material-plugin-CWtV7DkH.js";
|
|
7
7
|
import { a as postEffectValuesCodec, i as declaredTextureBinding, n as POST_EFFECT_FUNCTION, o as asJsonArray, r as customEffect, s as asJsonObject, t as POST_EFFECT_BUILTIN_UNIFORMS } from "./post-effect-C42XJFmo.js";
|
|
8
8
|
import { a as SHADER_BLEND_MODES, c as SHADER_KINDS, d as SURFACE_HOOK_NAMES, f as SURFACE_UNIFORM_BLOCK, i as SHADER_ATTRIBUTE_NAMES, l as SHADER_TEXTURE_FALLBACKS, o as SHADER_CULL_MODES, r as LITE_SYSTEM_UNIFORM_NAMES, s as SHADER_INSTANCING_MODES, t as IGNIFX_UNIFORM_NAMES, u as SHADER_UNIFORM_TYPES } from "./shader-declaration-5q__jycG.js";
|
|
9
9
|
import { acquireTexture, addTask, addToScene, buildFrameGraphTask, captureScreenshot, cloneTransformNode, createBloomPostProcessTask, createCopyToTextureTask, createCsmDirectionalShadowGenerator, createDirectionalLight, createEngine, createEsmDirectionalShadowGenerator, createFontFromBuffer, createFreeCamera, createGpuPicker, createHemisphericLight, createImageProcessingTask, createMeshFromData, createNullEngine, createPcfDirectionalShadowGenerator, createPcfSpotlightShadowGenerator, createPointLight, createRenderTarget, createRenderTask, createSceneContext, createSmaaPostProcessTask, createSpotLight, createStorageBuffer, createTexture2DFromPixels, disableOrthographicCamera, disposeEngine, disposePicker, disposeScene, disposeStorageBuffer, enableBoneControl, enableDeviceLostSceneRecovery, enableMaterialPlugins, enableMaterialStencil, enableOrthographicCamera, enablePbrLightmap, enableSkeletonShadows, enableStandardSkeleton, forceWebGpuDeviceLossForTesting, getEffectiveAspectRatio, getFrameGraph, getProjectionMatrix, getRenderTaskGpuTimings, getViewMatrix, getViewProjectionMatrix, isPbrMaterial, isShaderMaterial, loadTexture2D, onBeforeRender, pickAsync, pickWithRay, rebuildSceneRenderables, registerScene, registerSceneWithShadowSupport, releaseTexture, removeFromScene, resizeEngine, resolveCameraViewport, setGpuTimingEnabled, setShadowTaskCasterMeshes, setSubtreeVisible, setSurfaceSize, startEngine, stopEngine, updateStorageBuffer, updateTexture2DFromPixels } from "@babylonjs/lite";
|
|
@@ -445,6 +445,11 @@ var AssetHandleImpl = class {
|
|
|
445
445
|
interested = 0;
|
|
446
446
|
/** `true` while the loader is running. */
|
|
447
447
|
isRunning = false;
|
|
448
|
+
/**
|
|
449
|
+
* How many reloads were asked for. A running reload compares it with the count it last served,
|
|
450
|
+
* so one asked for meanwhile runs once more when the current pass finishes.
|
|
451
|
+
*/
|
|
452
|
+
reloadRequests = 0;
|
|
448
453
|
/** Bytes received so far. */
|
|
449
454
|
bytesLoaded = 0;
|
|
450
455
|
/** Bytes expected, from the manifest entry or the response's `Content-Length`; `0` when unknown. */
|
|
@@ -1680,14 +1685,19 @@ var AssetsImpl = class {
|
|
|
1680
1685
|
* own: it is re-derived from the base's new value when that base is delivered, which is the only
|
|
1681
1686
|
* order that cannot show a fragment of the old file next to a fragment of the new one.
|
|
1682
1687
|
*
|
|
1688
|
+
* A call that finds a reload of the handle already running queues one more pass instead of being
|
|
1689
|
+
* dropped, so a second save inside the first reload's window still lands.
|
|
1690
|
+
*
|
|
1683
1691
|
* @param address - The address that changed on disk, with or without a fragment.
|
|
1684
1692
|
*/
|
|
1685
1693
|
reload(address) {
|
|
1686
1694
|
const path = splitFragment(address).path;
|
|
1687
1695
|
for (const handle of this.#entries.values()) {
|
|
1688
1696
|
if (handle.address !== address && handle.path !== path) continue;
|
|
1689
|
-
if (handle.state !== "loaded"
|
|
1697
|
+
if (handle.state !== "loaded") continue;
|
|
1690
1698
|
if (handle.fragment !== null && handle.loader.parseFragment !== void 0) continue;
|
|
1699
|
+
handle.reloadRequests += 1;
|
|
1700
|
+
if (handle.isRunning) continue;
|
|
1691
1701
|
this.#runReload(handle);
|
|
1692
1702
|
}
|
|
1693
1703
|
}
|
|
@@ -1930,30 +1940,66 @@ var AssetsImpl = class {
|
|
|
1930
1940
|
}
|
|
1931
1941
|
}
|
|
1932
1942
|
/**
|
|
1933
|
-
* Runs
|
|
1943
|
+
* Runs a hot reload, and again for each reload asked for while it ran, then delivers the newest
|
|
1944
|
+
* value once. Each pass starts from the value the previous pass produced, so the default reload
|
|
1945
|
+
* releases every intermediate value exactly once.
|
|
1934
1946
|
*
|
|
1935
1947
|
* @param handle - The loaded handle to refresh.
|
|
1936
1948
|
*/
|
|
1937
1949
|
async #runReload(handle) {
|
|
1938
1950
|
const controller = new AbortController();
|
|
1939
|
-
|
|
1951
|
+
let current = handle.value;
|
|
1952
|
+
let isReplaced = false;
|
|
1953
|
+
let served = -1;
|
|
1940
1954
|
handle.isRunning = true;
|
|
1941
1955
|
try {
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1956
|
+
while (served !== handle.reloadRequests && handle.state === "loaded") {
|
|
1957
|
+
served = handle.reloadRequests;
|
|
1958
|
+
try {
|
|
1959
|
+
const value = await this.#invokeLoader(handle, controller.signal, true, current);
|
|
1960
|
+
if (this.#isDisposed) return;
|
|
1961
|
+
if (handle.loader.reload === void 0) this.#runUnload(handle, current);
|
|
1962
|
+
current = value;
|
|
1963
|
+
isReplaced = true;
|
|
1964
|
+
} catch (error) {
|
|
1965
|
+
this.#report(this.#reloadError(handle, error, isReplaced));
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
if (isReplaced) this.#enqueueDelivery({
|
|
1946
1969
|
kind: "replaced",
|
|
1947
1970
|
handle,
|
|
1948
|
-
value
|
|
1971
|
+
value: current
|
|
1949
1972
|
});
|
|
1950
|
-
} catch (error) {
|
|
1951
|
-
this.#report(error);
|
|
1952
1973
|
} finally {
|
|
1953
1974
|
handle.isRunning = false;
|
|
1954
1975
|
}
|
|
1955
1976
|
}
|
|
1956
1977
|
/**
|
|
1978
|
+
* Builds the failure a hot reload reports through `app.onError`.
|
|
1979
|
+
*
|
|
1980
|
+
* @param handle - The handle whose reload failed.
|
|
1981
|
+
* @param error - What the loader threw.
|
|
1982
|
+
* @param isReplaced - Whether an earlier pass of the same reload produced a value, which the
|
|
1983
|
+
* handle keeps instead of the one it held before.
|
|
1984
|
+
* @returns The `IGX-0505` failure, with the loader's error as `cause`.
|
|
1985
|
+
*/
|
|
1986
|
+
#reloadError(handle, error, isReplaced) {
|
|
1987
|
+
const kept = isReplaced ? "the last version that loaded" : "its previous value";
|
|
1988
|
+
return new AssetLoadError(CoreErrorCode.assetLoadFailed, `Reloading ${handle.address} from ${handle.url} failed; the asset keeps ${kept}.`, {
|
|
1989
|
+
address: handle.address,
|
|
1990
|
+
url: handle.url,
|
|
1991
|
+
cause: error,
|
|
1992
|
+
context: {
|
|
1993
|
+
asset: handle.address,
|
|
1994
|
+
url: handle.url,
|
|
1995
|
+
attempts: 1,
|
|
1996
|
+
reload: true,
|
|
1997
|
+
kept: isReplaced ? "earlier reload" : "previous"
|
|
1998
|
+
},
|
|
1999
|
+
hint: "Fix the file and save it again; the next save reloads it."
|
|
2000
|
+
});
|
|
2001
|
+
}
|
|
2002
|
+
/**
|
|
1957
2003
|
* Calls the loader, resolving a `#fragment` address through the base address first.
|
|
1958
2004
|
*
|
|
1959
2005
|
* @param handle - The handle being loaded.
|
|
@@ -3104,12 +3150,13 @@ function notAttached(component) {
|
|
|
3104
3150
|
* costs a call per frame and not defining it costs nothing.
|
|
3105
3151
|
*
|
|
3106
3152
|
* **The statics work the same way.** `typeId`, `schema`, `requires`, `allowMultiple`,
|
|
3107
|
-
* `executionOrder`, and `
|
|
3108
|
-
* static declared on the base class is an override too, so
|
|
3109
|
-
* have needed an `override` modifier. Their shape lives on
|
|
3110
|
-
* {@link ScriptStatics}, which the class-token types intersect, so a
|
|
3111
|
-
* satisfies them structurally; `ComponentRegistry` reads each one once
|
|
3112
|
-
* defaults (`executionOrder` `0`, `updateWhenPaused` `false
|
|
3153
|
+
* `executionOrder`, `updateWhenPaused`, and `runInEditMode` are not members of `Component` or
|
|
3154
|
+
* `Script` either: a static declared on the base class is an override too, so
|
|
3155
|
+
* `static typeId = "mygame/Mover"` would have needed an `override` modifier. Their shape lives on
|
|
3156
|
+
* {@link ComponentStatics} and {@link ScriptStatics}, which the class-token types intersect, so a
|
|
3157
|
+
* plain `static` on a subclass satisfies them structurally; `ComponentRegistry` reads each one once
|
|
3158
|
+
* per class and applies the defaults (`executionOrder` `0`, `updateWhenPaused` `false`,
|
|
3159
|
+
* `runInEditMode` `false`).
|
|
3113
3160
|
*
|
|
3114
3161
|
* @example
|
|
3115
3162
|
* ```ts
|
|
@@ -3161,6 +3208,8 @@ var Script = class extends Component {
|
|
|
3161
3208
|
*
|
|
3162
3209
|
* @param routine - The generator to drive. Call the generator function: `this.spawnLoop()`.
|
|
3163
3210
|
* @returns A handle for stopping it or waiting on it.
|
|
3211
|
+
* @throws IgnifxError with code `IGX-0111` in an edit-mode app when the class does not set
|
|
3212
|
+
* `static runInEditMode = true` (ADR-0028).
|
|
3164
3213
|
*
|
|
3165
3214
|
* @example
|
|
3166
3215
|
* ```ts
|
|
@@ -3217,6 +3266,7 @@ const TYPE_ID_PATTERN = /^[a-z0-9][a-z0-9\-.@/]*\/[A-Za-z][A-Za-z0-9]*$/u;
|
|
|
3217
3266
|
*/
|
|
3218
3267
|
var ComponentRegistry = class {
|
|
3219
3268
|
#byTypeId = /* @__PURE__ */ new Map();
|
|
3269
|
+
#registrars = /* @__PURE__ */ new Map();
|
|
3220
3270
|
#info = /* @__PURE__ */ new Map();
|
|
3221
3271
|
#nextClassIndex = 0;
|
|
3222
3272
|
/**
|
|
@@ -3232,11 +3282,13 @@ var ComponentRegistry = class {
|
|
|
3232
3282
|
*
|
|
3233
3283
|
* @param type - The component class.
|
|
3234
3284
|
* @param typeId - An explicit id, when the class does not declare one.
|
|
3285
|
+
* @param registrar - Who registers it, for example the extension's `name`; the first registrar of
|
|
3286
|
+
* an id is kept, and {@link ComponentRegistry.registrarOf} reports it.
|
|
3235
3287
|
* @returns What the registry worked out about the class.
|
|
3236
3288
|
* @throws IgnifxError with code `IGX-0203` when the id is already registered by another class, or
|
|
3237
3289
|
* when the id is not `<namespace>/<Name>`.
|
|
3238
3290
|
*/
|
|
3239
|
-
register(type, typeId) {
|
|
3291
|
+
register(type, typeId, registrar) {
|
|
3240
3292
|
const id = typeId ?? readStatics$1(type).typeId ?? null;
|
|
3241
3293
|
if (id !== null) {
|
|
3242
3294
|
if (!TYPE_ID_PATTERN.test(id)) throw new IgnifxError(CoreErrorCode.duplicateComponentTypeId, `The component type id ${id} is malformed.`, {
|
|
@@ -3252,6 +3304,7 @@ var ComponentRegistry = class {
|
|
|
3252
3304
|
owner: existing.prototype.constructor.name
|
|
3253
3305
|
} });
|
|
3254
3306
|
this.#byTypeId.set(id, type);
|
|
3307
|
+
if (registrar !== void 0 && !this.#registrars.has(id)) this.#registrars.set(id, registrar);
|
|
3255
3308
|
}
|
|
3256
3309
|
return this.describe(type);
|
|
3257
3310
|
}
|
|
@@ -3259,14 +3312,32 @@ var ComponentRegistry = class {
|
|
|
3259
3312
|
* Registers several component classes.
|
|
3260
3313
|
*
|
|
3261
3314
|
* @param types - The component classes.
|
|
3315
|
+
* @param registrar - Who registers them, as for {@link ComponentRegistry.register}.
|
|
3262
3316
|
*/
|
|
3263
|
-
registerAll(types) {
|
|
3317
|
+
registerAll(types, registrar) {
|
|
3264
3318
|
for (let index = 0; index < types.length; index += 1) {
|
|
3265
3319
|
const type = types[index];
|
|
3266
|
-
if (type !== void 0) this.register(type);
|
|
3320
|
+
if (type !== void 0) this.register(type, void 0, registrar);
|
|
3267
3321
|
}
|
|
3268
3322
|
}
|
|
3269
3323
|
/**
|
|
3324
|
+
* Who registered a type id: the extension `name` an `ExtensionContext` registers under, or
|
|
3325
|
+
* whatever a direct caller of {@link ComponentRegistry.register} passed. A hot-reload
|
|
3326
|
+
* {@link ComponentRegistry.replace} keeps it.
|
|
3327
|
+
*
|
|
3328
|
+
* @param typeId - The namespaced id.
|
|
3329
|
+
* @returns The registrar, or `null` when the id was registered without one (as
|
|
3330
|
+
* `app.registerComponents` does) or is not registered.
|
|
3331
|
+
*
|
|
3332
|
+
* @example
|
|
3333
|
+
* ```ts
|
|
3334
|
+
* app.world.registry.registrarOf("ignifx/Camera"); // "@ignifx/core"
|
|
3335
|
+
* ```
|
|
3336
|
+
*/
|
|
3337
|
+
registrarOf(typeId) {
|
|
3338
|
+
return this.#registrars.get(typeId) ?? null;
|
|
3339
|
+
}
|
|
3340
|
+
/**
|
|
3270
3341
|
* Swaps the class registered under a `typeId` for a replacement, for script hot reload
|
|
3271
3342
|
* (`docs/architecture/15-devtools-and-diagnostics.md` §5). The previous class's cached info is
|
|
3272
3343
|
* dropped and the replacement inherits its `classIndex`, so per-class bookkeeping indexed by that
|
|
@@ -3470,6 +3541,7 @@ function buildScriptInfo(type) {
|
|
|
3470
3541
|
return {
|
|
3471
3542
|
executionOrder: statics.executionOrder ?? 0,
|
|
3472
3543
|
updateWhenPaused: statics.updateWhenPaused ?? false,
|
|
3544
|
+
runInEditMode: statics.runInEditMode ?? false,
|
|
3473
3545
|
callbacks
|
|
3474
3546
|
};
|
|
3475
3547
|
}
|
|
@@ -3600,6 +3672,7 @@ var CoroutineRecord = class {
|
|
|
3600
3672
|
*/
|
|
3601
3673
|
var CoroutineHostImpl = class {
|
|
3602
3674
|
#frameState;
|
|
3675
|
+
#isEditMode;
|
|
3603
3676
|
#report;
|
|
3604
3677
|
#records = [];
|
|
3605
3678
|
#byOwner = /* @__PURE__ */ new Map();
|
|
@@ -3612,6 +3685,7 @@ var CoroutineHostImpl = class {
|
|
|
3612
3685
|
*/
|
|
3613
3686
|
constructor(options) {
|
|
3614
3687
|
this.#frameState = options.frameState;
|
|
3688
|
+
this.#isEditMode = options.editMode;
|
|
3615
3689
|
this.#report = (error, owner) => {
|
|
3616
3690
|
options.report(error, owner);
|
|
3617
3691
|
};
|
|
@@ -3631,8 +3705,17 @@ var CoroutineHostImpl = class {
|
|
|
3631
3705
|
* @param owner - The script whose enabled state gates the coroutine.
|
|
3632
3706
|
* @param routine - The generator to drive.
|
|
3633
3707
|
* @returns A handle for stopping it or waiting on it.
|
|
3708
|
+
* @throws IgnifxError with code `IGX-0111` in edit mode when the owner's class does not set
|
|
3709
|
+
* `static runInEditMode = true`.
|
|
3634
3710
|
*/
|
|
3635
3711
|
start(owner, routine) {
|
|
3712
|
+
if (this.#isEditMode && componentInternals(owner).info?.script?.runInEditMode !== true) {
|
|
3713
|
+
const script = owner.constructor.name;
|
|
3714
|
+
throw new IgnifxError(CoreErrorCode.coroutineInEditMode, `${script} cannot start a coroutine in edit mode because its class does not run in edit mode.`, {
|
|
3715
|
+
context: { script },
|
|
3716
|
+
hint: "Add `static runInEditMode = true` if the script is meant to run in an editor. Otherwise start the coroutine from a callback such as `start`, which only a game calls."
|
|
3717
|
+
});
|
|
3718
|
+
}
|
|
3636
3719
|
const record = new CoroutineRecord(owner, routine);
|
|
3637
3720
|
this.#records.push(record);
|
|
3638
3721
|
let owned = this.#byOwner.get(owner);
|
|
@@ -4614,15 +4697,14 @@ function createServiceKey(name) {
|
|
|
4614
4697
|
* `version` (`docs/architecture/04-extensions.md` §1).
|
|
4615
4698
|
*
|
|
4616
4699
|
* @remarks
|
|
4617
|
-
* The
|
|
4618
|
-
*
|
|
4619
|
-
*
|
|
4620
|
-
* an option — that would be an import-time side effect and a bundler hazard
|
|
4700
|
+
* The build stamps it from `package.json`, where Changesets writes each release's number; code run
|
|
4701
|
+
* from source, such as this repository's tests, sees `"0.0.0"`. Reading `package.json` at run time
|
|
4702
|
+
* is not an option: that would be an import-time side effect and a bundler hazard
|
|
4621
4703
|
* (`CONSTITUTION.md` §3.5).
|
|
4622
4704
|
*
|
|
4623
4705
|
* @public
|
|
4624
4706
|
*/
|
|
4625
|
-
const VERSION = "0.
|
|
4707
|
+
const VERSION = "0.11.0";
|
|
4626
4708
|
//#endregion
|
|
4627
4709
|
//#region src/assets/delivery-system.ts
|
|
4628
4710
|
/**
|
|
@@ -5188,37 +5270,89 @@ function raycastScene(scene, ray, options) {
|
|
|
5188
5270
|
return pickWithRay(scene, ray, options);
|
|
5189
5271
|
}
|
|
5190
5272
|
/**
|
|
5191
|
-
*
|
|
5192
|
-
*
|
|
5273
|
+
* The ignifx tag that owns a node: its own, or the nearest tagged ancestor's.
|
|
5274
|
+
*
|
|
5275
|
+
* @remarks
|
|
5276
|
+
* A `MeshRenderer` tags the mesh it clones, but a `Model` tags only the cloned glTF root, and the
|
|
5277
|
+
* meshes Lite draws are that root's descendants (`render/gpu/model-instance.ts`). Walking up to the
|
|
5278
|
+
* nearest tag resolves both, and any other renderable that parents several Lite nodes under one
|
|
5279
|
+
* tagged node, to the entity and component that created them (editor spike S0.2 §6.1). The walk
|
|
5280
|
+
* stops at the first tag, so an entity parented under a model's bone still owns its own meshes.
|
|
5281
|
+
*
|
|
5282
|
+
* @param node - The picked node, usually a mesh.
|
|
5283
|
+
* @returns The nearest tag, or `null` when no node on the way to the root carries one.
|
|
5284
|
+
*
|
|
5285
|
+
* @internal
|
|
5286
|
+
*/
|
|
5287
|
+
function readOwnerTag(node) {
|
|
5288
|
+
for (let current = node; current !== null; current = parentNode(current)) {
|
|
5289
|
+
const tag = readNodeTag(current);
|
|
5290
|
+
if (tag !== null) return tag;
|
|
5291
|
+
}
|
|
5292
|
+
return null;
|
|
5293
|
+
}
|
|
5294
|
+
/**
|
|
5295
|
+
* Casts a ray against a scene's renderable meshes, considering only the meshes a predicate accepts.
|
|
5193
5296
|
*
|
|
5194
5297
|
* @remarks
|
|
5195
|
-
* The predicate is stated over the *tag* rather than over Lite's `Mesh` so the component
|
|
5196
|
-
* filter by entity without naming a Lite type (`CONSTITUTION.md` §3.4). Lite's own
|
|
5298
|
+
* The predicate is stated over the owning *tag* rather than over Lite's `Mesh` so the component
|
|
5299
|
+
* layer can filter by entity without naming a Lite type (`CONSTITUTION.md` §3.4). Lite's own
|
|
5197
5300
|
* `pickable === false` exclusion still runs first.
|
|
5198
5301
|
*
|
|
5199
5302
|
* @param scene - The render scene.
|
|
5200
5303
|
* @param ray - The ray to cast.
|
|
5201
|
-
* @param accept - Decides whether a mesh may be picked, from the ignifx tag
|
|
5304
|
+
* @param accept - Decides whether a mesh may be picked, from the ignifx tag that owns it.
|
|
5202
5305
|
* @returns Lite's picking info.
|
|
5203
5306
|
*
|
|
5204
5307
|
* @internal
|
|
5205
5308
|
*/
|
|
5206
5309
|
function raycastSceneWhere(scene, ray, accept) {
|
|
5207
|
-
return pickWithRay(scene, ray, { predicate: (mesh) => accept(
|
|
5310
|
+
return pickWithRay(scene, ray, { predicate: (mesh) => accept(readOwnerTag(mesh), mesh) });
|
|
5208
5311
|
}
|
|
5209
5312
|
/**
|
|
5210
5313
|
* Resolves a hit back to the ignifx entity and component that own the mesh.
|
|
5211
5314
|
*
|
|
5212
5315
|
* @param info - A result from {@link raycastScene}, {@link raycastMeshes}, or the GPU picker.
|
|
5213
|
-
* @returns The owning
|
|
5214
|
-
*
|
|
5316
|
+
* @returns The owning tag — the picked mesh's own or its nearest tagged ancestor's, so a glTF mesh
|
|
5317
|
+
* inside a `Model` resolves to the model — or `null` when the ray missed or no node on the way to
|
|
5318
|
+
* the root is one ignifx created.
|
|
5215
5319
|
*
|
|
5216
5320
|
* @internal
|
|
5217
5321
|
*/
|
|
5218
5322
|
function readPickedTag(info) {
|
|
5219
5323
|
const mesh = info.pickedMesh;
|
|
5220
5324
|
if (mesh === null) return null;
|
|
5221
|
-
return
|
|
5325
|
+
return readOwnerTag(mesh);
|
|
5326
|
+
}
|
|
5327
|
+
/**
|
|
5328
|
+
* The name of the mesh a hit landed on.
|
|
5329
|
+
*
|
|
5330
|
+
* @param info - A hit.
|
|
5331
|
+
* @returns The Lite mesh's name — for a glTF model, the name the file gives the node or primitive —
|
|
5332
|
+
* or `""` for a miss or an unnamed mesh.
|
|
5333
|
+
*
|
|
5334
|
+
* @internal
|
|
5335
|
+
*/
|
|
5336
|
+
function readPickedMeshName(info) {
|
|
5337
|
+
const name = info.pickedMesh?.name;
|
|
5338
|
+
return typeof name === "string" ? name : "";
|
|
5339
|
+
}
|
|
5340
|
+
/**
|
|
5341
|
+
* Reads the identity of a hit, for a later pick to ignore.
|
|
5342
|
+
*
|
|
5343
|
+
* @param info - A hit.
|
|
5344
|
+
* @returns The mesh and thin instance, or `null` for a miss or a hit on something other than a
|
|
5345
|
+
* regular Lite mesh (a Gaussian-splatting mesh, which Lite's `ignore` cannot name).
|
|
5346
|
+
*
|
|
5347
|
+
* @internal
|
|
5348
|
+
*/
|
|
5349
|
+
function readPickedIdentity(info) {
|
|
5350
|
+
const mesh = info.pickedMesh;
|
|
5351
|
+
if (mesh === null || !("material" in mesh)) return null;
|
|
5352
|
+
return {
|
|
5353
|
+
mesh,
|
|
5354
|
+
thinInstanceIndex: info.thinInstanceIndex
|
|
5355
|
+
};
|
|
5222
5356
|
}
|
|
5223
5357
|
//#endregion
|
|
5224
5358
|
//#region src/schema/types.ts
|
|
@@ -5910,7 +6044,9 @@ const HEADLESS_TARGET_SIZE = 1;
|
|
|
5910
6044
|
* @example
|
|
5911
6045
|
* ```ts
|
|
5912
6046
|
* const ray = createRay();
|
|
5913
|
-
*
|
|
6047
|
+
* // A DOM event is in CSS pixels; the camera speaks the canvas's backing-store pixels.
|
|
6048
|
+
* const scale = canvas.width / canvas.clientWidth;
|
|
6049
|
+
* camera.screenToRay(event.offsetX * scale, event.offsetY * scale, ray);
|
|
5914
6050
|
* ```
|
|
5915
6051
|
*
|
|
5916
6052
|
* @public
|
|
@@ -6008,7 +6144,9 @@ var Camera = class Camera extends Component {
|
|
|
6008
6144
|
* @remarks
|
|
6009
6145
|
* Coordinates are backing-store pixels — the canvas's `width`/`height`, the space
|
|
6010
6146
|
* {@link Camera.worldToScreen} answers in and `@ignifx/input` reports `<Pointer>/position` in — not
|
|
6011
|
-
* CSS pixels; multiply a DOM event's `offsetX`/`offsetY` by `
|
|
6147
|
+
* CSS pixels; multiply a DOM event's `offsetX`/`offsetY` by `canvas.width / canvas.clientWidth`
|
|
6148
|
+
* first (`devicePixelRatio` is that ratio only while `renderer.pixelRatio` and
|
|
6149
|
+
* `renderer.resolutionScale` leave it alone).
|
|
6012
6150
|
*
|
|
6013
6151
|
* @param x - The backing-store pixel x, from the canvas's left edge.
|
|
6014
6152
|
* @param y - The backing-store pixel y, from the canvas's top edge.
|
|
@@ -6928,7 +7066,7 @@ let surfaceLayer = null;
|
|
|
6928
7066
|
* @internal
|
|
6929
7067
|
*/
|
|
6930
7068
|
async function loadShaderSupport() {
|
|
6931
|
-
const loaded = shaderLayer ?? await import("./shader-material-
|
|
7069
|
+
const loaded = shaderLayer ?? await import("./shader-material-C4VjLTfV.js").then((n) => n.n);
|
|
6932
7070
|
shaderLayer = loaded;
|
|
6933
7071
|
await loaded.loadShaderMaterialAdapter();
|
|
6934
7072
|
return loaded;
|
|
@@ -6951,7 +7089,7 @@ function shaderSupport() {
|
|
|
6951
7089
|
* @internal
|
|
6952
7090
|
*/
|
|
6953
7091
|
async function loadSurfaceShaderSupport() {
|
|
6954
|
-
const loaded = surfaceLayer ?? await import("./surface-shader-
|
|
7092
|
+
const loaded = surfaceLayer ?? await import("./surface-shader-BaR7Kg-F.js");
|
|
6955
7093
|
surfaceLayer = loaded;
|
|
6956
7094
|
return loaded;
|
|
6957
7095
|
}
|
|
@@ -7986,6 +8124,42 @@ function buildMeshTemplate(isHeadless, scene, engine, build) {
|
|
|
7986
8124
|
engine
|
|
7987
8125
|
};
|
|
7988
8126
|
}
|
|
8127
|
+
/**
|
|
8128
|
+
* Copies the ignifx ground options onto Lite's, which types `uvScale` as a mutable tuple.
|
|
8129
|
+
*
|
|
8130
|
+
* @param options - The declared options.
|
|
8131
|
+
* @returns Lite's options.
|
|
8132
|
+
*/
|
|
8133
|
+
function toGroundOptions(options) {
|
|
8134
|
+
const result = {};
|
|
8135
|
+
if (options.width !== void 0) result.width = options.width;
|
|
8136
|
+
if (options.height !== void 0) result.height = options.height;
|
|
8137
|
+
if (options.subdivisions !== void 0) result.subdivisions = options.subdivisions;
|
|
8138
|
+
const uvScale = options.uvScale;
|
|
8139
|
+
if (uvScale !== void 0) result.uvScale = [uvScale[0], uvScale[1]];
|
|
8140
|
+
return result;
|
|
8141
|
+
}
|
|
8142
|
+
/**
|
|
8143
|
+
* Builds a primitive's Lite mesh.
|
|
8144
|
+
*
|
|
8145
|
+
* @param engine - The engine that owns the buffers.
|
|
8146
|
+
* @param definition - The primitive and its options.
|
|
8147
|
+
* @returns The template.
|
|
8148
|
+
*
|
|
8149
|
+
* @internal
|
|
8150
|
+
*/
|
|
8151
|
+
function buildPrimitiveTemplate(engine, definition) {
|
|
8152
|
+
switch (definition.primitive) {
|
|
8153
|
+
case "box": return buildBoxTemplate(engine, definition.options);
|
|
8154
|
+
case "sphere": return buildSphereTemplate(engine, definition.options);
|
|
8155
|
+
case "plane": return buildPlaneTemplate(engine, definition.options);
|
|
8156
|
+
case "ground": return buildGroundTemplate(engine, toGroundOptions(definition.options));
|
|
8157
|
+
case "cylinder": return buildCylinderTemplate(engine, definition.options);
|
|
8158
|
+
case "capsule": return buildCapsuleTemplate(engine, definition.options);
|
|
8159
|
+
case "torus": return buildTorusTemplate(engine, definition.options);
|
|
8160
|
+
default: return assertNever(definition, "mesh primitive");
|
|
8161
|
+
}
|
|
8162
|
+
}
|
|
7989
8163
|
//#endregion
|
|
7990
8164
|
//#region src/render/mesh-asset.ts
|
|
7991
8165
|
/**
|
|
@@ -8009,12 +8183,28 @@ const FLOATS_PER_UV = 2;
|
|
|
8009
8183
|
/** Floats per vertex in the colour attribute — Lite's colour attribute is `vec4`. */
|
|
8010
8184
|
const FLOATS_PER_COLOR$1 = 4;
|
|
8011
8185
|
/**
|
|
8186
|
+
* The primitive shapes a `MeshAsset` factory and a `.mesh.json` file can build.
|
|
8187
|
+
*
|
|
8188
|
+
* @public
|
|
8189
|
+
*/
|
|
8190
|
+
const MESH_PRIMITIVES = [
|
|
8191
|
+
"box",
|
|
8192
|
+
"sphere",
|
|
8193
|
+
"plane",
|
|
8194
|
+
"ground",
|
|
8195
|
+
"cylinder",
|
|
8196
|
+
"capsule",
|
|
8197
|
+
"torus"
|
|
8198
|
+
];
|
|
8199
|
+
/**
|
|
8012
8200
|
* A geometry template a `MeshRenderer` draws (`docs/architecture/07-rendering.md` §2.3).
|
|
8013
8201
|
*
|
|
8014
8202
|
* @remarks
|
|
8015
8203
|
* Build one with a primitive factory or {@link MeshAsset.fromData}; each returns the handle the
|
|
8016
|
-
* `MeshRenderer.mesh` field takes. A mesh
|
|
8017
|
-
*
|
|
8204
|
+
* `MeshRenderer.mesh` field takes. A `.mesh.json` file loads the same primitives by address
|
|
8205
|
+
* (`app.assets.load("meshes/crate.mesh.json")`), so a scene file can name one. A glTF mesh
|
|
8206
|
+
* arrives as part of a `ModelAsset` instead — a glTF is a tree of meshes, materials, and
|
|
8207
|
+
* animations, not one buffer.
|
|
8018
8208
|
*
|
|
8019
8209
|
* @example
|
|
8020
8210
|
* ```ts
|
|
@@ -8270,7 +8460,10 @@ var MeshAsset = class {
|
|
|
8270
8460
|
* ```
|
|
8271
8461
|
*/
|
|
8272
8462
|
static box(app, options) {
|
|
8273
|
-
return
|
|
8463
|
+
return publishPrimitive(app, {
|
|
8464
|
+
primitive: "box",
|
|
8465
|
+
options: options ?? {}
|
|
8466
|
+
});
|
|
8274
8467
|
}
|
|
8275
8468
|
/**
|
|
8276
8469
|
* Creates a sphere template and publishes it.
|
|
@@ -8280,7 +8473,10 @@ var MeshAsset = class {
|
|
|
8280
8473
|
* @returns The handle, with one holder.
|
|
8281
8474
|
*/
|
|
8282
8475
|
static sphere(app, options) {
|
|
8283
|
-
return
|
|
8476
|
+
return publishPrimitive(app, {
|
|
8477
|
+
primitive: "sphere",
|
|
8478
|
+
options: options ?? {}
|
|
8479
|
+
});
|
|
8284
8480
|
}
|
|
8285
8481
|
/**
|
|
8286
8482
|
* Creates a quad template in the XY plane and publishes it.
|
|
@@ -8290,7 +8486,10 @@ var MeshAsset = class {
|
|
|
8290
8486
|
* @returns The handle, with one holder.
|
|
8291
8487
|
*/
|
|
8292
8488
|
static plane(app, options) {
|
|
8293
|
-
return
|
|
8489
|
+
return publishPrimitive(app, {
|
|
8490
|
+
primitive: "plane",
|
|
8491
|
+
options: options ?? {}
|
|
8492
|
+
});
|
|
8294
8493
|
}
|
|
8295
8494
|
/**
|
|
8296
8495
|
* Creates a subdivided grid in the XZ plane and publishes it.
|
|
@@ -8300,8 +8499,10 @@ var MeshAsset = class {
|
|
|
8300
8499
|
* @returns The handle, with one holder.
|
|
8301
8500
|
*/
|
|
8302
8501
|
static ground(app, options) {
|
|
8303
|
-
|
|
8304
|
-
|
|
8502
|
+
return publishPrimitive(app, {
|
|
8503
|
+
primitive: "ground",
|
|
8504
|
+
options: options ?? {}
|
|
8505
|
+
});
|
|
8305
8506
|
}
|
|
8306
8507
|
/**
|
|
8307
8508
|
* Creates a cylinder template standing along Y and publishes it.
|
|
@@ -8311,7 +8512,10 @@ var MeshAsset = class {
|
|
|
8311
8512
|
* @returns The handle, with one holder.
|
|
8312
8513
|
*/
|
|
8313
8514
|
static cylinder(app, options) {
|
|
8314
|
-
return
|
|
8515
|
+
return publishPrimitive(app, {
|
|
8516
|
+
primitive: "cylinder",
|
|
8517
|
+
options: options ?? {}
|
|
8518
|
+
});
|
|
8315
8519
|
}
|
|
8316
8520
|
/**
|
|
8317
8521
|
* Creates a capsule template standing along Y and publishes it.
|
|
@@ -8321,7 +8525,10 @@ var MeshAsset = class {
|
|
|
8321
8525
|
* @returns The handle, with one holder.
|
|
8322
8526
|
*/
|
|
8323
8527
|
static capsule(app, options) {
|
|
8324
|
-
return
|
|
8528
|
+
return publishPrimitive(app, {
|
|
8529
|
+
primitive: "capsule",
|
|
8530
|
+
options: options ?? {}
|
|
8531
|
+
});
|
|
8325
8532
|
}
|
|
8326
8533
|
/**
|
|
8327
8534
|
* Creates a torus template in the XZ plane and publishes it.
|
|
@@ -8331,7 +8538,10 @@ var MeshAsset = class {
|
|
|
8331
8538
|
* @returns The handle, with one holder.
|
|
8332
8539
|
*/
|
|
8333
8540
|
static torus(app, options) {
|
|
8334
|
-
return
|
|
8541
|
+
return publishPrimitive(app, {
|
|
8542
|
+
primitive: "torus",
|
|
8543
|
+
options: options ?? {}
|
|
8544
|
+
});
|
|
8335
8545
|
}
|
|
8336
8546
|
/**
|
|
8337
8547
|
* Creates a template from raw vertex data and publishes it.
|
|
@@ -8381,20 +8591,30 @@ function copyRange(source, target, components, vertexOffset, count) {
|
|
|
8381
8591
|
target.set(source.subarray(0, floats), base);
|
|
8382
8592
|
}
|
|
8383
8593
|
/**
|
|
8384
|
-
*
|
|
8594
|
+
* Builds a primitive mesh asset without publishing it. The factories and the `.mesh.json` loader
|
|
8595
|
+
* both go through here, so a primitive is the same whether code or a file asked for it.
|
|
8385
8596
|
*
|
|
8386
|
-
* @param
|
|
8387
|
-
* @
|
|
8597
|
+
* @param app - The app whose engine uploads the geometry; a headless app uploads nothing.
|
|
8598
|
+
* @param name - A human-readable name.
|
|
8599
|
+
* @param definition - The primitive and its options.
|
|
8600
|
+
* @returns The asset, owned by the caller.
|
|
8601
|
+
*
|
|
8602
|
+
* @internal
|
|
8388
8603
|
*/
|
|
8389
|
-
function
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
|
|
8393
|
-
|
|
8394
|
-
|
|
8395
|
-
|
|
8396
|
-
|
|
8397
|
-
|
|
8604
|
+
function createPrimitiveMeshAsset(app, name, definition) {
|
|
8605
|
+
const handles = buildMeshTemplate(app.isHeadless, app.lite.scene, app.lite.engine, (engine) => buildPrimitiveTemplate(engine, definition));
|
|
8606
|
+
return new MeshAsset(name, handles.mesh, handles.scene, null, handles.engine);
|
|
8607
|
+
}
|
|
8608
|
+
/**
|
|
8609
|
+
* Builds a primitive and registers it as an in-memory asset named after the primitive.
|
|
8610
|
+
*
|
|
8611
|
+
* @param app - The app that owns the engine and the asset service.
|
|
8612
|
+
* @param definition - The primitive and its options.
|
|
8613
|
+
* @returns The handle, with one holder.
|
|
8614
|
+
*/
|
|
8615
|
+
function publishPrimitive(app, definition) {
|
|
8616
|
+
const asset = createPrimitiveMeshAsset(app, definition.primitive, definition);
|
|
8617
|
+
return app.assets.register(asset, { type: MESH_ASSET_TYPE });
|
|
8398
8618
|
}
|
|
8399
8619
|
/**
|
|
8400
8620
|
* Builds a template — skipping the upload under a headless app — and registers it as an in-memory
|
|
@@ -8487,7 +8707,7 @@ function forceDeviceLossForTesting(engine) {
|
|
|
8487
8707
|
* @example
|
|
8488
8708
|
* ```ts
|
|
8489
8709
|
* const picker = createScenePicker(scene);
|
|
8490
|
-
* const hit = await pickScenePixel(picker,
|
|
8710
|
+
* const hit = await pickScenePixel(picker, scene, 120, 80, null, []);
|
|
8491
8711
|
* ```
|
|
8492
8712
|
*
|
|
8493
8713
|
* @internal
|
|
@@ -8496,44 +8716,116 @@ function createScenePicker(scene) {
|
|
|
8496
8716
|
return createGpuPicker(scene);
|
|
8497
8717
|
}
|
|
8498
8718
|
/**
|
|
8499
|
-
*
|
|
8719
|
+
* The ratio Lite's picker multiplies a CSS pixel by, on one axis.
|
|
8720
|
+
*
|
|
8721
|
+
* @param backing - The canvas's backing-store size on that axis.
|
|
8722
|
+
* @param client - Its CSS layout size, or `0` when it has none.
|
|
8723
|
+
* @returns `backing / (client || backing)`, exactly as Lite computes it, or `1` for an empty canvas.
|
|
8724
|
+
*/
|
|
8725
|
+
function liteScale(backing, client) {
|
|
8726
|
+
const css = client || backing;
|
|
8727
|
+
return css > 0 && backing > 0 ? backing / css : 1;
|
|
8728
|
+
}
|
|
8729
|
+
/**
|
|
8730
|
+
* Converts a backing-store coordinate to the CSS coordinate Lite's picker multiplies back.
|
|
8500
8731
|
*
|
|
8501
8732
|
* @remarks
|
|
8502
|
-
*
|
|
8503
|
-
*
|
|
8504
|
-
*
|
|
8505
|
-
*
|
|
8733
|
+
* Lite renders its 1×1 target at the exact sub-pixel point it computes (`computePickVP`,
|
|
8734
|
+
* `lib/picking/gpu-picker.js` ~96 and ~224 in 1.34.0), so a whole-number coordinate samples a
|
|
8735
|
+
* pixel **corner**, not a centre; add 0.5 for the centre. The floored value only feeds the viewport
|
|
8736
|
+
* bounds check, the clamp and the discard rule's `fragmentCoord`. `x / scale * scale` can land one
|
|
8737
|
+
* unit in the last place below `x`, which would put a point on the viewport's edge outside it, or
|
|
8738
|
+
* floor to the pixel before; the result is nudged up until Lite's product is not below `x`.
|
|
8506
8739
|
*
|
|
8507
|
-
* @param
|
|
8508
|
-
* @param
|
|
8509
|
-
* @
|
|
8510
|
-
* @param options - A mesh filter, identities to ignore, or a WGSL discard rule.
|
|
8511
|
-
* @returns The hit. Calls on one picker run one at a time.
|
|
8740
|
+
* @param value - The backing-store coordinate.
|
|
8741
|
+
* @param scale - Lite's ratio on that axis.
|
|
8742
|
+
* @returns The CSS coordinate.
|
|
8512
8743
|
*
|
|
8513
8744
|
* @internal
|
|
8514
8745
|
*/
|
|
8515
|
-
function
|
|
8516
|
-
|
|
8746
|
+
function toLitePickCoordinate(value, scale) {
|
|
8747
|
+
if (scale === 1) return value;
|
|
8748
|
+
let css = value / scale;
|
|
8749
|
+
for (let attempt = 0; attempt < 4 && css * scale < value; attempt += 1) css += Math.max(Math.abs(css) * Number.EPSILON, Number.MIN_VALUE);
|
|
8750
|
+
return css;
|
|
8517
8751
|
}
|
|
8518
8752
|
/**
|
|
8519
|
-
* Picks the object under one
|
|
8520
|
-
* accepts.
|
|
8753
|
+
* Picks the object under one backing-store pixel of the scene's canvas.
|
|
8521
8754
|
*
|
|
8522
8755
|
* @remarks
|
|
8523
|
-
*
|
|
8524
|
-
*
|
|
8525
|
-
*
|
|
8756
|
+
* Coordinates are backing-store pixels — `canvas.width`/`height`, the space `Camera.worldToScreen`
|
|
8757
|
+
* and `<Pointer>/position` use. They are converted to the CSS pixels Lite's picker takes (see the
|
|
8758
|
+
* module notes). Meshes `accept` rejects, and the identities in `ignore`, neither occlude nor return.
|
|
8526
8759
|
*
|
|
8527
8760
|
* @param picker - The picker.
|
|
8528
|
-
* @param
|
|
8529
|
-
* @param
|
|
8530
|
-
* @param
|
|
8531
|
-
* @
|
|
8761
|
+
* @param scene - The scene the picker was created for; its surface's canvas sets the ratio.
|
|
8762
|
+
* @param x - The backing-store pixel x, from the canvas's left edge.
|
|
8763
|
+
* @param y - The backing-store pixel y, from the canvas's top edge.
|
|
8764
|
+
* @param accept - Decides whether a mesh may be picked, from the ignifx tag that owns it, or `null`
|
|
8765
|
+
* to consider every mesh.
|
|
8766
|
+
* @param ignore - Earlier hits to look through; a thin-instance hit skips only that instance.
|
|
8767
|
+
* @returns The hit. Calls on one picker run one at a time.
|
|
8768
|
+
*
|
|
8769
|
+
* @example
|
|
8770
|
+
* ```ts
|
|
8771
|
+
* const picker = createScenePicker(scene);
|
|
8772
|
+
* const hit = await pickScenePixel(picker, scene, 120, 80, null, []);
|
|
8773
|
+
* ```
|
|
8532
8774
|
*
|
|
8533
8775
|
* @internal
|
|
8534
8776
|
*/
|
|
8535
|
-
function
|
|
8536
|
-
|
|
8777
|
+
function pickScenePixel(picker, scene, x, y, accept, ignore) {
|
|
8778
|
+
const canvas = scene.surface.canvas;
|
|
8779
|
+
const clientWidth = "clientWidth" in canvas ? canvas.clientWidth : 0;
|
|
8780
|
+
const clientHeight = "clientHeight" in canvas ? canvas.clientHeight : 0;
|
|
8781
|
+
const cssX = toLitePickCoordinate(x, liteScale(canvas.width, clientWidth));
|
|
8782
|
+
const cssY = toLitePickCoordinate(y, liteScale(canvas.height, clientHeight));
|
|
8783
|
+
const options = {};
|
|
8784
|
+
if (accept !== null) options.filter = (mesh) => accept(readOwnerTag(mesh), mesh);
|
|
8785
|
+
if (ignore.length > 0) options.ignore = toLiteIgnore(ignore);
|
|
8786
|
+
return pickAsync(picker, cssX, cssY, options);
|
|
8787
|
+
}
|
|
8788
|
+
/**
|
|
8789
|
+
* Folds earlier hits into Lite's ignore list, one entry per mesh.
|
|
8790
|
+
*
|
|
8791
|
+
* @remarks
|
|
8792
|
+
* Lite reads only the **first** entry it finds for a mesh (`lib/picking/picking-ignore.js`,
|
|
8793
|
+
* `forMesh`), so several hits on one mesh are merged here: a whole-mesh hit wins, thin instances
|
|
8794
|
+
* that form one contiguous run become a range, and otherwise the lowest index is kept — a Lite
|
|
8795
|
+
* 1.34 limit, which a caller cycling through instances of one renderer can meet.
|
|
8796
|
+
*
|
|
8797
|
+
* @param ignore - The hits to look through.
|
|
8798
|
+
* @returns Lite's entries.
|
|
8799
|
+
*/
|
|
8800
|
+
function toLiteIgnore(ignore) {
|
|
8801
|
+
const byMesh = /* @__PURE__ */ new Map();
|
|
8802
|
+
for (const identity of ignore) {
|
|
8803
|
+
const indices = byMesh.get(identity.mesh);
|
|
8804
|
+
if (identity.thinInstanceIndex < 0 || indices === null) byMesh.set(identity.mesh, null);
|
|
8805
|
+
else if (indices === void 0) byMesh.set(identity.mesh, [identity.thinInstanceIndex]);
|
|
8806
|
+
else indices.push(identity.thinInstanceIndex);
|
|
8807
|
+
}
|
|
8808
|
+
const entries = [];
|
|
8809
|
+
for (const [mesh, indices] of byMesh) {
|
|
8810
|
+
if (indices === null) {
|
|
8811
|
+
entries.push({ mesh });
|
|
8812
|
+
continue;
|
|
8813
|
+
}
|
|
8814
|
+
const sorted = [...new Set(indices)].toSorted((a, b) => a - b);
|
|
8815
|
+
const first = sorted[0] ?? 0;
|
|
8816
|
+
const last = sorted.at(-1) ?? first;
|
|
8817
|
+
entries.push(sorted.length === 1 || last - first + 1 !== sorted.length ? {
|
|
8818
|
+
mesh,
|
|
8819
|
+
thinInstanceIndex: first
|
|
8820
|
+
} : {
|
|
8821
|
+
mesh,
|
|
8822
|
+
thinInstanceRange: {
|
|
8823
|
+
start: first,
|
|
8824
|
+
count: sorted.length
|
|
8825
|
+
}
|
|
8826
|
+
});
|
|
8827
|
+
}
|
|
8828
|
+
return entries;
|
|
8537
8829
|
}
|
|
8538
8830
|
/**
|
|
8539
8831
|
* Releases a picker's GPU resources.
|
|
@@ -9381,7 +9673,8 @@ function createMaterialCacheResets() {
|
|
|
9381
9673
|
return {
|
|
9382
9674
|
found: /* @__PURE__ */ new Set(),
|
|
9383
9675
|
seen: /* @__PURE__ */ new WeakSet(),
|
|
9384
|
-
unconfirmed: false
|
|
9676
|
+
unconfirmed: false,
|
|
9677
|
+
retries: 0
|
|
9385
9678
|
};
|
|
9386
9679
|
}
|
|
9387
9680
|
/**
|
|
@@ -9428,6 +9721,9 @@ function trackMaterialCacheResets(scene, resets) {
|
|
|
9428
9721
|
* straight away, so the family's cache reset is known before anything needs it; see
|
|
9429
9722
|
* {@link MaterialCacheResets}.
|
|
9430
9723
|
*
|
|
9724
|
+
* The engine frees nothing the rebuild retires until the rebuild has finished; see
|
|
9725
|
+
* `holdGpuRetirements`.
|
|
9726
|
+
*
|
|
9431
9727
|
* @param scene - The scene to rebuild.
|
|
9432
9728
|
* @param resets - The scene's record of cache resets.
|
|
9433
9729
|
* @returns A promise that resolves when the rebuild has finished.
|
|
@@ -9435,14 +9731,111 @@ function trackMaterialCacheResets(scene, resets) {
|
|
|
9435
9731
|
* @internal
|
|
9436
9732
|
*/
|
|
9437
9733
|
async function rebuildRenderables(scene, resets) {
|
|
9438
|
-
|
|
9734
|
+
const release = holdGpuRetirements(scene.surface.engine);
|
|
9735
|
+
try {
|
|
9736
|
+
if (resets === void 0) {
|
|
9737
|
+
await rebuildAcrossMaterialSwaps(scene);
|
|
9738
|
+
return;
|
|
9739
|
+
}
|
|
9740
|
+
trackMaterialCacheResets(scene, resets);
|
|
9741
|
+
takeUnconfirmed(resets);
|
|
9742
|
+
await rebuildAcrossMaterialSwaps(scene, resets);
|
|
9743
|
+
if (takeUnconfirmed(resets)) await rebuildAcrossMaterialSwaps(scene, resets);
|
|
9744
|
+
} finally {
|
|
9745
|
+
release();
|
|
9746
|
+
}
|
|
9747
|
+
}
|
|
9748
|
+
/** How many times {@link rebuildAcrossMaterialSwaps} starts over after a swap broke a rebuild. */
|
|
9749
|
+
const MAX_SWAP_RETRIES = 2;
|
|
9750
|
+
/**
|
|
9751
|
+
* Runs `rebuildSceneRenderables`, and runs it again when a material swap landed during it and made
|
|
9752
|
+
* it throw.
|
|
9753
|
+
*
|
|
9754
|
+
* @remarks
|
|
9755
|
+
* A group builder awaits its shader modules (`import()`) before it reads each mesh's material, and
|
|
9756
|
+
* on a loaded machine that await spans frames. A mesh given a material of another family meanwhile
|
|
9757
|
+
* reaches the old family's builder: the Standard one reads `diffuseColor[0]` off a PBR material and
|
|
9758
|
+
* throws `Cannot read properties of undefined (reading '0')` (`buildStandardMeshRenderables`,
|
|
9759
|
+
* `writeStdMaterialData`, `lib/material/standard/standard-pipeline.js` 278). Lite expects swaps to
|
|
9760
|
+
* land mid-build — it puts the group's old renderables back on a throw, and a rebuild that does not
|
|
9761
|
+
* throw re-sorts the groups and goes round again (`membershipDrifted`, `lib/scene/scene-rebuild.js`)
|
|
9762
|
+
* — but it rethrows, so the rest of the rebuild is skipped. Starting over sorts the groups from the
|
|
9763
|
+
* current materials. A throw with every material unchanged is not this race, and is rethrown.
|
|
9764
|
+
*
|
|
9765
|
+
* @param scene - The scene to rebuild.
|
|
9766
|
+
* @param resets - The scene's record, which counts the restarts.
|
|
9767
|
+
* @param retries - How many more times to start over.
|
|
9768
|
+
* @returns A promise that resolves when a rebuild has finished.
|
|
9769
|
+
*/
|
|
9770
|
+
async function rebuildAcrossMaterialSwaps(scene, resets, retries = MAX_SWAP_RETRIES) {
|
|
9771
|
+
const meshes = scene.meshes;
|
|
9772
|
+
const materials = meshes.map((mesh) => mesh.material);
|
|
9773
|
+
try {
|
|
9439
9774
|
await rebuildSceneRenderables(scene);
|
|
9440
|
-
|
|
9775
|
+
} catch (error) {
|
|
9776
|
+
if (!(scene.meshes !== meshes || meshes.some((mesh, index) => mesh.material !== materials[index])) || retries <= 0) throw error;
|
|
9777
|
+
if (resets !== void 0) resets.retries += 1;
|
|
9778
|
+
await rebuildAcrossMaterialSwaps(scene, resets, retries - 1);
|
|
9441
9779
|
}
|
|
9442
|
-
|
|
9443
|
-
|
|
9444
|
-
|
|
9445
|
-
|
|
9780
|
+
}
|
|
9781
|
+
/**
|
|
9782
|
+
* Keeps an engine from freeing retired GPU resources until the returned function is called.
|
|
9783
|
+
*
|
|
9784
|
+
* @remarks
|
|
9785
|
+
* `rebuildSceneRenderables` rebuilds one material group at a time and retires each group's old
|
|
9786
|
+
* uniform buffers and bind groups as soon as that group is done, but it only bumps
|
|
9787
|
+
* `_renderableVersion` and re-records the frame graph after the **last** group
|
|
9788
|
+
* (`rebuildSceneGroups`, `lib/scene/scene-rebuild.js`). Until then every frame still draws the old
|
|
9789
|
+
* renderables. Lite frees a retired resource once the next submitted frame has finished
|
|
9790
|
+
* (`flushGpuResourceRetirements`, `lib/engine/gpu-resource-retirement.js`), so when a later group
|
|
9791
|
+
* takes two frames or more to build — a slow machine, or a pipeline to compile — the following
|
|
9792
|
+
* frames submit buffers that are already destroyed, and WebGPU rejects them ("[Buffer] used in
|
|
9793
|
+
* submit while destroyed"). Holding the releases until the whole rebuild has finished means they
|
|
9794
|
+
* are fenced behind the first frame that draws the new renderables.
|
|
9795
|
+
*
|
|
9796
|
+
* While a hold is active, `_flushGpuRetirements` reads as absent, so `renderFrame` skips it and
|
|
9797
|
+
* the retired resources wait in the engine's list. Lite installs the flush with `??=`, so an
|
|
9798
|
+
* assignment it makes meanwhile is kept only when it had none before. Holds nest.
|
|
9799
|
+
*
|
|
9800
|
+
* @param engine - The engine that renders the scene being rebuilt.
|
|
9801
|
+
* @returns A function that ends this hold. Call it once.
|
|
9802
|
+
*/
|
|
9803
|
+
function holdGpuRetirements(engine) {
|
|
9804
|
+
const target = engine;
|
|
9805
|
+
let hold = target._igxRetirementHold;
|
|
9806
|
+
if (hold === void 0) {
|
|
9807
|
+
const state = {
|
|
9808
|
+
count: 0,
|
|
9809
|
+
flush: target._flushGpuRetirements
|
|
9810
|
+
};
|
|
9811
|
+
Object.defineProperty(target, "_flushGpuRetirements", {
|
|
9812
|
+
configurable: true,
|
|
9813
|
+
enumerable: true,
|
|
9814
|
+
get: () => state.count > 0 ? void 0 : state.flush,
|
|
9815
|
+
set: (flush) => {
|
|
9816
|
+
state.flush ??= flush;
|
|
9817
|
+
}
|
|
9818
|
+
});
|
|
9819
|
+
Object.defineProperty(target, "_igxRetirementHold", {
|
|
9820
|
+
configurable: true,
|
|
9821
|
+
value: state
|
|
9822
|
+
});
|
|
9823
|
+
hold = state;
|
|
9824
|
+
}
|
|
9825
|
+
const held = hold;
|
|
9826
|
+
held.count += 1;
|
|
9827
|
+
return () => {
|
|
9828
|
+
held.count -= 1;
|
|
9829
|
+
if (held.count === 0) {
|
|
9830
|
+
Object.defineProperty(target, "_flushGpuRetirements", {
|
|
9831
|
+
configurable: true,
|
|
9832
|
+
enumerable: true,
|
|
9833
|
+
writable: true,
|
|
9834
|
+
value: held.flush
|
|
9835
|
+
});
|
|
9836
|
+
delete target._igxRetirementHold;
|
|
9837
|
+
}
|
|
9838
|
+
};
|
|
9446
9839
|
}
|
|
9447
9840
|
/**
|
|
9448
9841
|
* Reads and clears {@link MaterialCacheResets.unconfirmed}.
|
|
@@ -9620,18 +10013,35 @@ function createPicker(scene) {
|
|
|
9620
10013
|
return createScenePicker(scene);
|
|
9621
10014
|
}
|
|
9622
10015
|
/**
|
|
9623
|
-
*
|
|
10016
|
+
* Loads the overlay module (`docs/architecture/07-rendering.md` §2.10).
|
|
10017
|
+
*
|
|
10018
|
+
* @remarks
|
|
10019
|
+
* It is loaded on first use, so a game that never opens an overlay ships none of it
|
|
10020
|
+
* (`CONSTITUTION.md` §2.5).
|
|
10021
|
+
*
|
|
10022
|
+
* @returns The function that opens an overlay scene.
|
|
10023
|
+
*
|
|
10024
|
+
* @internal
|
|
10025
|
+
*/
|
|
10026
|
+
async function loadOverlayOpener() {
|
|
10027
|
+
return (await import("./overlay-CjVgsfrm.js")).openOverlayScene;
|
|
10028
|
+
}
|
|
10029
|
+
/**
|
|
10030
|
+
* Picks the object under one backing-store pixel, optionally restricted to the meshes a predicate
|
|
10031
|
+
* accepts and looking through earlier hits.
|
|
9624
10032
|
*
|
|
9625
10033
|
* @param picker - The app's picker.
|
|
9626
|
-
* @param
|
|
9627
|
-
* @param
|
|
10034
|
+
* @param scene - The scene the picker belongs to.
|
|
10035
|
+
* @param x - The backing-store pixel x, from the canvas's left edge.
|
|
10036
|
+
* @param y - The backing-store pixel y, from the canvas's top edge.
|
|
9628
10037
|
* @param accept - The tag predicate, or `null` to consider every mesh.
|
|
10038
|
+
* @param ignore - Earlier hits to look through.
|
|
9629
10039
|
* @returns Lite's picking info.
|
|
9630
10040
|
*
|
|
9631
10041
|
* @internal
|
|
9632
10042
|
*/
|
|
9633
|
-
function pickPixel(picker, x, y, accept) {
|
|
9634
|
-
return
|
|
10043
|
+
function pickPixel(picker, scene, x, y, accept, ignore) {
|
|
10044
|
+
return pickScenePixel(picker, scene, x, y, accept, ignore);
|
|
9635
10045
|
}
|
|
9636
10046
|
/**
|
|
9637
10047
|
* Installs one hidden probe per material so their families are compiled at `registerScene`
|
|
@@ -10154,6 +10564,13 @@ var RendererImpl = class {
|
|
|
10154
10564
|
/** `true` once a light gained or lost a shadow generator, so the next rebuild needs fresh layouts. */
|
|
10155
10565
|
needsShadowLayoutReset = false;
|
|
10156
10566
|
/**
|
|
10567
|
+
* `true` from the moment the render sync system queues a renderable rebuild until the last one it
|
|
10568
|
+
* owes has finished. A light waits for it to be `false` before it gains or loses a shadow generator.
|
|
10569
|
+
*/
|
|
10570
|
+
isRebuildInFlight = false;
|
|
10571
|
+
/** Scene changes held back until the rebuild in flight has finished; see {@link RendererImpl.afterRebuild}. */
|
|
10572
|
+
#afterRebuild = [];
|
|
10573
|
+
/**
|
|
10157
10574
|
* The PBR deformation kinds (`PBR_DEFORMER` bits) a full renderable build has already composed on
|
|
10158
10575
|
* this engine. A kind missing from it gets fresh layouts on its first rebuild (`../lite/pbr-deformers.ts`).
|
|
10159
10576
|
*/
|
|
@@ -10178,6 +10595,10 @@ var RendererImpl = class {
|
|
|
10178
10595
|
#countersMeshes;
|
|
10179
10596
|
#countersRebuilds;
|
|
10180
10597
|
#picker = null;
|
|
10598
|
+
/** The mesh behind each hit this renderer returned, so a later pick can be told to ignore it. */
|
|
10599
|
+
#pickIdentities = /* @__PURE__ */ new WeakMap();
|
|
10600
|
+
/** The open overlays, by their Lite scene. */
|
|
10601
|
+
#overlays = /* @__PURE__ */ new Map();
|
|
10181
10602
|
#warmUp = null;
|
|
10182
10603
|
#syncSystem = null;
|
|
10183
10604
|
/** Adapter chunks a component asked for; `app.start()` waits for them before it reconciles. */
|
|
@@ -10188,8 +10609,16 @@ var RendererImpl = class {
|
|
|
10188
10609
|
#resolutionScale = 1;
|
|
10189
10610
|
#pixelRatio;
|
|
10190
10611
|
#profileTasks = false;
|
|
10612
|
+
#animateMaterialsInEditMode = true;
|
|
10613
|
+
/** The shader clock `ShaderUniformSystem` accumulates, which edit mode's post effects read too. */
|
|
10614
|
+
#shaderClock = {
|
|
10615
|
+
time: 0,
|
|
10616
|
+
unscaledTime: 0,
|
|
10617
|
+
deltaTime: 0
|
|
10618
|
+
};
|
|
10191
10619
|
#isSceneRegistered = false;
|
|
10192
10620
|
#isLoopRunning = false;
|
|
10621
|
+
#isDisposed = false;
|
|
10193
10622
|
/** The clear colour as authored, in sRGB, before image processing. */
|
|
10194
10623
|
#authoredClear = {
|
|
10195
10624
|
r: 0,
|
|
@@ -10365,6 +10794,55 @@ var RendererImpl = class {
|
|
|
10365
10794
|
else disableGpuTiming(this.engine);
|
|
10366
10795
|
}
|
|
10367
10796
|
/**
|
|
10797
|
+
* Whether the shader clock runs in an edit-mode app.
|
|
10798
|
+
*
|
|
10799
|
+
* @returns `true` unless an editor turned material animation off.
|
|
10800
|
+
*/
|
|
10801
|
+
get animateMaterialsInEditMode() {
|
|
10802
|
+
return this.#animateMaterialsInEditMode;
|
|
10803
|
+
}
|
|
10804
|
+
set animateMaterialsInEditMode(value) {
|
|
10805
|
+
this.#animateMaterialsInEditMode = value;
|
|
10806
|
+
}
|
|
10807
|
+
/**
|
|
10808
|
+
* Records this frame's shader clock, as `ShaderUniformSystem` accumulated it: the one clock both
|
|
10809
|
+
* shader materials and, in edit mode, custom post effects read.
|
|
10810
|
+
*
|
|
10811
|
+
* @param time - Scaled seconds the clock has run.
|
|
10812
|
+
* @param unscaledTime - Unscaled seconds the clock has run.
|
|
10813
|
+
* @param deltaTime - This frame's step; `0` while the clock is held.
|
|
10814
|
+
*
|
|
10815
|
+
* @internal
|
|
10816
|
+
*/
|
|
10817
|
+
setShaderClock(time, unscaledTime, deltaTime) {
|
|
10818
|
+
this.#shaderClock.time = time;
|
|
10819
|
+
this.#shaderClock.unscaledTime = unscaledTime;
|
|
10820
|
+
this.#shaderClock.deltaTime = deltaTime;
|
|
10821
|
+
}
|
|
10822
|
+
/**
|
|
10823
|
+
* Whether the shader clock stands still this frame because an edit-mode app turned material
|
|
10824
|
+
* animation off. `app.pause()` is checked separately, by each reader.
|
|
10825
|
+
*
|
|
10826
|
+
* @returns `true` while the editor's toggle holds the clock.
|
|
10827
|
+
*
|
|
10828
|
+
* @internal
|
|
10829
|
+
*/
|
|
10830
|
+
get isShaderClockHeld() {
|
|
10831
|
+
return this.#app.isEditMode && !this.#animateMaterialsInEditMode;
|
|
10832
|
+
}
|
|
10833
|
+
/**
|
|
10834
|
+
* The clock custom post effects upload. In an edit-mode app it is the shader clock materials read
|
|
10835
|
+
* (`setShaderClock`), so the two never drift apart when the editor holds and resumes it
|
|
10836
|
+
* (ADR-0028, amendment of 2026-10-20). A game keeps the app's own clock.
|
|
10837
|
+
*
|
|
10838
|
+
* @returns The clock.
|
|
10839
|
+
*
|
|
10840
|
+
* @internal
|
|
10841
|
+
*/
|
|
10842
|
+
get effectClock() {
|
|
10843
|
+
return this.#app.isEditMode ? this.#shaderClock : this.#app.time;
|
|
10844
|
+
}
|
|
10845
|
+
/**
|
|
10368
10846
|
* GPU draw calls in the last rendered frame.
|
|
10369
10847
|
*
|
|
10370
10848
|
* @returns The count; `0` under a headless app.
|
|
@@ -10434,14 +10912,14 @@ var RendererImpl = class {
|
|
|
10434
10912
|
*
|
|
10435
10913
|
* @param x - The backing-store pixel x, from the canvas's left edge.
|
|
10436
10914
|
* @param y - The backing-store pixel y, from the canvas's top edge.
|
|
10437
|
-
* @param options - An entity filter.
|
|
10915
|
+
* @param options - An entity filter, and what to look through.
|
|
10438
10916
|
* @returns What was hit, or `null` for a miss.
|
|
10439
10917
|
*/
|
|
10440
10918
|
async pickAsync(x, y, options) {
|
|
10441
10919
|
if (this.isHeadless) return null;
|
|
10442
10920
|
const picker = this.#picker ??= createPicker(this.scene);
|
|
10443
|
-
const
|
|
10444
|
-
const info = await pickPixel(picker, x, y,
|
|
10921
|
+
const plan = this.planPick(options);
|
|
10922
|
+
const info = await pickPixel(picker, this.scene, x, y, plan.accept, plan.hits);
|
|
10445
10923
|
return this.resolvePick(info);
|
|
10446
10924
|
}
|
|
10447
10925
|
/**
|
|
@@ -10479,6 +10957,61 @@ var RendererImpl = class {
|
|
|
10479
10957
|
this.#features[feature] = true;
|
|
10480
10958
|
}
|
|
10481
10959
|
/**
|
|
10960
|
+
* Opens an overlay drawn over the finished frame.
|
|
10961
|
+
*
|
|
10962
|
+
* @returns The overlay.
|
|
10963
|
+
* @throws IgnifxError with code `IGX-0728` on a headless app or before the render scene is
|
|
10964
|
+
* registered, and `IGX-0106` when the app is disposed, also while the overlay was opening.
|
|
10965
|
+
*/
|
|
10966
|
+
async openOverlay() {
|
|
10967
|
+
this.#assertOverlayAllowed();
|
|
10968
|
+
const open = await loadOverlayOpener();
|
|
10969
|
+
this.#assertOverlayAllowed();
|
|
10970
|
+
const overlays = this.#overlays;
|
|
10971
|
+
let overlay;
|
|
10972
|
+
try {
|
|
10973
|
+
overlay = await open(this.engine, this.scene, {
|
|
10974
|
+
isPeer: (context) => overlays.has(context),
|
|
10975
|
+
onDispose: (scene) => {
|
|
10976
|
+
overlays.delete(scene);
|
|
10977
|
+
},
|
|
10978
|
+
onError: (error) => {
|
|
10979
|
+
this.#app.onError.emit({
|
|
10980
|
+
error,
|
|
10981
|
+
source: "system",
|
|
10982
|
+
phase: null,
|
|
10983
|
+
entity: null,
|
|
10984
|
+
component: null
|
|
10985
|
+
});
|
|
10986
|
+
}
|
|
10987
|
+
});
|
|
10988
|
+
} catch (error) {
|
|
10989
|
+
if (this.#isDisposed) throw overlayAfterDisposeError();
|
|
10990
|
+
throw error;
|
|
10991
|
+
}
|
|
10992
|
+
if (this.#isDisposed) {
|
|
10993
|
+
overlay.dispose();
|
|
10994
|
+
throw overlayAfterDisposeError();
|
|
10995
|
+
}
|
|
10996
|
+
overlays.set(overlay.lite.scene, overlay);
|
|
10997
|
+
return overlay;
|
|
10998
|
+
}
|
|
10999
|
+
/**
|
|
11000
|
+
* Refuses an overlay on a disposed or headless app, or before the render scene is registered.
|
|
11001
|
+
*
|
|
11002
|
+
* @throws IgnifxError with code `IGX-0106` once the app is disposed, `IGX-0728` otherwise.
|
|
11003
|
+
*/
|
|
11004
|
+
#assertOverlayAllowed() {
|
|
11005
|
+
if (this.#isDisposed) throw overlayAfterDisposeError();
|
|
11006
|
+
if (this.isHeadless || !this.#isSceneRegistered) throw new IgnifxError(CoreErrorCode.overlayNeedsRenderScene, "openOverlay() needs a canvas-backed app whose render scene is registered.", {
|
|
11007
|
+
context: {
|
|
11008
|
+
member: "app.renderer.openOverlay()",
|
|
11009
|
+
headless: this.isHeadless
|
|
11010
|
+
},
|
|
11011
|
+
hint: this.isHeadless ? "A headless app draws nothing, so it has no overlay. Create the app with a canvas." : "Call it after app.start() has resolved."
|
|
11012
|
+
});
|
|
11013
|
+
}
|
|
11014
|
+
/**
|
|
10482
11015
|
* Registers a probe that answers whether another rendering context has a camera of its own.
|
|
10483
11016
|
*
|
|
10484
11017
|
* @param probe - Answers `true` while the caller has an active camera for the world.
|
|
@@ -10547,10 +11080,52 @@ var RendererImpl = class {
|
|
|
10547
11080
|
readTargetSizePx(this.engine, out);
|
|
10548
11081
|
}
|
|
10549
11082
|
/**
|
|
11083
|
+
* Turns a pick's options into the mesh predicate and the earlier hits Lite looks through.
|
|
11084
|
+
*
|
|
11085
|
+
* @param options - The caller's options.
|
|
11086
|
+
* @returns The predicate — `null` when every mesh may be picked — and the hits to ignore.
|
|
11087
|
+
*
|
|
11088
|
+
* @internal
|
|
11089
|
+
*/
|
|
11090
|
+
planPick(options) {
|
|
11091
|
+
const filter = options?.filter;
|
|
11092
|
+
const ignore = options?.ignore;
|
|
11093
|
+
if (ignore === void 0 || ignore.length === 0) {
|
|
11094
|
+
const world = this.#app.world;
|
|
11095
|
+
return {
|
|
11096
|
+
accept: filter === void 0 ? null : (tag) => acceptsEntityTag(world, tag, filter),
|
|
11097
|
+
hits: []
|
|
11098
|
+
};
|
|
11099
|
+
}
|
|
11100
|
+
const world = this.#app.world;
|
|
11101
|
+
const entities = /* @__PURE__ */ new Set();
|
|
11102
|
+
const components = /* @__PURE__ */ new Set();
|
|
11103
|
+
const hits = [];
|
|
11104
|
+
for (const item of ignore) {
|
|
11105
|
+
const identity = this.#pickIdentities.get(item);
|
|
11106
|
+
if (identity !== void 0) hits.push(identity);
|
|
11107
|
+
else if ("children" in item) {
|
|
11108
|
+
if (!item.isDestroyed && world.getEntityByHandle(item.handle) === item) entities.add(item.handle);
|
|
11109
|
+
} else if ("isDestroyed" in item && !item.isDestroyed && world.getComponentByHandle(item.handle) === item) components.add(item.handle);
|
|
11110
|
+
}
|
|
11111
|
+
if (filter === void 0 && entities.size === 0 && components.size === 0) return {
|
|
11112
|
+
accept: null,
|
|
11113
|
+
hits
|
|
11114
|
+
};
|
|
11115
|
+
return {
|
|
11116
|
+
accept: (tag) => {
|
|
11117
|
+
if (tag === null) return filter === void 0;
|
|
11118
|
+
if (entities.has(tag.entity) || tag.component !== void 0 && components.has(tag.component)) return false;
|
|
11119
|
+
return filter === void 0 || acceptsEntityTag(world, tag, filter);
|
|
11120
|
+
},
|
|
11121
|
+
hits
|
|
11122
|
+
};
|
|
11123
|
+
}
|
|
11124
|
+
/**
|
|
10550
11125
|
* Resolves a Lite pick result back to the entity and component that own the mesh.
|
|
10551
11126
|
*
|
|
10552
11127
|
* @param info - Lite's picking info, from the GPU picker or a CPU ray cast.
|
|
10553
|
-
* @returns What was hit, or `null` for a miss or a mesh
|
|
11128
|
+
* @returns What was hit, or `null` for a miss or a mesh no entity owns.
|
|
10554
11129
|
*
|
|
10555
11130
|
* @internal
|
|
10556
11131
|
*/
|
|
@@ -10562,13 +11137,19 @@ var RendererImpl = class {
|
|
|
10562
11137
|
const entity = world.getEntityByHandle(toEntityHandle(tag.entity));
|
|
10563
11138
|
if (entity === null) return null;
|
|
10564
11139
|
const component = tag.component;
|
|
10565
|
-
|
|
11140
|
+
const thinInstanceIndex = info.thinInstanceIndex >= 0 ? info.thinInstanceIndex : null;
|
|
11141
|
+
const pick = {
|
|
10566
11142
|
entity,
|
|
10567
11143
|
component: component === void 0 ? null : world.getComponentByHandle(toComponentHandle(component)),
|
|
10568
11144
|
point: info.pickedPoint,
|
|
10569
11145
|
normal: info.pickedNormalWorld ?? info.pickedNormal,
|
|
10570
|
-
distance: info.distance
|
|
11146
|
+
distance: info.distance,
|
|
11147
|
+
meshName: readPickedMeshName(info),
|
|
11148
|
+
thinInstanceIndex
|
|
10571
11149
|
};
|
|
11150
|
+
const identity = readPickedIdentity(info);
|
|
11151
|
+
if (identity !== null) this.#pickIdentities.set(pick, identity);
|
|
11152
|
+
return pick;
|
|
10572
11153
|
}
|
|
10573
11154
|
/**
|
|
10574
11155
|
* Records the Lite objects the app owns, so the service keeps working while the app is being
|
|
@@ -10762,11 +11343,47 @@ var RendererImpl = class {
|
|
|
10762
11343
|
counters.set(this.#countersRebuilds, this.renderableRebuilds);
|
|
10763
11344
|
}
|
|
10764
11345
|
/**
|
|
10765
|
-
*
|
|
11346
|
+
* Runs a scene change now, or holds it until the render sync system's rebuild has finished when
|
|
11347
|
+
* one is in flight.
|
|
11348
|
+
*
|
|
11349
|
+
* @remarks
|
|
11350
|
+
* For a change a rebuild must not see half-way: one that changes how many shadow generators the
|
|
11351
|
+
* scene has. A rebuild reads them group by group against layouts cached without that number, so
|
|
11352
|
+
* a group built after the change gets a bind group the layout does not match.
|
|
11353
|
+
*
|
|
11354
|
+
* @param change - The change.
|
|
11355
|
+
*
|
|
11356
|
+
* @internal
|
|
11357
|
+
*/
|
|
11358
|
+
afterRebuild(change) {
|
|
11359
|
+
if (this.isRebuildInFlight) {
|
|
11360
|
+
this.#afterRebuild.push(change);
|
|
11361
|
+
return;
|
|
11362
|
+
}
|
|
11363
|
+
change();
|
|
11364
|
+
}
|
|
11365
|
+
/**
|
|
11366
|
+
* Takes the changes {@link RendererImpl.afterRebuild} held back. The render sync system runs them
|
|
11367
|
+
* once its rebuild has finished. A disposed renderer hands back none: its scene is gone.
|
|
11368
|
+
*
|
|
11369
|
+
* @returns The changes, oldest first.
|
|
11370
|
+
*
|
|
11371
|
+
* @internal
|
|
11372
|
+
*/
|
|
11373
|
+
takeHeldChanges() {
|
|
11374
|
+
const held = this.#afterRebuild.splice(0);
|
|
11375
|
+
return this.#isDisposed ? [] : held;
|
|
11376
|
+
}
|
|
11377
|
+
/**
|
|
11378
|
+
* Releases the open overlays, the picker and the warm-up probes. The core extension registers it
|
|
11379
|
+
* as a disposer.
|
|
10766
11380
|
*
|
|
10767
11381
|
* @internal
|
|
10768
11382
|
*/
|
|
10769
11383
|
dispose() {
|
|
11384
|
+
this.#isDisposed = true;
|
|
11385
|
+
this.#afterRebuild.length = 0;
|
|
11386
|
+
for (const overlay of this.#overlays.values()) overlay.dispose();
|
|
10770
11387
|
const picker = this.#picker;
|
|
10771
11388
|
this.#picker = null;
|
|
10772
11389
|
if (picker !== null) disposeScenePicker(picker);
|
|
@@ -10848,6 +11465,14 @@ function rendererInternals(renderer) {
|
|
|
10848
11465
|
function forceRendererDeviceLossForTesting(renderer) {
|
|
10849
11466
|
rendererInternals(renderer).forceDeviceLossForTesting();
|
|
10850
11467
|
}
|
|
11468
|
+
/**
|
|
11469
|
+
* The error an overlay request gets once the app is disposed.
|
|
11470
|
+
*
|
|
11471
|
+
* @returns `IGX-0106`.
|
|
11472
|
+
*/
|
|
11473
|
+
function overlayAfterDisposeError() {
|
|
11474
|
+
return new IgnifxError(CoreErrorCode.appDisposed, "The app has been disposed; app.renderer.openOverlay() is no longer available.", { context: { member: "app.renderer.openOverlay()" } });
|
|
11475
|
+
}
|
|
10851
11476
|
//#endregion
|
|
10852
11477
|
//#region src/render/instanced-mesh-renderer.ts
|
|
10853
11478
|
/**
|
|
@@ -10865,9 +11490,9 @@ function forceRendererDeviceLossForTesting(renderer) {
|
|
|
10865
11490
|
* abort every other renderable's reconciliation. The LOD pairing's `distance` and `band` are not in
|
|
10866
11491
|
* that set and are reconciled every frame.
|
|
10867
11492
|
*
|
|
10868
|
-
* `pickable` defaults to `false`, the opposite of `MeshRenderer`:
|
|
10869
|
-
*
|
|
10870
|
-
*
|
|
11493
|
+
* `pickable` defaults to `false`, the opposite of `MeshRenderer`: a scatter of thousands of
|
|
11494
|
+
* instances is rarely what a click means. Set it to `true` and `RenderPick.thinInstanceIndex` says
|
|
11495
|
+
* which instance was hit. Headless, the component keeps its slab, count, colours
|
|
10871
11496
|
* and flags and touches no scene (`docs/architecture/07-rendering.md` §6).
|
|
10872
11497
|
*/
|
|
10873
11498
|
/** How many floats one instance matrix occupies. */
|
|
@@ -11305,7 +11930,7 @@ function instancedMeshRendererSchema() {
|
|
|
11305
11930
|
castShadows: bool(true, { tooltip: "Whether the instances are rendered into shadow maps." }),
|
|
11306
11931
|
receiveShadows: bool(true, { tooltip: "Whether shadow maps darken the instances." }),
|
|
11307
11932
|
renderOrder: i32(0, { tooltip: "Sort key within the opaque or transparent phase; lower draws first." }),
|
|
11308
|
-
pickable: bool(false, { tooltip: "Whether picking considers the instances; a hit names
|
|
11933
|
+
pickable: bool(false, { tooltip: "Whether picking considers the instances; a hit names the instance it hit." }),
|
|
11309
11934
|
lod: optional(record({
|
|
11310
11935
|
mesh: asset(MeshAsset, { tooltip: "The coarse mesh drawn beyond the switch distance." }),
|
|
11311
11936
|
distance: f32(40, {
|
|
@@ -12187,6 +12812,7 @@ var Light = class Light extends Component {
|
|
|
12187
12812
|
this.#warnAboutShadows(renderer);
|
|
12188
12813
|
return false;
|
|
12189
12814
|
}
|
|
12815
|
+
if (renderer.isRebuildInFlight) return false;
|
|
12190
12816
|
this.#appliedShadows = wanted;
|
|
12191
12817
|
if (!wanted) {
|
|
12192
12818
|
this.#releaseGenerator(renderer);
|
|
@@ -12245,12 +12871,21 @@ var Light = class Light extends Component {
|
|
|
12245
12871
|
* @param renderer - The rendering service, for the scene.
|
|
12246
12872
|
*/
|
|
12247
12873
|
#teardown(renderer) {
|
|
12248
|
-
this.#
|
|
12874
|
+
const generator = this.#generator;
|
|
12249
12875
|
const light = this.#light;
|
|
12876
|
+
this.#generator = null;
|
|
12250
12877
|
this.#light = null;
|
|
12251
12878
|
this.#appliedType = null;
|
|
12252
12879
|
this.#appliedShadows = false;
|
|
12253
|
-
|
|
12880
|
+
const remove = () => {
|
|
12881
|
+
if (generator !== null) {
|
|
12882
|
+
detachShadows(renderer.scene, light, generator);
|
|
12883
|
+
renderer.needsShadowLayoutReset = true;
|
|
12884
|
+
}
|
|
12885
|
+
if (light !== null) removeLightFromScene(renderer.scene, light);
|
|
12886
|
+
};
|
|
12887
|
+
if (generator === null) remove();
|
|
12888
|
+
else renderer.afterRebuild(remove);
|
|
12254
12889
|
}
|
|
12255
12890
|
};
|
|
12256
12891
|
/**
|
|
@@ -13289,6 +13924,312 @@ function readDefines(file) {
|
|
|
13289
13924
|
return defines;
|
|
13290
13925
|
}
|
|
13291
13926
|
//#endregion
|
|
13927
|
+
//#region src/render/mesh-file.ts
|
|
13928
|
+
/**
|
|
13929
|
+
* The `.mesh.json` file format (ADR-0029): one primitive and the options its `MeshAsset` factory
|
|
13930
|
+
* takes, so a scene file can name a primitive by address.
|
|
13931
|
+
*
|
|
13932
|
+
* ```json
|
|
13933
|
+
* { "format": "ignifx.mesh", "formatVersion": 1, "primitive": "box", "options": { "size": 1 } }
|
|
13934
|
+
* ```
|
|
13935
|
+
*
|
|
13936
|
+
* One table, {@link MESH_PRIMITIVE_OPTIONS}, drives the runtime check and the JSON Schema, so the
|
|
13937
|
+
* two cannot drift apart.
|
|
13938
|
+
*/
|
|
13939
|
+
/**
|
|
13940
|
+
* The `format` header a `.mesh.json` carries.
|
|
13941
|
+
*
|
|
13942
|
+
* @public
|
|
13943
|
+
*/
|
|
13944
|
+
const MESH_FILE_FORMAT = "ignifx.mesh";
|
|
13945
|
+
/**
|
|
13946
|
+
* The only `.mesh.json` `formatVersion` this build reads.
|
|
13947
|
+
*
|
|
13948
|
+
* @public
|
|
13949
|
+
*/
|
|
13950
|
+
const MESH_FORMAT_VERSION = 1;
|
|
13951
|
+
/**
|
|
13952
|
+
* The address suffix that selects the mesh loader.
|
|
13953
|
+
*
|
|
13954
|
+
* @public
|
|
13955
|
+
*/
|
|
13956
|
+
const MESH_FILE_EXTENSION = ".mesh.json";
|
|
13957
|
+
/**
|
|
13958
|
+
* Every option each primitive takes, and what it holds. The keys are exactly the fields of the
|
|
13959
|
+
* factory's options type (`BoxMeshOptions`, …); the compiler checks that.
|
|
13960
|
+
*
|
|
13961
|
+
* @public
|
|
13962
|
+
*/
|
|
13963
|
+
const MESH_PRIMITIVE_OPTIONS = {
|
|
13964
|
+
box: {
|
|
13965
|
+
size: "length",
|
|
13966
|
+
width: "length",
|
|
13967
|
+
height: "length",
|
|
13968
|
+
depth: "length"
|
|
13969
|
+
},
|
|
13970
|
+
sphere: {
|
|
13971
|
+
diameter: "length",
|
|
13972
|
+
segments: "count"
|
|
13973
|
+
},
|
|
13974
|
+
plane: {
|
|
13975
|
+
size: "length",
|
|
13976
|
+
width: "length",
|
|
13977
|
+
height: "length"
|
|
13978
|
+
},
|
|
13979
|
+
ground: {
|
|
13980
|
+
width: "length",
|
|
13981
|
+
height: "length",
|
|
13982
|
+
subdivisions: "count",
|
|
13983
|
+
uvScale: "pair"
|
|
13984
|
+
},
|
|
13985
|
+
cylinder: {
|
|
13986
|
+
height: "length",
|
|
13987
|
+
diameter: "length",
|
|
13988
|
+
diameterTop: "length",
|
|
13989
|
+
diameterBottom: "length",
|
|
13990
|
+
tessellation: "count"
|
|
13991
|
+
},
|
|
13992
|
+
capsule: {
|
|
13993
|
+
height: "length",
|
|
13994
|
+
radius: "length",
|
|
13995
|
+
tessellation: "count"
|
|
13996
|
+
},
|
|
13997
|
+
torus: {
|
|
13998
|
+
diameter: "length",
|
|
13999
|
+
thickness: "length",
|
|
14000
|
+
tessellation: "count"
|
|
14001
|
+
}
|
|
14002
|
+
};
|
|
14003
|
+
/** The top-level fields a mesh file may carry. */
|
|
14004
|
+
const MESH_FILE_FIELDS = Object.freeze({
|
|
14005
|
+
format: true,
|
|
14006
|
+
formatVersion: true,
|
|
14007
|
+
name: true,
|
|
14008
|
+
primitive: true,
|
|
14009
|
+
options: true
|
|
14010
|
+
});
|
|
14011
|
+
/**
|
|
14012
|
+
* Reads and checks a parsed `.mesh.json`.
|
|
14013
|
+
*
|
|
14014
|
+
* @param parsed - The parsed JSON.
|
|
14015
|
+
* @param address - The file's address, for error messages.
|
|
14016
|
+
* @returns The file.
|
|
14017
|
+
* @throws IgnifxError with code `IGX-0709` when the file has no `ignifx.mesh` header, `IGX-0603`
|
|
14018
|
+
* when its format version is not 1, or `IGX-0507` when it names an unknown primitive, an option the
|
|
14019
|
+
* primitive does not take, or a value the option cannot hold.
|
|
14020
|
+
*
|
|
14021
|
+
* @internal
|
|
14022
|
+
*/
|
|
14023
|
+
function readMeshFile(parsed, address) {
|
|
14024
|
+
const file = asObject(parsed);
|
|
14025
|
+
if (file === null || file["format"] !== "ignifx.mesh") throw new IgnifxError(CoreErrorCode.invalidAssetFile, `${address} is not an ${MESH_FILE_FORMAT} file.`, {
|
|
14026
|
+
context: {
|
|
14027
|
+
file: address,
|
|
14028
|
+
format: MESH_FILE_FORMAT
|
|
14029
|
+
},
|
|
14030
|
+
hint: `A mesh file starts with { "format": "${MESH_FILE_FORMAT}", "formatVersion": ${String(1)} }.`
|
|
14031
|
+
});
|
|
14032
|
+
const version = file["formatVersion"];
|
|
14033
|
+
if (version !== 1) throw new IgnifxError(CoreErrorCode.unsupportedFormatVersion, `${address} declares format version ${JSON.stringify(version ?? null)}, which this build cannot read.`, {
|
|
14034
|
+
context: {
|
|
14035
|
+
file: address,
|
|
14036
|
+
version: JSON.stringify(version ?? null)
|
|
14037
|
+
},
|
|
14038
|
+
hint: `This build reads ${MESH_FILE_FORMAT} version ${String(1)}.`
|
|
14039
|
+
});
|
|
14040
|
+
for (const key of Object.keys(file)) if (!Object.hasOwn(MESH_FILE_FIELDS, key)) throw invalidMesh(address, `"${key}" is not a mesh file field`);
|
|
14041
|
+
const name = file["name"];
|
|
14042
|
+
if (name !== void 0 && typeof name !== "string") throw invalidMesh(address, "\"name\" must be a string");
|
|
14043
|
+
const primitive = readPrimitive(file["primitive"], address);
|
|
14044
|
+
const definition = {
|
|
14045
|
+
primitive,
|
|
14046
|
+
options: readOptions(file["options"], primitive, address)
|
|
14047
|
+
};
|
|
14048
|
+
return {
|
|
14049
|
+
name: name ?? null,
|
|
14050
|
+
definition
|
|
14051
|
+
};
|
|
14052
|
+
}
|
|
14053
|
+
/**
|
|
14054
|
+
* The JSON Schema `@ignifx/vite-plugin` validates `.mesh.json` files against, built from
|
|
14055
|
+
* {@link MESH_PRIMITIVE_OPTIONS}.
|
|
14056
|
+
*
|
|
14057
|
+
* @returns The schema document.
|
|
14058
|
+
*
|
|
14059
|
+
* @example
|
|
14060
|
+
* ```ts
|
|
14061
|
+
* // vite.config.ts
|
|
14062
|
+
* ignifx({ schemas: { formats: { [MESH_FILE_FORMAT]: meshFileJsonSchema() } } });
|
|
14063
|
+
* ```
|
|
14064
|
+
*
|
|
14065
|
+
* @public
|
|
14066
|
+
*/
|
|
14067
|
+
function meshFileJsonSchema() {
|
|
14068
|
+
const branches = [];
|
|
14069
|
+
for (const primitive of MESH_PRIMITIVES) {
|
|
14070
|
+
const properties = {};
|
|
14071
|
+
for (const [option, kind] of Object.entries(MESH_PRIMITIVE_OPTIONS[primitive])) properties[option] = { $ref: `#/$defs/${kind}` };
|
|
14072
|
+
branches.push({ properties: {
|
|
14073
|
+
primitive: { const: primitive },
|
|
14074
|
+
options: {
|
|
14075
|
+
type: "object",
|
|
14076
|
+
additionalProperties: false,
|
|
14077
|
+
properties
|
|
14078
|
+
}
|
|
14079
|
+
} });
|
|
14080
|
+
}
|
|
14081
|
+
return {
|
|
14082
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
14083
|
+
$id: `https://ignifx.com/schemas/${MESH_FILE_FORMAT}.v${String(1)}.json`,
|
|
14084
|
+
title: "ignifx mesh file",
|
|
14085
|
+
type: "object",
|
|
14086
|
+
required: [
|
|
14087
|
+
"format",
|
|
14088
|
+
"formatVersion",
|
|
14089
|
+
"primitive"
|
|
14090
|
+
],
|
|
14091
|
+
additionalProperties: false,
|
|
14092
|
+
properties: {
|
|
14093
|
+
format: { const: MESH_FILE_FORMAT },
|
|
14094
|
+
formatVersion: { const: 1 },
|
|
14095
|
+
name: { type: "string" },
|
|
14096
|
+
primitive: { enum: [...MESH_PRIMITIVES] },
|
|
14097
|
+
options: { type: "object" }
|
|
14098
|
+
},
|
|
14099
|
+
oneOf: branches,
|
|
14100
|
+
$defs: {
|
|
14101
|
+
length: {
|
|
14102
|
+
type: "number",
|
|
14103
|
+
minimum: 0
|
|
14104
|
+
},
|
|
14105
|
+
count: {
|
|
14106
|
+
type: "integer",
|
|
14107
|
+
minimum: 1
|
|
14108
|
+
},
|
|
14109
|
+
pair: {
|
|
14110
|
+
type: "array",
|
|
14111
|
+
items: { type: "number" },
|
|
14112
|
+
minItems: 2,
|
|
14113
|
+
maxItems: 2
|
|
14114
|
+
}
|
|
14115
|
+
}
|
|
14116
|
+
};
|
|
14117
|
+
}
|
|
14118
|
+
/**
|
|
14119
|
+
* Narrows a JSON value to an object.
|
|
14120
|
+
*
|
|
14121
|
+
* @param value - The value.
|
|
14122
|
+
* @returns The object, or `null` when it is not one.
|
|
14123
|
+
*/
|
|
14124
|
+
function asObject(value) {
|
|
14125
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
14126
|
+
return value;
|
|
14127
|
+
}
|
|
14128
|
+
/**
|
|
14129
|
+
* Reads the `primitive` field.
|
|
14130
|
+
*
|
|
14131
|
+
* @param value - The field's value.
|
|
14132
|
+
* @param address - The file's address.
|
|
14133
|
+
* @returns The primitive.
|
|
14134
|
+
* @throws IgnifxError with code `IGX-0507` when it is not one of {@link MESH_PRIMITIVES}.
|
|
14135
|
+
*/
|
|
14136
|
+
function readPrimitive(value, address) {
|
|
14137
|
+
for (const primitive of MESH_PRIMITIVES) if (value === primitive) return primitive;
|
|
14138
|
+
throw invalidMesh(address, `"primitive" is ${JSON.stringify(value ?? null)}; expected one of ${MESH_PRIMITIVES.join(", ")}`);
|
|
14139
|
+
}
|
|
14140
|
+
/**
|
|
14141
|
+
* Reads and checks the `options` field against one primitive's row of the table.
|
|
14142
|
+
*
|
|
14143
|
+
* @param value - The field's value; missing means every option takes its default.
|
|
14144
|
+
* @param primitive - The primitive the options are for.
|
|
14145
|
+
* @param address - The file's address.
|
|
14146
|
+
* @returns A copy of the options.
|
|
14147
|
+
* @throws IgnifxError with code `IGX-0507` when an option is unknown or holds the wrong value.
|
|
14148
|
+
*/
|
|
14149
|
+
function readOptions(value, primitive, address) {
|
|
14150
|
+
if (value === void 0) return {};
|
|
14151
|
+
const options = asObject(value);
|
|
14152
|
+
if (options === null) throw invalidMesh(address, "\"options\" must be an object");
|
|
14153
|
+
const kinds = MESH_PRIMITIVE_OPTIONS[primitive];
|
|
14154
|
+
const result = {};
|
|
14155
|
+
for (const [option, optionValue] of Object.entries(options)) {
|
|
14156
|
+
const kind = Object.hasOwn(kinds, option) ? kinds[option] : void 0;
|
|
14157
|
+
if (kind === void 0) throw invalidMesh(address, `a ${primitive} has no option "${option}"; it takes ${Object.keys(kinds).join(", ")}`);
|
|
14158
|
+
if (!isOptionValue(optionValue, kind)) throw invalidMesh(address, `options.${option} must be ${OPTION_KIND_TEXT[kind]}; got ${JSON.stringify(optionValue)}`);
|
|
14159
|
+
result[option] = optionValue;
|
|
14160
|
+
}
|
|
14161
|
+
return result;
|
|
14162
|
+
}
|
|
14163
|
+
/** How an error message describes each option kind. */
|
|
14164
|
+
const OPTION_KIND_TEXT = {
|
|
14165
|
+
length: "a number of metres, zero or more",
|
|
14166
|
+
count: "a whole number, one or more",
|
|
14167
|
+
pair: "an array of two numbers"
|
|
14168
|
+
};
|
|
14169
|
+
/**
|
|
14170
|
+
* Checks one option value against its kind.
|
|
14171
|
+
*
|
|
14172
|
+
* @param value - The value.
|
|
14173
|
+
* @param kind - What the option holds.
|
|
14174
|
+
* @returns `true` when the value fits.
|
|
14175
|
+
*/
|
|
14176
|
+
function isOptionValue(value, kind) {
|
|
14177
|
+
if (kind === "length") return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
14178
|
+
if (kind === "count") return typeof value === "number" && Number.isInteger(value) && value >= 1;
|
|
14179
|
+
return Array.isArray(value) && value.length === 2 && value.every((item) => typeof item === "number" && Number.isFinite(item));
|
|
14180
|
+
}
|
|
14181
|
+
/**
|
|
14182
|
+
* Builds the `IGX-0507` failure.
|
|
14183
|
+
*
|
|
14184
|
+
* @param address - The file's address.
|
|
14185
|
+
* @param problem - What is wrong, without a trailing period.
|
|
14186
|
+
* @returns The error to throw.
|
|
14187
|
+
*/
|
|
14188
|
+
function invalidMesh(address, problem) {
|
|
14189
|
+
return new IgnifxError(CoreErrorCode.invalidMeshFile, `${address} is not a valid mesh file: ${problem}.`, {
|
|
14190
|
+
context: {
|
|
14191
|
+
file: address,
|
|
14192
|
+
problem
|
|
14193
|
+
},
|
|
14194
|
+
hint: "See MESH_PRIMITIVE_OPTIONS for the options each primitive takes."
|
|
14195
|
+
});
|
|
14196
|
+
}
|
|
14197
|
+
//#endregion
|
|
14198
|
+
//#region src/render/loaders/mesh-loader.ts
|
|
14199
|
+
/**
|
|
14200
|
+
* Builds the `mesh` loader: `.mesh.json` to `MeshAsset` (ADR-0029).
|
|
14201
|
+
*
|
|
14202
|
+
* @remarks
|
|
14203
|
+
* The file names a primitive and its options, and the loader builds it exactly as the matching
|
|
14204
|
+
* `MeshAsset` factory would. The mesh is named after the file's `name`, or its address. A headless
|
|
14205
|
+
* app builds no GPU geometry. A file that is not a mesh file fails the load with `IGX-0709`, a
|
|
14206
|
+
* format version other than 1 with `IGX-0603`, and an unknown primitive or a bad option with
|
|
14207
|
+
* `IGX-0507`. The same `mesh` type still holds the in-memory meshes the factories publish; the
|
|
14208
|
+
* loader's `unload` frees both kinds.
|
|
14209
|
+
*
|
|
14210
|
+
* @returns The loader to register with `ctx.registerAssetLoader`.
|
|
14211
|
+
*
|
|
14212
|
+
* @example
|
|
14213
|
+
* ```ts
|
|
14214
|
+
* ctx.registerAssetLoader(createMeshLoader());
|
|
14215
|
+
* ```
|
|
14216
|
+
*
|
|
14217
|
+
* @public
|
|
14218
|
+
*/
|
|
14219
|
+
function createMeshLoader() {
|
|
14220
|
+
return {
|
|
14221
|
+
type: MESH_ASSET_TYPE,
|
|
14222
|
+
extensions: [MESH_FILE_EXTENSION],
|
|
14223
|
+
async load(ctx) {
|
|
14224
|
+
const file = readMeshFile(await ctx.fetchJson(), ctx.address);
|
|
14225
|
+
return createPrimitiveMeshAsset(ctx.app, file.name ?? ctx.address, file.definition);
|
|
14226
|
+
},
|
|
14227
|
+
unload(value) {
|
|
14228
|
+
value.dispose();
|
|
14229
|
+
}
|
|
14230
|
+
};
|
|
14231
|
+
}
|
|
14232
|
+
//#endregion
|
|
13292
14233
|
//#region src/lite/gpu/gltf.ts
|
|
13293
14234
|
/** The suffix `cloneTransformNode` appends to every cloned node's name. */
|
|
13294
14235
|
const CLONE_SUFFIX = "_clone";
|
|
@@ -13395,6 +14336,128 @@ function collectNames(node, out) {
|
|
|
13395
14336
|
if (child !== void 0) collectNames(child, out);
|
|
13396
14337
|
}
|
|
13397
14338
|
}
|
|
14339
|
+
/**
|
|
14340
|
+
* The file name of the meshopt decoder script Lite injects.
|
|
14341
|
+
*
|
|
14342
|
+
* @internal
|
|
14343
|
+
*/
|
|
14344
|
+
const MESHOPT_DECODER_FILE = "meshopt_decoder.js";
|
|
14345
|
+
/**
|
|
14346
|
+
* The transcoder modules `babylon.ktx2Decoder.js` fetches, as `[class, static property, file]`:
|
|
14347
|
+
* the class in the decoder's `KTX2DECODER` namespace whose property holds the URL, and the file
|
|
14348
|
+
* name it is served under. These are the defaults in `@babylonjs/ktx2decoder`'s
|
|
14349
|
+
* `Transcoders/*.js` and `zstddec.js`.
|
|
14350
|
+
*
|
|
14351
|
+
* @internal
|
|
14352
|
+
*/
|
|
14353
|
+
const KTX2_TRANSCODER_FILES = [
|
|
14354
|
+
[
|
|
14355
|
+
"MSCTranscoder",
|
|
14356
|
+
"JSModuleURL",
|
|
14357
|
+
"msc_basis_transcoder.js"
|
|
14358
|
+
],
|
|
14359
|
+
[
|
|
14360
|
+
"MSCTranscoder",
|
|
14361
|
+
"WasmModuleURL",
|
|
14362
|
+
"msc_basis_transcoder.wasm"
|
|
14363
|
+
],
|
|
14364
|
+
[
|
|
14365
|
+
"ZSTDDecoder",
|
|
14366
|
+
"WasmModuleURL",
|
|
14367
|
+
"zstddec.wasm"
|
|
14368
|
+
],
|
|
14369
|
+
[
|
|
14370
|
+
"LiteTranscoder_UASTC_ASTC",
|
|
14371
|
+
"WasmModuleURL",
|
|
14372
|
+
"uastc_astc.wasm"
|
|
14373
|
+
],
|
|
14374
|
+
[
|
|
14375
|
+
"LiteTranscoder_UASTC_BC7",
|
|
14376
|
+
"WasmModuleURL",
|
|
14377
|
+
"uastc_bc7.wasm"
|
|
14378
|
+
],
|
|
14379
|
+
[
|
|
14380
|
+
"LiteTranscoder_UASTC_R8_UNORM",
|
|
14381
|
+
"WasmModuleURL",
|
|
14382
|
+
"uastc_r8_unorm.wasm"
|
|
14383
|
+
],
|
|
14384
|
+
[
|
|
14385
|
+
"LiteTranscoder_UASTC_RG8_UNORM",
|
|
14386
|
+
"WasmModuleURL",
|
|
14387
|
+
"uastc_rg8_unorm.wasm"
|
|
14388
|
+
],
|
|
14389
|
+
[
|
|
14390
|
+
"LiteTranscoder_UASTC_RGBA_SRGB",
|
|
14391
|
+
"WasmModuleURL",
|
|
14392
|
+
"uastc_rgba8_srgb_v2.wasm"
|
|
14393
|
+
],
|
|
14394
|
+
[
|
|
14395
|
+
"LiteTranscoder_UASTC_RGBA_UNORM",
|
|
14396
|
+
"WasmModuleURL",
|
|
14397
|
+
"uastc_rgba8_unorm_v2.wasm"
|
|
14398
|
+
]
|
|
14399
|
+
];
|
|
14400
|
+
/**
|
|
14401
|
+
* Reads the decoder locations a manifest records.
|
|
14402
|
+
*
|
|
14403
|
+
* @remarks
|
|
14404
|
+
* The transcoders are only worth overriding together with the decoder script that reads them, so
|
|
14405
|
+
* they are ignored when the manifest has no `babylon.ktx2Decoder.js`. Lite takes the meshopt
|
|
14406
|
+
* decoder's **directory**, so its entry is used only when its URL ends in the file name.
|
|
14407
|
+
*
|
|
14408
|
+
* @param manifest - The asset manifest.
|
|
14409
|
+
* @returns The locations; a `null` field means the manifest does not list that decoder.
|
|
14410
|
+
*
|
|
14411
|
+
* @example
|
|
14412
|
+
* ```ts
|
|
14413
|
+
* decoderUrlsFromManifest(app.assets.manifest).ktx2Decoder; // "/assets/babylon.ktx2Decoder.js"
|
|
14414
|
+
* ```
|
|
14415
|
+
*
|
|
14416
|
+
* @internal
|
|
14417
|
+
*/
|
|
14418
|
+
function decoderUrlsFromManifest(manifest) {
|
|
14419
|
+
const urls = /* @__PURE__ */ new Map();
|
|
14420
|
+
for (const entry of manifest.entries) urls.set(entry.address, entry.url);
|
|
14421
|
+
const ktx2Decoder = urls.get("babylon.ktx2Decoder.js") ?? null;
|
|
14422
|
+
const ktx2Transcoders = {};
|
|
14423
|
+
if (ktx2Decoder !== null) for (const [name, property, file] of KTX2_TRANSCODER_FILES) {
|
|
14424
|
+
const url = urls.get(file);
|
|
14425
|
+
if (url !== void 0) ktx2Transcoders[name] = {
|
|
14426
|
+
...ktx2Transcoders[name],
|
|
14427
|
+
[property]: url
|
|
14428
|
+
};
|
|
14429
|
+
}
|
|
14430
|
+
const meshoptUrl = urls.get(MESHOPT_DECODER_FILE);
|
|
14431
|
+
return {
|
|
14432
|
+
ktx2Decoder,
|
|
14433
|
+
ktx2Transcoders,
|
|
14434
|
+
meshoptBaseUrl: meshoptUrl?.endsWith("meshopt_decoder.js") === true ? meshoptUrl.slice(0, meshoptUrl.length - 18) : null
|
|
14435
|
+
};
|
|
14436
|
+
}
|
|
14437
|
+
/** What {@link configureDecoders} last handed Lite, so an unchanged manifest costs one comparison. */
|
|
14438
|
+
let appliedKey = null;
|
|
14439
|
+
/**
|
|
14440
|
+
* Points Lite at the decoders the app's manifest lists, before a load that may need one.
|
|
14441
|
+
*
|
|
14442
|
+
* @remarks
|
|
14443
|
+
* Lite's decoder locations are process-wide, so two apps on one page with different manifests share
|
|
14444
|
+
* the last one applied. Lite loads the KTX2 decoder once and keeps it, so this has to run before the
|
|
14445
|
+
* first KTX2 texture — the texture and model loaders call it at the start of every load, and a call
|
|
14446
|
+
* whose manifest has not changed does nothing.
|
|
14447
|
+
*
|
|
14448
|
+
* @param app - The app whose manifest to read.
|
|
14449
|
+
* @returns Once Lite has been told; immediately when the manifest lists no decoder.
|
|
14450
|
+
*
|
|
14451
|
+
* @internal
|
|
14452
|
+
*/
|
|
14453
|
+
async function configureDecoders(app) {
|
|
14454
|
+
const urls = decoderUrlsFromManifest(app.assets.manifest);
|
|
14455
|
+
if (urls.ktx2Decoder === null && urls.meshoptBaseUrl === null) return;
|
|
14456
|
+
const key = JSON.stringify(urls);
|
|
14457
|
+
if (key === appliedKey) return;
|
|
14458
|
+
(await import("./decoders-CHJ7vduE.js")).applyLiteDecoderUrls(urls);
|
|
14459
|
+
appliedKey = key;
|
|
14460
|
+
}
|
|
13398
14461
|
//#endregion
|
|
13399
14462
|
//#region src/render/model-asset.ts
|
|
13400
14463
|
/**
|
|
@@ -13592,6 +14655,13 @@ function createModelAsset(address, container, scene) {
|
|
|
13592
14655
|
* asset pipeline produces, and the fix — passing the URL through for that one shape — is a
|
|
13593
14656
|
* three-line change whenever a project needs it.
|
|
13594
14657
|
*
|
|
14658
|
+
* ## Decoders
|
|
14659
|
+
*
|
|
14660
|
+
* A glTF may need one of Lite's run-time decoders: `KHR_texture_basisu` images go through the KTX2
|
|
14661
|
+
* decoder and `EXT_meshopt_compression` buffers through the meshopt decoder. Both load from
|
|
14662
|
+
* `cdn.babylonjs.com` unless told otherwise, so the loader calls `configureDecoders` first, which
|
|
14663
|
+
* points Lite at the copies `@ignifx/vite-plugin` serves (`../decoder-urls.ts`).
|
|
14664
|
+
*
|
|
13595
14665
|
* ## Headless
|
|
13596
14666
|
*
|
|
13597
14667
|
* `loadGltf` throws a `TypeError` under the null engine: it uploads while parsing and reaches for
|
|
@@ -13619,6 +14689,7 @@ function createModelLoader() {
|
|
|
13619
14689
|
async load(ctx) {
|
|
13620
14690
|
const bytes = await ctx.fetchBytes();
|
|
13621
14691
|
if (ctx.app.isHeadless) return createModelAsset(ctx.address, null, null);
|
|
14692
|
+
await configureDecoders(ctx.app);
|
|
13622
14693
|
const container = await loadGltfFromBytes(ctx.lite.engine, bytes);
|
|
13623
14694
|
return createModelAsset(ctx.address, container, ctx.app.lite.scene);
|
|
13624
14695
|
},
|
|
@@ -13641,7 +14712,7 @@ let effectLayer = null;
|
|
|
13641
14712
|
* @internal
|
|
13642
14713
|
*/
|
|
13643
14714
|
async function loadPostEffectSupport() {
|
|
13644
|
-
const [compiler, effects] = await Promise.all([compilerLayer ?? import("./post-effect-compiler-
|
|
14715
|
+
const [compiler, effects] = await Promise.all([compilerLayer ?? import("./post-effect-compiler-pOvXae-i.js"), effectLayer ?? import("./effect-task-CMbuO6Kb.js")]);
|
|
13645
14716
|
compilerLayer = compiler;
|
|
13646
14717
|
effectLayer = effects;
|
|
13647
14718
|
}
|
|
@@ -13779,7 +14850,7 @@ function createShaderLoader() {
|
|
|
13779
14850
|
type: SHADER_ASSET_TYPE,
|
|
13780
14851
|
extensions: SHADER_FILE_EXTENSIONS,
|
|
13781
14852
|
async load(ctx) {
|
|
13782
|
-
const [source, pragma] = await Promise.all([ctx.fetchText(), import("./shader-pragma-
|
|
14853
|
+
const [source, pragma] = await Promise.all([ctx.fetchText(), import("./shader-pragma-qO9_6sTd.js")]);
|
|
13783
14854
|
const declaration = pragma.parseShaderDeclaration(source, ctx.address);
|
|
13784
14855
|
await loadShaderSupport();
|
|
13785
14856
|
if (declaration.kind === "surface") await loadSurfaceShaderSupport();
|
|
@@ -13809,6 +14880,50 @@ function loadTexture(engine, url, options) {
|
|
|
13809
14880
|
return loadTexture2D(engine, url, options);
|
|
13810
14881
|
}
|
|
13811
14882
|
/**
|
|
14883
|
+
* Loads a KTX2 (Basis Universal) texture from a URL, transcoded to the device's best compressed
|
|
14884
|
+
* format.
|
|
14885
|
+
*
|
|
14886
|
+
* @remarks
|
|
14887
|
+
* Lite's KTX2 glue is imported on first use (`./decoders.ts`), so a game that never loads a `.ktx2`
|
|
14888
|
+
* does not carry it. The decoder script and its transcoders load from wherever
|
|
14889
|
+
* `applyLiteDecoderUrls` last pointed Lite, or from `cdn.babylonjs.com` when nothing did. Sampler and
|
|
14890
|
+
* sRGB options apply; `mipMaps`, `invertY` and `premultiplyAlpha` do not — the file's rows and mips
|
|
14891
|
+
* are uploaded as stored (`./decoders.ts` explains the orientation).
|
|
14892
|
+
*
|
|
14893
|
+
* @param engine - The engine that owns the GPU texture.
|
|
14894
|
+
* @param url - Where to fetch it from.
|
|
14895
|
+
* @param options - Colour space and sampler.
|
|
14896
|
+
* @returns The texture. Its reference count starts at an implicit one.
|
|
14897
|
+
*
|
|
14898
|
+
* @example
|
|
14899
|
+
* ```ts
|
|
14900
|
+
* const albedo = await loadKtx2Texture(engine, "textures/hero-albedo.ktx2", { srgb: true });
|
|
14901
|
+
* ```
|
|
14902
|
+
*
|
|
14903
|
+
* @internal
|
|
14904
|
+
*/
|
|
14905
|
+
async function loadKtx2Texture(engine, url, options = {}) {
|
|
14906
|
+
return (await import("./decoders-CHJ7vduE.js")).loadKtx2TextureWithOptions(engine, url, options);
|
|
14907
|
+
}
|
|
14908
|
+
/**
|
|
14909
|
+
* Loads a Basis Universal (`.basis`) texture from a URL.
|
|
14910
|
+
*
|
|
14911
|
+
* @remarks
|
|
14912
|
+
* Babylon Lite 1.34 always fetches the Basis transcoder from `cdn.babylonjs.com` and offers no
|
|
14913
|
+
* setter for it, so this works only where the page may load scripts from that origin. Prefer
|
|
14914
|
+
* `.ktx2`, which carries the same Basis payloads and whose decoder is served locally.
|
|
14915
|
+
*
|
|
14916
|
+
* @param engine - The engine that owns the GPU texture.
|
|
14917
|
+
* @param url - Where to fetch it from.
|
|
14918
|
+
* @param options - Colour space and sampler.
|
|
14919
|
+
* @returns The texture.
|
|
14920
|
+
*
|
|
14921
|
+
* @internal
|
|
14922
|
+
*/
|
|
14923
|
+
async function loadBasisTexture(engine, url, options = {}) {
|
|
14924
|
+
return (await import("./decoders-CHJ7vduE.js")).loadBasisTextureWithOptions(engine, url, options);
|
|
14925
|
+
}
|
|
14926
|
+
/**
|
|
13812
14927
|
* Creates a 2D texture from tightly packed RGBA8 bytes.
|
|
13813
14928
|
*
|
|
13814
14929
|
* @param engine - The engine that owns the GPU texture.
|
|
@@ -14356,6 +15471,17 @@ function readString$1(block, key, fallback) {
|
|
|
14356
15471
|
* one place §5's "the three `fetch*` methods are the only network paths" does not hold; the
|
|
14357
15472
|
* alternative is worse.
|
|
14358
15473
|
*
|
|
15474
|
+
* ## The container picks the decoder
|
|
15475
|
+
*
|
|
15476
|
+
* `.png`, `.jpg`, `.jpeg` and `.webp` go to `loadTexture2D` and the browser's image decoder.
|
|
15477
|
+
* `.ktx2` goes to Lite's KTX2 loader and `.basis` to its Basis loader, which transcode to the
|
|
15478
|
+
* device's best compressed format (`src/lite/gpu/decoders.ts` lists the targets); handing either
|
|
15479
|
+
* to `createImageBitmap` fails with "The source image could not be decoded". The asset type stays
|
|
15480
|
+
* `texture` for all six, so the choice is made here, from the address's extension — the one name a
|
|
15481
|
+
* manifest entry, a hashed build URL and a hand-written `{ type: "texture" }` load all keep. Before
|
|
15482
|
+
* a KTX2 or Basis load, {@link configureDecoders} points Lite at the decoders the manifest lists,
|
|
15483
|
+
* which is how a built game avoids `cdn.babylonjs.com`.
|
|
15484
|
+
*
|
|
14359
15485
|
* ## Options come from the sidecar
|
|
14360
15486
|
*
|
|
14361
15487
|
* `.meta.json` sidecars carry per-asset import options (§7), the build copies them into the
|
|
@@ -14389,7 +15515,9 @@ function createTextureLoader() {
|
|
|
14389
15515
|
const options = readTextureImportOptions(ctx.meta);
|
|
14390
15516
|
if (ctx.app.isHeadless) return new TextureAsset(ctx.address, null, options);
|
|
14391
15517
|
ctx.reportProgress(0);
|
|
14392
|
-
const
|
|
15518
|
+
const container = textureContainerOf(ctx.address, ctx.url);
|
|
15519
|
+
if (container !== "image") await configureDecoders(ctx.app);
|
|
15520
|
+
const texture = await loadByContainer(container, ctx.lite.engine, ctx.url, toLiteTextureOptions(options));
|
|
14393
15521
|
ctx.reportProgress(1);
|
|
14394
15522
|
return new TextureAsset(ctx.address, texture, options);
|
|
14395
15523
|
},
|
|
@@ -14398,6 +15526,57 @@ function createTextureLoader() {
|
|
|
14398
15526
|
}
|
|
14399
15527
|
};
|
|
14400
15528
|
}
|
|
15529
|
+
/**
|
|
15530
|
+
* The lowercase extension of a path or URL, without its query or fragment.
|
|
15531
|
+
*
|
|
15532
|
+
* @param reference - An address or URL.
|
|
15533
|
+
* @returns The extension with its dot, or `""`.
|
|
15534
|
+
*/
|
|
15535
|
+
function extensionOf(reference) {
|
|
15536
|
+
const path = reference.split(/[?#]/u, 1)[0] ?? "";
|
|
15537
|
+
const name = path.slice(path.lastIndexOf("/") + 1);
|
|
15538
|
+
const dot = name.lastIndexOf(".");
|
|
15539
|
+
return dot <= 0 ? "" : name.slice(dot).toLowerCase();
|
|
15540
|
+
}
|
|
15541
|
+
/**
|
|
15542
|
+
* Decides which Lite loader a texture needs.
|
|
15543
|
+
*
|
|
15544
|
+
* @remarks
|
|
15545
|
+
* The address decides; the URL is consulted only when the address has no extension, which happens
|
|
15546
|
+
* when a load passes `{ type: "texture" }` for an address the manifest maps to a file. Anything that
|
|
15547
|
+
* is neither `.ktx2` nor `.basis` is an image for the browser to decode.
|
|
15548
|
+
*
|
|
15549
|
+
* @param address - The asset address.
|
|
15550
|
+
* @param url - The URL it resolved to.
|
|
15551
|
+
* @returns The container.
|
|
15552
|
+
*
|
|
15553
|
+
* @example
|
|
15554
|
+
* ```ts
|
|
15555
|
+
* textureContainerOf("textures/rock.ktx2", "/assets/textures/rock.3f2a1b9c.ktx2"); // "ktx2"
|
|
15556
|
+
* ```
|
|
15557
|
+
*
|
|
15558
|
+
* @internal
|
|
15559
|
+
*/
|
|
15560
|
+
function textureContainerOf(address, url) {
|
|
15561
|
+
const extension = extensionOf(address) || extensionOf(url);
|
|
15562
|
+
if (extension === ".ktx2") return "ktx2";
|
|
15563
|
+
if (extension === ".basis") return "basis";
|
|
15564
|
+
return "image";
|
|
15565
|
+
}
|
|
15566
|
+
/**
|
|
15567
|
+
* Loads a texture with the Lite loader its container needs.
|
|
15568
|
+
*
|
|
15569
|
+
* @param container - What the file is.
|
|
15570
|
+
* @param engine - The engine that owns the GPU texture.
|
|
15571
|
+
* @param url - Where to fetch it from.
|
|
15572
|
+
* @param options - Lite's texture options, from the sidecar.
|
|
15573
|
+
* @returns The texture.
|
|
15574
|
+
*/
|
|
15575
|
+
function loadByContainer(container, engine, url, options) {
|
|
15576
|
+
if (container === "ktx2") return loadKtx2Texture(engine, url, options);
|
|
15577
|
+
if (container === "basis") return loadBasisTexture(engine, url, options);
|
|
15578
|
+
return loadTexture(engine, url, options);
|
|
15579
|
+
}
|
|
14401
15580
|
//#endregion
|
|
14402
15581
|
//#region src/render/gpu/mesh-instance.ts
|
|
14403
15582
|
/**
|
|
@@ -16009,7 +17188,7 @@ var PostProcessStack = class PostProcessStack extends Component {
|
|
|
16009
17188
|
}
|
|
16010
17189
|
if (!this.#hasWarnedAboutFeature && !renderer.features.postProcessing) this.#warnAboutFeature(renderer, this.plannedChain().length);
|
|
16011
17190
|
const surface = renderer.surface;
|
|
16012
|
-
applyPostProcessSettings(this.#chain, this.isEnabledInHierarchy, this.bloom, this.smaa, renderer.
|
|
17191
|
+
applyPostProcessSettings(this.#chain, this.isEnabledInHierarchy, this.bloom, this.smaa, renderer.effectClock, surface?.width ?? 0, surface?.height ?? 0, renderer.isSceneRegistered);
|
|
16013
17192
|
}
|
|
16014
17193
|
/**
|
|
16015
17194
|
* Replaces the chain with one that holds the effects the fields currently ask for.
|
|
@@ -16330,7 +17509,6 @@ var RenderSyncSystem = class {
|
|
|
16330
17509
|
/** Each world's winning `Environment` last frame, so a change of winner is seen. */
|
|
16331
17510
|
#lastEnvironment = /* @__PURE__ */ new WeakMap();
|
|
16332
17511
|
#isRebuildDue = false;
|
|
16333
|
-
#isRebuildInFlight = false;
|
|
16334
17512
|
/** A rebuild asked for while one was already running; it is run once the in-flight one lands. */
|
|
16335
17513
|
#isRebuildPending = false;
|
|
16336
17514
|
#areCastersDirty = false;
|
|
@@ -16409,13 +17587,13 @@ var RenderSyncSystem = class {
|
|
|
16409
17587
|
renderer.refreshClearColor();
|
|
16410
17588
|
this.#applyStacks(world);
|
|
16411
17589
|
this.#areCastersDirty = this.#areCastersDirty || castersChanged;
|
|
16412
|
-
if (renderer.materialCacheResets.unconfirmed && !this.#isRebuildDue && !
|
|
17590
|
+
if (renderer.materialCacheResets.unconfirmed && !this.#isRebuildDue && !renderer.isRebuildInFlight) this.#rebuildRenderables();
|
|
16413
17591
|
if (this.#isRebuildDue && !topologyChanged) {
|
|
16414
17592
|
this.#isRebuildDue = false;
|
|
16415
17593
|
this.#rebuildRenderables();
|
|
16416
17594
|
}
|
|
16417
17595
|
this.#isRebuildDue = this.#isRebuildDue || topologyChanged;
|
|
16418
|
-
if (this.#areCastersDirty && !this.#isRebuildDue && !
|
|
17596
|
+
if (this.#areCastersDirty && !this.#isRebuildDue && !renderer.isRebuildInFlight) {
|
|
16419
17597
|
this.#areCastersDirty = false;
|
|
16420
17598
|
this.#rebuildCasters(meshes, models, instanced, lights);
|
|
16421
17599
|
}
|
|
@@ -16614,11 +17792,11 @@ var RenderSyncSystem = class {
|
|
|
16614
17792
|
renderer.renderableRebuilds += 1;
|
|
16615
17793
|
renderer.needsCasterRebuild = true;
|
|
16616
17794
|
if (renderer.isHeadless || !renderer.isSceneRegistered) return;
|
|
16617
|
-
if (
|
|
17795
|
+
if (renderer.isRebuildInFlight) {
|
|
16618
17796
|
this.#isRebuildPending = true;
|
|
16619
17797
|
return;
|
|
16620
17798
|
}
|
|
16621
|
-
|
|
17799
|
+
renderer.isRebuildInFlight = true;
|
|
16622
17800
|
queueMicrotask(() => {
|
|
16623
17801
|
this.#drainRebuilds();
|
|
16624
17802
|
});
|
|
@@ -16677,8 +17855,25 @@ var RenderSyncSystem = class {
|
|
|
16677
17855
|
}
|
|
16678
17856
|
} while (this.#takePendingRebuild());
|
|
16679
17857
|
} finally {
|
|
16680
|
-
|
|
17858
|
+
renderer.isRebuildInFlight = false;
|
|
16681
17859
|
this.#isRebuildPending = false;
|
|
17860
|
+
this.#runHeldChanges();
|
|
17861
|
+
}
|
|
17862
|
+
}
|
|
17863
|
+
/** Runs the scene changes `RendererImpl.afterRebuild` held back while the rebuild ran. */
|
|
17864
|
+
#runHeldChanges() {
|
|
17865
|
+
const renderer = this.#renderer;
|
|
17866
|
+
const held = renderer.takeHeldChanges();
|
|
17867
|
+
for (let index = 0; index < held.length; index += 1) try {
|
|
17868
|
+
held[index]?.();
|
|
17869
|
+
} catch (error) {
|
|
17870
|
+
renderer.app.onError.emit({
|
|
17871
|
+
error,
|
|
17872
|
+
source: "system",
|
|
17873
|
+
phase: null,
|
|
17874
|
+
entity: null,
|
|
17875
|
+
component: null
|
|
17876
|
+
});
|
|
16682
17877
|
}
|
|
16683
17878
|
}
|
|
16684
17879
|
/**
|
|
@@ -16709,7 +17904,10 @@ var RenderSyncSystem = class {
|
|
|
16709
17904
|
* The clock is accumulated here rather than read from `app.time.time` because a system keeps running
|
|
16710
17905
|
* with a non-zero `dt` while the app is paused and has to check `time.paused` itself
|
|
16711
17906
|
* (`docs/architecture/01-lifecycle-and-time.md` §7); that is what freezes `time` under
|
|
16712
|
-
* `app.pause()` and resumes it without a jump.
|
|
17907
|
+
* `app.pause()` and resumes it without a jump. In an edit-mode app the system runs, so materials
|
|
17908
|
+
* animate as an editor previews them, and `app.renderer.animateMaterialsInEditMode = false` freezes
|
|
17909
|
+
* the clock the same way (ADR-0028, amendment of 2026-10-20). A held clock (`ctx.isClockHeld`, for a
|
|
17910
|
+
* registration that asks for `"hold"`) would too.
|
|
16713
17911
|
*/
|
|
16714
17912
|
/**
|
|
16715
17913
|
* Where the shader uniform writer sits inside `PreRender`: just before the render sync
|
|
@@ -16763,18 +17961,20 @@ var ShaderUniformSystem = class {
|
|
|
16763
17961
|
*/
|
|
16764
17962
|
update(ctx) {
|
|
16765
17963
|
const time = ctx.time;
|
|
16766
|
-
const
|
|
17964
|
+
const renderer = rendererInternals(this.#app.renderer);
|
|
17965
|
+
const isPaused = time.paused || ctx.isClockHeld || renderer.isShaderClockHeld;
|
|
16767
17966
|
if (!isPaused) {
|
|
16768
17967
|
this.#time += time.deltaTime;
|
|
16769
17968
|
this.#unscaledTime += time.unscaledDeltaTime;
|
|
16770
17969
|
}
|
|
17970
|
+
const delta = isPaused ? 0 : time.deltaTime;
|
|
17971
|
+
renderer.setShaderClock(this.#time, this.#unscaledTime, delta);
|
|
16771
17972
|
const support = shaderSupport();
|
|
16772
17973
|
if (support === null) return;
|
|
16773
17974
|
const materials = support.shaderMaterialsOf(this.#app).animated;
|
|
16774
17975
|
if (materials.length === 0) return;
|
|
16775
17976
|
const hasLight = this.#readMainLight(ctx.world);
|
|
16776
17977
|
this.#readAmbient();
|
|
16777
|
-
const delta = isPaused ? 0 : time.deltaTime;
|
|
16778
17978
|
for (let index = 0; index < materials.length; index += 1) materials[index]?.writeFrameUniforms(this.#time, this.#unscaledTime, delta, this.#frame, hasLight);
|
|
16779
17979
|
}
|
|
16780
17980
|
/**
|
|
@@ -17718,14 +18918,37 @@ function noReferences() {
|
|
|
17718
18918
|
};
|
|
17719
18919
|
}
|
|
17720
18920
|
/**
|
|
17721
|
-
* Builds the JSON Schema fragment for one field
|
|
18921
|
+
* Builds the JSON Schema fragment for one field, at any depth: its encoded form plus an
|
|
18922
|
+
* `x-ignifx-*` keyword for each inspector option it declares. JSON Schema validators ignore
|
|
18923
|
+
* keywords they do not know, and the `x-` prefix keeps these clear of any future standard one.
|
|
17722
18924
|
*
|
|
17723
18925
|
* @param field - The field to describe.
|
|
17724
|
-
* @returns The fragment
|
|
18926
|
+
* @returns The fragment.
|
|
17725
18927
|
*
|
|
17726
18928
|
* @internal
|
|
17727
18929
|
*/
|
|
17728
18930
|
function fieldJsonSchema(field) {
|
|
18931
|
+
const fragment = { ...kindJsonSchema(field) };
|
|
18932
|
+
const { step, hidden, readonly, group, transient } = field.options;
|
|
18933
|
+
if (step !== void 0) fragment["x-ignifx-step"] = step;
|
|
18934
|
+
if (hidden !== void 0) fragment["x-ignifx-hidden"] = hidden;
|
|
18935
|
+
if (readonly !== void 0) {
|
|
18936
|
+
fragment["x-ignifx-readonly"] = readonly;
|
|
18937
|
+
if (readonly) fragment["readOnly"] = true;
|
|
18938
|
+
}
|
|
18939
|
+
if (group !== void 0) fragment["x-ignifx-group"] = group;
|
|
18940
|
+
if (transient !== void 0) fragment["x-ignifx-transient"] = transient;
|
|
18941
|
+
return fragment;
|
|
18942
|
+
}
|
|
18943
|
+
/**
|
|
18944
|
+
* Builds the JSON Schema fragment for one field's encoded form.
|
|
18945
|
+
*
|
|
18946
|
+
* @param field - The field to describe.
|
|
18947
|
+
* @returns The fragment describing the field's encoded form.
|
|
18948
|
+
*
|
|
18949
|
+
* @internal
|
|
18950
|
+
*/
|
|
18951
|
+
function kindJsonSchema(field) {
|
|
17729
18952
|
const { spec } = field;
|
|
17730
18953
|
switch (spec.kind) {
|
|
17731
18954
|
case "f32":
|
|
@@ -17766,16 +18989,25 @@ function fieldJsonSchema(field) {
|
|
|
17766
18989
|
enum: [...spec.values]
|
|
17767
18990
|
};
|
|
17768
18991
|
case "entityRef": return taggedReferenceSchema("$entity");
|
|
17769
|
-
case "componentRef":
|
|
17770
|
-
|
|
17771
|
-
|
|
17772
|
-
|
|
17773
|
-
|
|
17774
|
-
|
|
17775
|
-
|
|
17776
|
-
|
|
17777
|
-
|
|
17778
|
-
|
|
18992
|
+
case "componentRef": {
|
|
18993
|
+
const typeId = spec.componentType.typeId;
|
|
18994
|
+
return {
|
|
18995
|
+
...taggedReferenceSchema("$component"),
|
|
18996
|
+
...typeId === void 0 ? {} : { "x-ignifx-component-type": typeId }
|
|
18997
|
+
};
|
|
18998
|
+
}
|
|
18999
|
+
case "asset": return {
|
|
19000
|
+
oneOf: [{
|
|
19001
|
+
type: "object",
|
|
19002
|
+
properties: {
|
|
19003
|
+
$asset: { type: "string" },
|
|
19004
|
+
type: { type: "string" }
|
|
19005
|
+
},
|
|
19006
|
+
required: ["$asset"],
|
|
19007
|
+
additionalProperties: false
|
|
19008
|
+
}, { type: "null" }],
|
|
19009
|
+
...spec.typeName === null ? {} : { "x-ignifx-asset-type": spec.typeName }
|
|
19010
|
+
};
|
|
17779
19011
|
case "array": return {
|
|
17780
19012
|
type: "array",
|
|
17781
19013
|
items: fieldJsonSchema(spec.item)
|
|
@@ -17859,14 +19091,18 @@ function schemaJsonSchema(schema) {
|
|
|
17859
19091
|
};
|
|
17860
19092
|
}
|
|
17861
19093
|
/**
|
|
17862
|
-
* Describes a component schema in the shape the documentation harness
|
|
17863
|
-
* a record of these keyed by `typeId`; `pnpm docs:schemas` reads it from
|
|
17864
|
-
* regenerates the format pages and `ignifx.schemas.json` from it
|
|
17865
|
-
* (`scripts/README.md`, `docs/architecture/16-docs-harness-and-skill.md` §3).
|
|
19094
|
+
* Describes a component schema in the shape the documentation harness and an external inspector
|
|
19095
|
+
* consume. A package exports a record of these keyed by `typeId`; `pnpm docs:schemas` reads it from
|
|
19096
|
+
* the built entry point and regenerates the format pages and `ignifx.schemas.json` from it
|
|
19097
|
+
* (`scripts/README.md`, `docs/architecture/16-docs-harness-and-skill.md` §3). Each field carries
|
|
19098
|
+
* its inspector options and what its kind declares ({@link SchemaFieldDescription}); to describe
|
|
19099
|
+
* an app's registered components with `allowMultiple` and `package` filled in, use
|
|
19100
|
+
* {@link describeRegisteredSchemas}.
|
|
17866
19101
|
*
|
|
17867
19102
|
* @param typeId - The component's namespaced registration id, for example `mygame/Mover`.
|
|
17868
19103
|
* @param schema - The component's declared fields.
|
|
17869
|
-
* @param meta - Overrides for the title, format grouping, and summary
|
|
19104
|
+
* @param meta - Overrides for the title, format grouping, and summary, and the component's
|
|
19105
|
+
* `allowMultiple`, `package` and `builtIn` when the caller knows them.
|
|
17870
19106
|
* @returns The description entry.
|
|
17871
19107
|
*
|
|
17872
19108
|
* @example
|
|
@@ -17879,25 +19115,109 @@ function schemaJsonSchema(schema) {
|
|
|
17879
19115
|
* @public
|
|
17880
19116
|
*/
|
|
17881
19117
|
function describeSchema(typeId, schema, meta) {
|
|
17882
|
-
const references = noReferences();
|
|
17883
|
-
const fields = {};
|
|
17884
|
-
for (const [name, field] of Object.entries(schema)) {
|
|
17885
|
-
const { tooltip } = field.options;
|
|
17886
|
-
fields[name] = {
|
|
17887
|
-
kind: field.kind,
|
|
17888
|
-
default: encodeValue(field, field.createDefault(), references),
|
|
17889
|
-
...tooltip === void 0 ? {} : { description: tooltip }
|
|
17890
|
-
};
|
|
17891
|
-
}
|
|
17892
19118
|
const derivedTitle = typeId.slice(typeId.lastIndexOf("/") + 1);
|
|
17893
19119
|
return {
|
|
17894
19120
|
title: meta?.title ?? derivedTitle,
|
|
17895
19121
|
format: meta?.format ?? "components",
|
|
17896
19122
|
...meta?.description === void 0 ? {} : { description: meta.description },
|
|
17897
|
-
fields
|
|
19123
|
+
fields: describeFields(schema, noReferences()),
|
|
19124
|
+
...meta?.allowMultiple === void 0 ? {} : { allowMultiple: meta.allowMultiple },
|
|
19125
|
+
...meta?.package === void 0 ? {} : { package: meta.package },
|
|
19126
|
+
...meta?.builtIn === void 0 ? {} : { builtIn: meta.builtIn }
|
|
19127
|
+
};
|
|
19128
|
+
}
|
|
19129
|
+
/**
|
|
19130
|
+
* Describes every field of a schema, in declaration order.
|
|
19131
|
+
*
|
|
19132
|
+
* @param schema - The fields.
|
|
19133
|
+
* @param references - The encoder for the defaults.
|
|
19134
|
+
* @returns The descriptions, keyed by field name.
|
|
19135
|
+
*
|
|
19136
|
+
* @internal
|
|
19137
|
+
*/
|
|
19138
|
+
function describeFields(schema, references) {
|
|
19139
|
+
const fields = {};
|
|
19140
|
+
for (const [name, field] of Object.entries(schema)) fields[name] = describeField(field, references);
|
|
19141
|
+
return fields;
|
|
19142
|
+
}
|
|
19143
|
+
/**
|
|
19144
|
+
* Describes one field: its kind, default and tooltip, its inspector options, and what its kind
|
|
19145
|
+
* declares, recursing into nested fields.
|
|
19146
|
+
*
|
|
19147
|
+
* @param field - The field.
|
|
19148
|
+
* @param references - The encoder for the default.
|
|
19149
|
+
* @returns The description.
|
|
19150
|
+
*
|
|
19151
|
+
* @internal
|
|
19152
|
+
*/
|
|
19153
|
+
function describeField(field, references) {
|
|
19154
|
+
const { tooltip } = field.options;
|
|
19155
|
+
return {
|
|
19156
|
+
kind: field.kind,
|
|
19157
|
+
default: encodeValue(field, field.createDefault(), references),
|
|
19158
|
+
...tooltip === void 0 ? {} : { description: tooltip },
|
|
19159
|
+
...describeOptions(field.options),
|
|
19160
|
+
...describeKind(field, references)
|
|
19161
|
+
};
|
|
19162
|
+
}
|
|
19163
|
+
/**
|
|
19164
|
+
* Copies the inspector options a field declares.
|
|
19165
|
+
*
|
|
19166
|
+
* @param options - The field's options.
|
|
19167
|
+
* @returns Only the declared options.
|
|
19168
|
+
*
|
|
19169
|
+
* @internal
|
|
19170
|
+
*/
|
|
19171
|
+
function describeOptions(options) {
|
|
19172
|
+
const { min, max, step, hidden, readonly, group, transient } = options;
|
|
19173
|
+
return {
|
|
19174
|
+
...min === void 0 ? {} : { min },
|
|
19175
|
+
...max === void 0 ? {} : { max },
|
|
19176
|
+
...step === void 0 ? {} : { step },
|
|
19177
|
+
...hidden === void 0 ? {} : { hidden },
|
|
19178
|
+
...readonly === void 0 ? {} : { readonly },
|
|
19179
|
+
...group === void 0 ? {} : { group },
|
|
19180
|
+
...transient === void 0 ? {} : { transient }
|
|
17898
19181
|
};
|
|
17899
19182
|
}
|
|
17900
19183
|
/**
|
|
19184
|
+
* Describes what a field's kind declares beyond the kind itself.
|
|
19185
|
+
*
|
|
19186
|
+
* @param field - The field.
|
|
19187
|
+
* @param references - The encoder for nested defaults.
|
|
19188
|
+
* @returns The kind's members; empty for a kind that declares nothing more.
|
|
19189
|
+
*
|
|
19190
|
+
* @internal
|
|
19191
|
+
*/
|
|
19192
|
+
function describeKind(field, references) {
|
|
19193
|
+
const { spec } = field;
|
|
19194
|
+
switch (spec.kind) {
|
|
19195
|
+
case "enum": return { values: [...spec.values] };
|
|
19196
|
+
case "asset": return spec.typeName === null ? {} : { assetType: spec.typeName };
|
|
19197
|
+
case "componentRef": return { componentType: spec.componentType.typeId ?? null };
|
|
19198
|
+
case "array": return { item: describeField(spec.item, references) };
|
|
19199
|
+
case "record": return { fields: describeFields(spec.fields, references) };
|
|
19200
|
+
case "map": return { value: describeField(spec.value, references) };
|
|
19201
|
+
case "optional": return { inner: describeField(spec.inner, references) };
|
|
19202
|
+
case "f32":
|
|
19203
|
+
case "f64":
|
|
19204
|
+
case "i32":
|
|
19205
|
+
case "u32":
|
|
19206
|
+
case "bool":
|
|
19207
|
+
case "str":
|
|
19208
|
+
case "vec2":
|
|
19209
|
+
case "vec3":
|
|
19210
|
+
case "vec4":
|
|
19211
|
+
case "quat":
|
|
19212
|
+
case "color":
|
|
19213
|
+
case "entityRef":
|
|
19214
|
+
case "layerMask":
|
|
19215
|
+
case "curve":
|
|
19216
|
+
case "custom": return {};
|
|
19217
|
+
default: return assertNever(spec, "schema field kind");
|
|
19218
|
+
}
|
|
19219
|
+
}
|
|
19220
|
+
/**
|
|
17901
19221
|
* Generates the JSON Schema (draft 2020-12) for a component's `props` object. The harness and the
|
|
17902
19222
|
* Vite plugin assemble these into `ignifx.schemas.json`, which drives build-time validation and
|
|
17903
19223
|
* editor autocompletion (`docs/architecture/06-serialization-and-scene-format.md` §8).
|
|
@@ -18761,15 +20081,14 @@ function readSceneFile(parsed, address, validate) {
|
|
|
18761
20081
|
return asSceneFile(parsed);
|
|
18762
20082
|
}
|
|
18763
20083
|
/**
|
|
18764
|
-
*
|
|
20084
|
+
* Lists every asset the file references, in a stable order: `settings` first, then each entity's
|
|
18765
20085
|
* `instance.scene`, then each component's `props`
|
|
18766
20086
|
* (`docs/architecture/06-serialization-and-scene-format.md` §4 step 2).
|
|
18767
20087
|
*
|
|
18768
20088
|
* @param file - The parsed file.
|
|
18769
|
-
* @
|
|
18770
|
-
* @returns The loaded handles, deduplicated by address, in discovery order.
|
|
20089
|
+
* @returns The references, deduplicated by address, in discovery order.
|
|
18771
20090
|
*/
|
|
18772
|
-
|
|
20091
|
+
function dependencyRequests(file) {
|
|
18773
20092
|
const requests = [];
|
|
18774
20093
|
const seen = /* @__PURE__ */ new Set();
|
|
18775
20094
|
const add = (address, type) => {
|
|
@@ -18786,7 +20105,59 @@ async function loadDependencies(file, ctx) {
|
|
|
18786
20105
|
const entity = file.entities[index];
|
|
18787
20106
|
if (entity !== void 0) collectEntityRefs(entity, add);
|
|
18788
20107
|
}
|
|
18789
|
-
return
|
|
20108
|
+
return requests;
|
|
20109
|
+
}
|
|
20110
|
+
/**
|
|
20111
|
+
* Loads every asset the file references through the loader context, which retains each one for
|
|
20112
|
+
* the scene asset being loaded.
|
|
20113
|
+
*
|
|
20114
|
+
* @param file - The parsed file.
|
|
20115
|
+
* @param ctx - The loader context.
|
|
20116
|
+
* @returns The loaded handles, deduplicated by address, in discovery order.
|
|
20117
|
+
*/
|
|
20118
|
+
async function loadDependencies(file, ctx) {
|
|
20119
|
+
return Promise.all(dependencyRequests(file).map(async (request) => ctx.loadDependency(request.address, request.type === null ? void 0 : { type: request.type })));
|
|
20120
|
+
}
|
|
20121
|
+
/**
|
|
20122
|
+
* Loads every asset a scene file references — in `settings`, in every component's `props`, and in
|
|
20123
|
+
* every `instance.scene`, recursively through the scenes those pull in — the walk the scene loader
|
|
20124
|
+
* runs before it builds anything (`docs/architecture/06-serialization-and-scene-format.md` §4
|
|
20125
|
+
* step 2).
|
|
20126
|
+
*
|
|
20127
|
+
* @remarks
|
|
20128
|
+
* It is the half of the scene loader a file that is already in memory needs: pass the result to
|
|
20129
|
+
* `createSceneAsset` and the asset can be built synchronously with `instantiateScene`. Each handle
|
|
20130
|
+
* is returned with one holder, which the caller owns: release them all when the scene they serve
|
|
20131
|
+
* is gone. `world.loadSceneFile` does that for a whole scene.
|
|
20132
|
+
*
|
|
20133
|
+
* @param assets - The asset service to load through, normally `app.assets`.
|
|
20134
|
+
* @param file - The scene file.
|
|
20135
|
+
* @param options - Cancellation.
|
|
20136
|
+
* @returns The loaded handles, deduplicated by address, in the loader's order.
|
|
20137
|
+
* @throws Whatever the asset service rejects a load with (an `AssetLoadError`); every handle
|
|
20138
|
+
* loaded by then is released first.
|
|
20139
|
+
*
|
|
20140
|
+
* @example
|
|
20141
|
+
* ```ts
|
|
20142
|
+
* const dependencies = await loadSceneDependencies(app.assets, file);
|
|
20143
|
+
* const asset = await createSceneAsset("memory:scene/draft", file, dependencies);
|
|
20144
|
+
* ```
|
|
20145
|
+
*
|
|
20146
|
+
* @public
|
|
20147
|
+
*/
|
|
20148
|
+
async function loadSceneDependencies(assets, file, options) {
|
|
20149
|
+
const signal = options?.signal;
|
|
20150
|
+
const handles = dependencyRequests(file).map((request) => assets.load(request.address, {
|
|
20151
|
+
...request.type === null ? {} : { type: request.type },
|
|
20152
|
+
...signal === void 0 ? {} : { signal }
|
|
20153
|
+
}));
|
|
20154
|
+
try {
|
|
20155
|
+
await Promise.all(handles.map(async (handle) => handle.promise));
|
|
20156
|
+
} catch (error) {
|
|
20157
|
+
for (let index = 0; index < handles.length; index += 1) handles[index]?.release();
|
|
20158
|
+
throw error;
|
|
20159
|
+
}
|
|
20160
|
+
return handles;
|
|
18790
20161
|
}
|
|
18791
20162
|
/**
|
|
18792
20163
|
* Collects the asset references of one entity: its `instance.scene` first, so a nested scene is
|
|
@@ -21544,14 +22915,7 @@ function registerRendering(ctx) {
|
|
|
21544
22915
|
if (value instanceof StorageBufferAsset) value.dispose();
|
|
21545
22916
|
}
|
|
21546
22917
|
});
|
|
21547
|
-
ctx.registerAssetLoader(
|
|
21548
|
-
type: MESH_ASSET_TYPE,
|
|
21549
|
-
extensions: [],
|
|
21550
|
-
load: () => Promise.reject(noMeshFileFormat()),
|
|
21551
|
-
unload: (value) => {
|
|
21552
|
-
if (value instanceof MeshAsset) value.dispose();
|
|
21553
|
-
}
|
|
21554
|
-
});
|
|
22918
|
+
ctx.registerAssetLoader(createMeshLoader());
|
|
21555
22919
|
ctx.registerSystem(new ShaderUniformSystem(ctx.app), {
|
|
21556
22920
|
phase: Phase.PreRender,
|
|
21557
22921
|
order: SHADER_UNIFORM_ORDER
|
|
@@ -21567,18 +22931,6 @@ function registerRendering(ctx) {
|
|
|
21567
22931
|
});
|
|
21568
22932
|
}
|
|
21569
22933
|
/**
|
|
21570
|
-
* Builds the failure a `mesh` **address** produces: there is no mesh file format, because geometry
|
|
21571
|
-
* arrives either as a primitive built in code or inside a `ModelAsset`.
|
|
21572
|
-
*
|
|
21573
|
-
* @returns The error to reject with.
|
|
21574
|
-
*/
|
|
21575
|
-
function noMeshFileFormat() {
|
|
21576
|
-
return new IgnifxError(CoreErrorCode.assetNoLoader, "There is no mesh file format; build one in code.", {
|
|
21577
|
-
context: { type: MESH_ASSET_TYPE },
|
|
21578
|
-
hint: "Use MeshAsset.box/sphere/plane/ground/... for primitives, or load a .glb as a model."
|
|
21579
|
-
});
|
|
21580
|
-
}
|
|
21581
|
-
/**
|
|
21582
22934
|
* Builds the failure a `storagebuffer` **address** produces: there is no storage buffer file
|
|
21583
22935
|
* format, because the bytes are always written by the game.
|
|
21584
22936
|
*
|
|
@@ -21773,7 +23125,7 @@ var ExtensionContextImpl = class {
|
|
|
21773
23125
|
* @param options - An explicit `typeId`, when the class does not declare one.
|
|
21774
23126
|
*/
|
|
21775
23127
|
registerComponent(type, options) {
|
|
21776
|
-
this.#registry.register(type, options?.typeId);
|
|
23128
|
+
this.#registry.register(type, options?.typeId, this.#extension.name);
|
|
21777
23129
|
}
|
|
21778
23130
|
/**
|
|
21779
23131
|
* Registers several component classes.
|
|
@@ -21781,7 +23133,7 @@ var ExtensionContextImpl = class {
|
|
|
21781
23133
|
* @param types - The component classes.
|
|
21782
23134
|
*/
|
|
21783
23135
|
registerComponents(types) {
|
|
21784
|
-
this.#registry.registerAll(types);
|
|
23136
|
+
this.#registry.registerAll(types, this.#extension.name);
|
|
21785
23137
|
}
|
|
21786
23138
|
/**
|
|
21787
23139
|
* Registers a system in a phase.
|
|
@@ -22783,6 +24135,17 @@ function readStatics(type) {
|
|
|
22783
24135
|
return type;
|
|
22784
24136
|
}
|
|
22785
24137
|
/**
|
|
24138
|
+
* Whether a replacement class declares `static runInEditMode = true`.
|
|
24139
|
+
*
|
|
24140
|
+
* @param type - The component class.
|
|
24141
|
+
* @returns `true` only when the class declares it.
|
|
24142
|
+
*
|
|
24143
|
+
* @internal
|
|
24144
|
+
*/
|
|
24145
|
+
function declaresRunInEditMode(type) {
|
|
24146
|
+
return readStatics(type).runInEditMode === true;
|
|
24147
|
+
}
|
|
24148
|
+
/**
|
|
22786
24149
|
* The policy a class declares, defaulting to `"patch"`.
|
|
22787
24150
|
*
|
|
22788
24151
|
* @param type - The component class.
|
|
@@ -22991,6 +24354,8 @@ var HotReloadHostImpl = class {
|
|
|
22991
24354
|
policy = "recreate";
|
|
22992
24355
|
this.#log.warn(`${CoreErrorCode.hotReloadSchemaChanged} ${typeId} changed its schema shape under the "patch" policy; its instances were re-created. Declare static hotReload = "recreate" to say so.`);
|
|
22993
24356
|
}
|
|
24357
|
+
const wasRunInEditMode = previousInfo.script?.runInEditMode ?? false;
|
|
24358
|
+
if (policy === "patch" && this.#app.isEditMode && wasRunInEditMode !== declaresRunInEditMode(next)) policy = "recreate";
|
|
22994
24359
|
return {
|
|
22995
24360
|
typeId,
|
|
22996
24361
|
previous: current,
|
|
@@ -24490,6 +25855,9 @@ function updatesWhilePaused(script) {
|
|
|
24490
25855
|
* not run" while paused, and a physics system that kept stepping with no `fixedUpdate` in front
|
|
24491
25856
|
* of it would be worse than either reading alone. Systems of every other phase keep running:
|
|
24492
25857
|
* rendering, audio, and UI must still work on a pause screen.
|
|
25858
|
+
* - **Edit mode costs a game one comparison per system.** An entry's edit-mode behaviour is
|
|
25859
|
+
* resolved at registration, so in an app that is not in edit mode every entry is `"run"` and the
|
|
25860
|
+
* frame takes the same path it always did (ADR-0028).
|
|
24493
25861
|
* - **`FrameSample.destroyed` counts entities.** The destroy flush reports no total, and the only
|
|
24494
25862
|
* world-level signal for a release is `onEntityDestroyed`; a component destroyed on a surviving
|
|
24495
25863
|
* entity is therefore not counted yet.
|
|
@@ -24512,17 +25880,21 @@ var SystemEntry = class {
|
|
|
24512
25880
|
order;
|
|
24513
25881
|
/** Registration serial, the tie-breaker. */
|
|
24514
25882
|
serial;
|
|
25883
|
+
/** What the system does this app's frames: always `"run"` outside edit mode. */
|
|
25884
|
+
editMode;
|
|
24515
25885
|
/**
|
|
24516
25886
|
* Creates an entry.
|
|
24517
25887
|
*
|
|
24518
25888
|
* @param system - The system.
|
|
24519
25889
|
* @param order - Its order within the phase.
|
|
24520
25890
|
* @param serial - Its registration serial.
|
|
25891
|
+
* @param editMode - What it does in this app's frames.
|
|
24521
25892
|
*/
|
|
24522
|
-
constructor(system, order, serial) {
|
|
25893
|
+
constructor(system, order, serial, editMode) {
|
|
24523
25894
|
this.system = system;
|
|
24524
25895
|
this.order = order;
|
|
24525
25896
|
this.serial = serial;
|
|
25897
|
+
this.editMode = editMode;
|
|
24526
25898
|
}
|
|
24527
25899
|
};
|
|
24528
25900
|
/**
|
|
@@ -24539,6 +25911,8 @@ var SystemContextImpl = class {
|
|
|
24539
25911
|
phase = Phase.EndOfFrame;
|
|
24540
25912
|
/** Seconds elapsed. */
|
|
24541
25913
|
dt = 0;
|
|
25914
|
+
/** Whether the running system's clock is held. */
|
|
25915
|
+
isClockHeld = false;
|
|
24542
25916
|
/**
|
|
24543
25917
|
* Creates the shared context.
|
|
24544
25918
|
*
|
|
@@ -24563,6 +25937,7 @@ var Scheduler = class {
|
|
|
24563
25937
|
#deferred;
|
|
24564
25938
|
#clock;
|
|
24565
25939
|
#development;
|
|
25940
|
+
#isEditMode;
|
|
24566
25941
|
#report;
|
|
24567
25942
|
/** One system list per phase, kept sorted by `(order, registration serial)`. */
|
|
24568
25943
|
#systems = [];
|
|
@@ -24620,6 +25995,7 @@ var Scheduler = class {
|
|
|
24620
25995
|
this.#deferred = options.deferred;
|
|
24621
25996
|
this.#clock = options.clock;
|
|
24622
25997
|
this.#development = options.development;
|
|
25998
|
+
this.#isEditMode = options.editMode;
|
|
24623
25999
|
this.#report = (error, system, phase) => {
|
|
24624
26000
|
options.report(error, system, phase);
|
|
24625
26001
|
};
|
|
@@ -24648,14 +26024,16 @@ var Scheduler = class {
|
|
|
24648
26024
|
* Registers a system in a phase (`docs/architecture/03-scripting-and-components.md` §6).
|
|
24649
26025
|
*
|
|
24650
26026
|
* @param system - The system.
|
|
24651
|
-
* @param options - The phase
|
|
26027
|
+
* @param options - The phase, the ascending order within it (`order` defaults to `0`), and what
|
|
26028
|
+
* it does in edit mode (`editMode` defaults to `"run"`).
|
|
24652
26029
|
*/
|
|
24653
26030
|
registerSystem(system, options) {
|
|
24654
26031
|
const phase = options.phase;
|
|
24655
26032
|
const list = this.#systems[phase];
|
|
24656
26033
|
if (list === void 0) return;
|
|
24657
26034
|
this.#serial += 1;
|
|
24658
|
-
const
|
|
26035
|
+
const editMode = this.#isEditMode ? options.editMode ?? "run" : "run";
|
|
26036
|
+
const entry = new SystemEntry(system, options.order ?? 0, this.#serial, editMode);
|
|
24659
26037
|
let index = list.length;
|
|
24660
26038
|
while (index > 0) {
|
|
24661
26039
|
const previous = list[index - 1];
|
|
@@ -24747,7 +26125,7 @@ var Scheduler = class {
|
|
|
24747
26125
|
const start = this.#now();
|
|
24748
26126
|
this.#phase = Phase.FixedUpdate;
|
|
24749
26127
|
this.#internals?.setPhase(Phase.FixedUpdate);
|
|
24750
|
-
if (!time.paused) {
|
|
26128
|
+
if (!time.paused && !this.#isEditMode) {
|
|
24751
26129
|
this.#accumulator = snap(this.#accumulator + time.deltaTime, time.fixedDeltaTime);
|
|
24752
26130
|
const step = time.fixedDeltaTime;
|
|
24753
26131
|
this.#stepDt = step;
|
|
@@ -24816,18 +26194,35 @@ var Scheduler = class {
|
|
|
24816
26194
|
this.#phase = phase;
|
|
24817
26195
|
this.#internals?.setPhase(phase);
|
|
24818
26196
|
for (let index = from; index < end; index += 1) {
|
|
24819
|
-
const
|
|
24820
|
-
if (
|
|
24821
|
-
|
|
24822
|
-
|
|
24823
|
-
|
|
24824
|
-
|
|
26197
|
+
const entry = list[index];
|
|
26198
|
+
if (entry === void 0) continue;
|
|
26199
|
+
if (entry.editMode === "run") this.#runSystem(entry.system, context, phase);
|
|
26200
|
+
else if (entry.editMode === "hold") {
|
|
26201
|
+
context.dt = 0;
|
|
26202
|
+
context.isClockHeld = true;
|
|
26203
|
+
this.#runSystem(entry.system, context, phase);
|
|
26204
|
+
context.dt = dt;
|
|
26205
|
+
context.isClockHeld = false;
|
|
24825
26206
|
}
|
|
24826
26207
|
}
|
|
24827
26208
|
this.#internals?.setPhase(previousPhase);
|
|
24828
26209
|
this.#phase = previousPhase;
|
|
24829
26210
|
}
|
|
24830
26211
|
/**
|
|
26212
|
+
* Runs one system, guarded.
|
|
26213
|
+
*
|
|
26214
|
+
* @param system - The system.
|
|
26215
|
+
* @param context - The shared context, already set for this phase.
|
|
26216
|
+
* @param phase - The phase, for the error report.
|
|
26217
|
+
*/
|
|
26218
|
+
#runSystem(system, context, phase) {
|
|
26219
|
+
try {
|
|
26220
|
+
system.update?.(context);
|
|
26221
|
+
} catch (error) {
|
|
26222
|
+
this.#report(error, system, phase);
|
|
26223
|
+
}
|
|
26224
|
+
}
|
|
26225
|
+
/**
|
|
24831
26226
|
* Walks one callback's sorted dispatch list.
|
|
24832
26227
|
*
|
|
24833
26228
|
* @param kind - Which callback.
|
|
@@ -25227,10 +26622,19 @@ var SettingsStore = class {
|
|
|
25227
26622
|
this.#sections.set(name, {
|
|
25228
26623
|
schema,
|
|
25229
26624
|
owner,
|
|
26625
|
+
defaults: base,
|
|
25230
26626
|
value: Object.freeze(value)
|
|
25231
26627
|
});
|
|
25232
26628
|
}
|
|
25233
26629
|
/**
|
|
26630
|
+
* Every registered section, in registration order, for `describeSettings`.
|
|
26631
|
+
*
|
|
26632
|
+
* @returns The sections, keyed by name.
|
|
26633
|
+
*/
|
|
26634
|
+
registrations() {
|
|
26635
|
+
return this.#sections;
|
|
26636
|
+
}
|
|
26637
|
+
/**
|
|
25234
26638
|
* Reports whether a section has been registered.
|
|
25235
26639
|
*
|
|
25236
26640
|
* @param name - The section name.
|
|
@@ -27479,6 +28883,11 @@ var Entity = class {
|
|
|
27479
28883
|
* The immovability hint: `true` promises that the transform will not change after `awake`, which
|
|
27480
28884
|
* lets the 2D batcher, physics, and navmesh treat the entity as static.
|
|
27481
28885
|
*
|
|
28886
|
+
* @remarks
|
|
28887
|
+
* It can be changed only in files or before `awake`; afterwards the setter throws `IGX-0101`. In an
|
|
28888
|
+
* edit-mode app it stays writable, because an editor's inspector edits it on loaded entities
|
|
28889
|
+
* (ADR-0028).
|
|
28890
|
+
*
|
|
27482
28891
|
* @returns `true` when the entity is marked static.
|
|
27483
28892
|
*/
|
|
27484
28893
|
get isStatic() {
|
|
@@ -27486,7 +28895,7 @@ var Entity = class {
|
|
|
27486
28895
|
}
|
|
27487
28896
|
set isStatic(value) {
|
|
27488
28897
|
const internals = this.#mutable("isStatic");
|
|
27489
|
-
if (internals.hasAwoken) throw new IgnifxError(CoreErrorCode.mutationAfterDestroy, "isStatic is set in files or before awake, and cannot change afterwards.", { context: {
|
|
28898
|
+
if (internals.hasAwoken && !internals.host.app.isEditMode) throw new IgnifxError(CoreErrorCode.mutationAfterDestroy, "isStatic is set in files or before awake, and cannot change afterwards.", { context: {
|
|
27490
28899
|
entity: internals.uid,
|
|
27491
28900
|
operation: "isStatic"
|
|
27492
28901
|
} });
|
|
@@ -27663,6 +29072,36 @@ var Entity = class {
|
|
|
27663
29072
|
internals.onParentChanged?.emit(parent);
|
|
27664
29073
|
}
|
|
27665
29074
|
/**
|
|
29075
|
+
* Moves the entity among its siblings: its parent's children, or its scene's roots when it has no
|
|
29076
|
+
* parent. Sibling order is the order a scene file lists entities in and the order `children`
|
|
29077
|
+
* reports.
|
|
29078
|
+
*
|
|
29079
|
+
* @param index - The entity's new index among its siblings. A value past either end is clamped
|
|
29080
|
+
* to that end, and a fraction is truncated.
|
|
29081
|
+
* @throws IgnifxError with code `IGX-0101` when the entity has been destroyed.
|
|
29082
|
+
*
|
|
29083
|
+
* @example
|
|
29084
|
+
* ```ts
|
|
29085
|
+
* weapon.setSiblingIndex(0); // first child of its parent
|
|
29086
|
+
* ```
|
|
29087
|
+
*/
|
|
29088
|
+
setSiblingIndex(index) {
|
|
29089
|
+
const internals = this.#mutable("setSiblingIndex");
|
|
29090
|
+
const parent = internals.parent;
|
|
29091
|
+
const siblings = parent === null ? internals.scene.roots : entityInternals(parent).children;
|
|
29092
|
+
const at = Math.min(Math.max(Math.trunc(Number.isNaN(index) ? 0 : index), 0), siblings.length - 1);
|
|
29093
|
+
if (parent === null) {
|
|
29094
|
+
internals.scene.moveRoot(this, at);
|
|
29095
|
+
return;
|
|
29096
|
+
}
|
|
29097
|
+
const children = entityInternals(parent).children;
|
|
29098
|
+
const from = children.indexOf(this);
|
|
29099
|
+
if (from >= 0 && from !== at) {
|
|
29100
|
+
children.splice(from, 1);
|
|
29101
|
+
children.splice(at, 0, this);
|
|
29102
|
+
}
|
|
29103
|
+
}
|
|
29104
|
+
/**
|
|
27666
29105
|
* Resolves a path relative to this entity — `"Body/Arm.L"`, `"../Sibling"`, `"/Root/Child"`.
|
|
27667
29106
|
*
|
|
27668
29107
|
* @remarks
|
|
@@ -28649,6 +30088,8 @@ function compare(item, order, serial) {
|
|
|
28649
30088
|
* `awake` waits until the component is effectively enabled. Outside callbacks, enables are queued
|
|
28650
30089
|
* and disables are immediate; nested changes run synchronously.
|
|
28651
30090
|
* Destroy children before parents and release each entity's components in attachment order.
|
|
30091
|
+
* In edit mode the one call site is also the gate: a script whose class does not run in edit mode
|
|
30092
|
+
* gets no callback at all, from any path (ADR-0028).
|
|
28652
30093
|
*/
|
|
28653
30094
|
/** How many callbacks get a sorted dispatch list. */
|
|
28654
30095
|
const DISPATCH_LIST_COUNT = 15 - FIRST_DISPATCHED_CALLBACK;
|
|
@@ -28670,6 +30111,8 @@ var LifecycleQueue = class {
|
|
|
28670
30111
|
#doomedComponents = [];
|
|
28671
30112
|
/** The phase the scheduler says is running, recorded in error reports. */
|
|
28672
30113
|
#phase = null;
|
|
30114
|
+
/** Whether the app is in edit mode, read once: it is fixed for the app's life. */
|
|
30115
|
+
#isEditMode;
|
|
28673
30116
|
/**
|
|
28674
30117
|
* Creates the queue.
|
|
28675
30118
|
*
|
|
@@ -28677,6 +30120,7 @@ var LifecycleQueue = class {
|
|
|
28677
30120
|
*/
|
|
28678
30121
|
constructor(host) {
|
|
28679
30122
|
this.#host = host;
|
|
30123
|
+
this.#isEditMode = host.app.isEditMode;
|
|
28680
30124
|
for (let index = 0; index < DISPATCH_LIST_COUNT; index += 1) this.#lists.push(new ScriptList());
|
|
28681
30125
|
}
|
|
28682
30126
|
/**
|
|
@@ -28815,6 +30259,7 @@ var LifecycleQueue = class {
|
|
|
28815
30259
|
const state = componentInternals(component);
|
|
28816
30260
|
const info = state.info;
|
|
28817
30261
|
if (info === null || !implementsCallback(info.script, kind)) return;
|
|
30262
|
+
if (this.#isEditMode && info.script?.runInEditMode !== true) return;
|
|
28818
30263
|
const name = SCRIPT_CALLBACK_NAMES[kind];
|
|
28819
30264
|
if (name === void 0) return;
|
|
28820
30265
|
const callback = readCallback(component, name);
|
|
@@ -28989,7 +30434,7 @@ var LifecycleQueue = class {
|
|
|
28989
30434
|
* @param info - Its class's callback mask and ordering, or `null` when it has none.
|
|
28990
30435
|
*/
|
|
28991
30436
|
#addToDispatch(script, info) {
|
|
28992
|
-
if (info === null) return;
|
|
30437
|
+
if (info === null || this.#isEditMode && !info.runInEditMode) return;
|
|
28993
30438
|
for (let kind = FIRST_DISPATCHED_CALLBACK; kind < 15; kind += 1) if ((info.callbacks & 1 << kind) !== 0) this.#lists[kind - FIRST_DISPATCHED_CALLBACK]?.insert(script, info);
|
|
28994
30439
|
}
|
|
28995
30440
|
/**
|
|
@@ -28999,7 +30444,7 @@ var LifecycleQueue = class {
|
|
|
28999
30444
|
* @param info - Its class's callback mask, or `null` when it has none.
|
|
29000
30445
|
*/
|
|
29001
30446
|
#removeFromDispatch(script, info) {
|
|
29002
|
-
if (info === null) return;
|
|
30447
|
+
if (info === null || this.#isEditMode && !info.runInEditMode) return;
|
|
29003
30448
|
for (let kind = FIRST_DISPATCHED_CALLBACK; kind < 15; kind += 1) if ((info.callbacks & 1 << kind) !== 0) this.#lists[kind - FIRST_DISPATCHED_CALLBACK]?.remove(script);
|
|
29004
30449
|
}
|
|
29005
30450
|
/**
|
|
@@ -29222,7 +30667,7 @@ let scratch = null;
|
|
|
29222
30667
|
* @param world - The world being picked in, for the handle tables.
|
|
29223
30668
|
* @param scene - The Lite render scene.
|
|
29224
30669
|
* @param ray - The ray to cast.
|
|
29225
|
-
* @param options - An entity filter.
|
|
30670
|
+
* @param options - An entity filter, and what to look through.
|
|
29226
30671
|
* @returns What was hit, or `null` for a miss.
|
|
29227
30672
|
*
|
|
29228
30673
|
* @internal
|
|
@@ -29231,8 +30676,11 @@ function raycastRenderScene(world, scene, ray, options) {
|
|
|
29231
30676
|
const renderer = rendererInternals(world.app.renderer);
|
|
29232
30677
|
const pickRay = scratch ??= createPickRay();
|
|
29233
30678
|
setPickRay(pickRay, ray.origin.x, ray.origin.y, ray.origin.z, ray.direction.x, ray.direction.y, ray.direction.z, ray.length);
|
|
29234
|
-
const
|
|
29235
|
-
const
|
|
30679
|
+
const plan = renderer.planPick(options);
|
|
30680
|
+
const accept = plan.accept;
|
|
30681
|
+
const hits = plan.hits;
|
|
30682
|
+
if (accept === null && hits.length === 0) return renderer.resolvePick(raycastScene(scene, pickRay));
|
|
30683
|
+
const info = raycastSceneWhere(scene, pickRay, (tag, mesh) => (accept === null || accept(tag, mesh)) && !hits.some((hit) => hit.mesh === mesh));
|
|
29236
30684
|
return renderer.resolvePick(info);
|
|
29237
30685
|
}
|
|
29238
30686
|
//#endregion
|
|
@@ -29397,6 +30845,21 @@ var SceneInstance = class {
|
|
|
29397
30845
|
if (!this.#roots.includes(entity)) this.#roots.push(entity);
|
|
29398
30846
|
}
|
|
29399
30847
|
/**
|
|
30848
|
+
* Moves a root to another place in the root list.
|
|
30849
|
+
*
|
|
30850
|
+
* @param entity - A root of this instance.
|
|
30851
|
+
* @param index - Its new index, already clamped to the list.
|
|
30852
|
+
*
|
|
30853
|
+
* @internal
|
|
30854
|
+
*/
|
|
30855
|
+
moveRoot(entity, index) {
|
|
30856
|
+
const from = this.#roots.indexOf(entity);
|
|
30857
|
+
if (from >= 0) {
|
|
30858
|
+
this.#roots.splice(from, 1);
|
|
30859
|
+
this.#roots.splice(index, 0, entity);
|
|
30860
|
+
}
|
|
30861
|
+
}
|
|
30862
|
+
/**
|
|
29400
30863
|
* Removes an entity from the root list.
|
|
29401
30864
|
*
|
|
29402
30865
|
* @param entity - The entity that gained a parent or was destroyed.
|
|
@@ -29837,9 +31300,11 @@ function invalidPath(path, reason) {
|
|
|
29837
31300
|
function expandScene(asset, options) {
|
|
29838
31301
|
const entities = [];
|
|
29839
31302
|
const instances = [];
|
|
31303
|
+
const merged = /* @__PURE__ */ new Map();
|
|
29840
31304
|
const state = {
|
|
29841
31305
|
entities,
|
|
29842
31306
|
instances,
|
|
31307
|
+
merged,
|
|
29843
31308
|
options,
|
|
29844
31309
|
counter: 0
|
|
29845
31310
|
};
|
|
@@ -29850,18 +31315,21 @@ function expandScene(asset, options) {
|
|
|
29850
31315
|
address: asset.address,
|
|
29851
31316
|
asset: null,
|
|
29852
31317
|
scene: asset,
|
|
29853
|
-
rootUid: null
|
|
31318
|
+
rootUid: null,
|
|
31319
|
+
root: null
|
|
29854
31320
|
});
|
|
29855
|
-
expandFile(asset, null, key, true, [asset.address], state);
|
|
31321
|
+
expandFile(asset, null, key, true, [asset.address], state, null);
|
|
29856
31322
|
return {
|
|
29857
31323
|
entities,
|
|
29858
|
-
instances
|
|
31324
|
+
instances,
|
|
31325
|
+
merged
|
|
29859
31326
|
};
|
|
29860
31327
|
}
|
|
29861
|
-
expandFile(asset, null, null, false, [asset.address], state);
|
|
31328
|
+
expandFile(asset, null, null, false, [asset.address], state, null);
|
|
29862
31329
|
return {
|
|
29863
31330
|
entities,
|
|
29864
|
-
instances
|
|
31331
|
+
instances,
|
|
31332
|
+
merged
|
|
29865
31333
|
};
|
|
29866
31334
|
}
|
|
29867
31335
|
/**
|
|
@@ -29873,16 +31341,17 @@ function expandScene(asset, options) {
|
|
|
29873
31341
|
* @param freshUids - `true` mints a new uid per entity and component; `false` keeps the file's own.
|
|
29874
31342
|
* @param chain - The addresses of the scenes currently being expanded, for the cycle check.
|
|
29875
31343
|
* @param state - The accumulating output.
|
|
31344
|
+
* @param merge - Where the file's single root merges, or `null` to create every entity.
|
|
29876
31345
|
* @returns The override targets produced, keyed by the uid each entity carries in `asset`'s own
|
|
29877
31346
|
* file.
|
|
29878
31347
|
*/
|
|
29879
|
-
function expandFile(asset, parentUid, instanceKey, freshUids, chain, state) {
|
|
31348
|
+
function expandFile(asset, parentUid, instanceKey, freshUids, chain, state, merge) {
|
|
29880
31349
|
const source = asset.file.entities;
|
|
29881
31350
|
const keys = /* @__PURE__ */ new Map();
|
|
29882
31351
|
if (freshUids) for (let index = 0; index < source.length; index += 1) {
|
|
29883
31352
|
const entity = source[index];
|
|
29884
31353
|
if (entity === void 0) continue;
|
|
29885
|
-
keys.set(entity.uid, state.options.nextUid());
|
|
31354
|
+
keys.set(entity.uid, merge !== null && entity.parent === null ? merge.into.uid : state.options.nextUid());
|
|
29886
31355
|
const components = entity.components ?? [];
|
|
29887
31356
|
for (let inner = 0; inner < components.length; inner += 1) {
|
|
29888
31357
|
const component = components[inner];
|
|
@@ -29893,6 +31362,11 @@ function expandFile(asset, parentUid, instanceKey, freshUids, chain, state) {
|
|
|
29893
31362
|
for (let index = 0; index < source.length; index += 1) {
|
|
29894
31363
|
const entity = source[index];
|
|
29895
31364
|
if (entity === void 0) continue;
|
|
31365
|
+
if (merge !== null && entity.parent === null) {
|
|
31366
|
+
produced.set(entity.uid, mergeRoot(entity, merge, keys, state));
|
|
31367
|
+
if (entity.instance !== void 0) expandInstance(asset, entity.instance, merge.into, chain, state);
|
|
31368
|
+
continue;
|
|
31369
|
+
}
|
|
29896
31370
|
const uid = keys.get(entity.uid) ?? entity.uid;
|
|
29897
31371
|
const componentSourceUids = /* @__PURE__ */ new Map();
|
|
29898
31372
|
const data = {
|
|
@@ -29921,20 +31395,52 @@ function expandFile(asset, parentUid, instanceKey, freshUids, chain, state) {
|
|
|
29921
31395
|
componentSourceUids
|
|
29922
31396
|
});
|
|
29923
31397
|
const nested = entity.instance;
|
|
29924
|
-
if (nested !== void 0) expandInstance(asset, nested,
|
|
31398
|
+
if (nested !== void 0) expandInstance(asset, nested, data, chain, state);
|
|
29925
31399
|
}
|
|
29926
31400
|
return produced;
|
|
29927
31401
|
}
|
|
29928
31402
|
/**
|
|
29929
|
-
*
|
|
31403
|
+
* Merges an instanced scene's single root into the entity carrying the `instance` entry: the
|
|
31404
|
+
* root's components come first, then the carrier's own. The carrier keeps its own uid, name,
|
|
31405
|
+
* transform, and other entity fields, as `world.instantiate` keeps the placement it is given.
|
|
31406
|
+
*
|
|
31407
|
+
* @param entity - The instanced root's record.
|
|
31408
|
+
* @param merge - The carrier and the component uid table to fill.
|
|
31409
|
+
* @param keys - Source uid to expanded uid for the instanced file.
|
|
31410
|
+
* @param state - The accumulating output.
|
|
31411
|
+
* @returns The override target for the root, which is the carrier.
|
|
31412
|
+
*/
|
|
31413
|
+
function mergeRoot(entity, merge, keys, state) {
|
|
31414
|
+
const into = merge.into;
|
|
31415
|
+
const components = cloneComponents(entity, keys, merge.componentSourceUids);
|
|
31416
|
+
into.components = [...components, ...into.components];
|
|
31417
|
+
let merged = state.merged.get(into.uid);
|
|
31418
|
+
if (merged === void 0) {
|
|
31419
|
+
merged = /* @__PURE__ */ new Set();
|
|
31420
|
+
state.merged.set(into.uid, merged);
|
|
31421
|
+
}
|
|
31422
|
+
for (let index = 0; index < components.length; index += 1) {
|
|
31423
|
+
const component = components[index];
|
|
31424
|
+
if (component !== void 0) merged.add(component.uid);
|
|
31425
|
+
}
|
|
31426
|
+
return {
|
|
31427
|
+
data: into,
|
|
31428
|
+
components: reverse(merge.componentSourceUids)
|
|
31429
|
+
};
|
|
31430
|
+
}
|
|
31431
|
+
/**
|
|
31432
|
+
* Expands one `instance` entry on the entity that carries it. A scene with exactly one root merges
|
|
31433
|
+
* that root into the carrier, as `world.instantiate` answers with that root; any other scene's
|
|
31434
|
+
* roots become the carrier's children.
|
|
29930
31435
|
*
|
|
29931
31436
|
* @param asset - The scene the entry was declared in, whose dependencies resolve the reference.
|
|
29932
31437
|
* @param instance - The entry.
|
|
29933
|
-
* @param
|
|
31438
|
+
* @param carrier - The expanded record of the entity carrying it.
|
|
29934
31439
|
* @param chain - The addresses currently being expanded.
|
|
29935
31440
|
* @param state - The accumulating output.
|
|
29936
31441
|
*/
|
|
29937
|
-
function expandInstance(asset, instance,
|
|
31442
|
+
function expandInstance(asset, instance, carrier, chain, state) {
|
|
31443
|
+
const rootUid = carrier.uid;
|
|
29938
31444
|
const address = instance.scene.$asset;
|
|
29939
31445
|
if (chain.includes(address)) throw new IgnifxError(CoreErrorCode.sceneInstanceCycle, `Instantiating ${address} would nest the scene inside itself.`, {
|
|
29940
31446
|
context: {
|
|
@@ -29952,14 +31458,28 @@ function expandInstance(asset, instance, rootUid, chain, state) {
|
|
|
29952
31458
|
const recorded = instance.hash;
|
|
29953
31459
|
if (recorded !== void 0 && recorded !== resolved.value.hash) reportHashMismatch(address, recorded, resolved.value.hash, state.options);
|
|
29954
31460
|
const key = nextInstanceKey(state);
|
|
31461
|
+
const single = singleRoot(resolved.value);
|
|
31462
|
+
let merge = null;
|
|
31463
|
+
let root = null;
|
|
31464
|
+
if (single !== null) {
|
|
31465
|
+
merge = {
|
|
31466
|
+
into: carrier,
|
|
31467
|
+
componentSourceUids: /* @__PURE__ */ new Map()
|
|
31468
|
+
};
|
|
31469
|
+
root = {
|
|
31470
|
+
sourceUid: single.uid,
|
|
31471
|
+
componentSourceUids: merge.componentSourceUids
|
|
31472
|
+
};
|
|
31473
|
+
}
|
|
29955
31474
|
state.instances.push({
|
|
29956
31475
|
key,
|
|
29957
31476
|
address,
|
|
29958
31477
|
asset: resolved.handle,
|
|
29959
31478
|
scene: resolved.value,
|
|
29960
|
-
rootUid
|
|
31479
|
+
rootUid,
|
|
31480
|
+
root
|
|
29961
31481
|
});
|
|
29962
|
-
const produced = expandFile(resolved.value, rootUid, key, true, [...chain, address], state);
|
|
31482
|
+
const produced = expandFile(resolved.value, rootUid, key, true, [...chain, address], state, merge);
|
|
29963
31483
|
const overrides = instance.overrides;
|
|
29964
31484
|
if (overrides !== void 0 && overrides.length > 0) applyOverrides(overrides, produced, (message) => {
|
|
29965
31485
|
state.options.report(CoreErrorCode.instanceHashMismatch, `${asset.address}: ${message}`);
|
|
@@ -29986,6 +31506,25 @@ function reportHashMismatch(address, recorded, actual, options) {
|
|
|
29986
31506
|
options.report(CoreErrorCode.instanceHashMismatch, message);
|
|
29987
31507
|
}
|
|
29988
31508
|
/**
|
|
31509
|
+
* The record of a scene's only root.
|
|
31510
|
+
*
|
|
31511
|
+
* @param asset - The scene.
|
|
31512
|
+
* @returns The root's record, or `null` when the scene declares no root or several.
|
|
31513
|
+
*
|
|
31514
|
+
* @internal
|
|
31515
|
+
*/
|
|
31516
|
+
function singleRoot(asset) {
|
|
31517
|
+
let found = null;
|
|
31518
|
+
const entities = asset.file.entities;
|
|
31519
|
+
for (let index = 0; index < entities.length; index += 1) {
|
|
31520
|
+
const entity = entities[index];
|
|
31521
|
+
if (entity === void 0 || entity.parent !== null) continue;
|
|
31522
|
+
if (found !== null) return null;
|
|
31523
|
+
found = entity;
|
|
31524
|
+
}
|
|
31525
|
+
return found;
|
|
31526
|
+
}
|
|
31527
|
+
/**
|
|
29989
31528
|
* Mints the next instance key.
|
|
29990
31529
|
*
|
|
29991
31530
|
* @param state - The expansion state.
|
|
@@ -30278,6 +31817,7 @@ function instantiateScene(world, asset, options) {
|
|
|
30278
31817
|
remap: new UidRemap(),
|
|
30279
31818
|
report,
|
|
30280
31819
|
instances: indexInstances(expanded.instances),
|
|
31820
|
+
merged: expanded.merged,
|
|
30281
31821
|
roots: [],
|
|
30282
31822
|
built: []
|
|
30283
31823
|
};
|
|
@@ -30380,16 +31920,17 @@ function attachComponents(context) {
|
|
|
30380
31920
|
* @param rootEntity - The entity that stands for the outermost instance, when the caller made one.
|
|
30381
31921
|
*/
|
|
30382
31922
|
function linkInstances(context, handle, rootEntity) {
|
|
30383
|
-
const
|
|
31923
|
+
const firstMember = /* @__PURE__ */ new Map();
|
|
30384
31924
|
for (let index = 0; index < context.built.length; index += 1) {
|
|
30385
31925
|
const built = context.built[index];
|
|
30386
31926
|
const key = built?.source.instanceKey ?? null;
|
|
30387
|
-
if (built
|
|
30388
|
-
|
|
30389
|
-
|
|
31927
|
+
if (built !== void 0 && key !== null && !firstMember.has(key)) firstMember.set(key, built.entity);
|
|
31928
|
+
}
|
|
31929
|
+
const rootOfInstance = /* @__PURE__ */ new Map();
|
|
31930
|
+
for (const instance of context.instances.values()) {
|
|
30390
31931
|
const declared = instance.rootUid;
|
|
30391
|
-
const resolved = declared === null ? rootEntity ??
|
|
30392
|
-
rootOfInstance.set(key, resolved
|
|
31932
|
+
const resolved = declared === null ? rootEntity ?? firstMember.get(instance.key) ?? null : context.remap.entity(declared);
|
|
31933
|
+
if (resolved !== null) rootOfInstance.set(instance.key, resolved);
|
|
30393
31934
|
}
|
|
30394
31935
|
const insideOf = /* @__PURE__ */ new Map();
|
|
30395
31936
|
for (let index = 0; index < context.built.length; index += 1) {
|
|
@@ -30400,7 +31941,7 @@ function linkInstances(context, handle, rootEntity) {
|
|
|
30400
31941
|
if (root !== void 0 && root !== built.entity) insideOf.set(built.entity, root);
|
|
30401
31942
|
}
|
|
30402
31943
|
if (rootEntity !== null) {
|
|
30403
|
-
const own = ownedInstance(context, rootEntity, rootOfInstance, handle);
|
|
31944
|
+
const own = ownedInstance(context, rootEntity, null, rootOfInstance, handle);
|
|
30404
31945
|
if (own !== null) entityInternals(rootEntity).origin = {
|
|
30405
31946
|
sourceUid: "",
|
|
30406
31947
|
instanceRoot: null,
|
|
@@ -30411,7 +31952,7 @@ function linkInstances(context, handle, rootEntity) {
|
|
|
30411
31952
|
for (let index = 0; index < context.built.length; index += 1) {
|
|
30412
31953
|
const built = context.built[index];
|
|
30413
31954
|
if (built === void 0) continue;
|
|
30414
|
-
const own = ownedInstance(context, built.entity, rootOfInstance, handle);
|
|
31955
|
+
const own = ownedInstance(context, built.entity, built.source, rootOfInstance, handle);
|
|
30415
31956
|
const inside = insideOf.get(built.entity) ?? null;
|
|
30416
31957
|
if (own === null && inside === null) continue;
|
|
30417
31958
|
const origin = {
|
|
@@ -30428,11 +31969,12 @@ function linkInstances(context, handle, rootEntity) {
|
|
|
30428
31969
|
*
|
|
30429
31970
|
* @param context - The build state.
|
|
30430
31971
|
* @param entity - The candidate root.
|
|
31972
|
+
* @param source - The expanded record that produced it, or `null` for a caller's container.
|
|
30431
31973
|
* @param rootOfInstance - Instance key to its root entity.
|
|
30432
31974
|
* @param handle - The handle the whole file was loaded through, for `asInstance` builds.
|
|
30433
31975
|
* @returns The link, or `null` when the entity roots no instance.
|
|
30434
31976
|
*/
|
|
30435
|
-
function ownedInstance(context, entity, rootOfInstance, handle) {
|
|
31977
|
+
function ownedInstance(context, entity, source, rootOfInstance, handle) {
|
|
30436
31978
|
for (const [key, root] of rootOfInstance) {
|
|
30437
31979
|
if (root !== entity) continue;
|
|
30438
31980
|
const instance = context.instances.get(key);
|
|
@@ -30440,12 +31982,37 @@ function ownedInstance(context, entity, rootOfInstance, handle) {
|
|
|
30440
31982
|
return {
|
|
30441
31983
|
address: instance.address,
|
|
30442
31984
|
asset: instance.rootUid === null ? handle : instance.asset,
|
|
30443
|
-
scene: instance.scene
|
|
31985
|
+
scene: instance.scene,
|
|
31986
|
+
root: instancedRoot(context, instance, source)
|
|
30444
31987
|
};
|
|
30445
31988
|
}
|
|
30446
31989
|
return null;
|
|
30447
31990
|
}
|
|
30448
31991
|
/**
|
|
31992
|
+
* What an instance root took from its scene's single root, when it stands for that root rather
|
|
31993
|
+
* than for a container (`docs/architecture/06-serialization-and-scene-format.md` §2).
|
|
31994
|
+
*
|
|
31995
|
+
* @param context - The build state.
|
|
31996
|
+
* @param instance - The instance the entity roots.
|
|
31997
|
+
* @param source - The expanded record that produced the entity, or `null` for a caller's container.
|
|
31998
|
+
* @returns The root's record uid and the components it brought, or `null` for a container.
|
|
31999
|
+
*/
|
|
32000
|
+
function instancedRoot(context, instance, source) {
|
|
32001
|
+
if (source === null) return null;
|
|
32002
|
+
const merged = context.merged.get(source.data.uid) ?? /* @__PURE__ */ new Set();
|
|
32003
|
+
if (instance.root !== null) return {
|
|
32004
|
+
sourceUid: instance.root.sourceUid,
|
|
32005
|
+
componentSourceUids: instance.root.componentSourceUids,
|
|
32006
|
+
components: merged
|
|
32007
|
+
};
|
|
32008
|
+
if (instance.rootUid !== null || singleRoot(instance.scene)?.uid !== source.sourceUid) return null;
|
|
32009
|
+
return {
|
|
32010
|
+
sourceUid: source.sourceUid,
|
|
32011
|
+
componentSourceUids: source.componentSourceUids,
|
|
32012
|
+
components: /* @__PURE__ */ new Set([...source.componentSourceUids.keys(), ...merged])
|
|
32013
|
+
};
|
|
32014
|
+
}
|
|
32015
|
+
/**
|
|
30449
32016
|
* Pass 4: decodes every component's props, resolving `entityRef`/`componentRef` through the now
|
|
30450
32017
|
* complete uid table (`docs/architecture/06-serialization-and-scene-format.md` §4 step 5).
|
|
30451
32018
|
*
|
|
@@ -30573,6 +32140,90 @@ function sceneAssetResolver(world, asset) {
|
|
|
30573
32140
|
return cached !== null && cached.state === "loaded" ? cached : null;
|
|
30574
32141
|
};
|
|
30575
32142
|
}
|
|
32143
|
+
/** A decoder that resolves nothing, for a record built without one. */
|
|
32144
|
+
const NO_REFERENCES = Object.freeze({
|
|
32145
|
+
entity: () => null,
|
|
32146
|
+
component: () => null,
|
|
32147
|
+
asset: () => null
|
|
32148
|
+
});
|
|
32149
|
+
/**
|
|
32150
|
+
* Attaches one component to a live entity from its scene file record, the way the scene loader
|
|
32151
|
+
* builds it: the record's registered type, its uid, its `enabled` flag, and its `props` decoded
|
|
32152
|
+
* against the schema (`docs/architecture/06-serialization-and-scene-format.md` §4).
|
|
32153
|
+
*
|
|
32154
|
+
* @remarks
|
|
32155
|
+
* This is the per-component step of {@link instantiateScene} for a world that already exists, which
|
|
32156
|
+
* is what an editor mirroring a document into a live world needs. The component is attached with
|
|
32157
|
+
* `entity.addComponent`, so `awake` follows that method's rules. The record's uid is adopted as is;
|
|
32158
|
+
* keeping it unique within the scene is the caller's job. Decoding never throws: a value that does
|
|
32159
|
+
* not match its field takes the field's default and is reported in `issues`.
|
|
32160
|
+
*
|
|
32161
|
+
* @param entity - The entity to attach to.
|
|
32162
|
+
* @param record - The component record, as a scene file writes it.
|
|
32163
|
+
* @param options - Where it goes among the entity's components, and how references resolve.
|
|
32164
|
+
* @returns The component and the decoding problems.
|
|
32165
|
+
* @throws IgnifxError with code `IGX-0307` when the record's type is not registered, and whatever
|
|
32166
|
+
* `entity.addComponent` throws (`IGX-0202` for a second instance of a single-instance class,
|
|
32167
|
+
* `IGX-0101` for a destroyed entity).
|
|
32168
|
+
*
|
|
32169
|
+
* @example
|
|
32170
|
+
* ```ts
|
|
32171
|
+
* const { component } = addComponentFromRecord(player, { uid: "01J9Z6M7E5S3A0V2Q4R8T1Y6WY", type: "game/Health", props: { max: 120 } });
|
|
32172
|
+
* ```
|
|
32173
|
+
*
|
|
32174
|
+
* @public
|
|
32175
|
+
*/
|
|
32176
|
+
function addComponentFromRecord(entity, record, options) {
|
|
32177
|
+
const registry = entity.world.registry;
|
|
32178
|
+
const type = registry.get(record.type);
|
|
32179
|
+
if (type === null) throw new IgnifxError(CoreErrorCode.unknownComponentTypeId, `The component type "${record.type}" is not registered; register it with app.registerComponents or check its typeId.`, { context: {
|
|
32180
|
+
typeId: record.type,
|
|
32181
|
+
entity: entity.uid
|
|
32182
|
+
} });
|
|
32183
|
+
const component = entity.addComponent(type);
|
|
32184
|
+
componentInternals(component).uid = record.uid;
|
|
32185
|
+
if (record.enabled === false) component.enabled = false;
|
|
32186
|
+
if (options?.index !== void 0) moveToFileIndex(entity, component, options.index);
|
|
32187
|
+
const issues = [];
|
|
32188
|
+
const schema = registry.describe(component.constructor).schema;
|
|
32189
|
+
if (schema !== null) applyProps({ report: (code, message) => {
|
|
32190
|
+
issues.push({
|
|
32191
|
+
code,
|
|
32192
|
+
message
|
|
32193
|
+
});
|
|
32194
|
+
} }, options?.references ?? NO_REFERENCES, component, schema, record.props ?? {}, record.uid);
|
|
32195
|
+
return {
|
|
32196
|
+
component,
|
|
32197
|
+
issues
|
|
32198
|
+
};
|
|
32199
|
+
}
|
|
32200
|
+
/**
|
|
32201
|
+
* Moves a component to an index of the entity's component list as a scene file counts it: the
|
|
32202
|
+
* transform, destroyed components, and the components an instanced scene merged in do not count.
|
|
32203
|
+
*
|
|
32204
|
+
* @param entity - The owner.
|
|
32205
|
+
* @param component - One of its components.
|
|
32206
|
+
* @param index - The index in file order; past the end means the end.
|
|
32207
|
+
*/
|
|
32208
|
+
function moveToFileIndex(entity, component, index) {
|
|
32209
|
+
const internals = entityInternals(entity);
|
|
32210
|
+
const list = internals.components;
|
|
32211
|
+
const from = list.indexOf(component);
|
|
32212
|
+
if (from < 0) return;
|
|
32213
|
+
list.splice(from, 1);
|
|
32214
|
+
const merged = internals.origin?.instanced?.root?.components ?? null;
|
|
32215
|
+
let counted = 0;
|
|
32216
|
+
for (let at = 0; at < list.length; at += 1) {
|
|
32217
|
+
const other = list[at];
|
|
32218
|
+
if (other === void 0 || other === internals.transform || other.isDestroyed || merged?.has(other.uid) === true) continue;
|
|
32219
|
+
if (counted >= index) {
|
|
32220
|
+
list.splice(at, 0, component);
|
|
32221
|
+
return;
|
|
32222
|
+
}
|
|
32223
|
+
counted += 1;
|
|
32224
|
+
}
|
|
32225
|
+
list.push(component);
|
|
32226
|
+
}
|
|
30576
32227
|
/**
|
|
30577
32228
|
* Checks that every scene a file instances — at any depth — is among the loaded dependencies, which
|
|
30578
32229
|
* is what makes `world.instantiate` safe to be synchronous
|
|
@@ -30946,7 +32597,7 @@ var World = class {
|
|
|
30946
32597
|
* answer.
|
|
30947
32598
|
*
|
|
30948
32599
|
* @param ray - The ray to cast.
|
|
30949
|
-
* @param options - An entity filter.
|
|
32600
|
+
* @param options - An entity filter, and what to look through.
|
|
30950
32601
|
* @returns What was hit, or `null` for a miss.
|
|
30951
32602
|
*
|
|
30952
32603
|
* @example
|
|
@@ -31090,6 +32741,110 @@ var World = class {
|
|
|
31090
32741
|
return instance;
|
|
31091
32742
|
}
|
|
31092
32743
|
/**
|
|
32744
|
+
* Builds a scene from a file that is already in memory, the way {@link World.loadScene} builds one
|
|
32745
|
+
* from an address (`docs/architecture/02-scene-graph.md` §2).
|
|
32746
|
+
*
|
|
32747
|
+
* @remarks
|
|
32748
|
+
* Nothing is fetched for the file itself: it is validated, every asset it references is loaded
|
|
32749
|
+
* through `app.assets` (the scene loader's own walk), and it is published there at
|
|
32750
|
+
* `options.address` as a scene asset, so the instance's `asset` and everything that reads it
|
|
32751
|
+
* behave as for a loaded file. Entity and component uids are the file's. The instance holds the
|
|
32752
|
+
* asset and its dependencies and releases them when it is unloaded. The rest is
|
|
32753
|
+
* {@link World.loadScene}'s: the same modes, the same synchronous build, `awake` before the
|
|
32754
|
+
* promise settles, and `onSceneLoaded`.
|
|
32755
|
+
*
|
|
32756
|
+
* This is how a tool builds a scene it holds as an object, such as an editor's open document with
|
|
32757
|
+
* unsaved edits.
|
|
32758
|
+
*
|
|
32759
|
+
* @param file - The scene file object, as `serializeScene` or `JSON.parse` produces it.
|
|
32760
|
+
* @param options - The address to publish it at, the mode, cancellation, and an issue collector.
|
|
32761
|
+
* @returns The instance, once every entity exists, every reference is resolved, and `awake` has
|
|
32762
|
+
* run.
|
|
32763
|
+
* @throws IgnifxError with code `IGX-0308` when the object is not a scene file, `IGX-0603` for a
|
|
32764
|
+
* format version this build cannot read, and `IGX-0608` when it does not match the scene format;
|
|
32765
|
+
* nothing is unloaded then. `IGX-0502` when `options.signal` aborts, `IGX-0307` when the file
|
|
32766
|
+
* names an unregistered component type (the half-built instance is unloaded first), and
|
|
32767
|
+
* whatever the asset system throws for a dependency.
|
|
32768
|
+
*
|
|
32769
|
+
* @example
|
|
32770
|
+
* ```ts
|
|
32771
|
+
* const level = await world.loadSceneFile(file, { address: "levels/level01.scene.json" });
|
|
32772
|
+
* ```
|
|
32773
|
+
*/
|
|
32774
|
+
async loadSceneFile(file, options) {
|
|
32775
|
+
const { address, signal } = options;
|
|
32776
|
+
const checked = readSceneFile(file, address, true);
|
|
32777
|
+
const mode = options.mode ?? "single";
|
|
32778
|
+
if (mode === "single") await this.#unloadNonPersistent();
|
|
32779
|
+
const dependencies = await loadSceneDependencies(this.#assets(), checked, signal === void 0 ? void 0 : { signal });
|
|
32780
|
+
const release = () => {
|
|
32781
|
+
for (let index = 0; index < dependencies.length; index += 1) dependencies[index]?.release();
|
|
32782
|
+
};
|
|
32783
|
+
if (signal?.aborted === true) {
|
|
32784
|
+
release();
|
|
32785
|
+
throw new IgnifxError(CoreErrorCode.assetLoadAborted, `Loading ${address} was aborted.`, { context: { asset: address } });
|
|
32786
|
+
}
|
|
32787
|
+
const asset = await createSceneAsset(address, checked, dependencies);
|
|
32788
|
+
const handle = this.#assets().register(asset, {
|
|
32789
|
+
type: SCENE_ASSET_TYPE,
|
|
32790
|
+
address
|
|
32791
|
+
});
|
|
32792
|
+
const instance = new SceneInstance(this.#nextUid(), options.name ?? checked.name, false);
|
|
32793
|
+
instance.setAsset(handle);
|
|
32794
|
+
instance.onUnloading.connect(release, { once: true });
|
|
32795
|
+
instance.setLoaded(false);
|
|
32796
|
+
this.#scenes.push(instance);
|
|
32797
|
+
let built;
|
|
32798
|
+
try {
|
|
32799
|
+
built = instantiateScene(this, asset, {
|
|
32800
|
+
scene: instance,
|
|
32801
|
+
...options.strictInstanceHashes === void 0 ? {} : { strictInstanceHashes: options.strictInstanceHashes }
|
|
32802
|
+
});
|
|
32803
|
+
} catch (error) {
|
|
32804
|
+
await this.unloadScene(instance);
|
|
32805
|
+
throw error;
|
|
32806
|
+
}
|
|
32807
|
+
instance.setRemap(built.remap);
|
|
32808
|
+
instance.setSettings(checked.settings ?? null);
|
|
32809
|
+
instance.setLoaded(true);
|
|
32810
|
+
this.#reportSceneIssues(address, built.issues);
|
|
32811
|
+
const onIssue = options.onIssue;
|
|
32812
|
+
if (onIssue !== void 0) for (let index = 0; index < built.issues.length; index += 1) {
|
|
32813
|
+
const issue = built.issues[index];
|
|
32814
|
+
if (issue !== void 0) onIssue(issue);
|
|
32815
|
+
}
|
|
32816
|
+
if (options.setActive ?? mode === "single") this.#activeScene = instance;
|
|
32817
|
+
this.#lifecycle.flushAwakeAndEnable();
|
|
32818
|
+
this.#onSceneLoaded.emit(instance);
|
|
32819
|
+
return instance;
|
|
32820
|
+
}
|
|
32821
|
+
/**
|
|
32822
|
+
* Creates an empty scene instance that is built in code rather than loaded from a file
|
|
32823
|
+
* (`docs/architecture/02-scene-graph.md` §3).
|
|
32824
|
+
*
|
|
32825
|
+
* @remarks
|
|
32826
|
+
* Entities join it through `createEntity(name, { scene })` or `moveEntityToScene`. A persistent
|
|
32827
|
+
* instance survives every `"single"` load, so it is where a tool keeps objects that must outlive
|
|
32828
|
+
* the levels it loads: an editor's cameras, grid and gizmo roots. Like any instance other than the
|
|
32829
|
+
* implicit `"default"` one, it can be unloaded with `unloadScene`. Creating it raises no
|
|
32830
|
+
* `onSceneLoaded`, because nothing was loaded; `serializeScene` writes it only when it is passed.
|
|
32831
|
+
*
|
|
32832
|
+
* @param name - The instance's name.
|
|
32833
|
+
* @param options - Whether it is persistent.
|
|
32834
|
+
* @returns The new, empty instance, appended to `scenes`.
|
|
32835
|
+
*
|
|
32836
|
+
* @example
|
|
32837
|
+
* ```ts
|
|
32838
|
+
* const tools = world.createScene("editor", { persistent: true });
|
|
32839
|
+
* const camera = world.createEntity("Editor Camera", { scene: tools });
|
|
32840
|
+
* ```
|
|
32841
|
+
*/
|
|
32842
|
+
createScene(name, options) {
|
|
32843
|
+
const instance = new SceneInstance(this.#nextUid(), name, options?.persistent ?? false);
|
|
32844
|
+
this.#scenes.push(instance);
|
|
32845
|
+
return instance;
|
|
32846
|
+
}
|
|
32847
|
+
/**
|
|
31093
32848
|
* Unloads a scene instance: `onUnloading` fires while its entities are still valid, its roots are
|
|
31094
32849
|
* destroyed through the normal destroy path (children before parents, `onDisable` then
|
|
31095
32850
|
* `onDestroy`), and the assets it held are released
|
|
@@ -31631,6 +33386,8 @@ var AppImpl = class {
|
|
|
31631
33386
|
hotReload;
|
|
31632
33387
|
/** `true` when the app runs on Lite's null engine with no render surface. */
|
|
31633
33388
|
isHeadless;
|
|
33389
|
+
/** `true` when the app was created for an editor's scene view. */
|
|
33390
|
+
isEditMode;
|
|
31634
33391
|
/** The `@ignifx/core` version this app was built from. */
|
|
31635
33392
|
version = VERSION;
|
|
31636
33393
|
/** Where the app is running. */
|
|
@@ -31684,6 +33441,7 @@ var AppImpl = class {
|
|
|
31684
33441
|
this.#clock = options.clock;
|
|
31685
33442
|
this.#mode = options.mode;
|
|
31686
33443
|
this.isHeadless = options.canvas === null;
|
|
33444
|
+
this.isEditMode = options.editMode;
|
|
31687
33445
|
this.platform = options.platform;
|
|
31688
33446
|
this.storage = new StorageImpl(options.storage);
|
|
31689
33447
|
const development = options.mode === "development";
|
|
@@ -31729,6 +33487,7 @@ var AppImpl = class {
|
|
|
31729
33487
|
});
|
|
31730
33488
|
this.coroutines = new CoroutineHostImpl({
|
|
31731
33489
|
frameState: this.#frameState,
|
|
33490
|
+
editMode: options.editMode,
|
|
31732
33491
|
report: (error, owner) => {
|
|
31733
33492
|
this.#report({
|
|
31734
33493
|
error,
|
|
@@ -31747,6 +33506,7 @@ var AppImpl = class {
|
|
|
31747
33506
|
deferred: this.#deferred,
|
|
31748
33507
|
clock: options.clock,
|
|
31749
33508
|
development,
|
|
33509
|
+
editMode: options.editMode,
|
|
31750
33510
|
report: (error, system, phase) => {
|
|
31751
33511
|
this.log.error(`The system ${system.name} threw in ${PHASE_NAMES[phase] ?? "no phase"}.`, error);
|
|
31752
33512
|
this.#report({
|
|
@@ -32193,7 +33953,8 @@ async function createApp(options = {}) {
|
|
|
32193
33953
|
mode: options.mode ?? "development",
|
|
32194
33954
|
logSink: options.logSink ?? createConsoleSink(),
|
|
32195
33955
|
logLevel: options.logLevel ?? "info",
|
|
32196
|
-
reloadScenes: options.hotReload?.reloadScenes ?? false
|
|
33956
|
+
reloadScenes: options.hotReload?.reloadScenes ?? false,
|
|
33957
|
+
editMode: options.editMode ?? false
|
|
32197
33958
|
});
|
|
32198
33959
|
await app.initialize(options.extensions ?? []);
|
|
32199
33960
|
return app;
|
|
@@ -32679,6 +34440,64 @@ var Vec4 = class Vec4 {
|
|
|
32679
34440
|
}
|
|
32680
34441
|
};
|
|
32681
34442
|
//#endregion
|
|
34443
|
+
//#region src/transform/transform-schema.ts
|
|
34444
|
+
/**
|
|
34445
|
+
* The entity transform as a schema: the fields of a scene file's `transform` block, so an
|
|
34446
|
+
* inspector and its ops can treat the transform like any component
|
|
34447
|
+
* (`docs/architecture/06-serialization-and-scene-format.md` §2).
|
|
34448
|
+
*
|
|
34449
|
+
* @remarks
|
|
34450
|
+
* The schema **describes** the transform; {@link (Transform:class)} does not declare it. The class keeps
|
|
34451
|
+
* no schema because its `position` and `rotation` are world-space getters, while the file, this
|
|
34452
|
+
* schema, and the editor's `setTransform` op all carry **local** values. Every entity has exactly
|
|
34453
|
+
* one transform, which is never in a file's `components` list, so `describeSchemas()` and
|
|
34454
|
+
* `describeRegisteredSchemas()` mark `ignifx/Transform` as `builtIn`: it cannot be added or
|
|
34455
|
+
* removed, and its values are edited as the whole block, not with a per-prop op.
|
|
34456
|
+
*
|
|
34457
|
+
* `rotation` is a `quat` field: files and ops store a unit quaternion, and an inspector shows
|
|
34458
|
+
* intrinsic XYZ Euler angles in degrees (ADR-0011), so its `step` is in degrees.
|
|
34459
|
+
*
|
|
34460
|
+
* @returns A new schema: `position` (`vec3`, origin, step 0.01), `rotation` (`quat`, identity,
|
|
34461
|
+
* step 0.5 degrees), `scale` (`vec3`, one, step 0.01).
|
|
34462
|
+
*
|
|
34463
|
+
* @example
|
|
34464
|
+
* ```ts
|
|
34465
|
+
* const fields = describeSchema("ignifx/Transform", transformSchema()).fields;
|
|
34466
|
+
* fields["rotation"]?.default; // [0, 0, 0, 1]
|
|
34467
|
+
* ```
|
|
34468
|
+
*
|
|
34469
|
+
* @public
|
|
34470
|
+
*/
|
|
34471
|
+
function transformSchema() {
|
|
34472
|
+
return defineSchema({
|
|
34473
|
+
position: vec3({
|
|
34474
|
+
x: 0,
|
|
34475
|
+
y: 0,
|
|
34476
|
+
z: 0
|
|
34477
|
+
}, {
|
|
34478
|
+
tooltip: "Local position relative to the parent, in metres.",
|
|
34479
|
+
step: .01
|
|
34480
|
+
}),
|
|
34481
|
+
rotation: quat({
|
|
34482
|
+
x: 0,
|
|
34483
|
+
y: 0,
|
|
34484
|
+
z: 0,
|
|
34485
|
+
w: 1
|
|
34486
|
+
}, {
|
|
34487
|
+
tooltip: "Local rotation relative to the parent: a unit quaternion [x, y, z, w], shown as intrinsic XYZ Euler angles in degrees.",
|
|
34488
|
+
step: .5
|
|
34489
|
+
}),
|
|
34490
|
+
scale: vec3({
|
|
34491
|
+
x: 1,
|
|
34492
|
+
y: 1,
|
|
34493
|
+
z: 1
|
|
34494
|
+
}, {
|
|
34495
|
+
tooltip: "Local scale relative to the parent.",
|
|
34496
|
+
step: .01
|
|
34497
|
+
})
|
|
34498
|
+
});
|
|
34499
|
+
}
|
|
34500
|
+
//#endregion
|
|
32682
34501
|
//#region src/render/schemas.ts
|
|
32683
34502
|
/**
|
|
32684
34503
|
* The documentation harness's view of everything `@ignifx/core` declares
|
|
@@ -32695,11 +34514,19 @@ var Vec4 = class Vec4 {
|
|
|
32695
34514
|
*
|
|
32696
34515
|
* The harness requires every key to be a namespaced `<package>/<Name>` type id
|
|
32697
34516
|
* (`scripts/lib/schema-source.ts` rejects a key with no `/`), and it groups entries onto a page by
|
|
32698
|
-
* their `format`. A *file* format is not a component and has no type id, so the
|
|
32699
|
-
* below are keyed `ignifx/scene-file`, `ignifx/material-file`,
|
|
32700
|
-
* declaring `format: "ignifx.scene"`, `"ignifx.material"`,
|
|
34517
|
+
* their `format`. A *file* format is not a component and has no type id, so the file formats
|
|
34518
|
+
* below are keyed `ignifx/scene-file`, `ignifx/material-file`, `ignifx/environment-file`, and
|
|
34519
|
+
* `ignifx/mesh-file` while declaring `format: "ignifx.scene"`, `"ignifx.material"`,
|
|
34520
|
+
* `"ignifx.environment"`, and `"ignifx.mesh"`. The wave-1
|
|
32701
34521
|
* hand-off asked for the key `"ignifx.scene"`; that key fails the namespacing check, and the
|
|
32702
34522
|
* grouping — which is what actually decides the page — comes from `format` either way.
|
|
34523
|
+
*
|
|
34524
|
+
* ## The transform
|
|
34525
|
+
*
|
|
34526
|
+
* `ignifx/Transform` is described like a component, from `transformSchema()`, though its class
|
|
34527
|
+
* declares no schema: it is the scene file's per-entity `transform` block. Its entry is the only one
|
|
34528
|
+
* that sets `builtIn` (with `allowMultiple: false` and `package: "@ignifx/core"`), so an editor
|
|
34529
|
+
* shows it with the components but never offers to add or remove it.
|
|
32703
34530
|
*/
|
|
32704
34531
|
/**
|
|
32705
34532
|
* Describes every component and file format this package declares, for the documentation harness.
|
|
@@ -32716,6 +34543,12 @@ var Vec4 = class Vec4 {
|
|
|
32716
34543
|
*/
|
|
32717
34544
|
function describeSchemas() {
|
|
32718
34545
|
return {
|
|
34546
|
+
"ignifx/Transform": describeSchema("ignifx/Transform", transformSchema(), {
|
|
34547
|
+
description: "The entity's local position, rotation, and scale; every entity has exactly one, stored as its transform block.",
|
|
34548
|
+
allowMultiple: false,
|
|
34549
|
+
package: "@ignifx/core",
|
|
34550
|
+
builtIn: true
|
|
34551
|
+
}),
|
|
32719
34552
|
"ignifx/Camera": describeSchema("ignifx/Camera", Camera.schema, { description: "The camera an entity renders the world through; the entity's transform is the view." }),
|
|
32720
34553
|
"ignifx/Light": describeSchema("ignifx/Light", Light.schema, { description: "A directional, point, spot, or hemispheric light, with optional shadow casting." }),
|
|
32721
34554
|
"ignifx/MeshRenderer": describeSchema("ignifx/MeshRenderer", MeshRenderer.schema, { description: "Draws one clone of a mesh asset with a material." }),
|
|
@@ -32725,7 +34558,8 @@ function describeSchemas() {
|
|
|
32725
34558
|
"ignifx/PostProcessStack": describeSchema("ignifx/PostProcessStack", PostProcessStack.schema, { description: "Bloom, SMAA, image processing, and custom .post.wgsl effects, inserted into the scene's frame graph." }),
|
|
32726
34559
|
"ignifx/scene-file": describeSceneFileFormat(),
|
|
32727
34560
|
"ignifx/material-file": describeMaterialFileFormat(),
|
|
32728
|
-
"ignifx/environment-file": describeEnvironmentFileFormat()
|
|
34561
|
+
"ignifx/environment-file": describeEnvironmentFileFormat(),
|
|
34562
|
+
"ignifx/mesh-file": describeMeshFileFormat()
|
|
32729
34563
|
};
|
|
32730
34564
|
}
|
|
32731
34565
|
/**
|
|
@@ -32987,6 +34821,48 @@ function describeEnvironmentFileFormat() {
|
|
|
32987
34821
|
}
|
|
32988
34822
|
};
|
|
32989
34823
|
}
|
|
34824
|
+
/**
|
|
34825
|
+
* Describes the `ignifx.mesh` file format (ADR-0029).
|
|
34826
|
+
*
|
|
34827
|
+
* @returns The description of the top-level file fields.
|
|
34828
|
+
*
|
|
34829
|
+
* @public
|
|
34830
|
+
*/
|
|
34831
|
+
function describeMeshFileFormat() {
|
|
34832
|
+
const optionsByPrimitive = MESH_PRIMITIVES.map((primitive) => `${primitive}: ${Object.keys(MESH_PRIMITIVE_OPTIONS[primitive]).join(", ")}`).join("; ");
|
|
34833
|
+
return {
|
|
34834
|
+
title: "Mesh file",
|
|
34835
|
+
format: MESH_FILE_FORMAT,
|
|
34836
|
+
description: "One primitive mesh and the options its MeshAsset factory takes, so a scene file can name it by address. glTF meshes load as models instead.",
|
|
34837
|
+
fields: {
|
|
34838
|
+
format: {
|
|
34839
|
+
kind: "str",
|
|
34840
|
+
default: MESH_FILE_FORMAT,
|
|
34841
|
+
description: `Always "${MESH_FILE_FORMAT}".`
|
|
34842
|
+
},
|
|
34843
|
+
formatVersion: {
|
|
34844
|
+
kind: "u32",
|
|
34845
|
+
default: 1,
|
|
34846
|
+
description: "The file format version; 1 before ignifx 1.0."
|
|
34847
|
+
},
|
|
34848
|
+
name: {
|
|
34849
|
+
kind: "str",
|
|
34850
|
+
default: "",
|
|
34851
|
+
description: "A name for diagnostics; empty uses the file's address."
|
|
34852
|
+
},
|
|
34853
|
+
primitive: {
|
|
34854
|
+
kind: "enum",
|
|
34855
|
+
default: "box",
|
|
34856
|
+
description: `The shape: ${MESH_PRIMITIVES.join(", ")}. Required; an unknown value is rejected with IGX-0507.`
|
|
34857
|
+
},
|
|
34858
|
+
options: {
|
|
34859
|
+
kind: "record",
|
|
34860
|
+
default: {},
|
|
34861
|
+
description: `The factory's options; omitted ones take its defaults. Lengths are metres, zero or more; counts are whole numbers, one or more; uvScale is two numbers. An unknown option or a bad value is IGX-0507. By primitive: ${optionsByPrimitive}.`
|
|
34862
|
+
}
|
|
34863
|
+
}
|
|
34864
|
+
};
|
|
34865
|
+
}
|
|
32990
34866
|
//#endregion
|
|
32991
34867
|
//#region src/serialization/serialize.ts
|
|
32992
34868
|
/**
|
|
@@ -33194,7 +35070,7 @@ function writeEntity(planned, references, report) {
|
|
|
33194
35070
|
const layerName = entity.world.layers.nameOf(entity.layer);
|
|
33195
35071
|
const origin = planned.origin;
|
|
33196
35072
|
const instance = origin === null ? null : writeInstance(entity, origin, references, report);
|
|
33197
|
-
const components = writeComponents(entity, references, report);
|
|
35073
|
+
const components = writeComponents(entity, references, report, origin?.instanced?.root?.components ?? null);
|
|
33198
35074
|
return {
|
|
33199
35075
|
uid: entity.uid,
|
|
33200
35076
|
name: entity.name,
|
|
@@ -33214,14 +35090,15 @@ function writeEntity(planned, references, report) {
|
|
|
33214
35090
|
* @param entity - The entity.
|
|
33215
35091
|
* @param references - How references resolve.
|
|
33216
35092
|
* @param report - Receives problems.
|
|
35093
|
+
* @param skip - The uids of components an instanced scene put on the entity, which are not written.
|
|
33217
35094
|
* @returns The records, in attach order.
|
|
33218
35095
|
*/
|
|
33219
|
-
function writeComponents(entity, references, report) {
|
|
35096
|
+
function writeComponents(entity, references, report, skip) {
|
|
33220
35097
|
const records = [];
|
|
33221
35098
|
const components = entity.components;
|
|
33222
35099
|
for (let index = 0; index < components.length; index += 1) {
|
|
33223
35100
|
const component = components[index];
|
|
33224
|
-
if (component === void 0 || component === entity.transform || component.isDestroyed) continue;
|
|
35101
|
+
if (component === void 0 || component === entity.transform || component.isDestroyed || skip?.has(component.uid) === true) continue;
|
|
33225
35102
|
if (component.world.registry.describe(component.constructor).typeId === null) {
|
|
33226
35103
|
report(CoreErrorCode.componentTypeIdMissing, `${component.constructor.name} on ${entity.name} has no typeId and cannot be written.`);
|
|
33227
35104
|
continue;
|
|
@@ -33275,7 +35152,7 @@ function writeTransform(transform) {
|
|
|
33275
35152
|
function writeInstance(root, origin, references, report) {
|
|
33276
35153
|
const link = origin.instanced;
|
|
33277
35154
|
if (link === null) return null;
|
|
33278
|
-
const overrides = computeOverrides(root, link
|
|
35155
|
+
const overrides = computeOverrides(root, link, references, report);
|
|
33279
35156
|
return {
|
|
33280
35157
|
scene: { $asset: link.address },
|
|
33281
35158
|
hash: link.scene.hash,
|
|
@@ -33291,23 +35168,37 @@ function writeInstance(root, origin, references, report) {
|
|
|
33291
35168
|
* a third file — so deep edits inside a nested prefab are not written back; `flatten: true` is the
|
|
33292
35169
|
* escape hatch.
|
|
33293
35170
|
*
|
|
35171
|
+
* An instance root that stands for its scene's single root is diffed against that root's record
|
|
35172
|
+
* too, but only for the components the scene put on it: its name, transform, and other entity
|
|
35173
|
+
* fields, and the components it gained, are the entry's own.
|
|
35174
|
+
*
|
|
33294
35175
|
* @param root - The instance root.
|
|
33295
|
-
* @param
|
|
35176
|
+
* @param link - Its link to the instanced scene.
|
|
33296
35177
|
* @param references - How references resolve.
|
|
33297
35178
|
* @param report - Receives problems.
|
|
33298
35179
|
* @returns The overrides, in a stable order: entity records in file order, then per entity its
|
|
33299
35180
|
* plain properties, then its components.
|
|
33300
35181
|
*/
|
|
33301
|
-
function computeOverrides(root,
|
|
35182
|
+
function computeOverrides(root, link, references, report) {
|
|
33302
35183
|
const current = /* @__PURE__ */ new Map();
|
|
35184
|
+
const single = link.root;
|
|
35185
|
+
if (single !== null) current.set(single.sourceUid, root);
|
|
33303
35186
|
collectDirectMembers(root, root, current);
|
|
33304
35187
|
const overrides = [];
|
|
33305
|
-
const source = scene.file.entities;
|
|
35188
|
+
const source = link.scene.file.entities;
|
|
33306
35189
|
for (let index = 0; index < source.length; index += 1) {
|
|
33307
35190
|
const record = source[index];
|
|
33308
35191
|
if (record === void 0) continue;
|
|
33309
35192
|
const entity = current.get(record.uid);
|
|
33310
35193
|
if (entity === void 0) continue;
|
|
35194
|
+
if (entity === root && single !== null) {
|
|
35195
|
+
diffComponents(entity, record, {
|
|
35196
|
+
sourceUids: single.componentSourceUids,
|
|
35197
|
+
from: single.components,
|
|
35198
|
+
inside: true
|
|
35199
|
+
}, overrides, references, report);
|
|
35200
|
+
continue;
|
|
35201
|
+
}
|
|
33311
35202
|
diffEntity(entity, record, overrides, references, report);
|
|
33312
35203
|
}
|
|
33313
35204
|
return overrides;
|
|
@@ -33364,7 +35255,13 @@ function diffEntity(entity, record, overrides, references, report) {
|
|
|
33364
35255
|
value: tags
|
|
33365
35256
|
});
|
|
33366
35257
|
diffTransform(entity, record, uid, overrides);
|
|
33367
|
-
|
|
35258
|
+
const origin = entityInternals(entity).origin;
|
|
35259
|
+
const nested = origin?.instanced?.root?.components ?? /* @__PURE__ */ new Set();
|
|
35260
|
+
diffComponents(entity, record, {
|
|
35261
|
+
sourceUids: origin?.componentSourceUids ?? /* @__PURE__ */ new Map(),
|
|
35262
|
+
from: nested,
|
|
35263
|
+
inside: false
|
|
35264
|
+
}, overrides, references, report);
|
|
33368
35265
|
}
|
|
33369
35266
|
/**
|
|
33370
35267
|
* Diffs an instanced entity's transform against its file record.
|
|
@@ -33395,21 +35292,24 @@ function diffTransform(entity, record, uid, overrides) {
|
|
|
33395
35292
|
*
|
|
33396
35293
|
* @param entity - The runtime entity.
|
|
33397
35294
|
* @param record - Its file record.
|
|
33398
|
-
* @param
|
|
35295
|
+
* @param diff - Which components to diff, and their record uids.
|
|
33399
35296
|
* @param overrides - Where patches are appended.
|
|
33400
35297
|
* @param references - How references resolve.
|
|
33401
35298
|
* @param report - Receives problems.
|
|
33402
35299
|
*/
|
|
33403
|
-
function diffComponents(entity, record,
|
|
33404
|
-
const
|
|
35300
|
+
function diffComponents(entity, record, diff, overrides, references, report) {
|
|
35301
|
+
const uid = record.uid;
|
|
35302
|
+
const sourceUids = diff.sourceUids;
|
|
33405
35303
|
const declared = record.components ?? [];
|
|
33406
35304
|
const seen = /* @__PURE__ */ new Set();
|
|
33407
35305
|
const components = entity.components;
|
|
33408
35306
|
for (let index = 0; index < components.length; index += 1) {
|
|
33409
35307
|
const component = components[index];
|
|
33410
35308
|
if (component === void 0 || component === entity.transform || component.isDestroyed) continue;
|
|
35309
|
+
if (diff.from.has(component.uid) !== diff.inside) continue;
|
|
33411
35310
|
if (component.world.registry.describe(component.constructor).typeId === null) continue;
|
|
33412
35311
|
const sourceUid = sourceUids.get(component.uid);
|
|
35312
|
+
if (sourceUid === void 0 && diff.inside) continue;
|
|
33413
35313
|
const written = serializeComponent(component, references, (issue) => {
|
|
33414
35314
|
report(issue.code, issue.message);
|
|
33415
35315
|
});
|
|
@@ -33562,15 +35462,113 @@ function sameNumbers(left, right) {
|
|
|
33562
35462
|
return true;
|
|
33563
35463
|
}
|
|
33564
35464
|
/**
|
|
33565
|
-
* Compares two JSON values structurally
|
|
33566
|
-
*
|
|
35465
|
+
* Compares two JSON values structurally, counting both spellings of one asset reference as equal.
|
|
35466
|
+
*
|
|
35467
|
+
* @remarks
|
|
35468
|
+
* One side is what the instanced file says, written by hand or by any tool; the other comes out of
|
|
35469
|
+
* the encoder. A file may leave out an asset reference's `type`, which the loader then infers from
|
|
35470
|
+
* the address, but the encoder always writes the type of the handle it holds. So
|
|
35471
|
+
* `{ "$asset": a }` and `{ "$asset": a, "type": t }` name the same asset; comparing them as text
|
|
35472
|
+
* would save every terse reference in an instanced prefab as an override.
|
|
33567
35473
|
*
|
|
33568
35474
|
* @param left - The first.
|
|
33569
35475
|
* @param right - The second.
|
|
33570
|
-
* @returns `true` when they
|
|
35476
|
+
* @returns `true` when they hold the same data.
|
|
33571
35477
|
*/
|
|
33572
35478
|
function sameJson(left, right) {
|
|
33573
|
-
|
|
35479
|
+
if (left === right) return true;
|
|
35480
|
+
const leftArray = asJsonArray(left);
|
|
35481
|
+
const rightArray = asJsonArray(right);
|
|
35482
|
+
if (leftArray !== null || rightArray !== null) {
|
|
35483
|
+
if (leftArray === null || rightArray === null || leftArray.length !== rightArray.length) return false;
|
|
35484
|
+
for (let index = 0; index < leftArray.length; index += 1) if (!sameJson(leftArray[index] ?? null, rightArray[index] ?? null)) return false;
|
|
35485
|
+
return true;
|
|
35486
|
+
}
|
|
35487
|
+
const leftObject = asJsonObject(left);
|
|
35488
|
+
const rightObject = asJsonObject(right);
|
|
35489
|
+
if (leftObject === null || rightObject === null) return false;
|
|
35490
|
+
if (typeof leftObject["$asset"] === "string" && typeof rightObject["$asset"] === "string") return sameAssetReference(leftObject, rightObject);
|
|
35491
|
+
const keys = Object.keys(leftObject);
|
|
35492
|
+
if (keys.length !== Object.keys(rightObject).length) return false;
|
|
35493
|
+
for (const key of keys) if (!Object.hasOwn(rightObject, key) || !sameJson(leftObject[key] ?? null, rightObject[key] ?? null)) return false;
|
|
35494
|
+
return true;
|
|
35495
|
+
}
|
|
35496
|
+
/**
|
|
35497
|
+
* Compares two `{ "$asset": … }` references: the same address, and the same type unless one side
|
|
35498
|
+
* leaves the type for the loader to infer.
|
|
35499
|
+
*
|
|
35500
|
+
* @param left - The first reference.
|
|
35501
|
+
* @param right - The second reference.
|
|
35502
|
+
* @returns `true` when they name the same asset.
|
|
35503
|
+
*/
|
|
35504
|
+
function sameAssetReference(left, right) {
|
|
35505
|
+
if (left["$asset"] !== right["$asset"]) return false;
|
|
35506
|
+
const leftType = left["type"];
|
|
35507
|
+
const rightType = right["type"];
|
|
35508
|
+
return leftType === void 0 || rightType === void 0 || leftType === rightType;
|
|
35509
|
+
}
|
|
35510
|
+
//#endregion
|
|
35511
|
+
//#region src/schema/describe-registry.ts
|
|
35512
|
+
/**
|
|
35513
|
+
* The package a registered component belongs to: the extension that registered it, or else the
|
|
35514
|
+
* namespace of its type id.
|
|
35515
|
+
*
|
|
35516
|
+
* @param registry - The registry the component is registered in.
|
|
35517
|
+
* @param typeId - The component's type id.
|
|
35518
|
+
* @returns The extension's `name` (`@ignifx/3d`), or everything before the type id's last `/`
|
|
35519
|
+
* (`mygame` for `mygame/Mover`) when no extension registered it.
|
|
35520
|
+
*
|
|
35521
|
+
* @internal
|
|
35522
|
+
*/
|
|
35523
|
+
function componentPackage(registry, typeId) {
|
|
35524
|
+
return registry.registrarOf(typeId) ?? typeId.slice(0, Math.max(0, typeId.lastIndexOf("/")));
|
|
35525
|
+
}
|
|
35526
|
+
/**
|
|
35527
|
+
* Describes every component an app has registered, the engine's, its extensions' and the game's,
|
|
35528
|
+
* the way {@link describeSchema} describes one, plus what only the registry knows: whether an
|
|
35529
|
+
* entity may hold more than one (`allowMultiple`) and which package registered it (`package`).
|
|
35530
|
+
* This is what an external inspector, such as the ignifx editor, is generated from.
|
|
35531
|
+
*
|
|
35532
|
+
* @remarks
|
|
35533
|
+
* `package` is the `name` of the extension whose `register(ctx)` registered the class, which is the
|
|
35534
|
+
* npm package name for a published extension (`@ignifx/core`, `@ignifx/3d`). A class the game
|
|
35535
|
+
* registered itself with `app.registerComponents` has no extension, so its `package` is its type
|
|
35536
|
+
* id's namespace: everything before the last `/` (`third-person` for `third-person/Beacon`).
|
|
35537
|
+
*
|
|
35538
|
+
* `ignifx/Transform` declares no schema on its class; it is described with {@link transformSchema}
|
|
35539
|
+
* and marked `builtIn`, because every entity carries exactly one and a scene file stores it as the
|
|
35540
|
+
* entity's `transform` block rather than in its `components`.
|
|
35541
|
+
*
|
|
35542
|
+
* @param registry - The registry to walk, usually `app.world.registry`.
|
|
35543
|
+
* @param curated - Titles, formats and summaries by type id, for example a package's own
|
|
35544
|
+
* `describeSchemas()`; a component without an entry is titled from its type id.
|
|
35545
|
+
* @returns The descriptions, keyed by type id, in registration order.
|
|
35546
|
+
*
|
|
35547
|
+
* @example
|
|
35548
|
+
* ```ts
|
|
35549
|
+
* const schemas = describeRegisteredSchemas(app.world.registry, describeSchemas());
|
|
35550
|
+
* schemas["ignifx/Camera"]?.package; // "@ignifx/core"
|
|
35551
|
+
* schemas["ignifx/Camera"]?.allowMultiple; // false
|
|
35552
|
+
* ```
|
|
35553
|
+
*
|
|
35554
|
+
* @public
|
|
35555
|
+
*/
|
|
35556
|
+
function describeRegisteredSchemas(registry, curated) {
|
|
35557
|
+
const described = {};
|
|
35558
|
+
for (const [typeId, type] of registry.registrations()) {
|
|
35559
|
+
const info = registry.describe(type);
|
|
35560
|
+
const meta = curated?.[typeId];
|
|
35561
|
+
const builtIn = type === Transform;
|
|
35562
|
+
described[typeId] = describeSchema(typeId, builtIn ? transformSchema() : info.schema ?? {}, {
|
|
35563
|
+
...meta?.title === void 0 ? {} : { title: meta.title },
|
|
35564
|
+
...meta?.format === void 0 ? {} : { format: meta.format },
|
|
35565
|
+
...meta?.description === void 0 ? {} : { description: meta.description },
|
|
35566
|
+
allowMultiple: info.allowMultiple,
|
|
35567
|
+
package: componentPackage(registry, typeId),
|
|
35568
|
+
...builtIn ? { builtIn } : {}
|
|
35569
|
+
});
|
|
35570
|
+
}
|
|
35571
|
+
return described;
|
|
33574
35572
|
}
|
|
33575
35573
|
//#endregion
|
|
33576
35574
|
//#region src/script/wait.ts
|
|
@@ -33678,6 +35676,443 @@ function waitWhile(predicate) {
|
|
|
33678
35676
|
});
|
|
33679
35677
|
}
|
|
33680
35678
|
//#endregion
|
|
33681
|
-
|
|
35679
|
+
//#region src/settings/settings-json.ts
|
|
35680
|
+
/**
|
|
35681
|
+
* The JSON form of project settings. Settings are read as written: `createApp` hands the project's
|
|
35682
|
+
* values to `validateProps` unencoded, so a `vec3` is `{ x, y, z }` and a `color` is
|
|
35683
|
+
* `{ r, g, b, a }`, not the scene file's arrays. Everything here describes that runtime form.
|
|
35684
|
+
*/
|
|
35685
|
+
/**
|
|
35686
|
+
* Reports whether a value is a plain bag of named values.
|
|
35687
|
+
*
|
|
35688
|
+
* @param value - The candidate.
|
|
35689
|
+
* @returns `true` for a non-null, non-array object.
|
|
35690
|
+
*/
|
|
35691
|
+
function isBag(value) {
|
|
35692
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
35693
|
+
}
|
|
35694
|
+
/**
|
|
35695
|
+
* Copies a value made of JSON data, dropping what JSON cannot carry.
|
|
35696
|
+
*
|
|
35697
|
+
* @param value - The value.
|
|
35698
|
+
* @returns The JSON copy, or `undefined` for a function, `undefined`, or a non-finite number.
|
|
35699
|
+
*/
|
|
35700
|
+
function plainJson(value) {
|
|
35701
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return value;
|
|
35702
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : void 0;
|
|
35703
|
+
if (Array.isArray(value)) return value.map((item) => plainJson(item) ?? null);
|
|
35704
|
+
if (isBag(value)) return entriesToJson(Object.entries(value), plainJson);
|
|
35705
|
+
}
|
|
35706
|
+
/**
|
|
35707
|
+
* Builds a JSON object from entries, leaving out the ones that convert to nothing.
|
|
35708
|
+
*
|
|
35709
|
+
* @param entries - The name and value pairs.
|
|
35710
|
+
* @param convert - How one value converts.
|
|
35711
|
+
* @returns The object.
|
|
35712
|
+
*/
|
|
35713
|
+
function entriesToJson(entries, convert) {
|
|
35714
|
+
const object = {};
|
|
35715
|
+
for (const [name, value] of entries) {
|
|
35716
|
+
const converted = convert(value, name);
|
|
35717
|
+
if (converted !== void 0) object[name] = converted;
|
|
35718
|
+
}
|
|
35719
|
+
return object;
|
|
35720
|
+
}
|
|
35721
|
+
/**
|
|
35722
|
+
* Converts a runtime settings value into the JSON a settings file holds for it.
|
|
35723
|
+
*
|
|
35724
|
+
* @param field - The field the value belongs to.
|
|
35725
|
+
* @param value - The runtime value, such as a registered default.
|
|
35726
|
+
* @returns The JSON form, or `undefined` when the value does not fit the field.
|
|
35727
|
+
*
|
|
35728
|
+
* @internal
|
|
35729
|
+
*/
|
|
35730
|
+
function settingsValueToJson(field, value) {
|
|
35731
|
+
const { spec } = field;
|
|
35732
|
+
switch (spec.kind) {
|
|
35733
|
+
case "vec2":
|
|
35734
|
+
case "vec3":
|
|
35735
|
+
case "vec4":
|
|
35736
|
+
case "quat": return isBag(value) ? entriesToJson(channelEntries(VECTOR_COMPONENTS.slice(0, spec.components), value), plainJson) : void 0;
|
|
35737
|
+
case "color": return isBag(value) ? entriesToJson(channelEntries(COLOR_CHANNELS, value), plainJson) : void 0;
|
|
35738
|
+
case "array": return Array.isArray(value) ? value.map((item) => settingsValueToJson(spec.item, item) ?? null) : void 0;
|
|
35739
|
+
case "record": {
|
|
35740
|
+
if (!isBag(value)) return;
|
|
35741
|
+
const object = {};
|
|
35742
|
+
for (const [name, sub] of Object.entries(spec.fields)) {
|
|
35743
|
+
const converted = settingsValueToJson(sub, value[name]);
|
|
35744
|
+
if (converted !== void 0) object[name] = converted;
|
|
35745
|
+
}
|
|
35746
|
+
return object;
|
|
35747
|
+
}
|
|
35748
|
+
case "map": return isBag(value) ? entriesToJson(Object.entries(value), (entry) => settingsValueToJson(spec.value, entry)) : void 0;
|
|
35749
|
+
case "optional": return value === null ? null : settingsValueToJson(spec.inner, value);
|
|
35750
|
+
case "entityRef":
|
|
35751
|
+
case "componentRef": return value === null ? null : void 0;
|
|
35752
|
+
case "asset":
|
|
35753
|
+
if (isBag(value) && typeof value["address"] === "string") return typeof value["type"] === "string" ? {
|
|
35754
|
+
address: value["address"],
|
|
35755
|
+
type: value["type"]
|
|
35756
|
+
} : { address: value["address"] };
|
|
35757
|
+
return value === null ? null : void 0;
|
|
35758
|
+
case "f32":
|
|
35759
|
+
case "f64":
|
|
35760
|
+
case "i32":
|
|
35761
|
+
case "u32":
|
|
35762
|
+
case "bool":
|
|
35763
|
+
case "str":
|
|
35764
|
+
case "enum":
|
|
35765
|
+
case "layerMask":
|
|
35766
|
+
case "curve":
|
|
35767
|
+
case "custom": return plainJson(value);
|
|
35768
|
+
default: return assertNever(spec, "schema field kind");
|
|
35769
|
+
}
|
|
35770
|
+
}
|
|
35771
|
+
/**
|
|
35772
|
+
* Pairs each channel name with the value's channel.
|
|
35773
|
+
*
|
|
35774
|
+
* @param names - The channel names.
|
|
35775
|
+
* @param value - The vector or colour.
|
|
35776
|
+
* @returns The pairs, in channel order.
|
|
35777
|
+
*/
|
|
35778
|
+
function channelEntries(names, value) {
|
|
35779
|
+
return names.map((name) => [name, value[name]]);
|
|
35780
|
+
}
|
|
35781
|
+
/**
|
|
35782
|
+
* The object schema of channel values, every channel required.
|
|
35783
|
+
*
|
|
35784
|
+
* @param names - The channel names.
|
|
35785
|
+
* @param channel - The schema of one channel.
|
|
35786
|
+
* @returns The fragment.
|
|
35787
|
+
*/
|
|
35788
|
+
function channelsSchema(names, channel) {
|
|
35789
|
+
return {
|
|
35790
|
+
type: "object",
|
|
35791
|
+
properties: Object.fromEntries(names.map((name) => [name, channel])),
|
|
35792
|
+
required: [...names]
|
|
35793
|
+
};
|
|
35794
|
+
}
|
|
35795
|
+
/**
|
|
35796
|
+
* Builds the JSON Schema of one settings field in the form `createApp` reads, with its default, its
|
|
35797
|
+
* tooltip, its bounds and the `x-ignifx-*` inspector keywords.
|
|
35798
|
+
*
|
|
35799
|
+
* @param field - The field.
|
|
35800
|
+
* @param defaultValue - The runtime default to annotate it with, or `undefined` for none.
|
|
35801
|
+
* @returns The fragment.
|
|
35802
|
+
*
|
|
35803
|
+
* @internal
|
|
35804
|
+
*/
|
|
35805
|
+
function settingsFieldJsonSchema(field, defaultValue) {
|
|
35806
|
+
const fragment = { ...settingsKindJsonSchema(field) };
|
|
35807
|
+
const { tooltip, min, max, step, hidden, readonly, group } = field.options;
|
|
35808
|
+
const annotations = {
|
|
35809
|
+
description: tooltip,
|
|
35810
|
+
minimum: min,
|
|
35811
|
+
maximum: max,
|
|
35812
|
+
"x-ignifx-step": step,
|
|
35813
|
+
"x-ignifx-hidden": hidden,
|
|
35814
|
+
"x-ignifx-readonly": readonly,
|
|
35815
|
+
"x-ignifx-group": group,
|
|
35816
|
+
default: defaultValue === void 0 ? void 0 : settingsValueToJson(field, defaultValue)
|
|
35817
|
+
};
|
|
35818
|
+
for (const [keyword, value] of Object.entries(annotations)) if (value !== void 0) fragment[keyword] = value;
|
|
35819
|
+
return fragment;
|
|
35820
|
+
}
|
|
35821
|
+
/**
|
|
35822
|
+
* Builds the object schema of a group of settings fields: every field optional, no other key.
|
|
35823
|
+
*
|
|
35824
|
+
* @param fields - The fields.
|
|
35825
|
+
* @param defaults - The runtime defaults by field name; a field without one carries no `default`.
|
|
35826
|
+
* @returns The fragment.
|
|
35827
|
+
*
|
|
35828
|
+
* @internal
|
|
35829
|
+
*/
|
|
35830
|
+
function settingsObjectJsonSchema(fields, defaults) {
|
|
35831
|
+
const properties = {};
|
|
35832
|
+
for (const [name, field] of Object.entries(fields)) properties[name] = settingsFieldJsonSchema(field, defaults[name]);
|
|
35833
|
+
return {
|
|
35834
|
+
type: "object",
|
|
35835
|
+
properties,
|
|
35836
|
+
additionalProperties: false
|
|
35837
|
+
};
|
|
35838
|
+
}
|
|
35839
|
+
/**
|
|
35840
|
+
* Builds the fragment that constrains a field's runtime form, mirroring `validateProps`.
|
|
35841
|
+
*
|
|
35842
|
+
* @param field - The field.
|
|
35843
|
+
* @returns The fragment, without annotations.
|
|
35844
|
+
*/
|
|
35845
|
+
function settingsKindJsonSchema(field) {
|
|
35846
|
+
const { spec } = field;
|
|
35847
|
+
switch (spec.kind) {
|
|
35848
|
+
case "f32":
|
|
35849
|
+
case "f64": return { type: "number" };
|
|
35850
|
+
case "i32": return {
|
|
35851
|
+
type: "integer",
|
|
35852
|
+
minimum: -2147483648,
|
|
35853
|
+
maximum: 2147483647
|
|
35854
|
+
};
|
|
35855
|
+
case "u32": return {
|
|
35856
|
+
type: "integer",
|
|
35857
|
+
minimum: 0,
|
|
35858
|
+
maximum: 4294967295
|
|
35859
|
+
};
|
|
35860
|
+
case "bool": return { type: "boolean" };
|
|
35861
|
+
case "str": return { type: "string" };
|
|
35862
|
+
case "enum": return {
|
|
35863
|
+
type: "string",
|
|
35864
|
+
enum: [...spec.values]
|
|
35865
|
+
};
|
|
35866
|
+
case "vec2":
|
|
35867
|
+
case "vec3":
|
|
35868
|
+
case "vec4":
|
|
35869
|
+
case "quat": return channelsSchema(VECTOR_COMPONENTS.slice(0, spec.components), { type: "number" });
|
|
35870
|
+
case "color": return channelsSchema(COLOR_CHANNELS, {
|
|
35871
|
+
type: "number",
|
|
35872
|
+
minimum: 0,
|
|
35873
|
+
maximum: 1
|
|
35874
|
+
});
|
|
35875
|
+
case "entityRef":
|
|
35876
|
+
case "componentRef": return { oneOf: [{ type: "object" }, { type: "null" }] };
|
|
35877
|
+
case "asset": return { oneOf: [{
|
|
35878
|
+
type: "object",
|
|
35879
|
+
properties: { address: { type: "string" } },
|
|
35880
|
+
required: ["address"]
|
|
35881
|
+
}, { type: "null" }] };
|
|
35882
|
+
case "array": return {
|
|
35883
|
+
type: "array",
|
|
35884
|
+
items: settingsFieldJsonSchema(spec.item, void 0)
|
|
35885
|
+
};
|
|
35886
|
+
case "record": return settingsObjectJsonSchema(spec.fields, {});
|
|
35887
|
+
case "map": return {
|
|
35888
|
+
type: "object",
|
|
35889
|
+
additionalProperties: settingsFieldJsonSchema(spec.value, void 0)
|
|
35890
|
+
};
|
|
35891
|
+
case "optional": return { anyOf: [settingsFieldJsonSchema(spec.inner, void 0), { type: "null" }] };
|
|
35892
|
+
case "layerMask": return {
|
|
35893
|
+
type: "array",
|
|
35894
|
+
items: { type: "string" }
|
|
35895
|
+
};
|
|
35896
|
+
case "curve": return {
|
|
35897
|
+
type: "object",
|
|
35898
|
+
properties: { keys: {
|
|
35899
|
+
type: "array",
|
|
35900
|
+
items: {
|
|
35901
|
+
type: "array",
|
|
35902
|
+
items: { type: "number" },
|
|
35903
|
+
minItems: 4,
|
|
35904
|
+
maxItems: 4
|
|
35905
|
+
}
|
|
35906
|
+
} },
|
|
35907
|
+
required: ["keys"]
|
|
35908
|
+
};
|
|
35909
|
+
case "custom": return {};
|
|
35910
|
+
default: return assertNever(spec, "schema field kind");
|
|
35911
|
+
}
|
|
35912
|
+
}
|
|
35913
|
+
//#endregion
|
|
35914
|
+
//#region src/settings/describe-settings.ts
|
|
35915
|
+
/**
|
|
35916
|
+
* The `format` every settings section description carries, so a consumer that merges settings and
|
|
35917
|
+
* component descriptions can tell them apart.
|
|
35918
|
+
*
|
|
35919
|
+
* @public
|
|
35920
|
+
*/
|
|
35921
|
+
const SETTINGS_DESCRIPTION_FORMAT = "settings";
|
|
35922
|
+
/**
|
|
35923
|
+
* Whether a single field of each kind may stand for its whole section: a one-field section may be
|
|
35924
|
+
* written as the field's value (`layers: ["Default"]`) only when that value cannot be mistaken for
|
|
35925
|
+
* the section's object form, so a kind whose runtime form may be an object (a vector or colour is
|
|
35926
|
+
* `{ x, y, z }` or `{ r, g, b, a }` in settings) never qualifies.
|
|
35927
|
+
*/
|
|
35928
|
+
const ALLOWS_SHORTHAND = {
|
|
35929
|
+
f32: true,
|
|
35930
|
+
f64: true,
|
|
35931
|
+
i32: true,
|
|
35932
|
+
u32: true,
|
|
35933
|
+
bool: true,
|
|
35934
|
+
str: true,
|
|
35935
|
+
vec2: false,
|
|
35936
|
+
vec3: false,
|
|
35937
|
+
vec4: false,
|
|
35938
|
+
quat: false,
|
|
35939
|
+
color: false,
|
|
35940
|
+
enum: true,
|
|
35941
|
+
array: true,
|
|
35942
|
+
layerMask: true,
|
|
35943
|
+
entityRef: false,
|
|
35944
|
+
componentRef: false,
|
|
35945
|
+
asset: false,
|
|
35946
|
+
record: false,
|
|
35947
|
+
map: false,
|
|
35948
|
+
optional: false,
|
|
35949
|
+
curve: false,
|
|
35950
|
+
custom: false
|
|
35951
|
+
};
|
|
35952
|
+
/**
|
|
35953
|
+
* Reaches the settings table behind `app.settings`.
|
|
35954
|
+
*
|
|
35955
|
+
* @param app - The app.
|
|
35956
|
+
* @returns The table.
|
|
35957
|
+
* @throws IgnifxError with code `IGX-0702` when the app was not created by this copy of core.
|
|
35958
|
+
*/
|
|
35959
|
+
function settingsStoreOf(app) {
|
|
35960
|
+
const { settings } = app;
|
|
35961
|
+
if (settings instanceof SettingsStore) return settings;
|
|
35962
|
+
throw new IgnifxError(CoreErrorCode.invalidRuntime, "app.settings was not created by this copy of @ignifx/core.", {
|
|
35963
|
+
context: { member: "app.settings" },
|
|
35964
|
+
hint: "Describe the settings of an app createApp returned."
|
|
35965
|
+
});
|
|
35966
|
+
}
|
|
35967
|
+
/**
|
|
35968
|
+
* Describes one section, with the defaults its owner registered rather than the schema's own field
|
|
35969
|
+
* defaults, because the registered bag is what the project gets for a value it omits.
|
|
35970
|
+
*
|
|
35971
|
+
* @param name - The section name.
|
|
35972
|
+
* @param section - The registered section.
|
|
35973
|
+
* @returns The description.
|
|
35974
|
+
*/
|
|
35975
|
+
function describeSection(name, section) {
|
|
35976
|
+
const described = describeSchema(name, section.schema, {
|
|
35977
|
+
title: name,
|
|
35978
|
+
format: SETTINGS_DESCRIPTION_FORMAT,
|
|
35979
|
+
package: section.owner
|
|
35980
|
+
});
|
|
35981
|
+
const fields = {};
|
|
35982
|
+
for (const [fieldName, field] of Object.entries(section.schema)) {
|
|
35983
|
+
const description = described.fields[fieldName];
|
|
35984
|
+
if (description !== void 0) fields[fieldName] = settingsFieldDescription(field, description, section.defaults[fieldName]);
|
|
35985
|
+
}
|
|
35986
|
+
return {
|
|
35987
|
+
...described,
|
|
35988
|
+
fields
|
|
35989
|
+
};
|
|
35990
|
+
}
|
|
35991
|
+
/**
|
|
35992
|
+
* Rewrites a field description's defaults, at every depth, into the runtime form settings are
|
|
35993
|
+
* written in: `{ x, y, z }` rather than the scene file's `[x, y, z]`.
|
|
35994
|
+
*
|
|
35995
|
+
* @param field - The field.
|
|
35996
|
+
* @param description - Its description, with defaults in the scene-file form.
|
|
35997
|
+
* @param value - The runtime default, or `undefined` to leave `default` off.
|
|
35998
|
+
* @returns The description in the settings form.
|
|
35999
|
+
*/
|
|
36000
|
+
function settingsFieldDescription(field, description, value) {
|
|
36001
|
+
const { default: _encoded, item, fields, value: entry, inner, ...rest } = description;
|
|
36002
|
+
const { spec } = field;
|
|
36003
|
+
const converted = value === void 0 ? void 0 : settingsValueToJson(field, value);
|
|
36004
|
+
const nested = {};
|
|
36005
|
+
if (spec.kind === "array" && item !== void 0) nested.item = settingsFieldDescription(spec.item, item, spec.item.createDefault());
|
|
36006
|
+
else if (spec.kind === "map" && entry !== void 0) nested.value = settingsFieldDescription(spec.value, entry, spec.value.createDefault());
|
|
36007
|
+
else if (spec.kind === "optional" && inner !== void 0) nested.inner = settingsFieldDescription(spec.inner, inner, spec.inner.createDefault());
|
|
36008
|
+
else if (spec.kind === "record" && fields !== void 0) {
|
|
36009
|
+
nested.fields = {};
|
|
36010
|
+
for (const [name, sub] of Object.entries(spec.fields)) {
|
|
36011
|
+
const subDescription = fields[name];
|
|
36012
|
+
if (subDescription !== void 0) nested.fields[name] = settingsFieldDescription(sub, subDescription, sub.createDefault());
|
|
36013
|
+
}
|
|
36014
|
+
}
|
|
36015
|
+
return {
|
|
36016
|
+
...rest,
|
|
36017
|
+
...converted === void 0 ? {} : { default: converted },
|
|
36018
|
+
...nested
|
|
36019
|
+
};
|
|
36020
|
+
}
|
|
36021
|
+
/**
|
|
36022
|
+
* Describes every project settings section an app has registered (core's own `layers`,
|
|
36023
|
+
* `sortingLayers`, `time`, `assets` and `rendering`, and every section an extension declared with
|
|
36024
|
+
* `ctx.registerSettings`) in the same shape {@link describeRegisteredSchemas} describes components.
|
|
36025
|
+
* This is what an external settings panel, such as the ignifx editor's, is generated from.
|
|
36026
|
+
*
|
|
36027
|
+
* @remarks
|
|
36028
|
+
* Each entry is keyed and titled by its section name, has `format: "settings"`
|
|
36029
|
+
* ({@link SETTINGS_DESCRIPTION_FORMAT}), and names the extension that registered it as `package`
|
|
36030
|
+
* (`@ignifx/core`, `@ignifx/physics`). A field's `default` is the value the owner registered for it,
|
|
36031
|
+
* which is what the project gets when it omits the field; a field the owner's defaults leave out has
|
|
36032
|
+
* no `default`, because the resolved section has no value for it either.
|
|
36033
|
+
*
|
|
36034
|
+
* Defaults are in the **settings form**, the form `createApp` reads, which differs from the scene
|
|
36035
|
+
* file's for vectors and colours: a `vec3` default is `{ "x": 0, "y": -9.81, "z": 0 }` and a `color`
|
|
36036
|
+
* default is `{ "r": 0, "g": 0, "b": 0, "a": 1 }`, not an array. A tool writes values back in this
|
|
36037
|
+
* form.
|
|
36038
|
+
*
|
|
36039
|
+
* The registration seam is `ctx.registerSettings(section, schema, defaults)`: an extension that
|
|
36040
|
+
* declares a section there is described here with no further work. A section is written in project
|
|
36041
|
+
* settings (`ignifx.settings.json` or `ignifx.config.ts`) as an object of these fields; a section
|
|
36042
|
+
* with exactly one field of a non-object kind (a number, string, enum or array, not a vector or
|
|
36043
|
+
* colour) may also be written as that field's value.
|
|
36044
|
+
*
|
|
36045
|
+
* @param app - The app whose sections to describe; its extensions have all registered by the time
|
|
36046
|
+
* `createApp` resolves.
|
|
36047
|
+
* @returns The descriptions, keyed by section name, in registration order.
|
|
36048
|
+
* @throws IgnifxError with code `IGX-0702` when `app` was not created by this copy of
|
|
36049
|
+
* `@ignifx/core`.
|
|
36050
|
+
*
|
|
36051
|
+
* @example
|
|
36052
|
+
* ```ts
|
|
36053
|
+
* const sections = describeSettings(app);
|
|
36054
|
+
* sections["time"]?.package; // "@ignifx/core"
|
|
36055
|
+
* sections["time"]?.fields["fixedDeltaTime"]?.default; // 0.016666666666666666
|
|
36056
|
+
* ```
|
|
36057
|
+
*
|
|
36058
|
+
* @public
|
|
36059
|
+
*/
|
|
36060
|
+
function describeSettings(app) {
|
|
36061
|
+
const described = {};
|
|
36062
|
+
for (const [name, section] of settingsStoreOf(app).registrations()) described[name] = describeSection(name, section);
|
|
36063
|
+
return described;
|
|
36064
|
+
}
|
|
36065
|
+
/**
|
|
36066
|
+
* The JSON Schema of one section as project settings may write it: the object form, or, for a
|
|
36067
|
+
* single field of a non-object kind, also that field's value on its own.
|
|
36068
|
+
*
|
|
36069
|
+
* @param section - The registered section.
|
|
36070
|
+
* @returns The fragment.
|
|
36071
|
+
*/
|
|
36072
|
+
function sectionJsonSchema(section) {
|
|
36073
|
+
const { schema, defaults } = section;
|
|
36074
|
+
const objectForm = settingsObjectJsonSchema(schema, defaults);
|
|
36075
|
+
const entries = Object.entries(schema);
|
|
36076
|
+
const [only] = entries;
|
|
36077
|
+
if (entries.length !== 1 || only === void 0 || !ALLOWS_SHORTHAND[only[1].kind]) return objectForm;
|
|
36078
|
+
return { oneOf: [objectForm, settingsFieldJsonSchema(only[1], defaults[only[0]])] };
|
|
36079
|
+
}
|
|
36080
|
+
/**
|
|
36081
|
+
* Generates the JSON Schema (draft 2020-12) of a project's settings object, the content of
|
|
36082
|
+
* `ignifx.settings.json`, from every section the app registered. Pass it to the Vite plugin as
|
|
36083
|
+
* `ignifx({ schemas: { settings } })` to validate the project settings at build time, or associate
|
|
36084
|
+
* it with `ignifx.settings.json` in a text editor.
|
|
36085
|
+
*
|
|
36086
|
+
* @remarks
|
|
36087
|
+
* The schema describes the settings form `createApp` reads (vectors as `{ x, y, z }`, colours as
|
|
36088
|
+
* `{ r, g, b, a }` with every channel required), so a document it accepts also passes `createApp`'s
|
|
36089
|
+
* own validation (`IGX-0408`). Every section is optional and a section omitted takes its defaults.
|
|
36090
|
+
* An unknown key inside a section is a violation. The top level stays open: a section this app did
|
|
36091
|
+
* not register, perhaps one of an extension it lacks, is left to `createApp`, which reports it
|
|
36092
|
+
* (`IGX-0407`), and to the Vite plugin, which warns about it.
|
|
36093
|
+
*
|
|
36094
|
+
* @param app - The app whose sections to describe.
|
|
36095
|
+
* @returns The object schema, one property per section.
|
|
36096
|
+
* @throws IgnifxError with code `IGX-0702` when `app` was not created by this copy of
|
|
36097
|
+
* `@ignifx/core`.
|
|
36098
|
+
*
|
|
36099
|
+
* @example
|
|
36100
|
+
* ```ts
|
|
36101
|
+
* const schema = settingsJsonSchema(app);
|
|
36102
|
+
* Object.keys(schema["properties"] ?? {}); // ["layers", "sortingLayers", "time", "assets", "rendering"]
|
|
36103
|
+
* ```
|
|
36104
|
+
*
|
|
36105
|
+
* @public
|
|
36106
|
+
*/
|
|
36107
|
+
function settingsJsonSchema(app) {
|
|
36108
|
+
const properties = {};
|
|
36109
|
+
for (const [name, section] of settingsStoreOf(app).registrations()) properties[name] = sectionJsonSchema(section);
|
|
36110
|
+
return {
|
|
36111
|
+
type: "object",
|
|
36112
|
+
properties
|
|
36113
|
+
};
|
|
36114
|
+
}
|
|
36115
|
+
//#endregion
|
|
36116
|
+
export { ASSET_DIAGNOSTICS_COUNTERS, ASSET_DIAGNOSTICS_GROUP, ASSET_MANIFEST_FORMAT, ASSET_MANIFEST_VERSION, AssetLoadError, CANVAS_ALPHA_MODES, CORE_ERROR_MESSAGES, Camera, Color, Component, ComponentRegistry, CoreErrorCode, DEFAULT_ASSET_CONCURRENCY, DEFAULT_ASSET_ROOT, DEFAULT_BRDF_LUT_ADDRESS, DEFAULT_LAYER, DEFAULT_MEMORY_SINK_LIMIT, DEFAULT_STORAGE_NAMESPACE, DEG_TO_RAD, Diagnostics, EASINGS, EASING_NAMES, EMPTY_ASSET_MANIFEST, ENVIRONMENT_ASSET_TYPE, ENVIRONMENT_FILE_EXTENSION, ENVIRONMENT_FILE_EXTENSIONS, ENVIRONMENT_FILE_FORMAT, ENVIRONMENT_FORMAT_VERSION, EPSILON, Entity, Environment, EnvironmentAsset, ErrorRange, FOG_MODE_NAMES, FONT_ASSET_TYPE, FONT_FILE_EXTENSIONS, FRAME_HISTORY_LENGTH, FieldKind, FontAsset, IGNIFX_UNIFORM_NAMES, INVALID_HANDLE, IgnifxError, IndexedDbStorageBackend, InstancedMeshRenderer, LIGHT_TYPES, LITE_MATERIAL_PLUGIN_POINTS, LITE_SYSTEM_UNIFORM_NAMES, LOG_LEVEL_SEVERITY, LayerMask, LayerTable, Light, LogLevel, MAT4_IDENTITY, MATERIAL_ALPHA_MODES, MATERIAL_ASSET_TYPE, MATERIAL_FILE_EXTENSION, MATERIAL_FILE_FORMAT, MATERIAL_FORMAT_VERSION, MATERIAL_KINDS, MATERIAL_PLUGIN_DEFAULT_PRIORITY, MATERIAL_PLUGIN_RESERVED_NAMES, MATERIAL_PLUGIN_SAMPLER_BUDGET, MAX_LAYERS, MAX_ULID_TIME_MS, MESH_ASSET_TYPE, MESH_FILE_EXTENSION, MESH_FILE_FORMAT, MESH_FORMAT_VERSION, MESH_PRIMITIVES, MESH_PRIMITIVE_OPTIONS, MODEL_ASSET_TYPE, MODEL_FILE_EXTENSIONS, Mat4, MaterialAsset, MemoryStorageBackend, MeshAsset, MeshRenderer, Model, ModelAsset, NAMESPACE_SEGMENT_MAX_LENGTH, PBR_TEXTURE_SLOTS, PHASES, PHASE_COUNT, PHASE_NAMES, POST_EFFECT_BUILTIN_UNIFORMS, POST_EFFECT_FUNCTION, PROJECTIONS, Phase, PhysicsCallbackName, PostProcessStack, QUAT_IDENTITY, Quat, RAD_TO_DEG, RENDERING_SETTINGS_SECTION, RENDER_DIAGNOSTICS_COUNTERS, RENDER_DIAGNOSTICS_GROUP, RESERVED_LAYER_NAMES, SCENE_ASSET_TYPE, SCENE_FILE_EXTENSIONS, SCENE_FILE_FORMAT, SCENE_FORMAT_VERSION, SETTINGS_DESCRIPTION_FORMAT, SHADER_ASSET_TYPE, SHADER_ATTRIBUTE_NAMES, SHADER_BLEND_MODES, SHADER_CULL_MODES, SHADER_FILE_EXTENSIONS, SHADER_INSTANCING_MODES, SHADER_KINDS, SHADER_TEXTURE_FALLBACKS, SHADER_UNIFORM_TYPES, SHADOW_TECHNIQUES, STANDARD_TEXTURE_SLOTS, STORAGE_BUFFER_ASSET_TYPE, STORAGE_KEY_MAX_LENGTH, SURFACE_HOOK_NAMES, SURFACE_UNIFORM_BLOCK, SceneAssetToken, SceneInstance, SchemaIssueCode, Script, ScriptCallbackKind, ShaderAsset, Signal, StorageBufferAsset, TEXTURE_ASSET_TYPE, THIRD_PARTY_ERROR_PREFIX, TONE_MAPPING_NAMES, TWEEN_LOOP_FOREVER, TWEEN_SYSTEM_ORDER, TWEEN_VALUE_KINDS, TagSet, TextureAsset, Transform, Tween, UidRemap, VEC2_ONE, VEC2_ZERO, VEC3_BACKWARD, VEC3_DOWN, VEC3_FORWARD, VEC3_LEFT, VEC3_ONE, VEC3_RIGHT, VEC3_UP, VEC3_ZERO, VERSION, Vec2, Vec3, Vec4, World, addComponentFromRecord, applyInit, approximately, array, assertNever, assertSceneDependenciesLoaded, asset, assetRef, binaryAssetLoader, bool, canonicalizeNumber, clamp, clamp01, color, componentRef, computeSceneHash, coreExtension, createApp, createAssetManifest, createConsoleSink, createCryptoRandom, createDefaults, createDiagnosticsGroup, createEnvironmentLoader, createErrorCodeRegistry, createFileStorageBackend, createFontLoader, createFrameSample, createLayerTable, createLogger, createManualClock, createMaterialAsset, createMaterialLoader, createMemorySink, createMeshLoader, createModelLoader, createPerformanceClock, createRay, createSceneAsset, createSceneLoader, createSeededRandom, createServiceKey, createShaderLoader, createStorageBufferAsset, createTextureLoader, createUlidFactory, curve, custom, customEffect, decodeProps, decodeValue, defaultRenderingSettings, defineExtension, defineMaterialPlugin, defineSchema, degToRad, deltaAngleDegrees, describeEnvironmentFileFormat, describeMaterialFileFormat, describeMeshFileFormat, describeRegisteredSchemas, describeSceneFileFormat, describeSchema, describeSchemas, describeSettings, encodeProps, encodeValue, entityRef, enumOf, environmentDefinition, f32, f64, forceRendererDeviceLossForTesting, formatErrorMessage, generateUlid, i32, instantiateScene, inverseLerp, isAssetRef, isIgnifxError, isLiteMaterialPluginPoint, isSceneFileHeader, isUlid, isValidErrorCode, isWebGpuAvailable, jsonAssetLoader, layerMask, lerp, lerpAngleDegrees, loadSceneDependencies, map, meshFileJsonSchema, moveTowards, optional, parseOverridePath, pbrMaterialDefinition, pingPong, platformInternals, quat, radToDeg, record, repeat, resetFrameSample, resolveEase, sceneFileJsonSchema, serializeComponent, serializeEntity, serializeScene, settingsJsonSchema, shaderMaterialDefinition, sign, smoothStep, standardMaterialDefinition, storageInternals, str, stringifySceneFile, textAssetLoader, toJsonSchema, transformSchema, u32, validateProps, validateSceneFile, validateValue, vec2, vec3, vec4, waitFixedUpdate, waitSeconds, waitSecondsRealtime, waitUntil, waitWhile, wrapAngleDegrees };
|
|
33682
36117
|
|
|
33683
36118
|
//# sourceMappingURL=index.js.map
|