@flighthq/node 0.2.0 → 0.2.1-next.410.a23f189

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 (47) hide show
  1. package/dist/boundsRectangle.d.ts.map +1 -1
  2. package/dist/boundsRectangle.js +9 -9
  3. package/dist/boundsRectangle.js.map +1 -1
  4. package/dist/hasAppearance.d.ts.map +1 -1
  5. package/dist/hasAppearance.js +0 -1
  6. package/dist/hasAppearance.js.map +1 -1
  7. package/dist/hasBlendMode.d.ts +3 -0
  8. package/dist/hasBlendMode.d.ts.map +1 -0
  9. package/dist/hasBlendMode.js +4 -0
  10. package/dist/hasBlendMode.js.map +1 -0
  11. package/dist/hasTransform2d.js +2 -2
  12. package/dist/hasTransform2d.js.map +1 -1
  13. package/dist/hasTransform3d.d.ts.map +1 -1
  14. package/dist/hasTransform3d.js +7 -3
  15. package/dist/hasTransform3d.js.map +1 -1
  16. package/dist/hierarchy.js +4 -4
  17. package/dist/hierarchy.js.map +1 -1
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +1 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/node.d.ts.map +1 -1
  23. package/dist/node.js +3 -0
  24. package/dist/node.js.map +1 -1
  25. package/dist/revision.d.ts.map +1 -1
  26. package/dist/revision.js +16 -5
  27. package/dist/revision.js.map +1 -1
  28. package/dist/transform2d.d.ts +8 -5
  29. package/dist/transform2d.d.ts.map +1 -1
  30. package/dist/transform2d.js +53 -20
  31. package/dist/transform2d.js.map +1 -1
  32. package/dist/transform3d.d.ts +10 -3
  33. package/dist/transform3d.d.ts.map +1 -1
  34. package/dist/transform3d.js +79 -13
  35. package/dist/transform3d.js.map +1 -1
  36. package/dist/viewport.d.ts.map +1 -1
  37. package/dist/viewport.js +3 -2
  38. package/dist/viewport.js.map +1 -1
  39. package/package.json +5 -5
  40. package/src/boundsRectangle.test.ts +2 -2
  41. package/src/hasAppearance.test.ts +0 -10
  42. package/src/hasBlendMode.test.ts +25 -0
  43. package/src/hasTransform2d.test.ts +2 -2
  44. package/src/hasTransform3d.test.ts +18 -19
  45. package/src/hierarchy.test.ts +13 -13
  46. package/src/transform2d.test.ts +113 -51
  47. package/src/transform3d.test.ts +302 -100
@@ -1,6 +1,13 @@
1
- import type { Matrix4Like, Transform3DNode, Vector3Like } from '@flighthq/types';
1
+ import type { Matrix4Like, Transform3DLike, Transform3DNode, Vector3Like } from '@flighthq/types';
2
2
  export declare function convertNodeVector3GlobalToLocal<Traits extends object>(out: Vector3Like, source: Transform3DNode<Traits>, point: Readonly<Vector3Like>): void;
3
3
  export declare function convertNodeVector3LocalToGlobal<Traits extends object>(out: Vector3Like, source: Transform3DNode<Traits>, point: Readonly<Vector3Like>): void;
