@carbonenginejs/runtime-utils 0.1.1 → 0.1.3
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/LICENSE +21 -21
- package/NOTICE +23 -23
- package/README.md +69 -69
- package/THIRD-PARTY-NOTICES.md +64 -64
- package/docs/README.md +74 -73
- package/docs/architecture.md +101 -101
- package/docs/concepts/foundation-consolidation.md +85 -85
- package/docs/concepts/model-lifecycle.md +111 -0
- package/docs/const-kb.md +85 -87
- package/docs/core-types/DECORATOR-TODOS.md +25 -25
- package/docs/core-types/README.md +229 -168
- package/docs/reference/api.md +105 -102
- package/docs/reference/classes/README.md +135 -135
- package/package.json +139 -139
- package/src/arrays.js +5 -5
- package/src/audio/audioFormats.js +34 -34
- package/src/audio/index.js +1 -1
- package/src/box3.js +331 -331
- package/src/bytes.js +56 -56
- package/src/compression.js +56 -56
- package/src/constants/index.js +7 -7
- package/src/constants/trinity.js +13 -13
- package/src/constants.js +15 -15
- package/src/curve.js +79 -79
- package/src/d3d/dxgiFormats.js +46 -46
- package/src/d3d/index.js +2 -2
- package/src/d3d/primitiveTopology.js +11 -11
- package/src/document/CjsCarbonDocument.js +212 -212
- package/src/document/CjsClassRegistry.js +373 -373
- package/src/document/CjsDocumentDehydrator.js +142 -142
- package/src/document/CjsDocumentHydrator.js +156 -156
- package/src/document/CjsStructRegistry.js +348 -348
- package/src/document/hydrationAdapter.js +129 -129
- package/src/document/index.js +6 -6
- package/src/errors/CjsError.js +286 -286
- package/src/errors/index.js +5 -5
- package/src/geometry/box.js +22 -22
- package/src/geometry/cylinder.js +22 -22
- package/src/geometry/helpers/earcut.js +1 -1
- package/src/geometry/helpers/misc.js +3 -3
- package/src/geometry/index.js +8 -8
- package/src/geometry/json.js +67 -67
- package/src/geometry/lathe.js +44 -44
- package/src/geometry/plane.js +14 -14
- package/src/geometry/shape.js +4 -4
- package/src/geometry/sphere.js +24 -24
- package/src/geometry/torus.js +14 -14
- package/src/graphics/colorSpaces.js +22 -22
- package/src/graphics/index.js +4 -4
- package/src/graphics/pixelFormats.js +158 -158
- package/src/graphics/textureDimensions.js +22 -22
- package/src/graphics/trinityEnums.js +87 -87
- package/src/index.js +62 -62
- package/src/is.js +108 -46
- package/src/json.js +23 -23
- package/src/lifecycle/CjsLifecycleState.js +77 -77
- package/src/lifecycle/index.js +1 -1
- package/src/lne3.js +70 -70
- package/src/lookup.js +48 -48
- package/src/mat3.js +51 -51
- package/src/mat4.js +699 -699
- package/src/math/index.js +25 -25
- package/src/math/scalar.js +63 -63
- package/src/media/index.js +1 -1
- package/src/media/mediaTypes.js +50 -50
- package/src/mesh.js +424 -424
- package/src/model/CjsEventEmitter.js +333 -333
- package/src/model/CjsModel.js +1589 -1544
- package/src/model/CjsModelState.js +72 -72
- package/src/model/index.js +4 -4
- package/src/model/sourceRecordUtils.js +54 -54
- package/src/noise.js +310 -310
- package/src/num.js +827 -827
- package/src/object.js +39 -39
- package/src/path.js +53 -53
- package/src/pln.js +125 -125
- package/src/pool.js +9 -9
- package/src/quat.js +144 -144
- package/src/ray3.js +188 -188
- package/src/renderContext/formats.js +145 -145
- package/src/renderContext/index.js +5 -5
- package/src/renderContext/presentation.js +125 -125
- package/src/renderContext/resources.js +27 -27
- package/src/renderContext/upscaling.js +22 -22
- package/src/renderContext/window.js +20 -20
- package/src/runtime/CjsRuntimeState.js +50 -50
- package/src/schema/CjsSchema.js +555 -318
- package/src/schema/index.js +4 -4
- package/src/shader/index.js +1 -1
- package/src/shader/shaderStages.js +37 -37
- package/src/sph3.js +181 -181
- package/src/tangent.js +288 -288
- package/src/text.js +40 -40
- package/src/tri3.js +98 -98
- package/src/types/carbonTypes.js +635 -635
- package/src/types/index.js +2 -2
- package/src/utils.js +58 -58
- package/src/validation.js +46 -46
- package/src/vec2.js +229 -229
- package/src/vec3.js +1188 -1172
- package/src/vec4.js +347 -347
- package/src/vertex.js +108 -108
- package/src/webgpu/index.js +1 -1
- package/src/webgpu/textureFormats.js +121 -121
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-model runtime state. One instance per model at `__state`.
|
|
3
|
-
*
|
|
4
|
-
* Ownership and clearing rules (kb section 8):
|
|
5
|
-
* - `dirty` is the only generically managed member: mutations mark it, and
|
|
6
|
-
* `UpdateValues` (the settle) is the only thing that clears it. The
|
|
7
|
-
* pipeline is cooperative - anything mutating outside `SetValues`
|
|
8
|
-
* (direct writes, Object.assign, reader adapters) owes a `MarkDirty()`
|
|
9
|
-
* or an explicit `UpdateValues()` ("I made changes, apply please").
|
|
10
|
-
* - `flags` holds lazy invalidations ("bounds is stale"). Written at
|
|
11
|
-
* mutation time from `@io.flag` field metadata or by class code; cleared
|
|
12
|
-
* ONLY by the getter that recomputes the derived value. Never
|
|
13
|
-
* auto-cleared - deferring until needed is their whole point.
|
|
14
|
-
* - `rebuild` holds scheduled work requirements ("vertices need
|
|
15
|
-
* rebuilding"). Written at mutation time from `@io.rebuild` field
|
|
16
|
-
* metadata or by class code; cleared ONLY by the specific work method
|
|
17
|
-
* that succeeds (e.g. RebuildVertices), typically driven from Update /
|
|
18
|
-
* per-frame passes. Never auto-cleared.
|
|
19
|
-
* - Future transient runtime state (lifecycle links, revision counters)
|
|
20
|
-
* lands here rather than growing new underscore properties.
|
|
21
|
-
*/
|
|
22
|
-
export class CjsModelState
|
|
23
|
-
{
|
|
24
|
-
|
|
25
|
-
/** Something changed; the next settle applies it. @type {boolean} */
|
|
26
|
-
dirty = false;
|
|
27
|
-
|
|
28
|
-
/** Lazy invalidations - consumers clear when they recompute. @type {Set<string>} */
|
|
29
|
-
flags = new Set();
|
|
30
|
-
|
|
31
|
-
/** Scheduled work requirements - work methods clear on success. @type {Set<string>} */
|
|
32
|
-
rebuild = new Set();
|
|
33
|
-
|
|
34
|
-
/** Settle re-entrancy guard. @type {boolean} */
|
|
35
|
-
updating = false;
|
|
36
|
-
|
|
37
|
-
/** Construction/teardown event gate (counted). @type {number} */
|
|
38
|
-
suppressEvents = 0;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Checks whether a settle is owed.
|
|
42
|
-
*
|
|
43
|
-
* @returns {boolean}
|
|
44
|
-
*/
|
|
45
|
-
IsDirty()
|
|
46
|
-
{
|
|
47
|
-
return this.dirty;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Marks the model as changed ("apply at the next settle").
|
|
52
|
-
*
|
|
53
|
-
* @returns {CjsModelState} This state.
|
|
54
|
-
*/
|
|
55
|
-
MarkDirty()
|
|
56
|
-
{
|
|
57
|
-
this.dirty = true;
|
|
58
|
-
return this;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Clears the dirty mark. The settle calls this; class code rarely should.
|
|
63
|
-
*
|
|
64
|
-
* @returns {CjsModelState} This state.
|
|
65
|
-
*/
|
|
66
|
-
ClearDirty()
|
|
67
|
-
{
|
|
68
|
-
this.dirty = false;
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Per-model runtime state. One instance per model at `__state`.
|
|
3
|
+
*
|
|
4
|
+
* Ownership and clearing rules (kb section 8):
|
|
5
|
+
* - `dirty` is the only generically managed member: mutations mark it, and
|
|
6
|
+
* `UpdateValues` (the settle) is the only thing that clears it. The
|
|
7
|
+
* pipeline is cooperative - anything mutating outside `SetValues`
|
|
8
|
+
* (direct writes, Object.assign, reader adapters) owes a `MarkDirty()`
|
|
9
|
+
* or an explicit `UpdateValues()` ("I made changes, apply please").
|
|
10
|
+
* - `flags` holds lazy invalidations ("bounds is stale"). Written at
|
|
11
|
+
* mutation time from `@io.flag` field metadata or by class code; cleared
|
|
12
|
+
* ONLY by the getter that recomputes the derived value. Never
|
|
13
|
+
* auto-cleared - deferring until needed is their whole point.
|
|
14
|
+
* - `rebuild` holds scheduled work requirements ("vertices need
|
|
15
|
+
* rebuilding"). Written at mutation time from `@io.rebuild` field
|
|
16
|
+
* metadata or by class code; cleared ONLY by the specific work method
|
|
17
|
+
* that succeeds (e.g. RebuildVertices), typically driven from Update /
|
|
18
|
+
* per-frame passes. Never auto-cleared.
|
|
19
|
+
* - Future transient runtime state (lifecycle links, revision counters)
|
|
20
|
+
* lands here rather than growing new underscore properties.
|
|
21
|
+
*/
|
|
22
|
+
export class CjsModelState
|
|
23
|
+
{
|
|
24
|
+
|
|
25
|
+
/** Something changed; the next settle applies it. @type {boolean} */
|
|
26
|
+
dirty = false;
|
|
27
|
+
|
|
28
|
+
/** Lazy invalidations - consumers clear when they recompute. @type {Set<string>} */
|
|
29
|
+
flags = new Set();
|
|
30
|
+
|
|
31
|
+
/** Scheduled work requirements - work methods clear on success. @type {Set<string>} */
|
|
32
|
+
rebuild = new Set();
|
|
33
|
+
|
|
34
|
+
/** Settle re-entrancy guard. @type {boolean} */
|
|
35
|
+
updating = false;
|
|
36
|
+
|
|
37
|
+
/** Construction/teardown event gate (counted). @type {number} */
|
|
38
|
+
suppressEvents = 0;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Checks whether a settle is owed.
|
|
42
|
+
*
|
|
43
|
+
* @returns {boolean}
|
|
44
|
+
*/
|
|
45
|
+
IsDirty()
|
|
46
|
+
{
|
|
47
|
+
return this.dirty;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Marks the model as changed ("apply at the next settle").
|
|
52
|
+
*
|
|
53
|
+
* @returns {CjsModelState} This state.
|
|
54
|
+
*/
|
|
55
|
+
MarkDirty()
|
|
56
|
+
{
|
|
57
|
+
this.dirty = true;
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Clears the dirty mark. The settle calls this; class code rarely should.
|
|
63
|
+
*
|
|
64
|
+
* @returns {CjsModelState} This state.
|
|
65
|
+
*/
|
|
66
|
+
ClearDirty()
|
|
67
|
+
{
|
|
68
|
+
this.dirty = false;
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
}
|
package/src/model/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./CjsModel.js";
|
|
2
|
-
export { CjsModelState } from "./CjsModelState.js";
|
|
3
|
-
export { CjsEventEmitter } from "./CjsEventEmitter.js";
|
|
4
|
-
export * from "./sourceRecordUtils.js";
|
|
1
|
+
export * from "./CjsModel.js";
|
|
2
|
+
export { CjsModelState } from "./CjsModelState.js";
|
|
3
|
+
export { CjsEventEmitter } from "./CjsEventEmitter.js";
|
|
4
|
+
export * from "./sourceRecordUtils.js";
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { CjsModel } from "./CjsModel.js";
|
|
2
|
-
|
|
3
|
-
export function asArray(value)
|
|
4
|
-
{
|
|
5
|
-
if (!value) return [];
|
|
6
|
-
if (value instanceof Map) return Array.from(value.values());
|
|
7
|
-
return Array.isArray(value) ? value : [value];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function firstDefined(...values)
|
|
11
|
-
{
|
|
12
|
-
for (const value of values)
|
|
13
|
-
{
|
|
14
|
-
if (value !== undefined && value !== null) return value;
|
|
15
|
-
}
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function getField(object, ...names)
|
|
20
|
-
{
|
|
21
|
-
if (!object) return null;
|
|
22
|
-
for (const name of names)
|
|
23
|
-
{
|
|
24
|
-
if (Object.prototype.hasOwnProperty.call(object, name)) return object[name];
|
|
25
|
-
}
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function objectFromMap(map)
|
|
30
|
-
{
|
|
31
|
-
return Object.fromEntries(map.entries());
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function collectionValues(value)
|
|
35
|
-
{
|
|
36
|
-
if (!value) return [];
|
|
37
|
-
if (value instanceof Map) return Array.from(value.values());
|
|
38
|
-
if (Array.isArray(value)) return value;
|
|
39
|
-
if (typeof value === "object") return Object.values(value);
|
|
40
|
-
return [value];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function clonePlain(value)
|
|
44
|
-
{
|
|
45
|
-
if (value instanceof CjsModel) return value.GetValues();
|
|
46
|
-
if (ArrayBuffer.isView(value)) return Array.from(value);
|
|
47
|
-
if (value instanceof Map) return new Map(Array.from(value.entries()).map(([key, item]) => [key, clonePlain(item)]));
|
|
48
|
-
if (Array.isArray(value)) return value.map(clonePlain);
|
|
49
|
-
if (value && typeof value === "object")
|
|
50
|
-
{
|
|
51
|
-
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, clonePlain(item)]));
|
|
52
|
-
}
|
|
53
|
-
return value;
|
|
54
|
-
}
|
|
1
|
+
import { CjsModel } from "./CjsModel.js";
|
|
2
|
+
|
|
3
|
+
export function asArray(value)
|
|
4
|
+
{
|
|
5
|
+
if (!value) return [];
|
|
6
|
+
if (value instanceof Map) return Array.from(value.values());
|
|
7
|
+
return Array.isArray(value) ? value : [value];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function firstDefined(...values)
|
|
11
|
+
{
|
|
12
|
+
for (const value of values)
|
|
13
|
+
{
|
|
14
|
+
if (value !== undefined && value !== null) return value;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getField(object, ...names)
|
|
20
|
+
{
|
|
21
|
+
if (!object) return null;
|
|
22
|
+
for (const name of names)
|
|
23
|
+
{
|
|
24
|
+
if (Object.prototype.hasOwnProperty.call(object, name)) return object[name];
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function objectFromMap(map)
|
|
30
|
+
{
|
|
31
|
+
return Object.fromEntries(map.entries());
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function collectionValues(value)
|
|
35
|
+
{
|
|
36
|
+
if (!value) return [];
|
|
37
|
+
if (value instanceof Map) return Array.from(value.values());
|
|
38
|
+
if (Array.isArray(value)) return value;
|
|
39
|
+
if (typeof value === "object") return Object.values(value);
|
|
40
|
+
return [value];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function clonePlain(value)
|
|
44
|
+
{
|
|
45
|
+
if (value instanceof CjsModel) return value.GetValues();
|
|
46
|
+
if (ArrayBuffer.isView(value)) return Array.from(value);
|
|
47
|
+
if (value instanceof Map) return new Map(Array.from(value.entries()).map(([key, item]) => [key, clonePlain(item)]));
|
|
48
|
+
if (Array.isArray(value)) return value.map(clonePlain);
|
|
49
|
+
if (value && typeof value === "object")
|
|
50
|
+
{
|
|
51
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, clonePlain(item)]));
|
|
52
|
+
}
|
|
53
|
+
return value;
|
|
54
|
+
}
|