@weasel-js/kernel3d 1.16.1 → 1.16.2

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.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Vec3, Mat4, Quat, Aabb, Ray } from '@weasel-js/geom/3d';
2
- import { PoseComposition, SceneNode, Scene, NodeId, SnapSource, SnapOutcomeStore, AreaSelectDep, NodeAtPointDep, PoseDescriptor, SnapDep, InsertExtras, InsertDep, ViewAim, AimSpace, SnapMark, OngoingHandle, Action, Tool } from '@weasel-js/core';
2
+ import { PoseComposition, SceneNode, Scene, SnapSource, SnapOutcomeStore, AreaSelectDep, NodeAtPointDep, PoseDescriptor, SnapDep, InsertExtras, InsertDep, ViewAim, AimSpace, SnapMark } from '@weasel-js/core/engine';
3
+ import { NodeId, OngoingHandle, Action, Tool } from '@weasel-js/routing';
3
4
  import { KitSettingsStore } from '@weasel-js/react';
4
5
  import { StrokeTrim } from '@weasel-js/paint';
5
6
  import * as _weasel_js_prefs from '@weasel-js/prefs';
@@ -696,4 +697,5 @@ declare const kernel3dKitSettingsSchema: Omit<_weasel_js_prefs.PrefGroup, "child
696
697
  };
697
698
  };
698
699
 
699
- export { type Aim3d, type Aim3dOptions, type Camera3d, type Camera3dDep, type ChromeBox, DEFAULT_ORBIT_LIMITS, type Footprint, type Frustum3d, type GroundGridSourceOptions, HEAD, HEAD_OVERDRAW, type HeadShape, type HeadSize, LINE_FLOATS, type Line3, type LineDrawOptions, type LineLayout, type LinePass, type LineRun3, MAX_PITCH, type Node3d, type NodeBounds, type Orbit3dKitSettings, type OrbitLimits, POSE3_COMPOSITION, type Pose3, type Scene3d, type ScreenBox, type ScreenLine, type ScreenPoint, type Snap3dOptions, UNIT_CUBE, type Viewport3d, type ViewportSource, type VisibleRun3, type World3d, aabbOfPose, aimOf3d, aimSpace3d, alignPlaneSource, boxSnapSource, cameraEye, cameraOfAim3d, cameraView, cameraViewProjection, clampCamera, collectOverlayBoxes, createAreaSelect, createCamera, createInsert, createLinePass, createNodeAtPoint, createPoseDescriptor, createSnap, dollyAction, dollyBy, dollyToward, groundGridSource, headFor, homeAction, kernel3dKitSettingsSchema, layoutLine, ndcToScreen, orbitAction, orbitBy, packLines, panAction, panBy, pinchDollyAction, pose3, poseMatrix, projectAabbToScreen, projectPoint, projectSnapMarks, rayThroughScreenPoint, screenBoxOf, screenToNdc, useOrbitTool, visibleRuns, worldPoseOf };
700
+ export { DEFAULT_ORBIT_LIMITS, HEAD, HEAD_OVERDRAW, LINE_FLOATS, MAX_PITCH, POSE3_COMPOSITION, UNIT_CUBE, aabbOfPose, aimOf3d, aimSpace3d, alignPlaneSource, boxSnapSource, cameraEye, cameraOfAim3d, cameraView, cameraViewProjection, clampCamera, collectOverlayBoxes, createAreaSelect, createCamera, createInsert, createLinePass, createNodeAtPoint, createPoseDescriptor, createSnap, dollyAction, dollyBy, dollyToward, groundGridSource, headFor, homeAction, kernel3dKitSettingsSchema, layoutLine, ndcToScreen, orbitAction, orbitBy, packLines, panAction, panBy, pinchDollyAction, pose3, poseMatrix, projectAabbToScreen, projectPoint, projectSnapMarks, rayThroughScreenPoint, screenBoxOf, screenToNdc, useOrbitTool, visibleRuns, worldPoseOf };
701
+ export type { Aim3d, Aim3dOptions, Camera3d, Camera3dDep, ChromeBox, Footprint, Frustum3d, GroundGridSourceOptions, HeadShape, HeadSize, Line3, LineDrawOptions, LineLayout, LinePass, LineRun3, Node3d, NodeBounds, Orbit3dKitSettings, OrbitLimits, Pose3, Scene3d, ScreenBox, ScreenLine, ScreenPoint, Snap3dOptions, Viewport3d, ViewportSource, VisibleRun3, World3d };
package/dist/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { lookAt, multiply, perspective, add, scale, quatIdentity, compose, transformAabb, quatMultiply, quatConjugate, quatRotate, sub, invert, transformPoint, normalize, transformPoint4, distance, dot, len, aabbOfPoints, intersectRayPlane, pointOnRay, cross, intersectRayAabb } from '@weasel-js/geom/3d';
2
2
  import { clamp, lengthTable, curveSpan, rectsOverlap } from '@weasel-js/geom';
3
- import { scenePoseFrame, createSnapOutcomeStore, assertSnapSourceIds, DEFAULT_SNAP_PX, overlaysOf, resolveOverlays, defineTool, snapSourcesFor, resolvedSnapMarks, SNAP_AXIS_STEP, gatherSnapCandidates, scenePoseAdapter, composeWorldPose } from '@weasel-js/core';
3
+ import { scenePoseFrame, createSnapOutcomeStore, assertSnapSourceIds, DEFAULT_SNAP_PX, resolveOverlays, snapSourcesFor, resolvedSnapMarks, SNAP_AXIS_STEP, gatherSnapCandidates, scenePoseAdapter, composeWorldPose } from '@weasel-js/core/engine';
4
4
  import { isDev } from '@weasel-js/react';
5
5
  import { closestOnFlat, resolveSnap, createBvh, stepLine, createSettledCache } from '@weasel-js/geom/nd';
6
+ import { overlaysOf, defineTool } from '@weasel-js/routing';
6
7
  import { resolveTrim } from '@weasel-js/stroke';
7
8
  import { useMemo } from 'react';
8
9
  import { pref } from '@weasel-js/prefs';
