@weasel-js/core 1.7.0 → 1.7.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/CHANGELOG.md +794 -0
- package/README.md +14 -8
- package/dist/WeaselProvider.js +15 -0
- package/dist/WeaselProvider.js.map +1 -0
- package/dist/affordances/composeAffordanceLayer.js +224 -0
- package/dist/affordances/composeAffordanceLayer.js.map +1 -0
- package/dist/affordances/cornerResize.js +69 -0
- package/dist/affordances/cornerResize.js.map +1 -0
- package/dist/affordances/hitAffordanceRegions.js +138 -0
- package/dist/affordances/hitAffordanceRegions.js.map +1 -0
- package/dist/affordances/pathAnchors.js +66 -0
- package/dist/affordances/pathAnchors.js.map +1 -0
- package/dist/affordances/rotationHandle.js +103 -0
- package/dist/affordances/rotationHandle.js.map +1 -0
- package/dist/animation/behaviors/momentum.js +118 -0
- package/dist/animation/behaviors/momentum.js.map +1 -0
- package/dist/animation/colorHelpers.js +135 -0
- package/dist/animation/colorHelpers.js.map +1 -0
- package/dist/animation/colorRegistry.js +37 -0
- package/dist/animation/colorRegistry.js.map +1 -0
- package/dist/animation/index.js +20 -0
- package/dist/animation/loop.js +62 -0
- package/dist/animation/loop.js.map +1 -0
- package/dist/animation/observe.js +23 -0
- package/dist/animation/observe.js.map +1 -0
- package/dist/animation/poseHelpers.js +50 -0
- package/dist/animation/poseHelpers.js.map +1 -0
- package/dist/animation/reflow.js +121 -0
- package/dist/animation/reflow.js.map +1 -0
- package/dist/animation/rig/bindRig.js +74 -0
- package/dist/animation/rig/bindRig.js.map +1 -0
- package/dist/animation/rig/blendPoses.js +43 -0
- package/dist/animation/rig/blendPoses.js.map +1 -0
- package/dist/animation/rig/mirrorPose.js +19 -0
- package/dist/animation/rig/mirrorPose.js.map +1 -0
- package/dist/animation/rig/resolveSkeleton.js +33 -0
- package/dist/animation/rig/resolveSkeleton.js.map +1 -0
- package/dist/animation/rig/solveIk.js +103 -0
- package/dist/animation/rig/solveIk.js.map +1 -0
- package/dist/animation/rig/types.js +12 -0
- package/dist/animation/rig/types.js.map +1 -0
- package/dist/animation/rig/useRig.js +23 -0
- package/dist/animation/rig/useRig.js.map +1 -0
- package/dist/animation/slew.js +27 -0
- package/dist/animation/slew.js.map +1 -0
- package/dist/animation/stagger.js +138 -0
- package/dist/animation/stagger.js.map +1 -0
- package/dist/animation/timeline/booking.js +106 -0
- package/dist/animation/timeline/booking.js.map +1 -0
- package/dist/animation/timeline/createTimeline.js +116 -0
- package/dist/animation/timeline/createTimeline.js.map +1 -0
- package/dist/animation/timeline/sampleTrack.js +29 -0
- package/dist/animation/timeline/sampleTrack.js.map +1 -0
- package/dist/animation/useAnimator.js +329 -0
- package/dist/animation/useAnimator.js.map +1 -0
- package/dist/animation/wrappers/animateLifecycle.js +40 -0
- package/dist/animation/wrappers/animateLifecycle.js.map +1 -0
- package/dist/animation/wrappers/animateOnSetPose.js +44 -0
- package/dist/animation/wrappers/animateOnSetPose.js.map +1 -0
- package/dist/{autoPoseDescriptor-_XOyF7t4.d.ts → autoPoseDescriptor-vCdt55xm.d.ts} +2 -2
- package/dist/{builtins-DLn2lCr_.d.ts → builtins-C-gRyVRx.d.ts} +742 -513
- package/dist/canvas/Canvas.js +608 -0
- package/dist/canvas/Canvas.js.map +1 -0
- package/dist/canvas/CanvasView.js +255 -0
- package/dist/canvas/CanvasView.js.map +1 -0
- package/dist/canvas/CursorCoordsHud.js +102 -0
- package/dist/canvas/CursorCoordsHud.js.map +1 -0
- package/dist/canvas/DrawCanvas.js +67 -0
- package/dist/canvas/DrawCanvas.js.map +1 -0
- package/dist/canvas/MinimapCanvas.js +139 -0
- package/dist/canvas/MinimapCanvas.js.map +1 -0
- package/dist/canvas/ModalityHud.js +66 -0
- package/dist/canvas/ModalityHud.js.map +1 -0
- package/dist/canvas/NodeShape.js +391 -0
- package/dist/canvas/NodeShape.js.map +1 -0
- package/dist/canvas/PickHud.js +93 -0
- package/dist/canvas/PickHud.js.map +1 -0
- package/dist/canvas/SceneCanvas/ActionsProviderIfRoot.js +10 -0
- package/dist/canvas/SceneCanvas/ActionsProviderIfRoot.js.map +1 -0
- package/dist/canvas/SceneCanvas/DepRegistryProviderIfRoot.js +10 -0
- package/dist/canvas/SceneCanvas/DepRegistryProviderIfRoot.js.map +1 -0
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js +51 -0
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js.map +1 -0
- package/dist/canvas/SceneCanvas/contributionFrameHooks.js +42 -0
- package/dist/canvas/SceneCanvas/contributionFrameHooks.js.map +1 -0
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js +549 -0
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -0
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js +26 -0
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js.map +1 -0
- package/dist/canvas/SceneCanvas/dispatcherGestureBounds.js +69 -0
- package/dist/canvas/SceneCanvas/dispatcherGestureBounds.js.map +1 -0
- package/dist/canvas/SceneCanvas/features.js +97 -0
- package/dist/canvas/SceneCanvas/features.js.map +1 -0
- package/dist/canvas/SceneCanvas/poseGeometry.js +46 -0
- package/dist/canvas/SceneCanvas/poseGeometry.js.map +1 -0
- package/dist/canvas/SceneCanvas/useActionsPropResolver.js +48 -0
- package/dist/canvas/SceneCanvas/useActionsPropResolver.js.map +1 -0
- package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js +70 -0
- package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js.map +1 -0
- package/dist/canvas/SceneCanvas/useContributionRoles.js +75 -0
- package/dist/canvas/SceneCanvas/useContributionRoles.js.map +1 -0
- package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js +172 -0
- package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js.map +1 -0
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js +69 -0
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js.map +1 -0
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js +127 -0
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -0
- package/dist/canvas/SceneCanvas/useViewportActions.js +30 -0
- package/dist/canvas/SceneCanvas/useViewportActions.js.map +1 -0
- package/dist/canvas/SceneCanvas.js +992 -0
- package/dist/canvas/SceneCanvas.js.map +1 -0
- package/dist/canvas/SceneViewCanvas.js +54 -0
- package/dist/canvas/SceneViewCanvas.js.map +1 -0
- package/dist/canvas/accentColor.js +9 -0
- package/dist/canvas/accentColor.js.map +1 -0
- package/dist/canvas/affordanceAt.js +63 -0
- package/dist/canvas/affordanceAt.js.map +1 -0
- package/dist/canvas/buildSceneTree.js +65 -0
- package/dist/canvas/buildSceneTree.js.map +1 -0
- package/dist/canvas/canvasRenderer.js +89 -0
- package/dist/canvas/canvasRenderer.js.map +1 -0
- package/dist/canvas/colorOverrides.js +16 -0
- package/dist/canvas/colorOverrides.js.map +1 -0
- package/dist/canvas/defaultDrawOne.js +43 -0
- package/dist/canvas/defaultDrawOne.js.map +1 -0
- package/dist/canvas/deps/areaSelect.js +19 -0
- package/dist/canvas/deps/areaSelect.js.map +1 -0
- package/dist/canvas/deps/debug.js +9 -0
- package/dist/canvas/deps/debug.js.map +1 -0
- package/dist/canvas/deps/dispatcher.js +11 -0
- package/dist/canvas/deps/dispatcher.js.map +1 -0
- package/dist/canvas/deps/editAnchors.js +101 -0
- package/dist/canvas/deps/editAnchors.js.map +1 -0
- package/dist/canvas/deps/geometryProjection.js +11 -0
- package/dist/canvas/deps/geometryProjection.js.map +1 -0
- package/dist/canvas/deps/hitTestArea.js +51 -0
- package/dist/canvas/deps/hitTestArea.js.map +1 -0
- package/dist/canvas/deps/ingestion.js +31 -0
- package/dist/canvas/deps/ingestion.js.map +1 -0
- package/dist/canvas/deps/insert.js +116 -0
- package/dist/canvas/deps/insert.js.map +1 -0
- package/dist/canvas/deps/lassoSelect.js +20 -0
- package/dist/canvas/deps/lassoSelect.js.map +1 -0
- package/dist/canvas/deps/layout.js +34 -0
- package/dist/canvas/deps/layout.js.map +1 -0
- package/dist/canvas/deps/nodeAtPoint.js +19 -0
- package/dist/canvas/deps/nodeAtPoint.js.map +1 -0
- package/dist/canvas/deps/poseComposition.js +11 -0
- package/dist/canvas/deps/poseComposition.js.map +1 -0
- package/dist/canvas/deps/poseDescriptor.js +12 -0
- package/dist/canvas/deps/poseDescriptor.js.map +1 -0
- package/dist/canvas/deps/resizePolicy.js +35 -0
- package/dist/canvas/deps/resizePolicy.js.map +1 -0
- package/dist/canvas/deps/slice.js +99 -0
- package/dist/canvas/deps/slice.js.map +1 -0
- package/dist/canvas/deps/snap.js +11 -0
- package/dist/canvas/deps/snap.js.map +1 -0
- package/dist/canvas/deps/textEdit.js +21 -0
- package/dist/canvas/deps/textEdit.js.map +1 -0
- package/dist/canvas/deps/view.js +43 -0
- package/dist/canvas/deps/view.js.map +1 -0
- package/dist/canvas/derivedPath.js +47 -0
- package/dist/canvas/derivedPath.js.map +1 -0
- package/dist/canvas/drawEnvelope.js +22 -0
- package/dist/canvas/drawEnvelope.js.map +1 -0
- package/dist/canvas/getNodeAtPoint.js +18 -0
- package/dist/canvas/getNodeAtPoint.js.map +1 -0
- package/dist/canvas/hostAnchor.js +29 -0
- package/dist/canvas/hostAnchor.js.map +1 -0
- package/dist/canvas/hud.module.js +18 -0
- package/dist/canvas/hud.module.js.map +1 -0
- package/dist/canvas/insertPreviewExtent.js +103 -0
- package/dist/canvas/insertPreviewExtent.js.map +1 -0
- package/dist/canvas/kitRequirements.js +177 -0
- package/dist/canvas/kitRequirements.js.map +1 -0
- package/dist/canvas/layerOrder.js +66 -0
- package/dist/canvas/layerOrder.js.map +1 -0
- package/dist/canvas/layerSlots.js +14 -0
- package/dist/canvas/layerSlots.js.map +1 -0
- package/dist/canvas/minimapMath.js +80 -0
- package/dist/canvas/minimapMath.js.map +1 -0
- package/dist/canvas/mountedCanvases.js +20 -0
- package/dist/canvas/mountedCanvases.js.map +1 -0
- package/dist/canvas/overlayRoleStrokes.js +17 -0
- package/dist/canvas/overlayRoleStrokes.js.map +1 -0
- package/dist/canvas/paintCull.js +20 -0
- package/dist/canvas/paintCull.js.map +1 -0
- package/dist/canvas/pickWalk.js +158 -0
- package/dist/canvas/pickWalk.js.map +1 -0
- package/dist/canvas/planeClips.js +30 -0
- package/dist/canvas/planeClips.js.map +1 -0
- package/dist/canvas/poseRotation.js +35 -0
- package/dist/canvas/poseRotation.js.map +1 -0
- package/dist/canvas/rasterToPng.js +21 -0
- package/dist/canvas/rasterToPng.js.map +1 -0
- package/dist/canvas/renderDebugSnapshot.js +32 -0
- package/dist/canvas/renderDebugSnapshot.js.map +1 -0
- package/dist/canvas/renderNeeds.js +25 -0
- package/dist/canvas/renderNeeds.js.map +1 -0
- package/dist/canvas/renderSceneToPixels.js +143 -0
- package/dist/canvas/renderSceneToPixels.js.map +1 -0
- package/dist/canvas/sceneAdapter.js +270 -0
- package/dist/canvas/sceneAdapter.js.map +1 -0
- package/dist/canvas/sceneLayerPaint.js +37 -0
- package/dist/canvas/sceneLayerPaint.js.map +1 -0
- package/dist/canvas/sceneSlotWiring.js +20 -0
- package/dist/canvas/sceneSlotWiring.js.map +1 -0
- package/dist/canvas/sceneViewRender.js +72 -0
- package/dist/canvas/sceneViewRender.js.map +1 -0
- package/dist/canvas/slopsDebugLayer.js +61 -0
- package/dist/canvas/slopsDebugLayer.js.map +1 -0
- package/dist/canvas/surfaceContribution.js +15 -0
- package/dist/canvas/surfaceContribution.js.map +1 -0
- package/dist/canvas/toolPreview.js +39 -0
- package/dist/canvas/toolPreview.js.map +1 -0
- package/dist/canvas/useCanvasRenderer.js +11 -0
- package/dist/canvas/useCanvasRenderer.js.map +1 -0
- package/dist/canvas/useFrameLoop.js +60 -0
- package/dist/canvas/useFrameLoop.js.map +1 -0
- package/dist/canvas/useHostAnchor.js +71 -0
- package/dist/canvas/useHostAnchor.js.map +1 -0
- package/dist/canvas/useLateContentRedraw.js +21 -0
- package/dist/canvas/useLateContentRedraw.js.map +1 -0
- package/dist/canvas/useRedrawOn.js +21 -0
- package/dist/canvas/useRedrawOn.js.map +1 -0
- package/dist/canvas/useViewHelpers.js +120 -0
- package/dist/canvas/useViewHelpers.js.map +1 -0
- package/dist/canvas/viewInputs.js +17 -0
- package/dist/canvas/viewInputs.js.map +1 -0
- package/dist/canvas/viewRegistry.js +61 -0
- package/dist/canvas/viewRegistry.js.map +1 -0
- package/dist/canvas/wrapNodeOutput.js +14 -0
- package/dist/canvas/wrapNodeOutput.js.map +1 -0
- package/dist/clipboard.d.ts +10 -5
- package/dist/clipboard.js +3 -5
- package/dist/clone.d.ts +3 -3
- package/dist/clone.js +2 -5
- package/dist/core/adapters/arrayAdapter.js +85 -0
- package/dist/core/adapters/arrayAdapter.js.map +1 -0
- package/dist/core/adapters/useArrayAdapter.js +13 -0
- package/dist/core/adapters/useArrayAdapter.js.map +1 -0
- package/dist/core/applyOps.js +12 -0
- package/dist/core/applyOps.js.map +1 -0
- package/dist/core/device/index.js +4 -0
- package/dist/core/device/targets.js +17 -0
- package/dist/core/device/targets.js.map +1 -0
- package/dist/core/device/useDeviceProfile.js +75 -0
- package/dist/core/device/useDeviceProfile.js.map +1 -0
- package/dist/core/fillInPoseFrame.js +102 -0
- package/dist/core/fillInPoseFrame.js.map +1 -0
- package/dist/core/geometry/poseDescriptor.js +93 -0
- package/dist/core/geometry/poseDescriptor.js.map +1 -0
- package/dist/core/geometry/poseRotation.js +58 -0
- package/dist/core/geometry/poseRotation.js.map +1 -0
- package/dist/core/geometry/regionHit.js +102 -0
- package/dist/core/geometry/regionHit.js.map +1 -0
- package/dist/core/geometry/unionBounds.js +60 -0
- package/dist/core/geometry/unionBounds.js.map +1 -0
- package/dist/core/gradient.js +136 -0
- package/dist/core/gradient.js.map +1 -0
- package/dist/core/isPlainObject.js +11 -0
- package/dist/core/isPlainObject.js.map +1 -0
- package/dist/core/layers/render.js +150 -0
- package/dist/core/layers/render.js.map +1 -0
- package/dist/core/markerInset.js +24 -0
- package/dist/core/markerInset.js.map +1 -0
- package/dist/core/mixed.js +6 -0
- package/dist/core/mixed.js.map +1 -0
- package/dist/core/ops/arrange.js +31 -0
- package/dist/core/ops/arrange.js.map +1 -0
- package/dist/core/ops/create.js +32 -0
- package/dist/core/ops/create.js.map +1 -0
- package/dist/core/ops/createHistory.js +20 -0
- package/dist/core/ops/createHistory.js.map +1 -0
- package/dist/core/ops/delete.js +89 -0
- package/dist/core/ops/delete.js.map +1 -0
- package/dist/core/ops/registry.js +17 -0
- package/dist/core/ops/registry.js.map +1 -0
- package/dist/core/ops/reorder/algorithms.js +55 -0
- package/dist/core/ops/reorder/algorithms.js.map +1 -0
- package/dist/core/ops/reorder/index.js +140 -0
- package/dist/core/ops/reorder/index.js.map +1 -0
- package/dist/core/ops/reparent.js +52 -0
- package/dist/core/ops/reparent.js.map +1 -0
- package/dist/core/ops/select.js +34 -0
- package/dist/core/ops/select.js.map +1 -0
- package/dist/core/ops/setData.js +34 -0
- package/dist/core/ops/setData.js.map +1 -0
- package/dist/core/ops/setLayer.js +34 -0
- package/dist/core/ops/setLayer.js.map +1 -0
- package/dist/core/ops/setLayout.js +31 -0
- package/dist/core/ops/setLayout.js.map +1 -0
- package/dist/core/ops/setPath.js +57 -0
- package/dist/core/ops/setPath.js.map +1 -0
- package/dist/core/ops/setText.js +34 -0
- package/dist/core/ops/setText.js.map +1 -0
- package/dist/core/ops/slot.js +37 -0
- package/dist/core/ops/slot.js.map +1 -0
- package/dist/core/ops/transform.js +42 -0
- package/dist/core/ops/transform.js.map +1 -0
- package/dist/core/paintKinds.js +156 -0
- package/dist/core/paintKinds.js.map +1 -0
- package/dist/core/scene/NodeProperties.js +20 -0
- package/dist/core/scene/NodeProperties.js.map +1 -0
- package/dist/core/scene/NodeRouting.js +24 -0
- package/dist/core/scene/NodeRouting.js.map +1 -0
- package/dist/core/scene/arrivals.js +12 -0
- package/dist/core/scene/arrivals.js.map +1 -0
- package/dist/core/scene/composeFrame.js +29 -0
- package/dist/core/scene/composeFrame.js.map +1 -0
- package/dist/core/scene/depMemo.js +18 -0
- package/dist/core/scene/depMemo.js.map +1 -0
- package/dist/core/scene/dependents.js +66 -0
- package/dist/core/scene/dependents.js.map +1 -0
- package/dist/core/scene/derivedPath.js +31 -0
- package/dist/core/scene/derivedPath.js.map +1 -0
- package/dist/core/scene/effectivePose.js +78 -0
- package/dist/core/scene/effectivePose.js.map +1 -0
- package/dist/core/scene/kitRegistry.js +33 -0
- package/dist/core/scene/kitRegistry.js.map +1 -0
- package/dist/core/scene/layoutPass.js +96 -0
- package/dist/core/scene/layoutPass.js.map +1 -0
- package/dist/core/scene/nodeFnFields.js +83 -0
- package/dist/core/scene/nodeFnFields.js.map +1 -0
- package/dist/core/scene/nodeMemo.js +28 -0
- package/dist/core/scene/nodeMemo.js.map +1 -0
- package/dist/core/scene/poseFeed.js +87 -0
- package/dist/core/scene/poseFeed.js.map +1 -0
- package/dist/core/scene/poseOverrides.js +52 -0
- package/dist/core/scene/poseOverrides.js.map +1 -0
- package/dist/core/scene/poseSnapshot.js +54 -0
- package/dist/core/scene/poseSnapshot.js.map +1 -0
- package/dist/core/scene/scene.js +1271 -0
- package/dist/core/scene/scene.js.map +1 -0
- package/dist/core/scene/types.js +6 -0
- package/dist/core/scene/types.js.map +1 -0
- package/dist/core/scene/useScene.js +32 -0
- package/dist/core/scene/useScene.js.map +1 -0
- package/dist/core/selection/chromeState.js +31 -0
- package/dist/core/selection/chromeState.js.map +1 -0
- package/dist/core/selection/selectionTarget.js +6 -0
- package/dist/core/selection/selectionTarget.js.map +1 -0
- package/dist/core/selection/useSelection.js +71 -0
- package/dist/core/selection/useSelection.js.map +1 -0
- package/dist/core/shapeKinds.js +54 -0
- package/dist/core/shapeKinds.js.map +1 -0
- package/dist/core/strokeMarkerShapes.js +139 -0
- package/dist/core/strokeMarkerShapes.js.map +1 -0
- package/dist/core/strokeMarkers.js +28 -0
- package/dist/core/strokeMarkers.js.map +1 -0
- package/dist/core/stylus/stylus.js +39 -0
- package/dist/core/stylus/stylus.js.map +1 -0
- package/dist/core/stylus/usePointerStylus.js +51 -0
- package/dist/core/stylus/usePointerStylus.js.map +1 -0
- package/dist/core/usePaintKinds.js +17 -0
- package/dist/core/usePaintKinds.js.map +1 -0
- package/dist/core/viewport/clampView.js +24 -0
- package/dist/core/viewport/clampView.js.map +1 -0
- package/dist/core/viewport/clientToWorld.js +8 -0
- package/dist/core/viewport/clientToWorld.js.map +1 -0
- package/dist/core/viewport/createVelocityTracker.js +39 -0
- package/dist/core/viewport/createVelocityTracker.js.map +1 -0
- package/dist/core/viewport/fitToBounds.js +18 -0
- package/dist/core/viewport/fitToBounds.js.map +1 -0
- package/dist/core/viewport/fitViewToBounds.js +36 -0
- package/dist/core/viewport/fitViewToBounds.js.map +1 -0
- package/dist/core/viewport/interpolateView.js +34 -0
- package/dist/core/viewport/interpolateView.js.map +1 -0
- package/dist/core/viewport/meanScale.js +8 -0
- package/dist/core/viewport/meanScale.js.map +1 -0
- package/dist/core/viewport/parallax.js +111 -0
- package/dist/core/viewport/parallax.js.map +1 -0
- package/dist/core/viewport/pxExtent.js +42 -0
- package/dist/core/viewport/pxExtent.js.map +1 -0
- package/dist/core/viewport/sceneNodeClientRect.js +18 -0
- package/dist/core/viewport/sceneNodeClientRect.js.map +1 -0
- package/dist/core/viewport/screenSlop.js +27 -0
- package/dist/core/viewport/screenSlop.js.map +1 -0
- package/dist/core/viewport/useAutoCenter.js +32 -0
- package/dist/core/viewport/useAutoCenter.js.map +1 -0
- package/dist/core/viewport/useCanvasSize.js +29 -0
- package/dist/core/viewport/useCanvasSize.js.map +1 -0
- package/dist/core/viewport/useDecayLoop.js +63 -0
- package/dist/core/viewport/useDecayLoop.js.map +1 -0
- package/dist/core/viewport/useVelocityTracker.js +10 -0
- package/dist/core/viewport/useVelocityTracker.js.map +1 -0
- package/dist/core/viewport/useViewAnimation.js +63 -0
- package/dist/core/viewport/useViewAnimation.js.map +1 -0
- package/dist/core/viewport/view.js +37 -0
- package/dist/core/viewport/view.js.map +1 -0
- package/dist/core/viewport/viewTransform.js +11 -0
- package/dist/core/viewport/viewTransform.js.map +1 -0
- package/dist/core/viewport/viewportWorldRect.js +13 -0
- package/dist/core/viewport/viewportWorldRect.js.map +1 -0
- package/dist/core/viewport/wheelHandler.js +30 -0
- package/dist/core/viewport/wheelHandler.js.map +1 -0
- package/dist/core/viewport/zoomAt.js +22 -0
- package/dist/core/viewport/zoomAt.js.map +1 -0
- package/dist/core/viewport/zoomBounds.js +20 -0
- package/dist/core/viewport/zoomBounds.js.map +1 -0
- package/dist/{pointSnapToGrid-Dp2IxLGb.d.ts → cornerHandles-BCrDp_mH.d.ts} +3 -13
- package/dist/debug/createDebugOverlayLayer.js +358 -0
- package/dist/debug/createDebugOverlayLayer.js.map +1 -0
- package/dist/debug/createDebugSink.js +83 -0
- package/dist/debug/createDebugSink.js.map +1 -0
- package/dist/debug/defaultTheme.js +31 -0
- package/dist/debug/defaultTheme.js.map +1 -0
- package/dist/debug/flag.js +41 -0
- package/dist/debug/flag.js.map +1 -0
- package/dist/debug/frameStats.js +16 -0
- package/dist/debug/frameStats.js.map +1 -0
- package/dist/debug/parseDebugFlags.js +32 -0
- package/dist/debug/parseDebugFlags.js.map +1 -0
- package/dist/features/chrome-caps/buildChromeCtx.js +16 -0
- package/dist/features/chrome-caps/buildChromeCtx.js.map +1 -0
- package/dist/features/chrome-caps/conditions.js +36 -0
- package/dist/features/chrome-caps/conditions.js.map +1 -0
- package/dist/features/chrome-caps/defaults.js +26 -0
- package/dist/features/chrome-caps/defaults.js.map +1 -0
- package/dist/features/chrome-caps/index.js +7 -0
- package/dist/features/chrome-caps/resolve.js +23 -0
- package/dist/features/chrome-caps/resolve.js.map +1 -0
- package/dist/features/chrome-caps/useHoverTracking.js +27 -0
- package/dist/features/chrome-caps/useHoverTracking.js.map +1 -0
- package/dist/features/cursor/paintedCursorLayer.js +60 -0
- package/dist/features/cursor/paintedCursorLayer.js.map +1 -0
- package/dist/features/focus/gateLayer.js +14 -0
- package/dist/features/focus/gateLayer.js.map +1 -0
- package/dist/features/focus/useCanvasFocus.js +29 -0
- package/dist/features/focus/useCanvasFocus.js.map +1 -0
- package/dist/features/groups/children.js +23 -0
- package/dist/features/groups/children.js.map +1 -0
- package/dist/features/groups/composePose.js +67 -0
- package/dist/features/groups/composePose.js.map +1 -0
- package/dist/features/groups/nestedHit.js +40 -0
- package/dist/features/groups/nestedHit.js.map +1 -0
- package/dist/features/groups/unionOfChildren.js +15 -0
- package/dist/features/groups/unionOfChildren.js.map +1 -0
- package/dist/features/images/imageCache.js +94 -0
- package/dist/features/images/imageCache.js.map +1 -0
- package/dist/features/ingestion/contentHandlers.js +37 -0
- package/dist/features/ingestion/contentHandlers.js.map +1 -0
- package/dist/features/ingestion/imageHandler.js +45 -0
- package/dist/features/ingestion/imageHandler.js.map +1 -0
- package/dist/features/ingestion/index.js +8 -0
- package/dist/features/ingestion/openFilePicker.js +15 -0
- package/dist/features/ingestion/openFilePicker.js.map +1 -0
- package/dist/features/ingestion/registerKitHandlers.js +26 -0
- package/dist/features/ingestion/registerKitHandlers.js.map +1 -0
- package/dist/features/ingestion/svgHandler.js +58 -0
- package/dist/features/ingestion/svgHandler.js.map +1 -0
- package/dist/features/ingestion/weaselJsonHandler.js +39 -0
- package/dist/features/ingestion/weaselJsonHandler.js.map +1 -0
- package/dist/features/longPress/longPressFeedback.js +96 -0
- package/dist/features/longPress/longPressFeedback.js.map +1 -0
- package/dist/features/meshPaint/bake.js +79 -0
- package/dist/features/meshPaint/bake.js.map +1 -0
- package/dist/features/meshPaint/bakeCache.js +59 -0
- package/dist/features/meshPaint/bakeCache.js.map +1 -0
- package/dist/features/meshPaint/handles.js +86 -0
- package/dist/features/meshPaint/handles.js.map +1 -0
- package/dist/features/meshPaint/lazyKind.js +1298 -0
- package/dist/features/meshPaint/lazyKind.js.map +1 -0
- package/dist/features/meshPaint/meshPaint.js +236 -0
- package/dist/features/meshPaint/meshPaint.js.map +1 -0
- package/dist/features/meshPaint/meshShader.js +6 -0
- package/dist/features/meshPaint/meshShader.js.map +1 -0
- package/dist/features/meshPaint/register.js +7 -0
- package/dist/features/meshPaint/register.js.map +1 -0
- package/dist/features/meshPaint/surface.js +110 -0
- package/dist/features/meshPaint/surface.js.map +1 -0
- package/dist/features/minimap/actions.js +53 -0
- package/dist/features/minimap/actions.js.map +1 -0
- package/dist/features/minimap/createMinimapContribution.js +96 -0
- package/dist/features/minimap/createMinimapContribution.js.map +1 -0
- package/dist/features/minimap/layers.js +103 -0
- package/dist/features/minimap/layers.js.map +1 -0
- package/dist/features/modes/modeLayers.js +113 -0
- package/dist/features/modes/modeLayers.js.map +1 -0
- package/dist/features/overlays/useNodeOverlayFrame.js +103 -0
- package/dist/features/overlays/useNodeOverlayFrame.js.map +1 -0
- package/dist/features/parallax/createParallaxLayer.js +26 -0
- package/dist/features/parallax/createParallaxLayer.js.map +1 -0
- package/dist/features/parallax/createParallaxPlane.js +26 -0
- package/dist/features/parallax/createParallaxPlane.js.map +1 -0
- package/dist/features/paths/anchorEdits.js +156 -0
- package/dist/features/paths/anchorEdits.js.map +1 -0
- package/dist/features/paths/anchors.js +154 -0
- package/dist/features/paths/anchors.js.map +1 -0
- package/dist/features/paths/booleans.js +2 -0
- package/dist/features/paths/index.js +15 -0
- package/dist/features/paths/markerCommands.js +116 -0
- package/dist/features/paths/markerCommands.js.map +1 -0
- package/dist/features/paths/markerSites.js +59 -0
- package/dist/features/paths/markerSites.js.map +1 -0
- package/dist/features/paths/markers.js +95 -0
- package/dist/features/paths/markers.js.map +1 -0
- package/dist/features/paths/nearestAnchor.js +36 -0
- package/dist/features/paths/nearestAnchor.js.map +1 -0
- package/dist/features/paths/originProjection.js +16 -0
- package/dist/features/paths/originProjection.js.map +1 -0
- package/dist/features/paths/pathEditingOverlayLayer.js +137 -0
- package/dist/features/paths/pathEditingOverlayLayer.js.map +1 -0
- package/dist/features/paths/pathInWorld.js +41 -0
- package/dist/features/paths/pathInWorld.js.map +1 -0
- package/dist/features/paths/pathLayer.js +44 -0
- package/dist/features/paths/pathLayer.js.map +1 -0
- package/dist/features/paths/penPreviewLayer.js +220 -0
- package/dist/features/paths/penPreviewLayer.js.map +1 -0
- package/dist/features/paths/poseDescriptor.js +39 -0
- package/dist/features/paths/poseDescriptor.js.map +1 -0
- package/dist/features/paths/tessellate/stroke.js +230 -0
- package/dist/features/paths/tessellate/stroke.js.map +1 -0
- package/dist/features/patterns/index.js +23 -0
- package/dist/features/patterns/index.js.map +1 -0
- package/dist/features/patterns/patterns-builtin.js +38 -0
- package/dist/features/patterns/patterns-builtin.js.map +1 -0
- package/dist/features/patterns/resolveSpec.js +57 -0
- package/dist/features/patterns/resolveSpec.js.map +1 -0
- package/dist/features/patterns/tileGeometry.js +158 -0
- package/dist/features/patterns/tileGeometry.js.map +1 -0
- package/dist/features/pointer/PointerContext.js +45 -0
- package/dist/features/pointer/PointerContext.js.map +1 -0
- package/dist/features/poseRun/usePoseRun.js +70 -0
- package/dist/features/poseRun/usePoseRun.js.map +1 -0
- package/dist/features/selection/SelectionContext.js +46 -0
- package/dist/features/selection/SelectionContext.js.map +1 -0
- package/dist/features/selection/overlay.js +442 -0
- package/dist/features/selection/overlay.js.map +1 -0
- package/dist/features/simulation/createSimulation.js +61 -0
- package/dist/features/simulation/createSimulation.js.map +1 -0
- package/dist/features/simulation/types.js +6 -0
- package/dist/features/simulation/types.js.map +1 -0
- package/dist/features/simulation/useSimulation.js +74 -0
- package/dist/features/simulation/useSimulation.js.map +1 -0
- package/dist/features/text/domRuns.js +258 -0
- package/dist/features/text/domRuns.js.map +1 -0
- package/dist/features/text/fitTextPose.js +38 -0
- package/dist/features/text/fitTextPose.js.map +1 -0
- package/dist/features/text/hitTest.js +45 -0
- package/dist/features/text/hitTest.js.map +1 -0
- package/dist/features/text/renderLabel.js +14 -0
- package/dist/features/text/renderLabel.js.map +1 -0
- package/dist/features/text/runs/effectiveRangeStyle.js +66 -0
- package/dist/features/text/runs/effectiveRangeStyle.js.map +1 -0
- package/dist/features/text/runs/flagRange.js +53 -0
- package/dist/features/text/runs/flagRange.js.map +1 -0
- package/dist/features/text/runs/rangeStyle.js +135 -0
- package/dist/features/text/runs/rangeStyle.js.map +1 -0
- package/dist/features/text/textCommand.js +59 -0
- package/dist/features/text/textCommand.js.map +1 -0
- package/dist/features/text/textLayer.js +35 -0
- package/dist/features/text/textLayer.js.map +1 -0
- package/dist/features/text/textToPath.js +181 -0
- package/dist/features/text/textToPath.js.map +1 -0
- package/dist/features/text/useSceneTextEdit.js +138 -0
- package/dist/features/text/useSceneTextEdit.js.map +1 -0
- package/dist/features/text/useTextEdit.js +465 -0
- package/dist/features/text/useTextEdit.js.map +1 -0
- package/dist/features/tiling/createTiledLayer.js +63 -0
- package/dist/features/tiling/createTiledLayer.js.map +1 -0
- package/dist/features/tiling/tiledProject.js +14 -0
- package/dist/features/tiling/tiledProject.js.map +1 -0
- package/dist/features/viewports/viewResolver.js +59 -0
- package/dist/features/viewports/viewResolver.js.map +1 -0
- package/dist/features/viewports/viewportLayer.js +58 -0
- package/dist/features/viewports/viewportLayer.js.map +1 -0
- package/dist/icons/ArrowIcon.js +23 -0
- package/dist/icons/ArrowIcon.js.map +1 -0
- package/dist/icons/EllipseIcon.js +21 -0
- package/dist/icons/EllipseIcon.js.map +1 -0
- package/dist/icons/EyedropperIcon.js +49 -0
- package/dist/icons/EyedropperIcon.js.map +1 -0
- package/dist/icons/HandIcon.js +59 -0
- package/dist/icons/HandIcon.js.map +1 -0
- package/dist/icons/ImageIcon.js +34 -0
- package/dist/icons/ImageIcon.js.map +1 -0
- package/dist/icons/LassoIcon.js +22 -0
- package/dist/icons/LassoIcon.js.map +1 -0
- package/dist/icons/LineIcon.js +22 -0
- package/dist/icons/LineIcon.js.map +1 -0
- package/dist/icons/PenIcon.js +36 -0
- package/dist/icons/PenIcon.js.map +1 -0
- package/dist/icons/PencilIcon.js +25 -0
- package/dist/icons/PencilIcon.js.map +1 -0
- package/dist/icons/PolygonIcon.js +19 -0
- package/dist/icons/PolygonIcon.js.map +1 -0
- package/dist/icons/RectIcon.js +37 -0
- package/dist/icons/RectIcon.js.map +1 -0
- package/dist/icons/SelectIcon.js +20 -0
- package/dist/icons/SelectIcon.js.map +1 -0
- package/dist/icons/StarIcon.js +19 -0
- package/dist/icons/StarIcon.js.map +1 -0
- package/dist/icons/TextIcon.js +19 -0
- package/dist/icons/TextIcon.js.map +1 -0
- package/dist/icons/UnknownIcon.js +33 -0
- package/dist/icons/UnknownIcon.js.map +1 -0
- package/dist/icons/_base.js +12 -0
- package/dist/icons/_base.js.map +1 -0
- package/dist/index.d.ts +1960 -1891
- package/dist/index.js +312 -13
- package/dist/input/keyState.js +76 -0
- package/dist/input/keyState.js.map +1 -0
- package/dist/input/useKeyState.js +22 -0
- package/dist/input/useKeyState.js.map +1 -0
- package/dist/interactions/actions/actionShortcuts.js +32 -0
- package/dist/interactions/actions/actionShortcuts.js.map +1 -0
- package/dist/interactions/actions/align/align.js +81 -0
- package/dist/interactions/actions/align/align.js.map +1 -0
- package/dist/interactions/actions/booleans/booleans.js +120 -0
- package/dist/interactions/actions/booleans/booleans.js.map +1 -0
- package/dist/interactions/actions/booleans/useBooleans.js +20 -0
- package/dist/interactions/actions/booleans/useBooleans.js.map +1 -0
- package/dist/interactions/actions/booleans/useBooleansAdapter.js +9 -0
- package/dist/interactions/actions/booleans/useBooleansAdapter.js.map +1 -0
- package/dist/interactions/actions/clipboard/clipboardOps.js +94 -0
- package/dist/interactions/actions/clipboard/clipboardOps.js.map +1 -0
- package/dist/interactions/actions/clipboard/materializePaste.js +25 -0
- package/dist/interactions/actions/clipboard/materializePaste.js.map +1 -0
- package/dist/interactions/actions/clipboard/wireFormat.js +43 -0
- package/dist/interactions/actions/clipboard/wireFormat.js.map +1 -0
- package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js +26 -0
- package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js.map +1 -0
- package/dist/interactions/actions/defaultCommitAdapter.js +42 -0
- package/dist/interactions/actions/defaultCommitAdapter.js.map +1 -0
- package/dist/interactions/actions/defaults/align.js +71 -0
- package/dist/interactions/actions/defaults/align.js.map +1 -0
- package/dist/interactions/actions/defaults/anchorEditing.js +235 -0
- package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -0
- package/dist/interactions/actions/defaults/areaSelect.js +75 -0
- package/dist/interactions/actions/defaults/areaSelect.js.map +1 -0
- package/dist/interactions/actions/defaults/booleans.js +52 -0
- package/dist/interactions/actions/defaults/booleans.js.map +1 -0
- package/dist/interactions/actions/defaults/cancelGesture.js +24 -0
- package/dist/interactions/actions/defaults/cancelGesture.js.map +1 -0
- package/dist/interactions/actions/defaults/clearSelection.js +19 -0
- package/dist/interactions/actions/defaults/clearSelection.js.map +1 -0
- package/dist/interactions/actions/defaults/clipboard.js +78 -0
- package/dist/interactions/actions/defaults/clipboard.js.map +1 -0
- package/dist/interactions/actions/defaults/clone.js +107 -0
- package/dist/interactions/actions/defaults/clone.js.map +1 -0
- package/dist/interactions/actions/defaults/createOutlines.js +47 -0
- package/dist/interactions/actions/defaults/createOutlines.js.map +1 -0
- package/dist/interactions/actions/defaults/createPaintAction.js +85 -0
- package/dist/interactions/actions/defaults/createPaintAction.js.map +1 -0
- package/dist/interactions/actions/defaults/delete.js +61 -0
- package/dist/interactions/actions/defaults/delete.js.map +1 -0
- package/dist/interactions/actions/defaults/distribute.js +66 -0
- package/dist/interactions/actions/defaults/distribute.js.map +1 -0
- package/dist/interactions/actions/defaults/duplicate.js +83 -0
- package/dist/interactions/actions/defaults/duplicate.js.map +1 -0
- package/dist/interactions/actions/defaults/editAnchors.js +100 -0
- package/dist/interactions/actions/defaults/editAnchors.js.map +1 -0
- package/dist/interactions/actions/defaults/enterPathEdit.js +29 -0
- package/dist/interactions/actions/defaults/enterPathEdit.js.map +1 -0
- package/dist/interactions/actions/defaults/enterTextEdit.js +20 -0
- package/dist/interactions/actions/defaults/enterTextEdit.js.map +1 -0
- package/dist/interactions/actions/defaults/escape.js +26 -0
- package/dist/interactions/actions/defaults/escape.js.map +1 -0
- package/dist/interactions/actions/defaults/exitPathEdit.js +22 -0
- package/dist/interactions/actions/defaults/exitPathEdit.js.map +1 -0
- package/dist/interactions/actions/defaults/flip.js +119 -0
- package/dist/interactions/actions/defaults/flip.js.map +1 -0
- package/dist/interactions/actions/defaults/freshNodeId.js +10 -0
- package/dist/interactions/actions/defaults/freshNodeId.js.map +1 -0
- package/dist/interactions/actions/defaults/group.js +131 -0
- package/dist/interactions/actions/defaults/group.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/actionGlyphIcons.js +40 -0
- package/dist/interactions/actions/defaults/icons/actionGlyphIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/actionGlyphs.js +10 -0
- package/dist/interactions/actions/defaults/icons/actionGlyphs.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/alignIcons.js +173 -0
- package/dist/interactions/actions/defaults/icons/alignIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/booleanIcons.js +171 -0
- package/dist/interactions/actions/defaults/icons/booleanIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/distributeIcons.js +63 -0
- package/dist/interactions/actions/defaults/icons/distributeIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/editIcons.js +280 -0
- package/dist/interactions/actions/defaults/icons/editIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/outlineIcons.js +53 -0
- package/dist/interactions/actions/defaults/icons/outlineIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/ingest.js +58 -0
- package/dist/interactions/actions/defaults/ingest.js.map +1 -0
- package/dist/interactions/actions/defaults/insert.js +288 -0
- package/dist/interactions/actions/defaults/insert.js.map +1 -0
- package/dist/interactions/actions/defaults/insertPathAnchor.js +50 -0
- package/dist/interactions/actions/defaults/insertPathAnchor.js.map +1 -0
- package/dist/interactions/actions/defaults/lassoSelect.js +156 -0
- package/dist/interactions/actions/defaults/lassoSelect.js.map +1 -0
- package/dist/interactions/actions/defaults/move.js +760 -0
- package/dist/interactions/actions/defaults/move.js.map +1 -0
- package/dist/interactions/actions/defaults/nudge.js +110 -0
- package/dist/interactions/actions/defaults/nudge.js.map +1 -0
- package/dist/interactions/actions/defaults/pinchZoom.js +63 -0
- package/dist/interactions/actions/defaults/pinchZoom.js.map +1 -0
- package/dist/interactions/actions/defaults/reorder.js +143 -0
- package/dist/interactions/actions/defaults/reorder.js.map +1 -0
- package/dist/interactions/actions/defaults/requiresSelection.js +10 -0
- package/dist/interactions/actions/defaults/requiresSelection.js.map +1 -0
- package/dist/interactions/actions/defaults/resize.js +335 -0
- package/dist/interactions/actions/defaults/resize.js.map +1 -0
- package/dist/interactions/actions/defaults/rotate.js +184 -0
- package/dist/interactions/actions/defaults/rotate.js.map +1 -0
- package/dist/interactions/actions/defaults/selectAll.js +27 -0
- package/dist/interactions/actions/defaults/selectAll.js.map +1 -0
- package/dist/interactions/actions/defaults/setFill.js +27 -0
- package/dist/interactions/actions/defaults/setFill.js.map +1 -0
- package/dist/interactions/actions/defaults/setFillOpacity.js +15 -0
- package/dist/interactions/actions/defaults/setFillOpacity.js.map +1 -0
- package/dist/interactions/actions/defaults/setStroke.js +36 -0
- package/dist/interactions/actions/defaults/setStroke.js.map +1 -0
- package/dist/interactions/actions/defaults/setStrokeOpacity.js +21 -0
- package/dist/interactions/actions/defaults/setStrokeOpacity.js.map +1 -0
- package/dist/interactions/actions/defaults/slice.js +39 -0
- package/dist/interactions/actions/defaults/slice.js.map +1 -0
- package/dist/interactions/actions/defaults/sliceOps.js +60 -0
- package/dist/interactions/actions/defaults/sliceOps.js.map +1 -0
- package/dist/interactions/actions/defaults/toolActivate.js +35 -0
- package/dist/interactions/actions/defaults/toolActivate.js.map +1 -0
- package/dist/interactions/actions/defaults/toolResetToDefault.js +26 -0
- package/dist/interactions/actions/defaults/toolResetToDefault.js.map +1 -0
- package/dist/interactions/actions/defaults/undoRedo.js +51 -0
- package/dist/interactions/actions/defaults/undoRedo.js.map +1 -0
- package/dist/interactions/actions/defaults/viewportDragPan.js +88 -0
- package/dist/interactions/actions/defaults/viewportDragPan.js.map +1 -0
- package/dist/interactions/actions/defaults/viewportWheelPan.js +57 -0
- package/dist/interactions/actions/defaults/viewportWheelPan.js.map +1 -0
- package/dist/interactions/actions/defaults/viewportZoom.js +143 -0
- package/dist/interactions/actions/defaults/viewportZoom.js.map +1 -0
- package/dist/interactions/actions/distribute/distribute.js +42 -0
- package/dist/interactions/actions/distribute/distribute.js.map +1 -0
- package/dist/interactions/actions/distribute/plan.js +29 -0
- package/dist/interactions/actions/distribute/plan.js.map +1 -0
- package/dist/interactions/actions/edit-anchors/geometry.js +61 -0
- package/dist/interactions/actions/edit-anchors/geometry.js.map +1 -0
- package/dist/interactions/actions/edit-anchors/handles.js +43 -0
- package/dist/interactions/actions/edit-anchors/handles.js.map +1 -0
- package/dist/interactions/actions/flip/helpers.js +35 -0
- package/dist/interactions/actions/flip/helpers.js.map +1 -0
- package/dist/interactions/actions/geometryProjection.js +18 -0
- package/dist/interactions/actions/geometryProjection.js.map +1 -0
- package/dist/interactions/actions/gestureLifecycle.js +44 -0
- package/dist/interactions/actions/gestureLifecycle.js.map +1 -0
- package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js +39 -0
- package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js.map +1 -0
- package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js +36 -0
- package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js.map +1 -0
- package/dist/interactions/actions/move/behaviors/snapToContainer.js +67 -0
- package/dist/interactions/actions/move/behaviors/snapToContainer.js.map +1 -0
- package/dist/interactions/actions/move/gestureAdapter.js +37 -0
- package/dist/interactions/actions/move/gestureAdapter.js.map +1 -0
- package/dist/interactions/actions/outlines/createOutlines.js +84 -0
- package/dist/interactions/actions/outlines/createOutlines.js.map +1 -0
- package/dist/interactions/actions/outlines/useCreateOutlinesAdapter.js +9 -0
- package/dist/interactions/actions/outlines/useCreateOutlinesAdapter.js.map +1 -0
- package/dist/interactions/actions/planeInput.js +181 -0
- package/dist/interactions/actions/planeInput.js.map +1 -0
- package/dist/interactions/actions/poseDescriptorDep.js +9 -0
- package/dist/interactions/actions/poseDescriptorDep.js.map +1 -0
- package/dist/interactions/actions/poseFrame.js +38 -0
- package/dist/interactions/actions/poseFrame.js.map +1 -0
- package/dist/interactions/actions/previewOverrides.js +25 -0
- package/dist/interactions/actions/previewOverrides.js.map +1 -0
- package/dist/interactions/actions/resize/autoPoseDescriptor.js +31 -0
- package/dist/interactions/actions/resize/autoPoseDescriptor.js.map +1 -0
- package/dist/interactions/actions/resize/behaviors/clampMinSize.js +18 -0
- package/dist/interactions/actions/resize/behaviors/clampMinSize.js.map +1 -0
- package/dist/interactions/actions/resize/behaviors/index.js +8 -0
- package/dist/interactions/actions/resize/behaviors/index.js.map +1 -0
- package/dist/interactions/actions/resize/behaviors/lockAspect.js +24 -0
- package/dist/interactions/actions/resize/behaviors/lockAspect.js.map +1 -0
- package/dist/interactions/actions/resize/cornerHandles.js +72 -0
- package/dist/interactions/actions/resize/cornerHandles.js.map +1 -0
- package/dist/interactions/actions/resolveOverlays.js +60 -0
- package/dist/interactions/actions/resolveOverlays.js.map +1 -0
- package/dist/interactions/actions/resolvePreviews.js +61 -0
- package/dist/interactions/actions/resolvePreviews.js.map +1 -0
- package/dist/interactions/actions/rotate/geometry.js +46 -0
- package/dist/interactions/actions/rotate/geometry.js.map +1 -0
- package/dist/interactions/actions/rotate/handle.js +27 -0
- package/dist/interactions/actions/rotate/handle.js.map +1 -0
- package/dist/interactions/actions/spatialReference.js +42 -0
- package/dist/interactions/actions/spatialReference.js.map +1 -0
- package/dist/interactions/actions/useStandardActions.js +142 -0
- package/dist/interactions/actions/useStandardActions.js.map +1 -0
- package/dist/interactions/gestures/dragGesture/dragGesture.js +111 -0
- package/dist/interactions/gestures/dragGesture/dragGesture.js.map +1 -0
- package/dist/interactions/gestures/dragRadial/dragRadial.js +117 -0
- package/dist/interactions/gestures/dragRadial/dragRadial.js.map +1 -0
- package/dist/interactions/gestures/dragRect/dragRect.js +164 -0
- package/dist/interactions/gestures/dragRect/dragRect.js.map +1 -0
- package/dist/interactions/gestures/handleDrag/handleDrag.js +46 -0
- package/dist/interactions/gestures/handleDrag/handleDrag.js.map +1 -0
- package/dist/interactions/gestures/pointerDrag/pointerDrag.js +118 -0
- package/dist/interactions/gestures/pointerDrag/pointerDrag.js.map +1 -0
- package/dist/interactions/gestures/shared/originProjection.js +42 -0
- package/dist/interactions/gestures/shared/originProjection.js.map +1 -0
- package/dist/interactions/gestures/shared/screenTolerance.js +21 -0
- package/dist/interactions/gestures/shared/screenTolerance.js.map +1 -0
- package/dist/interactions/gestures/shared/snap.js +24 -0
- package/dist/interactions/gestures/shared/snap.js.map +1 -0
- package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js +30 -0
- package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js.map +1 -0
- package/dist/layout/arrivals.js +36 -0
- package/dist/layout/arrivals.js.map +1 -0
- package/dist/{math-MCQcf_gc.d.ts → math-Drrw4ewZ.d.ts} +8 -116
- package/dist/math.d.ts +4 -5
- package/dist/math.js +6 -4
- package/dist/mesh.d.ts +268 -0
- package/dist/mesh.js +7 -0
- package/dist/move.d.ts +7 -49
- package/dist/move.js +3 -142
- package/dist/originProjection-DEklpDc_.d.ts +57 -0
- package/dist/patterns-builtin.js +3 -3
- package/dist/{poseDescriptor-rZa9W5hJ.d.ts → poseDescriptor-D-OH-tu5.d.ts} +0 -4
- package/dist/registerProgram-ateHDGjw.d.ts +193 -0
- package/dist/renderer/DrawCommand.js +6 -0
- package/dist/renderer/DrawCommand.js.map +1 -0
- package/dist/renderer/WeaselRenderer.js +328 -0
- package/dist/renderer/WeaselRenderer.js.map +1 -0
- package/dist/renderer/cache/GLImageCache.js +64 -0
- package/dist/renderer/cache/GLImageCache.js.map +1 -0
- package/dist/renderer/cache/GLMeshCache.js +102 -0
- package/dist/renderer/cache/GLMeshCache.js.map +1 -0
- package/dist/renderer/cache/GLTextureCache.js +51 -0
- package/dist/renderer/cache/GLTextureCache.js.map +1 -0
- package/dist/renderer/cache/GradientRampAtlas.js +82 -0
- package/dist/renderer/cache/GradientRampAtlas.js.map +1 -0
- package/dist/renderer/cache/cache.js +13 -0
- package/dist/renderer/cache/cache.js.map +1 -0
- package/dist/renderer/cache/markerCommandCache.js +59 -0
- package/dist/renderer/cache/markerCommandCache.js.map +1 -0
- package/dist/renderer/cache/outlineMeshCache.js +15 -0
- package/dist/renderer/cache/outlineMeshCache.js.map +1 -0
- package/dist/renderer/cache/outlineStrokeMeshCache.js +31 -0
- package/dist/renderer/cache/outlineStrokeMeshCache.js.map +1 -0
- package/dist/renderer/cache/strokeMeshCache.js +44 -0
- package/dist/renderer/cache/strokeMeshCache.js.map +1 -0
- package/dist/renderer/cullDrawCommands.js +89 -0
- package/dist/renderer/cullDrawCommands.js.map +1 -0
- package/dist/renderer/draw.js +1109 -0
- package/dist/renderer/draw.js.map +1 -0
- package/dist/renderer/drawBatch.js +168 -0
- package/dist/renderer/drawBatch.js.map +1 -0
- package/dist/renderer/effects/EffectTargets.js +45 -0
- package/dist/renderer/effects/EffectTargets.js.map +1 -0
- package/dist/renderer/effects/builtins.js +31 -0
- package/dist/renderer/effects/builtins.js.map +1 -0
- package/dist/renderer/effects/composite.js +9 -0
- package/dist/renderer/effects/composite.js.map +1 -0
- package/dist/renderer/effects/effectPrelude.js +10 -0
- package/dist/renderer/effects/effectPrelude.js.map +1 -0
- package/dist/renderer/effects/types.js +10 -0
- package/dist/renderer/effects/types.js.map +1 -0
- package/dist/renderer/index.js +19 -0
- package/dist/renderer/math/color.js +341 -0
- package/dist/renderer/math/color.js.map +1 -0
- package/dist/renderer/math/mat3.js +71 -0
- package/dist/renderer/math/mat3.js.map +1 -0
- package/dist/renderer/math/patternSpace.js +22 -0
- package/dist/renderer/math/patternSpace.js.map +1 -0
- package/dist/renderer/math/viewToMat3.js +19 -0
- package/dist/renderer/math/viewToMat3.js.map +1 -0
- package/dist/renderer/paintResources.js +18 -0
- package/dist/renderer/paintResources.js.map +1 -0
- package/dist/renderer/paintScratch.js +37 -0
- package/dist/renderer/paintScratch.js.map +1 -0
- package/dist/renderer/shaders/ShaderProgram.js +74 -0
- package/dist/renderer/shaders/ShaderProgram.js.map +1 -0
- package/dist/renderer/shaders/batchFill.js +118 -0
- package/dist/renderer/shaders/batchFill.js.map +1 -0
- package/dist/renderer/shaders/customPrelude.js +34 -0
- package/dist/renderer/shaders/customPrelude.js.map +1 -0
- package/dist/renderer/shaders/extractUniformNames.js +184 -0
- package/dist/renderer/shaders/extractUniformNames.js.map +1 -0
- package/dist/renderer/shaders/glyphPaint.js +61 -0
- package/dist/renderer/shaders/glyphPaint.js.map +1 -0
- package/dist/renderer/shaders/gradFill.js +30 -0
- package/dist/renderer/shaders/gradFill.js.map +1 -0
- package/dist/renderer/shaders/imageFill.js +14 -0
- package/dist/renderer/shaders/imageFill.js.map +1 -0
- package/dist/renderer/shaders/pathFill.js +13 -0
- package/dist/renderer/shaders/pathFill.js.map +1 -0
- package/dist/renderer/shaders/patternFill.js +24 -0
- package/dist/renderer/shaders/patternFill.js.map +1 -0
- package/dist/renderer/shaders/registerProgram.js +18 -0
- package/dist/renderer/shaders/registerProgram.js.map +1 -0
- package/dist/renderer/spriteSheet.js +14 -0
- package/dist/renderer/spriteSheet.js.map +1 -0
- package/dist/renderer/state/GroupState.js +77 -0
- package/dist/renderer/state/GroupState.js.map +1 -0
- package/dist/renderer/syntheticItalic.js +6 -0
- package/dist/renderer/syntheticItalic.js.map +1 -0
- package/dist/renderer/textures/registerTexture.js +14 -0
- package/dist/renderer/textures/registerTexture.js.map +1 -0
- package/dist/renderer.d.ts +11 -21
- package/dist/renderer.js +18 -13
- package/dist/resize.d.ts +10 -46
- package/dist/resize.js +7 -5
- package/dist/routing.js +2 -3
- package/dist/scheduling/useVisibleRaf.js +69 -0
- package/dist/scheduling/useVisibleRaf.js.map +1 -0
- package/dist/style.css +2 -0
- package/dist/test-hook/createTestHook.js +39 -0
- package/dist/test-hook/createTestHook.js.map +1 -0
- package/dist/test-hook/install.js +12 -0
- package/dist/test-hook/install.js.map +1 -0
- package/dist/test-seams-fYf6m5pu.d.ts +356 -0
- package/dist/test-seams.d.ts +6 -0
- package/dist/test-seams.js +3 -0
- package/dist/tools/builtin/ellipse/useEllipseTool.js +33 -0
- package/dist/tools/builtin/ellipse/useEllipseTool.js.map +1 -0
- package/dist/tools/builtin/eyedropper/useEyedropperTool.js +55 -0
- package/dist/tools/builtin/eyedropper/useEyedropperTool.js.map +1 -0
- package/dist/tools/builtin/hand/dragPanContribution.js +17 -0
- package/dist/tools/builtin/hand/dragPanContribution.js.map +1 -0
- package/dist/tools/builtin/hand/useHandTool.js +31 -0
- package/dist/tools/builtin/hand/useHandTool.js.map +1 -0
- package/dist/tools/builtin/image/useImageTool.js +41 -0
- package/dist/tools/builtin/image/useImageTool.js.map +1 -0
- package/dist/tools/builtin/lasso/useLassoTool.js +42 -0
- package/dist/tools/builtin/lasso/useLassoTool.js.map +1 -0
- package/dist/tools/builtin/line/useLineTool.js +33 -0
- package/dist/tools/builtin/line/useLineTool.js.map +1 -0
- package/dist/tools/builtin/pen/usePenTool.js +414 -0
- package/dist/tools/builtin/pen/usePenTool.js.map +1 -0
- package/dist/tools/builtin/pencil/usePencilTool.js +36 -0
- package/dist/tools/builtin/pencil/usePencilTool.js.map +1 -0
- package/dist/tools/builtin/pickTopMostHit.js +45 -0
- package/dist/tools/builtin/pickTopMostHit.js.map +1 -0
- package/dist/tools/builtin/polygon/usePolygonTool.js +81 -0
- package/dist/tools/builtin/polygon/usePolygonTool.js.map +1 -0
- package/dist/tools/builtin/rect/useRectTool.js +32 -0
- package/dist/tools/builtin/rect/useRectTool.js.map +1 -0
- package/dist/tools/builtin/select/selectionContributions.js +109 -0
- package/dist/tools/builtin/select/selectionContributions.js.map +1 -0
- package/dist/tools/builtin/select/useSelectTool.js +162 -0
- package/dist/tools/builtin/select/useSelectTool.js.map +1 -0
- package/dist/tools/builtin/shared/insertToolOptions.js +8 -0
- package/dist/tools/builtin/shared/insertToolOptions.js.map +1 -0
- package/dist/tools/builtin/slice/useSliceTool.js +263 -0
- package/dist/tools/builtin/slice/useSliceTool.js.map +1 -0
- package/dist/tools/builtin/star/useStarTool.js +82 -0
- package/dist/tools/builtin/star/useStarTool.js.map +1 -0
- package/dist/tools/builtin/text/useTextTool.js +177 -0
- package/dist/tools/builtin/text/useTextTool.js.map +1 -0
- package/dist/tools/overlayBinding.js +8 -0
- package/dist/tools/overlayBinding.js.map +1 -0
- package/dist/tools/prefs.js +47 -0
- package/dist/tools/prefs.js.map +1 -0
- package/dist/tools/useKeybindings.js +66 -0
- package/dist/tools/useKeybindings.js.map +1 -0
- package/dist/{types-D-9QWBy5.d.ts → types-A37hYkeR.d.ts} +185 -15
- package/dist/{types-qYpyTAiZ.d.ts → types-B_9g6hMM.d.ts} +32 -6
- package/dist/util/color.js +26 -0
- package/dist/util/color.js.map +1 -0
- package/dist/util/constrainTo45.js +17 -0
- package/dist/util/constrainTo45.js.map +1 -0
- package/dist/util/paint.js +72 -0
- package/dist/util/paint.js.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +31 -19
- package/dist/chunk-3TY6FHAF.js +0 -170
- package/dist/chunk-3TY6FHAF.js.map +0 -1
- package/dist/chunk-DGWNNKGD.js +0 -248
- package/dist/chunk-DGWNNKGD.js.map +0 -1
- package/dist/chunk-G4ZGQMY7.js +0 -33372
- package/dist/chunk-G4ZGQMY7.js.map +0 -1
- package/dist/chunk-L5YNZYEG.js +0 -648
- package/dist/chunk-L5YNZYEG.js.map +0 -1
- package/dist/chunk-LU4IJ52W.js +0 -111
- package/dist/chunk-LU4IJ52W.js.map +0 -1
- package/dist/chunk-M24CLARN.js +0 -28
- package/dist/chunk-M24CLARN.js.map +0 -1
- package/dist/chunk-NE27EOLP.js +0 -146
- package/dist/chunk-NE27EOLP.js.map +0 -1
- package/dist/chunk-PNNZSYRD.js +0 -318
- package/dist/chunk-PNNZSYRD.js.map +0 -1
- package/dist/chunk-UPZY4ART.js +0 -29
- package/dist/chunk-UPZY4ART.js.map +0 -1
- package/dist/chunk-WPNA6L5O.js +0 -250
- package/dist/chunk-WPNA6L5O.js.map +0 -1
- package/dist/chunk-XMAWPGTK.js +0 -128
- package/dist/chunk-XMAWPGTK.js.map +0 -1
- package/dist/clipboard.js.map +0 -1
- package/dist/clone.js.map +0 -1
- package/dist/grid-CY5UKlZh.d.ts +0 -98
- package/dist/index.css +0 -62
- package/dist/index.css.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/insert.d.ts +0 -36
- package/dist/insert.js +0 -81
- package/dist/insert.js.map +0 -1
- package/dist/math.js.map +0 -1
- package/dist/move.js.map +0 -1
- package/dist/path-JEV2c5If.d.ts +0 -48
- package/dist/patterns-builtin.js.map +0 -1
- package/dist/renderer.css +0 -62
- package/dist/renderer.css.map +0 -1
- package/dist/renderer.js.map +0 -1
- package/dist/resize.js.map +0 -1
- package/dist/routing.js.map +0 -1
- package/dist/types-D2tTKEU0.d.ts +0 -18
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpolateView.js","names":["axisCurve","linear","x0","x1","t","s0","s1","p","w","ratio","s","interpolateView","fx","from","to","fy","a","b"],"sources":["../../../src/core/viewport/interpolateView.ts"],"sourcesContent":["import type { View } from './view';\n\n/**\n * Per-axis camera curve. Two views that differ in scale agree at exactly one\n * screen point; holding the world point under it fixed is what makes a zoom\n * read as anchored rather than drifting. Scale moves geometrically between\n * positive endpoints, so each frame changes the view by the same ratio and an\n * easing that overshoots past 1 still cannot cross zero.\n *\n * Endpoints that are not both positive get the linear branch: `(s1/s0)^t` is\n * NaN for a negative ratio and `1/s0` is infinite at zero, and there is no\n * geometric path across a sign change to be had anyway.\n */\nfunction axisCurve(x0: number, s0: number, x1: number, s1: number): (t: number) => { x: number; s: number } {\n const linear = (t: number) => ({ x: x0 + (x1 - x0) * t, s: s0 + (s1 - s0) * t });\n if (!(s0 > 0) || !(s1 > 0)) return linear;\n // Equal scales: no fixed point exists on this axis. That is a pure pan.\n if (Math.abs(s1 - s0) <= 1e-12 * Math.max(Math.abs(s0), Math.abs(s1), 1)) return linear;\n const p = (x1 - x0) / (1 / s0 - 1 / s1); // screen px where the two views agree\n const w = p / s0 + x0; // the world point under it\n const ratio = s1 / s0;\n return (t) => {\n const s = s0 * Math.pow(ratio, t);\n return { x: w - p / s, s };\n };\n}\n\n/**\n * `InterpolatorFactory<View>` for camera animation — built once per animation,\n * called with eased `t` each frame. Pass to `Animator.tween`'s `interpolator`.\n */\nexport function interpolateView(from: View, to: View): (t: number) => View {\n const fx = axisCurve(from.x, from.scale.x, to.x, to.scale.x);\n const fy = axisCurve(from.y, from.scale.y, to.y, to.scale.y);\n return (t: number): View => {\n const a = fx(t);\n const b = fy(t);\n return { x: a.x, y: b.x, scale: { x: a.s, y: b.s } };\n };\n}\n"],"mappings":";AAaA,SAASA,EAAU,GAAY,GAAY,GAAY,GAAqD;CAC1G,IAAMC,KAAU,OAAe;EAAE,GAAGC,KAAMC,IAAKD,KAAME;EAAG,GAAGC,KAAMC,IAAKD,KAAMD;CAAE;CAG9E,IAFI,EAAEC,IAAK,MAAM,EAAEC,IAAK,MAEpB,KAAK,IAAIA,IAAKD,CAAE,KAAK,QAAQ,KAAK,IAAI,KAAK,IAAIA,CAAE,GAAG,KAAK,IAAIC,CAAE,GAAG,CAAC,GAAG,OAAOL;CACjF,IAAMM,KAAKJ,IAAKD,MAAO,IAAIG,IAAK,IAAIC,IAC9BE,IAAID,IAAIF,IAAKH,GACbO,IAAQH,IAAKD;CACnB,QAAQ,MAAM;EACZ,IAAMK,IAAIL,IAAcI,MAAOL;EAC/B,OAAO;GAAE,GAAGI,IAAID,IAAIG;GAAG;EAAE;CAC3B;AACF;AAMA,SAAgBC,EAAgB,GAAY,GAA+B;CACzE,IAAMC,IAAKZ,EAAUa,EAAK,GAAGA,EAAK,MAAM,GAAGC,EAAG,GAAGA,EAAG,MAAM,CAAC,GACrDC,IAAKf,EAAUa,EAAK,GAAGA,EAAK,MAAM,GAAGC,EAAG,GAAGA,EAAG,MAAM,CAAC;CAC3D,QAAQ,MAAoB;EAC1B,IAAME,IAAIJ,EAAGR,CAAC,GACRa,IAAIF,EAAGX,CAAC;EACd,OAAO;GAAE,GAAGY,EAAE;GAAG,GAAGC,EAAE;GAAG,OAAO;IAAE,GAAGD,EAAE;IAAG,GAAGC,EAAE;GAAE;EAAE;CACrD;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meanScale.js","names":["meanScale","s"],"sources":["../../../src/core/viewport/meanScale.ts"],"sourcesContent":["/**\n * Geometric mean of a per-axis scale. Degenerates to `s.x` (or `s.y`) when the\n * two axes are equal; otherwise sits between them.\n *\n * **Not for hit-testing.** A screen-pixel length is not one world distance\n * under non-uniform zoom, and collapsing it to a scalar makes a pickable\n * region too generous on one axis and too mean on the other. Use `pxExtent`\n * for a per-axis world length, or `withinPxBox` / `withinPxRadius` to compare\n * in screen space directly. Chrome hit-tests moved off this in 2026-08.\n *\n * Nor for placing chrome or measuring a pick slop: `standoff` and\n * `strokeHitTest`'s `slop` work on screen, which stays exact under a rotated\n * target where no per-axis world answer exists.\n *\n * What legitimately remains is a stroke width for a line that is not\n * axis-aligned. A ribbon takes one world width, and the renderer resolves a\n * `{ px }` width through this same mean, so a picker reading ink widths must\n * too. An axis-aligned line has an exact answer — `pxExtent` on its cross\n * axis, as the grid layer does.\n */\nexport function meanScale(s: { x: number; y: number }): number {\n return Math.sqrt(s.x * s.y);\n}\n"],"mappings":";AAoBA,SAAgBA,EAAU,GAAqC;CAC7D,OAAO,KAAK,KAAKC,EAAE,IAAIA,EAAE,CAAC;AAC5B"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
//#region src/core/viewport/parallax.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
return typeof e == "number" ? {
|
|
4
|
+
x: e,
|
|
5
|
+
y: e
|
|
6
|
+
} : e;
|
|
7
|
+
}
|
|
8
|
+
function t(t, n) {
|
|
9
|
+
let r = e(n.pan), i = e(n.zoom ?? 1), a = n.anchor ?? {
|
|
10
|
+
x: 0,
|
|
11
|
+
y: 0
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
x: a.x + (t.x - a.x) * r.x,
|
|
15
|
+
y: a.y + (t.y - a.y) * r.y,
|
|
16
|
+
scale: {
|
|
17
|
+
x: 1 + (t.scale.x - 1) * i.x,
|
|
18
|
+
y: 1 + (t.scale.y - 1) * i.y
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function n(e, n) {
|
|
23
|
+
let r = t(e, n), i = e.scale.x / r.scale.x, a = e.scale.y / r.scale.y;
|
|
24
|
+
return {
|
|
25
|
+
scale: {
|
|
26
|
+
x: i,
|
|
27
|
+
y: a
|
|
28
|
+
},
|
|
29
|
+
offset: {
|
|
30
|
+
x: r.x - i * e.x,
|
|
31
|
+
y: r.y - a * e.y
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function r(e, t) {
|
|
36
|
+
return {
|
|
37
|
+
x: t.x * e.scale.x + e.offset.x,
|
|
38
|
+
y: t.y * e.scale.y + e.offset.y
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function i(e, t) {
|
|
42
|
+
return {
|
|
43
|
+
x: (t.x - e.offset.x) / e.scale.x,
|
|
44
|
+
y: (t.y - e.offset.y) / e.scale.y
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function a(e, t) {
|
|
48
|
+
let n = t({
|
|
49
|
+
x: e.x,
|
|
50
|
+
y: e.y
|
|
51
|
+
}), r = t({
|
|
52
|
+
x: e.x + e.width,
|
|
53
|
+
y: e.y + e.height
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
x: Math.min(n.x, r.x),
|
|
57
|
+
y: Math.min(n.y, r.y),
|
|
58
|
+
width: Math.abs(r.x - n.x),
|
|
59
|
+
height: Math.abs(r.y - n.y)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function o(e, t) {
|
|
63
|
+
return {
|
|
64
|
+
...t,
|
|
65
|
+
...a(t, (t) => r(e, t))
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function s(e, t) {
|
|
69
|
+
return {
|
|
70
|
+
...t,
|
|
71
|
+
...a(t, (t) => i(e, t))
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function c(e, t) {
|
|
75
|
+
if (e === t) return null;
|
|
76
|
+
let n = e ?? l, r = t ?? l, i = r.scale.x / n.scale.x, a = r.scale.y / n.scale.y, o = {
|
|
77
|
+
scale: {
|
|
78
|
+
x: i,
|
|
79
|
+
y: a
|
|
80
|
+
},
|
|
81
|
+
offset: {
|
|
82
|
+
x: r.offset.x - n.offset.x * i,
|
|
83
|
+
y: r.offset.y - n.offset.y * a
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
return o.scale.x === 1 && o.scale.y === 1 && o.offset.x === 0 && o.offset.y === 0 ? null : o;
|
|
87
|
+
}
|
|
88
|
+
var l = {
|
|
89
|
+
scale: {
|
|
90
|
+
x: 1,
|
|
91
|
+
y: 1
|
|
92
|
+
},
|
|
93
|
+
offset: {
|
|
94
|
+
x: 0,
|
|
95
|
+
y: 0
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
function u(e) {
|
|
99
|
+
return [
|
|
100
|
+
e.scale.x,
|
|
101
|
+
0,
|
|
102
|
+
0,
|
|
103
|
+
e.scale.y,
|
|
104
|
+
e.offset.x,
|
|
105
|
+
e.offset.y
|
|
106
|
+
];
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
export { t as deriveParallaxView, i as fromPlane, n as planeMap, u as planeMatrix, c as planeToPlane, s as rectFromPlane, o as rectToPlane, r as toPlane };
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=parallax.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallax.js","names":["asXY","v","deriveParallaxView","p","opts","z","outer","planeMap","inner","kx","ky","toPlane","m","fromPlane","mapRect","a","map","r","b","rectToPlane","rectFromPlane","planeToPlane","from","to","f","IDENTITY_MAP","t","sx","sy","planeMatrix"],"sources":["../../../src/core/viewport/parallax.ts"],"sourcesContent":["import type { View } from './view';\n\n/** One value for both axes, or a separate value per axis. */\nexport type ScalarOrXY = number | { x: number; y: number };\n\n/** How a parallax plane tracks the camera: `pan` is the fraction of the\n * camera's translation it follows (1 = locked to the scene, 0 = fixed to the\n * screen), `zoom` the same for scale, and `anchor` the camera position\n * (`view.x` / `view.y`) the translation is measured from — every plane lines\n * up when the camera sits there. */\nexport interface ParallaxOpts {\n pan: ScalarOrXY;\n zoom?: ScalarOrXY;\n anchor?: { x: number; y: number };\n}\n\nfunction asXY(v: ScalarOrXY): { x: number; y: number } {\n return typeof v === 'number' ? { x: v, y: v } : v;\n}\n\n/**\n * Pure derivation of a parallax plane's inner `View` from the camera view\n * plus per-plane factors.\n *\n * `pan` controls how much the plane translates with the camera (1 = normal,\n * 0 = locked to `anchor`, >1 = leads). `zoom` controls how much it scales\n * with camera zoom (1 = normal, 0 = fixed at identity scale). `anchor`\n * (default origin) is the camera position at which all planes agree.\n *\n * Identity holds: `pan=1, zoom=1` returns a view equal to `outer`.\n */\nexport function deriveParallaxView(outer: View, opts: ParallaxOpts): View {\n const p = asXY(opts.pan);\n const z = asXY(opts.zoom ?? 1);\n const a = opts.anchor ?? { x: 0, y: 0 };\n return {\n x: a.x + (outer.x - a.x) * p.x,\n y: a.y + (outer.y - a.y) * p.y,\n scale: {\n x: 1 + (outer.scale.x - 1) * z.x,\n y: 1 + (outer.scale.y - 1) * z.y,\n },\n };\n}\n\n/** How a point of the camera's world lands in a plane's world, per axis:\n * `plane = world * scale + offset`. A plane draws its content through its\n * own view; this is what lets a pointer, a marquee or a selection box cross\n * between that view and the camera's. */\nexport interface PlaneMap {\n scale: { x: number; y: number };\n offset: { x: number; y: number };\n}\n\n/** The map from `outer`'s world into the world of a plane drawn through\n * `deriveParallaxView(outer, opts)` — the one that puts both points under the\n * same pixel. */\nexport function planeMap(outer: View, opts: ParallaxOpts): PlaneMap {\n const inner = deriveParallaxView(outer, opts);\n const kx = outer.scale.x / inner.scale.x;\n const ky = outer.scale.y / inner.scale.y;\n return {\n scale: { x: kx, y: ky },\n offset: { x: inner.x - kx * outer.x, y: inner.y - ky * outer.y },\n };\n}\n\n/** Map a point from the outer view's world into the plane's world. */\nexport function toPlane(m: PlaneMap, p: { x: number; y: number }): { x: number; y: number } {\n return { x: p.x * m.scale.x + m.offset.x, y: p.y * m.scale.y + m.offset.y };\n}\n\n/** Map a point from the plane's world back into the outer view's world. */\nexport function fromPlane(m: PlaneMap, p: { x: number; y: number }): { x: number; y: number } {\n return { x: (p.x - m.offset.x) / m.scale.x, y: (p.y - m.offset.y) / m.scale.y };\n}\n\ninterface Rect { x: number; y: number; width: number; height: number }\n\nfunction mapRect(r: Rect, map: (p: { x: number; y: number }) => { x: number; y: number }): Rect {\n const a = map({ x: r.x, y: r.y });\n const b = map({ x: r.x + r.width, y: r.y + r.height });\n return {\n x: Math.min(a.x, b.x),\n y: Math.min(a.y, b.y),\n width: Math.abs(b.x - a.x),\n height: Math.abs(b.y - a.y),\n };\n}\n\n/** A camera-world rect in the plane's world. The map is axis-aligned, so a\n * rect stays a rect; a flipped axis is normalized back to a positive size. */\nexport function rectToPlane<R extends Rect>(m: PlaneMap, r: R): R {\n return { ...r, ...mapRect(r, (p) => toPlane(m, p)) };\n}\n\n/** A plane-world rect in the camera's world — see {@link rectToPlane}. */\nexport function rectFromPlane<R extends Rect>(m: PlaneMap, r: R): R {\n return { ...r, ...mapRect(r, (p) => fromPlane(m, p)) };\n}\n\n/** The map from one world into another, where `null` is the camera's own:\n * `fromPlane(from)`, then `toPlane(to)`. Null when the two are the same\n * world, so a caller can skip the work. */\nexport function planeToPlane(from: PlaneMap | null, to: PlaneMap | null): PlaneMap | null {\n if (from === to) return null;\n const f = from ?? IDENTITY_MAP;\n const t = to ?? IDENTITY_MAP;\n const sx = t.scale.x / f.scale.x;\n const sy = t.scale.y / f.scale.y;\n const m = {\n scale: { x: sx, y: sy },\n offset: { x: t.offset.x - f.offset.x * sx, y: t.offset.y - f.offset.y * sy },\n };\n return m.scale.x === 1 && m.scale.y === 1 && m.offset.x === 0 && m.offset.y === 0 ? null : m;\n}\n\nconst IDENTITY_MAP: PlaneMap = { scale: { x: 1, y: 1 }, offset: { x: 0, y: 0 } };\n\n/** The map as an affine matrix in `@weasel-js/geom`'s `[a, b, c, d, e, f]`\n * order, for `transformPath` and friends. */\nexport function planeMatrix(m: PlaneMap): [number, number, number, number, number, number] {\n return [m.scale.x, 0, 0, m.scale.y, m.offset.x, m.offset.y];\n}\n"],"mappings":";AAgBA,SAASA,EAAK,GAAyC;CACrD,OAAO,OAAOC,KAAM,WAAW;EAAE,GAAGA;EAAG,GAAGA;CAAE,IAAIA;AAClD;AAaA,SAAgBC,EAAmB,GAAa,GAA0B;CACxE,IAAMC,IAAIH,EAAKI,EAAK,GAAG,GACjBC,IAAIL,EAAKI,EAAK,QAAQ,CAAC,GACvB,IAAIA,EAAK,UAAU;EAAE,GAAG;EAAG,GAAG;CAAE;CACtC,OAAO;EACL,GAAG,EAAE,KAAKE,EAAM,IAAI,EAAE,KAAKH,EAAE;EAC7B,GAAG,EAAE,KAAKG,EAAM,IAAI,EAAE,KAAKH,EAAE;EAC7B,OAAO;GACL,GAAG,KAAKG,EAAM,MAAM,IAAI,KAAKD,EAAE;GAC/B,GAAG,KAAKC,EAAM,MAAM,IAAI,KAAKD,EAAE;EACjC;CACF;AACF;AAcA,SAAgBE,EAAS,GAAa,GAA8B;CAClE,IAAMC,IAAQN,EAAmBI,GAAOF,CAAI,GACtCK,IAAKH,EAAM,MAAM,IAAIE,EAAM,MAAM,GACjCE,IAAKJ,EAAM,MAAM,IAAIE,EAAM,MAAM;CACvC,OAAO;EACL,OAAO;GAAE,GAAGC;GAAI,GAAGC;EAAG;EACtB,QAAQ;GAAE,GAAGF,EAAM,IAAIC,IAAKH,EAAM;GAAG,GAAGE,EAAM,IAAIE,IAAKJ,EAAM;EAAE;CACjE;AACF;AAGA,SAAgBK,EAAQ,GAAa,GAAuD;CAC1F,OAAO;EAAE,GAAGR,EAAE,IAAIS,EAAE,MAAM,IAAIA,EAAE,OAAO;EAAG,GAAGT,EAAE,IAAIS,EAAE,MAAM,IAAIA,EAAE,OAAO;CAAE;AAC5E;AAGA,SAAgBC,EAAU,GAAa,GAAuD;CAC5F,OAAO;EAAE,IAAIV,EAAE,IAAIS,EAAE,OAAO,KAAKA,EAAE,MAAM;EAAG,IAAIT,EAAE,IAAIS,EAAE,OAAO,KAAKA,EAAE,MAAM;CAAE;AAChF;AAIA,SAASE,EAAQ,GAAS,GAAsE;CAC9F,IAAMC,IAAIC,EAAI;EAAE,GAAGC,EAAE;EAAG,GAAGA,EAAE;CAAE,CAAC,GAC1BC,IAAIF,EAAI;EAAE,GAAGC,EAAE,IAAIA,EAAE;EAAO,GAAGA,EAAE,IAAIA,EAAE;CAAO,CAAC;CACrD,OAAO;EACL,GAAG,KAAK,IAAIF,EAAE,GAAGG,EAAE,CAAC;EACpB,GAAG,KAAK,IAAIH,EAAE,GAAGG,EAAE,CAAC;EACpB,OAAO,KAAK,IAAIA,EAAE,IAAIH,EAAE,CAAC;EACzB,QAAQ,KAAK,IAAIG,EAAE,IAAIH,EAAE,CAAC;CAC5B;AACF;AAIA,SAAgBI,EAA4B,GAAa,GAAS;CAChE,OAAO;EAAE,GAAGF;EAAG,GAAGH,EAAQG,IAAI,MAAMN,EAAQC,GAAGT,CAAC,CAAC;CAAE;AACrD;AAGA,SAAgBiB,EAA8B,GAAa,GAAS;CAClE,OAAO;EAAE,GAAGH;EAAG,GAAGH,EAAQG,IAAI,MAAMJ,EAAUD,GAAGT,CAAC,CAAC;CAAE;AACvD;AAKA,SAAgBkB,EAAa,GAAuB,GAAsC;CACxF,IAAIC,MAASC,GAAI,OAAO;CACxB,IAAMC,IAAIF,KAAQG,GACZC,IAAIH,KAAME,GACVE,IAAKD,EAAE,MAAM,IAAIF,EAAE,MAAM,GACzBI,IAAKF,EAAE,MAAM,IAAIF,EAAE,MAAM,GACzBZ,IAAI;EACR,OAAO;GAAE,GAAGe;GAAI,GAAGC;EAAG;EACtB,QAAQ;GAAE,GAAGF,EAAE,OAAO,IAAIF,EAAE,OAAO,IAAIG;GAAI,GAAGD,EAAE,OAAO,IAAIF,EAAE,OAAO,IAAII;EAAG;CAC7E;CACA,OAAOhB,EAAE,MAAM,MAAM,KAAKA,EAAE,MAAM,MAAM,KAAKA,EAAE,OAAO,MAAM,KAAKA,EAAE,OAAO,MAAM,IAAI,OAAOA;AAC7F;AAEA,IAAMa,IAAyB;CAAE,OAAO;EAAE,GAAG;EAAG,GAAG;CAAE;CAAG,QAAQ;EAAE,GAAG;EAAG,GAAG;CAAE;AAAE;AAI/E,SAAgBI,EAAY,GAA+D;CACzF,OAAO;EAACjB,EAAE,MAAM;EAAG;EAAG;EAAGA,EAAE,MAAM;EAAGA,EAAE,OAAO;EAAGA,EAAE,OAAO;CAAC;AAC5D"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/core/viewport/pxExtent.ts
|
|
2
|
+
function e(e, t, n = 0) {
|
|
3
|
+
if (!n) return {
|
|
4
|
+
x: e / Math.abs(t.x),
|
|
5
|
+
y: e / Math.abs(t.y)
|
|
6
|
+
};
|
|
7
|
+
let r = Math.cos(n), i = Math.sin(n);
|
|
8
|
+
return {
|
|
9
|
+
x: e * Math.hypot(r / t.x, i / t.y),
|
|
10
|
+
y: e * Math.hypot(i / t.x, r / t.y)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function t(e, t, n) {
|
|
14
|
+
return {
|
|
15
|
+
x: e * n.x,
|
|
16
|
+
y: t * n.y
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function n(e, n, r, i) {
|
|
20
|
+
let a = t(e, n, i);
|
|
21
|
+
return Math.abs(a.x) <= r && Math.abs(a.y) <= r;
|
|
22
|
+
}
|
|
23
|
+
function r(e, n, r, i) {
|
|
24
|
+
let a = t(e, n, i);
|
|
25
|
+
return a.x * a.x + a.y * a.y <= r * r;
|
|
26
|
+
}
|
|
27
|
+
function i(e, t, n, r) {
|
|
28
|
+
let i = Math.sign(r.x * r.y) || 1, a = t.x * r.y * i, o = t.y * r.x * i, s = Math.hypot(a, o) || 1;
|
|
29
|
+
return a /= s, o /= s, {
|
|
30
|
+
x: e.x + a * n / r.x,
|
|
31
|
+
y: e.y + o * n / r.y,
|
|
32
|
+
nx: a,
|
|
33
|
+
ny: o
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function a(e, t) {
|
|
37
|
+
return Math.atan2(Math.sin(e) * t.y, Math.cos(e) * t.x);
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { e as pxExtent, t as scaleDelta, a as screenAngleOf, i as standoff, n as withinPxBox, r as withinPxRadius };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=pxExtent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pxExtent.js","names":["pxExtent","rotation","px","scale","c","s","scaleDelta","dx","dy","withinPxBox","withinPxRadius","standoff","k","nx","normal","ny","l","anchor","screenAngleOf"],"sources":["../../../src/core/viewport/pxExtent.ts"],"sourcesContent":["/**\n * Screen-pixel lengths in world units, per axis.\n *\n * Chrome declares its hit zones in screen pixels — an 8px handle stays 8px at\n * every zoom, because it paints in screen space. Converting one such length to\n * world units with a single scalar (see `meanScale`) is exact only under\n * uniform zoom; per-axis it is too generous on one axis and too mean on the\n * other, so the pickable region stops matching the painted one.\n *\n * Prefer {@link withinPxBox} / {@link withinPxRadius}, which compare in screen\n * space and so can't drift from the paint at all. {@link pxExtent} is for the\n * cases that must stay in world units — a tolerance handed to geometry that\n * doesn't know about the view.\n */\n\nexport interface Scale2 {\n x: number;\n y: number;\n}\n\n/** One screen-pixel length as world-space extents, per axis. `scale` is a\n * view's, so neither axis is zero (see `View`).\n *\n * With `rotation`, the axes are a frame turned that far from world, and each\n * extent is how far along it an edge across it must move to move `px` on\n * screen — which, under non-uniform zoom, is not the extent along the screen\n * axis nearest to it. */\nexport function pxExtent(px: number, scale: Scale2, rotation = 0): { x: number; y: number } {\n if (!rotation) {\n return {\n x: px / Math.abs(scale.x),\n y: px / Math.abs(scale.y),\n };\n }\n const c = Math.cos(rotation), s = Math.sin(rotation);\n return {\n x: px * Math.hypot(c / scale.x, s / scale.y),\n y: px * Math.hypot(s / scale.x, c / scale.y),\n };\n}\n\n/** World delta → screen delta. Only the scale participates: translation\n * cancels in a difference, and the kit's views carry no skew. */\nexport function scaleDelta(dx: number, dy: number, scale: Scale2): { x: number; y: number } {\n return { x: dx * scale.x, y: dy * scale.y };\n}\n\n/**\n * Is a world-space delta inside a screen-space square of half-extent `px`?\n *\n * The square is axis-aligned **on screen**, which is what a handle painted in\n * screen space actually is — so this stays true under non-uniform zoom and\n * under a rotated target, where an axis-aligned world-space test is a rotated\n * rectangle on screen.\n */\nexport function withinPxBox(dx: number, dy: number, px: number, scale: Scale2): boolean {\n const s = scaleDelta(dx, dy, scale);\n return Math.abs(s.x) <= px && Math.abs(s.y) <= px;\n}\n\n/** Is a world-space delta inside a screen-space circle of radius `px`? */\nexport function withinPxRadius(dx: number, dy: number, px: number, scale: Scale2): boolean {\n const s = scaleDelta(dx, dy, scale);\n return s.x * s.x + s.y * s.y <= px * px;\n}\n\n/**\n * A world point pushed `px` screen pixels off an edge, along the edge's normal\n * as it lands on screen. `normal` is the edge's outward normal in world space.\n *\n * Scaling the world normal by the view is not the same thing: under\n * non-uniform zoom the image of a normal is no longer perpendicular to the\n * image of its edge, so chrome placed that way drifts sideways and sits closer\n * than `px`. Returns the point in world coords and the on-screen unit normal.\n */\nexport function standoff(\n anchor: { x: number; y: number },\n normal: { x: number; y: number },\n px: number,\n scale: Scale2,\n): { x: number; y: number; nx: number; ny: number } {\n // The edge's screen normal is S⁻ᵀn, here scaled by det S to stay finite.\n const k = Math.sign(scale.x * scale.y) || 1;\n let nx = normal.x * scale.y * k;\n let ny = normal.y * scale.x * k;\n const l = Math.hypot(nx, ny) || 1;\n nx /= l;\n ny /= l;\n return { x: anchor.x + (nx * px) / scale.x, y: anchor.y + (ny * px) / scale.y, nx, ny };\n}\n\n/** The screen angle a frame turned `rotation` from world lands its x axis at.\n * Equals `rotation` under uniform zoom; non-uniform zoom bends it. */\nexport function screenAngleOf(rotation: number, scale: Scale2): number {\n return Math.atan2(Math.sin(rotation) * scale.y, Math.cos(rotation) * scale.x);\n}\n"],"mappings":";AA2BA,SAAgBA,EAAS,GAAY,GAAe,IAAW,GAA6B;CAC1F,IAAI,CAACC,GACH,OAAO;EACL,GAAGC,IAAK,KAAK,IAAIC,EAAM,CAAC;EACxB,GAAGD,IAAK,KAAK,IAAIC,EAAM,CAAC;CAC1B;CAEF,IAAMC,IAAI,KAAK,IAAIH,CAAQ,GAAGI,IAAI,KAAK,IAAIJ,CAAQ;CACnD,OAAO;EACL,GAAGC,IAAK,KAAK,MAAME,IAAID,EAAM,GAAGE,IAAIF,EAAM,CAAC;EAC3C,GAAGD,IAAK,KAAK,MAAMG,IAAIF,EAAM,GAAGC,IAAID,EAAM,CAAC;CAC7C;AACF;AAIA,SAAgBG,EAAW,GAAY,GAAY,GAAyC;CAC1F,OAAO;EAAE,GAAGC,IAAKJ,EAAM;EAAG,GAAGK,IAAKL,EAAM;CAAE;AAC5C;AAUA,SAAgBM,EAAY,GAAY,GAAY,GAAY,GAAwB;CACtF,IAAMJ,IAAIC,EAAWC,GAAIC,GAAIL,CAAK;CAClC,OAAO,KAAK,IAAIE,EAAE,CAAC,KAAKH,KAAM,KAAK,IAAIG,EAAE,CAAC,KAAKH;AACjD;AAGA,SAAgBQ,EAAe,GAAY,GAAY,GAAY,GAAwB;CACzF,IAAML,IAAIC,EAAWC,GAAIC,GAAIL,CAAK;CAClC,OAAOE,EAAE,IAAIA,EAAE,IAAIA,EAAE,IAAIA,EAAE,KAAKH,IAAKA;AACvC;AAWA,SAAgBS,EACd,GACA,GACA,GACA,GACkD;CAElD,IAAMC,IAAI,KAAK,KAAKT,EAAM,IAAIA,EAAM,CAAC,KAAK,GACtCU,IAAKC,EAAO,IAAIX,EAAM,IAAIS,GAC1BG,IAAKD,EAAO,IAAIX,EAAM,IAAIS,GACxBI,IAAI,KAAK,MAAMH,GAAIE,CAAE,KAAK;CAGhC,OAFA,KAAMC,GACN,KAAMA,GACC;EAAE,GAAGC,EAAO,IAAKJ,IAAKX,IAAMC,EAAM;EAAG,GAAGc,EAAO,IAAKF,IAAKb,IAAMC,EAAM;EAAG;EAAI;CAAG;AACxF;AAIA,SAAgBe,EAAc,GAAkB,GAAuB;CACrE,OAAO,KAAK,MAAM,KAAK,IAAIjB,CAAQ,IAAIE,EAAM,GAAG,KAAK,IAAIF,CAAQ,IAAIE,EAAM,CAAC;AAC9E"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { viewToTransform as e } from "./view.js";
|
|
2
|
+
import { worldToScreen as t } from "./viewTransform.js";
|
|
3
|
+
//#region src/core/viewport/sceneNodeClientRect.ts
|
|
4
|
+
function n(n) {
|
|
5
|
+
let r = n.getWorldBounds(n.id);
|
|
6
|
+
if (r === null) return null;
|
|
7
|
+
let i = e(n.view), [a, o] = t(r.x, r.y, i), s = n.canvas.getBoundingClientRect();
|
|
8
|
+
return {
|
|
9
|
+
x: s.left + a,
|
|
10
|
+
y: s.top + o,
|
|
11
|
+
width: r.width * n.view.scale.x,
|
|
12
|
+
height: r.height * n.view.scale.y
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { n as sceneNodeClientRect };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=sceneNodeClientRect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sceneNodeClientRect.js","names":["sceneNodeClientRect","bounds","opts","t","viewToTransform","sx","sy","worldToScreen","canvasRect"],"sources":["../../../src/core/viewport/sceneNodeClientRect.ts"],"sourcesContent":["import type { Bounds } from './fitViewToBounds';\nimport type { View } from './view';\nimport { viewToTransform } from './view';\nimport { worldToScreen } from './viewTransform';\n\n/** Options for {@link sceneNodeClientRect}. */\nexport interface SceneNodeClientRectOpts {\n /** Node (or container) id to locate. */\n id: string;\n /**\n * Resolve an id to its world-space AABB, or null when unknown.\n * Typically adapts a pose resolver (e.g. from `composeSelectionPose`):\n * `(id) => { const p = resolvePose(id); return p ? boundsOfPath(p) : null; }`\n * — for rect poses the pose is its own AABB and can be returned directly.\n */\n getWorldBounds: (id: string) => Bounds | null;\n /** Current viewport. */\n view: View;\n /** The canvas element — supplies the client-coordinate origin. */\n canvas: Element;\n}\n\n/** Client-coordinate rect (viewport space) — the shape `Callout`'s `anchorRect` expects. */\nexport interface NodeClientRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/**\n * Project a scene node's world AABB to client (viewport) coordinates,\n * e.g. to anchor a `Callout` at a canvas-drawn object. Snapshot\n * semantics: the rect is where the node is *now* — it does not track\n * subsequent pan/zoom or scene mutations.\n */\nexport function sceneNodeClientRect(opts: SceneNodeClientRectOpts): NodeClientRect | null {\n const bounds = opts.getWorldBounds(opts.id);\n if (bounds === null) return null;\n const t = viewToTransform(opts.view);\n const [sx, sy] = worldToScreen(bounds.x, bounds.y, t);\n const canvasRect = opts.canvas.getBoundingClientRect();\n return {\n x: canvasRect.left + sx,\n y: canvasRect.top + sy,\n width: bounds.width * opts.view.scale.x,\n height: bounds.height * opts.view.scale.y,\n };\n}\n"],"mappings":";;;AAoCA,SAAgBA,EAAoB,GAAsD;CACxF,IAAMC,IAASC,EAAK,eAAeA,EAAK,EAAE;CAC1C,IAAID,MAAW,MAAM,OAAO;CAC5B,IAAME,IAAIC,EAAgBF,EAAK,IAAI,GAC7B,CAACG,GAAIC,KAAMC,EAAcN,EAAO,GAAGA,EAAO,GAAGE,CAAC,GAC9CK,IAAaN,EAAK,OAAO,sBAAsB;CACrD,OAAO;EACL,GAAGM,EAAW,OAAOH;EACrB,GAAGG,EAAW,MAAMF;EACpB,OAAOL,EAAO,QAAQC,EAAK,KAAK,MAAM;EACtC,QAAQD,EAAO,SAASC,EAAK,KAAK,MAAM;CAC1C;AACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { multiply as e, rotate as t, scale as n } from "@weasel-js/geom";
|
|
2
|
+
//#region src/core/viewport/screenSlop.ts
|
|
3
|
+
function r(r, i = 0) {
|
|
4
|
+
if (r === void 0) return {
|
|
5
|
+
extra: 0,
|
|
6
|
+
opts: {}
|
|
7
|
+
};
|
|
8
|
+
if (typeof r == "number") return {
|
|
9
|
+
extra: r,
|
|
10
|
+
opts: {}
|
|
11
|
+
};
|
|
12
|
+
let a = n(r.scale.x, r.scale.y);
|
|
13
|
+
return {
|
|
14
|
+
extra: 0,
|
|
15
|
+
opts: { slop: {
|
|
16
|
+
px: r.px,
|
|
17
|
+
transform: i ? e(a, t(i)) : a
|
|
18
|
+
} }
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function i(e) {
|
|
22
|
+
return e === void 0 ? !1 : typeof e == "number" ? e > 0 : e.px > 0;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { i as hasSlop, r as slopForStrokeHit };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=screenSlop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenSlop.js","names":["scaleMat","slopForStrokeHit","slop","s","scale","rotation","multiply","rotate","hasSlop"],"sources":["../../../src/core/viewport/screenSlop.ts"],"sourcesContent":["/**\n * Pointer forgiveness measured on screen.\n *\n * A pick slop is a screen distance: \"within 4px of the outline\". Converting it\n * to a world distance — per axis or as one scalar — is exact only when the\n * frame the geometry lives in reaches the screen by a similarity. A rotated\n * node under non-uniform zoom does not: a screen circle pulled back into its\n * frame is a tilted ellipse, so the test is run against the geometry's screen\n * image instead (`strokeHitTest`'s `slop`).\n */\nimport { multiply, rotate, scale as scaleMat, type Mat3 } from '@weasel-js/geom';\nimport type { Scale2 } from './pxExtent';\n\n/** `px` screen pixels under a view whose per-axis scale is `scale`. */\nexport interface ScreenSlop {\n px: number;\n scale: Scale2;\n}\n\n/** A slop in world units (a number, the view-less form) or on screen. */\nexport type PickSlop = number | ScreenSlop;\n\n/**\n * How `strokeHitTest` should apply a slop to geometry in a frame turned by\n * `rotation` from world: a world slop adds to the threshold, a screen slop is\n * handed over with the frame's map to the screen.\n */\nexport function slopForStrokeHit(\n slop: PickSlop | undefined,\n rotation = 0,\n): { extra: number; opts: { slop?: { px: number; transform: Mat3 } } } {\n if (slop === undefined) return { extra: 0, opts: {} };\n if (typeof slop === 'number') return { extra: slop, opts: {} };\n const s = scaleMat(slop.scale.x, slop.scale.y);\n return {\n extra: 0,\n opts: { slop: { px: slop.px, transform: rotation ? multiply(s, rotate(rotation)) : s } },\n };\n}\n\n/** Is any slop set at all? A zero reach plus a zero slop hits nothing. */\nexport function hasSlop(slop: PickSlop | undefined): boolean {\n if (slop === undefined) return false;\n return typeof slop === 'number' ? slop > 0 : slop.px > 0;\n}\n"],"mappings":";;AA2BA,SAAgBC,EACd,GACA,IAAW,GAC0D;CACrE,IAAIC,MAAS,KAAA,GAAW,OAAO;EAAE,OAAO;EAAG,MAAM,CAAC;CAAE;CACpD,IAAI,OAAOA,KAAS,UAAU,OAAO;EAAE,OAAOA;EAAM,MAAM,CAAC;CAAE;CAC7D,IAAMC,IAAIH,EAASE,EAAK,MAAM,GAAGA,EAAK,MAAM,CAAC;CAC7C,OAAO;EACL,OAAO;EACP,MAAM,EAAE,MAAM;GAAE,IAAIA,EAAK;GAAI,WAAWG,IAAWC,EAASH,GAAGI,EAAOF,CAAQ,CAAC,IAAIF;EAAE,EAAE;CACzF;AACF;AAGA,SAAgBK,EAAQ,GAAqC;CAE3D,OADIN,MAAS,KAAA,IAAkB,KACxB,OAAOA,KAAS,WAAWA,IAAO,IAAIA,EAAK,KAAK;AACzD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { fitZoom as e } from "./fitToBounds.js";
|
|
2
|
+
import { useEffect as t, useRef as n } from "react";
|
|
3
|
+
//#region src/core/viewport/useAutoCenter.ts
|
|
4
|
+
function r(t, n, r, i, a = .85) {
|
|
5
|
+
let o = e(t * a, n * a, r, i), s = r * o, c = i * o;
|
|
6
|
+
return {
|
|
7
|
+
zoom: o,
|
|
8
|
+
panX: (t - s) / 2,
|
|
9
|
+
panY: (n - c) / 2
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function i(e, i, a, o, s, c) {
|
|
13
|
+
let l = n(!1);
|
|
14
|
+
t(() => {
|
|
15
|
+
if (e > 0 && i > 0 && !l.current) {
|
|
16
|
+
l.current = !0;
|
|
17
|
+
let t = r(e, i, a, o);
|
|
18
|
+
s(t.zoom), c(t.panX, t.panY);
|
|
19
|
+
}
|
|
20
|
+
}, [
|
|
21
|
+
e,
|
|
22
|
+
i,
|
|
23
|
+
a,
|
|
24
|
+
o,
|
|
25
|
+
s,
|
|
26
|
+
c
|
|
27
|
+
]);
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { r as computeFitViewport, i as useAutoCenter };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=useAutoCenter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAutoCenter.js","names":["computeFitViewport","zoom","fitZoom","viewportW","padRatio","viewportH","contentW","contentH","cw","ch","useAutoCenter","hasCentered","useRef","width","height","fit","setZoom","setPan"],"sources":["../../../src/core/viewport/useAutoCenter.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { fitZoom } from './fitToBounds';\n\n/**\n * Compute zoom and pan that fit `contentW x contentH` (in content units)\n * inside `viewportW x viewportH` (in pixels). `padRatio` is the fraction of\n * each axis to fill (default 0.85 — leaves a uniform 15% margin).\n */\nexport function computeFitViewport(\n viewportW: number,\n viewportH: number,\n contentW: number,\n contentH: number,\n padRatio = 0.85,\n): { zoom: number; panX: number; panY: number } {\n const zoom = fitZoom(viewportW * padRatio, viewportH * padRatio, contentW, contentH);\n const cw = contentW * zoom;\n const ch = contentH * zoom;\n return { zoom, panX: (viewportW - cw) / 2, panY: (viewportH - ch) / 2 };\n}\n\n/**\n * Run `computeFitViewport` once when the viewport first has non-zero size, and\n * apply the result via the supplied setters. Subsequent size changes are\n * ignored — this hook centers exactly once.\n */\nexport function useAutoCenter(\n width: number,\n height: number,\n contentW: number,\n contentH: number,\n setZoom: (z: number) => void,\n setPan: (x: number, y: number) => void,\n) {\n const hasCentered = useRef(false);\n\n useEffect(() => {\n if (width > 0 && height > 0 && !hasCentered.current) {\n hasCentered.current = true;\n const fit = computeFitViewport(width, height, contentW, contentH);\n setZoom(fit.zoom);\n setPan(fit.panX, fit.panY);\n }\n }, [width, height, contentW, contentH, setZoom, setPan]);\n}\n"],"mappings":";;;AAQA,SAAgBA,EACd,GACA,GACA,GACA,GACA,IAAW,KACmC;CAC9C,IAAMC,IAAOC,EAAQC,IAAYC,GAAUC,IAAYD,GAAUE,GAAUC,CAAQ,GAC7EC,IAAKF,IAAWL,GAChBQ,IAAKF,IAAWN;CACtB,OAAO;EAAE;EAAM,OAAOE,IAAYK,KAAM;EAAG,OAAOH,IAAYI,KAAM;CAAE;AACxE;AAOA,SAAgBC,EACd,GACA,GACA,GACA,GACA,GACA,GACA;CACA,IAAMC,IAAcC,EAAO,EAAK;CAEhC,QAAgB;EACd,IAAIC,IAAQ,KAAKC,IAAS,KAAK,CAACH,EAAY,SAAS;GACnD,EAAY,UAAU;GACtB,IAAMI,IAAMf,EAAmBa,GAAOC,GAAQR,GAAUC,CAAQ;GAEhE,AADAS,EAAQD,EAAI,IAAI,GAChBE,EAAOF,EAAI,MAAMA,EAAI,IAAI;EAC3B;CACF,GAAG;EAACF;EAAOC;EAAQR;EAAUC;EAAUS;EAASC;CAAM,CAAC;AACzD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useDeviceProfile as e } from "../device/useDeviceProfile.js";
|
|
2
|
+
import { useCallback as t, useEffect as n, useState as r } from "react";
|
|
3
|
+
//#region src/core/viewport/useCanvasSize.ts
|
|
4
|
+
function i(i) {
|
|
5
|
+
let { dpr: a } = e(), [o, s] = r({
|
|
6
|
+
width: 0,
|
|
7
|
+
height: 0
|
|
8
|
+
}), c = t(() => {
|
|
9
|
+
if (!i.current) return;
|
|
10
|
+
let e = i.current.getBoundingClientRect();
|
|
11
|
+
s((t) => t.width === e.width && t.height === e.height ? t : {
|
|
12
|
+
width: e.width,
|
|
13
|
+
height: e.height
|
|
14
|
+
});
|
|
15
|
+
}, [i]);
|
|
16
|
+
return n(() => {
|
|
17
|
+
c();
|
|
18
|
+
let e = new ResizeObserver(c);
|
|
19
|
+
return i.current && e.observe(i.current), () => e.disconnect();
|
|
20
|
+
}, [c, i]), {
|
|
21
|
+
width: o.width,
|
|
22
|
+
height: o.height,
|
|
23
|
+
dpr: a
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { i as useCanvasSize };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=useCanvasSize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCanvasSize.js","names":["useCanvasSize","useDeviceProfile","size","setSize","useState","measure","useCallback","containerRef","rect","prev","useEffect","observer"],"sources":["../../../src/core/viewport/useCanvasSize.ts"],"sourcesContent":["import { type RefObject, useCallback, useEffect, useState } from 'react';\nimport type { CanvasSize } from './clampView';\nimport { useDeviceProfile } from '../device/useDeviceProfile';\n\n/** Size snapshot returned by `useCanvasSize` — the kit-wide `CanvasSize`\n * (width × height in CSS pixels) plus the current devicePixelRatio. */\nexport interface CanvasSizeSnapshot extends CanvasSize {\n dpr: number;\n}\n\n/** Track a container's content-rect size via `ResizeObserver`, and density via\n * the ambient `DeviceProfile`.\n *\n * This hook is the screen path's designated ambient-density source —\n * rendering code should take density as a parameter (cf.\n * `renderSceneToPixels`, `renderSceneToCanvas`'s `dpr`) rather than reading\n * `window.devicePixelRatio` inline.\n *\n * Density deliberately does NOT come from a `window.devicePixelRatio` read\n * inside the resize callback: that only refreshes when the element resizes,\n * so dragging a window to a different-density display without resizing it\n * left the snapshot stale. The profile watches a re-armed resolution media\n * query instead. */\nexport function useCanvasSize(containerRef: RefObject<HTMLElement | null>): CanvasSizeSnapshot {\n const { dpr } = useDeviceProfile();\n const [size, setSize] = useState<CanvasSize>({ width: 0, height: 0 });\n\n const measure = useCallback(() => {\n if (!containerRef.current) return;\n const rect = containerRef.current.getBoundingClientRect();\n setSize((prev) =>\n prev.width === rect.width && prev.height === rect.height\n ? prev\n : { width: rect.width, height: rect.height },\n );\n }, [containerRef]);\n\n useEffect(() => {\n measure();\n const observer = new ResizeObserver(measure);\n if (containerRef.current) {\n observer.observe(containerRef.current);\n }\n return () => observer.disconnect();\n }, [measure, containerRef]);\n\n return { width: size.width, height: size.height, dpr };\n}\n"],"mappings":";;;AAuBA,SAAgBA,EAAc,GAAiE;CAC7F,IAAM,EAAE,WAAQC,EAAiB,GAC3B,CAACC,GAAMC,KAAWC,EAAqB;EAAE,OAAO;EAAG,QAAQ;CAAE,CAAC,GAE9DC,IAAUC,QAAkB;EAChC,IAAI,CAACC,EAAa,SAAS;EAC3B,IAAMC,IAAOD,EAAa,QAAQ,sBAAsB;EACxD,GAAS,MACPE,EAAK,UAAUD,EAAK,SAASC,EAAK,WAAWD,EAAK,SAC9CC,IACA;GAAE,OAAOD,EAAK;GAAO,QAAQA,EAAK;EAAO,CAC/C;CACF,GAAG,CAACD,CAAY,CAAC;CAWjB,OATAG,QAAgB;EACd,EAAQ;EACR,IAAMC,IAAW,IAAI,eAAeN,CAAO;EAI3C,OAHIE,EAAa,WACfI,EAAS,QAAQJ,EAAa,OAAO,SAE1BI,EAAS,WAAW;CACnC,GAAG,CAACN,GAASE,CAAY,CAAC,GAEnB;EAAE,OAAOL,EAAK;EAAO,QAAQA,EAAK;EAAQ;CAAI;AACvD"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useVisibleRaf as e } from "../../scheduling/useVisibleRaf.js";
|
|
2
|
+
import { useCallback as t, useEffect as n, useRef as r } from "react";
|
|
3
|
+
//#region src/core/viewport/useDecayLoop.ts
|
|
4
|
+
var i = .5;
|
|
5
|
+
function a() {
|
|
6
|
+
let a = r(null), o = e((e) => {
|
|
7
|
+
c(e);
|
|
8
|
+
}, { onResume: t(() => {
|
|
9
|
+
a.current && (a.current.lastTime = null);
|
|
10
|
+
}, []) }), s = t(() => {
|
|
11
|
+
o.cancel(), a.current = null;
|
|
12
|
+
}, [o]), c = t((e) => {
|
|
13
|
+
let t = a.current;
|
|
14
|
+
if (!t) return;
|
|
15
|
+
if (t.lastTime === null) {
|
|
16
|
+
t.lastTime = e, o.request();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
let n = Math.min(e - t.lastTime, 64);
|
|
20
|
+
t.lastTime = e;
|
|
21
|
+
let r = t.friction ** (n / 16.67);
|
|
22
|
+
if (t.vx *= r, t.vy *= r, Math.sqrt(t.vx * t.vx + t.vy * t.vy) < t.minSpeed) {
|
|
23
|
+
a.current = null, o.cancel(), t.onEnd?.();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
let s = t.vx * n, c = t.vy * n;
|
|
27
|
+
if (t.viewBounds && t.boundary) {
|
|
28
|
+
let { minX: e, maxX: n, minY: r, maxY: a } = t.viewBounds, o = t.posX + s, l = t.posY + c;
|
|
29
|
+
t.boundary === "stop" ? (e !== void 0 && o < e ? (s = e - t.posX, t.vx = 0) : n !== void 0 && o > n && (s = n - t.posX, t.vx = 0), r !== void 0 && l < r ? (c = r - t.posY, t.vy = 0) : a !== void 0 && l > a && (c = a - t.posY, t.vy = 0)) : t.boundary === "spring" ? (e !== void 0 && o < e ? (s = e - t.posX, t.vx = Math.abs(t.vx) * i) : n !== void 0 && o > n && (s = n - t.posX, t.vx = -Math.abs(t.vx) * i), r !== void 0 && l < r ? (c = r - t.posY, t.vy = Math.abs(t.vy) * i) : a !== void 0 && l > a && (c = a - t.posY, t.vy = -Math.abs(t.vy) * i)) : (e !== void 0 && o < e ? (s = e - t.posX, t.vx = Math.abs(t.vx)) : n !== void 0 && o > n && (s = n - t.posX, t.vx = -Math.abs(t.vx)), r !== void 0 && l < r ? (c = r - t.posY, t.vy = Math.abs(t.vy)) : a !== void 0 && l > a && (c = a - t.posY, t.vy = -Math.abs(t.vy))), t.posX += s, t.posY += c;
|
|
30
|
+
}
|
|
31
|
+
t.onTick(s, c), o.request();
|
|
32
|
+
}, [o]), l = t((e) => {
|
|
33
|
+
s();
|
|
34
|
+
let { velocity: t, friction: n = .92, minSpeed: r = .01, viewBounds: i, boundary: c, initialPosition: l, onTick: u, onEnd: d } = e;
|
|
35
|
+
if (Math.sqrt(t.vx ** 2 + t.vy ** 2) < r) {
|
|
36
|
+
d?.();
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
a.current = {
|
|
40
|
+
vx: t.vx,
|
|
41
|
+
vy: t.vy,
|
|
42
|
+
friction: n,
|
|
43
|
+
minSpeed: r,
|
|
44
|
+
lastTime: null,
|
|
45
|
+
posX: l?.x ?? 0,
|
|
46
|
+
posY: l?.y ?? 0,
|
|
47
|
+
viewBounds: i,
|
|
48
|
+
boundary: c,
|
|
49
|
+
onTick: u,
|
|
50
|
+
onEnd: d
|
|
51
|
+
}, o.request();
|
|
52
|
+
}, [s, o]);
|
|
53
|
+
return n(() => () => {
|
|
54
|
+
s();
|
|
55
|
+
}, [s]), {
|
|
56
|
+
start: l,
|
|
57
|
+
cancel: s
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { a as useDecayLoop };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=useDecayLoop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDecayLoop.js","names":["SPRING_DAMPING","useDecayLoop","stateRef","useRef","frameLoop","useVisibleRaf","now","useCallback","cancel","tick","s","dt","f","dx","dy","newX","newY","minX","maxX","minY","maxY","start","config","velocity","minSpeed","initialPosition","useEffect"],"sources":["../../../src/core/viewport/useDecayLoop.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport { useVisibleRaf } from '../../scheduling/useVisibleRaf';\n\n/** Per-axis limits on a view's position. Any side may be left open. */\nexport interface PanBounds {\n minX?: number;\n maxX?: number;\n minY?: number;\n maxY?: number;\n}\n\n/** Momentum settings for a pan: how quickly a flung view slows, when it stops,\n * and what happens at the pan limits. The `DecayLoopConfig` fields a caller\n * chooses up front, without the per-gesture `velocity` / `onTick`. */\nexport interface InertiaConfig {\n friction?: number;\n minSpeed?: number;\n /** What to do when inertial pan reaches `bounds`. Default: no clamping. */\n boundary?: 'stop' | 'bounce' | 'spring';\n /** View-coordinate limits for boundary clamping. Requires `boundary` to take effect. */\n bounds?: PanBounds;\n}\n\n/** How a decay should run: its starting velocity, how fast it slows, and what\n * happens if it reaches the pan limits. */\nexport interface DecayLoopConfig {\n velocity: { vx: number; vy: number };\n friction?: number;\n minSpeed?: number;\n /** Bounds for boundary clamping. Requires `boundary` to take effect. */\n viewBounds?: PanBounds;\n /**\n * What to do when the accumulated position hits `viewBounds`. Default: no clamping.\n * - `'stop'`: clamp at boundary, kill velocity component.\n * - `'bounce'`: linear reflection — flip velocity sign, magnitude preserved.\n * - `'spring'`: damped reflection — flip velocity sign and shrink magnitude\n * by `SPRING_DAMPING` per bounce so the motion settles naturally.\n */\n boundary?: 'stop' | 'bounce' | 'spring';\n /** Starting position for internal boundary tracking. Required when `viewBounds` is set. */\n initialPosition?: { x: number; y: number };\n onTick: (dx: number, dy: number) => void;\n onEnd?: () => void;\n}\n\n/**\n * Fraction of velocity preserved per `'spring'` bounce. 0.5 means each bounce\n * loses half its energy, giving a quick visible settle (typically 2–4 bounces\n * before `minSpeed` cuts the loop). Fixed for v1; a future `bounceDamping`\n * config option could expose this if a consumer needs control.\n */\nconst SPRING_DAMPING = 0.5;\n\n/** A rAF loop that coasts a value to a stop under friction, reporting the\n * per-frame delta. What turns a released pan drag into momentum scrolling. */\nexport function useDecayLoop() {\n const stateRef = useRef<{\n vx: number; vy: number;\n friction: number; minSpeed: number;\n lastTime: number | null;\n posX: number; posY: number;\n viewBounds: PanBounds | undefined;\n boundary: 'stop' | 'bounce' | 'spring' | undefined;\n onTick: (dx: number, dy: number) => void;\n onEnd?: () => void;\n } | null>(null);\n\n const frameLoop = useVisibleRaf(\n (now: number) => { tick(now); },\n {\n // Coasting does not continue while suspended: dropping `lastTime` makes\n // the resuming frame seed a fresh interval instead of applying an hour of\n // friction at once, which would end the decay before it was seen.\n onResume: useCallback(() => {\n if (stateRef.current) stateRef.current.lastTime = null;\n }, []),\n },\n );\n\n const cancel = useCallback(() => {\n frameLoop.cancel();\n stateRef.current = null;\n }, [frameLoop]);\n\n const tick = useCallback((now: number) => {\n const s = stateRef.current;\n if (!s) return;\n if (s.lastTime === null) {\n s.lastTime = now;\n frameLoop.request();\n return;\n }\n const dt = Math.min(now - s.lastTime, 64); // cap at 64ms to avoid huge jumps\n s.lastTime = now;\n // Time-normalize friction to 60fps baseline\n const f = Math.pow(s.friction, dt / 16.67);\n s.vx *= f;\n s.vy *= f;\n const speed = Math.sqrt(s.vx * s.vx + s.vy * s.vy);\n if (speed < s.minSpeed) {\n stateRef.current = null;\n frameLoop.cancel();\n s.onEnd?.();\n return;\n }\n let dx = s.vx * dt;\n let dy = s.vy * dt;\n if (s.viewBounds && s.boundary) {\n const { minX, maxX, minY, maxY } = s.viewBounds;\n const newX = s.posX + dx;\n const newY = s.posY + dy;\n if (s.boundary === 'stop') {\n if (minX !== undefined && newX < minX) { dx = minX - s.posX; s.vx = 0; }\n else if (maxX !== undefined && newX > maxX) { dx = maxX - s.posX; s.vx = 0; }\n if (minY !== undefined && newY < minY) { dy = minY - s.posY; s.vy = 0; }\n else if (maxY !== undefined && newY > maxY) { dy = maxY - s.posY; s.vy = 0; }\n } else if (s.boundary === 'spring') {\n // Damped reflection: flip sign AND scale magnitude by SPRING_DAMPING so\n // each bounce loses energy. Once |v| < minSpeed the outer loop ends.\n if (minX !== undefined && newX < minX) { dx = minX - s.posX; s.vx = Math.abs(s.vx) * SPRING_DAMPING; }\n else if (maxX !== undefined && newX > maxX) { dx = maxX - s.posX; s.vx = -Math.abs(s.vx) * SPRING_DAMPING; }\n if (minY !== undefined && newY < minY) { dy = minY - s.posY; s.vy = Math.abs(s.vy) * SPRING_DAMPING; }\n else if (maxY !== undefined && newY > maxY) { dy = maxY - s.posY; s.vy = -Math.abs(s.vy) * SPRING_DAMPING; }\n } else {\n if (minX !== undefined && newX < minX) { dx = minX - s.posX; s.vx = Math.abs(s.vx); }\n else if (maxX !== undefined && newX > maxX) { dx = maxX - s.posX; s.vx = -Math.abs(s.vx); }\n if (minY !== undefined && newY < minY) { dy = minY - s.posY; s.vy = Math.abs(s.vy); }\n else if (maxY !== undefined && newY > maxY) { dy = maxY - s.posY; s.vy = -Math.abs(s.vy); }\n }\n s.posX += dx;\n s.posY += dy;\n }\n s.onTick(dx, dy);\n frameLoop.request();\n }, [frameLoop]);\n\n const start = useCallback((config: DecayLoopConfig) => {\n cancel();\n const { velocity, friction = 0.92, minSpeed = 0.01, viewBounds, boundary, initialPosition, onTick, onEnd } = config;\n const speed = Math.sqrt(velocity.vx ** 2 + velocity.vy ** 2);\n if (speed < minSpeed) { onEnd?.(); return; }\n stateRef.current = {\n vx: velocity.vx, vy: velocity.vy, friction, minSpeed, lastTime: null,\n posX: initialPosition?.x ?? 0, posY: initialPosition?.y ?? 0,\n viewBounds, boundary,\n onTick, onEnd,\n };\n frameLoop.request();\n }, [cancel, frameLoop]);\n\n useEffect(() => () => { cancel(); }, [cancel]);\n\n return { start, cancel };\n}\n"],"mappings":";;;AAmDA,IAAMA,IAAiB;AAIvB,SAAgBC,IAAe;CAC7B,IAAMC,IAAWC,EASP,IAAI,GAERC,IAAYC,GACf,MAAgB;EAAE,EAAKC,CAAG;CAAG,GAC9B,EAIE,UAAUC,QAAkB;EAC1B,AAAIL,EAAS,YAAS,EAAS,QAAQ,WAAW;CACpD,GAAG,CAAC,CAAC,EACP,CACF,GAEMM,IAASD,QAAkB;EAE/B,AADAH,EAAU,OAAO,GACjB,EAAS,UAAU;CACrB,GAAG,CAACA,CAAS,CAAC,GAERK,IAAOF,GAAa,MAAgB;EACxC,IAAMG,IAAIR,EAAS;EACnB,IAAI,CAACQ,GAAG;EACR,IAAIA,EAAE,aAAa,MAAM;GAEvB,AADA,EAAE,WAAWJ,GACbF,EAAU,QAAQ;GAClB;EACF;EACA,IAAMO,IAAK,KAAK,IAAIL,IAAMI,EAAE,UAAU,EAAE;EACxC,EAAE,WAAWJ;EAEb,IAAMM,IAAaF,EAAE,aAAUC,IAAK;EAIpC,IAHA,EAAE,MAAMC,GACR,EAAE,MAAMA,GACM,KAAK,KAAKF,EAAE,KAAKA,EAAE,KAAKA,EAAE,KAAKA,EAAE,EAC3C,IAAQA,EAAE,UAAU;GAGtB,AAFA,EAAS,UAAU,MACnBN,EAAU,OAAO,GACjBM,EAAE,QAAQ;GACV;EACF;EACA,IAAIG,IAAKH,EAAE,KAAKC,GACZG,IAAKJ,EAAE,KAAKC;EAChB,IAAID,EAAE,cAAcA,EAAE,UAAU;GAC9B,IAAM,EAAE,SAAM,SAAM,SAAM,YAASA,EAAE,YAC/BK,IAAOL,EAAE,OAAOG,GAChBG,IAAON,EAAE,OAAOI;GAoBtB,AAnBIJ,EAAE,aAAa,UACbO,MAAS,KAAA,KAAaF,IAAOE,KAAQ,IAAKA,IAAOP,EAAE,MAAM,EAAE,KAAK,KAC3DQ,MAAS,KAAA,KAAaH,IAAOG,MAAQ,IAAKA,IAAOR,EAAE,MAAM,EAAE,KAAK,IACrES,MAAS,KAAA,KAAaH,IAAOG,KAAQ,IAAKA,IAAOT,EAAE,MAAM,EAAE,KAAK,KAC3DU,MAAS,KAAA,KAAaJ,IAAOI,MAAQ,IAAKA,IAAOV,EAAE,MAAM,EAAE,KAAK,MAChEA,EAAE,aAAa,YAGpBO,MAAS,KAAA,KAAaF,IAAOE,KAAQ,IAAKA,IAAOP,EAAE,MAAM,EAAE,KAAK,KAAK,IAAIA,EAAE,EAAE,IAAIV,KAC5EkB,MAAS,KAAA,KAAaH,IAAOG,MAAQ,IAAKA,IAAOR,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,IAAIA,EAAE,EAAE,IAAIV,IACvFmB,MAAS,KAAA,KAAaH,IAAOG,KAAQ,IAAKA,IAAOT,EAAE,MAAM,EAAE,KAAK,KAAK,IAAIA,EAAE,EAAE,IAAIV,KAC5EoB,MAAS,KAAA,KAAaJ,IAAOI,MAAQ,IAAKA,IAAOV,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,IAAIA,EAAE,EAAE,IAAIV,OAEvFiB,MAAS,KAAA,KAAaF,IAAOE,KAAQ,IAAKA,IAAOP,EAAE,MAAM,EAAE,KAAK,KAAK,IAAIA,EAAE,EAAE,KACxEQ,MAAS,KAAA,KAAaH,IAAOG,MAAQ,IAAKA,IAAOR,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,IAAIA,EAAE,EAAE,IACnFS,MAAS,KAAA,KAAaH,IAAOG,KAAQ,IAAKA,IAAOT,EAAE,MAAM,EAAE,KAAK,KAAK,IAAIA,EAAE,EAAE,KACxEU,MAAS,KAAA,KAAaJ,IAAOI,MAAQ,IAAKA,IAAOV,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,IAAIA,EAAE,EAAE,KAEzF,EAAE,QAAQG,GACV,EAAE,QAAQC;EACZ;EAEA,AADAJ,EAAE,OAAOG,GAAIC,CAAE,GACfV,EAAU,QAAQ;CACpB,GAAG,CAACA,CAAS,CAAC,GAERiB,IAAQd,GAAa,MAA4B;EACrD,EAAO;EACP,IAAM,EAAE,aAAU,cAAW,KAAM,cAAW,KAAM,eAAY,aAAU,oBAAiB,WAAQ,aAAUe;EAE7G,IADc,KAAK,KAAKC,EAAS,MAAM,IAAIA,EAAS,MAAM,CACtD,IAAQC,GAAU;GAAE,IAAQ;GAAG;EAAQ;EAO3C,AANA,EAAS,UAAU;GACjB,IAAID,EAAS;GAAI,IAAIA,EAAS;GAAI;GAAU;GAAU,UAAU;GAChE,MAAME,GAAiB,KAAK;GAAG,MAAMA,GAAiB,KAAK;GAC3D;GAAY;GACZ;GAAQ;EACV,GACArB,EAAU,QAAQ;CACpB,GAAG,CAACI,GAAQJ,CAAS,CAAC;CAItB,OAFAsB,cAAsB;EAAE,EAAO;CAAG,GAAG,CAAClB,CAAM,CAAC,GAEtC;EAAE;EAAO;CAAO;AACzB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createVelocityTracker as e } from "./createVelocityTracker.js";
|
|
2
|
+
import { useMemo as t } from "react";
|
|
3
|
+
//#region src/core/viewport/useVelocityTracker.ts
|
|
4
|
+
function n() {
|
|
5
|
+
return t(() => e(), []);
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { n as useVelocityTracker };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=useVelocityTracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useVelocityTracker.js","names":["useVelocityTracker","useMemo","createVelocityTracker"],"sources":["../../../src/core/viewport/useVelocityTracker.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { createVelocityTracker, type VelocityTracker } from './createVelocityTracker';\n\nexport type { VelocityTracker };\n\n/** Records recent pointer deltas and reports the current velocity, averaged\n * over the last 100ms — the throw speed a momentum decay starts from. */\nexport function useVelocityTracker(): VelocityTracker {\n return useMemo(() => createVelocityTracker(), []);\n}\n"],"mappings":";;;AAOA,SAAgBA,IAAsC;CACpD,OAAOC,QAAcC,EAAsB,GAAG,CAAC,CAAC;AAClD"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { normalizeView as e } from "./view.js";
|
|
2
|
+
import { fitViewToBounds as t } from "./fitViewToBounds.js";
|
|
3
|
+
import { interpolateView as n } from "./interpolateView.js";
|
|
4
|
+
import { useAnimator as r } from "../../animation/useAnimator.js";
|
|
5
|
+
import { easeOutCubic as i } from "@weasel-js/geom";
|
|
6
|
+
import { useId as a, useMemo as o, useRef as s } from "react";
|
|
7
|
+
import { useLatest as c } from "@weasel-js/react";
|
|
8
|
+
//#region src/core/viewport/useViewAnimation.ts
|
|
9
|
+
var l = "view", u = 250;
|
|
10
|
+
function d(e, t) {
|
|
11
|
+
let n = r();
|
|
12
|
+
return f(e, t ?? n);
|
|
13
|
+
}
|
|
14
|
+
function f(r, d) {
|
|
15
|
+
let f = `${l}:${a()}`, p = c(r), m = c(d), h = s(null), g = s(!1);
|
|
16
|
+
return o(() => {
|
|
17
|
+
let r = () => m.current.isActive(f), a = () => r() ? h.current : null, o = () => {
|
|
18
|
+
m.current.cancelKey(f), h.current = null;
|
|
19
|
+
}, s = (t, r = {}) => {
|
|
20
|
+
let s = p.current.get(), c = e(typeof t == "function" ? t(a() ?? s) : t);
|
|
21
|
+
o(), h.current = c, m.current.tween({
|
|
22
|
+
from: s,
|
|
23
|
+
to: c,
|
|
24
|
+
ms: r.ms ?? u,
|
|
25
|
+
easing: r.easing ?? i,
|
|
26
|
+
interpolator: r.interpolator ?? n,
|
|
27
|
+
cancelKey: f,
|
|
28
|
+
onTick: (e) => {
|
|
29
|
+
g.current = !0;
|
|
30
|
+
try {
|
|
31
|
+
p.current.set(e);
|
|
32
|
+
} finally {
|
|
33
|
+
g.current = !1;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
onDone: () => {
|
|
37
|
+
h.current = null, r.onDone?.();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
animate: s,
|
|
43
|
+
animateToBounds: (e, n, r = {}) => {
|
|
44
|
+
let i = p.current.get(), a = t(e, n, i, r);
|
|
45
|
+
a !== i && s(a, r);
|
|
46
|
+
},
|
|
47
|
+
stop: o,
|
|
48
|
+
isAnimating: r,
|
|
49
|
+
target: a,
|
|
50
|
+
stopIfExternal: () => {
|
|
51
|
+
g.current || o();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}, [
|
|
55
|
+
f,
|
|
56
|
+
p,
|
|
57
|
+
m
|
|
58
|
+
]);
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { l as VIEW_ANIMATION_KEY, d as useViewAnimation, f as useViewAnimationOn };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=useViewAnimation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useViewAnimation.js","names":["VIEW_ANIMATION_KEY","DEFAULT_MS","useViewAnimation","own","useAnimator","useViewAnimationOn","view","animator","key","useId","viewRef","useLatest","animatorRef","targetRef","useRef","writingRef","useMemo","isAnimating","target","stop","animate","from","resolved","normalizeView","to","opts","easeOutCubic","interpolateView","v","current","fitted","fitViewToBounds","bounds","dims"],"sources":["../../../src/core/viewport/useViewAnimation.ts"],"sourcesContent":["import { useId, useMemo, useRef } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport { useAnimator } from '../../animation/useAnimator';\nimport { easeOutCubic } from '@weasel-js/geom';\nimport type { Animator, EasingSpec, InterpolatorFactory } from '../../animation/types';\nimport { interpolateView } from './interpolateView';\nimport { fitViewToBounds } from './fitViewToBounds';\nimport type { Bounds, FitViewToBoundsOptions, ViewportDims } from './fitViewToBounds';\nimport { normalizeView, type View } from './view';\n\n/** Cancel-key prefix. Each hook instance appends its own id, so two runners\n * sharing an animator do not cancel each other. */\nexport const VIEW_ANIMATION_KEY = 'view';\n\nconst DEFAULT_MS = 250;\n\n/** How the camera should move. */\nexport interface ViewAnimationOptions {\n /** Duration in ms. Default 250. */\n ms?: number;\n /** Easing curve. Default `easeOutCubic`. */\n easing?: EasingSpec;\n /** Replace the kit's log-scale / fixed-anchor curve. */\n interpolator?: InterpolatorFactory<View>;\n /** Fires when the target is reached. Not called on cancel. */\n onDone?: () => void;\n}\n\n/** Options accepted by {@link ViewAnimationApi.animateToBounds}. */\nexport interface AnimateToBoundsOptions extends FitViewToBoundsOptions, ViewAnimationOptions {}\n\n/** What the runner reads and writes. On `<SceneCanvas>` this is the same\n * channel `view.set` uses, so a camera animation on an uncontrolled canvas\n * costs no React render. */\nexport interface ViewChannel {\n get(): View;\n set(v: View): void;\n}\n\n/** The camera animation surface. One animation at a time. */\nexport interface ViewAnimationApi {\n /** Glide from the live view to `to`. A thunk receives the pending target when\n * one is in flight, so successive discrete steps compound. */\n animate(to: View | ((base: View) => View), opts?: ViewAnimationOptions): void;\n /** `fitViewToBounds` composed with `animate`. */\n animateToBounds(bounds: Bounds, dims: ViewportDims, opts?: AnimateToBoundsOptions): void;\n /** Cancel. The view stays where it is — no jump to the target. */\n stop(): void;\n isAnimating(): boolean;\n /** Where the in-flight animation is heading, or null when none is. */\n target(): View | null;\n /** Cancel unless the write that prompted this came from the runner's own\n * per-frame write. Feed it from every channel that can move the camera. */\n stopIfExternal(): void;\n}\n\n/**\n * Animate the viewport `View`. Runs on the kit's {@link Animator} — pass one to\n * share a canvas's animator, or omit it and the hook makes its own. A caller\n * that always has one should use {@link useViewAnimationOn}, which builds none.\n *\n * Every animation from one instance registers under that instance's cancel key,\n * so starting one cancels whatever *it* had in flight, and each starts from the\n * *live* view rather than a captured value — an interrupted camera never jumps.\n * Two instances on one animator are independent.\n */\nexport function useViewAnimation(view: ViewChannel, animator?: Animator): ViewAnimationApi {\n const own = useAnimator();\n return useViewAnimationOn(view, animator ?? own);\n}\n\n/** {@link useViewAnimation} on an animator the caller owns. Constructs no\n * animator of its own, so the camera runs on exactly the one passed. */\nexport function useViewAnimationOn(view: ViewChannel, animator: Animator): ViewAnimationApi {\n const key = `${VIEW_ANIMATION_KEY}:${useId()}`;\n const viewRef = useLatest(view);\n const animatorRef = useLatest(animator);\n const targetRef = useRef<View | null>(null);\n const writingRef = useRef(false);\n\n return useMemo<ViewAnimationApi>(() => {\n const isAnimating = () => animatorRef.current.isActive(key);\n const target = () => (isAnimating() ? targetRef.current : null);\n const stop = () => {\n animatorRef.current.cancelKey(key);\n targetRef.current = null;\n };\n\n const animate: ViewAnimationApi['animate'] = (to, opts = {}) => {\n const from = viewRef.current.get();\n const resolved = normalizeView(typeof to === 'function' ? to(target() ?? from) : to);\n stop();\n targetRef.current = resolved;\n animatorRef.current.tween<View>({\n from,\n to: resolved,\n ms: opts.ms ?? DEFAULT_MS,\n easing: opts.easing ?? easeOutCubic,\n interpolator: opts.interpolator ?? interpolateView,\n cancelKey: key,\n onTick: (v) => {\n writingRef.current = true;\n try { viewRef.current.set(v); } finally { writingRef.current = false; }\n },\n onDone: () => {\n targetRef.current = null;\n opts.onDone?.();\n },\n });\n };\n\n return {\n animate,\n animateToBounds: (bounds, dims, opts = {}) => {\n const current = viewRef.current.get();\n const fitted = fitViewToBounds(bounds, dims, current, opts);\n if (fitted === current) return; // helper bailed (zero-area bounds/viewport)\n animate(fitted, opts);\n },\n stop,\n isAnimating,\n target,\n stopIfExternal: () => { if (!writingRef.current) stop(); },\n };\n }, [key, viewRef, animatorRef]);\n}\n"],"mappings":";;;;;;;;AAYA,IAAaA,IAAqB,QAE5BC,IAAa;AAoDnB,SAAgBC,EAAiB,GAAmB,GAAuC;CACzF,IAAMC,IAAMC,EAAY;CACxB,OAAOC,EAAmBC,GAAMC,KAAYJ,CAAG;AACjD;AAIA,SAAgBE,EAAmB,GAAmB,GAAsC;CAC1F,IAAMG,IAAM,GAAGR,EAAmB,GAAGS,EAAM,KACrCC,IAAUC,EAAUL,CAAI,GACxBM,IAAcD,EAAUJ,CAAQ,GAChCM,IAAYC,EAAoB,IAAI,GACpCC,IAAaD,EAAO,EAAK;CAE/B,OAAOE,QAAgC;EACrC,IAAMC,UAAoBL,EAAY,QAAQ,SAASJ,CAAG,GACpDU,UAAgBD,EAAY,IAAIJ,EAAU,UAAU,MACpDM,UAAa;GAEjB,AADAP,EAAY,QAAQ,UAAUJ,CAAG,GACjC,EAAU,UAAU;EACtB,GAEMY,KAAwC,GAAI,IAAO,CAAC,MAAM;GAC9D,IAAMC,IAAOX,EAAQ,QAAQ,IAAI,GAC3BY,IAAWC,EAAc,OAAOC,KAAO,aAAaA,EAAGN,EAAO,KAAKG,CAAI,IAAIG,CAAE;GAGnF,AAFAL,EAAK,GACL,EAAU,UAAUG,GACpBV,EAAY,QAAQ,MAAY;IAC9B;IACA,IAAIU;IACJ,IAAIG,EAAK,MAAMxB;IACf,QAAQwB,EAAK,UAAUC;IACvB,cAAcD,EAAK,gBAAgBE;IACnC,WAAWnB;IACX,SAAS,MAAM;KACb,EAAW,UAAU;KACrB,IAAI;MAAE,EAAQ,QAAQ,IAAIoB,CAAC;KAAG,UAAU;MAAE,EAAW,UAAU;KAAO;IACxE;IACA,cAAc;KAEZ,AADA,EAAU,UAAU,MACpBH,EAAK,SAAS;IAChB;GACF,CAAC;EACH;EAEA,OAAO;GACL;GACA,kBAAkB,GAAQ,GAAM,IAAO,CAAC,MAAM;IAC5C,IAAMI,IAAUnB,EAAQ,QAAQ,IAAI,GAC9BoB,IAASC,EAAgBC,GAAQC,GAAMJ,GAASJ,CAAI;IAC1D,AAAIK,MAAWD,KACfT,EAAQU,GAAQL,CAAI;GACtB;GACA;GACA;GACA;GACA,sBAAsB;IAAE,AAAKV,EAAW,WAASI,EAAK;GAAG;EAC3D;CACF,GAAG;EAACX;EAAKE;EAASE;CAAW,CAAC;AAChC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { normalizeZoom as e, warnInvalidView as t } from "./zoomBounds.js";
|
|
2
|
+
//#region src/core/viewport/view.ts
|
|
3
|
+
function n(e) {
|
|
4
|
+
return {
|
|
5
|
+
panX: -e.x * e.scale.x + 0,
|
|
6
|
+
panY: -e.y * e.scale.y + 0,
|
|
7
|
+
zoom: {
|
|
8
|
+
x: e.scale.x,
|
|
9
|
+
y: e.scale.y
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function r(e) {
|
|
14
|
+
let { x: t, y: n } = e.scale;
|
|
15
|
+
return t === n ? t : Math.sqrt(t * n);
|
|
16
|
+
}
|
|
17
|
+
function i(e) {
|
|
18
|
+
let t = a(e.scale.x), n = a(e.scale.y), r = o(e.x), i = o(e.y);
|
|
19
|
+
return t === e.scale.x && n === e.scale.y && r === e.x && i === e.y ? e : {
|
|
20
|
+
x: r,
|
|
21
|
+
y: i,
|
|
22
|
+
scale: {
|
|
23
|
+
x: t,
|
|
24
|
+
y: n
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function a(t) {
|
|
29
|
+
return t < 0 && t > -Infinity ? -e(-t) : e(t);
|
|
30
|
+
}
|
|
31
|
+
function o(e) {
|
|
32
|
+
return Number.isFinite(e) ? e : (t(`a position of ${e}`), 0);
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { i as normalizeView, n as viewToTransform, r as viewZoom };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.js","names":["viewToTransform","view","viewZoom","x","y","normalizeView","sx","normalizeAxis","sy","finiteTranslation","s","normalizeZoom","v","warnInvalidView"],"sources":["../../../src/core/viewport/view.ts"],"sourcesContent":["import type { ViewTransform } from './viewTransform';\nimport type { View } from '@weasel-js/routing';\nimport { normalizeZoom, warnInvalidView } from './zoomBounds';\n\n/**\n * `View` is declared in `@weasel-js/routing` — the dispatcher and every\n * viewport action are typed in it. Re-exported here, where core's own call\n * sites have always named it.\n *\n * Core holds the invariant behind the shape: every view the kit keeps is\n * total, so each `scale` axis is finite with a magnitude of at least\n * `ZOOM_FLOOR` and `x` / `y` are finite. A negative axis is a flipped one\n * (y-up), not a degenerate one, and keeps its sign. Canvases, views and\n * animations pass what they are given through {@link normalizeView}, so\n * screen/world conversion never divides by zero.\n *\n * `scale` is always a 2-vector. Input convenience types {@link ZoomFactor}\n * and {@link ZoomBound} let callers pass a scalar when they want both axes\n * treated the same.\n */\nexport type { View };\n\n/**\n * Input convenience for zoom primitives. A `number` is treated as a\n * uniform factor applied to both axes; a `{x, y}` vector applies\n * per-axis factors.\n */\nexport type ZoomFactor = number | { x: number; y: number };\n\n/**\n * Input convenience for zoom-clamp ranges. A `number` is applied as the\n * same bound on both axes; a `{x, y}` vector applies per-axis bounds.\n */\nexport type ZoomBound = number | { x: number; y: number };\n\n/**\n * Bridge `View` into the legacy `ViewTransform` shape so chrome can keep\n * calling `worldToScreen` / `screenToWorld`. `View` and `ViewTransform`\n * use opposite sign conventions for the translation half (`view.x` is\n * camera position; `panX` is canvas translation), so the adapter flips\n * the sign and multiplies by per-axis scale.\n */\nexport function viewToTransform(view: View): ViewTransform {\n // `+ 0` coerces `-0 → 0` without swallowing NaN (matches viewToMat3).\n return {\n panX: -view.x * view.scale.x + 0,\n panY: -view.y * view.scale.y + 0,\n zoom: { x: view.scale.x, y: view.scale.y },\n };\n}\n\n/**\n * How far `view` is zoomed in, as one number — the geometric mean of its two\n * axes, so a uniform view reports its own scale and a stretched one reports\n * the scale that covers the same area.\n *\n * What a `RuleCtx` carries, because the only rule that asks about the\n * viewport asks for a threshold rather than a camera.\n */\nexport function viewZoom(view: View): number {\n const { x, y } = view.scale;\n return x === y ? x : Math.sqrt(x * y);\n}\n\n/**\n * `view` inside the invariant {@link View} documents: a zero or non-finite\n * scale axis becomes `ZOOM_FLOOR`, a negative one keeps its sign, and a\n * non-finite translation becomes 0. Returns `view` itself when it already\n * holds, so a valid view keeps its identity.\n */\nexport function normalizeView(view: View): View {\n const sx = normalizeAxis(view.scale.x);\n const sy = normalizeAxis(view.scale.y);\n const x = finiteTranslation(view.x);\n const y = finiteTranslation(view.y);\n if (sx === view.scale.x && sy === view.scale.y && x === view.x && y === view.y) return view;\n return { x, y, scale: { x: sx, y: sy } };\n}\n\nfunction normalizeAxis(s: number): number {\n return s < 0 && s > -Infinity ? -normalizeZoom(-s) : normalizeZoom(s);\n}\n\nfunction finiteTranslation(v: number): number {\n if (Number.isFinite(v)) return v;\n warnInvalidView(`a position of ${v}`);\n return 0;\n}\n"],"mappings":";;AA0CA,SAAgBA,EAAgB,GAA2B;CAEzD,OAAO;EACL,MAAM,CAACC,EAAK,IAAIA,EAAK,MAAM,IAAI;EAC/B,MAAM,CAACA,EAAK,IAAIA,EAAK,MAAM,IAAI;EAC/B,MAAM;GAAE,GAAGA,EAAK,MAAM;GAAG,GAAGA,EAAK,MAAM;EAAE;CAC3C;AACF;AAUA,SAAgBC,EAAS,GAAoB;CAC3C,IAAM,EAAE,MAAG,SAAMD,EAAK;CACtB,OAAOE,MAAMC,IAAID,IAAI,KAAK,KAAKA,IAAIC,CAAC;AACtC;AAQA,SAAgBC,EAAc,GAAkB;CAC9C,IAAMC,IAAKC,EAAcN,EAAK,MAAM,CAAC,GAC/BO,IAAKD,EAAcN,EAAK,MAAM,CAAC,GAC/BE,IAAIM,EAAkBR,EAAK,CAAC,GAC5BG,IAAIK,EAAkBR,EAAK,CAAC;CAElC,OADIK,MAAOL,EAAK,MAAM,KAAKO,MAAOP,EAAK,MAAM,KAAKE,MAAMF,EAAK,KAAKG,MAAMH,EAAK,IAAUA,IAChF;EAAE;EAAG;EAAG,OAAO;GAAE,GAAGK;GAAI,GAAGE;EAAG;CAAE;AACzC;AAEA,SAASD,EAAc,GAAmB;CACxC,OAAOG,IAAI,KAAKA,IAAI,YAAY,CAACC,EAAc,CAACD,CAAC,IAAIC,EAAcD,CAAC;AACtE;AAEA,SAASD,EAAkB,GAAmB;CAG5C,OAFI,OAAO,SAASG,CAAC,IAAUA,KAC/BC,EAAgB,iBAAiBD,GAAG,GAC7B;AACT"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/core/viewport/viewTransform.ts
|
|
2
|
+
function e(e, t, n) {
|
|
3
|
+
return [n.panX + e * n.zoom.x, n.panY + t * n.zoom.y];
|
|
4
|
+
}
|
|
5
|
+
function t(e, t, n) {
|
|
6
|
+
return [(e - n.panX) / n.zoom.x, (t - n.panY) / n.zoom.y];
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { t as screenToWorld, e as worldToScreen };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=viewTransform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewTransform.js","names":["worldToScreen","view","worldX","worldY","screenToWorld","screenX","screenY"],"sources":["../../../src/core/viewport/viewTransform.ts"],"sourcesContent":["/** Pan offset (in pixels) plus per-axis zoom (pixels per content unit). */\nexport interface ViewTransform {\n panX: number;\n panY: number;\n zoom: { x: number; y: number };\n}\n\n/** Project a world-space point to screen-space pixels through a `ViewTransform`. */\nexport function worldToScreen(\n worldX: number,\n worldY: number,\n view: ViewTransform,\n): [number, number] {\n return [view.panX + worldX * view.zoom.x, view.panY + worldY * view.zoom.y];\n}\n\n/** Inverse of `worldToScreen` — recover the world-space point under a screen-space pixel. */\nexport function screenToWorld(\n screenX: number,\n screenY: number,\n view: ViewTransform,\n): [number, number] {\n return [(screenX - view.panX) / view.zoom.x, (screenY - view.panY) / view.zoom.y];\n}\n"],"mappings":";AAQA,SAAgBA,EACd,GACA,GACA,GACkB;CAClB,OAAO,CAACC,EAAK,OAAOC,IAASD,EAAK,KAAK,GAAGA,EAAK,OAAOE,IAASF,EAAK,KAAK,CAAC;AAC5E;AAGA,SAAgBG,EACd,GACA,GACA,GACkB;CAClB,OAAO,EAAEC,IAAUJ,EAAK,QAAQA,EAAK,KAAK,IAAIK,IAAUL,EAAK,QAAQA,EAAK,KAAK,CAAC;AAClF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/core/viewport/viewportWorldRect.ts
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
return {
|
|
4
|
+
x: e.x,
|
|
5
|
+
y: e.y,
|
|
6
|
+
width: t.width / e.scale.x,
|
|
7
|
+
height: t.height / e.scale.y
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { e as viewportWorldRect };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=viewportWorldRect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewportWorldRect.js","names":["viewportWorldRect","view","size"],"sources":["../../../src/core/viewport/viewportWorldRect.ts"],"sourcesContent":["import type { View } from './view';\n\n/**\n * The world-space rectangle a camera shows in a host `size` CSS pixels across.\n *\n * One formula, because two callers need it against different hosts: the\n * canvas element for view zero, and a view's own rect for a panel. Paste\n * placement centers on it, so the two disagreeing puts pasted content in a\n * view the user is not looking at.\n */\nexport function viewportWorldRect(\n view: View,\n size: { width: number; height: number },\n): { x: number; y: number; width: number; height: number } {\n return {\n x: view.x,\n y: view.y,\n width: size.width / view.scale.x,\n height: size.height / view.scale.y,\n };\n}\n"],"mappings":";AAUA,SAAgBA,EACd,GACA,GACyD;CACzD,OAAO;EACL,GAAGC,EAAK;EACR,GAAGA,EAAK;EACR,OAAOC,EAAK,QAAQD,EAAK,MAAM;EAC/B,QAAQC,EAAK,SAASD,EAAK,MAAM;CACnC;AACF"}
|