@adobe/data 0.5.14 → 0.5.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/ecs/database/create-database.test.js +11 -0
  2. package/dist/ecs/database/create-database.test.js.map +1 -1
  3. package/dist/math/aabb/aabb.d.ts +42 -42
  4. package/dist/math/aabb/aabb.js +65 -62
  5. package/dist/math/aabb/aabb.js.map +1 -1
  6. package/dist/math/aabb-face/aabb-face.d.ts +59 -0
  7. package/dist/math/aabb-face/aabb-face.js +145 -0
  8. package/dist/math/aabb-face/aabb-face.js.map +1 -0
  9. package/dist/math/aabb-face/aabb-face.test.d.ts +1 -0
  10. package/dist/math/aabb-face/aabb-face.test.js +54 -0
  11. package/dist/math/aabb-face/aabb-face.test.js.map +1 -0
  12. package/dist/math/f32/f32.d.ts +8 -6
  13. package/dist/math/f32/f32.js +4 -1
  14. package/dist/math/f32/f32.js.map +1 -1
  15. package/dist/math/i32/i32.d.ts +9 -6
  16. package/dist/math/i32/i32.js +5 -2
  17. package/dist/math/i32/i32.js.map +1 -1
  18. package/dist/math/index.d.ts +13 -22
  19. package/dist/math/index.js +13 -22
  20. package/dist/math/index.js.map +1 -1
  21. package/dist/math/line2/line2.d.ts +36 -36
  22. package/dist/math/line2/line2.js +55 -52
  23. package/dist/math/line2/line2.js.map +1 -1
  24. package/dist/math/line3/line3.d.ts +48 -43
  25. package/dist/math/line3/line3.js +64 -52
  26. package/dist/math/line3/line3.js.map +1 -1
  27. package/dist/math/mat4x4/mat4x4.d.ts +34 -34
  28. package/dist/math/mat4x4/mat4x4.js +216 -213
  29. package/dist/math/mat4x4/mat4x4.js.map +1 -1
  30. package/dist/math/picking/get-closest-entity-to-line.d.ts +4 -0
  31. package/dist/math/picking/get-closest-entity-to-line.js +30 -0
  32. package/dist/math/picking/get-closest-entity-to-line.js.map +1 -0
  33. package/dist/math/picking/get-closest-entity-to-point.d.ts +4 -0
  34. package/dist/math/picking/get-closest-entity-to-point.js +27 -0
  35. package/dist/math/picking/get-closest-entity-to-point.js.map +1 -0
  36. package/dist/math/picking/get-intersecting-entities.d.ts +12 -0
  37. package/dist/math/picking/get-intersecting-entities.js +15 -0
  38. package/dist/math/picking/get-intersecting-entities.js.map +1 -0
  39. package/dist/math/picking/index.d.ts +4 -0
  40. package/dist/math/picking/index.js +4 -0
  41. package/dist/math/picking/index.js.map +1 -1
  42. package/dist/math/picking/pick-from-tables.d.ts +1 -0
  43. package/dist/math/picking/pick-from-tables.js +7 -98
  44. package/dist/math/picking/pick-from-tables.js.map +1 -1
  45. package/dist/math/picking/pick-result.d.ts +5 -2
  46. package/dist/math/plane/plane.d.ts +43 -0
  47. package/dist/math/plane/plane.js +70 -0
  48. package/dist/math/plane/plane.js.map +1 -0
  49. package/dist/math/plane/plane.test.d.ts +1 -0
  50. package/dist/math/plane/plane.test.js +132 -0
  51. package/dist/math/plane/plane.test.js.map +1 -0
  52. package/dist/math/quat/quat.d.ts +49 -39
  53. package/dist/math/quat/quat.js +225 -185
  54. package/dist/math/quat/quat.js.map +1 -1
  55. package/dist/math/u32/u32.d.ts +9 -7
  56. package/dist/math/u32/u32.js +4 -1
  57. package/dist/math/u32/u32.js.map +1 -1
  58. package/dist/math/vec2/vec2.d.ts +61 -61
  59. package/dist/math/vec2/vec2.js +93 -90
  60. package/dist/math/vec2/vec2.js.map +1 -1
  61. package/dist/math/vec3/vec3.d.ts +66 -63
  62. package/dist/math/vec3/vec3.js +137 -129
  63. package/dist/math/vec3/vec3.js.map +1 -1
  64. package/dist/math/vec4/vec4.d.ts +61 -61
  65. package/dist/math/vec4/vec4.js +132 -129
  66. package/dist/math/vec4/vec4.js.map +1 -1
  67. package/dist/observe/to-async-generator.js +4 -4
  68. package/dist/observe/to-async-generator.js.map +1 -1
  69. package/dist/old-ecs/action-ecs/action-ecs.test.js +1 -1
  70. package/dist/old-ecs/action-ecs/action-ecs.test.js.map +1 -1
  71. package/dist/old-ecs/action-ecs/action-types.d.ts +7 -0
  72. package/dist/old-ecs/action-ecs/action-types.js.map +1 -1
  73. package/dist/old-ecs/core-ecs/core-ecs-serialization.test.js +205 -1
  74. package/dist/old-ecs/core-ecs/core-ecs-serialization.test.js.map +1 -1
  75. package/dist/old-ecs/core-ecs/core-ecs-types.d.ts +4 -1
  76. package/dist/old-ecs/core-ecs/core-ecs.d.ts +2 -0
  77. package/dist/old-ecs/core-ecs/core-ecs.js +23 -9
  78. package/dist/old-ecs/core-ecs/core-ecs.js.map +1 -1
  79. package/dist/old-ecs/ecs/ecs-types.d.ts +7 -0
  80. package/dist/old-ecs/ecs/ecs.test.js +1 -1
  81. package/dist/old-ecs/ecs/ecs.test.js.map +1 -1
  82. package/dist/old-ecs/privacy/helper-functions.d.ts +43 -0
  83. package/dist/old-ecs/privacy/helper-functions.js +76 -0
  84. package/dist/old-ecs/privacy/helper-functions.js.map +1 -0
  85. package/dist/old-ecs/privacy/helper-functions.test.d.ts +1 -0
  86. package/dist/old-ecs/privacy/helper-functions.test.js +173 -0
  87. package/dist/old-ecs/privacy/helper-functions.test.js.map +1 -0
  88. package/dist/old-ecs/transaction-ecs/transaction-ecs.test.js +1 -1
  89. package/dist/old-ecs/transaction-ecs/transaction-ecs.test.js.map +1 -1
  90. package/dist/old-ecs/transaction-ecs/transaction-types.d.ts +7 -0
  91. package/dist/samples/todo/services/state-service/create-todo-database.d.ts +2 -2
  92. package/dist/samples/todo/services/state-service/create-todo-store.d.ts +2 -2
  93. package/dist/tsconfig.tsbuildinfo +1 -1
  94. package/package.json +6 -3
