@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
package/src/math/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
export * as num from "../num.js";
|
|
2
|
-
export * as vec2 from "../vec2.js";
|
|
3
|
-
export * as vec3 from "../vec3.js";
|
|
4
|
-
export * as vec4 from "../vec4.js";
|
|
5
|
-
export * as quat from "../quat.js";
|
|
6
|
-
export * as mat3 from "../mat3.js";
|
|
7
|
-
export * as mat4 from "../mat4.js";
|
|
8
|
-
|
|
9
|
-
export * as box3 from "../box3.js";
|
|
10
|
-
export * as tri3 from "../tri3.js";
|
|
11
|
-
export * as lne3 from "../lne3.js";
|
|
12
|
-
export * as pln from "../pln.js";
|
|
13
|
-
export * as ray3 from "../ray3.js";
|
|
14
|
-
export * as sph3 from "../sph3.js";
|
|
15
|
-
|
|
16
|
-
export * as pool from "../pool.js";
|
|
17
|
-
export * as noise from "../noise.js";
|
|
18
|
-
export * as curve from "../curve.js";
|
|
19
|
-
|
|
20
|
-
export * as geometry from "../geometry/index.js";
|
|
21
|
-
export * as vertex from "../vertex.js";
|
|
22
|
-
export * as mesh from "../mesh.js";
|
|
23
|
-
export * as tangent from "../tangent.js";
|
|
24
|
-
|
|
25
|
-
export * from "./scalar.js";
|
|
1
|
+
export * as num from "../num.js";
|
|
2
|
+
export * as vec2 from "../vec2.js";
|
|
3
|
+
export * as vec3 from "../vec3.js";
|
|
4
|
+
export * as vec4 from "../vec4.js";
|
|
5
|
+
export * as quat from "../quat.js";
|
|
6
|
+
export * as mat3 from "../mat3.js";
|
|
7
|
+
export * as mat4 from "../mat4.js";
|
|
8
|
+
|
|
9
|
+
export * as box3 from "../box3.js";
|
|
10
|
+
export * as tri3 from "../tri3.js";
|
|
11
|
+
export * as lne3 from "../lne3.js";
|
|
12
|
+
export * as pln from "../pln.js";
|
|
13
|
+
export * as ray3 from "../ray3.js";
|
|
14
|
+
export * as sph3 from "../sph3.js";
|
|
15
|
+
|
|
16
|
+
export * as pool from "../pool.js";
|
|
17
|
+
export * as noise from "../noise.js";
|
|
18
|
+
export * as curve from "../curve.js";
|
|
19
|
+
|
|
20
|
+
export * as geometry from "../geometry/index.js";
|
|
21
|
+
export * as vertex from "../vertex.js";
|
|
22
|
+
export * as mesh from "../mesh.js";
|
|
23
|
+
export * as tangent from "../tangent.js";
|
|
24
|
+
|
|
25
|
+
export * from "./scalar.js";
|
package/src/math/scalar.js
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
export {
|
|
2
|
-
EPSILON as defaultEpsilon,
|
|
3
|
-
TWO_PI as tau,
|
|
4
|
-
clamp,
|
|
5
|
-
cubicHermite,
|
|
6
|
-
cubicHermiteDerivative,
|
|
7
|
-
smoothStep,
|
|
8
|
-
smootherStep
|
|
9
|
-
} from "../num.js";
|
|
10
|
-
|
|
11
|
-
/** Restricts a value to the inclusive range from zero to one. */
|
|
12
|
-
export function saturate(value)
|
|
13
|
-
{
|
|
14
|
-
return Math.max(0, Math.min(1, value));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** Linearly interpolates without clamping the interpolation amount. */
|
|
18
|
-
export function lerp(start, end, amount)
|
|
19
|
-
{
|
|
20
|
-
return start + (end - start) * amount;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** Compares two numbers with an explicit relative tolerance. */
|
|
24
|
-
export function approximatelyEqual(a, b, epsilon = 1e-6)
|
|
25
|
-
{
|
|
26
|
-
if (epsilon < 0)
|
|
27
|
-
{
|
|
28
|
-
throw new RangeError("epsilon must be non-negative.");
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return Math.abs(a - b) <= epsilon * Math.max(1, Math.abs(a), Math.abs(b));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** Converts degrees to radians. */
|
|
35
|
-
export function degreesToRadians(degrees)
|
|
36
|
-
{
|
|
37
|
-
return degrees * Math.PI / 180;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** Converts radians to degrees. */
|
|
41
|
-
export function radiansToDegrees(radians)
|
|
42
|
-
{
|
|
43
|
-
return radians * 180 / Math.PI;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** Wraps degrees into the inclusive range from -180 to 180. */
|
|
47
|
-
export function wrapDegrees(degrees)
|
|
48
|
-
{
|
|
49
|
-
let wrapped = degrees % 360;
|
|
50
|
-
if (wrapped > 180) wrapped -= 360;
|
|
51
|
-
if (wrapped < -180) wrapped += 360;
|
|
52
|
-
return wrapped;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** Wraps radians into the inclusive range from -pi to pi. */
|
|
56
|
-
export function wrapRadians(radians)
|
|
57
|
-
{
|
|
58
|
-
const tau = Math.PI * 2;
|
|
59
|
-
let wrapped = radians % tau;
|
|
60
|
-
if (wrapped > Math.PI) wrapped -= tau;
|
|
61
|
-
if (wrapped < -Math.PI) wrapped += tau;
|
|
62
|
-
return wrapped;
|
|
63
|
-
}
|
|
1
|
+
export {
|
|
2
|
+
EPSILON as defaultEpsilon,
|
|
3
|
+
TWO_PI as tau,
|
|
4
|
+
clamp,
|
|
5
|
+
cubicHermite,
|
|
6
|
+
cubicHermiteDerivative,
|
|
7
|
+
smoothStep,
|
|
8
|
+
smootherStep
|
|
9
|
+
} from "../num.js";
|
|
10
|
+
|
|
11
|
+
/** Restricts a value to the inclusive range from zero to one. */
|
|
12
|
+
export function saturate(value)
|
|
13
|
+
{
|
|
14
|
+
return Math.max(0, Math.min(1, value));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Linearly interpolates without clamping the interpolation amount. */
|
|
18
|
+
export function lerp(start, end, amount)
|
|
19
|
+
{
|
|
20
|
+
return start + (end - start) * amount;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Compares two numbers with an explicit relative tolerance. */
|
|
24
|
+
export function approximatelyEqual(a, b, epsilon = 1e-6)
|
|
25
|
+
{
|
|
26
|
+
if (epsilon < 0)
|
|
27
|
+
{
|
|
28
|
+
throw new RangeError("epsilon must be non-negative.");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return Math.abs(a - b) <= epsilon * Math.max(1, Math.abs(a), Math.abs(b));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Converts degrees to radians. */
|
|
35
|
+
export function degreesToRadians(degrees)
|
|
36
|
+
{
|
|
37
|
+
return degrees * Math.PI / 180;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Converts radians to degrees. */
|
|
41
|
+
export function radiansToDegrees(radians)
|
|
42
|
+
{
|
|
43
|
+
return radians * 180 / Math.PI;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Wraps degrees into the inclusive range from -180 to 180. */
|
|
47
|
+
export function wrapDegrees(degrees)
|
|
48
|
+
{
|
|
49
|
+
let wrapped = degrees % 360;
|
|
50
|
+
if (wrapped > 180) wrapped -= 360;
|
|
51
|
+
if (wrapped < -180) wrapped += 360;
|
|
52
|
+
return wrapped;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Wraps radians into the inclusive range from -pi to pi. */
|
|
56
|
+
export function wrapRadians(radians)
|
|
57
|
+
{
|
|
58
|
+
const tau = Math.PI * 2;
|
|
59
|
+
let wrapped = radians % tau;
|
|
60
|
+
if (wrapped > Math.PI) wrapped -= tau;
|
|
61
|
+
if (wrapped < -Math.PI) wrapped += tau;
|
|
62
|
+
return wrapped;
|
|
63
|
+
}
|
package/src/media/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./mediaTypes.js";
|
|
1
|
+
export * from "./mediaTypes.js";
|
package/src/media/mediaTypes.js
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Canonical high-level media families used by format metadata and resources.
|
|
3
|
-
*/
|
|
4
|
-
export const MediaType = Object.freeze({
|
|
5
|
-
AUDIO: "audio",
|
|
6
|
-
DATA: "data",
|
|
7
|
-
GEOMETRY: "geometry",
|
|
8
|
-
IMAGE: "image",
|
|
9
|
-
SCHEMA: "schema",
|
|
10
|
-
SHADER: "shader",
|
|
11
|
-
TEXTURE: "texture",
|
|
12
|
-
VIDEO: "video"
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Canonical semantic payload roles emitted by format readers.
|
|
17
|
-
*/
|
|
18
|
-
export const PayloadType = Object.freeze({
|
|
19
|
-
AUDIO: "audio",
|
|
20
|
-
DATA: "data",
|
|
21
|
-
GEOMETRY: "geometry",
|
|
22
|
-
IMAGE: "image",
|
|
23
|
-
RAW: "raw",
|
|
24
|
-
SCHEMA: "schema",
|
|
25
|
-
SHADER: "shader",
|
|
26
|
-
TEXTURE: "texture",
|
|
27
|
-
VIDEO: "video"
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Normalize a media type token to lowercase canonical text.
|
|
32
|
-
*
|
|
33
|
-
* @param {string} value Input media type.
|
|
34
|
-
* @returns {string} Normalized media type.
|
|
35
|
-
*/
|
|
36
|
-
export function normalizeMediaType(value)
|
|
37
|
-
{
|
|
38
|
-
return value ? String(value).trim().toLowerCase() : "";
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Normalize a payload type token to lowercase canonical text.
|
|
43
|
-
*
|
|
44
|
-
* @param {string} value Input payload type.
|
|
45
|
-
* @returns {string} Normalized payload type.
|
|
46
|
-
*/
|
|
47
|
-
export function normalizePayloadType(value)
|
|
48
|
-
{
|
|
49
|
-
return value ? String(value).trim().toLowerCase() : "";
|
|
50
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Canonical high-level media families used by format metadata and resources.
|
|
3
|
+
*/
|
|
4
|
+
export const MediaType = Object.freeze({
|
|
5
|
+
AUDIO: "audio",
|
|
6
|
+
DATA: "data",
|
|
7
|
+
GEOMETRY: "geometry",
|
|
8
|
+
IMAGE: "image",
|
|
9
|
+
SCHEMA: "schema",
|
|
10
|
+
SHADER: "shader",
|
|
11
|
+
TEXTURE: "texture",
|
|
12
|
+
VIDEO: "video"
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Canonical semantic payload roles emitted by format readers.
|
|
17
|
+
*/
|
|
18
|
+
export const PayloadType = Object.freeze({
|
|
19
|
+
AUDIO: "audio",
|
|
20
|
+
DATA: "data",
|
|
21
|
+
GEOMETRY: "geometry",
|
|
22
|
+
IMAGE: "image",
|
|
23
|
+
RAW: "raw",
|
|
24
|
+
SCHEMA: "schema",
|
|
25
|
+
SHADER: "shader",
|
|
26
|
+
TEXTURE: "texture",
|
|
27
|
+
VIDEO: "video"
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Normalize a media type token to lowercase canonical text.
|
|
32
|
+
*
|
|
33
|
+
* @param {string} value Input media type.
|
|
34
|
+
* @returns {string} Normalized media type.
|
|
35
|
+
*/
|
|
36
|
+
export function normalizeMediaType(value)
|
|
37
|
+
{
|
|
38
|
+
return value ? String(value).trim().toLowerCase() : "";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Normalize a payload type token to lowercase canonical text.
|
|
43
|
+
*
|
|
44
|
+
* @param {string} value Input payload type.
|
|
45
|
+
* @returns {string} Normalized payload type.
|
|
46
|
+
*/
|
|
47
|
+
export function normalizePayloadType(value)
|
|
48
|
+
{
|
|
49
|
+
return value ? String(value).trim().toLowerCase() : "";
|
|
50
|
+
}
|