4
- export declare function ensureNodeWorldTransformMatrix4<Traits extends object>(target: Transform3DNode<Traits>): void;
5
- export declare function getNodeWorldTransformMatrix4<Traits extends object>(target: Transform3DNode<Traits>): Readonly<Matrix4Like>;
4
+ export declare function ensureNodeLocalMatrix4<Traits extends object>(target: Transform3DNode<Traits>): void;
5
+ export declare function ensureNodeWorldMatrix4<Traits extends object>(target: Transform3DNode<Traits>): void;
6
+ export declare function getNodeLocalMatrix4<Traits extends object>(target: Transform3DNode<Traits>): Readonly<Matrix4Like>;
7
+ export declare function getNodeTransform3D<Traits extends object>(out: Transform3DLike, source: Transform3DNode<Traits>): void;
8
+ export declare function getNodeWorldMatrix4<Traits extends object>(target: Transform3DNode<Traits>): Readonly<Matrix4Like>;
9
+ export declare function isNodeLocalMatrix4Detached<Traits extends object>(target: Transform3DNode<Traits>): boolean;
10
+ export declare function setNodeLocalMatrix4<Traits extends object>(target: Transform3DNode<Traits>, source: Readonly<Matrix4Like>): void;
11
+ export declare function setNodeTransform3D<Traits extends object>(target: Transform3DNode<Traits>, source: Readonly<Transform3DLike>): void;
12
+ export declare function syncNodeTransform3DFromMatrix4<Traits extends object>(target: Transform3DNode<Traits>): void;
6
13
  //# sourceMappingURL=transform3d.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform3d.d.ts","sourceRoot":"","sources":["../src/transform3d.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAyB,WAAW,EAAe,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAIrH,wBAAgB,+BAA+B,CAAC,MAAM,SAAS,MAAM,EACnE,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,EAC/B,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,GAC3B,IAAI,CAMN;AAED,wBAAgB,+BAA+B,CAAC,MAAM,SAAS,MAAM,EACnE,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,EAC/B,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,GAC3B,IAAI,CAEN;AAED,wBAAgB,+BAA+B,CAAC,MAAM,SAAS,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,GAAG,IAAI,CAmB5G;AAED,wBAAgB,4BAA4B,CAAC,MAAM,SAAS,MAAM,EAChE,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,GAC9B,QAAQ,CAAC,WAAW,CAAC,CAGvB"}