@@ -21,104 +21,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.*/
22
22
  import { Aabb } from "../index.js";
23
23
  import { Line3 } from "../index.js";
24
- import { Vec3 } from "../index.js";
25
- /**
26
- * Determines which face of a cube was hit based on the intersection point
27
- * @param position World position of the intersection
28
- * @param aabb Bounding box of the cube
29
- * @returns Face index: 0=POS_Z, 1=POS_X, 2=NEG_Z, 3=NEG_X, 4=POS_Y, 5=NEG_Y
30
- */
31
- function determineFaceFromPosition(position, aabb) {
32
- const aabbCenter = Aabb.center(aabb);
33
- const localPos = [
34
- position[0] - aabbCenter[0],
35
- position[1] - aabbCenter[1],
36
- position[2] - aabbCenter[2]
37
- ];
38
- // Find the face with the largest absolute coordinate (closest to cube surface)
39
- const absX = Math.abs(localPos[0]);
40
- const absY = Math.abs(localPos[1]);
41
- const absZ = Math.abs(localPos[2]);
42
- if (absX >= absY && absX >= absZ) {
43
- // X-axis face (NEG_X or POS_X)
44
- return localPos[0] > 0 ? 1 : 3; // 1=POS_X, 3=NEG_X
45
- }
46
- else if (absY >= absZ) {
47
- // Y-axis face (NEG_Y or POS_Y)
48
- return localPos[1] > 0 ? 4 : 5; // 4=POS_Y, 5=NEG_Y
49
- }
50
- else {
51
- // Z-axis face (NEG_Z or POS_Z)
52
- return localPos[2] > 0 ? 0 : 2; // 0=POS_Z, 2=NEG_Z
53
- }
54
- }
55
- function getIntersectingEntities(options) {
56
- const { tables, line, radius = 0, predicate } = options;
57
- const rows = new Map();
58
- for (const table of tables) {
59
- for (let row = 0; row < table.rowCount; row++) {
60
- const boundingBox = table.columns.boundingBox.get(row);
61
- if (Aabb.lineIntersection(boundingBox, line, radius) !== -1 && (predicate?.(table, row) ?? true)) {
62
- rows.set(table.columns.id.get(row), boundingBox);
63
- }
64
- }
65
- }
66
- return rows;
67
- }
68
- function getClosestEntityToPoint(rows, point) {
69
- let closestRow = -1;
70
- let closestDistanceSquared = Infinity;
71
- let closestAabb = null;
72
- for (const [row, aabb] of rows) {
73
- const distSquared = Vec3.distanceSquared(point, Aabb.center(aabb));
74
- if (distSquared < closestDistanceSquared) {
75
- closestDistanceSquared = distSquared;
76
- closestRow = row;
77
- closestAabb = aabb;
78
- }
79
- }
80
- if (closestRow !== -1 && closestAabb) {
81
- // For direct intersection, use the intersection point if possible
82
- // We'll use the intersection alpha from Aabb.lineIntersection
83
- // If the line starts inside, alpha=0, so position is line.a
84
- // Otherwise, Line3.interpolate at alpha
85
- return {
86
- entity: closestRow,
87
- position: point,
88
- face: determineFaceFromPosition(point, closestAabb),
89
- };
90
- }
91
- return null;
92
- }
93
- function getClosestEntityToLine(rows, line) {
94
- let closestEntity = null;
95
- let closestDistanceSquared = Infinity;
96
- let closestAlpha = Infinity;
97
- let pickedPosition = null;
98
- for (const [id, aabb] of rows) {
99
- const aabbCenter = Aabb.center(aabb);
100
- const alpha = Line3.closestPointOnLine(line, aabbCenter);
101
- const closestPointOnLineSegment = Line3.interpolate(line, alpha);
102
- const distSquared = Vec3.distanceSquared(aabbCenter, closestPointOnLineSegment);
103
- if (distSquared < closestDistanceSquared ||
104
- (distSquared === closestDistanceSquared && alpha < closestAlpha)) {
105
- closestDistanceSquared = distSquared;
106
- closestAlpha = alpha;
107
- closestEntity = id;
108
- pickedPosition = closestPointOnLineSegment;
109
- }
110
- }
111
- if (closestEntity !== null && pickedPosition) {
112
- return {
113
- entity: closestEntity,
114
- position: pickedPosition,
115
- face: determineFaceFromPosition(pickedPosition, rows.get(closestEntity)),
116
- };
117
- }
118
- return null;
119
- }
24
+ import { getIntersectingEntities } from "./get-intersecting-entities.js";
25
+ import { getClosestEntityToPoint } from "./get-closest-entity-to-point.js";
26
+ import { getClosestEntityToLine } from "./get-closest-entity-to-line.js";
120
27
  /**
121
28
  * Picks the closest intersecting row from a table.
29
+ * This would be the broad phase picking step.
122
30
  * @returns The entity id and picked position, or null if no entity is found.
123
31
  */
