test: import geometry helpers from scene graph package
This commit is contained in:
parent
3a5b6a5c37
commit
5487f659da
|
|
@ -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.parentId
|
||||
this.absPosCache.clear()
|
||||
|
||||
// Convert absolute position
|
||||
const 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 parent
|
||||
if (oldParent) {
|
||||
oldParent.childIds = oldParent.childIds.filter((cid) => cid !== nodeId)
|
||||
}
|
||||
|
||||
// Add to new parent
|
||||
node.parentId = newParentId
|
||||
newParent.childIds.push(nodeId)
|
||||
|
||||
// Adjust position so node stays in same visual place
|
||||
node.x = absPos.x - newParentAbs.x
|
||||
node.y = absPos.y - newParentAbs.y
|
||||
|
||||
|
|
|
|||
|
|
@ -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', () => {
|
||||
|
|
|
|||
|
|
@ -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', () => {
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
||||
|
|
|
|||
|
|
@ -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', () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue