Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions packages/editor/src/lib/history.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@ function runSourceHistoryTest(body: string) {
import assert from 'node:assert/strict'
import { mock } from 'bun:test'
import { fileURLToPath, pathToFileURL } from 'node:url'
const consumers = [
${JSON.stringify(resolve(import.meta.dir, 'history.ts'))},
${JSON.stringify(resolve(import.meta.dir, '../../../core/src/index.ts'))},
${JSON.stringify(resolve(import.meta.dir, '../../../viewer/src/systems/wall/wall-system.tsx'))},
${JSON.stringify(resolve(import.meta.dir, '../../../nodes/src/shared/node-batch/system.tsx'))},
const editorConsumer = ${JSON.stringify(resolve(import.meta.dir, 'history.ts'))}
const coreConsumer = ${JSON.stringify(resolve(import.meta.dir, '../../../core/src/index.ts'))}
const viewerConsumer = ${JSON.stringify(resolve(import.meta.dir, '../../../viewer/src/systems/wall/wall-system.tsx'))}
const nodesConsumer = ${JSON.stringify(resolve(import.meta.dir, '../../../nodes/src/shared/node-batch/system.tsx'))}
const peerConsumers = [editorConsumer, coreConsumer, viewerConsumer, nodesConsumer]
// Resolve only from declared consumers; isolated installs cannot see sibling dependencies.
const sharedConsumers = [
['@pascal-app/core', [editorConsumer, viewerConsumer, nodesConsumer]],
['@pascal-app/viewer', [editorConsumer, nodesConsumer]],
['react', peerConsumers],
['three', peerConsumers],
['@react-three/fiber', peerConsumers],
]
const sharedPaths = new Map(
['@pascal-app/core', '@pascal-app/viewer', 'react', 'three', '@react-three/fiber'].map(specifier => [
sharedConsumers.map(([specifier, consumers]) => [
specifier,
[...new Set(consumers.map(consumer => fileURLToPath(import.meta.resolve(specifier, pathToFileURL(consumer).href))))],
]),
Expand Down
50 changes: 25 additions & 25 deletions packages/nodes/src/lean-to-extension/mono-j-rendering.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,33 +221,33 @@ describe('continuous mono canopy rendering', () => {
expect(extendedChain.overlaps).toBe(0)
})

test('miters either turn and slope direction throughout the angle range', () => {
for (const angle of Array.from({ length: 90 }, (_, index) => 90 - index)) {
const radians = (angle * Math.PI) / 180
const corner: Pt = [8, 0]
const forwardEnd: Pt = [8 + 6 * Math.cos(radians), 6 * Math.sin(radians)]
const mirroredEnd: Pt = [8 + 6 * Math.cos(radians), -6 * Math.sin(radians)]
const paths = [
[[0, 0] as Pt, corner, forwardEnd],
[forwardEnd, corner, [0, 0] as Pt],
[[0, 0] as Pt, corner, mirroredEnd],
[mirroredEnd, corner, [0, 0] as Pt],
]

for (const [pathIndex, points] of paths.entries()) {
for (const flipProjection of [false, true]) {
const result = buildCanopy(
`angle_${angle}_path_${pathIndex}_flip_${flipProjection}`,
points,
flipProjection,
)
expect(result.holes).toBe(0)
expect(result.overlaps).toBe(0)
expect(result.totalVertical).toBeLessThan(0.05)
}
test.each(
Array.from({ length: 90 }, (_, index) => 90 - index),
)('miters either turn and slope direction at %i degrees', (angle) => {
const radians = (angle * Math.PI) / 180
const corner: Pt = [8, 0]
const forwardEnd: Pt = [8 + 6 * Math.cos(radians), 6 * Math.sin(radians)]
const mirroredEnd: Pt = [8 + 6 * Math.cos(radians), -6 * Math.sin(radians)]
const paths = [
[[0, 0] as Pt, corner, forwardEnd],
[forwardEnd, corner, [0, 0] as Pt],
[[0, 0] as Pt, corner, mirroredEnd],
[mirroredEnd, corner, [0, 0] as Pt],
]

for (const [pathIndex, points] of paths.entries()) {
for (const flipProjection of [false, true]) {
const result = buildCanopy(
`angle_${angle}_path_${pathIndex}_flip_${flipProjection}`,
points,
flipProjection,
)
expect(result.holes).toBe(0)
expect(result.overlaps).toBe(0)
expect(result.totalVertical).toBeLessThan(0.05)
}
}
}, 15_000)
})

// J-shapes and closed loops use the same corner partitioning as an L at each end.
const multiJointShapes: Record<string, Pt[]> = {
Expand Down
16 changes: 11 additions & 5 deletions packages/nodes/src/shared/node-batch/source-systems.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@ function runSourceTest(body: string) {

// Isolated installs can give each tested package its own peer module instance.
// Share the viewer's instance across every resolved path before loading consumers.
const consumers = [
${sourcePath('packages/viewer/src/lib/materials.ts')},
${sourcePath('packages/nodes/src/shared/node-batch/system.tsx')},
${sourcePath('packages/editor/src/components/editor/selection-manager.tsx')},
const viewerConsumer = ${sourcePath('packages/viewer/src/lib/materials.ts')}
const nodesConsumer = ${sourcePath('packages/nodes/src/shared/node-batch/system.tsx')}
const editorConsumer = ${sourcePath('packages/editor/src/components/editor/selection-manager.tsx')}
const consumers = [viewerConsumer, nodesConsumer, editorConsumer]
const sharedConsumers = [
['react', consumers],
['three', consumers],
['@react-three/fiber', consumers],
['@pascal-app/core', consumers],
['@pascal-app/viewer', [nodesConsumer, editorConsumer]],
]
const sharedPaths = new Map(
['react', 'three', '@react-three/fiber', '@pascal-app/core', '@pascal-app/viewer'].map((specifier) => [
sharedConsumers.map(([specifier, consumers]) => [
specifier,
[...new Set(consumers.map((consumer) => fileURLToPath(import.meta.resolve(specifier, pathToFileURL(consumer).href))))],
]),
Expand Down
Loading