124
32
  export function pickFromTables(options) {
@@ -136,8 +44,9 @@ export function pickFromTables(options) {
136
44
  if (best) {
137
45
  return {
138
46
  entity: best.id,
139
- position: Line3.interpolate(line, best.alpha),
140
- face: determineFaceFromPosition(Line3.interpolate(line, best.alpha), rows.get(best.id)),
47
+ lineAlpha: best.alpha,
48
+ entityPosition: Line3.interpolate(line, best.alpha),
49
+ // face: AabbFace.fromPosition(Line3.interpolate(line, best.alpha), rows.get(best.id)!),
141
50
  };
142
51
  }
143
52
  // fallback (should not happen):
@@ -1 +1 @@
1
- {"version":3,"file":"pick-from-tables.js","sourceRoot":"","sources":["../../../src/math/picking/pick-from-tables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAIX,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAInC;;;;;GAKG;AACH,SAAS,yBAAyB,CAAC,QAAc,EAAE,IAAU;IACzD,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG;QACb,QAAQ,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;QAC3B,QAAQ,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;QAC3B,QAAQ,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;KAC9B,CAAC;IAEF,+EAA+E;IAC/E,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAEnC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QAC/B,+BAA+B;QAC/B,OAAO,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,mBAAmB;IACvD,CAAC;SAAM,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACtB,+BAA+B;QAC/B,OAAO,QAAQ,CAA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AAC;AAChB,CAAC"}
@@ -1,7 +1,10 @@
1
1
  import { Entity } from "../../ecs/index.js";
2
2
  import { Vec3 } from "../index.js";
3
3
  export interface PickResult {
4
+ /** The entity that was picked. */
4
5
  entity: Entity;
5
- position: Vec3;
6
- face: number;
6
+ /** Alpha value (0-1) along the picking line where the intersection/closest point occurs. */
7
+ lineAlpha: number;
8
+ /** World-space position of the entity or closest point on the AABB. */
9
+ entityPosition: Vec3;
7
10
  }
@@ -0,0 +1,43 @@
1
+ import { FromSchema } from "../../schema/index.js";
2
+ import { Vec3, Line3 } from "../index.js";
3
+ export type Plane = FromSchema<typeof Plane.schema>;
4
+ export declare namespace Plane {
5
+ const schema: {
6
+ readonly type: "object";
7
+ readonly properties: {
8
+ readonly normal: {
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];
18
+ };
19
+ readonly distance: {
20
+ readonly type: "number";
21
+ readonly precision: 1;
22
+ readonly default: number;
23
+ };
24
+ };
25
+ readonly layout: "std140";
26
+ readonly required: readonly ["normal", "distance"];
27
+ readonly additionalProperties: false;
28
+ };
29
+ const layout: import("../../typed-buffer/index.js").StructLayout;
30
+ function is(value: any): value is Plane;
31
+ const signedDistance: (plane: Plane, point: Vec3) => number;
32
+ const distance: (plane: Plane, point: Vec3) => number;
33
+ const containsPoint: (plane: Plane, point: Vec3) => boolean;
34
+ const isPointInFront: (plane: Plane, point: Vec3) => boolean;
35
+ const isPointBehind: (plane: Plane, point: Vec3) => boolean;
36
+ /**
37
+ * Find the intersection alpha between a line and a plane.
38
+ * @param plane The plane to intersect with
39
+ * @param line The line to intersect
40
+ * @returns The alpha parameter (0-1 = within segment, <0 or >1 = outside segment), or null if line is parallel to plane
41
+ */
42
+ const lineIntersection: (plane: Plane, line: Line3) => number | null;
43
+ }
@@ -0,0 +1,70 @@
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 { getStructLayout } from "../../typed-buffer/index.js";
23
+ import { Vec3, F32, epsilon } from "../index.js";
24
+ export var Plane;
25
+ (function (Plane) {
26
+ Plane.schema = {
27
+ type: 'object',
28
+ properties: {
29
+ normal: Vec3.schema,
30
+ distance: F32.schema,
31
+ },
32
+ layout: 'std140',
33
+ required: ['normal', 'distance'],
34
+ additionalProperties: false,
35
+ };
36
+ Plane.layout = getStructLayout(Plane.schema);
37
+ function is(value) {
38
+ return value && typeof value === 'object' && 'normal' in value && 'distance' in value;
39
+ }
40
+ Plane.is = is;
41
+ // Plane utility functions
42
+ Plane.signedDistance = (plane, point) => Vec3.dot(plane.normal, point) - plane.distance;
43
+ Plane.distance = (plane, point) => Math.abs(Plane.signedDistance(plane, point));
44
+ Plane.containsPoint = (plane, point) => Math.abs(Plane.signedDistance(plane, point)) < epsilon;
45
+ Plane.isPointInFront = (plane, point) => Plane.signedDistance(plane, point) > 0;
46
+ Plane.isPointBehind = (plane, point) => Plane.signedDistance(plane, point) < 0;
47
+ /**
48
+ * Find the intersection alpha between a line and a plane.
49
+ * @param plane The plane to intersect with
50
+ * @param line The line to intersect
51
+ * @returns The alpha parameter (0-1 = within segment, <0 or >1 = outside segment), or null if line is parallel to plane
52
+ */
53
+ Plane.lineIntersection = (plane, line) => {
54
+ const { a, b } = line;
55
+ // Calculate line direction vector
56
+ const direction = Vec3.subtract(b, a);
57
+ // Calculate denominator: dot(normal, direction)
58
+ const denominator = Vec3.dot(plane.normal, direction);
59
+ // If denominator is close to zero, line is parallel to plane
60
+ if (Math.abs(denominator) < epsilon) {
61
+ return null;
62
+ }
63
+ // Calculate numerator: dot(normal, a) - distance
64
+ const numerator = Vec3.dot(plane.normal, a) - plane.distance;
65
+ // Calculate parameter t (alpha)
66
+ const alpha = -numerator / denominator;
67
+ return alpha;
68
+ };
69
+ })(Plane || (Plane = {}));
70
+ //# sourceMappingURL=plane.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plane.js","sourceRoot":"","sources":["../../../src/math/plane/plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAGX,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,GAAG,EAAS,OAAO,EAAE,MAAM,aAAa,CAAC;AAIxD,MAAM,KAAW,KAAK,CA8DrB;AA9DD,WAAiB,KAAK;IACL,YAAM,GAAG;QAClB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACR,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,GAAG,CAAC,MAAM;SACvB;QACD,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC;QAChC,oBAAoB,EAAE,KAAK;KACJ,CAAC;IAEf,YAAM,GA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E,SAAS,CAAC,CAAC;QAEtD,6DAA6D;QAC7D,IAAI,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,OAAO,EAAE,CAAC;YAClC,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,iDAAiD;QACjD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC;QAE7D,gCAAgC;QAChC,MAAM,KAAK,GAAG,CAAC,SAAS,GAAG,WAAW,CAAC;QAEvC,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC;AACN,CAAC,EA9DgB,KAAK,KAAL,KAAK,QA8DrB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,132 @@
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 { Plane } from "../index.js";
24
+ describe("Plane", () => {
25
+ const xyPlane = {
26
+ normal: [0, 0, 1], // pointing up
27
+ distance: 0 // plane at origin
28
+ };
29
+ const xyPlaneOffset = {
30
+ normal: [0, 0, 1], // pointing up
31
+ distance: 5 // plane 5 units above origin
32
+ };
33
+ describe("signedDistance", () => {
34
+ it("should return 0 for points on the plane", () => {
35
+ expect(Plane.signedDistance(xyPlane, [0, 0, 0])).toBe(0);
36
+ expect(Plane.signedDistance(xyPlane, [5, 3, 0])).toBe(0);
37
+ });
38
+ it("should return positive distance for points in front of plane", () => {
39
+ expect(Plane.signedDistance(xyPlane, [0, 0, 1])).toBe(1);
40
+ expect(Plane.signedDistance(xyPlane, [0, 0, 5])).toBe(5);
41
+ });
42
+ it("should return negative distance for points behind plane", () => {
43
+ expect(Plane.signedDistance(xyPlane, [0, 0, -1])).toBe(-1);
44
+ expect(Plane.signedDistance(xyPlane, [0, 0, -3])).toBe(-3);
45
+ });
46
+ it("should work with offset planes", () => {
47
+ expect(Plane.signedDistance(xyPlaneOffset, [0, 0, 5])).toBe(0); // on plane
48
+ expect(Plane.signedDistance(xyPlaneOffset, [0, 0, 7])).toBe(2); // 2 units above
49
+ expect(Plane.signedDistance(xyPlaneOffset, [0, 0, 3])).toBe(-2); // 2 units below
50
+ });
51
+ });
52
+ describe("distance", () => {
53
+ it("should return absolute distance", () => {
54
+ expect(Plane.distance(xyPlane, [0, 0, 3])).toBe(3);
55
+ expect(Plane.distance(xyPlane, [0, 0, -3])).toBe(3);
56
+ expect(Plane.distance(xyPlane, [0, 0, 0])).toBe(0);
57
+ });
58
+ });
59
+ describe("containsPoint", () => {
60
+ it("should return true for points on the plane", () => {
61
+ expect(Plane.containsPoint(xyPlane, [0, 0, 0])).toBe(true);
62
+ expect(Plane.containsPoint(xyPlane, [5, 3, 0])).toBe(true);
63
+ });
64
+ it("should return false for points off the plane", () => {
65
+ expect(Plane.containsPoint(xyPlane, [0, 0, 0.001])).toBe(false);
66
+ expect(Plane.containsPoint(xyPlane, [0, 0, -0.001])).toBe(false);
67
+ });
68
+ });
69
+ describe("isPointInFront", () => {
70
+ it("should return true for points in front of plane", () => {
71
+ expect(Plane.isPointInFront(xyPlane, [0, 0, 1])).toBe(true);
72
+ expect(Plane.isPointInFront(xyPlane, [0, 0, 5])).toBe(true);
73
+ });
74
+ it("should return false for points behind or on plane", () => {
75
+ expect(Plane.isPointInFront(xyPlane, [0, 0, 0])).toBe(false);
76
+ expect(Plane.isPointInFront(xyPlane, [0, 0, -1])).toBe(false);
77
+ });
78
+ });
79
+ describe("isPointBehind", () => {
80
+ it("should return true for points behind plane", () => {
81
+ expect(Plane.isPointBehind(xyPlane, [0, 0, -1])).toBe(true);
82
+ expect(Plane.isPointBehind(xyPlane, [0, 0, -5])).toBe(true);
83
+ });
84
+ it("should return false for points in front or on plane", () => {
85
+ expect(Plane.isPointBehind(xyPlane, [0, 0, 0])).toBe(false);
86
+ expect(Plane.isPointBehind(xyPlane, [0, 0, 1])).toBe(false);
87
+ });
88
+ });
89
+ describe("lineIntersection", () => {
90
+ it("should find intersection alpha for line crossing plane", () => {
91
+ const line = { a: [0, 0, -1], b: [0, 0, 1] }; // vertical line
92
+ const alpha = Plane.lineIntersection(xyPlane, line);
93
+ expect(alpha).toBe(0.5); // intersects at midpoint
94
+ });
95
+ it("should find intersection alpha for diagonal line", () => {
96
+ const line = { a: [1, 1, -1], b: [1, 1, 1] }; // diagonal line
97
+ const alpha = Plane.lineIntersection(xyPlane, line);
98
+ expect(alpha).toBe(0.5); // intersects at midpoint
99
+ });
100
+ it("should find intersection alpha for offset plane", () => {
101
+ const line = { a: [0, 0, 3], b: [0, 0, 7] }; // line above offset plane
102
+ const alpha = Plane.lineIntersection(xyPlaneOffset, line);
103
+ expect(alpha).toBe(0.5); // intersects at midpoint (z=5)
104
+ });
105
+ it("should return null for line parallel to plane", () => {
106
+ const line = { a: [0, 0, 1], b: [1, 0, 1] }; // horizontal line
107
+ const alpha = Plane.lineIntersection(xyPlane, line);
108
+ expect(alpha).toBeNull();
109
+ });
110
+ it("should return null for line in the plane", () => {
111
+ const line = { a: [0, 0, 0], b: [1, 0, 0] }; // line in xy plane
112
+ const alpha = Plane.lineIntersection(xyPlane, line);
113
+ expect(alpha).toBeNull();
114
+ });
115
+ it("should handle line that doesn't intersect within segment", () => {
116
+ const line = { a: [0, 0, 2], b: [0, 0, 4] }; // line above plane
117
+ const alpha = Plane.lineIntersection(xyPlane, line);
118
+ expect(alpha).toBe(-1); // intersection exists but before segment start
119
+ });
120
+ it("should handle alpha values outside segment", () => {
121
+ const line = { a: [0, 0, 2], b: [0, 0, 6] }; // line from z=2 to z=6
122
+ const alpha = Plane.lineIntersection(xyPlane, line);
123
+ expect(alpha).toBe(-0.5); // intersects at z=0, which is before segment start
124
+ });
125
+ it("should handle alpha values after segment end", () => {
126
+ const line = { a: [0, 0, -2], b: [0, 0, -1] }; // line from z=-2 to z=-1
127
+ const alpha = Plane.lineIntersection(xyPlane, line);
128
+ expect(alpha).toBe(2); // intersects at z=0, which is after segment end
129
+ });
130
+ });
131
+ });
132
+ //# sourceMappingURL=plane.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plane.test.js","sourceRoot":"","sources":["../../../src/math/plane/plane.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAEX,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAe,MAAM,aAAa,CAAC;AAEjD,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACnB,MAAM,OAAO,GAAU;QACnB,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc;QACjC,QAAQ,EAAE,CAAC,CAAC,kBAAkB;KACjC,CAAC;IAEF,MAAM,aAAa,GAAU;QACzB,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAA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AC3E,MAAM,KAAK,GAAG,KAAK,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACpD,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,mDAAmD;QACjF,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;YACpD,MAAM,IAAI,GAAU,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,yBAAyB;YAC/E,MAAM,KAAK,GAAG,KAAK,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACpD,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,gDAAgD;QAC3E,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,42 +1,52 @@
1
1
  import { FromSchema } from "../../schema/index.js";
2
2
  import { Vec3, Mat4x4 } from "../index.js";
3
- export declare const schema: {
4
- readonly type: "array";
5
- readonly items: {
6
- readonly type: "number";
7
- readonly precision: 1;
8
- readonly default: number;
3
+ export type Quat = FromSchema<typeof Quat.schema>;
4
+ export declare namespace Quat {
5
+ const schema: {
6
+ readonly type: "array";
7
+ readonly items: {
8
+ readonly type: "number";
9
+ readonly precision: 1;
10
+ readonly default: number;
11
+ };
12
+ readonly minItems: 4;
13
+ readonly maxItems: 4;
14
+ readonly default: readonly [0, 0, 0, 1];
9
15
  };
10
- readonly minItems: 4;
11
- readonly maxItems: 4;
12
- readonly default: readonly [0, 0, 0, 1];
13
- };
14
- export type Type = FromSchema<typeof schema>;
15
- type Quat = Type;
16
- export declare const layout: import("../../typed-buffer/index.js").StructLayout;
17
- export declare const add: ([x1, y1, z1, w1]: Quat, [x2, y2, z2, w2]: Quat) => Quat;
18
- export declare const subtract: ([x1, y1, z1, w1]: Quat, [x2, y2, z2, w2]: Quat) => Quat;
19
- export declare const scale: ([x, y, z, w]: Quat, s: number) => Quat;
20
- export declare const negate: ([x, y, z, w]: Quat) => Quat;
21
- export declare const conjugate: ([x, y, z, w]: Quat) => Quat;
22
- export declare const multiply: ([x1, y1, z1, w1]: Quat, [x2, y2, z2, w2]: Quat) => Quat;
23
- export declare const length: ([x, y, z, w]: Quat) => number;
24
- export declare const lengthSquared: ([x, y, z, w]: Quat) => number;
25
- export declare const normalize: (q: Quat) => Quat;
26
- export declare const dot: ([x1, y1, z1, w1]: Quat, [x2, y2, z2, w2]: Quat) => number;
27
- export declare const distance: (a: Quat, b: Quat) => number;
28
- export declare const fromAxisAngle: (axis: Vec3, angle: number) => Quat;
29
- export declare const toAxisAngle: ([x, y, z, w]: Quat) => {
30
- axis: Vec3;
31
- angle: number;
32
- };
33
- export declare const fromEuler: (x: number, y: number, z: number) => Quat;
34
- export declare const toEuler: ([x, y, z, w]: Quat) => Vec3;
35
- export declare const rotateVec3: ([x, y, z, w]: Quat, v: Vec3) => Vec3;
36
- export declare const slerp: (q1: Quat, q2: Quat, t: number) => Quat;
37
- export declare const lerp: (q1: Quat, q2: Quat, t: number) => Quat;
38
- export declare const toMat4: ([x, y, z, w]: Quat) => Mat4x4;
39
- export declare const identity: () => Quat;
40
- export declare const inverse: (q: Quat) => Quat;
41
- export declare const lookAt: (forward: Vec3, up: Vec3) => Quat;
42
- export {};
16
+ const layout: import("../../typed-buffer/index.js").StructLayout;
17
+ const add: ([x1, y1, z1, w1]: Quat, [x2, y2, z2, w2]: Quat) => Quat;
18
+ const subtract: ([x1, y1, z1, w1]: Quat, [x2, y2, z2, w2]: Quat) => Quat;
19
+ const scale: ([x, y, z, w]: Quat, s: number) => Quat;
20
+ const negate: ([x, y, z, w]: Quat) => Quat;
21
+ const conjugate: ([x, y, z, w]: Quat) => Quat;
22
+ const multiply: ([x1, y1, z1, w1]: Quat, [x2, y2, z2, w2]: Quat) => Quat;
23
+ const length: ([x, y, z, w]: Quat) => number;
24
+ const lengthSquared: ([x, y, z, w]: Quat) => number;
25
+ const normalize: (q: Quat) => Quat;
26
+ const dot: ([x1, y1, z1, w1]: Quat, [x2, y2, z2, w2]: Quat) => number;
27
+ const distance: (a: Quat, b: Quat) => number;
28
+ const fromAxisAngle: (axis: Vec3, angle: number) => Quat;
29
+ const toAxisAngle: ([x, y, z, w]: Quat) => {
30
+ axis: Vec3;
31
+ angle: number;
32
+ };
33
+ const fromEuler: (x: number, y: number, z: number) => Quat;
34
+ const toEuler: ([x, y, z, w]: Quat) => Vec3;
35
+ const rotateVec3: ([x, y, z, w]: Quat, v: Vec3) => Vec3;
36
+ const slerp: (q1: Quat, q2: Quat, t: number) => Quat;
37
+ const lerp: (q1: Quat, q2: Quat, t: number) => Quat;
38
+ const toMat4: ([x, y, z, w]: Quat) => Mat4x4;
39
+ const identity: Quat;
40
+ const inverse: (q: Quat) => Quat;
41
+ const lookAt: (forward: Vec3, up: Vec3) => Quat;
42
+ /**
43
+ * Returns a quaternion that aligns the local Z-axis to the given direction via the shortest arc,
44
+ * then applies an additional twist around that aligned Z-axis.
45
+ *
46
+ * Note: This aligns the Z axis.
47
+ *
48
+ * @param direction - Target world-space direction for local Z. If zero-length, returns identity.
49
+ * @param twistRadians - Extra rotation around the aligned Z-axis, in radians. Defaults to 0.
50
+ */
51
+ const alignTo: (direction: Vec3, twistRadians?: number) => Quat;
52
+ }