AI-native design editor. Open-source Figma alternative.
test: import geometry helpers from scene graph package
Danila Poyarkov5487f659da63
diff --git a/packages/scene-graph/src/index.ts b/packages/scene-graph/src/index.tsindex a90d60d3d..74bb220f8 100644--- a/packages/scene-graph/src/index.ts+++ b/packages/scene-graph/src/index.ts@@ -1,6 +1,9 @@export * from './images'export * from './snap'export * from './export-scale'+export * from './geometry'+export { default as TransformMatrix } from './matrix'+export type { Mat3 } from './matrix'export { UndoManager, type UndoEntry, type UndoManagerOptions } from './undo'import { omit } from 'es-toolkit/object'@@ -128,7 +131,6 @@ export class SceneGraph {}return count}- // --- Variables ---addVariable(variable: Variable): void {Variables.addVariable(this, variable)}@@ -415,7 +417,6 @@ export class SceneGraph {const oldParentId = node.parentIdthis.absPosCache.clear()- // Convert absolute positionconst absPos = this.getAbsolutePosition(nodeId)const newParentNode = this.nodes.get(newParentId)const newParentAbs =@@ -423,16 +424,13 @@ export class SceneGraph {? { x: 0, y: 0 }: this.getAbsolutePosition(newParentId)- // Remove from old parentif (oldParent) {oldParent.childIds = oldParent.childIds.filter((cid) => cid !== nodeId)}- // Add to new parentnode.parentId = newParentIdnewParent.childIds.push(nodeId)- // Adjust position so node stays in same visual placenode.x = absPos.x - newParentAbs.xnode.y = absPos.y - newParentAbs.ydiff --git a/tests/engine/geometry/angles.test.ts b/tests/engine/geometry/angles.test.tsindex 250a8b7b2..8da2b8e67 100644--- a/tests/engine/geometry/angles.test.ts+++ b/tests/engine/geometry/angles.test.ts@@ -1,6 +1,6 @@import { describe, test, expect } from 'bun:test'-import { degToRad, radToDeg } from '@open-pencil/core'+import { degToRad, radToDeg } from '@open-pencil/scene-graph'describe('degToRad / radToDeg', () => {test('degToRad converts degrees to radians', () => {diff --git a/tests/engine/geometry/bounds.test.ts b/tests/engine/geometry/bounds.test.tsindex 200a1f2a3..5d4ce7803 100644--- a/tests/engine/geometry/bounds.test.ts+++ b/tests/engine/geometry/bounds.test.ts@@ -1,6 +1,6 @@import { describe, test, expect } from 'bun:test'-import { computeAbsoluteBounds, computeBounds, type Vector } from '@open-pencil/core'+import { computeAbsoluteBounds, computeBounds, type Vector } from '@open-pencil/scene-graph'describe('computeBounds', () => {test('empty iterable returns zero rect', () => {diff --git a/tests/engine/geometry/matrix.test.ts b/tests/engine/geometry/matrix.test.tsindex cf791c830..88ec6a0a0 100644--- a/tests/engine/geometry/matrix.test.ts+++ b/tests/engine/geometry/matrix.test.ts@@ -7,7 +7,7 @@*/import { describe, test, expect } from 'bun:test'-import { TransformMatrix } from '@open-pencil/core'+import { TransformMatrix } from '@open-pencil/scene-graph'import { expectDefined } from '#tests/helpers/assert'diff --git a/tests/engine/geometry/rotation.test.ts b/tests/engine/geometry/rotation.test.tsindex 8899275b9..1e181872d 100644--- a/tests/engine/geometry/rotation.test.ts+++ b/tests/engine/geometry/rotation.test.ts@@ -1,6 +1,6 @@import { describe, test, expect } from 'bun:test'-import { rotatePoint, rotatedBBox, rotatedCorners } from '@open-pencil/core'+import { rotatePoint, rotatedBBox, rotatedCorners } from '@open-pencil/scene-graph'describe('rotatePoint', () => {test('no rotation returns same point', () => {