1
+ {"version":3,"file":"transform3d.d.ts","sourceRoot":"","sources":["../src/transform3d.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAEV,WAAW,EAEX,eAAe,EACf,eAAe,EACf,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAIzB,wBAAgB,+BAA+B,CAAC,MAAM,SAAS,MAAM,EACnE,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,EAC/B,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,GAC3B,IAAI,CAMN;AAED,wBAAgB,+BAA+B,CAAC,MAAM,SAAS,MAAM,EACnE,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,eAAe,CAAC,MAAM,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'@flighthq/entity';
2
- import { acquireMatrix4, copyMatrix4, createMatrix4, inverseMatrix4, matrix4TransformPoint, multiplyMatrix4, releaseMatrix4, } from '@flighthq/geometry';
3
- import { computeNodeWorldTransformRevision } from './revision';
2
+ import { acquireMatrix4, composeMatrix4, copyMatrix4, copyQuaternion, copyVector3, createMatrix4, decomposeMatrix4, inverseMatrix4, matrix4TransformPoint, multiplyMatrix4, releaseMatrix4, } from '@flighthq/geometry';
3
+ import { computeNodeWorldTransformRevision, invalidateNodeLocalTransform } from './revision';
4
4
  export function convertNodeVector3GlobalToLocal(out, source, point) {
5
5
  // Acquire from pool instead of allocating to avoid hot-path GC pressure.
6
6
  const inv = acquireMatrix4();
7
- inverseMatrix4(inv, getNodeWorldTransformMatrix4(source));
7
+ inverseMatrix4(inv, getNodeWorldMatrix4(source));
8
8
  matrix4TransformPoint(out, inv, point);
9
9
  releaseMatrix4(inv);
10
10
  }
11
11
  export function convertNodeVector3LocalToGlobal(out, source, point) {
12
- matrix4TransformPoint(out, getNodeWorldTransformMatrix4(source), point);
12
+ matrix4TransformPoint(out, getNodeWorldMatrix4(source), point);
13
13
  }
14
- export function ensureNodeWorldTransformMatrix4(target) {
14
+ // Ensures the cached local matrix is current. Recomposes it from translation/rotation/scale when the
15
+ // local transform is dirty — unless it was set directly (setNodeLocalMatrix4 pre-satisfies the dirty
16
+ // check so the detached matrix survives).
17
+ export function ensureNodeLocalMatrix4(target) {
18
+ const runtime = getEntityRuntime(target);
19
+ if (runtime.localMatrix4 === null || runtime.localTransformUsingLocalTransformId !== runtime.localTransformId) {
20
+ recomputeLocalTransform3D(target, runtime);
21
+ }
22
+ }
23
+ export function ensureNodeWorldMatrix4(target) {
15
24
  const runtime = getEntityRuntime(target);
16
25
  const parent = runtime.parent;
17
26
  let parentRuntime;
18
27
  let parentWorldTransformId = 0;
19
28
  if (parent !== null) {
20
- ensureNodeWorldTransformMatrix4(parent);
29
+ ensureNodeWorldMatrix4(parent);
21
30
  parentRuntime = getEntityRuntime(parent);
22
31
  parentWorldTransformId = parentRuntime.worldTransformId;
23
32
  }
@@ -26,19 +35,76 @@ export function ensureNodeWorldTransformMatrix4(target) {
26
35
  recomputeWorldTransform3D(target, runtime, parentRuntime);
27
36
  }
28
37
  }
29
- export function getNodeWorldTransformMatrix4(target) {
30
- ensureNodeWorldTransformMatrix4(target);
31
- return getEntityRuntime(target).worldMatrix;
38
+ export function getNodeLocalMatrix4(target) {
39
+ ensureNodeLocalMatrix4(target);
40
+ return getEntityRuntime(target).localMatrix4;
41
+ }
42
+ // Reads the node's decomposed local transform (translation/rotation/scale) into `out`. When the local
43
+ // matrix is detached (set directly), these fields are dormant; call syncNodeTransform3DFromMatrix4
44
+ // first to reflect the matrix.
45
+ export function getNodeTransform3D(out, source) {
46
+ copyVector3(out.position, source.position);
47
+ copyQuaternion(out.rotation, source.rotation);
48
+ copyVector3(out.scale, source.scale);
49
+ }
50
+ export function getNodeWorldMatrix4(target) {
51
+ ensureNodeWorldMatrix4(target);
52
+ return getEntityRuntime(target).worldMatrix4;
53
+ }
54
+ // True when the local matrix was set directly (setNodeLocalMatrix4) and the translation/rotation/scale
55
+ // fields have not since been reattached by a TRS write or syncNodeTransform3DFromMatrix4. Diagnostic.
56
+ // Resolves the local matrix first so a pending TRS write reports as reattached rather than stale.
57
+ export function isNodeLocalMatrix4Detached(target) {
58
+ ensureNodeLocalMatrix4(target);
59
+ return getEntityRuntime(target).localMatrix4Detached;
60
+ }
61
+ // Sets the node's local matrix directly, bypassing translation/rotation/scale. The matrix is copied
62
+ // (the node owns its storage) and marked detached: the TRS fields go dormant and are not recomposed
63
+ // over it until a TRS write or syncNodeTransform3DFromMatrix4. Bumps the local transform revision so
64
+ // world and render refresh, then pre-satisfies the local recompute so the set matrix survives.
65
+ export function setNodeLocalMatrix4(target, source) {
66
+ const runtime = getEntityRuntime(target);
67
+ if (runtime.localMatrix4 === null)
68
+ runtime.localMatrix4 = createMatrix4();
69
+ copyMatrix4(runtime.localMatrix4, source);
70
+ invalidateNodeLocalTransform(target);
71
+ runtime.localTransformUsingLocalTransformId = runtime.localTransformId;
72
+ runtime.localMatrix4Detached = true;
73
+ }
74
+ // Sets the node's local transform from a decomposed carrier, reattaching TRS authoring (clears the
75
+ // detached state via the recompute) and rebuilding the matrix cache from the fields.
76
+ export function setNodeTransform3D(target, source) {
77
+ copyVector3(target.position, source.position);
78
+ copyQuaternion(target.rotation, source.rotation);
79
+ copyVector3(target.scale, source.scale);
80
+ invalidateNodeLocalTransform(target);
81
+ }
82
+ // Reattaches the TRS fields to a directly-set matrix by decomposing it into translation/rotation/scale
83
+ // (best-effort: lossy on shear). Non-destructive — the matrix cache is unchanged and stays authoritative
84
+ // until a subsequent TRS write. Clears the detached state.
85
+ export function syncNodeTransform3DFromMatrix4(target) {
86
+ const runtime = getEntityRuntime(target);
87
+ ensureNodeLocalMatrix4(target);
88
+ decomposeMatrix4(target.position, target.rotation, target.scale, runtime.localMatrix4);
89
+ runtime.localMatrix4Detached = false;
90
+ }
91
+ function recomputeLocalTransform3D(target, runtime) {
92
+ if (runtime.localMatrix4 === null)
93
+ runtime.localMatrix4 = createMatrix4();
94
+ composeMatrix4(runtime.localMatrix4, target.position, target.rotation, target.scale);
95
+ runtime.localMatrix4Detached = false;
96
+ runtime.localTransformUsingLocalTransformId = runtime.localTransformId;
32
97
  }
33
98
  function recomputeWorldTransform3D(target, runtime, parentRuntime) {
34
- if (runtime.worldMatrix === null) {
35
- runtime.worldMatrix = createMatrix4();
99
+ if (runtime.worldMatrix4 === null) {
100
+ runtime.worldMatrix4 = createMatrix4();
36
101
  }
102
+ ensureNodeLocalMatrix4(target);
37
103
  if (parentRuntime !== undefined) {
38
- multiplyMatrix4(runtime.worldMatrix, parentRuntime.worldMatrix, target.localMatrix);
104
+ multiplyMatrix4(runtime.worldMatrix4, parentRuntime.worldMatrix4, runtime.localMatrix4);
39
105
  }
40
106
  else {
41
- copyMatrix4(runtime.worldMatrix, target.localMatrix);
107
+ copyMatrix4(runtime.worldMatrix4, runtime.localMatrix4);
42
108
  }
43
109
  computeNodeWorldTransformRevision(runtime, parentRuntime);
44
110
  }
@@ -1 +1 @@
1
- {"version":3,"file":"transform3d.js","sourceRoot":"","sources":["../src/transform3d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,cAAc,EACd,WAAW,EACX,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,eAAe,EACf,cAAc,GACf,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AAE/D,MAAM,UAAU,+BAA+B,CAC7C,GAAgB,EAChB,MAA+B,EAC/B,KAA4B;IAE5B,yEAAyE;IACzE,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;IAC7B,cAAc,CAAC,GAAG,EAAE,4BAA4B,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1D,qBAAqB,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACvC,cAAc,CAAC,GAAG,CAAC,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC7C,GAAgB,EAChB,MAA+B,EAC/B,KAA4B;IAE5B,qBAAqB,CAAC,GAAG,EAAE,4BAA4B,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAwB,MAA+B;IACpG,MAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAgD,CAAC;IACxF,MAAM,MAAM,GAAG,OAAO,CAAC,MAAwC,CAAC;IAEhE,IAAI,aAAwE,CAAC;IAC7E,IAAI,sBAAsB,GAAG,CAAC,CAAC;IAE/B,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,+BAA+B,CAAC,MAAM,CAAC,CAAC;QACxC,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAgD,CAAC;QACxF,sBAAsB,GAAG,aAAa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,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,IAAI,CA+CN;AAED,wBAAgB,cAAc,CAAC,MAAM,SAAS,MAAM,GAAG,UAAU,EAC/D,GAAG,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GACxC,QAAQ,CAAC,MAAM,CAAC,CAMlB"}
package/dist/viewport.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { createEntity } from '@flighthq/entity';
1
2
  import { createRectangle } from '@flighthq/geometry';
2
3
  import { getNodeRuntime } from './node';
3
4
  export function computeViewportAlignX(scaledContentWidth, viewWidth, align) {
@@ -68,11 +69,11 @@ export function computeViewportRenderTransform(out, scene, viewWidth, viewHeight
68
69
  out.ty = computeViewportAlignY(contentHeight * sy, viewHeight, scene.align);
69
70
  }
70
71
  export function createViewport(obj) {
71
- return {
72
+ return createEntity({
72
73
  align: obj?.align ?? 'topleft',
73
74
  root: obj?.root ?? null,
74
75
  scaleMode: obj?.scaleMode ?? 'noscale',
75
- };
76
+ });
76
77
  }
77
78
  const _tempRectangle = createRectangle();
78
79
  //# sourceMappingURL=viewport.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"viewport.js","sourceRoot":"","sources":["../src/viewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAUrD,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,UAAU,qBAAqB,CAAC,kBAA0B,EAAE,SAAiB,EAAE,KAAoB;IACvG,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,CAAC,CAAC;IACrC,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,SAAS,GAAG,kBAAkB,CAAC;IACnE,OAAO,CAAC,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,qB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GAAG,EAAE,IAAI,IAAI,IAAI;QACvB,SAAS,EAAE,GAAG,EAAE,SAAS,IAAI,SAAS;KACvC,CAAqB,CAAC;AACzB,CAAC;AAED,MAAM,cAAc,GAAc,eAAe,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flighthq/node",
3
- "version": "0.2.0",
3
+ "version": "0.2.1-next.410.a23f189",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/flighthq/flight.git",
@@ -32,10 +32,10 @@
32
32
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
33
33
  },
34
34
  "dependencies": {
35
- "@flighthq/entity": "0.2.0",
36
- "@flighthq/geometry": "0.2.0",
37
- "@flighthq/signals": "0.2.0",
38
- "@flighthq/types": "0.2.0"
35
+ "@flighthq/entity": "0.2.1-next.410.a23f189",
36
+ "@flighthq/geometry": "0.2.1-next.410.a23f189",
37
+ "@flighthq/signals": "0.2.1-next.410.a23f189",
38
+ "@flighthq/types": "0.2.1-next.410.a23f189"
39
39
  },
40
40
  "devDependencies": {
41
41
  "typescript": "^5.3.0"
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  addNodeChild,
11
11
  createNode,
12
- ensureNodeLocalTransformMatrix,
12
+ ensureNodeLocalMatrix,
13
13
  initTransform2DRuntimeTrait,
14
14
  initTransform2DTrait,
15
15
  invalidateNodeLocalTransform,
@@ -332,7 +332,7 @@ describe('ensureNodeWorldBoundsRectangle', () => {
332
332
  const cache = cloneRectangle(runtime.worldBoundsRectangle!);
333
333
  parent.scaleX = 2;
334
334
  invalidateNodeLocalTransform(parent);
335
- ensureNodeLocalTransformMatrix(parent);
335
+ ensureNodeLocalMatrix(parent);
336
336
  ensureNodeWorldBoundsRectangle(child);
337
337
  expect(runtime.worldBoundsRectangle).not.toEqual(cache);
338
338
  expect(equalsRectangle(runtime.worldBoundsRectangle, { x: 0, y: 0, width: 20, height: 0 })).toBe(true);
@@ -1,5 +1,4 @@
1
1
  import type { HasAppearance } from '@flighthq/types';
2
- import { BlendMode } from '@flighthq/types';
3
2
 
4
3
  import { initAppearanceTrait } from './hasAppearance';
5
4
  import { createNode } from './node';
@@ -17,7 +16,6 @@ describe('initAppearanceTrait', () => {
17
16
  initAppearanceTrait(target);
18
17
 
19
18
  expect(target.alpha).toBe(1);
20
- expect(target.blendMode).toBeNull();
21
19
  expect(target.visible).toBe(true);
22
20
  });
23
21
 
@@ -27,14 +25,6 @@ describe('initAppearanceTrait', () => {
27
25
 
28
26
  expect(target.alpha).toBe(0.5);
29
27
  expect(target.visible).toBe(false);
30
- expect(target.blendMode).toBeNull();
31
- });
32
-
33
- it('applies blendMode override', () => {
34
- const target = makeTarget();
35
- initAppearanceTrait(target, { blendMode: BlendMode.Add });
36
-
37
- expect(target.blendMode).toBe(BlendMode.Add);
38
28
  });
39
29
 
40
30
  it('overwrites existing values', () => {
@@ -0,0 +1,25 @@
1
+ import type { HasBlendMode } from '@flighthq/types';
2
+ import { BlendMode } from '@flighthq/types';
3
+
4
+ import { initBlendModeTrait } from './hasBlendMode';
5
+ import { createNode } from './node';
6
+
7
+ const TestKind = 'Test';
8
+
9
+ function makeTarget(): HasBlendMode {
10
+ return createNode(TestKind) as unknown as HasBlendMode;
11
+ }
12
+
13
+ describe('initBlendModeTrait', () => {
14
+ it('defaults blendMode to null', () => {
15
+ const target = makeTarget();
16
+ initBlendModeTrait(target);
17
+ expect(target.blendMode).toBeNull();
18
+ });
19
+
20
+ it('applies a blendMode override', () => {
21
+ const target = makeTarget();
22
+ initBlendModeTrait(target, { blendMode: BlendMode.Add });
23
+ expect(target.blendMode).toBe(BlendMode.Add);
24
+ });
25
+ });
@@ -13,11 +13,11 @@ describe('initTransform2DRuntimeTrait', () => {
13
13
  it('initializes default values', () => {
14
14
  initTransform2DRuntimeTrait(runtime);
15
15
 
16
- expect(runtime.localTransform2D).toBeNull();
16
+ expect(runtime.localMatrix).toBeNull();
17
17
  expect(runtime.rotationAngle).toStrictEqual(0);
18
18
  expect(runtime.rotationCosine).toStrictEqual(1);
19
19
  expect(runtime.rotationSine).toStrictEqual(0);
20
- expect(runtime.worldTransform2D).toBeNull();
20
+ expect(runtime.worldMatrix).toBeNull();
21
21
 
22
22
  // inherited graph runtime fields
23
23
  expect(runtime.appearanceId).toStrictEqual(0);
@@ -1,37 +1,36 @@
1
- import type { HasTransform3D, HasTransform3DRuntime, Matrix4 } from '@flighthq/types';
1
+ import { createQuaternion, createVector3 } from '@flighthq/geometry';
2
+ import type { HasTransform3D, HasTransform3DRuntime } from '@flighthq/types';
2
3
  import { describe, expect, it } from 'vitest';
3
4
 
4
5
  import { initTransform3DRuntimeTrait, initTransform3DTrait } from './hasTransform3d';
5
6
 
6
7
  describe('initTransform3DRuntimeTrait', () => {
7
- it('sets worldMatrix to null', () => {
8
+ it('nulls the matrix caches and clears the detached flag', () => {
8
9
  const runtime = {} as HasTransform3DRuntime;
9
10
  initTransform3DRuntimeTrait(runtime);
10
- expect(runtime.worldMatrix).toBeNull();
11
+ expect(runtime.localMatrix4).toBeNull();
12
+ expect(runtime.worldMatrix4).toBeNull();
13
+ expect(runtime.localMatrix4Detached).toBe(false);
11
14
  });
12
15
  });
13
16
 
14
17
  describe('initTransform3DTrait', () => {
15
- it('creates an identity localMatrix by default', () => {
18
+ it('defaults to identity position/rotation/scale', () => {
16
19
  const node = {} as HasTransform3D;
17
20
  initTransform3DTrait(node);
18
- expect(node.localMatrix).toBeDefined();
19
- const m = node.localMatrix.m;
20
- expect(m[0]).toBe(1);
21
- expect(m[5]).toBe(1);
22
- expect(m[10]).toBe(1);
23
- expect(m[15]).toBe(1);
24
- expect(m[12]).toBe(0);
25
- expect(m[13]).toBe(0);
26
- expect(m[14]).toBe(0);
21
+ expect(node.position).toMatchObject({ x: 0, y: 0, z: 0 });
22
+ expect(node.rotation).toMatchObject({ x: 0, y: 0, z: 0, w: 1 });
23
+ expect(node.scale).toMatchObject({ x: 1, y: 1, z: 1 });
27
24
  });
28
25
 
29
- it('accepts an existing localMatrix', () => {
26
+ it('accepts existing position/rotation/scale', () => {
30
27
  const node = {} as HasTransform3D;
31
- const existing = { m: new Float32Array(16) } as unknown as Matrix4;
32
- existing.m[12] = 7;
33
- initTransform3DTrait(node, { localMatrix: existing });
34
- expect(node.localMatrix).toBe(existing);
35
- expect(node.localMatrix.m[12]).toBe(7);
28
+ const position = createVector3(7, 0, 0);
29
+ const rotation = createQuaternion();
30
+ const scale = createVector3(2, 2, 2);
31
+ initTransform3DTrait(node, { position, rotation, scale });
32
+ expect(node.position).toBe(position);
33
+ expect(node.rotation).toBe(rotation);
34
+ expect(node.scale).toBe(scale);
36
35
  });
37
36
  });
@@ -31,7 +31,7 @@ import {
31
31
  } from './hierarchy';
32
32
  import { createNode, enableNodeSignals, getNodeRuntime } from './node';
33
33
  import { invalidateNodeLocalTransform } from './revision';
34
- import { getNodeWorldTransformMatrix } from './transform2d';
34
+ import { getNodeWorldMatrix } from './transform2d';
35
35
 
36
36
  let container: Node<NodeTraits>;
37
37
  let childA: Node<NodeTraits>;
@@ -650,7 +650,7 @@ describe('reparentNode', () => {
650
650
  invalidateNodeLocalTransform(child);
651
651
  addNodeChild(parentA, child);
652
652
 
653
- const before = cloneMatrix(getNodeWorldTransformMatrix(child));
653
+ const before = cloneMatrix(getNodeWorldMatrix(child));
654
654
 
655
655
  const parentB = createTransformNode();
656
656
  parentB.x = 200;
@@ -658,7 +658,7 @@ describe('reparentNode', () => {
658
658
  invalidateNodeLocalTransform(parentB);
659
659
 
660
660
  reparentNode(child, parentB);
661
- const after = getNodeWorldTransformMatrix(child);
661
+ const after = getNodeWorldMatrix(child);
662
662
 
663
663
  expect(after.a).toBeCloseTo(before.a, 10);
664
664
  expect(after.b).toBeCloseTo(before.b, 10);
@@ -680,13 +680,13 @@ describe('reparentNode', () => {
680
680
  invalidateNodeLocalTransform(child);
681
681
  addNodeChild(parentA, child);
682
682
 
683
- const before = cloneMatrix(getNodeWorldTransformMatrix(child));
683
+ const before = cloneMatrix(getNodeWorldMatrix(child));
684
684
 
685
685
  const parentB = createTransformNode();
686
686
  invalidateNodeLocalTransform(parentB);
687
687
 
688
688
  reparentNode(child, parentB);
689
- const after = getNodeWorldTransformMatrix(child);
689
+ const after = getNodeWorldMatrix(child);
690
690
 
691
691
  expect(after.a).toBeCloseTo(before.a, 10);
692
692
  expect(after.b).toBeCloseTo(before.b, 10);
@@ -733,14 +733,14 @@ describe('reparentNode', () => {
733
733
  invalidateNodeLocalTransform(child);
734
734
  addNodeChild(parentA, child);
735
735
 
736
- const before = cloneMatrix(getNodeWorldTransformMatrix(child));
736
+ const before = cloneMatrix(getNodeWorldMatrix(child));
737
737
 
738
738
  const parentB = createTransformNode();
739
739
  parentB.x = 200;
740
740
  invalidateNodeLocalTransform(parentB);
741
741
 
742
742
  reparentNode(child, parentB);
743
- const after = getNodeWorldTransformMatrix(child);
743
+ const after = getNodeWorldMatrix(child);
744
744
 
745
745
  expect(after.a).toBeCloseTo(before.a, 10);
746
746
  expect(after.b).toBeCloseTo(before.b, 10);
@@ -758,7 +758,7 @@ describe('reparentNode', () => {
758
758
  child.scaleX = 1.5;
759
759
  invalidateNodeLocalTransform(child);
760
760
 
761
- const before = cloneMatrix(getNodeWorldTransformMatrix(child));
761
+ const before = cloneMatrix(getNodeWorldMatrix(child));
762
762
 
763
763
  const parentB = createTransformNode();
764
764
  parentB.x = 50;
@@ -767,7 +767,7 @@ describe('reparentNode', () => {
767
767
  invalidateNodeLocalTransform(parentB);
768
768
 
769
769
  reparentNode(child, parentB);
770
- const after = getNodeWorldTransformMatrix(child);
770
+ const after = getNodeWorldMatrix(child);
771
771
 
772
772
  expect(after.a).toBeCloseTo(before.a, 10);
773
773
  expect(after.b).toBeCloseTo(before.b, 10);
@@ -789,14 +789,14 @@ describe('reparentNode', () => {
789
789
  invalidateNodeLocalTransform(child);
790
790
  addNodeChild(parentA, child);
791
791
 
792
- const before = cloneMatrix(getNodeWorldTransformMatrix(child));
792
+ const before = cloneMatrix(getNodeWorldMatrix(child));
793
793
 
794
794
  const parentB = createTransformNode();
795
795
  parentB.x = 100;
796
796
  invalidateNodeLocalTransform(parentB);
797
797
 
798
798
  reparentNode(child, parentB);
799
- const after = getNodeWorldTransformMatrix(child);
799
+ const after = getNodeWorldMatrix(child);
800
800
 
801
801
  expect(after.a).toBeCloseTo(before.a, 10);
802
802
  expect(after.b).toBeCloseTo(before.b, 10);
@@ -821,13 +821,13 @@ describe('reparentNode', () => {
821
821
  invalidateNodeLocalTransform(child);
822
822
  addNodeChild(parentA, child);
823
823
 
824
- const before = cloneMatrix(getNodeWorldTransformMatrix(child));
824
+ const before = cloneMatrix(getNodeWorldMatrix(child));
825
825
 
826
826
  const identityParent = createTransformNode();
827
827
  invalidateNodeLocalTransform(identityParent);
828
828
 
829
829
  reparentNode(child, identityParent);
830
- const after = getNodeWorldTransformMatrix(child);
830
+ const after = getNodeWorldMatrix(child);
831
831
 
832
832
  expect(after.a).toBeCloseTo(before.a, 10);
833
833
  expect(after.b).toBeCloseTo(before.b, 10);