@@ -1582,7 +1583,7 @@ function useOrbitTool() {
1582
1583
  id: "orbit",
1583
1584
  hookName: "useOrbitTool",
1584
1585
  cursor: "grab",
1585
- presentation: { label: "Orbit", group: "viewport" },
1586
+ presentation: { label: "Orbit", group: "view" },
1586
1587
  bindings: [
1587
1588
  { spec: { kind: "drag" }, actionId: "camera.orbit", opts: { id: "orbit.orbit" } },
1588
1589
  { spec: { kind: "drag", mods: { shift: true } }, actionId: "camera.pan", opts: { id: "orbit.pan" } }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/camera.ts","../src/pose3.ts","../src/composePose3.ts","../src/screen.ts","../src/project.ts","../src/ground.ts","../src/world.ts","../src/pickIndex.ts","../src/snap/plane.ts","../src/snap/probes3d.ts","../src/snap/session3d.ts","../src/deps.ts","../src/insert.ts","../src/aim.ts","../src/snap/boxIndex.ts","../src/snap/sources.ts","../src/snap/marks.ts","../src/overlays.ts","../src/lines/head.ts","../src/lines/pack.ts","../src/lines/pass.glsl.ts","../src/lines/pass.ts","../src/tools.ts","../src/kitSettings.ts"],"names":["distance","scale","add","sub","transformPoint4","compose","normalize","dot","ZERO","intersectRayPlane","pointOnRay","cross","build","scaleBy","len","quatIdentity","level","CACHE","boxValid","createBvh","out","transformPoint"],"mappings":";;;;;;;;;;AAmCO,IAAM,SAAA,GAAY,IAAA,CAAK,EAAA,GAAK,CAAA,GAAI;AACvC,IAAM,KAAW,EAAE,CAAA,EAAG,GAAG,CAAA,EAAG,CAAA,EAAG,GAAG,CAAA,EAAE;AAI7B,SAAS,aAAa,IAAA,EAAmC;AAC9D,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,KAAK,MAAA,IAAU,EAAE,GAAG,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAA,EAAE;AAAA,IAC1C,GAAA,EAAK,KAAK,GAAA,IAAO,CAAA;AAAA,IACjB,KAAA,EAAO,KAAK,KAAA,IAAS,CAAA;AAAA,IACrB,QAAA,EAAU,KAAK,QAAA,IAAY,EAAA;AAAA,IAC3B,GAAA,EAAK,IAAA,CAAK,GAAA,IAAO,IAAA,CAAK,EAAA,GAAK,CAAA;AAAA,IAC3B,IAAA,EAAM,KAAK,IAAA,IAAQ,GAAA;AAAA,IACnB,GAAA,EAAK,KAAK,GAAA,IAAO;AAAA,GACnB;AACF;AAGO,SAAS,UAAU,MAAA,EAAwB;AAChD,EAAA,MAAM,EAAE,MAAA,EAAQ,GAAA,EAAK,KAAA,EAAO,QAAA,EAAAA,WAAS,GAAI,MAAA;AACzC,EAAA,MAAM,UAAA,GAAa,IAAA,CAAK,GAAA,CAAI,KAAK,CAAA,GAAIA,SAAAA;AACrC,EAAA,OAAO;AAAA,IACL,GAAG,MAAA,CAAO,CAAA,GAAI,UAAA,GAAa,IAAA,CAAK,IAAI,GAAG,CAAA;AAAA,IACvC,GAAG,MAAA,CAAO,CAAA,GAAI,IAAA,CAAK,GAAA,CAAI,KAAK,CA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it can live in instrument state.\n *\n * This is the shape `ViewApi` cannot hold, and the reason the kernel declares a\n * `camera3d` dep of its own rather than reusing the kit's `view`.\n */\n\nimport {\n add,\n lookAt,\n multiply,\n perspective,\n scale,\n type Mat4,\n type Vec3,\n} from '@weasel-js/geom/3d';\nimport { clamp } from '@weasel-js/geom';\n\n/** An orbit camera. The eye sits `distance` world units from `target` at\n * `yaw`/`pitch`; `fov` is the vertical field of view in radians, and\n * `near`/`far` the clip distances. */\nexport interface Camera3d {\n target: Vec3;\n /** Radians about +y, measured from +z. */\n yaw: number;\n /** Radians above the xz plane. */\n pitch: number;\n distance: number;\n fov: number;\n near: number;\n far: number;\n}\n\n/** Short of vertical: at exactly ±π/2 the eye lands on the up axis and `lookAt` degenerates. */\nexport const MAX_PITCH = Math.PI / 2 - 0.01;\nconst UP: Vec3 = { x: 0, y: 1, z: 0 };\n\n/** A camera with defaults for every field not given: origin target, level at\n * yaw 0, distance 10, fov π/4, near 0.1, far 1000. */\nexport function createCamera(init: Partial<Camera3d>): Camera3d {\n return {\n target: init.target ?? { x: 0, y: 0, z: 0 },\n yaw: init.yaw ?? 0,\n pitch: init.pitch ?? 0,\n distance: init.distance ?? 10,\n fov: init.fov ?? Math.PI / 4,\n near: init.near ?? 0.1,\n far: init.far ?? 1000,\n };\n}\n\n/** The eye's world position. */\nexport function cameraEye(camera: Camera3d): Vec3 {\n const { target, yaw, pitch, distance } = camera;\n const horizontal = Math.cos(pitch) * distance;\n return {\n x: target.x + horizontal * Math.sin(yaw),\n y: target.y + Math.sin(pitch) * distance,\n z: target.z + horizontal * Math.cos(yaw),\n };\n}\n\n/** World-to-view matrix, with +y up. */\nexport function cameraView(camera: Camera3d): Mat4 {\n return lookAt(cameraEye(camera), camera.target, UP);\n}\n\n/** World-to-clip matrix for a pane of the given width/height `aspect`. */\nexport function cameraViewProjection(camera: Camera3d, aspect: number): Mat4 {\n return multiply(perspective(camera.fov, aspect, camera.near, camera.far), cameraView(camera));\n}\n\n/** How far an orbit camera may turn and travel. Distances are in world units,\n * so a scene measured in millimeters and one in kilometers want different ones. */\nexport interface OrbitLimits {\n minDistance: number;\n maxDistance: number;\n /** Radians. Held inside ±`MAX_PITCH` whatever is asked for. */\n minPitch: number;\n maxPitch: number;\n}\n\n/** Pitch short of the poles, distance 0.5..500. */\nexport const DEFAULT_ORBIT_LIMITS: OrbitLimits = {\n minDistance: 0.5,\n maxDistance: 500,\n minPitch: -MAX_PITCH,\n maxPitch: MAX_PITCH,\n};\n\n/** The camera with its pitch and distance inside `limits`. Returns `camera`\n * itself when it already holds. */\nexport function clampCamera(camera: Camera3d, limits: Partial<OrbitLimits> = {}): Camera3d {\n const l = { ...DEFAULT_ORBIT_LIMITS, ...limits };\n const pitch = clamp(camera.pitch, Math.max(-MAX_PITCH, l.minPitch), Math.min(MAX_PITCH, l.maxPitch));\n const distance = clamp(camera.distance, l.minDistance, l.maxDistance);\n if (pitch === camera.pitch && distance === camera.distance) return camera;\n return { ...camera, pitch, distance };\n}\n\n/** The camera turned about its target by the given radians, pitch held inside\n * `limits`. Yaw is not wrapped. */\nexport function orbitBy(\n camera: Camera3d,\n deltaYaw: number,\n deltaPitch: number,\n limits?: Partial<OrbitLimits>,\n): Camera3d {\n return clampCamera(\n { ...camera, yaw: camera.yaw + deltaYaw, pitch: camera.pitch + deltaPitch },\n limits,\n );\n}\n\n/** The camera with its distance multiplied by `factor`, held inside `limits`. */\nexport function dollyBy(camera: Camera3d, factor: number, limits?: Partial<OrbitLimits>): Camera3d {\n return clampCamera({ ...camera, distance: camera.distance * factor }, limits);\n}\n\n/**\n * The camera with its target slid across the screen plane, so the point at the\n * target follows a pointer that moved `dx`, `dy` CSS pixels in a pane\n * `paneHeight` pixels tall. Neither angle nor distance changes.\n */\nexport function panBy(camera: Camera3d, dx: number, dy: number, paneHeight: number): Camera3d {\n if (!(paneHeight > 0)) return camera;\n const perPixel = (2 * camera.distance * Math.tan(camera.fov / 2)) / paneHeight;\n const { yaw, pitch } = camera;\n const right: Vec3 = { x: Math.cos(yaw), y: 0, z: -Math.sin(yaw) };\n const up: Vec3 = {\n x: -Math.sin(yaw) * Math.sin(pitch),\n y: Math.cos(pitch),\n z: -Math.cos(yaw) * Math.sin(pitch),\n };\n const shift = add(scale(right, -dx * perPixel), scale(up, dy * perPixel));\n return { ...camera, target: add(camera.target, shift) };\n}\n\n/**\n * `dollyBy` about a point on the pane rather than its middle: the point in the\n * target's screen-facing plane under `at` — CSS pixels from the pane's\n * top-left, in a pane of `pane` size — stays under it, as a 2D camera's wheel\n * zoom keeps the point under the pointer. The target slides toward that point\n * by as much as the distance shrank, so the next turn pivots nearer it.\n */\nexport function dollyToward(\n camera: Camera3d,\n factor: number,\n at: { x: number; y: number },\n pane: { width: number; height: number },\n limits?: Partial<OrbitLimits>,\n): Camera3d {\n const dollied = dollyBy(camera, factor, limits);\n const kept = 1 - dollied.distance / camera.distance;\n const moved = panBy(\n camera,\n -kept * (at.x - pane.width / 2),\n -kept * (at.y - pane.height / 2),\n pane.height,\n );\n return { ...dollied, target: moved.target };\n}\n","/**\n * A 3D pose, and the two things every consumer of one needs: its matrix, and\n * the world box it occupies.\n *\n * `Scene<TData, TLayer, Pose3>` is the whole of how this reaches weasel —\n * `Scene` is generic over its pose and holds this one with no adapter, no\n * subclass and no special case.\n */\n\nimport {\n compose, quatIdentity, transformAabb, type Aabb, type Mat4, type Quat, type Vec3,\n} from '@weasel-js/geom/3d';\n\n/** Position, rotation and scale of a 3D node. */\nexport interface Pose3 {\n position: Vec3;\n rotation: Quat;\n scale: Vec3;\n}\n\n/** The box a primitive occupies before its pose. A unit primitive centred on\n * its own origin — which is what the kernel assumes nothing about — is\n * `UNIT_CUBE`. */\nexport const UNIT_CUBE: Aabb = {\n min: { x: -0.5, y: -0.5, z: -0.5 },\n max: { x: 0.5, y: 0.5, z: 0.5 },\n};\n\n/** A pose at `position`, unscaled and unrotated unless given. */\nexport function pose3(\n position: Vec3,\n scale: Vec3 = { x: 1, y: 1, z: 1 },\n rotation: Quat = quatIdentity(),\n): Pose3 {\n return { position, rotation, scale };\n}\n\n/** The pose as a matrix: scale, then rotation, then translation to\n * `position`. */\nexport function poseMatrix(pose: Pose3): Mat4 {\n return compose(pose.position, pose.rotation, pose.scale);\n}\n\n/**\n * The world box a posed primitive occupies, given the box it occupies in its\n * own space.\n *\n * Which local box a primitive has is the consumer's answer, not the kernel's:\n * a sphere's is rotation-invariant and a mesh's comes from its vertices, and\n * neither is something a pose can tell you.\n */\nexport function aabbOfPose(pose: Pose3, local: Aabb = UNIT_CUBE): Aabb {\n return transformAabb(poseMatrix(pose), local);\n}\n","/** Container composition for `Pose3`: a child's pose is stored in its\n * container's frame, and folds up to world through every frame above it. */\n\nimport type { PoseComposition } from '@weasel-js/core';\nimport { add, quatConjugate, quatMultiply, quatRotate, sub, type Vec3 } from '@weasel-js/geom/3d';\nimport type { Pose3 } from './pose3';\n\nconst times = (a: Vec3, b: Vec3): Vec3 => ({ x: a.x * b.x, y: a.y * b.y, z: a.z * b.z });\n\n/** `a / s` per axis, reading a collapsed axis (`s` 0) as `zero`: nothing in a\n * zero-scaled frame can be told apart along it. */\nconst over = (a: Vec3, s: Vec3, zero: Vec3): Vec3 => ({\n x: s.x === 0 ? zero.x : a.x / s.x,\n y: s.y === 0 ? zero.y : a.y / s.y,\n z: s.z === 0 ? zero.z : a.z / s.z,\n});\n\nconst ORIGIN: Vec3 = { x: 0, y: 0, z: 0 };\n\n/**\n * Container composition for a 3D scene: a container's position, rotation and\n * scale all reach its children, so moving, turning or growing a container\n * carries everything under it.\n *\n * Exact whenever the container's scale is uniform. Under a non-uniform one a\n * turned child would come out sheared, which no `Pose3` holds; it keeps its\n * own axes instead and takes the container's scale axis by axis. Either way\n * `decompose` undoes `compose`, so a node rebased into a frame and read back\n * lands where it was.\n */\nexport const POSE3_COMPOSITION: PoseComposition<Pose3> = {\n compose: (parent, child) => ({\n position: add(parent.position, quatRotate(parent.rotation, times(parent.scale, child.position))),\n rotation: quatMultiply(parent.rotation, child.rotation),\n scale: times(parent.scale, child.scale),\n }),\n decompose: (parent, world) => ({\n position: over(quatRotate(quatConjugate(parent.rotation), sub(world.position, parent.position)), parent.scale, ORIGIN),\n rotation: quatMultiply(quatConjugate(parent.rotation), world.rotation),\n scale: over(world.scale, parent.scale, world.scale),\n }),\n closure: 'rigid',\n};\n","/**\n * The screen side of the kernel: where a pointer points, and what rectangle a\n * world box covers. This is the seam weasel's 2D chrome meets — everything\n * here speaks `Bounds`-shaped screen rectangles, which is why a 3D host can\n * pass the dispatcher's world point through unchanged.\n */\n\nimport {\n invert,\n normalize,\n sub,\n transformPoint,\n transformPoint4,\n type Aabb,\n type Mat4,\n type Ray,\n type Vec3,\n} from '@weasel-js/geom/3d';\n\n/** A screen rectangle in CSS pixels, in the shape core's `Bounds` uses. Both\n * a pane's own rect and a projected world box are this — one spelling, so the\n * two never need converting between. */\nexport interface ScreenBox {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** A `ScreenBox` a host is being asked to outline. `tint` says why: warm for\n * what is selected, cool for what the gesture in hand is proposing. */\nexport interface ChromeBox extends ScreenBox {\n tint?: 'selection' | 'gesture';\n}\n\n/** Screen point (y down, rect-relative) to normalized device coordinates (y up). */\nexport function screenToNdc(\n point: { x: number; y: number },\n rect: ScreenBox,\n): { x: number; y: number } {\n return {\n x: ((point.x - rect.x) / rect.width) * 2 - 1,\n y: 1 - ((point.y - rect.y) / rect.height) * 2,\n };\n}\n\n/** Inverse of `screenToNdc`: normalized device coordinates (y up) to a point\n * in `rect`'s space (y down). */\nexport function ndcToScreen(\n ndc: { x: number; y: number },\n rect: ScreenBox,\n): { x: number; y: number } {\n return {\n x: rect.x + (ndc.x * 0.5 + 0.5) * rect.width,\n y: rect.y + (1 - (ndc.y * 0.5 + 0.5)) * rect.height,\n };\n}\n\n/**\n * The ray a screen point names, given the camera that drew the rect. This is\n * the whole of what 3D picking needs from a pointer — which is why the world\n * point the dispatcher carries stays two numbers.\n *\n * `null` when the point names no ray: the view-projection has no inverse (a\n * camera on its own target, a degenerate projection) or the pane has no area.\n */\nexport function rayThroughScreenPoint(\n point: { x: number; y: number },\n rect: ScreenBox,\n viewProjection: Mat4,\n eye: Vec3,\n): Ray | null {\n const inv = invert(viewProjection);\n if (!inv) return null;\n const ndc = screenToNdc(point, rect);\n const near = transformPoint(inv, { x: ndc.x, y: ndc.y, z: -1 });\n const far = transformPoint(inv, { x: ndc.x, y: ndc.y, z: 1 });\n const direction = normalize(sub(far, near));\n // normalize answers zero for a non-finite difference, which is no direction.\n if (direction.x === 0 && direction.y === 0 && direction.z === 0) return null;\n return { origin: eye, direction };\n}\n\ntype Clip = readonly [number, number, number, number];\n\n/** Signed distance to the near plane in clip space; `>= 0` is in front of it.\n * GL puts the near plane at `z = -w`. */\nfunction nearSide(p: Clip): number {\n return p[2] + p[3];\n}\n\nfunction lerpClip(a: Clip, b: Clip, t: number): Clip {\n return [\n a[0] + (b[0] - a[0]) * t,\n a[1] + (b[1] - a[1]) * t,\n a[2] + (b[2] - a[2]) * t,\n a[3] + (b[3] - a[3]) * t,\n ];\n}\n\n/** The three edges leaving corner `i` toward a higher bit, as bit masks. */\nconst EDGE_BITS = [1, 2, 4] as const;\n\n/**\n * The screen rectangle a world-space box covers — the currency weasel's chrome\n * and `PoseDescriptor.getBounds` speak in. `null` when the box is entirely\n * behind the near plane.\n *\n * Each of the twelve edges is clipped against the near plane before it is\n * projected, rather than dropping the corners behind it. Dropping them reports\n * a box that is too small for anything straddling the near plane, and the error\n * grows as the camera moves in: a solid the pointer is inside of would outline\n * as a sliver, or as nothing.\n */\nexport function projectAabbToScreen(\n box: Aabb,\n viewProjection: Mat4,\n rect: ScreenBox,\n): ScreenBox | null {\n const corners: Clip[] = [];\n for (let i = 0; i < 8; i++) {\n const corner: Vec3 = {\n x: i & 1 ? box.max.x : box.min.x,\n y: i & 2 ? box.max.y : box.min.y,\n z: i & 4 ? box.max.z : box.min.z,\n };\n corners.push(transformPoint4(viewProjection, corner));\n }\n\n let minX = Number.POSITIVE_INFINITY;\n let minY = Number.POSITIVE_INFINITY;\n let maxX = Number.NEGATIVE_INFINITY;\n let maxY = Number.NEGATIVE_INFINITY;\n let any = false;\n\n const extend = (p: Clip): void => {\n if (!(p[3] > 0)) return;\n const screen = ndcToScreen({ x: p[0] / p[3], y: p[1] / p[3] }, rect);\n minX = Math.min(minX, screen.x);\n minY = Math.min(minY, screen.y);\n maxX = Math.max(maxX, screen.x);\n maxY = Math.max(maxY, screen.y);\n any = true;\n };\n\n for (let i = 0; i < 8; i++) {\n for (const bit of EDGE_BITS) {\n if (i & bit) continue;\n let a = corners[i];\n let b = corners[i | bit];\n const da = nearSide(a);\n const db = nearSide(b);\n if (da < 0 && db < 0) continue;\n if (da < 0) a = lerpClip(a, b, da / (da - db));\n else if (db < 0) b = lerpClip(b, a, db / (db - da));\n extend(a);\n extend(b);\n }\n }\n\n if (!any) return null;\n return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };\n}\n","/**\n * A viewport's two directions: a screen point to the ray it names, and a\n * world point to the screen point it draws at. Both speak the coordinate\n * space the host's pointer points arrive in.\n */\n\nimport { transformPoint4, type Ray, type Vec3 } from '@weasel-js/geom/3d';\nimport { cameraEye, cameraViewProjection, type Camera3d } from './camera';\nimport { ndcToScreen, rayThroughScreenPoint, type ScreenBox } from './screen';\n\n/** The camera and the pane it draws into; `width`/`height` are the pane's\n * size in the same units as the pointer points. */\nexport interface Viewport3d {\n camera: Camera3d;\n width: number;\n height: number;\n /**\n * Where the pane sits in client coordinates. A 3D host works in one space\n * from the event to the ray — it passes the dispatcher an identity\n * `clientToWorld` — so the deps subtract this rather than the dispatcher.\n */\n originX?: number;\n originY?: number;\n}\n\n/** Read on every dep call, so a dep always sees the current camera and pane. */\nexport type ViewportSource = () => Viewport3d;\n\ntype Point = { x: number; y: number };\n\n/** The pane, in the coordinate space the host's points arrive in. The origin\n * defaults to the client origin — a host that fills the window passes none. */\nexport function rectOf(viewport: Viewport3d): ScreenBox {\n return {\n x: viewport.originX ?? 0,\n y: viewport.originY ?? 0,\n width: viewport.width,\n height: viewport.height,\n };\n}\n\nexport function viewProjectionOf(viewport: Viewport3d) {\n return cameraViewProjection(viewport.camera, viewport.width / Math.max(1, viewport.height));\n}\n\nexport function rayAt(viewport: Viewport3d, point: Point): Ray | null {\n return rayThroughScreenPoint(\n point,\n rectOf(viewport),\n viewProjectionOf(viewport),\n cameraEye(viewport.camera),\n );\n}\n\n/** Where `p` draws in the viewport, or null when it is behind the near plane\n * or projects to nothing finite. */\nexport function projectPoint(p: Vec3, viewport: Viewport3d): Point | null {\n const [x, y, z, w] = transformPoint4(viewProjectionOf(viewport), p);\n // GL's near plane is z = -w.\n if (!(w > 0) || z < -w) return null;\n const screen = ndcToScreen({ x: x / w, y: y / w }, rectOf(viewport));\n return Number.isFinite(screen.x) && Number.isFinite(screen.y) ? screen : null;\n}\n","/**\n * The ground: the plane through the origin at right angles to `up`. A drag\n * inserts onto it, and a 2D world lies on it when a 3D view meets one.\n */\n\nimport type { AimPoint } from '@weasel-js/core';\nimport { intersectRayPlane, pointOnRay, type Vec3 } from '@weasel-js/geom/3d';\nimport { rayAt, type Viewport3d } from './project';\n\nexport type Axis = 'x' | 'y' | 'z';\n\n/** `up`'s own axis, and the two it is not: a 2D world's x lies along `u` and its y along `v`. */\nexport interface GroundAxes {\n readonly u: Axis;\n readonly v: Axis;\n readonly up: Axis;\n}\n\nexport function groundAxes(up: Vec3): GroundAxes {\n if (up.y !== 0) return { u: 'x', v: 'z', up: 'y' };\n if (up.x !== 0) return { u: 'y', v: 'z', up: 'x' };\n return { u: 'x', v: 'y', up: 'z' };\n}\n\n/** Where the ray through `point`, in the coordinates the viewport's pointer points arrive in, meets the ground, or `null`. */\nexport function groundHit(viewport: Viewport3d, point: { x: number; y: number }, up: Vec3): Vec3 | null {\n const ray = rayAt(viewport, point);\n const t = ray && intersectRayPlane(ray, up, 0);\n return ray && t !== null ? pointOnRay(ray, t) : null;\n}\n\n/** A world point as a 2D world reads it: its place along the ground axes as x and y, its height as z. */\nexport function toAimPoint(p: Vec3, axes: GroundAxes): AimPoint {\n return { x: p[axes.u], y: p[axes.v], z: p[axes.up] };\n}\n\n/** The world point an aim point names; a 2D world's point, with no z, lies on the ground. */\nexport function fromAimPoint(p: AimPoint, axes: GroundAxes): Vec3 {\n const out = { x: 0, y: 0, z: 0 };\n out[axes.u] = p.x;\n out[axes.v] = p.y;\n out[axes.up] = p.z ?? 0;\n return out;\n}\n","/** The 3D world every dep is built from: core's scene with a `Pose3`, the\n * viewport it is seen through, and how wide each node is. */\n\nimport {\n composeWorldPose, scenePoseAdapter, scenePoseFrame, type NodeId, type Scene, type SceneNode,\n} from '@weasel-js/core';\nimport type { Aabb, Vec3 } from '@weasel-js/geom/3d';\nimport { aabbOfPose, type Pose3 } from './pose3';\nimport type { ViewportSource } from './project';\n\n/** A 3D scene is core's scene with a `Pose3`. Nothing wraps it. */\nexport type Scene3d<TData, TLayer extends string> = Scene<TData, TLayer, Pose3>;\n/** A node of a `Scene3d`. */\nexport type Node3d<TData, TLayer extends string> = SceneNode<TData, TLayer, Pose3>;\n\n/**\n * The world box a node occupies, rather than a local box to transform: a\n * sphere's box is the same under every rotation, and no transform of a local\n * box reproduces that — rotate a cube and it widens.\n *\n * The node it is handed carries its world pose: under container composition,\n * or mid-gesture, that is not the pose the scene stores. `null` means the node\n * occupies nothing, so nothing picks it or snaps to it; a container that only\n * groups its children answers that.\n *\n * Omitted, a mark is a unit cube carried by its pose and a group occupies\n * nothing.\n *\n * A function of the node alone; a result that depends on anything else must\n * come with a scene change, or picks go stale.\n */\nexport type NodeBounds<TData, TLayer extends string> = (\n node: Node3d<TData, TLayer>,\n) => Aabb | null;\n\n/** What every 3D dep is built from: the scene, the viewport, and optionally\n * each node's world box. */\nexport interface World3d<TData, TLayer extends string> {\n scene: Scene3d<TData, TLayer>;\n viewport: ViewportSource;\n bounds?: NodeBounds<TData, TLayer>;\n /** The axis gestures resolve against. Default `+y`. */\n up?: Vec3;\n}\n\nexport const DEFAULT_UP: Vec3 = { x: 0, y: 1, z: 0 };\n\n/**\n * Where `id` is in world, as it is shown: folded up through every container\n * frame above it under the scene's composition, at the pose an in-flight\n * gesture published where there is one. What a renderer draws the node at.\n */\nexport function worldPoseOf<TData, TLayer extends string>(\n scene: Scene3d<TData, TLayer>,\n id: NodeId,\n): Pose3 | undefined {\n return scene.get(id) === undefined ? undefined : worldPoses(scene, 'shown')(id);\n}\n\n/** Which world a read sees: as shown, or as the document holds it with no\n * gesture's override anywhere up the chain. */\nexport type Reading = 'shown' | 'document';\n\n/** A world-pose lookup over `scene`, to build once per pass and ask per node. */\nexport function worldPoses<TData, TLayer extends string>(\n scene: Scene3d<TData, TLayer>,\n reading: Reading,\n): (id: NodeId) => Pose3 {\n const untyped = scene as unknown as Scene<unknown, string, unknown>;\n if (reading === 'shown') {\n const frame = scenePoseFrame(untyped);\n return (id) => frame.world(id) as Pose3;\n }\n const adapter = scenePoseAdapter(untyped);\n const compose = scene.composition.compose as (p: unknown, c: unknown) => unknown;\n return (id) => composeWorldPose(adapter, id as string, compose) as Pose3;\n}\n\n/** The box `node` occupies at the world pose `pose`, or `null` for none. */\nexport function boxAt<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n node: Node3d<TData, TLayer>,\n pose: Pose3,\n): Aabb | null {\n if (world.bounds) return world.bounds(pose === node.pose ? node : { ...node, pose });\n return node.kind === 'group' ? null : aabbOfPose(pose);\n}\n\n/** The box `node` is measured by at `pose`, and a gesture casts it from: its\n * own, or for a node that occupies nothing, its origin. */\nexport function measuredBoxAt<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n node: Node3d<TData, TLayer>,\n pose: Pose3,\n): Aabb {\n return boxAt(world, node, pose) ?? pointBox(pose.position);\n}\n\n/** A world-box lookup over `world`, to build once per pass and ask per node. */\nexport function worldBoxes<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n reading: Reading,\n): (node: Node3d<TData, TLayer>) => Aabb | null {\n const poseOf = worldPoses(world.scene, reading);\n return (node) => boxAt(world, node, poseOf(node.id));\n}\n\n/** `ids` and everything under them. */\nexport function withDescendants<TData, TLayer extends string>(\n scene: Scene3d<TData, TLayer>,\n ids: Iterable<string>,\n): Set<string> {\n const out = new Set<string>();\n const queue = [...ids];\n while (queue.length > 0) {\n const id = queue.pop()!;\n if (out.has(id)) continue;\n out.add(id);\n queue.push(...scene.childrenOf(id as NodeId));\n }\n return out;\n}\n\n/** A box with no extent at `p`. */\nexport function pointBox(p: Vec3): Aabb {\n return { min: p, max: p };\n}\n","/**\n * The 3D world's pick index: one BVH over every node's world box as shown,\n * rebuilt whole on the first pick after the scene, its overrides or the\n * world's `bounds` function can have changed. A node whose box the tree\n * refuses (non-finite or inverted) is tested on every pick, the way the scan\n * did; one that occupies nothing is never picked.\n */\n\nimport type { NodeId } from '@weasel-js/core';\nimport { rectsOverlap } from '@weasel-js/geom';\nimport { intersectRayAabb, type Aabb, type Ray } from '@weasel-js/geom/3d';\nimport { createBvh, type Bvh, type HalfSpace } from '@weasel-js/geom/nd';\nimport { rectOf, viewProjectionOf, type Viewport3d } from './project';\nimport { projectAabbToScreen, screenToNdc, type ScreenBox } from './screen';\nimport { boxAt, worldBoxes, worldPoseOf, type Node3d, type World3d } from './world';\n\nexport interface WorldPickIndex {\n /** The nearest node the ray enters; a tie on distance goes to the first in render order. */\n nearestOnRay(ray: Ray, excluded: ReadonlySet<NodeId> | null): NodeId | null;\n /** The nodes whose projected box overlaps `rect`, in render order. */\n inScreenRect(vp: Viewport3d, rect: ScreenBox): NodeId[];\n}\n\n/** The screen box a node covers, or null when it projects to nothing visible. */\nexport function screenBoxOf<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n id: NodeId,\n viewport: Viewport3d,\n): ScreenBox | null {\n const node = world.scene.get(id) as Node3d<TData, TLayer> | undefined;\n const pose = node && worldPoseOf(world.scene, id);\n const box = node && pose && boxAt(world, node, pose);\n return box ? projectAabbToScreen(box, viewProjectionOf(viewport), rectOf(viewport)) : null;\n}\n\nfunction boxValid({ min, max }: Aabb): boolean {\n return (\n Number.isFinite(min.x) && Number.isFinite(min.y) && Number.isFinite(min.z) &&\n Number.isFinite(max.x) && Number.isFinite(max.y) && Number.isFinite(max.z) &&\n min.x <= max.x && min.y <= max.y && min.z <= max.z\n );\n}\n\n/** Widens each side plane, in NDC, past the rounding between it and the exact screen test. */\nconst NDC_SLACK = 1e-9;\n\n/**\n * The four half-spaces a point must sit in for its screen point to fall in\n * `rect`'s columns and rows: `ndc.x >= a` is `clip.x - a * clip.w >= 0`\n * wherever `clip.w > 0`, which is linear in the world point. Each plane is\n * kept or dropped on its own, so a box survives exactly when its projection's\n * x span and y span each reach the rect — what the screen-box test asks —\n * and points behind the eye only ever add candidates.\n */\nfunction sidePlanes(vp: Viewport3d, rect: ScreenBox): HalfSpace[] {\n const m = viewProjectionOf(vp);\n const pane = rectOf(vp);\n const lo = screenToNdc({ x: rect.x, y: rect.y + rect.height }, pane);\n const hi = screenToNdc({ x: rect.x + rect.width, y: rect.y }, pane);\n // Column-major: row r of the matrix is m[r], m[4 + r], m[8 + r], m[12 + r].\n const row = (r: number) => [m[r]!, m[4 + r]!, m[8 + r]!, m[12 + r]!];\n const w = row(3);\n const plane = (r: number, a: number, sign: 1 | -1): HalfSpace => {\n const c = row(r);\n const e = [0, 1, 2, 3].map((j) => sign * (c[j]! - a * w[j]!));\n return { normal: [e[0]!, e[1]!, e[2]!], offset: e[3]! };\n };\n return [\n plane(0, lo.x - NDC_SLACK, 1),\n plane(0, hi.x + NDC_SLACK, -1),\n plane(1, lo.y - NDC_SLACK, 1),\n plane(1, hi.y + NDC_SLACK, -1),\n ];\n}\n\nclass BuiltIndex<TData, TLayer extends string> implements WorldPickIndex {\n constructor(\n private readonly order: readonly Node3d<TData, TLayer>[],\n private readonly boxes: readonly (Aabb | null)[],\n private readonly tree: Bvh<number>,\n private readonly always: readonly number[],\n ) {}\n\n nearestOnRay(ray: Ray, excluded: ReadonlySet<NodeId> | null): NodeId | null {\n const { order, boxes } = this;\n let best = -1;\n let bestT = Infinity;\n const consider = (i: number) => {\n const box = boxes[i]!;\n if (excluded?.has(order[i]!.id)) return;\n const t = intersectRayAabb(ray, box.min, box.max);\n if (t !== null && (t < bestT || (t === bestT && i < best))) {\n bestT = t;\n best = i;\n }\n };\n for (const i of this.always) consider(i);\n const { origin: o, direction: d } = ray;\n this.tree.raycast([o.x, o.y, o.z], [d.x, d.y, d.z], (i, entryT) => {\n // The tree's slab test rounds differently from intersectRayAabb's.\n if (entryT > bestT * (1 + 1e-12) + 1e-12) return false;\n consider(i);\n return true;\n });\n return best < 0 ? null : order[best]!.id;\n }\n\n inScreenRect(vp: Viewport3d, rect: ScreenBox): NodeId[] {\n const candidates = [...this.always];\n this.tree.queryHalfSpaces(sidePlanes(vp, rect), (i) => {\n candidates.push(i);\n });\n candidates.sort((a, b) => a - b);\n const hits: NodeId[] = [];\n const m = viewProjectionOf(vp);\n const pane = rectOf(vp);\n for (const i of candidates) {\n const box = projectAabbToScreen(this.boxes[i]!, m, pane);\n if (box && rectsOverlap(box, rect)) hits.push(this.order[i]!.id);\n }\n return hits;\n }\n}\n\ninterface Cached {\n version: number;\n overrides: number;\n bounds: unknown;\n order: readonly unknown[];\n index: WorldPickIndex;\n}\n\nconst CACHE = new WeakMap<object, Cached>();\n\n/** The box grown by a relative epsilon, so rounding in the tree's tests can\n * only add candidates for the exact ones to drop. */\nfunction padded({ min, max }: Aabb): number[] {\n const m = Math.max(\n Math.abs(min.x), Math.abs(min.y), Math.abs(min.z),\n Math.abs(max.x), Math.abs(max.y), Math.abs(max.z),\n );\n const e = 1e-9 * (1 + m);\n return [min.x - e, min.y - e, min.z - e, max.x + e, max.y + e, max.z + e];\n}\n\nfunction build<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n order: readonly Node3d<TData, TLayer>[],\n): WorldPickIndex {\n const boxOf = worldBoxes(world, 'shown');\n const boxes = order.map(boxOf);\n const entries: [number, number[]][] = [];\n const always: number[] = [];\n boxes.forEach((b, i) => {\n if (b === null) return;\n if (boxValid(b)) entries.push([i, padded(b)]);\n else always.push(i);\n });\n return new BuiltIndex(order, boxes, createBvh<number>(3, entries), always);\n}\n\n/** The index for `world`, current as of this call. */\nexport function worldPickIndex<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n): WorldPickIndex {\n const { scene } = world;\n const version = scene.getVersion();\n const overrides = scene.overrides.getGeneration();\n const order = scene.renderOrderNodes() as readonly Node3d<TData, TLayer>[];\n const hit = CACHE.get(world);\n if (\n hit && hit.version === version && hit.overrides === overrides &&\n hit.bounds === world.bounds && hit.order === order\n ) {\n return hit.index;\n }\n const index = build(world, order);\n CACHE.set(world, { version, overrides, bounds: world.bounds, order, index });\n return index;\n}\n","import { SNAP_AXIS_STEP, type SnapConstrain } from '@weasel-js/core';\nimport { stepLine, type Flat } from '@weasel-js/geom/nd';\nimport { cross, dot, normalize, scale, sub, type Vec3 } from '@weasel-js/geom/3d';\n\nconst ZERO: Vec3 = { x: 0, y: 0, z: 0 };\n\nexport const tuple = (p: Vec3): number[] => [p.x, p.y, p.z];\nexport const vec3Of = (t: readonly number[]): Vec3 => ({ x: t[0]!, y: t[1]!, z: t[2]! });\n\n/** Two unit directions spanning the plane normal to `up`. For an axis `up`\n * they are the other two world axes, so a ground grid runs along them. */\nexport function planeBasis(up: Vec3): readonly [Vec3, Vec3] {\n const n = normalize(up);\n const e: Vec3 = Math.abs(n.x) < 0.9 ? { x: 1, y: 0, z: 0 } : { x: 0, y: 0, z: 1 };\n const u = normalize(sub(e, scale(n, dot(n, e))));\n return [u, cross(u, n)];\n}\n\n/**\n * `H` for a 3D gesture: the plane `basis` spans, through the origin of\n * δ-space. While `snap.constrain` is held, an `'axis'` constraint holds δ to\n * the axes and diagonals of that plane, and an angle step holds it to the\n * line through `about` at the nearest multiple of the step.\n */\nexport function inputFlat3d(\n c: SnapConstrain | undefined, held: boolean, basis: readonly [Vec3, Vec3], delta0: Vec3, about: Vec3,\n): Flat {\n const [u, v] = basis;\n if (!held || c === undefined || c === 'aspect') return { at: [0, 0, 0], dirs: [tuple(u), tuple(v)] };\n const step = c === 'axis' ? SNAP_AXIS_STEP : c.step;\n return stepLine(tuple(c === 'axis' ? ZERO : about), tuple(delta0), [tuple(u), tuple(v)], step);\n}\n","import type { NodeId, SnapProbeAt } from '@weasel-js/core';\nimport { add, dot, scale, type Aabb, type Vec3 } from '@weasel-js/geom/3d';\nimport { boxAt, measuredBoxAt, withDescendants, worldPoses, type Node3d, type World3d } from '../world';\n\n/** What a 3D move drags, at press. */\nexport interface Subject3d {\n /** The union of the world boxes of the subject and everything under it,\n * which moves with it. */\n box: Aabb;\n /** The node whose `translate` the session answers for exactly: the first\n * of the subject still in the scene, which is the move's lead, so every\n * other root follows it onto what it snapped to. */\n anchor: { box: Aabb; height: number };\n}\n\nexport function subjectOf<TData, TLayer extends string>(\n world: World3d<TData, TLayer>, ids: readonly string[], up: Vec3,\n): Subject3d | null {\n const { scene } = world;\n const poseOf = worldPoses(scene, 'shown');\n const nodeOf = (id: string) => scene.get(id as NodeId) as Node3d<TData, TLayer> | undefined;\n const lead = ids.find((id) => nodeOf(id) !== undefined);\n if (lead === undefined) return null;\n const leadPose = poseOf(lead as NodeId);\n const anchor = { box: measuredBoxAt(world, nodeOf(lead)!, leadPose), height: dot(up, leadPose.position) };\n let box: Aabb | null = null;\n for (const id of withDescendants(scene, ids)) {\n const node = nodeOf(id);\n const b = node && boxAt(world, node, poseOf(node.id));\n if (b) box = box ? union(box, b) : b;\n }\n return { box: box ?? anchor.box, anchor };\n}\n\nfunction union(a: Aabb, b: Aabb): Aabb {\n return {\n min: { x: Math.min(a.min.x, b.min.x), y: Math.min(a.min.y, b.min.y), z: Math.min(a.min.z, b.min.z) },\n max: { x: Math.max(a.max.x, b.max.x), y: Math.max(a.max.y, b.max.y), z: Math.max(a.max.z, b.max.z) },\n };\n}\n\n/** Corner `i` of `box`: bit 1 picks max x, bit 2 max y, bit 4 max z. */\nexport function boxCorner(box: Aabb, i: number): Vec3 {\n return {\n x: i & 1 ? box.max.x : box.min.x,\n y: i & 2 ? box.max.y : box.min.y,\n z: i & 4 ? box.max.z : box.min.z,\n };\n}\n\n/** A move's probes: the box's 8 corners and center as its geometry, and its\n * min, center and max as its box. */\nexport function boxProbes(box: Aabb): SnapProbeAt<Vec3>[] {\n const center = scale(add(box.min, box.max), 0.5);\n const out: SnapProbeAt<Vec3>[] = [];\n for (let i = 0; i < 8; i++) {\n out.push({ id: `corner:${i}`, at: boxCorner(box, i), role: 'geometry' });\n }\n out.push(\n { id: 'center', at: center, role: 'geometry' },\n { id: 'box.min', at: box.min, role: 'box' },\n { id: 'box.center', at: center, role: 'box' },\n { id: 'box.max', at: box.max, role: 'box' },\n );\n return out;\n}\n","import {\n gatherSnapCandidates, resolvedSnapMarks, snapSourcesFor,\n type SnapBegin, type SnapCandidateMark, type SnapOutcome, type SnapOutcomeStore,\n type SnapProbeAt, type SnapSession, type SnapSource,\n} from '@weasel-js/core';\nimport { closestOnFlat, resolveSnap, type Flat, type SnapCandidate } from '@weasel-js/geom/nd';\nimport {\n add, cross, dot, intersectRayPlane, len, normalize, pointOnRay, sub, type Vec3,\n} from '@weasel-js/geom/3d';\nimport { cameraEye } from '../camera';\nimport { projectPoint, rayAt, rectOf, viewProjectionOf, type Viewport3d } from '../project';\nimport { projectAabbToScreen } from '../screen';\nimport { DEFAULT_UP, type World3d } from '../world';\nimport { inputFlat3d, planeBasis, tuple, vec3Of } from './plane';\nimport { boxProbes, subjectOf } from './probes3d';\n\ntype Point = { x: number; y: number };\n\nconst ZERO: Vec3 = { x: 0, y: 0, z: 0 };\n\n/** What a 3D session runs on. */\nexport interface Session3dInputs<TData, TLayer extends string> {\n req: SnapBegin;\n world: World3d<TData, TLayer>;\n /** In source order: earlier wins a full tie. */\n sources: readonly SnapSource<Vec3>[];\n /** The reach of a source that sets none, in screen px. */\n reachPx: number;\n store: SnapOutcomeStore<Vec3>;\n}\n\n/**\n * The plane a gesture moves on, `up · p = offset`, and how its δ is read: as\n * the world distance between where `anchor` and the pointer's offset from the\n * press cast onto that plane. For a move, `anchor` is the screen point\n * `translate` casts from, so a δ handed back as a screen point is the delta\n * `translate` makes of it.\n */\ninterface Frame {\n offset: number;\n anchor(vp: Viewport3d): Point | null;\n probes(anchorWorld: Vec3): readonly SnapProbeAt<Vec3>[];\n}\n\n/**\n * A snap session over a 3D world: ctx points are screen points. A move runs\n * on the plane through its subject normal to `up`, an insert on the ground,\n * and each returns the screen point whose cast lands where the snap put it.\n * Other gestures pass their input through.\n */\nexport function createSession3d<TData, TLayer extends string>(inputs: Session3dInputs<TData, TLayer>): SnapSession {\n const { req, world, store } = inputs;\n const up = normalize(world.up ?? DEFAULT_UP);\n const basis = planeBasis(up);\n const frame = frameOf(req, world, up);\n const sources = snapSourcesFor(inputs.sources, req.gesture);\n const unsnapped = (p: Point): SnapOutcome => {\n store.set([]);\n return { point: p, held: false, marks: [] };\n };\n return {\n at(p, mods) {\n if (!frame) return unsnapped(p);\n const vp = world.viewport();\n const screen = frame.anchor(vp);\n const anchor = screen && castOnto(vp, screen, up, frame.offset);\n const hit = screen && castOnto(vp, { x: screen.x + p.x - req.press.x, y: screen.y + p.y - req.press.y }, up, frame.offset);\n if (!screen || !anchor || !hit) return unsnapped(p);\n const delta0 = sub(hit, anchor);\n const origin = req.origin ? castOnto(vp, req.origin, up, frame.offset) : null;\n const input = inputFlat3d(req.constrain, mods.constrain, basis, delta0, origin ? sub(origin, anchor) : ZERO);\n let delta: Vec3;\n let held = false;\n if (mods.suspend) {\n delta = vec3Of(closestOnFlat(input, tuple(delta0)));\n store.set([]);\n } else {\n const probes = frame.probes(anchor);\n const res = resolveSnap({\n probes: probes.map((q) => ({ id: q.id, at: tuple(q.at), role: q.role })),\n input,\n delta0: tuple(delta0),\n candidates: candidatesOf(inputs, sources, probes, delta0, vp, origin, up),\n toScreen: (w) => {\n const s = projectPoint(vec3Of(w), vp);\n return s ? [s.x, s.y] : [NaN, NaN];\n },\n });\n delta = vec3Of(res.delta);\n held = res.members.length > 0;\n store.set(resolvedSnapMarks(res.satisfied, delta));\n }\n const landed = projectPoint(add(anchor, delta), vp);\n if (!landed) return unsnapped(p);\n return {\n point: { x: req.press.x + landed.x - screen.x, y: req.press.y + landed.y - screen.y },\n held,\n marks: store.get(),\n };\n },\n angle: (theta) => ({ theta, marks: [] }),\n end() {\n store.set([]);\n },\n };\n}\n\nfunction frameOf<TData, TLayer extends string>(req: SnapBegin, world: World3d<TData, TLayer>, up: Vec3): Frame | null {\n if (req.gesture === 'point') {\n return {\n offset: 0,\n anchor: () => req.press,\n probes: (at) => [{ id: 'pointer', at, role: 'pointer' }],\n };\n }\n if (req.gesture !== 'move') return null;\n const subject = subjectOf(world, req.ids ?? [], up);\n if (!subject) return null;\n const probes = boxProbes(subject.box);\n return {\n offset: subject.anchor.height,\n anchor(vp) {\n const box = projectAabbToScreen(subject.anchor.box, viewProjectionOf(vp), rectOf(vp));\n return box ? { x: box.x + box.width / 2, y: box.y + box.height / 2 } : null;\n },\n probes: () => probes,\n };\n}\n\nfunction castOnto(vp: Viewport3d, s: Point, up: Vec3, offset: number): Vec3 | null {\n const ray = rayAt(vp, s);\n const t = ray && intersectRayPlane(ray, up, offset);\n return ray && t !== null ? pointOnRay(ray, t) : null;\n}\n\nfunction candidatesOf<TData, TLayer extends string>(\n inputs: Session3dInputs<TData, TLayer>, sources: readonly SnapSource<Vec3>[], probes: readonly SnapProbeAt<Vec3>[],\n delta0: Vec3, vp: Viewport3d, origin: Vec3 | null, up: Vec3,\n): SnapCandidate<SnapCandidateMark<Vec3>>[] {\n const { req } = inputs;\n const shifted = probes.map((q) => ({ ...q, at: add(q.at, delta0) }));\n const perPx = worldPerPx(vp, shifted);\n const found = gatherSnapCandidates(sources, shifted, (_source, offered, reachPx) => ({\n gesture: req.gesture, probes: offered, delta0, exclude: req.ids ?? [],\n ...(req.ids ? { ids: req.ids } : {}),\n ...(req.parent !== undefined ? { parent: req.parent } : {}),\n ...(origin ? { origin } : {}),\n reachWorld: (px) => px * perPx,\n reachPx,\n }), { toVec: tuple, reachPx: inputs.reachPx, ...(origin ? { origin } : {}) });\n return found.filter((c) => !level(c.locus, up));\n}\n\n/** Whether `locus` is a plane normal to `up`: the gesture's own plane or one\n * parallel to it, which height alone meets or misses. */\nfunction level(locus: Flat, up: Vec3): boolean {\n if (locus.dirs.length !== 2) return false;\n const n = cross(vec3Of(locus.dirs[0]!), vec3Of(locus.dirs[1]!));\n return Math.abs(dot(n, up)) >= (1 - 1e-9) * len(n);\n}\n\n/** World units per screen px at the farthest probe in front of the camera:\n * the radius that culls by reach without dropping anything in it. */\nfunction worldPerPx(vp: Viewport3d, probes: readonly SnapProbeAt<Vec3>[]): number {\n const eye = cameraEye(vp.camera);\n const forward = normalize(sub(vp.camera.target, eye));\n const k = (2 * Math.tan(vp.camera.fov / 2)) / Math.max(1, vp.height);\n let depth = 0;\n for (const q of probes) depth = Math.max(depth, dot(sub(q.at, eye), forward));\n return depth * k;\n}\n","/**\n * The kit's deps, implemented against a 3D world.\n *\n * Every one of these takes its camera from a thunk rather than an argument:\n * the dispatcher keeps handing actions two numbers, and what makes them mean\n * something in 3D is the camera each dep already closes over.\n */\n\nimport type {\n AreaSelectDep,\n NodeAtPointDep,\n NodeId,\n PoseDescriptor,\n SnapDep,\n SnapOutcomeStore,\n SnapSource,\n} from '@weasel-js/core';\nimport { DEFAULT_SNAP_PX, createSnapOutcomeStore, assertSnapSourceIds } from '@weasel-js/core';\nimport { isDev, type KitSettingsStore } from '@weasel-js/react';\nimport {\n aabbOfPoints,\n add,\n dot,\n intersectRayPlane,\n len,\n normalize,\n pointOnRay,\n quatIdentity,\n scale as scaleBy,\n sub,\n type Aabb,\n type Vec3,\n} from '@weasel-js/geom/3d';\nimport { cameraEye, type Camera3d } from './camera';\nimport { aabbOfPose, type Pose3 } from './pose3';\nimport { groundAxes, type Axis } from './ground';\nimport { rayAt, rectOf, viewProjectionOf, type Viewport3d } from './project';\nimport { worldPickIndex } from './pickIndex';\nimport { projectAabbToScreen } from './screen';\nimport { createSession3d } from './snap/session3d';\n\nimport { DEFAULT_UP, measuredBoxAt, type Node3d, type World3d } from './world';\n\nexport type { Viewport3d, ViewportSource } from './project';\nexport type { NodeBounds, Node3d, Scene3d, World3d } from './world';\nexport { worldPoseOf } from './world';\n\n/**\n * The plane through `p` that faces the camera.\n *\n * This is the depth choice the kit's reverse contracts need: a screen\n * rectangle names a pose only once something says how far away it is, and the\n * answer is \"as far as it already was\". Nothing resolved on this plane changes\n * depth, and one screen pixel is the same world distance everywhere on it.\n */\nfunction viewPlaneAt(camera: Camera3d, p: Vec3): { normal: Vec3; offset: number } {\n const normal = normalize(sub(camera.target, cameraEye(camera)));\n return { normal, offset: dot(normal, p) };\n}\n\n/** Where a screen point lands on `plane`, or `null` when it casts no ray. */\nfunction onPlane(\n vp: Viewport3d,\n plane: { normal: Vec3; offset: number },\n point: { x: number; y: number },\n): Vec3 | null {\n const ray = rayAt(vp, point);\n if (!ray) return null;\n const t = intersectRayPlane(ray, plane.normal, plane.offset);\n return t === null ? null : pointOnRay(ray, t);\n}\n\n/** `pose` moved by `delta`, kept at its own height along `upAxis`. */\nfunction movedOnLevel(pose: Pose3, delta: Vec3, upAxis: Axis): Pose3 {\n const position = { ...add(pose.position, delta), [upAxis]: pose.position[upAxis] };\n return { ...pose, position };\n}\n\nexport { screenBoxOf } from './pickIndex';\n\n/**\n * Nearest node along the ray the screen point names.\n *\n * The kit calls this with what it believes is a world point; a 3D host feeds\n * the dispatcher an identity `clientToWorld`, so it is the pane-relative screen\n * point, which is exactly what a ray needs.\n */\nexport function createNodeAtPoint<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n): NodeAtPointDep {\n return (point, exclude) => {\n const ray = rayAt(world.viewport(), point);\n if (!ray) return null;\n return worldPickIndex(world).nearestOnRay(ray, exclude ? new Set(exclude) : null);\n };\n}\n\n/** Marquee: the nodes whose projected box the screen rectangle touches, in render order. */\nexport function createAreaSelect<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n selection: { get(): readonly NodeId[]; set(ids: NodeId[]): void },\n): AreaSelectDep {\n return {\n hitTestArea: (bounds) => worldPickIndex(world).inScreenRect(world.viewport(), bounds),\n getSelection: () => [...selection.get()],\n setSelection: (ids) => selection.set([...ids]),\n };\n}\n\n/** Options for `createSnap`. */\nexport interface Snap3dOptions {\n /** What a gesture snaps to, in order: earlier wins a full tie. Two sharing\n * an id throw. Default none, which leaves only the gesture's own constraint. */\n sources?: readonly SnapSource<Vec3>[];\n /** The reach of a source that sets none, in screen px. Overrides the kit\n * setting `targets.snapPx`. */\n reachPx?: number;\n /** Where `targets.snapPx` is read, when each gesture begins. Absent, and\n * with no `reachPx`, reach is `DEFAULT_SNAP_PX`. */\n kitSettings?: KitSettingsStore;\n /** Where the marks of the snap in flight are written, for a host to draw\n * with `projectSnapMarks`. */\n store?: SnapOutcomeStore<Vec3>;\n}\n\nlet warnedGestureSources = false;\n\nfunction warnGestureSources(): void {\n if (warnedGestureSources || !isDev()) return;\n warnedGestureSources = true;\n console.warn(\n '[kernel3d] a gesture passed snap `sources`, which are 2D and are not asked in a 3D host. ' +\n 'List 3D sources in createSnap({ sources }).',\n );\n}\n\n/**\n * The `snap` dep over a 3D world. A gesture's `omit` is honored; its 2D\n * `sources` are not asked. A move snaps its subject's world box on the\n * plane it already moves on; an insert snaps the pointer on the ground. Both\n * answer in screen points, which `translate` and `createInsert` cast back\n * onto the same plane, landing exactly where the snap put them.\n */\nexport function createSnap<TData, TLayer extends string>(\n world: World3d<TData, TLayer>, opts: Snap3dOptions = {},\n): SnapDep {\n const store = opts.store ?? createSnapOutcomeStore<Vec3>();\n const listed = opts.sources ?? [];\n assertSnapSourceIds(listed);\n return {\n begin: (req) => {\n if (req.sources?.length) warnGestureSources();\n const omit = new Set(req.omit);\n const sources = listed.filter((s) => !omit.has(s.id));\n return createSession3d({\n req, world, sources, store,\n reachPx: opts.reachPx ?? opts.kitSettings?.get('targets.snapPx') ?? DEFAULT_SNAP_PX,\n });\n },\n };\n}\n\n/**\n * `PoseDescriptor` over a 3D pose, with `Bounds` read as the screen box the\n * node covers.\n *\n * `forNode` is what lets a sphere bound itself as a sphere: the shape lives\n * on `node.data`. Unspecialized — the kit calling with only a pose in hand —\n * it answers with the default local box, which is the looser of the two.\n *\n * `remapBounds` and `fromBounds` take a screen rectangle, which names a pose\n * only once something supplies a depth. Both resolve it against the plane\n * through the pose they were handed, facing the camera, so nothing they\n * produce changes depth.\n */\nexport function createPoseDescriptor<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n): PoseDescriptor<Pose3, Node3d<TData, TLayer>> {\n const up = world.up ?? DEFAULT_UP;\n const upAxis = groundAxes(up).up;\n const specialized = new WeakMap<object, PoseDescriptor<Pose3, Node3d<TData, TLayer>>>();\n\n // A drag whose camera stops casting rays mid-gesture keeps moving through the\n // last one that did, rather than snapping the node back.\n let lastCastable: Viewport3d | null = null;\n function castableViewport(): Viewport3d | null {\n const vp = world.viewport();\n const rect = rectOf(vp);\n if (rayAt(vp, { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 })) lastCastable = vp;\n return lastCastable;\n }\n\n function build(worldBox: (pose: Pose3) => Aabb): PoseDescriptor<Pose3, Node3d<TData, TLayer>> {\n const boundsIn = (vp: Viewport3d, pose: Pose3) =>\n projectAabbToScreen(worldBox(pose), viewProjectionOf(vp), rectOf(vp));\n const boundsOf = (pose: Pose3) => boundsIn(world.viewport(), pose);\n\n const descriptor: PoseDescriptor<Pose3, Node3d<TData, TLayer>> = {\n forNode(node) {\n let d = specialized.get(node);\n if (!d) {\n // The pose arriving here is often an in-flight override rather than\n // `node.pose`, so the consumer is asked about that pose on this node\n // rather than about the node as committed.\n d = build((pose) => measuredBoxAt(world, node, pose));\n specialized.set(node, d);\n }\n return d;\n },\n\n getBounds(pose) {\n return boundsOf(pose) ?? { x: 0, y: 0, width: 0, height: 0 };\n },\n\n /**\n * The src→dst screen map, applied at the pose's own depth: the node's\n * screen anchor moves the way the rectangle does, and both ends of that\n * move are read back off the plane through its position, so the world\n * delta is exact rather than a scaled screen one.\n *\n * The scale is uniform. The rectangle names two extents and a pose has\n * three, so there is no reading in which a screen box resizes a solid\n * per-axis; the geometric mean is the one factor that agrees with both\n * of the extents it does name.\n */\n remapBounds(pose, src, dst) {\n const vp = castableViewport();\n if (!vp) return pose;\n const box = boundsIn(vp, pose);\n if (!box) return pose;\n\n const kx = src.width === 0 ? 1 : dst.width / src.width;\n const ky = src.height === 0 ? 1 : dst.height / src.height;\n const from = { x: box.x + box.width / 2, y: box.y + box.height / 2 };\n const to = {\n x: dst.x + (from.x - src.x) * kx,\n y: dst.y + (from.y - src.y) * ky,\n };\n\n const plane = viewPlaneAt(vp.camera, pose.position);\n const before = onPlane(vp, plane, from);\n const after = onPlane(vp, plane, to);\n if (!before || !after) return pose;\n\n const k = Math.sqrt(Math.abs(kx * ky));\n return {\n ...pose,\n position: add(pose.position, sub(after, before)),\n scale: scaleBy(pose.scale, k),\n };\n },\n\n /**\n * The world box the rectangle covers at the template's depth, as a pose.\n *\n * The rectangle is flat and a box is not, so the third extent — the one\n * no screen rectangle names — is the mean of the two it does. The result\n * is world-axis-aligned and unrotated: the pose carries none of the\n * template's shape, which is the contract, and it takes only its depth.\n *\n * Extents are written as `scale`, so this reads a pose as carrying a\n * unit primitive — the same assumption `aabbOfPose` makes by default.\n */\n fromBounds(bounds, template) {\n const vp = castableViewport();\n if (!vp) return template;\n const plane = viewPlaneAt(vp.camera, template.position);\n\n const corners: Vec3[] = [];\n for (const [x, y] of [\n [bounds.x, bounds.y],\n [bounds.x + bounds.width, bounds.y],\n [bounds.x, bounds.y + bounds.height],\n [bounds.x + bounds.width, bounds.y + bounds.height],\n ]) {\n const corner = onPlane(vp, plane, { x, y });\n if (!corner) return template;\n corners.push(corner);\n }\n\n const width = len(sub(corners[1]!, corners[0]!));\n const height = len(sub(corners[2]!, corners[0]!));\n const half = Math.sqrt(width * height) / 2;\n const box = aabbOfPoints(\n corners.flatMap((c) => [\n add(c, scaleBy(plane.normal, half)),\n sub(c, scaleBy(plane.normal, half)),\n ]),\n );\n return {\n position: scaleBy(add(box.min, box.max), 0.5),\n rotation: quatIdentity(),\n scale: sub(box.max, box.min),\n };\n },\n\n /**\n * Screen-space deltas resolve against the plane the node already sits on. That\n * plane differs per node, so in a move of several each takes the lead's change\n * whole (it kept its height already), and the group moves as one body. */\n translate(pose, dx, dy, lead) {\n if (lead) return { ...pose, position: add(pose.position, sub(lead.to.position, lead.from.position)) };\n const vp = castableViewport();\n const box = vp && boundsIn(vp, pose);\n if (!vp || !box) return pose;\n const from = { x: box.x + box.width / 2, y: box.y + box.height / 2 };\n const level = { normal: up, offset: dot(up, pose.position) };\n const before = onPlane(vp, level, from);\n const after = onPlane(vp, level, { x: from.x + dx, y: from.y + dy });\n return before && after ? movedOnLevel(pose, sub(after, before), upAxis) : pose;\n },\n\n supportsRotation() {\n return false;\n },\n };\n\n return descriptor;\n }\n\n return build((pose) => aabbOfPose(pose));\n}\n","/** The `insert` dep over a 3D world: a drag becomes a footprint on the ground. */\n\nimport type { InsertDep, InsertEnds, InsertExtras, NodeId } from '@weasel-js/core';\nimport { scale as scaleBy, sub, type Vec3 } from '@weasel-js/geom/3d';\nimport { groundAxes, groundHit } from './ground';\nimport type { ViewportSource } from './project';\nimport { DEFAULT_UP } from './world';\n\n/** The ground-plane rectangle a drag swept out, in world units. */\nexport interface Footprint {\n /** Centre of the swept rectangle, on the ground plane. */\n center: Vec3;\n /** Extent along the two axes the up axis is not. */\n width: number;\n depth: number;\n}\n\n/** The ground points a footprint spans. A drag's two ends are cast rather\n * than its box's corners: in perspective the other two corners land outside\n * the rectangle the ends make, and would carry the footprint past a corner\n * the drag snapped to. */\nfunction footprintPoints(\n bounds: { x: number; y: number; width: number; height: number },\n ends: InsertEnds | undefined,\n cast: (p: { x: number; y: number }) => Vec3 | null,\n): Vec3[] {\n if (ends) {\n const start = cast(ends.start);\n const end = cast(ends.end);\n if (!start || !end) return [];\n return ends.fromCenter ? [end, sub(scaleBy(start, 2), end)] : [start, end];\n }\n const corners = [\n { x: bounds.x, y: bounds.y },\n { x: bounds.x + bounds.width, y: bounds.y },\n { x: bounds.x, y: bounds.y + bounds.height },\n { x: bounds.x + bounds.width, y: bounds.y + bounds.height },\n ];\n return corners.map(cast).filter((h): h is Vec3 => h !== null);\n}\n\n/**\n * A drag becomes a footprint on the ground plane: its ends, or without them\n * its box's four corners, are cast onto the plane and the hit points give the\n * extent. What node that implies is the consumer's answer — the kernel does\n * not know what it is inserting. The depth the 2D contract cannot express\n * comes from the plane, not from the caller.\n */\nexport function createInsert(opts: {\n viewport: ViewportSource;\n up?: Vec3;\n /** Smallest footprint a click-sized drag produces. Default 0.25. */\n minExtent?: number;\n mint(footprint: Footprint, extras: InsertExtras): NodeId | null;\n}): InsertDep {\n const up = opts.up ?? DEFAULT_UP;\n const minExtent = opts.minExtent ?? 0.25;\n const { u, v } = groundAxes(up);\n\n return {\n commit(bounds, extras, ends) {\n const vp = opts.viewport();\n const hits = footprintPoints(bounds, ends, (p) => groundHit(vp, p, up));\n if (hits.length === 0) return null;\n\n let minU = Infinity, maxU = -Infinity, minV = Infinity, maxV = -Infinity;\n for (const h of hits) {\n minU = Math.min(minU, h[u]); maxU = Math.max(maxU, h[u]);\n minV = Math.min(minV, h[v]); maxV = Math.max(maxV, h[v]);\n }\n\n const center = { x: 0, y: 0, z: 0 };\n center[u] = (minU + maxU) / 2;\n center[v] = (minV + maxV) / 2;\n return opts.mint(\n {\n center,\n width: Math.max(minExtent, maxU - minU),\n depth: Math.max(minExtent, maxV - minV),\n },\n extras,\n );\n },\n };\n}\n","/**\n * A kernel3d viewport as a view aim: the frustum its camera shows, drawn into\n * any target view, and the pane itself as a target. Core's aim contract names\n * no 3D type, so this is the side that knows the camera.\n */\n\nimport type { AimOutline, AimPoint, AimSpace, ViewAim } from '@weasel-js/core';\nimport { add, dot, normalize, scale, sub, type Vec3 } from '@weasel-js/geom/3d';\nimport { cameraEye, type Camera3d } from './camera';\nimport { fromAimPoint, groundAxes, groundHit, toAimPoint, type GroundAxes } from './ground';\nimport { projectPoint, rayAt, rectOf, type Viewport3d } from './project';\nimport { DEFAULT_UP } from './world';\n\ntype Quad = readonly [Vec3, Vec3, Vec3, Vec3];\n\n/** The frustum a camera shows: its eye, and its near and far rectangles, corners clockwise from the top-left as seen. */\nexport interface Frustum3d {\n eye: Vec3;\n near: Quad;\n far: Quad;\n}\n\n/** A kernel3d view's aim: the frustum its camera sees, with the viewport it was read from. */\nexport type Aim3d = ViewAim<Frustum3d> & { readonly kind: 'frustum'; readonly viewport: Viewport3d };\n\n/** How a kernel3d view meets a 2D one. */\nexport interface Aim3dOptions {\n /** The axis the ground, where a 2D world lies, is at right angles to: `createInsert`'s `up`. Default `+y`. */\n up?: Vec3;\n}\n\nfunction paneCorners(viewport: Viewport3d): { x: number; y: number }[] {\n const { x, y, width, height } = rectOf(viewport);\n return [\n { x, y },\n { x: x + width, y },\n { x: x + width, y: y + height },\n { x, y: y + height },\n ];\n}\n\nfunction frustumOf(viewport: Viewport3d): Frustum3d {\n const { camera } = viewport;\n const eye = cameraEye(camera);\n const forward = normalize(sub(camera.target, eye));\n const at = (depth: number): Vec3[] =>\n paneCorners(viewport).map((c) => {\n const ray = rayAt(viewport, c);\n if (!ray) return eye;\n const d = normalize(ray.direction);\n return add(eye, scale(d, depth / dot(d, forward)));\n });\n return {\n eye,\n near: at(camera.near) as unknown as Quad,\n far: at(camera.far) as unknown as Quad,\n };\n}\n\n/**\n * Where the frustum meets the ground, in the 2D world's terms, its edges' crossings wound about their middle: the\n * stretch of the ground the camera sees, cut off at its far plane, so a view with the horizon in it still outlines\n * the ground it shows. `null` when the frustum meets the ground in less than an area.\n */\nfunction footprint(f: Frustum3d, up: Vec3, axes: GroundAxes): AimPoint[] | null {\n const edges: [Vec3, Vec3][] = [];\n for (let i = 0; i < 4; i++) {\n const j = (i + 1) % 4;\n edges.push([f.near[i]!, f.near[j]!], [f.far[i]!, f.far[j]!], [f.near[i]!, f.far[i]!]);\n }\n const hits: AimPoint[] = [];\n for (const [a, b] of edges) {\n const ha = dot(a, up), hb = dot(b, up);\n if ((ha > 0 && hb > 0) || (ha < 0 && hb < 0) || ha === hb) continue;\n const hit = toAimPoint(add(a, scale(sub(b, a), ha / (ha - hb))), axes);\n hits.push({ x: hit.x, y: hit.y });\n }\n if (hits.length < 3) return null;\n const cx = hits.reduce((s, p) => s + p.x, 0) / hits.length;\n const cy = hits.reduce((s, p) => s + p.y, 0) / hits.length;\n const around = hits\n .map((p) => ({ p, a: Math.atan2(p.y - cy, p.x - cx) }))\n .sort((u, v) => u.a - v.a)\n .map((u) => u.p)\n .filter((p, i, all) => i === 0 || Math.hypot(p.x - all[i - 1]!.x, p.y - all[i - 1]!.y) > 1e-9);\n return around.length >= 3 ? around : null;\n}\n\nfunction projectAll(space: AimSpace, points: readonly AimPoint[]): AimOutline | null {\n const out: { x: number; y: number }[] = [];\n for (const p of points) {\n const px = space.project(p);\n if (!px) return null;\n out.push(px);\n }\n return out;\n}\n\n/**\n * The aim of view `viewId` (`null`: a surface's root): the frustum `viewport`'s camera sees. Drawn into a 2D view, it\n * outlines its footprint on the ground, the ground's two axes carrying the 2D world's x and y.\n */\nexport function aimOf3d(viewport: Viewport3d, viewId: string | null, opts: Aim3dOptions = {}): Aim3d {\n const up = opts.up ?? DEFAULT_UP;\n const axes = groundAxes(up);\n const extent = frustumOf(viewport);\n return {\n viewId,\n kind: 'frustum',\n extent,\n viewport,\n outlineIn(space) {\n if (space.kind === '3d') return projectAll(space, extent.far.map((p) => toAimPoint(p, axes)));\n const onGround = footprint(extent, up, axes);\n return onGround && projectAll(space, onGround);\n },\n pannedIn(space, from, to) {\n const a = space.unproject(from);\n const b = space.unproject(to);\n if (!a || !b) return null;\n const { camera } = viewport;\n const target = add(camera.target, sub(fromAimPoint(b, axes), fromAimPoint(a, axes)));\n return aimOf3d({ ...viewport, camera: { ...camera, target } }, viewId, opts);\n },\n };\n}\n\n/**\n * A 3D pane as a target. Its points are aim points: x and y along the ground's two axes and z, height, along `up`,\n * so a 2D world's points lie on the ground. It projects through `projectPoint` and unprojects onto the ground.\n */\nexport function aimSpace3d(viewport: Viewport3d, viewId: string | null, opts: Aim3dOptions = {}): AimSpace {\n const up = opts.up ?? DEFAULT_UP;\n const axes = groundAxes(up);\n const { x: ox, y: oy } = rectOf(viewport);\n return {\n viewId,\n kind: '3d',\n size: { width: viewport.width, height: viewport.height },\n project(p) {\n const s = projectPoint(fromAimPoint(p, axes), viewport);\n return s && { x: s.x - ox, y: s.y - oy };\n },\n unproject(px) {\n const hit = groundHit(viewport, { x: px.x + ox, y: px.y + oy }, up);\n return hit && toAimPoint(hit, axes);\n },\n };\n}\n\n/** The camera an aim was read from, which is what a by-value source's writer sets. */\nexport function cameraOfAim3d(aim: Aim3d): Camera3d {\n return aim.viewport.camera;\n}\n","/** The world boxes a snap source reads, as the document holds them, narrowed\n * by a BVH to the ones a query can reach. Keyed on the scene's version and\n * the world's `bounds`: `NodeBounds` is a function of the node alone, and a\n * move's overrides leave the version alone, so one index serves every frame\n * of a drag. The first query at a new key scans and records it; the second\n * builds. A node that occupies nothing is no target. */\n\nimport type { NodeId } from '@weasel-js/core';\nimport type { Aabb } from '@weasel-js/geom/3d';\nimport { createBvh, createSettledCache, type BoxN, type Bvh, type SettledCache } from '@weasel-js/geom/nd';\nimport { withDescendants, worldBoxes, type Node3d, type World3d } from '../world';\n\ninterface Built {\n ids: readonly NodeId[];\n boxes: readonly (Aabb | null)[];\n tree: Bvh<number>;\n /** Boxes the tree refuses (non-finite or inverted), read by every query. */\n always: readonly number[];\n}\n\nconst CACHE = new WeakMap<object, SettledCache<Built>>();\n\nlet builds = 0;\n\n/** How many box indexes have been built, for tests that pin when one rebuilds. */\nexport function snapBoxIndexBuildCount(): number {\n return builds;\n}\n\nfunction nodesOf<TData, TLayer extends string>(world: World3d<TData, TLayer>): readonly Node3d<TData, TLayer>[] {\n return world.scene.renderOrderNodes() as readonly Node3d<TData, TLayer>[];\n}\n\nfunction boxValid({ min, max }: Aabb): boolean {\n return (\n Number.isFinite(min.x) && Number.isFinite(min.y) && Number.isFinite(min.z) &&\n Number.isFinite(max.x) && Number.isFinite(max.y) && Number.isFinite(max.z) &&\n min.x <= max.x && min.y <= max.y && min.z <= max.z\n );\n}\n\nfunction build<TData, TLayer extends string>(world: World3d<TData, TLayer>): Built {\n builds++;\n const nodes = nodesOf(world);\n const boxes = nodes.map(worldBoxes(world, 'document'));\n const entries: [number, number[]][] = [];\n const always: number[] = [];\n boxes.forEach((box, i) => {\n if (box === null) return;\n const { min, max } = box;\n if (boxValid(box)) entries.push([i, [min.x, min.y, min.z, max.x, max.y, max.z]]);\n else always.push(i);\n });\n return { ids: nodes.map((n) => n.id), boxes, tree: createBvh<number>(3, entries), always };\n}\n\nfunction current<TData, TLayer extends string>(world: World3d<TData, TLayer>): Built | null {\n let cache = CACHE.get(world);\n if (cache === undefined) CACHE.set(world, (cache = createSettledCache()));\n return cache.read([world.scene.getVersion(), world.bounds], () => build(world));\n}\n\n/** Grows a query box by a relative epsilon, so rounding between the tree's\n * overlap test and a source's exact one only ever adds candidates. */\nexport function padQuery(box: number[]): number[] {\n let m = 0;\n for (const v of box) if (Number.isFinite(v)) m = Math.max(m, Math.abs(v));\n const e = 1e-9 * (1 + m);\n return [box[0]! - e, box[1]! - e, box[2]! - e, box[3]! + e, box[4]! + e, box[5]! + e];\n}\n\n/**\n * Each node's world box, in render order, leaving out `exclude` and\n * everything under it, which a move of `exclude` carries along. With\n * `near`, the index may drop any box that meets none of those boxes\n * (`[minX, minY, minZ, maxX, maxY, maxZ]`, already padded); a box that\n * meets one is always kept. Without an index, every box is returned.\n */\nexport function snapBoxes<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n exclude: readonly string[],\n near: readonly BoxN[],\n): Aabb[] {\n const excluded = withDescendants(world.scene, exclude);\n const index = near.every((b) => Array.prototype.every.call(b, (v: number) => !Number.isNaN(v))) ? current(world) : null;\n if (index === null) {\n const boxOf = worldBoxes(world, 'document');\n const out: Aabb[] = [];\n for (const node of nodesOf(world)) {\n const box = excluded.has(node.id) ? null : boxOf(node);\n if (box) out.push(box);\n }\n return out;\n }\n const found = new Set<number>(index.always);\n for (const box of near) index.tree.queryBox(box, (i) => { found.add(i); });\n const out: Aabb[] = [];\n for (const i of [...found].sort((a, b) => a - b)) {\n if (!excluded.has(index.ids[i]!)) out.push(index.boxes[i]!);\n }\n return out;\n}\n","/** What a 3D scene offers a snap session: its boxes' corners, edges, faces\n * and centers, the planes through their sides and centers, and a grid on\n * the ground. */\n\nimport type { SnapCollect, SnapMark, SnapSource, SourceCandidate } from '@weasel-js/core';\nimport { add, distance, dot, len, normalize, scale, sub, type Aabb, type Vec3 } from '@weasel-js/geom/3d';\nimport { DEFAULT_UP, type World3d } from '../world';\nimport { padQuery, snapBoxes } from './boxIndex';\nimport { planeBasis } from './plane';\nimport { boxCorner } from './probes3d';\n\ntype Axis = 'x' | 'y' | 'z';\ntype Candidate = SourceCandidate<Vec3>;\n\nconst AXES: readonly Axis[] = ['x', 'y', 'z'];\nconst BITS = [1, 2, 4] as const;\nconst UNIT: Record<Axis, Vec3> = { x: { x: 1, y: 0, z: 0 }, y: { x: 0, y: 1, z: 0 }, z: { x: 0, y: 0, z: 1 } };\nconst ACROSS: Record<Axis, readonly Vec3[]> = { x: [UNIT.y, UNIT.z], y: [UNIT.x, UNIT.z], z: [UNIT.x, UNIT.y] };\n\n/** The boxes within `r` of a probe on every axis, a superset of those within `r` of it. */\nfunction boxesNear<TData, TLayer extends string>(world: World3d<TData, TLayer>, q: SnapCollect<Vec3>, r: number): Aabb[] {\n return snapBoxes(world, q.exclude, q.probes.map(({ at: p }) => padQuery([p.x - r, p.y - r, p.z - r, p.x + r, p.y + r, p.z + r])));\n}\n\n/** The boxes reaching within `r` of a probe along some axis: every box with a side or center plane in reach. */\nfunction boxesInSlabs<TData, TLayer extends string>(world: World3d<TData, TLayer>, q: SnapCollect<Vec3>, r: number): Aabb[] {\n const slabs = q.probes.flatMap(({ at: p }) => AXES.map((axis) => {\n const lo = [-Infinity, -Infinity, -Infinity];\n const hi = [Infinity, Infinity, Infinity];\n const k = AXES.indexOf(axis);\n lo[k] = p[axis] - r;\n hi[k] = p[axis] + r;\n return padQuery([...lo, ...hi]);\n }));\n return snapBoxes(world, q.exclude, slabs);\n}\n\nfunction distanceToBox(p: Vec3, box: Aabb): number {\n const d = (a: Axis) => Math.max(box.min[a] - p[a], 0, p[a] - box.max[a]);\n return Math.hypot(d('x'), d('y'), d('z'));\n}\n\nconst centerOf = (box: Aabb): Vec3 => scale(add(box.min, box.max), 0.5);\nconst isZero = (v: Vec3) => v.x === 0 && v.y === 0 && v.z === 0;\n\n/**\n * Each node's world box as targets for geometry and pointer probes: its 8\n * corners and its center as points, its 12 edges as segments, and its 6\n * faces as bounded planes. Targets past the reach are not offered.\n */\nexport function boxSnapSource<TData, TLayer extends string>(world: World3d<TData, TLayer>): SnapSource<Vec3> {\n return {\n id: 'box',\n roles: ['geometry', 'pointer'],\n *collect(q) {\n const r = q.reachWorld(q.reachPx);\n for (const box of boxesNear(world, q, r)) {\n for (const p of q.probes) {\n if (distanceToBox(p.at, box) <= r) yield* boxLoci(p.id, p.at, box, r);\n }\n }\n },\n };\n}\n\nfunction* boxLoci(probe: string, at: Vec3, box: Aabb, r: number): Generator<Candidate> {\n for (let i = 0; i < 8; i++) {\n const c = boxCorner(box, i);\n if (distance(at, c) <= r) yield { probe, locus: { at: c, dirs: [] }, mark: { kind: 'point', at: c, glyph: 'corner' } };\n }\n const center = centerOf(box);\n if (distance(at, center) <= r) {\n yield { probe, locus: { at: center, dirs: [] }, mark: { kind: 'point', at: center, glyph: 'center' } };\n }\n for (let i = 0; i < 8; i++) {\n for (const bit of BITS) {\n if (i & bit) continue;\n const a = boxCorner(box, i);\n const b = boxCorner(box, i | bit);\n const dir = sub(b, a);\n if (isZero(dir) || distanceToBox(at, { min: a, max: b }) > r) continue;\n yield { probe, locus: { at: a, dirs: [dir], span: [[0, 1]] }, mark: { kind: 'line', from: a, to: b } };\n }\n }\n for (const bit of BITS) {\n const [b1, b2] = BITS.filter((b) => b !== bit) as [number, number];\n for (const base of [0, bit]) {\n const o = boxCorner(box, base);\n const far = boxCorner(box, base | b1 | b2);\n const d1 = sub(boxCorner(box, base | b1), o);\n const d2 = sub(boxCorner(box, base | b2), o);\n if (isZero(d1) || isZero(d2) || distanceToBox(at, { min: o, max: far }) > r) continue;\n yield {\n probe,\n locus: { at: o, dirs: [d1, d2], span: [[0, 1], [0, 1]] },\n mark: () => outline([o, boxCorner(box, base | b1), far, boxCorner(box, base | b2)]),\n };\n }\n }\n}\n\nfunction outline(ring: readonly Vec3[]): SnapMark<Vec3>[] {\n return ring.map((from, i) => ({ kind: 'line', from, to: ring[(i + 1) % ring.length]! }));\n}\n\n/**\n * The planes through each node's world box at its min, center and max on\n * every axis, as targets for box and pointer probes: alignment in depth as\n * well as across. Boxes sharing a plane offer it once, and its mark reaches\n * each of them.\n */\nexport function alignPlaneSource<TData, TLayer extends string>(world: World3d<TData, TLayer>): SnapSource<Vec3> {\n return {\n id: 'align-plane',\n roles: ['box', 'pointer'],\n *collect(q) {\n const r = q.reachWorld(q.reachPx);\n for (const [axis, planes] of planesOf(boxesInSlabs(world, q, r))) {\n for (const [value, ends] of planes) {\n for (const p of q.probes) {\n if (Math.abs(p.at[axis] - value) > r) continue;\n yield {\n probe: p.id,\n locus: { at: ends[0]!, dirs: ACROSS[axis] },\n mark: (delta: Vec3): SnapMark<Vec3>[] => {\n const from = add(sub(p.at, q.delta0), delta);\n return ends.map((to) => ({ kind: 'line', from, to }));\n },\n };\n }\n }\n }\n },\n };\n}\n\n/** Per axis, each plane value the boxes have a side or center on, and the\n * point on it at each such box's center. */\nfunction planesOf(boxes: readonly Aabb[]): Map<Axis, Map<number, Vec3[]>> {\n const out = new Map<Axis, Map<number, Vec3[]>>(AXES.map((a) => [a, new Map()]));\n for (const box of boxes) {\n const center = centerOf(box);\n for (const axis of AXES) {\n const planes = out.get(axis)!;\n for (const value of new Set([box.min[axis], center[axis], box.max[axis]])) {\n const on = { ...center, [axis]: value };\n const ends = planes.get(value);\n if (ends) ends.push(on);\n else planes.set(value, [on]);\n }\n }\n }\n return out;\n}\n\n/** Options for `groundGridSource`. */\nexport interface GroundGridSourceOptions {\n /** The grid's pitch, in world units. */\n step: number;\n /** The ground's normal; the grid lies on `up · p = 0`. Default `+y`. */\n up?: Vec3;\n}\n\n/**\n * A grid on the ground plane as snap targets: for each pointer or geometry\n * probe on the ground, the grid line on either side of it along each of the\n * ground's two axes. Its reach is unlimited and it is a fallback, so it\n * holds every axis no target claims and never displaces one.\n */\nexport function groundGridSource(opts: GroundGridSourceOptions): SnapSource<Vec3> {\n const up = normalize(opts.up ?? DEFAULT_UP);\n const [u, v] = planeBasis(up);\n const lines = (c: number): [number, number] => {\n const near = Math.round(c / opts.step) * opts.step;\n return [near, near + (c >= near ? opts.step : -opts.step)];\n };\n return {\n id: 'ground-grid',\n tier: 'fallback',\n reachPx: Infinity,\n roles: ['pointer', 'geometry'],\n *collect(q) {\n for (const p of q.probes) {\n if (Math.abs(dot(p.at, up)) > 1e-6 * Math.max(1, len(p.at))) continue;\n const a = dot(p.at, u);\n const b = dot(p.at, v);\n for (const at of lines(a)) yield { probe: p.id, locus: { at: add(scale(u, at), scale(v, b)), dirs: [v] } };\n for (const at of lines(b)) yield { probe: p.id, locus: { at: add(scale(u, a), scale(v, at)), dirs: [u] } };\n }\n },\n };\n}\n","import type { SnapMark } from '@weasel-js/core';\nimport type { Vec3 } from '@weasel-js/geom/3d';\nimport { projectPoint, type Viewport3d } from '../project';\n\ntype Point = { x: number; y: number };\n\n/** A snap mark's segment on screen: a line, a gap, or a distance. */\nexport interface ScreenLine {\n from: Point;\n to: Point;\n /** A gap's or distance's value, in world units. */\n value?: number;\n color?: string;\n}\n\n/** A snap mark's point on screen. */\nexport interface ScreenPoint {\n at: Point;\n glyph: string;\n label?: string;\n color?: string;\n}\n\n/**\n * The marks a 3D snap session draws, in the viewport's screen space, for a\n * host to draw through its own renderer. A mark with any point that does not\n * project — behind the camera — is dropped whole.\n */\nexport function projectSnapMarks(\n marks: readonly SnapMark<Vec3>[], viewport: Viewport3d,\n): { lines: ScreenLine[]; points: ScreenPoint[] } {\n const lines: ScreenLine[] = [];\n const points: ScreenPoint[] = [];\n for (const m of marks) {\n if (m.kind === 'point') {\n const at = projectPoint(m.at, viewport);\n if (at) {\n points.push({\n at, glyph: m.glyph,\n ...(m.label !== undefined ? { label: m.label } : {}),\n ...(m.color ? { color: m.color } : {}),\n });\n }\n continue;\n }\n const from = projectPoint(m.from, viewport);\n const to = projectPoint(m.to, viewport);\n if (!from || !to) continue;\n lines.push({\n from, to,\n ...('value' in m ? { value: m.value } : {}),\n ...(m.color ? { color: m.color } : {}),\n });\n }\n return { lines, points };\n}\n","/**\n * What a host paints for a gesture that proposes chrome rather than a pose.\n *\n * A marquee sweep and a box-drag both publish an `OngoingOverlay`.\n * `resolveOverlays` hands back world geometry with no renderer in it, so the\n * same call `<SceneCanvas>` makes serves a consumer-owned 3D renderer.\n *\n * A 3D host's `clientToWorld` is identity, so an overlay's world bounds are the\n * client rect the deps already work in, and the pane origin comes off exactly\n * once. Only the rectangular variants resolve here: a lasso, a pencil, and a run\n * of points are paths, and a path is geometry this cannot flatten to a box.\n */\n\nimport { overlaysOf, resolveOverlays, type OngoingHandle } from '@weasel-js/core';\nimport type { ChromeBox } from './screen';\n\n/** Gesture chrome, in CSS pixels relative to the pane's top-left. */\nexport function collectOverlayBoxes(\n handles: Iterable<OngoingHandle>,\n origin: { x: number; y: number },\n): ChromeBox[] {\n const overlays = [];\n for (const handle of handles) overlays.push(...overlaysOf(handle));\n\n const boxes: ChromeBox[] = [];\n for (const resolved of resolveOverlays(overlays)) {\n if (resolved.kind !== 'marquee' && resolved.kind !== 'insertPreview') continue;\n const { x, y, width, height } = resolved.bounds;\n boxes.push({ x: x - origin.x, y: y - origin.y, width, height, tint: 'gesture' });\n }\n return boxes;\n}\n","/**\n * The numbers an arrowhead is cut from, and how a line's shaft and head share\n * its length on screen. The line pass's vertex shader repeats {@link layoutLine}\n * in GLSL; the two must agree.\n */\n\n/**\n * An arrowhead, set by the shaft it caps: a line is set by its width alone and\n * its head follows, so a wide line is still an arrow rather than a band with a\n * small head poking out of it.\n */\nexport interface HeadShape {\n /** The head's length, in multiples of half the shaft's width. */\n lenRatio: number;\n /** The most of the line's on-screen length the head may take. */\n maxShare: number;\n /** Half the head's base as a share of its length. The cap shortens a head; it never reshapes it. */\n aspect: number;\n}\n\n/** A 16 px head 14 px across on a 4 px shaft, taking at most half the line. */\nexport const HEAD: HeadShape = { lenRatio: 8, maxShare: 0.5, aspect: 7 / 16 };\n\n/**\n * How far the shaft runs on under the head, as a share of the head's length:\n * enough to close the seam between them, little enough that a curving shaft\n * stays inside the triangle.\n */\nexport const HEAD_OVERDRAW = 0.1;\n\n/** The head a shaft carries, in pixels, and the shaft that goes under it. */\nexport interface HeadSize {\n /** The head's length. */\n headLen: number;\n /** Half the head's base. */\n headHalf: number;\n /** Half the shaft's width: narrowed by whatever the cap took off the head. */\n shaftHalf: number;\n}\n\n/**\n * The head `shaftHalf` carries on a line `linePx` long on screen. The head is\n * capped at `head.maxShare` of the line, and the shaft narrows by the share\n * the cap took, so a short line is the same arrow drawn smaller rather than a\n * full-width band with a stub on the end. Left out, `linePx` caps nothing.\n */\nexport function headFor(shaftHalf: number, linePx = Number.POSITIVE_INFINITY, head: HeadShape = HEAD): HeadSize {\n const wanted = shaftHalf * head.lenRatio;\n const headLen = Math.max(0, Math.min(wanted, head.maxShare * linePx));\n const headHalf = headLen * head.aspect;\n const shrunk = wanted > 0 ? (shaftHalf * headLen) / wanted : shaftHalf;\n return { headLen, headHalf, shaftHalf: wanted > 0 ? Math.min(shrunk, headHalf) : shrunk };\n}\n\n/** {@link HeadSize}, plus where along the line its shaft stops. */\nexport interface LineLayout extends HeadSize {\n /** Where the shaft ends, in the line's own length units. */\n shaftEnd: number;\n}\n\n/**\n * How a line `length` long in its own units, drawn at `pxPerUnit` pixels per\n * unit near its tip, splits between shaft and head. A line with no head\n * (`head` null) or no known scale runs its shaft to the end.\n */\nexport function layoutLine(\n shaftHalf: number, length: number, pxPerUnit: number, head: HeadShape | null,\n): LineLayout {\n if (!head || !(pxPerUnit > 0)) return { headLen: 0, headHalf: 0, shaftHalf, shaftEnd: length };\n const size = headFor(shaftHalf, pxPerUnit * length, head);\n return { ...size, shaftEnd: length - (size.headLen / pxPerUnit) * (1 - HEAD_OVERDRAW) };\n}\n","/**\n * Lines as the line pass's vertices. Trimming happens here, on the CPU and in\n * the line's own space; widths and the head are pixels, laid out by the shader\n * once the camera is known.\n */\n\nimport { curveSpan, lengthTable, type CurveSpan } from '@weasel-js/geom';\nimport { transformPoint, type Mat4, type Vec3 } from '@weasel-js/geom/3d';\nimport type { StrokeTrim } from '@weasel-js/paint';\nimport { resolveTrim } from '@weasel-js/stroke';\nimport { HEAD, type HeadShape } from './head';\n\n/** One subpath of a {@link Line3}: points joined by straight segments. */\nexport interface LineRun3 {\n points: readonly Vec3[];\n /** Whether a closing edge runs from the last point back to the first. */\n closed?: boolean;\n}\n\n/** A polyline drawn a fixed number of pixels wide, whatever its depth. */\nexport interface Line3 {\n /** Subpaths in pen order, which is the order a trim runs. */\n runs: readonly LineRun3[];\n /** Straight (not premultiplied) RGBA, each 0–1. */\n color: readonly [number, number, number, number];\n /** The shaft's width in CSS pixels. Default 4. */\n width?: number;\n /** The head at each open run's end; null for none. Default {@link HEAD}. */\n head?: HeadShape | null;\n /** The stretch drawn, measured in the line's own space. */\n trim?: StrokeTrim;\n /** From the line's own space to the world. Default identity. */\n model?: Mat4;\n}\n\n/** A visible stretch of a line: what the pass draws as one shaft and at most one head. */\nexport interface VisibleRun3 {\n /** In the line's own space. */\n points: Vec3[];\n closed: boolean;\n headed: boolean;\n}\n\n/** Floats per vertex; see {@link packLines} for the layout. */\nexport const LINE_FLOATS = 29;\n\n/** Which point of its segment a vertex sits at. */\nexport const ROLE_BACK = 0;\nexport const ROLE_SHAFT_END = 1;\nexport const ROLE_HEAD_BASE = 2;\nexport const ROLE_TIP = 3;\n\n/** `[role, side]` per vertex: two triangles of shaft, then the head's one. */\nconst SHAFT_CORNERS = [\n [ROLE_BACK, -1], [ROLE_BACK, 1], [ROLE_SHAFT_END, 1],\n [ROLE_BACK, -1], [ROLE_SHAFT_END, 1], [ROLE_SHAFT_END, -1],\n] as const;\nconst HEAD_CORNERS = [[ROLE_HEAD_BASE, -1], [ROLE_HEAD_BASE, 1], [ROLE_TIP, 0]] as const;\n\nconst flat = (points: readonly Vec3[]): number[] => points.flatMap((p) => [p.x, p.y, p.z]);\nconst lerp3 = (a: Vec3, b: Vec3, t: number): Vec3 =>\n ({ x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t, z: a.z + (b.z - a.z) * t });\nconst dist = (a: Vec3, b: Vec3): number => Math.hypot(b.x - a.x, b.y - a.y, b.z - a.z);\n\n/**\n * The stretches of `line` its trim leaves, one per subpath the trim reaches.\n * A closed subpath the trim covers whole stays closed; one it cuts is open and,\n * as a closed subpath takes no marker, carries no head.\n */\nexport function visibleRuns(line: Line3): VisibleRun3[] {\n const runs = line.runs.filter((r) => r.points.length >= 2);\n if (runs.length === 0) return [];\n const table = lengthTable(runs.map((r) => ({ points: flat(r.points), closed: !!r.closed })), 3);\n const span = resolveTrim(table, line.trim);\n const cut = span && curveSpan(table, span);\n if (!cut) return [];\n const out: VisibleRun3[] = [];\n for (let r = cut.from.run; r <= cut.to.run; r++) {\n const run = windowRun(runs[r], r, cut);\n if (run) out.push({ ...run, headed: !run.closed && !runs[r].closed && line.head !== null });\n }\n return out;\n}\n\nfunction windowRun(run: LineRun3, r: number, cut: CurveSpan): { points: Vec3[]; closed: boolean } | null {\n const pts = run.points;\n const n = pts.length;\n const segments = run.closed ? n : n - 1;\n const at = (i: number) => pts[i % n];\n const from = r === cut.from.run ? cut.from : { segment: 0, t: 0 };\n const to = r === cut.to.run ? cut.to : { segment: segments - 1, t: 1 };\n if (run.closed && from.segment === 0 && from.t === 0 && to.segment === segments - 1 && to.t === 1) {\n return { points: [...pts], closed: true };\n }\n const out: Vec3[] = [lerp3(at(from.segment), at(from.segment + 1), from.t)];\n for (let k = from.segment + 1; k <= to.segment; k++) out.push(at(k));\n out.push(lerp3(at(to.segment), at(to.segment + 1), to.t));\n const kept = out.filter((p, i) => i === 0 || dist(out[i - 1], p) > 0);\n return kept.length >= 2 ? { points: kept, closed: false } : null;\n}\n\n/**\n * `lines` as the line pass draws them: six vertices a segment, three more for\n * a head, `LINE_FLOATS` floats each, laid out as\n *\n * | floats | holds |\n * |---|---|\n * | 0–2, 3–5 | the segment's two ends, in the world |\n * | 6–8 | the point past this vertex's own end, so the shaft can miter |\n * | 9, 10 | role and side |\n * | 11–13 | the segment's start and end along its run, and the run's length, in the line's own units |\n * | 14–17 | half the shaft's width in pixels, then the head's `lenRatio`, `maxShare` and `aspect` (`lenRatio` 0: no head) |\n * | 18–20, 21–23, 24 | the run's tip, the start of its last segment, and that segment's length: one screen scale for every vertex of the run |\n * | 25–28 | straight RGBA |\n */\nexport function packLines(lines: readonly Line3[]): Float32Array {\n const chunks: number[] = [];\n for (const line of lines) {\n const shaftHalf = (line.width ?? 4) / 2;\n const head = line.head === undefined ? HEAD : line.head;\n const toWorld = line.model ? (p: Vec3) => transformPoint(line.model!, p) : (p: Vec3) => p;\n for (const run of visibleRuns(line)) {\n packRun(chunks, run, run.points.map(toWorld), shaftHalf, run.headed ? head : null, line.color);\n }\n }\n return Float32Array.from(chunks);\n}\n\nfunction packRun(\n out: number[], run: VisibleRun3, world: readonly Vec3[], shaftHalf: number,\n head: HeadShape | null, color: Line3['color'],\n): void {\n const n = world.length;\n const segments = run.closed ? n : n - 1;\n const at = (i: number) => world[((i % n) + n) % n];\n const along = [0];\n for (let i = 0; i < segments; i++) along.push(along[i] + dist(run.points[i], run.points[(i + 1) % n]));\n const total = along[segments];\n const apex = at(segments);\n const apexBack = at(segments - 1);\n const reach = total - along[segments - 1];\n const shape = head ? [head.lenRatio, head.maxShare, head.aspect] : [0, 0, 0];\n for (let i = 0; i < segments; i++) {\n const a = at(i);\n const b = at(i + 1);\n // A free end has no neighbor; pointing at itself, it keeps its own perpendicular.\n const before = run.closed || i > 0 ? at(i - 1) : a;\n const after = run.closed || i + 2 <= n - 1 ? at(i + 2) : b;\n const corners = head && i === segments - 1 ? [...SHAFT_CORNERS, ...HEAD_CORNERS] : SHAFT_CORNERS;\n for (const [role, side] of corners) {\n const adj = role === ROLE_BACK ? before : role === ROLE_SHAFT_END ? after : b;\n out.push(\n a.x, a.y, a.z, b.x, b.y, b.z, adj.x, adj.y, adj.z, role, side,\n along[i], along[i + 1], total, shaftHalf, ...shape,\n apex.x, apex.y, apex.z, apexBack.x, apexBack.y, apexBack.z, reach,\n ...color,\n );\n }\n }\n}\n","import { HEAD_OVERDRAW } from './head';\nimport { ROLE_SHAFT_END, ROLE_TIP } from './pack';\n\n/**\n * A line is expanded in screen space after projection: its width and its head\n * are pixels, so a line across the whole scene is as legible as one beside the\n * camera. Every vertex carries both ends of its segment, which is what gives\n * it a direction on screen.\n *\n * The shaft stops under the head at a length along the run, so it is cut where\n * it lies. The head stands back from the tip along its own segment's straight\n * direction on screen, never back along the path: a head longer than its\n * segment would otherwise interpolate past the segment's end and run the\n * perspective divide through zero. The scale a head is sized by is read from\n * the run's last segment, which every vertex of the run carries, so every\n * segment cuts its shaft at the same place.\n */\nexport const LINE_VS = `#version 300 es\nprecision highp float;\nlayout(location = 0) in vec3 a_from;\nlayout(location = 1) in vec3 a_to;\nlayout(location = 2) in vec3 a_adj;\nlayout(location = 3) in vec2 a_corner;\nlayout(location = 4) in vec3 a_along;\nlayout(location = 5) in vec4 a_shape;\nlayout(location = 6) in vec3 a_apex;\nlayout(location = 7) in vec4 a_apexBack;\nlayout(location = 8) in vec4 a_color;\nuniform mat4 u_viewProjection;\n/* Half the viewport in CSS pixels: ndc times this is pixels. */\nuniform vec2 u_halfViewport;\nout vec4 v_color;\nconst float OVERDRAW = ${HEAD_OVERDRAW.toFixed(3)};\n/* How far a bisector may stretch before the corner is let go; a hairpin would run to infinity. */\nconst float MITER_LIMIT = 4.0;\nconst vec4 CULLED = vec4(0.0, 0.0, 2.0, 1.0);\n\nvec2 screenOf(vec4 c) { return c.xy / c.w * u_halfViewport; }\n\nvoid main() {\n v_color = a_color;\n vec4 ca = u_viewProjection * vec4(a_from, 1.0);\n vec4 cb = u_viewProjection * vec4(a_to, 1.0);\n /* An end behind the eye projects to a line across the whole screen; drop the segment instead. */\n if (ca.w <= 0.0 || cb.w <= 0.0) { gl_Position = CULLED; return; }\n vec2 sa = screenOf(ca);\n vec2 sb = screenOf(cb);\n vec2 d = sb - sa;\n float L = length(d);\n vec2 dir = L > 0.0 ? d / L : vec2(1.0, 0.0);\n vec2 perp = vec2(-dir.y, dir.x);\n float role = a_corner.x;\n float side = a_corner.y;\n float s0 = a_along.x;\n float s1 = a_along.y;\n float total = a_along.z;\n float span = s1 - s0;\n\n /* Pixels per unit near the tip, the same for every segment of the run; this segment's own where the tip is unseen. */\n float density = span > 0.0 ? L / span : 0.0;\n vec4 cp = u_viewProjection * vec4(a_apex, 1.0);\n vec4 cq = u_viewProjection * vec4(a_apexBack.xyz, 1.0);\n float reach = a_apexBack.w;\n if (reach > 0.0 && cp.w > 0.0 && cq.w > 0.0) {\n float px = length(screenOf(cp) - screenOf(cq));\n if (px > 0.0) density = px / reach;\n }\n\n /* layoutLine in head.ts, repeated. */\n float shaftHalf = a_shape.x;\n float wanted = shaftHalf * a_shape.y;\n float headPx = 0.0;\n float headHalf = 0.0;\n float shaft = shaftHalf;\n float shaftEnd = total;\n if (wanted > 0.0 && density > 0.0) {\n headPx = max(0.0, min(wanted, a_shape.z * density * total));\n headHalf = headPx * a_shape.w;\n shaft = min(shaftHalf * headPx / wanted, headHalf);\n shaftEnd = total - headPx / density * (1.0 - OVERDRAW);\n }\n\n if (role > ${(ROLE_SHAFT_END + 0.5).toFixed(1)}) {\n if (headPx <= 0.0) { gl_Position = CULLED; return; }\n if (role > ${(ROLE_TIP - 0.5).toFixed(1)}) { gl_Position = cb; return; }\n vec2 base = sb - dir * headPx + perp * side * headHalf;\n gl_Position = vec4(base / u_halfViewport * cb.w, cb.z, cb.w);\n return;\n }\n\n float to = min(s1, shaftEnd);\n if (to <= s0 || span <= 0.0) { gl_Position = CULLED; return; }\n bool atEnd = role > 0.5;\n /* Clip space is linear in the world, so a fraction of the segment lands at its true depth. */\n vec4 c = mix(ca, cb, atEnd ? (to - s0) / span : 0.0);\n vec2 miter = perp;\n float stretch = 1.0;\n /* Only an end that meets its neighbor miters; a shaft cut short under the head stays square. */\n if (!atEnd || to >= s1) {\n vec4 cj = u_viewProjection * vec4(a_adj, 1.0);\n if (cj.w > 0.0) {\n vec2 sj = screenOf(cj);\n vec2 e = atEnd ? sj - sb : sa - sj;\n float eL = length(e);\n if (eL > 0.0) {\n vec2 o = e / eL;\n vec2 bisect = perp + vec2(-o.y, o.x);\n float bL = length(bisect);\n if (bL > 0.0001) {\n vec2 m = bisect / bL;\n float cosHalf = dot(m, perp);\n if (cosHalf > 1.0 / MITER_LIMIT) { miter = m; stretch = 1.0 / cosHalf; }\n }\n }\n }\n }\n c.xy += miter * side * shaft * stretch / u_halfViewport * c.w;\n gl_Position = c;\n}`;\n\n/** Flat color, straight alpha. */\nexport const LINE_FS = `#version 300 es\nprecision mediump float;\nin vec4 v_color;\nout vec4 fragColor;\nvoid main() {\n fragColor = v_color;\n}`;\n","import type { Mat4 } from '@weasel-js/geom/3d';\nimport { LINE_FLOATS } from './pack';\nimport { LINE_FS, LINE_VS } from './pass.glsl';\n\n/** Options for {@link LinePass.draw}. */\nexport interface LineDrawOptions {\n /** Hide the parts of a line behind what the bound depth buffer holds. Default true. */\n depthTest?: boolean;\n}\n\n/**\n * Lines drawn into a WebGL2 context the host owns. The kernel hosts a renderer\n * rather than owning one; this is a pass that renderer calls, between its own.\n */\nexport interface LinePass {\n /**\n * Draw `vertices`, as {@link packLines} lays them out, into the bound\n * framebuffer under the host's `gl.viewport`. `viewProjection` takes world\n * points to clip space; `size` is that viewport in CSS pixels, the unit a\n * line's width is given in. Depth is tested, not written, and blending is\n * straight alpha. The capabilities, depth mask, blend function, program,\n * vertex array and array buffer it changes are put back as it found them.\n */\n draw(\n vertices: Float32Array,\n viewProjection: Mat4,\n size: { width: number; height: number },\n options?: LineDrawOptions,\n ): void;\n dispose(): void;\n}\n\n/** `[size, offset]` per attribute location, in floats, in `LINE_FLOATS` order. */\nconst ATTRIBUTES: readonly (readonly [number, number])[] = [\n [3, 0], [3, 3], [3, 6], [2, 9], [3, 11], [4, 14], [3, 18], [4, 21], [4, 25],\n];\n\nfunction compile(gl: WebGL2RenderingContext, type: number, source: string): WebGLShader {\n const shader = gl.createShader(type)!;\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS) && !gl.isContextLost()) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`kernel3d line pass: shader failed to compile: ${log}`);\n }\n return shader;\n}\n\nfunction link(gl: WebGL2RenderingContext): WebGLProgram {\n const program = gl.createProgram()!;\n const vs = compile(gl, gl.VERTEX_SHADER, LINE_VS);\n const fs = compile(gl, gl.FRAGMENT_SHADER, LINE_FS);\n gl.attachShader(program, vs);\n gl.attachShader(program, fs);\n gl.linkProgram(program);\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS) && !gl.isContextLost()) {\n const log = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw new Error(`kernel3d line pass: program failed to link: ${log}`);\n }\n return program;\n}\n\n/** A {@link LinePass} on `gl`: one program, one vertex array, one buffer refilled each draw. */\nexport function createLinePass(gl: WebGL2RenderingContext): LinePass {\n const program = link(gl);\n const viewProjection = gl.getUniformLocation(program, 'u_viewProjection');\n const halfViewport = gl.getUniformLocation(program, 'u_halfViewport');\n const buffer = gl.createBuffer();\n const vao = gl.createVertexArray();\n\n const prevVao = gl.getParameter(gl.VERTEX_ARRAY_BINDING) as WebGLVertexArrayObject | null;\n const prevBuffer = gl.getParameter(gl.ARRAY_BUFFER_BINDING) as WebGLBuffer | null;\n gl.bindVertexArray(vao);\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n ATTRIBUTES.forEach(([size, offset], loc) => {\n gl.enableVertexAttribArray(loc);\n gl.vertexAttribPointer(loc, size, gl.FLOAT, false, LINE_FLOATS * 4, offset * 4);\n });\n gl.bindVertexArray(prevVao);\n gl.bindBuffer(gl.ARRAY_BUFFER, prevBuffer);\n\n const matrix = new Float32Array(16);\n\n return {\n draw(vertices, vp, size, options = {}) {\n if (vertices.length === 0) return;\n const was = {\n program: gl.getParameter(gl.CURRENT_PROGRAM) as WebGLProgram | null,\n vao: gl.getParameter(gl.VERTEX_ARRAY_BINDING) as WebGLVertexArrayObject | null,\n buffer: gl.getParameter(gl.ARRAY_BUFFER_BINDING) as WebGLBuffer | null,\n blend: gl.isEnabled(gl.BLEND),\n depth: gl.isEnabled(gl.DEPTH_TEST),\n cull: gl.isEnabled(gl.CULL_FACE),\n depthMask: gl.getParameter(gl.DEPTH_WRITEMASK) as boolean,\n blendFunc: [gl.BLEND_SRC_RGB, gl.BLEND_DST_RGB, gl.BLEND_SRC_ALPHA, gl.BLEND_DST_ALPHA]\n .map((p) => gl.getParameter(p) as number) as [number, number, number, number],\n };\n\n gl.useProgram(program);\n matrix.set(vp);\n gl.uniformMatrix4fv(viewProjection, false, matrix);\n gl.uniform2f(halfViewport, Math.max(1, size.width) / 2, Math.max(1, size.height) / 2);\n gl.enable(gl.BLEND);\n gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);\n // A segment's quad winds whichever way its direction on screen turns it.\n gl.disable(gl.CULL_FACE);\n if (options.depthTest ?? true) gl.enable(gl.DEPTH_TEST);\n else gl.disable(gl.DEPTH_TEST);\n gl.depthMask(false);\n gl.bindVertexArray(vao);\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.DYNAMIC_DRAW);\n gl.drawArrays(gl.TRIANGLES, 0, vertices.length / LINE_FLOATS);\n\n gl.useProgram(was.program);\n gl.bindVertexArray(was.vao);\n gl.bindBuffer(gl.ARRAY_BUFFER, was.buffer);\n const set = (cap: number, on: boolean) => (on ? gl.enable(cap) : gl.disable(cap));\n set(gl.BLEND, was.blend);\n set(gl.DEPTH_TEST, was.depth);\n set(gl.CULL_FACE, was.cull);\n gl.depthMask(was.depthMask);\n gl.blendFuncSeparate(...was.blendFunc);\n },\n\n dispose() {\n gl.deleteVertexArray(vao);\n gl.deleteBuffer(buffer);\n gl.deleteProgram(program);\n },\n };\n}\n","/**\n * Camera tools and their actions.\n *\n * Shape tools transfer from the kit untouched — a 3D host mounts core's own\n * `useSelectTool` and a rectangle-style insert binding and neither notices the\n * dimension. Only the viewport tools are written here, which is the one\n * exception the kernel doc predicted: `useHandTool` routes to\n * `viewport.dragPan`, and that wants the 2D `view`.\n */\n\nimport { useMemo } from 'react';\nimport { defineTool, type Action, type InvocationCtx, type Tool } from '@weasel-js/core';\nimport { dollyToward, orbitBy, panBy, type Camera3d } from './camera';\nimport type { Camera3dDep } from './cameraDep';\n\n/** Radians per CSS pixel of drag. A full pane width is a bit over half a turn. */\nexport const ORBIT_RATE = 0.006;\n/** Dolly exponent per unit of wheel `deltaY`. */\nexport const DOLLY_RATE = 0.0015;\n\n/**\n * The drag's cumulative client-pixel delta.\n *\n * The fallback is only sound because a 3D host's `clientToWorld` is identity\n * (see `overlays.ts`), so the world delta already is the client one. Don't copy\n * this to a host with a 2D view — there the two spaces differ by the zoom.\n */\nfunction screenDelta(move: InvocationCtx): { x: number; y: number } | undefined {\n return move.drag?.screenDelta ?? move.drag?.delta;\n}\n\n/** An ongoing drag replacing the `camera3d` dep with `step` of the camera as\n * it was when the drag began. `drag.delta` runs from the drag origin, not the\n * previous move, so every move composes against that one camera. */\nfunction dragCamera(\n ctx: InvocationCtx,\n kind: string,\n step: (origin: Camera3d, delta: { x: number; y: number }, dep: Camera3dDep) => Camera3d,\n) {\n const dep = ctx.deps.camera3d;\n const origin: Camera3d | undefined = dep?.get();\n return {\n kind,\n onMove(move: InvocationCtx) {\n const delta = screenDelta(move);\n if (!dep || !origin || !delta) return;\n dep.set(step(origin, delta, dep));\n },\n };\n}\n\n/** `camera.orbit`: an ongoing drag that turns the `camera3d` dep about its\n * target. */\nexport const orbitAction: Action = {\n id: 'camera.orbit',\n label: 'Orbit',\n group: 'viewport',\n cursor: 'grab',\n activeCursor: 'grabbing',\n requires: ['camera3d', 'kitSettings'],\n invoker: {\n timing: 'ongoing',\n start(ctx) {\n const rate = ctx.deps.kitSettings?.get('orbit3d.orbitRate') ?? ORBIT_RATE;\n return dragCamera(ctx, 'orbit', (origin, d, dep) =>\n orbitBy(origin, -d.x * rate, d.y * rate, dep.limits?.()));\n },\n },\n};\n\n/** `camera.pan`: an ongoing drag that slides the `camera3d` dep's target\n * across the screen plane, so the point at the target follows the pointer. */\nexport const panAction: Action = {\n id: 'camera.pan',\n label: 'Pan',\n group: 'viewport',\n cursor: 'move',\n requires: ['camera3d'],\n invoker: {\n timing: 'ongoing',\n start(ctx) {\n return dragCamera(ctx, 'pan', (origin, d, dep) =>\n panBy(origin, d.x, d.y, dep.size().height));\n },\n },\n};\n\n/** Where on the pane a dolly anchors: the canvas-local point the event\n * carries, or the middle when it carries none. */\nfunction anchorOf(\n params: Record<string, unknown> | undefined,\n pane: { width: number; height: number },\n): { x: number; y: number } {\n const x = params?.clientX;\n const y = params?.clientY;\n return typeof x === 'number' && typeof y === 'number'\n ? { x, y }\n : { x: pane.width / 2, y: pane.height / 2 };\n}\n\n/** `camera.dolly`: moves the `camera3d` dep in or out about the point under\n * the pointer, as a 2D camera's wheel zooms about it. A wheel's `deltaY`, and\n * a trackpad pinch delivered as ctrl+wheel, dolly by `exp(deltaY × rate)` —\n * one rate for both, as a 2D camera zooms by both. Safari's pinch arrives as\n * a `scale` and divides the distance by it. Bound to all three by default, in\n * every tool. */\nexport const dollyAction: Action = {\n id: 'camera.dolly',\n label: 'Dolly',\n group: 'viewport',\n defaultBinding: [\n { spec: { kind: 'wheel' }, opts: { id: 'camera.dolly.wheel' } },\n // Unbound, a trackpad pinch zooms the page instead.\n { spec: { kind: 'wheel', mods: { ctrl: true } }, opts: { id: 'camera.dolly.trackpadPinch' } },\n { spec: { kind: 'pinch' }, opts: { id: 'camera.dolly.pinch' } },\n ],\n requires: ['camera3d', 'kitSettings'],\n invoker: {\n timing: 'immediate',\n run(deps, params) {\n const dep = deps.camera3d;\n if (!dep) return;\n const factor = typeof params?.scale === 'number'\n ? 1 / params.scale\n : Math.exp(\n (typeof params?.deltaY === 'number' ? params.deltaY : 0)\n * (deps.kitSettings?.get('orbit3d.dollyRate') ?? DOLLY_RATE),\n );\n if (!(factor > 0) || !Number.isFinite(factor)) return;\n const pane = dep.size();\n dep.set(dollyToward(dep.get(), factor, anchorOf(params, pane), pane, dep.limits?.()));\n },\n },\n};\n\n/** `camera.pinchDolly`: two fingers spreading dolly the `camera3d` dep in and\n * closing dolly it out, by the ratio of their spread, about where they began. */\nexport const pinchDollyAction: Action = {\n id: 'camera.pinchDolly',\n label: 'Pinch Dolly',\n group: 'viewport',\n defaultBinding: [{ spec: { kind: 'multiTouch', fingers: 2 }, opts: { id: 'camera.pinchDolly.multiTouch' } }],\n requires: ['camera3d'],\n invoker: {\n timing: 'ongoing',\n start(ctx) {\n const dep = ctx.deps.camera3d;\n const origin: Camera3d | undefined = dep?.get();\n const startSpread = ctx.multiTouch?.spread ?? 0;\n const at = ctx.multiTouch?.centroid;\n return {\n kind: 'pinch',\n onMove(move) {\n const spread = move.multiTouch?.pinch?.currentSpread ?? 0;\n if (!dep || !origin || !(startSpread > 0) || !(spread > 0)) return;\n const pane = dep.size();\n const anchor = at ?? { x: pane.width / 2, y: pane.height / 2 };\n dep.set(dollyToward(origin, startSpread / spread, anchor, pane, dep.limits?.()));\n },\n };\n },\n },\n};\n\n/** `camera.home`: returns the `camera3d` dep to its `home`. Bound to a double\n * click by default. */\nexport const homeAction: Action = {\n id: 'camera.home',\n label: 'Reset Camera',\n group: 'viewport',\n defaultBinding: [{ spec: { kind: 'doubleClick' }, opts: { id: 'camera.home.doubleClick' } }],\n requires: ['camera3d'],\n invoker: {\n timing: 'immediate',\n run(deps) {\n const dep = deps.camera3d;\n const home = dep?.home?.();\n if (dep && home) dep.set(home);\n },\n },\n};\n\n/** A tool that binds a drag to `camera.orbit` and Shift+drag to `camera.pan`.\n * Register both actions alongside it; the tool only declares the bindings. */\nexport function useOrbitTool(): Tool {\n return useMemo(() => defineTool({\n id: 'orbit',\n hookName: 'useOrbitTool',\n cursor: 'grab',\n presentation: { label: 'Orbit', group: 'viewport' },\n bindings: [\n { spec: { kind: 'drag' }, actionId: 'camera.orbit', opts: { id: 'orbit.orbit' } },\n { spec: { kind: 'drag', mods: { shift: true } }, actionId: 'camera.pan', opts: { id: 'orbit.pan' } },\n ],\n }), []);\n}\n","import type {} from '@weasel-js/react';\nimport { pref } from '@weasel-js/prefs';\nimport { DOLLY_RATE, ORBIT_RATE } from './tools';\n\n/** The `orbit3d` kit settings area: how far the camera tools move per input. */\nexport interface Orbit3dKitSettings {\n /** Radians of orbit per CSS pixel of drag. */\n orbitRate: number;\n /** Dolly exponent per unit of wheel `deltaY`. */\n dollyRate: number;\n}\n\ndeclare module '@weasel-js/react' {\n interface KitSettings {\n orbit3d: Orbit3dKitSettings;\n }\n}\n\n/** The `orbit3d` area as a prefs group whose paths are the `KitSettings` paths. */\nexport const kernel3dKitSettingsSchema = pref.group('3D camera', {\n orbit3d: pref.group('Orbit', {\n orbitRate: pref.number('Orbit speed', ORBIT_RATE, { min: 0.001, max: 0.03, step: 0.001 }),\n dollyRate: pref.number('Dolly speed', DOLLY_RATE, { min: 0.0002, max: 0.01, step: 0.0001 }),\n }),\n});\n"]}
1
+ {"version":3,"sources":["../src/camera.ts","../src/pose3.ts","../src/composePose3.ts","../src/screen.ts","../src/project.ts","../src/ground.ts","../src/world.ts","../src/pickIndex.ts","../src/snap/plane.ts","../src/snap/probes3d.ts","../src/snap/session3d.ts","../src/deps.ts","../src/insert.ts","../src/aim.ts","../src/snap/boxIndex.ts","../src/snap/sources.ts","../src/snap/marks.ts","../src/overlays.ts","../src/lines/head.ts","../src/lines/pack.ts","../src/lines/pass.glsl.ts","../src/lines/pass.ts","../src/tools.ts","../src/kitSettings.ts"],"names":["distance","scale","add","sub","transformPoint4","compose","normalize","dot","ZERO","intersectRayPlane","pointOnRay","cross","build","scaleBy","len","quatIdentity","level","CACHE","boxValid","createBvh","out","transformPoint"],"mappings":";;;;;;;;;;;AAmCO,IAAM,SAAA,GAAY,IAAA,CAAK,EAAA,GAAK,CAAA,GAAI;AACvC,IAAM,KAAW,EAAE,CAAA,EAAG,GAAG,CAAA,EAAG,CAAA,EAAG,GAAG,CAAA,EAAE;AAI7B,SAAS,aAAa,IAAA,EAAmC;AAC9D,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,KAAK,MAAA,IAAU,EAAE,GAAG,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAA,EAAE;AAAA,IAC1C,GAAA,EAAK,KAAK,GAAA,IAAO,CAAA;AAAA,IACjB,KAAA,EAAO,KAAK,KAAA,IAAS,CAAA;AAAA,IACrB,QAAA,EAAU,KAAK,QAAA,IAAY,EAAA;AAAA,IAC3B,GAAA,EAAK,IAAA,CAAK,GAAA,IAAO,IAAA,CAAK,EAAA,GAAK,CAAA;AAAA,IAC3B,IAAA,EAAM,KAAK,IAAA,IAAQ,GAAA;AAAA,IACnB,GA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AAA,CAAM,OAAA,EAAS;AAAA,IAC3B,SAAA,EAAW,IAAA,CAAK,MAAA,CAAO,aAAA,EAAe,UAAA,EAAY,EAAE,GAAA,EAAK,IAAA,EAAO,GAAA,EAAK,IAAA,EAAM,IAAA,EAAM,IAAA,EAAO,CAAA;AAAA,IACxF,SAAA,EAAW,IAAA,CAAK,MAAA,CAAO,aAAA,EAAe,UAAA,EAAY,EAAE,GAAA,EAAK,IAAA,EAAQ,GAAA,EAAK,IAAA,EAAM,IAAA,EAAM,IAAA,EAAQ;AAAA,GAC3F;AACH,CAAC","file":"index.js","sourcesContent":["/**\n * An orbit camera: a target, two angles and a distance. Immutable — every\n * gesture returns a new one, so it can live in instrument state.\n *\n * This is the shape `ViewApi` cannot hold, and the reason the kernel declares a\n * `camera3d` dep of its own rather than reusing the kit's `view`.\n */\n\nimport {\n add,\n lookAt,\n multiply,\n perspective,\n scale,\n type Mat4,\n type Vec3,\n} from '@weasel-js/geom/3d';\nimport { clamp } from '@weasel-js/geom';\n\n/** An orbit camera. The eye sits `distance` world units from `target` at\n * `yaw`/`pitch`; `fov` is the vertical field of view in radians, and\n * `near`/`far` the clip distances. */\nexport interface Camera3d {\n target: Vec3;\n /** Radians about +y, measured from +z. */\n yaw: number;\n /** Radians above the xz plane. */\n pitch: number;\n distance: number;\n fov: number;\n near: number;\n far: number;\n}\n\n/** Short of vertical: at exactly ±π/2 the eye lands on the up axis and `lookAt` degenerates. */\nexport const MAX_PITCH = Math.PI / 2 - 0.01;\nconst UP: Vec3 = { x: 0, y: 1, z: 0 };\n\n/** A camera with defaults for every field not given: origin target, level at\n * yaw 0, distance 10, fov π/4, near 0.1, far 1000. */\nexport function createCamera(init: Partial<Camera3d>): Camera3d {\n return {\n target: init.target ?? { x: 0, y: 0, z: 0 },\n yaw: init.yaw ?? 0,\n pitch: init.pitch ?? 0,\n distance: init.distance ?? 10,\n fov: init.fov ?? Math.PI / 4,\n near: init.near ?? 0.1,\n far: init.far ?? 1000,\n };\n}\n\n/** The eye's world position. */\nexport function cameraEye(camera: Camera3d): Vec3 {\n const { target, yaw, pitch, distance } = camera;\n const horizontal = Math.cos(pitch) * distance;\n return {\n x: target.x + horizontal * Math.sin(yaw),\n y: target.y + Math.sin(pitch) * distance,\n z: target.z + horizontal * Math.cos(yaw),\n };\n}\n\n/** World-to-view matrix, with +y up. */\nexport function cameraView(camera: Camera3d): Mat4 {\n return lookAt(cameraEye(camera), camera.target, UP);\n}\n\n/** World-to-clip matrix for a pane of the given width/height `aspect`. */\nexport function cameraViewProjection(camera: Camera3d, aspect: number): Mat4 {\n return multiply(perspective(camera.fov, aspect, camera.near, camera.far), cameraView(camera));\n}\n\n/** How far an orbit camera may turn and travel. Distances are in world units,\n * so a scene measured in millimeters and one in kilometers want different ones. */\nexport interface OrbitLimits {\n minDistance: number;\n maxDistance: number;\n /** Radians. Held inside ±`MAX_PITCH` whatever is asked for. */\n minPitch: number;\n maxPitch: number;\n}\n\n/** Pitch short of the poles, distance 0.5..500. */\nexport const DEFAULT_ORBIT_LIMITS: OrbitLimits = {\n minDistance: 0.5,\n maxDistance: 500,\n minPitch: -MAX_PITCH,\n maxPitch: MAX_PITCH,\n};\n\n/** The camera with its pitch and distance inside `limits`. Returns `camera`\n * itself when it already holds. */\nexport function clampCamera(camera: Camera3d, limits: Partial<OrbitLimits> = {}): Camera3d {\n const l = { ...DEFAULT_ORBIT_LIMITS, ...limits };\n const pitch = clamp(camera.pitch, Math.max(-MAX_PITCH, l.minPitch), Math.min(MAX_PITCH, l.maxPitch));\n const distance = clamp(camera.distance, l.minDistance, l.maxDistance);\n if (pitch === camera.pitch && distance === camera.distance) return camera;\n return { ...camera, pitch, distance };\n}\n\n/** The camera turned about its target by the given radians, pitch held inside\n * `limits`. Yaw is not wrapped. */\nexport function orbitBy(\n camera: Camera3d,\n deltaYaw: number,\n deltaPitch: number,\n limits?: Partial<OrbitLimits>,\n): Camera3d {\n return clampCamera(\n { ...camera, yaw: camera.yaw + deltaYaw, pitch: camera.pitch + deltaPitch },\n limits,\n );\n}\n\n/** The camera with its distance multiplied by `factor`, held inside `limits`. */\nexport function dollyBy(camera: Camera3d, factor: number, limits?: Partial<OrbitLimits>): Camera3d {\n return clampCamera({ ...camera, distance: camera.distance * factor }, limits);\n}\n\n/**\n * The camera with its target slid across the screen plane, so the point at the\n * target follows a pointer that moved `dx`, `dy` CSS pixels in a pane\n * `paneHeight` pixels tall. Neither angle nor distance changes.\n */\nexport function panBy(camera: Camera3d, dx: number, dy: number, paneHeight: number): Camera3d {\n if (!(paneHeight > 0)) return camera;\n const perPixel = (2 * camera.distance * Math.tan(camera.fov / 2)) / paneHeight;\n const { yaw, pitch } = camera;\n const right: Vec3 = { x: Math.cos(yaw), y: 0, z: -Math.sin(yaw) };\n const up: Vec3 = {\n x: -Math.sin(yaw) * Math.sin(pitch),\n y: Math.cos(pitch),\n z: -Math.cos(yaw) * Math.sin(pitch),\n };\n const shift = add(scale(right, -dx * perPixel), scale(up, dy * perPixel));\n return { ...camera, target: add(camera.target, shift) };\n}\n\n/**\n * `dollyBy` about a point on the pane rather than its middle: the point in the\n * target's screen-facing plane under `at` — CSS pixels from the pane's\n * top-left, in a pane of `pane` size — stays under it, as a 2D camera's wheel\n * zoom keeps the point under the pointer. The target slides toward that point\n * by as much as the distance shrank, so the next turn pivots nearer it.\n */\nexport function dollyToward(\n camera: Camera3d,\n factor: number,\n at: { x: number; y: number },\n pane: { width: number; height: number },\n limits?: Partial<OrbitLimits>,\n): Camera3d {\n const dollied = dollyBy(camera, factor, limits);\n const kept = 1 - dollied.distance / camera.distance;\n const moved = panBy(\n camera,\n -kept * (at.x - pane.width / 2),\n -kept * (at.y - pane.height / 2),\n pane.height,\n );\n return { ...dollied, target: moved.target };\n}\n","/**\n * A 3D pose, and the two things every consumer of one needs: its matrix, and\n * the world box it occupies.\n *\n * `Scene<TData, TLayer, Pose3>` is the whole of how this reaches weasel —\n * `Scene` is generic over its pose and holds this one with no adapter, no\n * subclass and no special case.\n */\n\nimport {\n compose, quatIdentity, transformAabb, type Aabb, type Mat4, type Quat, type Vec3,\n} from '@weasel-js/geom/3d';\n\n/** Position, rotation and scale of a 3D node. */\nexport interface Pose3 {\n position: Vec3;\n rotation: Quat;\n scale: Vec3;\n}\n\n/** The box a primitive occupies before its pose. A unit primitive centred on\n * its own origin — which is what the kernel assumes nothing about — is\n * `UNIT_CUBE`. */\nexport const UNIT_CUBE: Aabb = {\n min: { x: -0.5, y: -0.5, z: -0.5 },\n max: { x: 0.5, y: 0.5, z: 0.5 },\n};\n\n/** A pose at `position`, unscaled and unrotated unless given. */\nexport function pose3(\n position: Vec3,\n scale: Vec3 = { x: 1, y: 1, z: 1 },\n rotation: Quat = quatIdentity(),\n): Pose3 {\n return { position, rotation, scale };\n}\n\n/** The pose as a matrix: scale, then rotation, then translation to\n * `position`. */\nexport function poseMatrix(pose: Pose3): Mat4 {\n return compose(pose.position, pose.rotation, pose.scale);\n}\n\n/**\n * The world box a posed primitive occupies, given the box it occupies in its\n * own space.\n *\n * Which local box a primitive has is the consumer's answer, not the kernel's:\n * a sphere's is rotation-invariant and a mesh's comes from its vertices, and\n * neither is something a pose can tell you.\n */\nexport function aabbOfPose(pose: Pose3, local: Aabb = UNIT_CUBE): Aabb {\n return transformAabb(poseMatrix(pose), local);\n}\n","/** Container composition for `Pose3`: a child's pose is stored in its\n * container's frame, and folds up to world through every frame above it. */\n\nimport type { PoseComposition } from '@weasel-js/core/engine';\nimport { add, quatConjugate, quatMultiply, quatRotate, sub, type Vec3 } from '@weasel-js/geom/3d';\nimport type { Pose3 } from './pose3';\n\nconst times = (a: Vec3, b: Vec3): Vec3 => ({ x: a.x * b.x, y: a.y * b.y, z: a.z * b.z });\n\n/** `a / s` per axis, reading a collapsed axis (`s` 0) as `zero`: nothing in a\n * zero-scaled frame can be told apart along it. */\nconst over = (a: Vec3, s: Vec3, zero: Vec3): Vec3 => ({\n x: s.x === 0 ? zero.x : a.x / s.x,\n y: s.y === 0 ? zero.y : a.y / s.y,\n z: s.z === 0 ? zero.z : a.z / s.z,\n});\n\nconst ORIGIN: Vec3 = { x: 0, y: 0, z: 0 };\n\n/**\n * Container composition for a 3D scene: a container's position, rotation and\n * scale all reach its children, so moving, turning or growing a container\n * carries everything under it.\n *\n * Exact whenever the container's scale is uniform. Under a non-uniform one a\n * turned child would come out sheared, which no `Pose3` holds; it keeps its\n * own axes instead and takes the container's scale axis by axis. Either way\n * `decompose` undoes `compose`, so a node rebased into a frame and read back\n * lands where it was.\n */\nexport const POSE3_COMPOSITION: PoseComposition<Pose3> = {\n compose: (parent, child) => ({\n position: add(parent.position, quatRotate(parent.rotation, times(parent.scale, child.position))),\n rotation: quatMultiply(parent.rotation, child.rotation),\n scale: times(parent.scale, child.scale),\n }),\n decompose: (parent, world) => ({\n position: over(quatRotate(quatConjugate(parent.rotation), sub(world.position, parent.position)), parent.scale, ORIGIN),\n rotation: quatMultiply(quatConjugate(parent.rotation), world.rotation),\n scale: over(world.scale, parent.scale, world.scale),\n }),\n closure: 'rigid',\n};\n","/**\n * The screen side of the kernel: where a pointer points, and what rectangle a\n * world box covers. This is the seam weasel's 2D chrome meets — everything\n * here speaks `Bounds`-shaped screen rectangles, which is why a 3D host can\n * pass the dispatcher's world point through unchanged.\n */\n\nimport {\n invert,\n normalize,\n sub,\n transformPoint,\n transformPoint4,\n type Aabb,\n type Mat4,\n type Ray,\n type Vec3,\n} from '@weasel-js/geom/3d';\n\n/** A screen rectangle in CSS pixels, in the shape core's `Bounds` uses. Both\n * a pane's own rect and a projected world box are this — one spelling, so the\n * two never need converting between. */\nexport interface ScreenBox {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** A `ScreenBox` a host is being asked to outline. `tint` says why: warm for\n * what is selected, cool for what the gesture in hand is proposing. */\nexport interface ChromeBox extends ScreenBox {\n tint?: 'selection' | 'gesture';\n}\n\n/** Screen point (y down, rect-relative) to normalized device coordinates (y up). */\nexport function screenToNdc(\n point: { x: number; y: number },\n rect: ScreenBox,\n): { x: number; y: number } {\n return {\n x: ((point.x - rect.x) / rect.width) * 2 - 1,\n y: 1 - ((point.y - rect.y) / rect.height) * 2,\n };\n}\n\n/** Inverse of `screenToNdc`: normalized device coordinates (y up) to a point\n * in `rect`'s space (y down). */\nexport function ndcToScreen(\n ndc: { x: number; y: number },\n rect: ScreenBox,\n): { x: number; y: number } {\n return {\n x: rect.x + (ndc.x * 0.5 + 0.5) * rect.width,\n y: rect.y + (1 - (ndc.y * 0.5 + 0.5)) * rect.height,\n };\n}\n\n/**\n * The ray a screen point names, given the camera that drew the rect. This is\n * the whole of what 3D picking needs from a pointer — which is why the world\n * point the dispatcher carries stays two numbers.\n *\n * `null` when the point names no ray: the view-projection has no inverse (a\n * camera on its own target, a degenerate projection) or the pane has no area.\n */\nexport function rayThroughScreenPoint(\n point: { x: number; y: number },\n rect: ScreenBox,\n viewProjection: Mat4,\n eye: Vec3,\n): Ray | null {\n const inv = invert(viewProjection);\n if (!inv) return null;\n const ndc = screenToNdc(point, rect);\n const near = transformPoint(inv, { x: ndc.x, y: ndc.y, z: -1 });\n const far = transformPoint(inv, { x: ndc.x, y: ndc.y, z: 1 });\n const direction = normalize(sub(far, near));\n // normalize answers zero for a non-finite difference, which is no direction.\n if (direction.x === 0 && direction.y === 0 && direction.z === 0) return null;\n return { origin: eye, direction };\n}\n\ntype Clip = readonly [number, number, number, number];\n\n/** Signed distance to the near plane in clip space; `>= 0` is in front of it.\n * GL puts the near plane at `z = -w`. */\nfunction nearSide(p: Clip): number {\n return p[2] + p[3];\n}\n\nfunction lerpClip(a: Clip, b: Clip, t: number): Clip {\n return [\n a[0] + (b[0] - a[0]) * t,\n a[1] + (b[1] - a[1]) * t,\n a[2] + (b[2] - a[2]) * t,\n a[3] + (b[3] - a[3]) * t,\n ];\n}\n\n/** The three edges leaving corner `i` toward a higher bit, as bit masks. */\nconst EDGE_BITS = [1, 2, 4] as const;\n\n/**\n * The screen rectangle a world-space box covers — the currency weasel's chrome\n * and `PoseDescriptor.getBounds` speak in. `null` when the box is entirely\n * behind the near plane.\n *\n * Each of the twelve edges is clipped against the near plane before it is\n * projected, rather than dropping the corners behind it. Dropping them reports\n * a box that is too small for anything straddling the near plane, and the error\n * grows as the camera moves in: a solid the pointer is inside of would outline\n * as a sliver, or as nothing.\n */\nexport function projectAabbToScreen(\n box: Aabb,\n viewProjection: Mat4,\n rect: ScreenBox,\n): ScreenBox | null {\n const corners: Clip[] = [];\n for (let i = 0; i < 8; i++) {\n const corner: Vec3 = {\n x: i & 1 ? box.max.x : box.min.x,\n y: i & 2 ? box.max.y : box.min.y,\n z: i & 4 ? box.max.z : box.min.z,\n };\n corners.push(transformPoint4(viewProjection, corner));\n }\n\n let minX = Number.POSITIVE_INFINITY;\n let minY = Number.POSITIVE_INFINITY;\n let maxX = Number.NEGATIVE_INFINITY;\n let maxY = Number.NEGATIVE_INFINITY;\n let any = false;\n\n const extend = (p: Clip): void => {\n if (!(p[3] > 0)) return;\n const screen = ndcToScreen({ x: p[0] / p[3], y: p[1] / p[3] }, rect);\n minX = Math.min(minX, screen.x);\n minY = Math.min(minY, screen.y);\n maxX = Math.max(maxX, screen.x);\n maxY = Math.max(maxY, screen.y);\n any = true;\n };\n\n for (let i = 0; i < 8; i++) {\n for (const bit of EDGE_BITS) {\n if (i & bit) continue;\n let a = corners[i];\n let b = corners[i | bit];\n const da = nearSide(a);\n const db = nearSide(b);\n if (da < 0 && db < 0) continue;\n if (da < 0) a = lerpClip(a, b, da / (da - db));\n else if (db < 0) b = lerpClip(b, a, db / (db - da));\n extend(a);\n extend(b);\n }\n }\n\n if (!any) return null;\n return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };\n}\n","/**\n * A viewport's two directions: a screen point to the ray it names, and a\n * world point to the screen point it draws at. Both speak the coordinate\n * space the host's pointer points arrive in.\n */\n\nimport { transformPoint4, type Ray, type Vec3 } from '@weasel-js/geom/3d';\nimport { cameraEye, cameraViewProjection, type Camera3d } from './camera';\nimport { ndcToScreen, rayThroughScreenPoint, type ScreenBox } from './screen';\n\n/** The camera and the pane it draws into; `width`/`height` are the pane's\n * size in the same units as the pointer points. */\nexport interface Viewport3d {\n camera: Camera3d;\n width: number;\n height: number;\n /**\n * Where the pane sits in client coordinates. A 3D host works in one space\n * from the event to the ray — it passes the dispatcher an identity\n * `clientToWorld` — so the deps subtract this rather than the dispatcher.\n */\n originX?: number;\n originY?: number;\n}\n\n/** Read on every dep call, so a dep always sees the current camera and pane. */\nexport type ViewportSource = () => Viewport3d;\n\ntype Point = { x: number; y: number };\n\n/** The pane, in the coordinate space the host's points arrive in. The origin\n * defaults to the client origin — a host that fills the window passes none. */\nexport function rectOf(viewport: Viewport3d): ScreenBox {\n return {\n x: viewport.originX ?? 0,\n y: viewport.originY ?? 0,\n width: viewport.width,\n height: viewport.height,\n };\n}\n\nexport function viewProjectionOf(viewport: Viewport3d) {\n return cameraViewProjection(viewport.camera, viewport.width / Math.max(1, viewport.height));\n}\n\nexport function rayAt(viewport: Viewport3d, point: Point): Ray | null {\n return rayThroughScreenPoint(\n point,\n rectOf(viewport),\n viewProjectionOf(viewport),\n cameraEye(viewport.camera),\n );\n}\n\n/** Where `p` draws in the viewport, or null when it is behind the near plane\n * or projects to nothing finite. */\nexport function projectPoint(p: Vec3, viewport: Viewport3d): Point | null {\n const [x, y, z, w] = transformPoint4(viewProjectionOf(viewport), p);\n // GL's near plane is z = -w.\n if (!(w > 0) || z < -w) return null;\n const screen = ndcToScreen({ x: x / w, y: y / w }, rectOf(viewport));\n return Number.isFinite(screen.x) && Number.isFinite(screen.y) ? screen : null;\n}\n","/**\n * The ground: the plane through the origin at right angles to `up`. A drag\n * inserts onto it, and a 2D world lies on it when a 3D view meets one.\n */\n\nimport type { AimPoint } from '@weasel-js/core/engine';\nimport { intersectRayPlane, pointOnRay, type Vec3 } from '@weasel-js/geom/3d';\nimport { rayAt, type Viewport3d } from './project';\n\nexport type Axis = 'x' | 'y' | 'z';\n\n/** `up`'s own axis, and the two it is not: a 2D world's x lies along `u` and its y along `v`. */\nexport interface GroundAxes {\n readonly u: Axis;\n readonly v: Axis;\n readonly up: Axis;\n}\n\nexport function groundAxes(up: Vec3): GroundAxes {\n if (up.y !== 0) return { u: 'x', v: 'z', up: 'y' };\n if (up.x !== 0) return { u: 'y', v: 'z', up: 'x' };\n return { u: 'x', v: 'y', up: 'z' };\n}\n\n/** Where the ray through `point`, in the coordinates the viewport's pointer points arrive in, meets the ground, or `null`. */\nexport function groundHit(viewport: Viewport3d, point: { x: number; y: number }, up: Vec3): Vec3 | null {\n const ray = rayAt(viewport, point);\n const t = ray && intersectRayPlane(ray, up, 0);\n return ray && t !== null ? pointOnRay(ray, t) : null;\n}\n\n/** A world point as a 2D world reads it: its place along the ground axes as x and y, its height as z. */\nexport function toAimPoint(p: Vec3, axes: GroundAxes): AimPoint {\n return { x: p[axes.u], y: p[axes.v], z: p[axes.up] };\n}\n\n/** The world point an aim point names; a 2D world's point, with no z, lies on the ground. */\nexport function fromAimPoint(p: AimPoint, axes: GroundAxes): Vec3 {\n const out = { x: 0, y: 0, z: 0 };\n out[axes.u] = p.x;\n out[axes.v] = p.y;\n out[axes.up] = p.z ?? 0;\n return out;\n}\n","/** The 3D world every dep is built from: core's scene with a `Pose3`, the\n * viewport it is seen through, and how wide each node is. */\n\nimport { composeWorldPose, scenePoseAdapter, scenePoseFrame, type Scene, type SceneNode } from '@weasel-js/core/engine';\nimport { type NodeId } from '@weasel-js/routing';\nimport type { Aabb, Vec3 } from '@weasel-js/geom/3d';\nimport { aabbOfPose, type Pose3 } from './pose3';\nimport type { ViewportSource } from './project';\n\n/** A 3D scene is core's scene with a `Pose3`. Nothing wraps it. */\nexport type Scene3d<TData, TLayer extends string> = Scene<TData, TLayer, Pose3>;\n/** A node of a `Scene3d`. */\nexport type Node3d<TData, TLayer extends string> = SceneNode<TData, TLayer, Pose3>;\n\n/**\n * The world box a node occupies, rather than a local box to transform: a\n * sphere's box is the same under every rotation, and no transform of a local\n * box reproduces that — rotate a cube and it widens.\n *\n * The node it is handed carries its world pose: under container composition,\n * or mid-gesture, that is not the pose the scene stores. `null` means the node\n * occupies nothing, so nothing picks it or snaps to it; a container that only\n * groups its children answers that.\n *\n * Omitted, a mark is a unit cube carried by its pose and a group occupies\n * nothing.\n *\n * A function of the node alone; a result that depends on anything else must\n * come with a scene change, or picks go stale.\n */\nexport type NodeBounds<TData, TLayer extends string> = (\n node: Node3d<TData, TLayer>,\n) => Aabb | null;\n\n/** What every 3D dep is built from: the scene, the viewport, and optionally\n * each node's world box. */\nexport interface World3d<TData, TLayer extends string> {\n scene: Scene3d<TData, TLayer>;\n viewport: ViewportSource;\n bounds?: NodeBounds<TData, TLayer>;\n /** The axis gestures resolve against. Default `+y`. */\n up?: Vec3;\n}\n\nexport const DEFAULT_UP: Vec3 = { x: 0, y: 1, z: 0 };\n\n/**\n * Where `id` is in world, as it is shown: folded up through every container\n * frame above it under the scene's composition, at the pose an in-flight\n * gesture published where there is one. What a renderer draws the node at.\n */\nexport function worldPoseOf<TData, TLayer extends string>(\n scene: Scene3d<TData, TLayer>,\n id: NodeId,\n): Pose3 | undefined {\n return scene.get(id) === undefined ? undefined : worldPoses(scene, 'shown')(id);\n}\n\n/** Which world a read sees: as shown, or as the document holds it with no\n * gesture's override anywhere up the chain. */\nexport type Reading = 'shown' | 'document';\n\n/** A world-pose lookup over `scene`, to build once per pass and ask per node. */\nexport function worldPoses<TData, TLayer extends string>(\n scene: Scene3d<TData, TLayer>,\n reading: Reading,\n): (id: NodeId) => Pose3 {\n const untyped = scene as unknown as Scene<unknown, string, unknown>;\n if (reading === 'shown') {\n const frame = scenePoseFrame(untyped);\n return (id) => frame.world(id) as Pose3;\n }\n const adapter = scenePoseAdapter(untyped);\n const compose = scene.composition.compose as (p: unknown, c: unknown) => unknown;\n return (id) => composeWorldPose(adapter, id as string, compose) as Pose3;\n}\n\n/** The box `node` occupies at the world pose `pose`, or `null` for none. */\nexport function boxAt<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n node: Node3d<TData, TLayer>,\n pose: Pose3,\n): Aabb | null {\n if (world.bounds) return world.bounds(pose === node.pose ? node : { ...node, pose });\n return node.kind === 'group' ? null : aabbOfPose(pose);\n}\n\n/** The box `node` is measured by at `pose`, and a gesture casts it from: its\n * own, or for a node that occupies nothing, its origin. */\nexport function measuredBoxAt<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n node: Node3d<TData, TLayer>,\n pose: Pose3,\n): Aabb {\n return boxAt(world, node, pose) ?? pointBox(pose.position);\n}\n\n/** A world-box lookup over `world`, to build once per pass and ask per node. */\nexport function worldBoxes<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n reading: Reading,\n): (node: Node3d<TData, TLayer>) => Aabb | null {\n const poseOf = worldPoses(world.scene, reading);\n return (node) => boxAt(world, node, poseOf(node.id));\n}\n\n/** `ids` and everything under them. */\nexport function withDescendants<TData, TLayer extends string>(\n scene: Scene3d<TData, TLayer>,\n ids: Iterable<string>,\n): Set<string> {\n const out = new Set<string>();\n const queue = [...ids];\n while (queue.length > 0) {\n const id = queue.pop()!;\n if (out.has(id)) continue;\n out.add(id);\n queue.push(...scene.childrenOf(id as NodeId));\n }\n return out;\n}\n\n/** A box with no extent at `p`. */\nexport function pointBox(p: Vec3): Aabb {\n return { min: p, max: p };\n}\n","/**\n * The 3D world's pick index: one BVH over every node's world box as shown,\n * rebuilt whole on the first pick after the scene, its overrides or the\n * world's `bounds` function can have changed. A node whose box the tree\n * refuses (non-finite or inverted) is tested on every pick, the way the scan\n * did; one that occupies nothing is never picked.\n */\n\nimport type { NodeId } from '@weasel-js/routing';\nimport { rectsOverlap } from '@weasel-js/geom';\nimport { intersectRayAabb, type Aabb, type Ray } from '@weasel-js/geom/3d';\nimport { createBvh, type Bvh, type HalfSpace } from '@weasel-js/geom/nd';\nimport { rectOf, viewProjectionOf, type Viewport3d } from './project';\nimport { projectAabbToScreen, screenToNdc, type ScreenBox } from './screen';\nimport { boxAt, worldBoxes, worldPoseOf, type Node3d, type World3d } from './world';\n\nexport interface WorldPickIndex {\n /** The nearest node the ray enters; a tie on distance goes to the first in render order. */\n nearestOnRay(ray: Ray, excluded: ReadonlySet<NodeId> | null): NodeId | null;\n /** The nodes whose projected box overlaps `rect`, in render order. */\n inScreenRect(vp: Viewport3d, rect: ScreenBox): NodeId[];\n}\n\n/** The screen box a node covers, or null when it projects to nothing visible. */\nexport function screenBoxOf<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n id: NodeId,\n viewport: Viewport3d,\n): ScreenBox | null {\n const node = world.scene.get(id) as Node3d<TData, TLayer> | undefined;\n const pose = node && worldPoseOf(world.scene, id);\n const box = node && pose && boxAt(world, node, pose);\n return box ? projectAabbToScreen(box, viewProjectionOf(viewport), rectOf(viewport)) : null;\n}\n\nfunction boxValid({ min, max }: Aabb): boolean {\n return (\n Number.isFinite(min.x) && Number.isFinite(min.y) && Number.isFinite(min.z) &&\n Number.isFinite(max.x) && Number.isFinite(max.y) && Number.isFinite(max.z) &&\n min.x <= max.x && min.y <= max.y && min.z <= max.z\n );\n}\n\n/** Widens each side plane, in NDC, past the rounding between it and the exact screen test. */\nconst NDC_SLACK = 1e-9;\n\n/**\n * The four half-spaces a point must sit in for its screen point to fall in\n * `rect`'s columns and rows: `ndc.x >= a` is `clip.x - a * clip.w >= 0`\n * wherever `clip.w > 0`, which is linear in the world point. Each plane is\n * kept or dropped on its own, so a box survives exactly when its projection's\n * x span and y span each reach the rect — what the screen-box test asks —\n * and points behind the eye only ever add candidates.\n */\nfunction sidePlanes(vp: Viewport3d, rect: ScreenBox): HalfSpace[] {\n const m = viewProjectionOf(vp);\n const pane = rectOf(vp);\n const lo = screenToNdc({ x: rect.x, y: rect.y + rect.height }, pane);\n const hi = screenToNdc({ x: rect.x + rect.width, y: rect.y }, pane);\n // Column-major: row r of the matrix is m[r], m[4 + r], m[8 + r], m[12 + r].\n const row = (r: number) => [m[r]!, m[4 + r]!, m[8 + r]!, m[12 + r]!];\n const w = row(3);\n const plane = (r: number, a: number, sign: 1 | -1): HalfSpace => {\n const c = row(r);\n const e = [0, 1, 2, 3].map((j) => sign * (c[j]! - a * w[j]!));\n return { normal: [e[0]!, e[1]!, e[2]!], offset: e[3]! };\n };\n return [\n plane(0, lo.x - NDC_SLACK, 1),\n plane(0, hi.x + NDC_SLACK, -1),\n plane(1, lo.y - NDC_SLACK, 1),\n plane(1, hi.y + NDC_SLACK, -1),\n ];\n}\n\nclass BuiltIndex<TData, TLayer extends string> implements WorldPickIndex {\n constructor(\n private readonly order: readonly Node3d<TData, TLayer>[],\n private readonly boxes: readonly (Aabb | null)[],\n private readonly tree: Bvh<number>,\n private readonly always: readonly number[],\n ) {}\n\n nearestOnRay(ray: Ray, excluded: ReadonlySet<NodeId> | null): NodeId | null {\n const { order, boxes } = this;\n let best = -1;\n let bestT = Infinity;\n const consider = (i: number) => {\n const box = boxes[i]!;\n if (excluded?.has(order[i]!.id)) return;\n const t = intersectRayAabb(ray, box.min, box.max);\n if (t !== null && (t < bestT || (t === bestT && i < best))) {\n bestT = t;\n best = i;\n }\n };\n for (const i of this.always) consider(i);\n const { origin: o, direction: d } = ray;\n this.tree.raycast([o.x, o.y, o.z], [d.x, d.y, d.z], (i, entryT) => {\n // The tree's slab test rounds differently from intersectRayAabb's.\n if (entryT > bestT * (1 + 1e-12) + 1e-12) return false;\n consider(i);\n return true;\n });\n return best < 0 ? null : order[best]!.id;\n }\n\n inScreenRect(vp: Viewport3d, rect: ScreenBox): NodeId[] {\n const candidates = [...this.always];\n this.tree.queryHalfSpaces(sidePlanes(vp, rect), (i) => {\n candidates.push(i);\n });\n candidates.sort((a, b) => a - b);\n const hits: NodeId[] = [];\n const m = viewProjectionOf(vp);\n const pane = rectOf(vp);\n for (const i of candidates) {\n const box = projectAabbToScreen(this.boxes[i]!, m, pane);\n if (box && rectsOverlap(box, rect)) hits.push(this.order[i]!.id);\n }\n return hits;\n }\n}\n\ninterface Cached {\n version: number;\n overrides: number;\n bounds: unknown;\n order: readonly unknown[];\n index: WorldPickIndex;\n}\n\nconst CACHE = new WeakMap<object, Cached>();\n\n/** The box grown by a relative epsilon, so rounding in the tree's tests can\n * only add candidates for the exact ones to drop. */\nfunction padded({ min, max }: Aabb): number[] {\n const m = Math.max(\n Math.abs(min.x), Math.abs(min.y), Math.abs(min.z),\n Math.abs(max.x), Math.abs(max.y), Math.abs(max.z),\n );\n const e = 1e-9 * (1 + m);\n return [min.x - e, min.y - e, min.z - e, max.x + e, max.y + e, max.z + e];\n}\n\nfunction build<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n order: readonly Node3d<TData, TLayer>[],\n): WorldPickIndex {\n const boxOf = worldBoxes(world, 'shown');\n const boxes = order.map(boxOf);\n const entries: [number, number[]][] = [];\n const always: number[] = [];\n boxes.forEach((b, i) => {\n if (b === null) return;\n if (boxValid(b)) entries.push([i, padded(b)]);\n else always.push(i);\n });\n return new BuiltIndex(order, boxes, createBvh<number>(3, entries), always);\n}\n\n/** The index for `world`, current as of this call. */\nexport function worldPickIndex<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n): WorldPickIndex {\n const { scene } = world;\n const version = scene.getVersion();\n const overrides = scene.overrides.getGeneration();\n const order = scene.renderOrderNodes() as readonly Node3d<TData, TLayer>[];\n const hit = CACHE.get(world);\n if (\n hit && hit.version === version && hit.overrides === overrides &&\n hit.bounds === world.bounds && hit.order === order\n ) {\n return hit.index;\n }\n const index = build(world, order);\n CACHE.set(world, { version, overrides, bounds: world.bounds, order, index });\n return index;\n}\n","import { SNAP_AXIS_STEP, type SnapConstrain } from '@weasel-js/core/engine';\nimport { stepLine, type Flat } from '@weasel-js/geom/nd';\nimport { cross, dot, normalize, scale, sub, type Vec3 } from '@weasel-js/geom/3d';\n\nconst ZERO: Vec3 = { x: 0, y: 0, z: 0 };\n\nexport const tuple = (p: Vec3): number[] => [p.x, p.y, p.z];\nexport const vec3Of = (t: readonly number[]): Vec3 => ({ x: t[0]!, y: t[1]!, z: t[2]! });\n\n/** Two unit directions spanning the plane normal to `up`. For an axis `up`\n * they are the other two world axes, so a ground grid runs along them. */\nexport function planeBasis(up: Vec3): readonly [Vec3, Vec3] {\n const n = normalize(up);\n const e: Vec3 = Math.abs(n.x) < 0.9 ? { x: 1, y: 0, z: 0 } : { x: 0, y: 0, z: 1 };\n const u = normalize(sub(e, scale(n, dot(n, e))));\n return [u, cross(u, n)];\n}\n\n/**\n * `H` for a 3D gesture: the plane `basis` spans, through the origin of\n * δ-space. While `snap.constrain` is held, an `'axis'` constraint holds δ to\n * the axes and diagonals of that plane, and an angle step holds it to the\n * line through `about` at the nearest multiple of the step.\n */\nexport function inputFlat3d(\n c: SnapConstrain | undefined, held: boolean, basis: readonly [Vec3, Vec3], delta0: Vec3, about: Vec3,\n): Flat {\n const [u, v] = basis;\n if (!held || c === undefined || c === 'aspect') return { at: [0, 0, 0], dirs: [tuple(u), tuple(v)] };\n const step = c === 'axis' ? SNAP_AXIS_STEP : c.step;\n return stepLine(tuple(c === 'axis' ? ZERO : about), tuple(delta0), [tuple(u), tuple(v)], step);\n}\n","import type { SnapProbeAt } from '@weasel-js/core/engine';\nimport type { NodeId } from '@weasel-js/routing';\nimport { add, dot, scale, type Aabb, type Vec3 } from '@weasel-js/geom/3d';\nimport { boxAt, measuredBoxAt, withDescendants, worldPoses, type Node3d, type World3d } from '../world';\n\n/** What a 3D move drags, at press. */\nexport interface Subject3d {\n /** The union of the world boxes of the subject and everything under it,\n * which moves with it. */\n box: Aabb;\n /** The node whose `translate` the session answers for exactly: the first\n * of the subject still in the scene, which is the move's lead, so every\n * other root follows it onto what it snapped to. */\n anchor: { box: Aabb; height: number };\n}\n\nexport function subjectOf<TData, TLayer extends string>(\n world: World3d<TData, TLayer>, ids: readonly string[], up: Vec3,\n): Subject3d | null {\n const { scene } = world;\n const poseOf = worldPoses(scene, 'shown');\n const nodeOf = (id: string) => scene.get(id as NodeId) as Node3d<TData, TLayer> | undefined;\n const lead = ids.find((id) => nodeOf(id) !== undefined);\n if (lead === undefined) return null;\n const leadPose = poseOf(lead as NodeId);\n const anchor = { box: measuredBoxAt(world, nodeOf(lead)!, leadPose), height: dot(up, leadPose.position) };\n let box: Aabb | null = null;\n for (const id of withDescendants(scene, ids)) {\n const node = nodeOf(id);\n const b = node && boxAt(world, node, poseOf(node.id));\n if (b) box = box ? union(box, b) : b;\n }\n return { box: box ?? anchor.box, anchor };\n}\n\nfunction union(a: Aabb, b: Aabb): Aabb {\n return {\n min: { x: Math.min(a.min.x, b.min.x), y: Math.min(a.min.y, b.min.y), z: Math.min(a.min.z, b.min.z) },\n max: { x: Math.max(a.max.x, b.max.x), y: Math.max(a.max.y, b.max.y), z: Math.max(a.max.z, b.max.z) },\n };\n}\n\n/** Corner `i` of `box`: bit 1 picks max x, bit 2 max y, bit 4 max z. */\nexport function boxCorner(box: Aabb, i: number): Vec3 {\n return {\n x: i & 1 ? box.max.x : box.min.x,\n y: i & 2 ? box.max.y : box.min.y,\n z: i & 4 ? box.max.z : box.min.z,\n };\n}\n\n/** A move's probes: the box's 8 corners and center as its geometry, and its\n * min, center and max as its box. */\nexport function boxProbes(box: Aabb): SnapProbeAt<Vec3>[] {\n const center = scale(add(box.min, box.max), 0.5);\n const out: SnapProbeAt<Vec3>[] = [];\n for (let i = 0; i < 8; i++) {\n out.push({ id: `corner:${i}`, at: boxCorner(box, i), role: 'geometry' });\n }\n out.push(\n { id: 'center', at: center, role: 'geometry' },\n { id: 'box.min', at: box.min, role: 'box' },\n { id: 'box.center', at: center, role: 'box' },\n { id: 'box.max', at: box.max, role: 'box' },\n );\n return out;\n}\n","import { gatherSnapCandidates, resolvedSnapMarks, snapSourcesFor, type SnapBegin, type SnapCandidateMark, type SnapOutcome, type SnapOutcomeStore, type SnapProbeAt, type SnapSession, type SnapSource } from '@weasel-js/core/engine';\nimport { closestOnFlat, resolveSnap, type Flat, type SnapCandidate } from '@weasel-js/geom/nd';\nimport {\n add, cross, dot, intersectRayPlane, len, normalize, pointOnRay, sub, type Vec3,\n} from '@weasel-js/geom/3d';\nimport { cameraEye } from '../camera';\nimport { projectPoint, rayAt, rectOf, viewProjectionOf, type Viewport3d } from '../project';\nimport { projectAabbToScreen } from '../screen';\nimport { DEFAULT_UP, type World3d } from '../world';\nimport { inputFlat3d, planeBasis, tuple, vec3Of } from './plane';\nimport { boxProbes, subjectOf } from './probes3d';\n\ntype Point = { x: number; y: number };\n\nconst ZERO: Vec3 = { x: 0, y: 0, z: 0 };\n\n/** What a 3D session runs on. */\nexport interface Session3dInputs<TData, TLayer extends string> {\n req: SnapBegin;\n world: World3d<TData, TLayer>;\n /** In source order: earlier wins a full tie. */\n sources: readonly SnapSource<Vec3>[];\n /** The reach of a source that sets none, in screen px. */\n reachPx: number;\n store: SnapOutcomeStore<Vec3>;\n}\n\n/**\n * The plane a gesture moves on, `up · p = offset`, and how its δ is read: as\n * the world distance between where `anchor` and the pointer's offset from the\n * press cast onto that plane. For a move, `anchor` is the screen point\n * `translate` casts from, so a δ handed back as a screen point is the delta\n * `translate` makes of it.\n */\ninterface Frame {\n offset: number;\n anchor(vp: Viewport3d): Point | null;\n probes(anchorWorld: Vec3): readonly SnapProbeAt<Vec3>[];\n}\n\n/**\n * A snap session over a 3D world: ctx points are screen points. A move runs\n * on the plane through its subject normal to `up`, an insert on the ground,\n * and each returns the screen point whose cast lands where the snap put it.\n * Other gestures pass their input through.\n */\nexport function createSession3d<TData, TLayer extends string>(inputs: Session3dInputs<TData, TLayer>): SnapSession {\n const { req, world, store } = inputs;\n const up = normalize(world.up ?? DEFAULT_UP);\n const basis = planeBasis(up);\n const frame = frameOf(req, world, up);\n const sources = snapSourcesFor(inputs.sources, req.gesture);\n const unsnapped = (p: Point): SnapOutcome => {\n store.set([]);\n return { point: p, held: false, marks: [] };\n };\n return {\n at(p, mods) {\n if (!frame) return unsnapped(p);\n const vp = world.viewport();\n const screen = frame.anchor(vp);\n const anchor = screen && castOnto(vp, screen, up, frame.offset);\n const hit = screen && castOnto(vp, { x: screen.x + p.x - req.press.x, y: screen.y + p.y - req.press.y }, up, frame.offset);\n if (!screen || !anchor || !hit) return unsnapped(p);\n const delta0 = sub(hit, anchor);\n const origin = req.origin ? castOnto(vp, req.origin, up, frame.offset) : null;\n const input = inputFlat3d(req.constrain, mods.constrain, basis, delta0, origin ? sub(origin, anchor) : ZERO);\n let delta: Vec3;\n let held = false;\n if (mods.suspend) {\n delta = vec3Of(closestOnFlat(input, tuple(delta0)));\n store.set([]);\n } else {\n const probes = frame.probes(anchor);\n const res = resolveSnap({\n probes: probes.map((q) => ({ id: q.id, at: tuple(q.at), role: q.role })),\n input,\n delta0: tuple(delta0),\n candidates: candidatesOf(inputs, sources, probes, delta0, vp, origin, up),\n toScreen: (w) => {\n const s = projectPoint(vec3Of(w), vp);\n return s ? [s.x, s.y] : [NaN, NaN];\n },\n });\n delta = vec3Of(res.delta);\n held = res.members.length > 0;\n store.set(resolvedSnapMarks(res.satisfied, delta));\n }\n const landed = projectPoint(add(anchor, delta), vp);\n if (!landed) return unsnapped(p);\n return {\n point: { x: req.press.x + landed.x - screen.x, y: req.press.y + landed.y - screen.y },\n held,\n marks: store.get(),\n };\n },\n angle: (theta) => ({ theta, marks: [] }),\n end() {\n store.set([]);\n },\n };\n}\n\nfunction frameOf<TData, TLayer extends string>(req: SnapBegin, world: World3d<TData, TLayer>, up: Vec3): Frame | null {\n if (req.gesture === 'point') {\n return {\n offset: 0,\n anchor: () => req.press,\n probes: (at) => [{ id: 'pointer', at, role: 'pointer' }],\n };\n }\n if (req.gesture !== 'move') return null;\n const subject = subjectOf(world, req.ids ?? [], up);\n if (!subject) return null;\n const probes = boxProbes(subject.box);\n return {\n offset: subject.anchor.height,\n anchor(vp) {\n const box = projectAabbToScreen(subject.anchor.box, viewProjectionOf(vp), rectOf(vp));\n return box ? { x: box.x + box.width / 2, y: box.y + box.height / 2 } : null;\n },\n probes: () => probes,\n };\n}\n\nfunction castOnto(vp: Viewport3d, s: Point, up: Vec3, offset: number): Vec3 | null {\n const ray = rayAt(vp, s);\n const t = ray && intersectRayPlane(ray, up, offset);\n return ray && t !== null ? pointOnRay(ray, t) : null;\n}\n\nfunction candidatesOf<TData, TLayer extends string>(\n inputs: Session3dInputs<TData, TLayer>, sources: readonly SnapSource<Vec3>[], probes: readonly SnapProbeAt<Vec3>[],\n delta0: Vec3, vp: Viewport3d, origin: Vec3 | null, up: Vec3,\n): SnapCandidate<SnapCandidateMark<Vec3>>[] {\n const { req } = inputs;\n const shifted = probes.map((q) => ({ ...q, at: add(q.at, delta0) }));\n const perPx = worldPerPx(vp, shifted);\n const found = gatherSnapCandidates(sources, shifted, (_source, offered, reachPx) => ({\n gesture: req.gesture, probes: offered, delta0, exclude: req.ids ?? [],\n ...(req.ids ? { ids: req.ids } : {}),\n ...(req.parent !== undefined ? { parent: req.parent } : {}),\n ...(origin ? { origin } : {}),\n reachWorld: (px) => px * perPx,\n reachPx,\n }), { toVec: tuple, reachPx: inputs.reachPx, ...(origin ? { origin } : {}) });\n return found.filter((c) => !level(c.locus, up));\n}\n\n/** Whether `locus` is a plane normal to `up`: the gesture's own plane or one\n * parallel to it, which height alone meets or misses. */\nfunction level(locus: Flat, up: Vec3): boolean {\n if (locus.dirs.length !== 2) return false;\n const n = cross(vec3Of(locus.dirs[0]!), vec3Of(locus.dirs[1]!));\n return Math.abs(dot(n, up)) >= (1 - 1e-9) * len(n);\n}\n\n/** World units per screen px at the farthest probe in front of the camera:\n * the radius that culls by reach without dropping anything in it. */\nfunction worldPerPx(vp: Viewport3d, probes: readonly SnapProbeAt<Vec3>[]): number {\n const eye = cameraEye(vp.camera);\n const forward = normalize(sub(vp.camera.target, eye));\n const k = (2 * Math.tan(vp.camera.fov / 2)) / Math.max(1, vp.height);\n let depth = 0;\n for (const q of probes) depth = Math.max(depth, dot(sub(q.at, eye), forward));\n return depth * k;\n}\n","/**\n * The kit's deps, implemented against a 3D world.\n *\n * Every one of these takes its camera from a thunk rather than an argument:\n * the dispatcher keeps handing actions two numbers, and what makes them mean\n * something in 3D is the camera each dep already closes over.\n */\n\nimport type { AreaSelectDep, NodeAtPointDep, PoseDescriptor, SnapDep, SnapOutcomeStore, SnapSource } from '@weasel-js/core/engine';\nimport type { NodeId } from '@weasel-js/routing';\nimport { DEFAULT_SNAP_PX, createSnapOutcomeStore, assertSnapSourceIds } from '@weasel-js/core/engine';\nimport { isDev, type KitSettingsStore } from '@weasel-js/react';\nimport {\n aabbOfPoints,\n add,\n dot,\n intersectRayPlane,\n len,\n normalize,\n pointOnRay,\n quatIdentity,\n scale as scaleBy,\n sub,\n type Aabb,\n type Vec3,\n} from '@weasel-js/geom/3d';\nimport { cameraEye, type Camera3d } from './camera';\nimport { aabbOfPose, type Pose3 } from './pose3';\nimport { groundAxes, type Axis } from './ground';\nimport { rayAt, rectOf, viewProjectionOf, type Viewport3d } from './project';\nimport { worldPickIndex } from './pickIndex';\nimport { projectAabbToScreen } from './screen';\nimport { createSession3d } from './snap/session3d';\n\nimport { DEFAULT_UP, measuredBoxAt, type Node3d, type World3d } from './world';\n\nexport type { Viewport3d, ViewportSource } from './project';\nexport type { NodeBounds, Node3d, Scene3d, World3d } from './world';\nexport { worldPoseOf } from './world';\n\n/**\n * The plane through `p` that faces the camera.\n *\n * This is the depth choice the kit's reverse contracts need: a screen\n * rectangle names a pose only once something says how far away it is, and the\n * answer is \"as far as it already was\". Nothing resolved on this plane changes\n * depth, and one screen pixel is the same world distance everywhere on it.\n */\nfunction viewPlaneAt(camera: Camera3d, p: Vec3): { normal: Vec3; offset: number } {\n const normal = normalize(sub(camera.target, cameraEye(camera)));\n return { normal, offset: dot(normal, p) };\n}\n\n/** Where a screen point lands on `plane`, or `null` when it casts no ray. */\nfunction onPlane(\n vp: Viewport3d,\n plane: { normal: Vec3; offset: number },\n point: { x: number; y: number },\n): Vec3 | null {\n const ray = rayAt(vp, point);\n if (!ray) return null;\n const t = intersectRayPlane(ray, plane.normal, plane.offset);\n return t === null ? null : pointOnRay(ray, t);\n}\n\n/** `pose` moved by `delta`, kept at its own height along `upAxis`. */\nfunction movedOnLevel(pose: Pose3, delta: Vec3, upAxis: Axis): Pose3 {\n const position = { ...add(pose.position, delta), [upAxis]: pose.position[upAxis] };\n return { ...pose, position };\n}\n\nexport { screenBoxOf } from './pickIndex';\n\n/**\n * Nearest node along the ray the screen point names.\n *\n * The kit calls this with what it believes is a world point; a 3D host feeds\n * the dispatcher an identity `clientToWorld`, so it is the pane-relative screen\n * point, which is exactly what a ray needs.\n */\nexport function createNodeAtPoint<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n): NodeAtPointDep {\n return (point, exclude) => {\n const ray = rayAt(world.viewport(), point);\n if (!ray) return null;\n return worldPickIndex(world).nearestOnRay(ray, exclude ? new Set(exclude) : null);\n };\n}\n\n/** Marquee: the nodes whose projected box the screen rectangle touches, in render order. */\nexport function createAreaSelect<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n selection: { get(): readonly NodeId[]; set(ids: NodeId[]): void },\n): AreaSelectDep {\n return {\n hitTestArea: (bounds) => worldPickIndex(world).inScreenRect(world.viewport(), bounds),\n getSelection: () => [...selection.get()],\n setSelection: (ids) => selection.set([...ids]),\n };\n}\n\n/** Options for `createSnap`. */\nexport interface Snap3dOptions {\n /** What a gesture snaps to, in order: earlier wins a full tie. Two sharing\n * an id throw. Default none, which leaves only the gesture's own constraint. */\n sources?: readonly SnapSource<Vec3>[];\n /** The reach of a source that sets none, in screen px. Overrides the kit\n * setting `targets.snapPx`. */\n reachPx?: number;\n /** Where `targets.snapPx` is read, when each gesture begins. Absent, and\n * with no `reachPx`, reach is `DEFAULT_SNAP_PX`. */\n kitSettings?: KitSettingsStore;\n /** Where the marks of the snap in flight are written, for a host to draw\n * with `projectSnapMarks`. */\n store?: SnapOutcomeStore<Vec3>;\n}\n\nlet warnedGestureSources = false;\n\nfunction warnGestureSources(): void {\n if (warnedGestureSources || !isDev()) return;\n warnedGestureSources = true;\n console.warn(\n '[kernel3d] a gesture passed snap `sources`, which are 2D and are not asked in a 3D host. ' +\n 'List 3D sources in createSnap({ sources }).',\n );\n}\n\n/**\n * The `snap` dep over a 3D world. A gesture's `omit` is honored; its 2D\n * `sources` are not asked. A move snaps its subject's world box on the\n * plane it already moves on; an insert snaps the pointer on the ground. Both\n * answer in screen points, which `translate` and `createInsert` cast back\n * onto the same plane, landing exactly where the snap put them.\n */\nexport function createSnap<TData, TLayer extends string>(\n world: World3d<TData, TLayer>, opts: Snap3dOptions = {},\n): SnapDep {\n const store = opts.store ?? createSnapOutcomeStore<Vec3>();\n const listed = opts.sources ?? [];\n assertSnapSourceIds(listed);\n return {\n begin: (req) => {\n if (req.sources?.length) warnGestureSources();\n const omit = new Set(req.omit);\n const sources = listed.filter((s) => !omit.has(s.id));\n return createSession3d({\n req, world, sources, store,\n reachPx: opts.reachPx ?? opts.kitSettings?.get('targets.snapPx') ?? DEFAULT_SNAP_PX,\n });\n },\n };\n}\n\n/**\n * `PoseDescriptor` over a 3D pose, with `Bounds` read as the screen box the\n * node covers.\n *\n * `forNode` is what lets a sphere bound itself as a sphere: the shape lives\n * on `node.data`. Unspecialized — the kit calling with only a pose in hand —\n * it answers with the default local box, which is the looser of the two.\n *\n * `remapBounds` and `fromBounds` take a screen rectangle, which names a pose\n * only once something supplies a depth. Both resolve it against the plane\n * through the pose they were handed, facing the camera, so nothing they\n * produce changes depth.\n */\nexport function createPoseDescriptor<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n): PoseDescriptor<Pose3, Node3d<TData, TLayer>> {\n const up = world.up ?? DEFAULT_UP;\n const upAxis = groundAxes(up).up;\n const specialized = new WeakMap<object, PoseDescriptor<Pose3, Node3d<TData, TLayer>>>();\n\n // A drag whose camera stops casting rays mid-gesture keeps moving through the\n // last one that did, rather than snapping the node back.\n let lastCastable: Viewport3d | null = null;\n function castableViewport(): Viewport3d | null {\n const vp = world.viewport();\n const rect = rectOf(vp);\n if (rayAt(vp, { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 })) lastCastable = vp;\n return lastCastable;\n }\n\n function build(worldBox: (pose: Pose3) => Aabb): PoseDescriptor<Pose3, Node3d<TData, TLayer>> {\n const boundsIn = (vp: Viewport3d, pose: Pose3) =>\n projectAabbToScreen(worldBox(pose), viewProjectionOf(vp), rectOf(vp));\n const boundsOf = (pose: Pose3) => boundsIn(world.viewport(), pose);\n\n const descriptor: PoseDescriptor<Pose3, Node3d<TData, TLayer>> = {\n forNode(node) {\n let d = specialized.get(node);\n if (!d) {\n // The pose arriving here is often an in-flight override rather than\n // `node.pose`, so the consumer is asked about that pose on this node\n // rather than about the node as committed.\n d = build((pose) => measuredBoxAt(world, node, pose));\n specialized.set(node, d);\n }\n return d;\n },\n\n getBounds(pose) {\n return boundsOf(pose) ?? { x: 0, y: 0, width: 0, height: 0 };\n },\n\n /**\n * The src→dst screen map, applied at the pose's own depth: the node's\n * screen anchor moves the way the rectangle does, and both ends of that\n * move are read back off the plane through its position, so the world\n * delta is exact rather than a scaled screen one.\n *\n * The scale is uniform. The rectangle names two extents and a pose has\n * three, so there is no reading in which a screen box resizes a solid\n * per-axis; the geometric mean is the one factor that agrees with both\n * of the extents it does name.\n */\n remapBounds(pose, src, dst) {\n const vp = castableViewport();\n if (!vp) return pose;\n const box = boundsIn(vp, pose);\n if (!box) return pose;\n\n const kx = src.width === 0 ? 1 : dst.width / src.width;\n const ky = src.height === 0 ? 1 : dst.height / src.height;\n const from = { x: box.x + box.width / 2, y: box.y + box.height / 2 };\n const to = {\n x: dst.x + (from.x - src.x) * kx,\n y: dst.y + (from.y - src.y) * ky,\n };\n\n const plane = viewPlaneAt(vp.camera, pose.position);\n const before = onPlane(vp, plane, from);\n const after = onPlane(vp, plane, to);\n if (!before || !after) return pose;\n\n const k = Math.sqrt(Math.abs(kx * ky));\n return {\n ...pose,\n position: add(pose.position, sub(after, before)),\n scale: scaleBy(pose.scale, k),\n };\n },\n\n /**\n * The world box the rectangle covers at the template's depth, as a pose.\n *\n * The rectangle is flat and a box is not, so the third extent — the one\n * no screen rectangle names — is the mean of the two it does. The result\n * is world-axis-aligned and unrotated: the pose carries none of the\n * template's shape, which is the contract, and it takes only its depth.\n *\n * Extents are written as `scale`, so this reads a pose as carrying a\n * unit primitive — the same assumption `aabbOfPose` makes by default.\n */\n fromBounds(bounds, template) {\n const vp = castableViewport();\n if (!vp) return template;\n const plane = viewPlaneAt(vp.camera, template.position);\n\n const corners: Vec3[] = [];\n for (const [x, y] of [\n [bounds.x, bounds.y],\n [bounds.x + bounds.width, bounds.y],\n [bounds.x, bounds.y + bounds.height],\n [bounds.x + bounds.width, bounds.y + bounds.height],\n ]) {\n const corner = onPlane(vp, plane, { x, y });\n if (!corner) return template;\n corners.push(corner);\n }\n\n const width = len(sub(corners[1]!, corners[0]!));\n const height = len(sub(corners[2]!, corners[0]!));\n const half = Math.sqrt(width * height) / 2;\n const box = aabbOfPoints(\n corners.flatMap((c) => [\n add(c, scaleBy(plane.normal, half)),\n sub(c, scaleBy(plane.normal, half)),\n ]),\n );\n return {\n position: scaleBy(add(box.min, box.max), 0.5),\n rotation: quatIdentity(),\n scale: sub(box.max, box.min),\n };\n },\n\n /**\n * Screen-space deltas resolve against the plane the node already sits on. That\n * plane differs per node, so in a move of several each takes the lead's change\n * whole (it kept its height already), and the group moves as one body. */\n translate(pose, dx, dy, lead) {\n if (lead) return { ...pose, position: add(pose.position, sub(lead.to.position, lead.from.position)) };\n const vp = castableViewport();\n const box = vp && boundsIn(vp, pose);\n if (!vp || !box) return pose;\n const from = { x: box.x + box.width / 2, y: box.y + box.height / 2 };\n const level = { normal: up, offset: dot(up, pose.position) };\n const before = onPlane(vp, level, from);\n const after = onPlane(vp, level, { x: from.x + dx, y: from.y + dy });\n return before && after ? movedOnLevel(pose, sub(after, before), upAxis) : pose;\n },\n\n supportsRotation() {\n return false;\n },\n };\n\n return descriptor;\n }\n\n return build((pose) => aabbOfPose(pose));\n}\n","/** The `insert` dep over a 3D world: a drag becomes a footprint on the ground. */\n\nimport type { InsertDep, InsertEnds, InsertExtras } from '@weasel-js/core/engine';\nimport type { NodeId } from '@weasel-js/routing';\nimport { scale as scaleBy, sub, type Vec3 } from '@weasel-js/geom/3d';\nimport { groundAxes, groundHit } from './ground';\nimport type { ViewportSource } from './project';\nimport { DEFAULT_UP } from './world';\n\n/** The ground-plane rectangle a drag swept out, in world units. */\nexport interface Footprint {\n /** Centre of the swept rectangle, on the ground plane. */\n center: Vec3;\n /** Extent along the two axes the up axis is not. */\n width: number;\n depth: number;\n}\n\n/** The ground points a footprint spans. A drag's two ends are cast rather\n * than its box's corners: in perspective the other two corners land outside\n * the rectangle the ends make, and would carry the footprint past a corner\n * the drag snapped to. */\nfunction footprintPoints(\n bounds: { x: number; y: number; width: number; height: number },\n ends: InsertEnds | undefined,\n cast: (p: { x: number; y: number }) => Vec3 | null,\n): Vec3[] {\n if (ends) {\n const start = cast(ends.start);\n const end = cast(ends.end);\n if (!start || !end) return [];\n return ends.fromCenter ? [end, sub(scaleBy(start, 2), end)] : [start, end];\n }\n const corners = [\n { x: bounds.x, y: bounds.y },\n { x: bounds.x + bounds.width, y: bounds.y },\n { x: bounds.x, y: bounds.y + bounds.height },\n { x: bounds.x + bounds.width, y: bounds.y + bounds.height },\n ];\n return corners.map(cast).filter((h): h is Vec3 => h !== null);\n}\n\n/**\n * A drag becomes a footprint on the ground plane: its ends, or without them\n * its box's four corners, are cast onto the plane and the hit points give the\n * extent. What node that implies is the consumer's answer — the kernel does\n * not know what it is inserting. The depth the 2D contract cannot express\n * comes from the plane, not from the caller.\n */\nexport function createInsert(opts: {\n viewport: ViewportSource;\n up?: Vec3;\n /** Smallest footprint a click-sized drag produces. Default 0.25. */\n minExtent?: number;\n mint(footprint: Footprint, extras: InsertExtras): NodeId | null;\n}): InsertDep {\n const up = opts.up ?? DEFAULT_UP;\n const minExtent = opts.minExtent ?? 0.25;\n const { u, v } = groundAxes(up);\n\n return {\n commit(bounds, extras, ends) {\n const vp = opts.viewport();\n const hits = footprintPoints(bounds, ends, (p) => groundHit(vp, p, up));\n if (hits.length === 0) return null;\n\n let minU = Infinity, maxU = -Infinity, minV = Infinity, maxV = -Infinity;\n for (const h of hits) {\n minU = Math.min(minU, h[u]); maxU = Math.max(maxU, h[u]);\n minV = Math.min(minV, h[v]); maxV = Math.max(maxV, h[v]);\n }\n\n const center = { x: 0, y: 0, z: 0 };\n center[u] = (minU + maxU) / 2;\n center[v] = (minV + maxV) / 2;\n return opts.mint(\n {\n center,\n width: Math.max(minExtent, maxU - minU),\n depth: Math.max(minExtent, maxV - minV),\n },\n extras,\n );\n },\n };\n}\n","/**\n * A kernel3d viewport as a view aim: the frustum its camera shows, drawn into\n * any target view, and the pane itself as a target. Core's aim contract names\n * no 3D type, so this is the side that knows the camera.\n */\n\nimport type { AimOutline, AimPoint, AimSpace, ViewAim } from '@weasel-js/core/engine';\nimport { add, dot, normalize, scale, sub, type Vec3 } from '@weasel-js/geom/3d';\nimport { cameraEye, type Camera3d } from './camera';\nimport { fromAimPoint, groundAxes, groundHit, toAimPoint, type GroundAxes } from './ground';\nimport { projectPoint, rayAt, rectOf, type Viewport3d } from './project';\nimport { DEFAULT_UP } from './world';\n\ntype Quad = readonly [Vec3, Vec3, Vec3, Vec3];\n\n/** The frustum a camera shows: its eye, and its near and far rectangles, corners clockwise from the top-left as seen. */\nexport interface Frustum3d {\n eye: Vec3;\n near: Quad;\n far: Quad;\n}\n\n/** A kernel3d view's aim: the frustum its camera sees, with the viewport it was read from. */\nexport type Aim3d = ViewAim<Frustum3d> & { readonly kind: 'frustum'; readonly viewport: Viewport3d };\n\n/** How a kernel3d view meets a 2D one. */\nexport interface Aim3dOptions {\n /** The axis the ground, where a 2D world lies, is at right angles to: `createInsert`'s `up`. Default `+y`. */\n up?: Vec3;\n}\n\nfunction paneCorners(viewport: Viewport3d): { x: number; y: number }[] {\n const { x, y, width, height } = rectOf(viewport);\n return [\n { x, y },\n { x: x + width, y },\n { x: x + width, y: y + height },\n { x, y: y + height },\n ];\n}\n\nfunction frustumOf(viewport: Viewport3d): Frustum3d {\n const { camera } = viewport;\n const eye = cameraEye(camera);\n const forward = normalize(sub(camera.target, eye));\n const at = (depth: number): Vec3[] =>\n paneCorners(viewport).map((c) => {\n const ray = rayAt(viewport, c);\n if (!ray) return eye;\n const d = normalize(ray.direction);\n return add(eye, scale(d, depth / dot(d, forward)));\n });\n return {\n eye,\n near: at(camera.near) as unknown as Quad,\n far: at(camera.far) as unknown as Quad,\n };\n}\n\n/**\n * Where the frustum meets the ground, in the 2D world's terms, its edges' crossings wound about their middle: the\n * stretch of the ground the camera sees, cut off at its far plane, so a view with the horizon in it still outlines\n * the ground it shows. `null` when the frustum meets the ground in less than an area.\n */\nfunction footprint(f: Frustum3d, up: Vec3, axes: GroundAxes): AimPoint[] | null {\n const edges: [Vec3, Vec3][] = [];\n for (let i = 0; i < 4; i++) {\n const j = (i + 1) % 4;\n edges.push([f.near[i]!, f.near[j]!], [f.far[i]!, f.far[j]!], [f.near[i]!, f.far[i]!]);\n }\n const hits: AimPoint[] = [];\n for (const [a, b] of edges) {\n const ha = dot(a, up), hb = dot(b, up);\n if ((ha > 0 && hb > 0) || (ha < 0 && hb < 0) || ha === hb) continue;\n const hit = toAimPoint(add(a, scale(sub(b, a), ha / (ha - hb))), axes);\n hits.push({ x: hit.x, y: hit.y });\n }\n if (hits.length < 3) return null;\n const cx = hits.reduce((s, p) => s + p.x, 0) / hits.length;\n const cy = hits.reduce((s, p) => s + p.y, 0) / hits.length;\n const around = hits\n .map((p) => ({ p, a: Math.atan2(p.y - cy, p.x - cx) }))\n .sort((u, v) => u.a - v.a)\n .map((u) => u.p)\n .filter((p, i, all) => i === 0 || Math.hypot(p.x - all[i - 1]!.x, p.y - all[i - 1]!.y) > 1e-9);\n return around.length >= 3 ? around : null;\n}\n\nfunction projectAll(space: AimSpace, points: readonly AimPoint[]): AimOutline | null {\n const out: { x: number; y: number }[] = [];\n for (const p of points) {\n const px = space.project(p);\n if (!px) return null;\n out.push(px);\n }\n return out;\n}\n\n/**\n * The aim of view `viewId` (`null`: a surface's root): the frustum `viewport`'s camera sees. Drawn into a 2D view, it\n * outlines its footprint on the ground, the ground's two axes carrying the 2D world's x and y.\n */\nexport function aimOf3d(viewport: Viewport3d, viewId: string | null, opts: Aim3dOptions = {}): Aim3d {\n const up = opts.up ?? DEFAULT_UP;\n const axes = groundAxes(up);\n const extent = frustumOf(viewport);\n return {\n viewId,\n kind: 'frustum',\n extent,\n viewport,\n outlineIn(space) {\n if (space.kind === '3d') return projectAll(space, extent.far.map((p) => toAimPoint(p, axes)));\n const onGround = footprint(extent, up, axes);\n return onGround && projectAll(space, onGround);\n },\n pannedIn(space, from, to) {\n const a = space.unproject(from);\n const b = space.unproject(to);\n if (!a || !b) return null;\n const { camera } = viewport;\n const target = add(camera.target, sub(fromAimPoint(b, axes), fromAimPoint(a, axes)));\n return aimOf3d({ ...viewport, camera: { ...camera, target } }, viewId, opts);\n },\n };\n}\n\n/**\n * A 3D pane as a target. Its points are aim points: x and y along the ground's two axes and z, height, along `up`,\n * so a 2D world's points lie on the ground. It projects through `projectPoint` and unprojects onto the ground.\n */\nexport function aimSpace3d(viewport: Viewport3d, viewId: string | null, opts: Aim3dOptions = {}): AimSpace {\n const up = opts.up ?? DEFAULT_UP;\n const axes = groundAxes(up);\n const { x: ox, y: oy } = rectOf(viewport);\n return {\n viewId,\n kind: '3d',\n size: { width: viewport.width, height: viewport.height },\n project(p) {\n const s = projectPoint(fromAimPoint(p, axes), viewport);\n return s && { x: s.x - ox, y: s.y - oy };\n },\n unproject(px) {\n const hit = groundHit(viewport, { x: px.x + ox, y: px.y + oy }, up);\n return hit && toAimPoint(hit, axes);\n },\n };\n}\n\n/** The camera an aim was read from, which is what a by-value source's writer sets. */\nexport function cameraOfAim3d(aim: Aim3d): Camera3d {\n return aim.viewport.camera;\n}\n","/** The world boxes a snap source reads, as the document holds them, narrowed\n * by a BVH to the ones a query can reach. Keyed on the scene's version and\n * the world's `bounds`: `NodeBounds` is a function of the node alone, and a\n * move's overrides leave the version alone, so one index serves every frame\n * of a drag. The first query at a new key scans and records it; the second\n * builds. A node that occupies nothing is no target. */\n\nimport type { NodeId } from '@weasel-js/routing';\nimport type { Aabb } from '@weasel-js/geom/3d';\nimport { createBvh, createSettledCache, type BoxN, type Bvh, type SettledCache } from '@weasel-js/geom/nd';\nimport { withDescendants, worldBoxes, type Node3d, type World3d } from '../world';\n\ninterface Built {\n ids: readonly NodeId[];\n boxes: readonly (Aabb | null)[];\n tree: Bvh<number>;\n /** Boxes the tree refuses (non-finite or inverted), read by every query. */\n always: readonly number[];\n}\n\nconst CACHE = new WeakMap<object, SettledCache<Built>>();\n\nlet builds = 0;\n\n/** How many box indexes have been built, for tests that pin when one rebuilds. */\nexport function snapBoxIndexBuildCount(): number {\n return builds;\n}\n\nfunction nodesOf<TData, TLayer extends string>(world: World3d<TData, TLayer>): readonly Node3d<TData, TLayer>[] {\n return world.scene.renderOrderNodes() as readonly Node3d<TData, TLayer>[];\n}\n\nfunction boxValid({ min, max }: Aabb): boolean {\n return (\n Number.isFinite(min.x) && Number.isFinite(min.y) && Number.isFinite(min.z) &&\n Number.isFinite(max.x) && Number.isFinite(max.y) && Number.isFinite(max.z) &&\n min.x <= max.x && min.y <= max.y && min.z <= max.z\n );\n}\n\nfunction build<TData, TLayer extends string>(world: World3d<TData, TLayer>): Built {\n builds++;\n const nodes = nodesOf(world);\n const boxes = nodes.map(worldBoxes(world, 'document'));\n const entries: [number, number[]][] = [];\n const always: number[] = [];\n boxes.forEach((box, i) => {\n if (box === null) return;\n const { min, max } = box;\n if (boxValid(box)) entries.push([i, [min.x, min.y, min.z, max.x, max.y, max.z]]);\n else always.push(i);\n });\n return { ids: nodes.map((n) => n.id), boxes, tree: createBvh<number>(3, entries), always };\n}\n\nfunction current<TData, TLayer extends string>(world: World3d<TData, TLayer>): Built | null {\n let cache = CACHE.get(world);\n if (cache === undefined) CACHE.set(world, (cache = createSettledCache()));\n return cache.read([world.scene.getVersion(), world.bounds], () => build(world));\n}\n\n/** Grows a query box by a relative epsilon, so rounding between the tree's\n * overlap test and a source's exact one only ever adds candidates. */\nexport function padQuery(box: number[]): number[] {\n let m = 0;\n for (const v of box) if (Number.isFinite(v)) m = Math.max(m, Math.abs(v));\n const e = 1e-9 * (1 + m);\n return [box[0]! - e, box[1]! - e, box[2]! - e, box[3]! + e, box[4]! + e, box[5]! + e];\n}\n\n/**\n * Each node's world box, in render order, leaving out `exclude` and\n * everything under it, which a move of `exclude` carries along. With\n * `near`, the index may drop any box that meets none of those boxes\n * (`[minX, minY, minZ, maxX, maxY, maxZ]`, already padded); a box that\n * meets one is always kept. Without an index, every box is returned.\n */\nexport function snapBoxes<TData, TLayer extends string>(\n world: World3d<TData, TLayer>,\n exclude: readonly string[],\n near: readonly BoxN[],\n): Aabb[] {\n const excluded = withDescendants(world.scene, exclude);\n const index = near.every((b) => Array.prototype.every.call(b, (v: number) => !Number.isNaN(v))) ? current(world) : null;\n if (index === null) {\n const boxOf = worldBoxes(world, 'document');\n const out: Aabb[] = [];\n for (const node of nodesOf(world)) {\n const box = excluded.has(node.id) ? null : boxOf(node);\n if (box) out.push(box);\n }\n return out;\n }\n const found = new Set<number>(index.always);\n for (const box of near) index.tree.queryBox(box, (i) => { found.add(i); });\n const out: Aabb[] = [];\n for (const i of [...found].sort((a, b) => a - b)) {\n if (!excluded.has(index.ids[i]!)) out.push(index.boxes[i]!);\n }\n return out;\n}\n","/** What a 3D scene offers a snap session: its boxes' corners, edges, faces\n * and centers, the planes through their sides and centers, and a grid on\n * the ground. */\n\nimport type { SnapCollect, SnapMark, SnapSource, SourceCandidate } from '@weasel-js/core/engine';\nimport { add, distance, dot, len, normalize, scale, sub, type Aabb, type Vec3 } from '@weasel-js/geom/3d';\nimport { DEFAULT_UP, type World3d } from '../world';\nimport { padQuery, snapBoxes } from './boxIndex';\nimport { planeBasis } from './plane';\nimport { boxCorner } from './probes3d';\n\ntype Axis = 'x' | 'y' | 'z';\ntype Candidate = SourceCandidate<Vec3>;\n\nconst AXES: readonly Axis[] = ['x', 'y', 'z'];\nconst BITS = [1, 2, 4] as const;\nconst UNIT: Record<Axis, Vec3> = { x: { x: 1, y: 0, z: 0 }, y: { x: 0, y: 1, z: 0 }, z: { x: 0, y: 0, z: 1 } };\nconst ACROSS: Record<Axis, readonly Vec3[]> = { x: [UNIT.y, UNIT.z], y: [UNIT.x, UNIT.z], z: [UNIT.x, UNIT.y] };\n\n/** The boxes within `r` of a probe on every axis, a superset of those within `r` of it. */\nfunction boxesNear<TData, TLayer extends string>(world: World3d<TData, TLayer>, q: SnapCollect<Vec3>, r: number): Aabb[] {\n return snapBoxes(world, q.exclude, q.probes.map(({ at: p }) => padQuery([p.x - r, p.y - r, p.z - r, p.x + r, p.y + r, p.z + r])));\n}\n\n/** The boxes reaching within `r` of a probe along some axis: every box with a side or center plane in reach. */\nfunction boxesInSlabs<TData, TLayer extends string>(world: World3d<TData, TLayer>, q: SnapCollect<Vec3>, r: number): Aabb[] {\n const slabs = q.probes.flatMap(({ at: p }) => AXES.map((axis) => {\n const lo = [-Infinity, -Infinity, -Infinity];\n const hi = [Infinity, Infinity, Infinity];\n const k = AXES.indexOf(axis);\n lo[k] = p[axis] - r;\n hi[k] = p[axis] + r;\n return padQuery([...lo, ...hi]);\n }));\n return snapBoxes(world, q.exclude, slabs);\n}\n\nfunction distanceToBox(p: Vec3, box: Aabb): number {\n const d = (a: Axis) => Math.max(box.min[a] - p[a], 0, p[a] - box.max[a]);\n return Math.hypot(d('x'), d('y'), d('z'));\n}\n\nconst centerOf = (box: Aabb): Vec3 => scale(add(box.min, box.max), 0.5);\nconst isZero = (v: Vec3) => v.x === 0 && v.y === 0 && v.z === 0;\n\n/**\n * Each node's world box as targets for geometry and pointer probes: its 8\n * corners and its center as points, its 12 edges as segments, and its 6\n * faces as bounded planes. Targets past the reach are not offered.\n */\nexport function boxSnapSource<TData, TLayer extends string>(world: World3d<TData, TLayer>): SnapSource<Vec3> {\n return {\n id: 'box',\n roles: ['geometry', 'pointer'],\n *collect(q) {\n const r = q.reachWorld(q.reachPx);\n for (const box of boxesNear(world, q, r)) {\n for (const p of q.probes) {\n if (distanceToBox(p.at, box) <= r) yield* boxLoci(p.id, p.at, box, r);\n }\n }\n },\n };\n}\n\nfunction* boxLoci(probe: string, at: Vec3, box: Aabb, r: number): Generator<Candidate> {\n for (let i = 0; i < 8; i++) {\n const c = boxCorner(box, i);\n if (distance(at, c) <= r) yield { probe, locus: { at: c, dirs: [] }, mark: { kind: 'point', at: c, glyph: 'corner' } };\n }\n const center = centerOf(box);\n if (distance(at, center) <= r) {\n yield { probe, locus: { at: center, dirs: [] }, mark: { kind: 'point', at: center, glyph: 'center' } };\n }\n for (let i = 0; i < 8; i++) {\n for (const bit of BITS) {\n if (i & bit) continue;\n const a = boxCorner(box, i);\n const b = boxCorner(box, i | bit);\n const dir = sub(b, a);\n if (isZero(dir) || distanceToBox(at, { min: a, max: b }) > r) continue;\n yield { probe, locus: { at: a, dirs: [dir], span: [[0, 1]] }, mark: { kind: 'line', from: a, to: b } };\n }\n }\n for (const bit of BITS) {\n const [b1, b2] = BITS.filter((b) => b !== bit) as [number, number];\n for (const base of [0, bit]) {\n const o = boxCorner(box, base);\n const far = boxCorner(box, base | b1 | b2);\n const d1 = sub(boxCorner(box, base | b1), o);\n const d2 = sub(boxCorner(box, base | b2), o);\n if (isZero(d1) || isZero(d2) || distanceToBox(at, { min: o, max: far }) > r) continue;\n yield {\n probe,\n locus: { at: o, dirs: [d1, d2], span: [[0, 1], [0, 1]] },\n mark: () => outline([o, boxCorner(box, base | b1), far, boxCorner(box, base | b2)]),\n };\n }\n }\n}\n\nfunction outline(ring: readonly Vec3[]): SnapMark<Vec3>[] {\n return ring.map((from, i) => ({ kind: 'line', from, to: ring[(i + 1) % ring.length]! }));\n}\n\n/**\n * The planes through each node's world box at its min, center and max on\n * every axis, as targets for box and pointer probes: alignment in depth as\n * well as across. Boxes sharing a plane offer it once, and its mark reaches\n * each of them.\n */\nexport function alignPlaneSource<TData, TLayer extends string>(world: World3d<TData, TLayer>): SnapSource<Vec3> {\n return {\n id: 'align-plane',\n roles: ['box', 'pointer'],\n *collect(q) {\n const r = q.reachWorld(q.reachPx);\n for (const [axis, planes] of planesOf(boxesInSlabs(world, q, r))) {\n for (const [value, ends] of planes) {\n for (const p of q.probes) {\n if (Math.abs(p.at[axis] - value) > r) continue;\n yield {\n probe: p.id,\n locus: { at: ends[0]!, dirs: ACROSS[axis] },\n mark: (delta: Vec3): SnapMark<Vec3>[] => {\n const from = add(sub(p.at, q.delta0), delta);\n return ends.map((to) => ({ kind: 'line', from, to }));\n },\n };\n }\n }\n }\n },\n };\n}\n\n/** Per axis, each plane value the boxes have a side or center on, and the\n * point on it at each such box's center. */\nfunction planesOf(boxes: readonly Aabb[]): Map<Axis, Map<number, Vec3[]>> {\n const out = new Map<Axis, Map<number, Vec3[]>>(AXES.map((a) => [a, new Map()]));\n for (const box of boxes) {\n const center = centerOf(box);\n for (const axis of AXES) {\n const planes = out.get(axis)!;\n for (const value of new Set([box.min[axis], center[axis], box.max[axis]])) {\n const on = { ...center, [axis]: value };\n const ends = planes.get(value);\n if (ends) ends.push(on);\n else planes.set(value, [on]);\n }\n }\n }\n return out;\n}\n\n/** Options for `groundGridSource`. */\nexport interface GroundGridSourceOptions {\n /** The grid's pitch, in world units. */\n step: number;\n /** The ground's normal; the grid lies on `up · p = 0`. Default `+y`. */\n up?: Vec3;\n}\n\n/**\n * A grid on the ground plane as snap targets: for each pointer or geometry\n * probe on the ground, the grid line on either side of it along each of the\n * ground's two axes. Its reach is unlimited and it is a fallback, so it\n * holds every axis no target claims and never displaces one.\n */\nexport function groundGridSource(opts: GroundGridSourceOptions): SnapSource<Vec3> {\n const up = normalize(opts.up ?? DEFAULT_UP);\n const [u, v] = planeBasis(up);\n const lines = (c: number): [number, number] => {\n const near = Math.round(c / opts.step) * opts.step;\n return [near, near + (c >= near ? opts.step : -opts.step)];\n };\n return {\n id: 'ground-grid',\n tier: 'fallback',\n reachPx: Infinity,\n roles: ['pointer', 'geometry'],\n *collect(q) {\n for (const p of q.probes) {\n if (Math.abs(dot(p.at, up)) > 1e-6 * Math.max(1, len(p.at))) continue;\n const a = dot(p.at, u);\n const b = dot(p.at, v);\n for (const at of lines(a)) yield { probe: p.id, locus: { at: add(scale(u, at), scale(v, b)), dirs: [v] } };\n for (const at of lines(b)) yield { probe: p.id, locus: { at: add(scale(u, a), scale(v, at)), dirs: [u] } };\n }\n },\n };\n}\n","import type { SnapMark } from '@weasel-js/core/engine';\nimport type { Vec3 } from '@weasel-js/geom/3d';\nimport { projectPoint, type Viewport3d } from '../project';\n\ntype Point = { x: number; y: number };\n\n/** A snap mark's segment on screen: a line, a gap, or a distance. */\nexport interface ScreenLine {\n from: Point;\n to: Point;\n /** A gap's or distance's value, in world units. */\n value?: number;\n color?: string;\n}\n\n/** A snap mark's point on screen. */\nexport interface ScreenPoint {\n at: Point;\n glyph: string;\n label?: string;\n color?: string;\n}\n\n/**\n * The marks a 3D snap session draws, in the viewport's screen space, for a\n * host to draw through its own renderer. A mark with any point that does not\n * project — behind the camera — is dropped whole.\n */\nexport function projectSnapMarks(\n marks: readonly SnapMark<Vec3>[], viewport: Viewport3d,\n): { lines: ScreenLine[]; points: ScreenPoint[] } {\n const lines: ScreenLine[] = [];\n const points: ScreenPoint[] = [];\n for (const m of marks) {\n if (m.kind === 'point') {\n const at = projectPoint(m.at, viewport);\n if (at) {\n points.push({\n at, glyph: m.glyph,\n ...(m.label !== undefined ? { label: m.label } : {}),\n ...(m.color ? { color: m.color } : {}),\n });\n }\n continue;\n }\n const from = projectPoint(m.from, viewport);\n const to = projectPoint(m.to, viewport);\n if (!from || !to) continue;\n lines.push({\n from, to,\n ...('value' in m ? { value: m.value } : {}),\n ...(m.color ? { color: m.color } : {}),\n });\n }\n return { lines, points };\n}\n","/**\n * What a host paints for a gesture that proposes chrome rather than a pose.\n *\n * A marquee sweep and a box-drag both publish an `OngoingOverlay`.\n * `resolveOverlays` hands back world geometry with no renderer in it, so the\n * same call `<SceneCanvas>` makes serves a consumer-owned 3D renderer.\n *\n * A 3D host's `clientToWorld` is identity, so an overlay's world bounds are the\n * client rect the deps already work in, and the pane origin comes off exactly\n * once. Only the rectangular variants resolve here: a lasso, a pencil, and a run\n * of points are paths, and a path is geometry this cannot flatten to a box.\n */\n\nimport { resolveOverlays } from '@weasel-js/core/engine';\nimport { overlaysOf, type OngoingHandle } from '@weasel-js/routing';\nimport type { ChromeBox } from './screen';\n\n/** Gesture chrome, in CSS pixels relative to the pane's top-left. */\nexport function collectOverlayBoxes(\n handles: Iterable<OngoingHandle>,\n origin: { x: number; y: number },\n): ChromeBox[] {\n const overlays = [];\n for (const handle of handles) overlays.push(...overlaysOf(handle));\n\n const boxes: ChromeBox[] = [];\n for (const resolved of resolveOverlays(overlays)) {\n if (resolved.kind !== 'marquee' && resolved.kind !== 'insertPreview') continue;\n const { x, y, width, height } = resolved.bounds;\n boxes.push({ x: x - origin.x, y: y - origin.y, width, height, tint: 'gesture' });\n }\n return boxes;\n}\n","/**\n * The numbers an arrowhead is cut from, and how a line's shaft and head share\n * its length on screen. The line pass's vertex shader repeats {@link layoutLine}\n * in GLSL; the two must agree.\n */\n\n/**\n * An arrowhead, set by the shaft it caps: a line is set by its width alone and\n * its head follows, so a wide line is still an arrow rather than a band with a\n * small head poking out of it.\n */\nexport interface HeadShape {\n /** The head's length, in multiples of half the shaft's width. */\n lenRatio: number;\n /** The most of the line's on-screen length the head may take. */\n maxShare: number;\n /** Half the head's base as a share of its length. The cap shortens a head; it never reshapes it. */\n aspect: number;\n}\n\n/** A 16 px head 14 px across on a 4 px shaft, taking at most half the line. */\nexport const HEAD: HeadShape = { lenRatio: 8, maxShare: 0.5, aspect: 7 / 16 };\n\n/**\n * How far the shaft runs on under the head, as a share of the head's length:\n * enough to close the seam between them, little enough that a curving shaft\n * stays inside the triangle.\n */\nexport const HEAD_OVERDRAW = 0.1;\n\n/** The head a shaft carries, in pixels, and the shaft that goes under it. */\nexport interface HeadSize {\n /** The head's length. */\n headLen: number;\n /** Half the head's base. */\n headHalf: number;\n /** Half the shaft's width: narrowed by whatever the cap took off the head. */\n shaftHalf: number;\n}\n\n/**\n * The head `shaftHalf` carries on a line `linePx` long on screen. The head is\n * capped at `head.maxShare` of the line, and the shaft narrows by the share\n * the cap took, so a short line is the same arrow drawn smaller rather than a\n * full-width band with a stub on the end. Left out, `linePx` caps nothing.\n */\nexport function headFor(shaftHalf: number, linePx = Number.POSITIVE_INFINITY, head: HeadShape = HEAD): HeadSize {\n const wanted = shaftHalf * head.lenRatio;\n const headLen = Math.max(0, Math.min(wanted, head.maxShare * linePx));\n const headHalf = headLen * head.aspect;\n const shrunk = wanted > 0 ? (shaftHalf * headLen) / wanted : shaftHalf;\n return { headLen, headHalf, shaftHalf: wanted > 0 ? Math.min(shrunk, headHalf) : shrunk };\n}\n\n/** {@link HeadSize}, plus where along the line its shaft stops. */\nexport interface LineLayout extends HeadSize {\n /** Where the shaft ends, in the line's own length units. */\n shaftEnd: number;\n}\n\n/**\n * How a line `length` long in its own units, drawn at `pxPerUnit` pixels per\n * unit near its tip, splits between shaft and head. A line with no head\n * (`head` null) or no known scale runs its shaft to the end.\n */\nexport function layoutLine(\n shaftHalf: number, length: number, pxPerUnit: number, head: HeadShape | null,\n): LineLayout {\n if (!head || !(pxPerUnit > 0)) return { headLen: 0, headHalf: 0, shaftHalf, shaftEnd: length };\n const size = headFor(shaftHalf, pxPerUnit * length, head);\n return { ...size, shaftEnd: length - (size.headLen / pxPerUnit) * (1 - HEAD_OVERDRAW) };\n}\n","/**\n * Lines as the line pass's vertices. Trimming happens here, on the CPU and in\n * the line's own space; widths and the head are pixels, laid out by the shader\n * once the camera is known.\n */\n\nimport { curveSpan, lengthTable, type CurveSpan } from '@weasel-js/geom';\nimport { transformPoint, type Mat4, type Vec3 } from '@weasel-js/geom/3d';\nimport type { StrokeTrim } from '@weasel-js/paint';\nimport { resolveTrim } from '@weasel-js/stroke';\nimport { HEAD, type HeadShape } from './head';\n\n/** One subpath of a {@link Line3}: points joined by straight segments. */\nexport interface LineRun3 {\n points: readonly Vec3[];\n /** Whether a closing edge runs from the last point back to the first. */\n closed?: boolean;\n}\n\n/** A polyline drawn a fixed number of pixels wide, whatever its depth. */\nexport interface Line3 {\n /** Subpaths in pen order, which is the order a trim runs. */\n runs: readonly LineRun3[];\n /** Straight (not premultiplied) RGBA, each 0–1. */\n color: readonly [number, number, number, number];\n /** The shaft's width in CSS pixels. Default 4. */\n width?: number;\n /** The head at each open run's end; null for none. Default {@link HEAD}. */\n head?: HeadShape | null;\n /** The stretch drawn, measured in the line's own space. */\n trim?: StrokeTrim;\n /** From the line's own space to the world. Default identity. */\n model?: Mat4;\n}\n\n/** A visible stretch of a line: what the pass draws as one shaft and at most one head. */\nexport interface VisibleRun3 {\n /** In the line's own space. */\n points: Vec3[];\n closed: boolean;\n headed: boolean;\n}\n\n/** Floats per vertex; see {@link packLines} for the layout. */\nexport const LINE_FLOATS = 29;\n\n/** Which point of its segment a vertex sits at. */\nexport const ROLE_BACK = 0;\nexport const ROLE_SHAFT_END = 1;\nexport const ROLE_HEAD_BASE = 2;\nexport const ROLE_TIP = 3;\n\n/** `[role, side]` per vertex: two triangles of shaft, then the head's one. */\nconst SHAFT_CORNERS = [\n [ROLE_BACK, -1], [ROLE_BACK, 1], [ROLE_SHAFT_END, 1],\n [ROLE_BACK, -1], [ROLE_SHAFT_END, 1], [ROLE_SHAFT_END, -1],\n] as const;\nconst HEAD_CORNERS = [[ROLE_HEAD_BASE, -1], [ROLE_HEAD_BASE, 1], [ROLE_TIP, 0]] as const;\n\nconst flat = (points: readonly Vec3[]): number[] => points.flatMap((p) => [p.x, p.y, p.z]);\nconst lerp3 = (a: Vec3, b: Vec3, t: number): Vec3 =>\n ({ x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t, z: a.z + (b.z - a.z) * t });\nconst dist = (a: Vec3, b: Vec3): number => Math.hypot(b.x - a.x, b.y - a.y, b.z - a.z);\n\n/**\n * The stretches of `line` its trim leaves, one per subpath the trim reaches.\n * A closed subpath the trim covers whole stays closed; one it cuts is open and,\n * as a closed subpath takes no marker, carries no head.\n */\nexport function visibleRuns(line: Line3): VisibleRun3[] {\n const runs = line.runs.filter((r) => r.points.length >= 2);\n if (runs.length === 0) return [];\n const table = lengthTable(runs.map((r) => ({ points: flat(r.points), closed: !!r.closed })), 3);\n const span = resolveTrim(table, line.trim);\n const cut = span && curveSpan(table, span);\n if (!cut) return [];\n const out: VisibleRun3[] = [];\n for (let r = cut.from.run; r <= cut.to.run; r++) {\n const run = windowRun(runs[r], r, cut);\n if (run) out.push({ ...run, headed: !run.closed && !runs[r].closed && line.head !== null });\n }\n return out;\n}\n\nfunction windowRun(run: LineRun3, r: number, cut: CurveSpan): { points: Vec3[]; closed: boolean } | null {\n const pts = run.points;\n const n = pts.length;\n const segments = run.closed ? n : n - 1;\n const at = (i: number) => pts[i % n];\n const from = r === cut.from.run ? cut.from : { segment: 0, t: 0 };\n const to = r === cut.to.run ? cut.to : { segment: segments - 1, t: 1 };\n if (run.closed && from.segment === 0 && from.t === 0 && to.segment === segments - 1 && to.t === 1) {\n return { points: [...pts], closed: true };\n }\n const out: Vec3[] = [lerp3(at(from.segment), at(from.segment + 1), from.t)];\n for (let k = from.segment + 1; k <= to.segment; k++) out.push(at(k));\n out.push(lerp3(at(to.segment), at(to.segment + 1), to.t));\n const kept = out.filter((p, i) => i === 0 || dist(out[i - 1], p) > 0);\n return kept.length >= 2 ? { points: kept, closed: false } : null;\n}\n\n/**\n * `lines` as the line pass draws them: six vertices a segment, three more for\n * a head, `LINE_FLOATS` floats each, laid out as\n *\n * | floats | holds |\n * |---|---|\n * | 0–2, 3–5 | the segment's two ends, in the world |\n * | 6–8 | the point past this vertex's own end, so the shaft can miter |\n * | 9, 10 | role and side |\n * | 11–13 | the segment's start and end along its run, and the run's length, in the line's own units |\n * | 14–17 | half the shaft's width in pixels, then the head's `lenRatio`, `maxShare` and `aspect` (`lenRatio` 0: no head) |\n * | 18–20, 21–23, 24 | the run's tip, the start of its last segment, and that segment's length: one screen scale for every vertex of the run |\n * | 25–28 | straight RGBA |\n */\nexport function packLines(lines: readonly Line3[]): Float32Array {\n const chunks: number[] = [];\n for (const line of lines) {\n const shaftHalf = (line.width ?? 4) / 2;\n const head = line.head === undefined ? HEAD : line.head;\n const toWorld = line.model ? (p: Vec3) => transformPoint(line.model!, p) : (p: Vec3) => p;\n for (const run of visibleRuns(line)) {\n packRun(chunks, run, run.points.map(toWorld), shaftHalf, run.headed ? head : null, line.color);\n }\n }\n return Float32Array.from(chunks);\n}\n\nfunction packRun(\n out: number[], run: VisibleRun3, world: readonly Vec3[], shaftHalf: number,\n head: HeadShape | null, color: Line3['color'],\n): void {\n const n = world.length;\n const segments = run.closed ? n : n - 1;\n const at = (i: number) => world[((i % n) + n) % n];\n const along = [0];\n for (let i = 0; i < segments; i++) along.push(along[i] + dist(run.points[i], run.points[(i + 1) % n]));\n const total = along[segments];\n const apex = at(segments);\n const apexBack = at(segments - 1);\n const reach = total - along[segments - 1];\n const shape = head ? [head.lenRatio, head.maxShare, head.aspect] : [0, 0, 0];\n for (let i = 0; i < segments; i++) {\n const a = at(i);\n const b = at(i + 1);\n // A free end has no neighbor; pointing at itself, it keeps its own perpendicular.\n const before = run.closed || i > 0 ? at(i - 1) : a;\n const after = run.closed || i + 2 <= n - 1 ? at(i + 2) : b;\n const corners = head && i === segments - 1 ? [...SHAFT_CORNERS, ...HEAD_CORNERS] : SHAFT_CORNERS;\n for (const [role, side] of corners) {\n const adj = role === ROLE_BACK ? before : role === ROLE_SHAFT_END ? after : b;\n out.push(\n a.x, a.y, a.z, b.x, b.y, b.z, adj.x, adj.y, adj.z, role, side,\n along[i], along[i + 1], total, shaftHalf, ...shape,\n apex.x, apex.y, apex.z, apexBack.x, apexBack.y, apexBack.z, reach,\n ...color,\n );\n }\n }\n}\n","import { HEAD_OVERDRAW } from './head';\nimport { ROLE_SHAFT_END, ROLE_TIP } from './pack';\n\n/**\n * A line is expanded in screen space after projection: its width and its head\n * are pixels, so a line across the whole scene is as legible as one beside the\n * camera. Every vertex carries both ends of its segment, which is what gives\n * it a direction on screen.\n *\n * The shaft stops under the head at a length along the run, so it is cut where\n * it lies. The head stands back from the tip along its own segment's straight\n * direction on screen, never back along the path: a head longer than its\n * segment would otherwise interpolate past the segment's end and run the\n * perspective divide through zero. The scale a head is sized by is read from\n * the run's last segment, which every vertex of the run carries, so every\n * segment cuts its shaft at the same place.\n */\nexport const LINE_VS = `#version 300 es\nprecision highp float;\nlayout(location = 0) in vec3 a_from;\nlayout(location = 1) in vec3 a_to;\nlayout(location = 2) in vec3 a_adj;\nlayout(location = 3) in vec2 a_corner;\nlayout(location = 4) in vec3 a_along;\nlayout(location = 5) in vec4 a_shape;\nlayout(location = 6) in vec3 a_apex;\nlayout(location = 7) in vec4 a_apexBack;\nlayout(location = 8) in vec4 a_color;\nuniform mat4 u_viewProjection;\n/* Half the viewport in CSS pixels: ndc times this is pixels. */\nuniform vec2 u_halfViewport;\nout vec4 v_color;\nconst float OVERDRAW = ${HEAD_OVERDRAW.toFixed(3)};\n/* How far a bisector may stretch before the corner is let go; a hairpin would run to infinity. */\nconst float MITER_LIMIT = 4.0;\nconst vec4 CULLED = vec4(0.0, 0.0, 2.0, 1.0);\n\nvec2 screenOf(vec4 c) { return c.xy / c.w * u_halfViewport; }\n\nvoid main() {\n v_color = a_color;\n vec4 ca = u_viewProjection * vec4(a_from, 1.0);\n vec4 cb = u_viewProjection * vec4(a_to, 1.0);\n /* An end behind the eye projects to a line across the whole screen; drop the segment instead. */\n if (ca.w <= 0.0 || cb.w <= 0.0) { gl_Position = CULLED; return; }\n vec2 sa = screenOf(ca);\n vec2 sb = screenOf(cb);\n vec2 d = sb - sa;\n float L = length(d);\n vec2 dir = L > 0.0 ? d / L : vec2(1.0, 0.0);\n vec2 perp = vec2(-dir.y, dir.x);\n float role = a_corner.x;\n float side = a_corner.y;\n float s0 = a_along.x;\n float s1 = a_along.y;\n float total = a_along.z;\n float span = s1 - s0;\n\n /* Pixels per unit near the tip, the same for every segment of the run; this segment's own where the tip is unseen. */\n float density = span > 0.0 ? L / span : 0.0;\n vec4 cp = u_viewProjection * vec4(a_apex, 1.0);\n vec4 cq = u_viewProjection * vec4(a_apexBack.xyz, 1.0);\n float reach = a_apexBack.w;\n if (reach > 0.0 && cp.w > 0.0 && cq.w > 0.0) {\n float px = length(screenOf(cp) - screenOf(cq));\n if (px > 0.0) density = px / reach;\n }\n\n /* layoutLine in head.ts, repeated. */\n float shaftHalf = a_shape.x;\n float wanted = shaftHalf * a_shape.y;\n float headPx = 0.0;\n float headHalf = 0.0;\n float shaft = shaftHalf;\n float shaftEnd = total;\n if (wanted > 0.0 && density > 0.0) {\n headPx = max(0.0, min(wanted, a_shape.z * density * total));\n headHalf = headPx * a_shape.w;\n shaft = min(shaftHalf * headPx / wanted, headHalf);\n shaftEnd = total - headPx / density * (1.0 - OVERDRAW);\n }\n\n if (role > ${(ROLE_SHAFT_END + 0.5).toFixed(1)}) {\n if (headPx <= 0.0) { gl_Position = CULLED; return; }\n if (role > ${(ROLE_TIP - 0.5).toFixed(1)}) { gl_Position = cb; return; }\n vec2 base = sb - dir * headPx + perp * side * headHalf;\n gl_Position = vec4(base / u_halfViewport * cb.w, cb.z, cb.w);\n return;\n }\n\n float to = min(s1, shaftEnd);\n if (to <= s0 || span <= 0.0) { gl_Position = CULLED; return; }\n bool atEnd = role > 0.5;\n /* Clip space is linear in the world, so a fraction of the segment lands at its true depth. */\n vec4 c = mix(ca, cb, atEnd ? (to - s0) / span : 0.0);\n vec2 miter = perp;\n float stretch = 1.0;\n /* Only an end that meets its neighbor miters; a shaft cut short under the head stays square. */\n if (!atEnd || to >= s1) {\n vec4 cj = u_viewProjection * vec4(a_adj, 1.0);\n if (cj.w > 0.0) {\n vec2 sj = screenOf(cj);\n vec2 e = atEnd ? sj - sb : sa - sj;\n float eL = length(e);\n if (eL > 0.0) {\n vec2 o = e / eL;\n vec2 bisect = perp + vec2(-o.y, o.x);\n float bL = length(bisect);\n if (bL > 0.0001) {\n vec2 m = bisect / bL;\n float cosHalf = dot(m, perp);\n if (cosHalf > 1.0 / MITER_LIMIT) { miter = m; stretch = 1.0 / cosHalf; }\n }\n }\n }\n }\n c.xy += miter * side * shaft * stretch / u_halfViewport * c.w;\n gl_Position = c;\n}`;\n\n/** Flat color, straight alpha. */\nexport const LINE_FS = `#version 300 es\nprecision mediump float;\nin vec4 v_color;\nout vec4 fragColor;\nvoid main() {\n fragColor = v_color;\n}`;\n","import type { Mat4 } from '@weasel-js/geom/3d';\nimport { LINE_FLOATS } from './pack';\nimport { LINE_FS, LINE_VS } from './pass.glsl';\n\n/** Options for {@link LinePass.draw}. */\nexport interface LineDrawOptions {\n /** Hide the parts of a line behind what the bound depth buffer holds. Default true. */\n depthTest?: boolean;\n}\n\n/**\n * Lines drawn into a WebGL2 context the host owns. The kernel hosts a renderer\n * rather than owning one; this is a pass that renderer calls, between its own.\n */\nexport interface LinePass {\n /**\n * Draw `vertices`, as {@link packLines} lays them out, into the bound\n * framebuffer under the host's `gl.viewport`. `viewProjection` takes world\n * points to clip space; `size` is that viewport in CSS pixels, the unit a\n * line's width is given in. Depth is tested, not written, and blending is\n * straight alpha. The capabilities, depth mask, blend function, program,\n * vertex array and array buffer it changes are put back as it found them.\n */\n draw(\n vertices: Float32Array,\n viewProjection: Mat4,\n size: { width: number; height: number },\n options?: LineDrawOptions,\n ): void;\n dispose(): void;\n}\n\n/** `[size, offset]` per attribute location, in floats, in `LINE_FLOATS` order. */\nconst ATTRIBUTES: readonly (readonly [number, number])[] = [\n [3, 0], [3, 3], [3, 6], [2, 9], [3, 11], [4, 14], [3, 18], [4, 21], [4, 25],\n];\n\nfunction compile(gl: WebGL2RenderingContext, type: number, source: string): WebGLShader {\n const shader = gl.createShader(type)!;\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS) && !gl.isContextLost()) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`kernel3d line pass: shader failed to compile: ${log}`);\n }\n return shader;\n}\n\nfunction link(gl: WebGL2RenderingContext): WebGLProgram {\n const program = gl.createProgram()!;\n const vs = compile(gl, gl.VERTEX_SHADER, LINE_VS);\n const fs = compile(gl, gl.FRAGMENT_SHADER, LINE_FS);\n gl.attachShader(program, vs);\n gl.attachShader(program, fs);\n gl.linkProgram(program);\n gl.deleteShader(vs);\n gl.deleteShader(fs);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS) && !gl.isContextLost()) {\n const log = gl.getProgramInfoLog(program);\n gl.deleteProgram(program);\n throw new Error(`kernel3d line pass: program failed to link: ${log}`);\n }\n return program;\n}\n\n/** A {@link LinePass} on `gl`: one program, one vertex array, one buffer refilled each draw. */\nexport function createLinePass(gl: WebGL2RenderingContext): LinePass {\n const program = link(gl);\n const viewProjection = gl.getUniformLocation(program, 'u_viewProjection');\n const halfViewport = gl.getUniformLocation(program, 'u_halfViewport');\n const buffer = gl.createBuffer();\n const vao = gl.createVertexArray();\n\n const prevVao = gl.getParameter(gl.VERTEX_ARRAY_BINDING) as WebGLVertexArrayObject | null;\n const prevBuffer = gl.getParameter(gl.ARRAY_BUFFER_BINDING) as WebGLBuffer | null;\n gl.bindVertexArray(vao);\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n ATTRIBUTES.forEach(([size, offset], loc) => {\n gl.enableVertexAttribArray(loc);\n gl.vertexAttribPointer(loc, size, gl.FLOAT, false, LINE_FLOATS * 4, offset * 4);\n });\n gl.bindVertexArray(prevVao);\n gl.bindBuffer(gl.ARRAY_BUFFER, prevBuffer);\n\n const matrix = new Float32Array(16);\n\n return {\n draw(vertices, vp, size, options = {}) {\n if (vertices.length === 0) return;\n const was = {\n program: gl.getParameter(gl.CURRENT_PROGRAM) as WebGLProgram | null,\n vao: gl.getParameter(gl.VERTEX_ARRAY_BINDING) as WebGLVertexArrayObject | null,\n buffer: gl.getParameter(gl.ARRAY_BUFFER_BINDING) as WebGLBuffer | null,\n blend: gl.isEnabled(gl.BLEND),\n depth: gl.isEnabled(gl.DEPTH_TEST),\n cull: gl.isEnabled(gl.CULL_FACE),\n depthMask: gl.getParameter(gl.DEPTH_WRITEMASK) as boolean,\n blendFunc: [gl.BLEND_SRC_RGB, gl.BLEND_DST_RGB, gl.BLEND_SRC_ALPHA, gl.BLEND_DST_ALPHA]\n .map((p) => gl.getParameter(p) as number) as [number, number, number, number],\n };\n\n gl.useProgram(program);\n matrix.set(vp);\n gl.uniformMatrix4fv(viewProjection, false, matrix);\n gl.uniform2f(halfViewport, Math.max(1, size.width) / 2, Math.max(1, size.height) / 2);\n gl.enable(gl.BLEND);\n gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);\n // A segment's quad winds whichever way its direction on screen turns it.\n gl.disable(gl.CULL_FACE);\n if (options.depthTest ?? true) gl.enable(gl.DEPTH_TEST);\n else gl.disable(gl.DEPTH_TEST);\n gl.depthMask(false);\n gl.bindVertexArray(vao);\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.DYNAMIC_DRAW);\n gl.drawArrays(gl.TRIANGLES, 0, vertices.length / LINE_FLOATS);\n\n gl.useProgram(was.program);\n gl.bindVertexArray(was.vao);\n gl.bindBuffer(gl.ARRAY_BUFFER, was.buffer);\n const set = (cap: number, on: boolean) => (on ? gl.enable(cap) : gl.disable(cap));\n set(gl.BLEND, was.blend);\n set(gl.DEPTH_TEST, was.depth);\n set(gl.CULL_FACE, was.cull);\n gl.depthMask(was.depthMask);\n gl.blendFuncSeparate(...was.blendFunc);\n },\n\n dispose() {\n gl.deleteVertexArray(vao);\n gl.deleteBuffer(buffer);\n gl.deleteProgram(program);\n },\n };\n}\n","/**\n * Camera tools and their actions.\n *\n * Shape tools transfer from the kit untouched — a 3D host mounts core's own\n * `useSelectTool` and a rectangle-style insert binding and neither notices the\n * dimension. Only the viewport tools are written here, which is the one\n * exception the kernel doc predicted: `useHandTool` routes to\n * `viewport.dragPan`, and that wants the 2D `view`.\n */\n\nimport { useMemo } from 'react';\nimport { defineTool, type Action, type InvocationCtx, type Tool } from '@weasel-js/routing';\nimport { dollyToward, orbitBy, panBy, type Camera3d } from './camera';\nimport type { Camera3dDep } from './cameraDep';\n\n/** Radians per CSS pixel of drag. A full pane width is a bit over half a turn. */\nexport const ORBIT_RATE = 0.006;\n/** Dolly exponent per unit of wheel `deltaY`. */\nexport const DOLLY_RATE = 0.0015;\n\n/**\n * The drag's cumulative client-pixel delta.\n *\n * The fallback is only sound because a 3D host's `clientToWorld` is identity\n * (see `overlays.ts`), so the world delta already is the client one. Don't copy\n * this to a host with a 2D view — there the two spaces differ by the zoom.\n */\nfunction screenDelta(move: InvocationCtx): { x: number; y: number } | undefined {\n return move.drag?.screenDelta ?? move.drag?.delta;\n}\n\n/** An ongoing drag replacing the `camera3d` dep with `step` of the camera as\n * it was when the drag began. `drag.delta` runs from the drag origin, not the\n * previous move, so every move composes against that one camera. */\nfunction dragCamera(\n ctx: InvocationCtx,\n kind: string,\n step: (origin: Camera3d, delta: { x: number; y: number }, dep: Camera3dDep) => Camera3d,\n) {\n const dep = ctx.deps.camera3d;\n const origin: Camera3d | undefined = dep?.get();\n return {\n kind,\n onMove(move: InvocationCtx) {\n const delta = screenDelta(move);\n if (!dep || !origin || !delta) return;\n dep.set(step(origin, delta, dep));\n },\n };\n}\n\n/** `camera.orbit`: an ongoing drag that turns the `camera3d` dep about its\n * target. */\nexport const orbitAction: Action = {\n id: 'camera.orbit',\n label: 'Orbit',\n group: 'viewport',\n cursor: 'grab',\n activeCursor: 'grabbing',\n requires: ['camera3d', 'kitSettings'],\n invoker: {\n timing: 'ongoing',\n start(ctx) {\n const rate = ctx.deps.kitSettings?.get('orbit3d.orbitRate') ?? ORBIT_RATE;\n return dragCamera(ctx, 'orbit', (origin, d, dep) =>\n orbitBy(origin, -d.x * rate, d.y * rate, dep.limits?.()));\n },\n },\n};\n\n/** `camera.pan`: an ongoing drag that slides the `camera3d` dep's target\n * across the screen plane, so the point at the target follows the pointer. */\nexport const panAction: Action = {\n id: 'camera.pan',\n label: 'Pan',\n group: 'viewport',\n cursor: 'move',\n requires: ['camera3d'],\n invoker: {\n timing: 'ongoing',\n start(ctx) {\n return dragCamera(ctx, 'pan', (origin, d, dep) =>\n panBy(origin, d.x, d.y, dep.size().height));\n },\n },\n};\n\n/** Where on the pane a dolly anchors: the canvas-local point the event\n * carries, or the middle when it carries none. */\nfunction anchorOf(\n params: Record<string, unknown> | undefined,\n pane: { width: number; height: number },\n): { x: number; y: number } {\n const x = params?.clientX;\n const y = params?.clientY;\n return typeof x === 'number' && typeof y === 'number'\n ? { x, y }\n : { x: pane.width / 2, y: pane.height / 2 };\n}\n\n/** `camera.dolly`: moves the `camera3d` dep in or out about the point under\n * the pointer, as a 2D camera's wheel zooms about it. A wheel's `deltaY`, and\n * a trackpad pinch delivered as ctrl+wheel, dolly by `exp(deltaY × rate)` —\n * one rate for both, as a 2D camera zooms by both. Safari's pinch arrives as\n * a `scale` and divides the distance by it. Bound to all three by default, in\n * every tool. */\nexport const dollyAction: Action = {\n id: 'camera.dolly',\n label: 'Dolly',\n group: 'viewport',\n defaultBinding: [\n { spec: { kind: 'wheel' }, opts: { id: 'camera.dolly.wheel' } },\n // Unbound, a trackpad pinch zooms the page instead.\n { spec: { kind: 'wheel', mods: { ctrl: true } }, opts: { id: 'camera.dolly.trackpadPinch' } },\n { spec: { kind: 'pinch' }, opts: { id: 'camera.dolly.pinch' } },\n ],\n requires: ['camera3d', 'kitSettings'],\n invoker: {\n timing: 'immediate',\n run(deps, params) {\n const dep = deps.camera3d;\n if (!dep) return;\n const factor = typeof params?.scale === 'number'\n ? 1 / params.scale\n : Math.exp(\n (typeof params?.deltaY === 'number' ? params.deltaY : 0)\n * (deps.kitSettings?.get('orbit3d.dollyRate') ?? DOLLY_RATE),\n );\n if (!(factor > 0) || !Number.isFinite(factor)) return;\n const pane = dep.size();\n dep.set(dollyToward(dep.get(), factor, anchorOf(params, pane), pane, dep.limits?.()));\n },\n },\n};\n\n/** `camera.pinchDolly`: two fingers spreading dolly the `camera3d` dep in and\n * closing dolly it out, by the ratio of their spread, about where they began. */\nexport const pinchDollyAction: Action = {\n id: 'camera.pinchDolly',\n label: 'Pinch Dolly',\n group: 'viewport',\n defaultBinding: [{ spec: { kind: 'multiTouch', fingers: 2 }, opts: { id: 'camera.pinchDolly.multiTouch' } }],\n requires: ['camera3d'],\n invoker: {\n timing: 'ongoing',\n start(ctx) {\n const dep = ctx.deps.camera3d;\n const origin: Camera3d | undefined = dep?.get();\n const startSpread = ctx.multiTouch?.spread ?? 0;\n const at = ctx.multiTouch?.centroid;\n return {\n kind: 'pinch',\n onMove(move) {\n const spread = move.multiTouch?.pinch?.currentSpread ?? 0;\n if (!dep || !origin || !(startSpread > 0) || !(spread > 0)) return;\n const pane = dep.size();\n const anchor = at ?? { x: pane.width / 2, y: pane.height / 2 };\n dep.set(dollyToward(origin, startSpread / spread, anchor, pane, dep.limits?.()));\n },\n };\n },\n },\n};\n\n/** `camera.home`: returns the `camera3d` dep to its `home`. Bound to a double\n * click by default. */\nexport const homeAction: Action = {\n id: 'camera.home',\n label: 'Reset Camera',\n group: 'viewport',\n defaultBinding: [{ spec: { kind: 'doubleClick' }, opts: { id: 'camera.home.doubleClick' } }],\n requires: ['camera3d'],\n invoker: {\n timing: 'immediate',\n run(deps) {\n const dep = deps.camera3d;\n const home = dep?.home?.();\n if (dep && home) dep.set(home);\n },\n },\n};\n\n/** A tool that binds a drag to `camera.orbit` and Shift+drag to `camera.pan`.\n * Register both actions alongside it; the tool only declares the bindings. */\nexport function useOrbitTool(): Tool {\n return useMemo(() => defineTool({\n id: 'orbit',\n hookName: 'useOrbitTool',\n cursor: 'grab',\n presentation: { label: 'Orbit', group: 'view' },\n bindings: [\n { spec: { kind: 'drag' }, actionId: 'camera.orbit', opts: { id: 'orbit.orbit' } },\n { spec: { kind: 'drag', mods: { shift: true } }, actionId: 'camera.pan', opts: { id: 'orbit.pan' } },\n ],\n }), []);\n}\n","import type {} from '@weasel-js/react';\nimport { pref } from '@weasel-js/prefs';\nimport { DOLLY_RATE, ORBIT_RATE } from './tools';\n\n/** The `orbit3d` kit settings area: how far the camera tools move per input. */\nexport interface Orbit3dKitSettings {\n /** Radians of orbit per CSS pixel of drag. */\n orbitRate: number;\n /** Dolly exponent per unit of wheel `deltaY`. */\n dollyRate: number;\n}\n\ndeclare module '@weasel-js/react' {\n interface KitSettings {\n orbit3d: Orbit3dKitSettings;\n }\n}\n\n/** The `orbit3d` area as a prefs group whose paths are the `KitSettings` paths. */\nexport const kernel3dKitSettingsSchema = pref.group('3D camera', {\n orbit3d: pref.group('Orbit', {\n orbitRate: pref.number('Orbit speed', ORBIT_RATE, { min: 0.001, max: 0.03, step: 0.001 }),\n dollyRate: pref.number('Dolly speed', DOLLY_RATE, { min: 0.0002, max: 0.01, step: 0.0001 }),\n }),\n});\n"]}
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@weasel-js/kernel3d",
3
- "version": "1.16.1",
3
+ "version": "1.16.2",
4
4
  "description": "3D kernel for weasel: poses, orbit camera, ray picking, screen-projected chrome geometry and a screen-space line pass over core's scene graph and dispatcher. Hosts a renderer rather than owning one.",
5
+ "weasel": {
6
+ "tier": "other"
7
+ },
5
8
  "license": "MIT",
6
9
  "type": "module",
7
10
  "sideEffects": false,
@@ -26,7 +29,7 @@
26
29
  "url": "https://github.com/orochi235/weasel/issues"
27
30
  },
28
31
  "engines": {
29
- "node": ">=22"
32
+ "node": ">=24"
30
33
  },
31
34
  "files": [
32
35
  "dist",
@@ -37,14 +40,15 @@
37
40
  "build": "tsup"
38
41
  },
39
42
  "dependencies": {
40
- "@weasel-js/geom": "1.16.1",
41
- "@weasel-js/paint": "1.16.1",
42
- "@weasel-js/prefs": "1.16.1",
43
- "@weasel-js/react": "1.16.1",
44
- "@weasel-js/stroke": "1.16.1"
43
+ "@weasel-js/geom": "1.16.2",
44
+ "@weasel-js/paint": "1.16.2",
45
+ "@weasel-js/prefs": "1.16.2",
46
+ "@weasel-js/react": "1.16.2",
47
+ "@weasel-js/routing": "1.16.2",
48
+ "@weasel-js/stroke": "1.16.2"
45
49
  },
46
50
  "peerDependencies": {
47
- "@weasel-js/core": "1.16.1",
51
+ "@weasel-js/core": "1.16.2",
48
52
  "react": ">=18"
49
53
  },
50
54
  "publishConfig": {