@adobe/data 0.5.14 → 0.5.16
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/dist/ecs/entity/entity.d.ts +8 -0
- package/dist/ecs/entity/entity.js +3 -0
- package/dist/ecs/entity/entity.js.map +1 -0
- package/dist/ecs/entity/u32.d.ts +8 -0
- package/dist/{lit/elements/service-context.js → ecs/entity/u32.js} +3 -3
- package/dist/ecs/entity/u32.js.map +1 -0
- package/dist/graphics/frame.d.ts +1 -22
- package/dist/graphics/frame.js +14 -11
- package/dist/graphics/frame.js.map +1 -1
- package/dist/graphics/get-web-gpu-device-and-context.d.ts +1 -2
- package/dist/graphics/get-web-gpu-device-and-context.js +23 -20
- package/dist/graphics/get-web-gpu-device-and-context.js.map +1 -1
- package/dist/graphics/graphics-context.d.ts +1 -5
- package/dist/graphics/graphics-context.js +5 -0
- package/dist/graphics/graphics-context.js.map +1 -1
- package/dist/math/aabb/aabb.d.ts +42 -42
- package/dist/math/aabb/aabb.js +65 -62
- package/dist/math/aabb/aabb.js.map +1 -1
- package/dist/math/aabb-face/aabb-face.d.ts +59 -0
- package/dist/math/aabb-face/aabb-face.js +145 -0
- package/dist/math/aabb-face/aabb-face.js.map +1 -0
- package/dist/math/aabb-face/aabb-face.test.d.ts +1 -0
- package/dist/math/aabb-face/aabb-face.test.js +54 -0
- package/dist/math/aabb-face/aabb-face.test.js.map +1 -0
- package/dist/math/aabb-face/face.d.ts +51 -0
- package/dist/math/aabb-face/face.js +110 -0
- package/dist/math/aabb-face/face.js.map +1 -0
- package/dist/math/aabb-face/face.test.d.ts +1 -0
- package/dist/math/aabb-face/face.test.js +94 -0
- package/dist/math/aabb-face/face.test.js.map +1 -0
- package/dist/math/box/box.d.ts +50 -0
- package/dist/math/box/box.js +23 -0
- package/dist/math/box/box.js.map +1 -0
- package/dist/math/f32/f32.d.ts +8 -6
- package/dist/math/f32/f32.js +4 -1
- package/dist/math/f32/f32.js.map +1 -1
- package/dist/math/face/face.d.ts +51 -0
- package/dist/math/face/face.js +110 -0
- package/dist/math/face/face.js.map +1 -0
- package/dist/math/face/face.test.d.ts +1 -0
- package/dist/math/face/face.test.js +94 -0
- package/dist/math/face/face.test.js.map +1 -0
- package/dist/math/i32/i32.d.ts +9 -6
- package/dist/math/i32/i32.js +5 -2
- package/dist/math/i32/i32.js.map +1 -1
- package/dist/math/index.d.ts +13 -22
- package/dist/math/index.js +13 -22
- package/dist/math/index.js.map +1 -1
- package/dist/math/line2/line2.d.ts +36 -36
- package/dist/math/line2/line2.js +55 -52
- package/dist/math/line2/line2.js.map +1 -1
- package/dist/math/line3/line3.d.ts +48 -43
- package/dist/math/line3/line3.js +64 -52
- package/dist/math/line3/line3.js.map +1 -1
- package/dist/math/mat4x4/mat4x4.d.ts +34 -34
- package/dist/math/mat4x4/mat4x4.js +216 -213
- package/dist/math/mat4x4/mat4x4.js.map +1 -1
- package/dist/math/picking/face.d.ts +1 -0
- package/dist/math/picking/face.js +2 -0
- package/dist/math/picking/face.js.map +1 -0
- package/dist/math/picking/get-closest-entity-to-line.d.ts +4 -0
- package/dist/math/picking/get-closest-entity-to-line.js +30 -0
- package/dist/math/picking/get-closest-entity-to-line.js.map +1 -0
- package/dist/math/picking/get-closest-entity-to-point.d.ts +4 -0
- package/dist/math/picking/get-closest-entity-to-point.js +27 -0
- package/dist/math/picking/get-closest-entity-to-point.js.map +1 -0
- package/dist/math/picking/get-intersecting-entities.d.ts +12 -0
- package/dist/math/picking/get-intersecting-entities.js +15 -0
- package/dist/math/picking/get-intersecting-entities.js.map +1 -0
- package/dist/math/picking/getClosestEntityToLine.d.ts +4 -0
- package/dist/math/picking/getClosestEntityToLine.js +29 -0
- package/dist/math/picking/getClosestEntityToLine.js.map +1 -0
- package/dist/math/picking/getClosestEntityToPoint.d.ts +4 -0
- package/dist/math/picking/getClosestEntityToPoint.js +27 -0
- package/dist/math/picking/getClosestEntityToPoint.js.map +1 -0
- package/dist/math/picking/getIntersectingEntities.d.ts +12 -0
- package/dist/math/picking/getIntersectingEntities.js +15 -0
- package/dist/math/picking/getIntersectingEntities.js.map +1 -0
- package/dist/math/picking/index.d.ts +4 -0
- package/dist/math/picking/index.js +4 -0
- package/dist/math/picking/index.js.map +1 -1
- package/dist/math/picking/pick-from-tables.d.ts +1 -0
- package/dist/math/picking/pick-from-tables.js +7 -98
- package/dist/math/picking/pick-from-tables.js.map +1 -1
- package/dist/math/picking/pick-result.d.ts +5 -2
- package/dist/math/plane/plane.d.ts +43 -0
- package/dist/math/plane/plane.js +70 -0
- package/dist/math/plane/plane.js.map +1 -0
- package/dist/math/plane/plane.test.d.ts +1 -0
- package/dist/math/plane/plane.test.js +132 -0
- package/dist/math/plane/plane.test.js.map +1 -0
- package/dist/math/quat/quat.d.ts +49 -39
- package/dist/math/quat/quat.js +225 -185
- package/dist/math/quat/quat.js.map +1 -1
- package/dist/math/u32/u32.d.ts +9 -7
- package/dist/math/u32/u32.js +4 -1
- package/dist/math/u32/u32.js.map +1 -1
- package/dist/math/vec2/vec2.d.ts +61 -61
- package/dist/math/vec2/vec2.js +93 -90
- package/dist/math/vec2/vec2.js.map +1 -1
- package/dist/math/vec3/vec3.d.ts +66 -63
- package/dist/math/vec3/vec3.js +137 -129
- package/dist/math/vec3/vec3.js.map +1 -1
- package/dist/math/vec4/vec4.d.ts +61 -61
- package/dist/math/vec4/vec4.js +132 -129
- package/dist/math/vec4/vec4.js.map +1 -1
- package/dist/observe/to-async-generator.js +4 -4
- package/dist/observe/to-async-generator.js.map +1 -1
- package/dist/old-ecs/action-ecs/action-ecs.test.js +1 -1
- package/dist/old-ecs/action-ecs/action-ecs.test.js.map +1 -1
- package/dist/old-ecs/action-ecs/action-types.d.ts +7 -0
- package/dist/old-ecs/action-ecs/action-types.js.map +1 -1
- package/dist/old-ecs/ecs/ecs-types.d.ts +7 -0
- package/dist/old-ecs/ecs/ecs.test.js +1 -1
- package/dist/old-ecs/ecs/ecs.test.js.map +1 -1
- package/dist/old-ecs/transaction-ecs/transaction-ecs.test.js +1 -1
- package/dist/old-ecs/transaction-ecs/transaction-ecs.test.js.map +1 -1
- package/dist/old-ecs/transaction-ecs/transaction-types.d.ts +7 -0
- package/dist/samples/todo/services/state-service/create-todo-database.d.ts +2 -2
- package/dist/samples/todo/services/state-service/create-todo-store.d.ts +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -3
- package/dist/lit/elements/service-application.d.ts +0 -9
- package/dist/lit/elements/service-application.js +0 -55
- package/dist/lit/elements/service-application.js.map +0 -1
- package/dist/lit/elements/service-context.d.ts +0 -1
- package/dist/lit/elements/service-context.js.map +0 -1
- package/dist/lit/elements/service-element.d.ts +0 -6
- package/dist/lit/elements/service-element.js +0 -43
- package/dist/lit/elements/service-element.js.map +0 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/*MIT License
|
|
2
|
+
|
|
3
|
+
© Copyright 2025 Adobe. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.*/
|
|
22
|
+
import { describe, it, expect } from 'vitest';
|
|
23
|
+
import * as Face from './face.js';
|
|
24
|
+
describe('Face', () => {
|
|
25
|
+
it('should have correct constants', () => {
|
|
26
|
+
expect(Face.POS_Z).toBe(0);
|
|
27
|
+
expect(Face.POS_X).toBe(1);
|
|
28
|
+
expect(Face.NEG_Z).toBe(2);
|
|
29
|
+
expect(Face.NEG_X).toBe(3);
|
|
30
|
+
expect(Face.POS_Y).toBe(4);
|
|
31
|
+
expect(Face.NEG_Y).toBe(5);
|
|
32
|
+
});
|
|
33
|
+
it('should get correct face names', () => {
|
|
34
|
+
expect(Face.getName(Face.POS_Z)).toBe('POS_Z');
|
|
35
|
+
expect(Face.getName(Face.POS_X)).toBe('POS_X');
|
|
36
|
+
expect(Face.getName(Face.NEG_Z)).toBe('NEG_Z');
|
|
37
|
+
expect(Face.getName(Face.NEG_X)).toBe('NEG_X');
|
|
38
|
+
expect(Face.getName(Face.POS_Y)).toBe('POS_Y');
|
|
39
|
+
expect(Face.getName(Face.NEG_Y)).toBe('NEG_Y');
|
|
40
|
+
});
|
|
41
|
+
it('should get correct normal vectors', () => {
|
|
42
|
+
expect(Face.getNormal(Face.POS_Z)).toEqual([0, 0, 1]);
|
|
43
|
+
expect(Face.getNormal(Face.NEG_Z)).toEqual([0, 0, -1]);
|
|
44
|
+
expect(Face.getNormal(Face.POS_X)).toEqual([1, 0, 0]);
|
|
45
|
+
expect(Face.getNormal(Face.NEG_X)).toEqual([-1, 0, 0]);
|
|
46
|
+
expect(Face.getNormal(Face.POS_Y)).toEqual([0, 1, 0]);
|
|
47
|
+
expect(Face.getNormal(Face.NEG_Y)).toEqual([0, -1, 0]);
|
|
48
|
+
});
|
|
49
|
+
it('should get correct opposite faces', () => {
|
|
50
|
+
expect(Face.getOpposite(Face.POS_Z)).toBe(Face.NEG_Z);
|
|
51
|
+
expect(Face.getOpposite(Face.NEG_Z)).toBe(Face.POS_Z);
|
|
52
|
+
expect(Face.getOpposite(Face.POS_X)).toBe(Face.NEG_X);
|
|
53
|
+
expect(Face.getOpposite(Face.NEG_X)).toBe(Face.POS_X);
|
|
54
|
+
expect(Face.getOpposite(Face.POS_Y)).toBe(Face.NEG_Y);
|
|
55
|
+
expect(Face.getOpposite(Face.NEG_Y)).toBe(Face.POS_Y);
|
|
56
|
+
});
|
|
57
|
+
it('should correctly identify opposite faces', () => {
|
|
58
|
+
expect(Face.isOpposite(Face.POS_Z, Face.NEG_Z)).toBe(true);
|
|
59
|
+
expect(Face.isOpposite(Face.POS_X, Face.NEG_X)).toBe(true);
|
|
60
|
+
expect(Face.isOpposite(Face.POS_Y, Face.NEG_Y)).toBe(true);
|
|
61
|
+
expect(Face.isOpposite(Face.POS_Z, Face.POS_X)).toBe(false);
|
|
62
|
+
expect(Face.isOpposite(Face.POS_Z, Face.POS_Z)).toBe(false);
|
|
63
|
+
});
|
|
64
|
+
it('should get correct adjacent faces', () => {
|
|
65
|
+
const posZAdjacent = Face.getAdjacent(Face.POS_Z);
|
|
66
|
+
expect(posZAdjacent).toContain(Face.POS_X);
|
|
67
|
+
expect(posZAdjacent).toContain(Face.NEG_X);
|
|
68
|
+
expect(posZAdjacent).toContain(Face.POS_Y);
|
|
69
|
+
expect(posZAdjacent).toContain(Face.NEG_Y);
|
|
70
|
+
expect(posZAdjacent).not.toContain(Face.NEG_Z);
|
|
71
|
+
expect(posZAdjacent).not.toContain(Face.POS_Z);
|
|
72
|
+
const posXAdjacent = Face.getAdjacent(Face.POS_X);
|
|
73
|
+
expect(posXAdjacent).toContain(Face.POS_Z);
|
|
74
|
+
expect(posXAdjacent).toContain(Face.NEG_Z);
|
|
75
|
+
expect(posXAdjacent).toContain(Face.POS_Y);
|
|
76
|
+
expect(posXAdjacent).toContain(Face.NEG_Y);
|
|
77
|
+
expect(posXAdjacent).not.toContain(Face.NEG_X);
|
|
78
|
+
expect(posXAdjacent).not.toContain(Face.POS_X);
|
|
79
|
+
});
|
|
80
|
+
it('should correctly identify adjacent faces', () => {
|
|
81
|
+
expect(Face.isAdjacent(Face.POS_Z, Face.POS_X)).toBe(true);
|
|
82
|
+
expect(Face.isAdjacent(Face.POS_Z, Face.NEG_X)).toBe(true);
|
|
83
|
+
expect(Face.isAdjacent(Face.POS_Z, Face.POS_Y)).toBe(true);
|
|
84
|
+
expect(Face.isAdjacent(Face.POS_Z, Face.NEG_Y)).toBe(true);
|
|
85
|
+
expect(Face.isAdjacent(Face.POS_Z, Face.NEG_Z)).toBe(false);
|
|
86
|
+
expect(Face.isAdjacent(Face.POS_Z, Face.POS_Z)).toBe(false);
|
|
87
|
+
});
|
|
88
|
+
it('should throw error for invalid face indices', () => {
|
|
89
|
+
expect(() => Face.getNormal(6)).toThrow('Invalid face index: 6');
|
|
90
|
+
expect(() => Face.getOpposite(6)).toThrow('Invalid face index: 6');
|
|
91
|
+
expect(() => Face.getAdjacent(6)).toThrow('Invalid face index: 6');
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
//# sourceMappingURL=face.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"face.test.js","sourceRoot":"","sources":["../../../src/math/face/face.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAEX,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IAClB,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACrC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC3B,MAAM,CAAC,IAAI,CAA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d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { FromSchema } from "../../schema/index.js";
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
export type I32 = FromSchema<typeof I32.schema>;
|
|
3
|
+
export declare namespace I32 {
|
|
4
|
+
const schema: {
|
|
5
|
+
readonly type: "integer";
|
|
6
|
+
readonly minimum: -2147483648;
|
|
7
|
+
readonly maximum: 2147483647;
|
|
8
|
+
readonly default: number;
|
|
9
|
+
};
|
|
10
|
+
}
|
package/dist/math/i32/i32.js
CHANGED
|
@@ -19,6 +19,9 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.*/
|
|
22
|
-
import {
|
|
23
|
-
export
|
|
22
|
+
import { I32Schema } from "../../schema/index.js";
|
|
23
|
+
export var I32;
|
|
24
|
+
(function (I32) {
|
|
25
|
+
I32.schema = I32Schema;
|
|
26
|
+
})(I32 || (I32 = {}));
|
|
24
27
|
//# sourceMappingURL=i32.js.map
|
package/dist/math/i32/i32.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i32.js","sourceRoot":"","sources":["../../../src/math/i32/i32.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAEX,OAAO,EAAE,SAAS,EAAc,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"i32.js","sourceRoot":"","sources":["../../../src/math/i32/i32.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAEX,OAAO,EAAE,SAAS,EAAc,MAAM,uBAAuB,CAAC;AAI9D,MAAM,KAAW,GAAG,CAEnB;AAFD,WAAiB,GAAG;IACH,UAAM,GAAG,SAAS,CAAC;AACpC,CAAC,EAFgB,GAAG,KAAH,GAAG,QAEnB"}
|
package/dist/math/index.d.ts
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
export * from "./constants.js";
|
|
2
|
-
export
|
|
3
|
-
export *
|
|
4
|
-
export
|
|
5
|
-
export *
|
|
6
|
-
export
|
|
7
|
-
export *
|
|
8
|
-
export
|
|
9
|
-
export *
|
|
10
|
-
export
|
|
11
|
-
export *
|
|
12
|
-
export
|
|
13
|
-
export *
|
|
14
|
-
export
|
|
15
|
-
export * as Vec4 from "./vec4/vec4.js";
|
|
16
|
-
export type Quat = import("./quat/quat.js").Type;
|
|
17
|
-
export * as Quat from "./quat/quat.js";
|
|
18
|
-
export type Aabb = import("./aabb/aabb.js").Type;
|
|
19
|
-
export * as Aabb from "./aabb/aabb.js";
|
|
20
|
-
export type Line2 = import("./line2/line2.js").Type;
|
|
21
|
-
export * as Line2 from "./line2/line2.js";
|
|
22
|
-
export type Line3 = import("./line3/line3.js").Type;
|
|
23
|
-
export * as Line3 from "./line3/line3.js";
|
|
2
|
+
export * from "./mat4x4/mat4x4.js";
|
|
3
|
+
export * from "./f32/f32.js";
|
|
4
|
+
export * from "./u32/u32.js";
|
|
5
|
+
export * from "./i32/i32.js";
|
|
6
|
+
export * from "./vec2/vec2.js";
|
|
7
|
+
export * from "./vec3/vec3.js";
|
|
8
|
+
export * from "./vec4/vec4.js";
|
|
9
|
+
export * from "./quat/quat.js";
|
|
10
|
+
export * from "./aabb/aabb.js";
|
|
11
|
+
export * from "./line2/line2.js";
|
|
12
|
+
export * from "./line3/line3.js";
|
|
13
|
+
export * from "./aabb-face/aabb-face.js";
|
|
14
|
+
export * from "./plane/plane.js";
|
|
24
15
|
export * from "./picking/index.js";
|
package/dist/math/index.js
CHANGED
|
@@ -20,27 +20,18 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.*/
|
|
22
22
|
export * from "./constants.js";
|
|
23
|
-
|
|
24
|
-
export *
|
|
25
|
-
|
|
26
|
-
export *
|
|
27
|
-
|
|
28
|
-
export *
|
|
29
|
-
|
|
30
|
-
export *
|
|
31
|
-
|
|
32
|
-
export *
|
|
33
|
-
|
|
34
|
-
export *
|
|
35
|
-
|
|
36
|
-
export * as Vec4 from "./vec4/vec4.js";
|
|
37
|
-
// Export the namespace Quat
|
|
38
|
-
export * as Quat from "./quat/quat.js";
|
|
39
|
-
// Export the namespace Aabb
|
|
40
|
-
export * as Aabb from "./aabb/aabb.js";
|
|
41
|
-
// Export the namespace Line2
|
|
42
|
-
export * as Line2 from "./line2/line2.js";
|
|
43
|
-
// Export the namespace Line3
|
|
44
|
-
export * as Line3 from "./line3/line3.js";
|
|
23
|
+
export * from "./mat4x4/mat4x4.js";
|
|
24
|
+
export * from "./f32/f32.js";
|
|
25
|
+
export * from "./u32/u32.js";
|
|
26
|
+
export * from "./i32/i32.js";
|
|
27
|
+
export * from "./vec2/vec2.js";
|
|
28
|
+
export * from "./vec3/vec3.js";
|
|
29
|
+
export * from "./vec4/vec4.js";
|
|
30
|
+
export * from "./quat/quat.js";
|
|
31
|
+
export * from "./aabb/aabb.js";
|
|
32
|
+
export * from "./line2/line2.js";
|
|
33
|
+
export * from "./line3/line3.js";
|
|
34
|
+
export * from "./aabb-face/aabb-face.js";
|
|
35
|
+
export * from "./plane/plane.js";
|
|
45
36
|
export * from "./picking/index.js";
|
|
46
37
|
//# sourceMappingURL=index.js.map
|
package/dist/math/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/math/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAEX,cAAc,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/math/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAEX,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
import { FromSchema } from "../../schema/index.js";
|
|
2
2
|
import { Vec2 } from "../index.js";
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
readonly
|
|
7
|
-
|
|
8
|
-
readonly
|
|
9
|
-
readonly type: "
|
|
10
|
-
readonly
|
|
11
|
-
|
|
3
|
+
export type Line2 = FromSchema<typeof Line2.schema>;
|
|
4
|
+
export declare namespace Line2 {
|
|
5
|
+
const schema: {
|
|
6
|
+
readonly type: "object";
|
|
7
|
+
readonly properties: {
|
|
8
|
+
readonly a: {
|
|
9
|
+
readonly type: "array";
|
|
10
|
+
readonly items: {
|
|
11
|
+
readonly type: "number";
|
|
12
|
+
readonly precision: 1;
|
|
13
|
+
readonly default: number;
|
|
14
|
+
};
|
|
15
|
+
readonly minItems: 2;
|
|
16
|
+
readonly maxItems: 2;
|
|
17
|
+
readonly default: readonly [0, 0];
|
|
12
18
|
};
|
|
13
|
-
readonly
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
readonly
|
|
21
|
-
readonly
|
|
22
|
-
readonly default:
|
|
19
|
+
readonly b: {
|
|
20
|
+
readonly type: "array";
|
|
21
|
+
readonly items: {
|
|
22
|
+
readonly type: "number";
|
|
23
|
+
readonly precision: 1;
|
|
24
|
+
readonly default: number;
|
|
25
|
+
};
|
|
26
|
+
readonly minItems: 2;
|
|
27
|
+
readonly maxItems: 2;
|
|
28
|
+
readonly default: readonly [0, 0];
|
|
23
29
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
};
|
|
31
|
+
readonly required: readonly ["a", "b"];
|
|
32
|
+
readonly additionalProperties: false;
|
|
33
|
+
readonly default: {
|
|
34
|
+
readonly a: readonly [0, 0];
|
|
35
|
+
readonly b: readonly [0, 0];
|
|
27
36
|
};
|
|
28
37
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
export type Type = FromSchema<typeof schema>;
|
|
37
|
-
type Line2 = Type;
|
|
38
|
-
export declare const layout: import("../../typed-buffer/index.js").StructLayout;
|
|
39
|
-
export declare const interpolate: (line: Line2, alpha: number) => Vec2;
|
|
40
|
-
export declare const intersects: (line1: Line2, line2: Line2, includeEndpoints?: boolean) => boolean;
|
|
41
|
-
export declare const subLine: (line: Line2, alpha: number, beta: number) => Line2;
|
|
42
|
-
export {};
|
|
38
|
+
const layout: import("../../typed-buffer/index.js").StructLayout;
|
|
39
|
+
const interpolate: (line: Line2, alpha: number) => Vec2;
|
|
40
|
+
const intersects: (line1: Line2, line2: Line2, includeEndpoints?: boolean) => boolean;
|
|
41
|
+
const subLine: (line: Line2, alpha: number, beta: number) => Line2;
|
|
42
|
+
}
|
package/dist/math/line2/line2.js
CHANGED
|
@@ -22,57 +22,60 @@ SOFTWARE.*/
|
|
|
22
22
|
import { getStructLayout } from "../../typed-buffer/index.js";
|
|
23
23
|
import { Vec2 } from "../index.js";
|
|
24
24
|
import { epsilon } from "../constants.js";
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// Line2 utility functions
|
|
41
|
-
export const interpolate = (line, alpha) => {
|
|
42
|
-
const a = line.a;
|
|
43
|
-
const b = line.b;
|
|
44
|
-
return [a[0] + alpha * (b[0] - a[0]), a[1] + alpha * (b[1] - a[1])];
|
|
45
|
-
};
|
|
46
|
-
export const intersects = (line1, line2, includeEndpoints = false) => {
|
|
47
|
-
const a = line1.a;
|
|
48
|
-
const b = line1.b;
|
|
49
|
-
const c = line2.a;
|
|
50
|
-
const d = line2.b;
|
|
51
|
-
// Check for endpoint intersections
|
|
52
|
-
if (includeEndpoints && ((Math.abs(a[0] - c[0]) < epsilon && Math.abs(a[1] - c[1]) < epsilon) ||
|
|
53
|
-
(Math.abs(a[0] - d[0]) < epsilon && Math.abs(a[1] - d[1]) < epsilon) ||
|
|
54
|
-
(Math.abs(b[0] - c[0]) < epsilon && Math.abs(b[1] - c[1]) < epsilon) ||
|
|
55
|
-
(Math.abs(b[0] - d[0]) < epsilon && Math.abs(b[1] - d[1]) < epsilon))) {
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
// Calculate the denominator
|
|
59
|
-
const denominator = (d[0] - c[0]) * (b[1] - a[1]) - (d[1] - c[1]) * (b[0] - a[0]);
|
|
60
|
-
// Check if lines are parallel or collinear
|
|
61
|
-
if (Math.abs(denominator) < epsilon) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
// Calculate intersection parameters
|
|
65
|
-
const numerator1 = (d[1] - c[1]) * (a[0] - c[0]) - (d[0] - c[0]) * (a[1] - c[1]);
|
|
66
|
-
const numerator2 = (b[1] - a[1]) * (a[0] - c[0]) - (b[0] - a[0]) * (a[1] - c[1]);
|
|
67
|
-
const ua = numerator1 / denominator;
|
|
68
|
-
const ub = numerator2 / denominator;
|
|
69
|
-
// Check if intersection point lies within both line segments
|
|
70
|
-
return ua >= -epsilon && ua <= 1 + epsilon && ub >= -epsilon && ub <= 1 + epsilon;
|
|
71
|
-
};
|
|
72
|
-
export const subLine = (line, alpha, beta) => {
|
|
73
|
-
return {
|
|
74
|
-
a: interpolate(line, alpha),
|
|
75
|
-
b: interpolate(line, beta),
|
|
25
|
+
export var Line2;
|
|
26
|
+
(function (Line2) {
|
|
27
|
+
const { schema: Vec2Schema } = Vec2;
|
|
28
|
+
Line2.schema = {
|
|
29
|
+
type: 'object',
|
|
30
|
+
properties: {
|
|
31
|
+
a: Vec2Schema,
|
|
32
|
+
b: Vec2Schema,
|
|
33
|
+
},
|
|
34
|
+
required: ['a', 'b'],
|
|
35
|
+
additionalProperties: false,
|
|
36
|
+
default: {
|
|
37
|
+
a: Vec2Schema.default,
|
|
38
|
+
b: Vec2Schema.default,
|
|
39
|
+
}
|
|
76
40
|
};
|
|
77
|
-
|
|
41
|
+
Line2.layout = getStructLayout(Line2.schema);
|
|
42
|
+
// Line2 utility functions
|
|
43
|
+
Line2.interpolate = (line, alpha) => {
|
|
44
|
+
const a = line.a;
|
|
45
|
+
const b = line.b;
|
|
46
|
+
return [a[0] + alpha * (b[0] - a[0]), a[1] + alpha * (b[1] - a[1])];
|
|
47
|
+
};
|
|
48
|
+
Line2.intersects = (line1, line2, includeEndpoints = false) => {
|
|
49
|
+
const a = line1.a;
|
|
50
|
+
const b = line1.b;
|
|
51
|
+
const c = line2.a;
|
|
52
|
+
const d = line2.b;
|
|
53
|
+
// Check for endpoint intersections
|
|
54
|
+
if (includeEndpoints && ((Math.abs(a[0] - c[0]) < epsilon && Math.abs(a[1] - c[1]) < epsilon) ||
|
|
55
|
+
(Math.abs(a[0] - d[0]) < epsilon && Math.abs(a[1] - d[1]) < epsilon) ||
|
|
56
|
+
(Math.abs(b[0] - c[0]) < epsilon && Math.abs(b[1] - c[1]) < epsilon) ||
|
|
57
|
+
(Math.abs(b[0] - d[0]) < epsilon && Math.abs(b[1] - d[1]) < epsilon))) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
// Calculate the denominator
|
|
61
|
+
const denominator = (d[0] - c[0]) * (b[1] - a[1]) - (d[1] - c[1]) * (b[0] - a[0]);
|
|
62
|
+
// Check if lines are parallel or collinear
|
|
63
|
+
if (Math.abs(denominator) < epsilon) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
// Calculate intersection parameters
|
|
67
|
+
const numerator1 = (d[1] - c[1]) * (a[0] - c[0]) - (d[0] - c[0]) * (a[1] - c[1]);
|
|
68
|
+
const numerator2 = (b[1] - a[1]) * (a[0] - c[0]) - (b[0] - a[0]) * (a[1] - c[1]);
|
|
69
|
+
const ua = numerator1 / denominator;
|
|
70
|
+
const ub = numerator2 / denominator;
|
|
71
|
+
// Check if intersection point lies within both line segments
|
|
72
|
+
return ua >= -epsilon && ua <= 1 + epsilon && ub >= -epsilon && ub <= 1 + epsilon;
|
|
73
|
+
};
|
|
74
|
+
Line2.subLine = (line, alpha, beta) => {
|
|
75
|
+
return {
|
|
76
|
+
a: Line2.interpolate(line, alpha),
|
|
77
|
+
b: Line2.interpolate(line, beta),
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
})(Line2 || (Line2 = {}));
|
|
78
81
|
//# sourceMappingURL=line2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line2.js","sourceRoot":"","sources":["../../../src/math/line2/line2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAGX,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"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AAI,CAAC,GAAG,OAAO,CAAC;IACtF,CAAC,CAAC;IAEW,aAAO,GAAG,CAAC,IAAW,EAAE,KAAa,EAAE,IAAY,EAAS,EAAE;QACvE,OAAO;YACH,CAAC,EAAE,MAAA,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC;YAC3B,CAAC,EAAE,MAAA,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC;SAC7B,CAAC;IACN,CAAC,CAAC;AACN,CAAC,EAlEgB,KAAK,KAAL,KAAK,QAkErB"}
|
|
@@ -1,49 +1,54 @@
|
|
|
1
1
|
import { FromSchema } from "../../schema/index.js";
|
|
2
2
|
import { Vec3 } from "../index.js";
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
readonly
|
|
7
|
-
|
|
8
|
-
readonly
|
|
9
|
-
readonly type: "
|
|
10
|
-
readonly
|
|
11
|
-
|
|
3
|
+
export type Line3 = FromSchema<typeof Line3.schema>;
|
|
4
|
+
export declare namespace Line3 {
|
|
5
|
+
const schema: {
|
|
6
|
+
readonly type: "object";
|
|
7
|
+
readonly properties: {
|
|
8
|
+
readonly a: {
|
|
9
|
+
readonly type: "array";
|
|
10
|
+
readonly items: {
|
|
11
|
+
readonly type: "number";
|
|
12
|
+
readonly precision: 1;
|
|
13
|
+
readonly default: number;
|
|
14
|
+
};
|
|
15
|
+
readonly minItems: 3;
|
|
16
|
+
readonly maxItems: 3;
|
|
17
|
+
readonly default: readonly [0, 0, 0];
|
|
12
18
|
};
|
|
13
|
-
readonly
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
readonly
|
|
21
|
-
readonly
|
|
22
|
-
readonly default:
|
|
19
|
+
readonly b: {
|
|
20
|
+
readonly type: "array";
|
|
21
|
+
readonly items: {
|
|
22
|
+
readonly type: "number";
|
|
23
|
+
readonly precision: 1;
|
|
24
|
+
readonly default: number;
|
|
25
|
+
};
|
|
26
|
+
readonly minItems: 3;
|
|
27
|
+
readonly maxItems: 3;
|
|
28
|
+
readonly default: readonly [0, 0, 0];
|
|
23
29
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
};
|
|
31
|
+
readonly required: readonly ["a", "b"];
|
|
32
|
+
readonly additionalProperties: false;
|
|
33
|
+
readonly default: {
|
|
34
|
+
readonly a: readonly [0, 0, 0];
|
|
35
|
+
readonly b: readonly [0, 0, 0];
|
|
27
36
|
};
|
|
28
37
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*/
|
|
47
|
-
export declare const closestPointOnLine: (line: Line3, point: Vec3) => number;
|
|
48
|
-
export declare const subLine: (line: Line3, alpha: number, beta: number) => Line3;
|
|
49
|
-
export {};
|
|
38
|
+
const layout: import("../../typed-buffer/index.js").StructLayout;
|
|
39
|
+
const interpolate: (line: Line3, alpha: number) => Vec3;
|
|
40
|
+
/**
|
|
41
|
+
* Calculates the alpha value (0-1) representing the closest point on a line to a given point.
|
|
42
|
+
*
|
|
43
|
+
* @param line - The line segment
|
|
44
|
+
* @param point - The point in 3D space
|
|
45
|
+
* @returns Alpha value, usually between 0 and 1, where 0 is line.a and 1 is line.b
|
|
46
|
+
*/
|
|
47
|
+
const closestPointOnLine: (line: Line3, point: Vec3) => number;
|
|
48
|
+
const subLine: (line: Line3, alpha: number, beta: number) => Line3;
|
|
49
|
+
/**
|
|
50
|
+
* Returns a unit vector pointing from line.a to line.b. If the line has zero length,
|
|
51
|
+
* returns the provided default direction (defaults to [0,0,1]).
|
|
52
|
+
*/
|
|
53
|
+
const direction: (line: Line3) => Vec3;
|
|
54
|
+
}
|