@mark1russell7/visuals 0.3.3 → 0.3.5
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/README.md +147 -2
- package/build/globe.d.ts +2 -2
- package/build/graph.d.ts +417 -0
- package/build/graph.d.ts.map +1 -0
- package/build/graph.js +855 -0
- package/build/graph.js.map +1 -0
- package/build/highlight-BJ6xGp6V.d.ts +30 -0
- package/build/highlight-BJ6xGp6V.d.ts.map +1 -0
- package/build/index.d.ts +2 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/build/labels.d.ts +1 -1
- package/build/markers.d.ts +2 -2
- package/build/{motion-BvRKIWAC.js → motion-VS13e4Pw.js} +14 -3
- package/build/{motion-BvRKIWAC.js.map → motion-VS13e4Pw.js.map} +1 -1
- package/build/{stage-DmFfah2e.d.ts → stage-D8JVM6wZ.d.ts} +3 -2
- package/build/stage-D8JVM6wZ.d.ts.map +1 -0
- package/build/{theme-3EGbXXoP.d.ts → theme-DBbBlCbC.d.ts} +2 -30
- package/build/theme-DBbBlCbC.d.ts.map +1 -0
- package/build/three.d.ts +2 -2
- package/build/three.js +2 -8
- package/build/three.js.map +1 -1
- package/package.json +6 -1
- package/build/stage-DmFfah2e.d.ts.map +0 -1
- package/build/theme-3EGbXXoP.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.js","names":[],"sources":["../src/graph/camera.ts","../src/graph/aim.ts","../src/graph/keys.ts","../src/graph/pointers.ts","../src/graph/stack.ts","../src/graph/stage.ts"],"sourcesContent":["import type { Point, Rect } from \"@mark1russell7/layout-contract\";\nimport { easeInOut, partAt } from \"../motion.ts\";\n\n/**\n * The camera of a flat picture: a zoom and the position of the origin.\n * A point `p` of the picture shows at the screen point `p * k + (x, y)`. Each screen length is in CSS pixels.\n */\nexport interface PictureView {\n /** The screen position of the origin of the picture, from the left edge. */\n readonly x: number;\n /** The screen position of the origin of the picture, from the top edge. */\n readonly y: number;\n /** The zoom: the screen length of one unit of the picture. */\n readonly k: number;\n}\n\n/** The limits of the zoom of a camera. */\nexport interface ZoomLimits {\n readonly min: number;\n readonly max: number;\n}\n\n/** The default limits of the zoom. */\nexport const ZOOM_LIMITS: ZoomLimits = { min: 0.05, max: 8 };\n\n/** The view that shows each point of the picture at its own position. */\nexport const UNIT_VIEW: PictureView = { x: 0, y: 0, k: 1 };\n\n/** This function gives a zoom in its limits. A zoom that is not a number gives the smallest zoom. */\nexport function clampZoom(k: number, limits: ZoomLimits = ZOOM_LIMITS): number {\n return k >= limits.min ? Math.min(k, limits.max) : limits.min;\n}\n\n/** This function gives the point of the picture that shows at a screen point. */\nexport function toPicture(view: PictureView, screen: Point): Point {\n return { x: (screen.x - view.x) / view.k, y: (screen.y - view.y) / view.k };\n}\n\n/** This function gives the screen point that shows a point of the picture. */\nexport function toScreen(view: PictureView, point: Point): Point {\n return { x: point.x * view.k + view.x, y: point.y * view.k + view.y };\n}\n\n/** This function gives the screen rectangle that shows a rectangle of the picture. */\nexport function rectToScreen(view: PictureView, rect: Rect): Rect {\n return { x: rect.x * view.k + view.x, y: rect.y * view.k + view.y, w: rect.w * view.k, h: rect.h * view.k };\n}\n\n/** This function gives the view with the zoom `k` that shows the point `point` of the picture at the screen point `at`. */\nexport function viewAt(point: Point, at: Point, k: number): PictureView {\n return { x: at.x - point.x * k, y: at.y - point.y * k, k };\n}\n\n/** This function gives the view after a move of the picture by a screen distance. */\nexport function panView(view: PictureView, dx: number, dy: number): PictureView {\n return { x: view.x + dx, y: view.y + dy, k: view.k };\n}\n\n/**\n * This function gives the view after a zoom by `factor`. The zoom stays in its limits.\n * The screen point `at` shows the same point of the picture before and after the zoom.\n */\nexport function zoomView(view: PictureView, at: Point, factor: number, limits: ZoomLimits = ZOOM_LIMITS): PictureView {\n const k = clampZoom(view.k * factor, limits);\n const ratio = k / view.k;\n return { x: at.x - (at.x - view.x) * ratio, y: at.y - (at.y - view.y) * ratio, k };\n}\n\n/** The positions of the two pointers of a pinch, in CSS pixels. */\nexport type PointerPair = readonly [Point, Point];\n\n/**\n * This function gives the view after the two pointers of a pinch move from `before` to `after`.\n *\n * The zoom changes by the ratio of the two distances between the pointers.\n * The point of the picture at the middle of the pointers stays at their middle.\n * Thus each pointer keeps its point of the picture, if the pointers do not turn and the zoom is in its limits.\n */\nexport function pinchView(view: PictureView, before: PointerPair, after: PointerPair, limits: ZoomLimits = ZOOM_LIMITS): PictureView {\n const from = { x: (before[0].x + before[1].x) / 2, y: (before[0].y + before[1].y) / 2 };\n const to = { x: (after[0].x + after[1].x) / 2, y: (after[0].y + after[1].y) / 2 };\n const was = Math.hypot(before[0].x - before[1].x, before[0].y - before[1].y);\n const is = Math.hypot(after[0].x - after[1].x, after[0].y - after[1].y);\n // Two pointers at one position give no ratio. The picture then only moves.\n const factor = was > 0 && is > 0 ? is / was : 1;\n return zoomView(panView(view, to.x - from.x, to.y - from.y), to, factor, limits);\n}\n\n/** The speed of the zoom of a wheel: the change of the natural logarithm of the zoom for one CSS pixel of the wheel. */\nexport const WHEEL_SPEED = 0.0015;\n\n/** The height of one line of a wheel that gives its turn in lines, in CSS pixels. */\nexport const WHEEL_LINE = 16;\n\n/** The factor of the speed of the wheel for a pinch on a touch pad. A browser gives such a pinch as a wheel with the key `Control`. */\nexport const WHEEL_PINCH = 10;\n\n/**\n * This function gives the factor of the zoom for one event of a wheel. A turn away from the person makes the picture larger.\n *\n * `deltaY` and `deltaMode` are the fields of the event. A mode of 1 has its turn in lines.\n * `pinch` is the field `ctrlKey` of the event: a pinch on a touch pad has small turns, so its speed is higher.\n */\nexport function wheelFactor(deltaY: number, deltaMode: number = 0, pinch: boolean = false): number {\n const pixels = deltaMode === 1 ? deltaY * WHEEL_LINE : deltaY;\n return Math.exp(0 - pixels * WHEEL_SPEED * (pinch ? WHEEL_PINCH : 1));\n}\n\n/** The parts of a picture that a page covers, from each edge, in CSS pixels. */\nexport interface Insets {\n readonly top: number;\n readonly right: number;\n readonly bottom: number;\n readonly left: number;\n}\n\n/** The smallest width and height of a free area, in CSS pixels. */\nexport const SMALLEST_AREA = 80;\n\n/**\n * This function gives the free area of a picture: the screen rectangle that the page does not cover.\n * A camera shows a selection in this area, so a panel of the page does not hide it.\n * The width and the height of the area are `SMALLEST_AREA` at least.\n */\nexport function freeArea(size: { readonly width: number; readonly height: number }, insets: Partial<Insets> = {}): Rect {\n const left = insets.left ?? 0;\n const top = insets.top ?? 0;\n return {\n x: left,\n y: top,\n w: Math.max(SMALLEST_AREA, size.width - left - (insets.right ?? 0)),\n h: Math.max(SMALLEST_AREA, size.height - top - (insets.bottom ?? 0)),\n };\n}\n\n/** The default distance between a rectangle that a camera shows and each edge of the area, in CSS pixels. */\nexport const FIT_PADDING = 24;\n\n/** The options of `fitRect`. */\nexport interface FitOptions {\n /** The distance between the rectangle and each edge of the area, in CSS pixels. The default is `FIT_PADDING`. */\n readonly padding?: number | undefined;\n /** The largest zoom of the result. The default is the largest zoom of the limits. */\n readonly most?: number | undefined;\n /** The limits of the zoom. The default is `ZOOM_LIMITS`. */\n readonly limits?: ZoomLimits | undefined;\n}\n\n/**\n * This function gives the middle of a rectangle.\n * The home of this function is `@mark1russell7/layout-contract`, which does not have it. It moves there with the records of a picture.\n */\nexport function middleOf(rect: Rect): Point {\n return { x: rect.x + rect.w / 2, y: rect.y + rect.h / 2 };\n}\n\n/** This function gives the zoom at which a rectangle of the picture fills an area of the screen, with a padding at each edge. */\nfunction fillZoom(rect: Rect, area: Rect, padding: number): number {\n const width = Math.max(area.w - 2 * padding, 1);\n const height = Math.max(area.h - 2 * padding, 1);\n return Math.min(width / Math.max(rect.w, 0), height / Math.max(rect.h, 0));\n}\n\n/**\n * This function gives the view that shows a rectangle of the picture in an area of the screen, as large as the area permits.\n * The middle of the rectangle is at the middle of the area. A rectangle with no size gets the largest zoom.\n */\nexport function fitRect(rect: Rect, area: Rect, options: FitOptions = {}): PictureView {\n const limits = options.limits ?? ZOOM_LIMITS;\n const k = clampZoom(Math.min(options.most ?? limits.max, fillZoom(rect, area, options.padding ?? FIT_PADDING)), limits);\n return viewAt(middleOf(rect), middleOf(area), k);\n}\n\n/**\n * This function gives the limits of the zoom for a picture with the bounds `bounds`.\n *\n * The smallest zoom of the result shows all of the picture in the area, with a padding at each edge.\n * A picture that fits at the smallest zoom of `limits` keeps `limits`. Thus a person can show all of a very large picture.\n */\nexport function zoomLimitsFor(bounds: Rect, area: Rect, limits: ZoomLimits = ZOOM_LIMITS, padding: number = FIT_PADDING): ZoomLimits {\n const all = fillZoom(bounds, area, padding);\n return all > 0 && all < limits.min ? { min: all, max: limits.max } : limits;\n}\n\n/** The length of a picture that stays in the free area when a person moves the picture, in CSS pixels. */\nexport const KEEP_IN_VIEW = 64;\n\n/** This function gives the start of a span of the screen that keeps the length `least` in an area, on one axis. */\nfunction keepSpan(start: number, length: number, areaStart: number, areaLength: number, least: number): number {\n const keep = Math.min(Math.max(least, 0), length, areaLength);\n return Math.min(Math.max(start, areaStart + keep - length), areaStart + areaLength - keep);\n}\n\n/**\n * This function gives the view that keeps a part of a rectangle of the picture in an area of the screen.\n * A person who moves the picture then cannot lose it.\n *\n * `least` is the length of the rectangle that stays in the area on each axis, in CSS pixels.\n * A rectangle that is smaller on the screen stays in the area fully. The zoom does not change.\n * The result is `view` itself when the view keeps the rectangle.\n */\nexport function keepRect(view: PictureView, rect: Rect, area: Rect, least: number = KEEP_IN_VIEW): PictureView {\n const shown = rectToScreen(view, rect);\n const x = keepSpan(shown.x, shown.w, area.x, area.w, least);\n const y = keepSpan(shown.y, shown.h, area.y, area.h, least);\n return x === shown.x && y === shown.y ? view : { x: view.x + x - shown.x, y: view.y + y - shown.y, k: view.k };\n}\n\n/** This function tells if two views are equal. */\nexport function sameView(a: PictureView, b: PictureView): boolean {\n return a.x === b.x && a.y === b.y && a.k === b.k;\n}\n\n/** The options of `frameRects`. */\nexport interface FrameOptions extends FitOptions {\n /** The smallest zoom at which a person reads the content of a rectangle. */\n readonly least: number;\n}\n\n/**\n * This function gives the view for the first rectangle of a list that an area of the screen shows at the zoom `least` or more.\n *\n * Give the bounds of the largest group of boxes first, then the bounds of smaller groups.\n * If no rectangle is small enough, the result has the zoom `least` and the middle of the last rectangle at the middle of the area.\n * An empty list gives `undefined`.\n */\nexport function frameRects(rects: readonly Rect[], area: Rect, options: FrameOptions): PictureView | undefined {\n for (const rect of rects) {\n const view = fitRect(rect, area, options);\n if (view.k >= options.least) return view;\n }\n const last = rects.at(-1);\n if (last === undefined) return undefined;\n return viewAt(middleOf(last), middleOf(area), clampZoom(options.least, options.limits));\n}\n\n/**\n * This function tells if a view shows all of a rectangle of the picture in an area of the screen.\n * `margin` is the smallest distance between the rectangle and each edge of the area, in CSS pixels.\n */\nexport function showsRect(view: PictureView, rect: Rect, area: Rect, margin: number = 0): boolean {\n const shown = rectToScreen(view, rect);\n return shown.x >= area.x + margin && shown.y >= area.y + margin && shown.x + shown.w <= area.x + area.w - margin && shown.y + shown.h <= area.y + area.h - margin;\n}\n\n/** The options of `revealRects`. */\nexport interface RevealOptions extends FrameOptions {\n /** The smallest distance between a rectangle in view and each edge of the area, in CSS pixels. The default is 0. */\n readonly margin?: number | undefined;\n}\n\n/**\n * This function gives the view that shows a selection, and it keeps the view `view` when the selection is in view.\n *\n * The rectangles are the bounds of the groups of the selection, as for `frameRects`, the largest group first.\n * The selection is in view when `view` has the zoom `least` or more, and shows all of the rectangle that `frameRects` selects.\n * The result is then `view` itself, so a camera does not move for a click on a box that a person reads.\n * In each other case, the result is the view of `frameRects`. An empty list gives `view`.\n */\nexport function revealRects(view: PictureView, rects: readonly Rect[], area: Rect, options: RevealOptions): PictureView {\n for (const rect of rects) {\n const framed = fitRect(rect, area, options);\n if (framed.k < options.least) continue;\n return view.k >= options.least && showsRect(view, rect, area, options.margin ?? 0) ? view : framed;\n }\n return frameRects(rects.slice(-1), area, options) ?? view;\n}\n\n/**\n * This function gives the view at a part of the way between two views. `part` goes from 0 to 1.\n *\n * The zoom changes by an equal factor for each equal step, so a zoom has one speed in the picture.\n * The way is a zoom at one screen point: the point of the picture that the two views show there stays there.\n * Thus each point of the picture moves along a straight line of the screen, in one direction.\n * Two views with one zoom give a straight move at one speed.\n */\nexport function viewBetween(from: PictureView, to: PictureView, part: number): PictureView {\n if (!(part > 0)) return from;\n if (part >= 1) return to;\n const log = Math.log(to.k / from.k);\n if (!Number.isFinite(log)) return to;\n // The origin moves in proportion to the change of the zoom. The function expm1 keeps the precision for two zooms that are almost equal.\n const share = log === 0 ? part : Math.expm1(log * part) / Math.expm1(log);\n return { x: from.x + (to.x - from.x) * share, y: from.y + (to.y - from.y) * share, k: from.k * Math.exp(log * part) };\n}\n\n/** A move of the camera of a flat picture from one view to a different view. */\nexport interface PictureMove {\n readonly from: PictureView;\n readonly to: PictureView;\n /** The time of the start of the move, in milliseconds. */\n readonly start: number;\n /** The time that the move takes, in milliseconds. */\n readonly duration: number;\n}\n\n/** The view of a camera at one time of a move. */\nexport interface PictureMoveStep {\n readonly view: PictureView;\n /** This value is true at the end of the move, and after it. */\n readonly done: boolean;\n}\n\n/**\n * This function gives the view of a camera at the time `now` of a move, in milliseconds.\n * The move has a slow start and a slow end. A move with no duration is at its end immediately.\n */\nexport function pictureMoveAt(move: PictureMove, now: number): PictureMoveStep {\n const part = partAt(move.start, move.duration, now);\n if (part >= 1) return { view: move.to, done: true };\n return { view: viewBetween(move.from, move.to, easeInOut(part)), done: false };\n}\n","import type { Rect } from \"@mark1russell7/layout-contract\";\nimport { fitRect, frameRects, revealRects, type FitOptions, type FrameOptions, type PictureView, type RevealOptions, type ZoomLimits } from \"./camera.ts\";\n\n/** What an aim gets: the picture and the screen at the time of the aim. */\nexport interface AimFrame {\n /** The bounds of the content, in the unit of the picture. */\n readonly bounds: Rect;\n /** The free area of the picture on the screen, in CSS pixels. */\n readonly area: Rect;\n /** The view of the camera before the aim. */\n readonly view: PictureView;\n /** The limits of the zoom. */\n readonly limits: ZoomLimits;\n}\n\n/**\n * An aim of the camera of a flat picture: a function that gives the view for a picture and a screen.\n * A stage asks the aim again after a change of the size of the picture, so the view stays correct.\n */\nexport type PictureAim = (frame: AimFrame) => PictureView;\n\n/** This function makes the aim that shows all of the picture, as large as the free area permits. */\nexport function aimAll(options: FitOptions = {}): PictureAim {\n return (frame) => fitRect(frame.bounds, frame.area, { ...options, limits: options.limits ?? frame.limits });\n}\n\n/**\n * This function makes the aim that shows a group of boxes at a zoom that a person reads.\n * The rectangles are the bounds of the groups, the largest group first: `frameRects` selects one. An empty list keeps the view.\n */\nexport function aimRects(rects: readonly Rect[], options: FrameOptions): PictureAim {\n return (frame) => frameRects(rects, frame.area, { ...options, limits: options.limits ?? frame.limits }) ?? frame.view;\n}\n\n/**\n * This function makes the aim that shows a selection, and keeps the view when the selection is in view.\n * The rectangles are the bounds of the groups of the selection, the largest group first: `revealRects` selects one.\n */\nexport function aimReveal(rects: readonly Rect[], options: RevealOptions): PictureAim {\n return (frame) => revealRects(frame.view, rects, frame.area, { ...options, limits: options.limits ?? frame.limits });\n}\n","import type { Rect } from \"@mark1russell7/layout-contract\";\nimport { KEY_PART, KEY_ZOOM } from \"../keys.ts\";\nimport { middleOf, panView, zoomView, type PictureView, type ZoomLimits } from \"./camera.ts\";\n\n/** What a key does on a flat picture: it moves the camera to a view, or it shows a view by its name. */\nexport type PictureKeyAction = { readonly type: \"move\"; readonly to: PictureView } | { readonly type: \"view\"; readonly view: string };\n\n/** The keys of a flat picture. */\nexport interface PictureKeyOptions {\n /** The name of the view of the keys `Home` and `0`. */\n readonly home: string;\n /** The name of the view of each other key, for example `{ f: \"focus\" }`. A letter has no case. */\n readonly views?: Readonly<Record<string, string>> | undefined;\n /** The limits of the zoom. The default is `ZOOM_LIMITS`. */\n readonly limits?: ZoomLimits | undefined;\n}\n\n/**\n * This function gives the action of a key on a flat picture, or `undefined` for a key with no action.\n *\n * `area` is the part of the screen that shows the picture. `freeArea` gives it.\n * An arrow key moves the camera by the part `KEY_PART` of the smaller side of the area.\n * The keys `+` and `-` zoom at the middle of the area, by the factor of one step of a key on a 3D stage.\n * The keys `Home` and `0` show the home view.\n */\nexport function pictureKeyAction(key: string, now: PictureView, area: Rect, options: PictureKeyOptions): PictureKeyAction | undefined {\n const step = Math.min(area.w, area.h) * KEY_PART;\n const middle = middleOf(area);\n switch (key) {\n // The camera moves in the direction of the arrow, so the picture moves in the opposite direction.\n case \"ArrowLeft\":\n return { type: \"move\", to: panView(now, step, 0) };\n case \"ArrowRight\":\n return { type: \"move\", to: panView(now, 0 - step, 0) };\n case \"ArrowUp\":\n return { type: \"move\", to: panView(now, 0, step) };\n case \"ArrowDown\":\n return { type: \"move\", to: panView(now, 0, 0 - step) };\n case \"+\":\n case \"=\":\n return { type: \"move\", to: zoomView(now, middle, 1 / KEY_ZOOM, options.limits) };\n case \"-\":\n case \"_\":\n return { type: \"move\", to: zoomView(now, middle, KEY_ZOOM, options.limits) };\n case \"Home\":\n case \"0\":\n return { type: \"view\", view: options.home };\n default: {\n const view = key.length === 1 ? options.views?.[key.toLowerCase()] : undefined;\n return view === undefined ? undefined : { type: \"view\", view };\n }\n }\n}\n","import type { Point } from \"@mark1russell7/layout-contract\";\nimport { CLICK_DISTANCE, isClick } from \"../highlight.ts\";\nimport { panView, pinchView, ZOOM_LIMITS, type PictureView, type ZoomLimits } from \"./camera.ts\";\n\n/** The pointers that are down on a picture: a mouse button, a pen or each finger of a hand. */\nexport interface Pointers {\n /** The screen position of each pointer that is down, by the id of the pointer. */\n readonly at: ReadonlyMap<number, Point>;\n /** The position where the first pointer went down. */\n readonly start: Point | undefined;\n /** This value is true after a second pointer went down. The pointers then make no click. */\n readonly many: boolean;\n}\n\n/** The pointers of a picture that no pointer is down on. */\nexport const NO_POINTERS: Pointers = { at: new Map(), start: undefined, many: false };\n\n/** A finger moves more than a mouse between down and up. This is the distance of a click for a finger, in CSS pixels. */\nexport const TOUCH_CLICK_DISTANCE = 10;\n\n/** This function gives the pointers after a pointer went down. The first pointer starts a possible click. */\nexport function pointerDown(pointers: Pointers, id: number, at: Point): Pointers {\n const next = new Map(pointers.at).set(id, at);\n // A pointer that went up outside of the page can go down again with no up between.\n const first = next.size === 1;\n return first ? { at: next, start: at, many: false } : { at: next, start: pointers.start, many: true };\n}\n\n/** The result of `pointerMove`: the pointers and the view after the move. */\nexport interface PointerMoveResult {\n readonly pointers: Pointers;\n readonly view: PictureView;\n}\n\n/**\n * This function gives the pointers and the view after a pointer moved.\n *\n * One pointer moves the picture, so the point of the picture below the pointer stays there.\n * Two pointers make a pinch: `pinchView` gives the view. Three pointers or more do not change the view.\n * A pointer that is not down changes nothing.\n */\nexport function pointerMove(pointers: Pointers, id: number, at: Point, view: PictureView, limits: ZoomLimits = ZOOM_LIMITS): PointerMoveResult {\n const old = pointers.at.get(id);\n if (old === undefined) return { pointers, view };\n const next: Pointers = { ...pointers, at: new Map(pointers.at).set(id, at) };\n if (pointers.at.size === 1) return { pointers: next, view: panView(view, at.x - old.x, at.y - old.y) };\n if (pointers.at.size > 2) return { pointers: next, view };\n for (const [key, other] of pointers.at) {\n if (key !== id) return { pointers: next, view: pinchView(view, [old, other], [at, other], limits) };\n }\n return { pointers: next, view };\n}\n\n/** The result of `pointerUp`: the pointers that stay down, and the answer if the pointer made a click. */\nexport interface PointerUpResult {\n readonly pointers: Pointers;\n /** This value is true when one pointer went down and up at almost the same position. */\n readonly click: boolean;\n}\n\n/**\n * This function gives the pointers after a pointer went up, and tells if the pointer made a click.\n *\n * A click is one pointer that went up not more than `limit` from its start, with no second pointer between.\n * The default of `limit` is `CLICK_DISTANCE`. Use `TOUCH_CLICK_DISTANCE` for a finger.\n */\nexport function pointerUp(pointers: Pointers, id: number, at: Point, limit: number = CLICK_DISTANCE): PointerUpResult {\n if (!pointers.at.has(id)) return { pointers, click: false };\n const rest = new Map(pointers.at);\n rest.delete(id);\n if (rest.size > 0) return { pointers: { ...pointers, at: rest }, click: false };\n return { pointers: NO_POINTERS, click: !pointers.many && pointers.start !== undefined && isClick(pointers.start, at, limit) };\n}\n\n/** This function gives the pointers after the browser stopped a pointer, for example for a gesture of the system. It makes no click. */\nexport function pointerCancel(pointers: Pointers, id: number): Pointers {\n if (!pointers.at.has(id)) return pointers;\n const rest = new Map(pointers.at);\n rest.delete(id);\n return rest.size > 0 ? { ...pointers, at: rest } : NO_POINTERS;\n}\n","import type { PictureContent, PicturePick } from \"./stage.ts\";\n\n/**\n * This function makes one content from a list of contents, for a flat stage that shows them together.\n * An example is a layer of boxes below a layer of routes and a layer of labels.\n *\n * - The first content gives the bounds: the views and the limits of the camera come from it.\n * - The stack draws the contents in their sequence, so the last content is on top.\n * - A pick asks the last content first. The first record that a content gives is the record.\n * - A record that two contents have is one record: each of them gets its highlight.\n * - A content does not get the state of the canvas of an earlier content: the stack restores it.\n * - The stage disposes the stack, and the stack disposes each content.\n */\nexport function stackPictureContents<P, T>(contents: readonly [PictureContent<P, T>, ...PictureContent<P, T>[]]): PictureContent<P, T> {\n const [first] = contents;\n return {\n get bounds() {\n return first.bounds;\n },\n has: (record) => contents.some((content) => content.has(record)),\n pick(at): PicturePick<P> | undefined {\n for (let index = contents.length - 1; index >= 0; index -= 1) {\n const pick = contents[index]?.pick(at);\n if (pick !== undefined) return pick;\n }\n return undefined;\n },\n draw(context, frame, theme, highlight): boolean {\n let active = false;\n // Each content has its picture, also after a content that continues to change.\n for (const content of contents) {\n context.save();\n active = content.draw(context, frame, theme, highlight) || active;\n context.restore();\n }\n return active;\n },\n dispose(): void {\n for (const content of contents) content.dispose?.();\n },\n };\n}\n","import type { Point, Rect } from \"@mark1russell7/layout-contract\";\nimport { CLICK_DISTANCE, highlightOf, NO_HIGHLIGHTS, type Highlight, type Highlights } from \"../highlight.ts\";\nimport { lessMotion, MOVE_TIME } from \"../motion.ts\";\nimport { aimAll, type AimFrame, type PictureAim } from \"./aim.ts\";\nimport {\n clampZoom,\n freeArea,\n keepRect,\n middleOf,\n pictureMoveAt,\n sameView,\n toPicture,\n UNIT_VIEW,\n viewAt,\n wheelFactor,\n ZOOM_LIMITS,\n zoomLimitsFor,\n zoomView,\n type Insets,\n type PictureMove,\n type PictureView,\n type ZoomLimits,\n} from \"./camera.ts\";\nimport { pictureKeyAction } from \"./keys.ts\";\nimport { NO_POINTERS, pointerCancel, pointerDown, pointerMove, pointerUp, TOUCH_CLICK_DISTANCE, type Pointers } from \"./pointers.ts\";\n\n/** The record below the pointer of a flat picture: its name, and the value that the content gives for it. */\nexport interface PicturePick<P> {\n /** The name of the record. The highlights of the stage use this name. */\n readonly record: string;\n /** The value of the record for the page, for example its kind and its source. */\n readonly value: P;\n}\n\n/** The position of a pointer on a flat picture, for the pick of a content. */\nexport interface PickAt {\n /** The point of the picture below the pointer. */\n readonly point: Point;\n /** The position of the pointer on the screen, in CSS pixels from the top left corner of the picture. */\n readonly screen: Point;\n /** The view of the camera. */\n readonly view: PictureView;\n /** The distance from the pointer at which a thin part is below the pointer, in CSS pixels. A finger has a larger distance than a mouse. */\n readonly slack: number;\n}\n\n/** One picture of a flat stage, for the drawing of its content. */\nexport interface PictureFrame {\n /** The view of the camera. */\n readonly view: PictureView;\n /** The width of the picture, in CSS pixels. */\n readonly width: number;\n /** The height of the picture, in CSS pixels. */\n readonly height: number;\n /** The part of the picture that the page does not cover, in CSS pixels. */\n readonly area: Rect;\n /** The number of pixels of the canvas for one CSS pixel. */\n readonly pixelRatio: number;\n /** The time since the last picture, in seconds. */\n readonly seconds: number;\n /**\n * This value is true for the first picture of a content, and for a person who asks for less motion.\n * Each change then has no time: the content sets each value to its goal immediately.\n */\n readonly settle: boolean;\n}\n\n/**\n * The content of a flat stage: what the stage draws, and what the stage asks of it.\n * `P` is the type of the value of a pick, and `T` is the type of the theme.\n */\nexport interface PictureContent<P, T> {\n /** The bounds of the content, in the unit of the picture. The views and the limits of the camera come from them. */\n readonly bounds: Rect;\n /** This function tells if the content has a record with a name. */\n has(record: string): boolean;\n /** This function gives the record below a pointer, or `undefined` for no record. */\n pick(at: PickAt): PicturePick<P> | undefined;\n /**\n * This function draws the content on a clear canvas. The unit of the context is the CSS pixel: the view is in the frame.\n * `highlight` gives the highlight of a record. The function gives true while a part continues to change.\n * The stage then makes the next picture.\n */\n draw(context: CanvasRenderingContext2D, frame: PictureFrame, theme: T, highlight: (record: string) => Highlight): boolean;\n /** This function releases what the content keeps, for example its images. */\n dispose?(): void;\n}\n\n/** The options of a flat stage. */\nexport interface PictureStageOptions<P, T> {\n /** The first content. The stage disposes each content that it gets. */\n readonly content: PictureContent<P, T>;\n readonly theme: T;\n /** The name of the picture for a screen reader. */\n readonly label: string;\n /** The views of the stage, each with a name. The view `all` shows all of the picture, if the options do not give a different one. */\n readonly views?: Readonly<Record<string, PictureAim>> | undefined;\n /** The name of the first view. The keys `Home` and `0` show it. The default is `all`. */\n readonly home?: string | undefined;\n /** The name of the view of a key, for example `{ f: \"focus\" }`. A letter has no case. */\n readonly keys?: Readonly<Record<string, string>> | undefined;\n /** The limits of the zoom. The default is `ZOOM_LIMITS`. A very large picture gets a smaller least zoom, so a person can show all of it. */\n readonly limits?: ZoomLimits | undefined;\n /** The parts of the picture that the page covers, from each edge, in CSS pixels. */\n readonly insets?: Partial<Insets> | undefined;\n /**\n * When the wheel changes the zoom. With `in-use`, the wheel moves the page until a person uses the picture.\n * With `always`, the wheel changes the zoom at each time. The default is `in-use`. A pinch on a touch pad changes the zoom always.\n */\n readonly wheel?: \"always\" | \"in-use\" | undefined;\n /** The stage starts this function when the pointer goes to a different record, or to no record. */\n readonly onHover?: ((pick: P | undefined) => void) | undefined;\n /** The stage starts this function when a person selects a record with the pointer, or selects no record. */\n readonly onSelect?: ((pick: P | undefined) => void) | undefined;\n /** The stage starts this function after a change of the view, one time for each picture at most. */\n readonly onView?: ((view: PictureView) => void) | undefined;\n}\n\n/** A flat stage in a page: one canvas with a camera that a person moves, and one content. */\nexport interface PictureStage<P, T> {\n /** The canvas of the stage. It is in the container. */\n readonly canvas: HTMLCanvasElement;\n /** This function shows a different content, and disposes the old content. The view stays if a person moved it. */\n setContent(content: PictureContent<P, T>): void;\n /** This function changes the colors. */\n setTheme(theme: T): void;\n /** This function moves the camera to a view: a name of the options, or an aim. `animate` has the default true. */\n setView(view: string | PictureAim, animate?: boolean): void;\n /** This function tells the stage which parts of the picture the page covers. The camera goes to its view again if no person moved it. */\n setInsets(insets: Partial<Insets>): void;\n /** This function gives the view of the camera. */\n view(): PictureView;\n /** This function gives the part of the picture that the page does not cover, in CSS pixels. */\n area(): Rect;\n /** This function changes the zoom by a factor, at the middle of the free area. Use it for the buttons of a page. `animate` has the default true. */\n zoomBy(factor: number, animate?: boolean): void;\n /** This function highlights records by their names, as the pointer does. An empty list removes the highlights. */\n highlight(records: readonly string[]): void;\n /** This function selects one record by its name, or no record. It does not start `onSelect`. */\n select(record: string | undefined): void;\n /** This function makes a new picture. Use it after a change of the content. */\n refresh(): void;\n /** This function removes the canvas, and disposes the content. */\n dispose(): void;\n}\n\n/** The distance from a mouse at which a thin part is below the pointer, in CSS pixels. */\nexport const PICK_SLACK = 5;\n\n/** The distance from a finger or a pen at which a thin part is below the pointer, in CSS pixels. */\nexport const TOUCH_PICK_SLACK = 12;\n\n/** The factor of the zoom for a double click. */\nexport const DOUBLE_CLICK_ZOOM = 2;\n\n/** The largest number of pixels of the canvas for one CSS pixel. A larger number costs memory, and a person does not see it. */\nconst LARGEST_PIXEL_RATIO = 3;\n\n/**\n * This function makes a flat stage in a container of a page. The stage fills the container, so give the container a size.\n *\n * A person moves the picture with a drag, and changes the zoom with the wheel, with two fingers or with a double click.\n * A click selects the record below the pointer. With the keyboard, the arrow keys move the camera, `+` and `-` change the zoom,\n * and `Home` shows the first view. The stage makes a picture only after a change.\n *\n * The function gives `undefined` when the browser gives no 2D context for a canvas. It does not throw.\n */\nexport function createPictureStage<P, T>(container: HTMLElement, options: PictureStageOptions<P, T>): PictureStage<P, T> | undefined {\n const canvas = container.ownerDocument.createElement(\"canvas\");\n const made = canvas.getContext(\"2d\");\n if (made === null) return undefined;\n // The functions below use this constant: its type has no `null`.\n const context: CanvasRenderingContext2D = made;\n\n canvas.style.display = \"block\";\n canvas.style.width = \"100%\";\n canvas.style.height = \"100%\";\n canvas.style.cursor = \"grab\";\n canvas.style.touchAction = \"none\";\n canvas.tabIndex = 0;\n canvas.setAttribute(\"role\", \"application\");\n canvas.setAttribute(\"aria-label\", options.label);\n container.append(canvas);\n\n const views: Readonly<Record<string, PictureAim>> = { all: aimAll(), ...options.views };\n const home = options.home ?? \"all\";\n const baseLimits = options.limits ?? ZOOM_LIMITS;\n const wheel = options.wheel ?? \"in-use\";\n\n let content = options.content;\n let theme = options.theme;\n let insets: Partial<Insets> = options.insets ?? {};\n let highlights: Highlights = NO_HIGHLIGHTS;\n /** The size of the picture, in CSS pixels. */\n let width = 0;\n let height = 0;\n let pixelRatio = 1;\n /** This value is true after the container gave a size. A stage with no size makes no picture. */\n let sized = false;\n let area: Rect = freeArea({ width, height }, insets);\n let limits: ZoomLimits = baseLimits;\n let view: PictureView = UNIT_VIEW;\n /** The view that the camera has, or goes to: a name of the views, or an aim. */\n let aim: string | PictureAim = home;\n let move: PictureMove | undefined;\n /** This value is true after a person moved the view. Then a new size of the container does not aim the camera again. */\n let moved = false;\n /** This value is true until the content had a picture with no time. */\n let settle = true;\n /** This value is true while a person uses the picture. The wheel then changes the zoom. */\n let inUse = false;\n let pointers: Pointers = NO_POINTERS;\n /** This value is true while a pointer that is down moves the picture. */\n let dragging = false;\n /** The view that `onView` got last. */\n let told: PictureView | undefined;\n let frame = 0;\n let lastTime = 0;\n let disposed = false;\n\n const invalidate = (): void => {\n if (frame === 0 && !disposed) frame = requestAnimationFrame(tick);\n };\n\n const setCursor = (): void => {\n canvas.style.cursor = dragging ? \"grabbing\" : highlights.hovered === undefined ? \"grab\" : \"pointer\";\n };\n\n /** This function sets the free area and the limits of the zoom, from the size, the insets and the content. */\n const setArea = (): void => {\n area = freeArea({ width, height }, insets);\n limits = zoomLimitsFor(content.bounds, area, baseLimits);\n };\n\n const aimFrame = (): AimFrame => ({ bounds: content.bounds, area, view, limits });\n\n /** This function moves the camera to a view, with a move or immediately. A picture with no size has no move. */\n const glide = (to: PictureView, animate: boolean): void => {\n if (animate && sized && !lessMotion() && !sameView(view, to)) {\n move = { from: view, to, start: performance.now(), duration: MOVE_TIME };\n } else {\n move = undefined;\n view = to;\n }\n invalidate();\n };\n\n const goTo = (next: string | PictureAim, animate: boolean): void => {\n const found = typeof next === \"string\" ? views[next] : next;\n if (found === undefined) return;\n aim = next;\n moved = false;\n glide(found(aimFrame()), animate);\n };\n\n /**\n * This function sets a view that a person made, immediately. The zoom stays in its limits, and a part of the picture stays in the free area.\n * A zoom that the limits change keeps the point of the picture at the middle of the free area.\n */\n const hold = (base: PictureView): void => {\n const k = clampZoom(base.k, limits);\n const middle = middleOf(area);\n move = undefined;\n view = keepRect(k === base.k ? base : viewAt(toPicture(base, middle), middle, k), content.bounds, area);\n invalidate();\n };\n\n /** This function sets a view that a person made with a pointer, the wheel or a key. */\n const steer = (next: PictureView): void => {\n moved = true;\n hold(next);\n };\n\n /**\n * This function sets the size of the canvas from the size of the container and the pixels of the screen.\n * It gives true after a change. A container with no size changes nothing.\n */\n const setSize = (): boolean => {\n const wide = container.clientWidth;\n const tall = container.clientHeight;\n if (wide === 0 || tall === 0) return false;\n const ratio = Math.min(globalThis.devicePixelRatio > 0 ? globalThis.devicePixelRatio : 1, LARGEST_PIXEL_RATIO);\n if (wide === width && tall === height && ratio === pixelRatio) return false;\n width = wide;\n height = tall;\n pixelRatio = ratio;\n canvas.width = Math.round(wide * ratio);\n canvas.height = Math.round(tall * ratio);\n return true;\n };\n\n /** This function sets the camera after a change of the size of the picture. */\n const fitAgain = (): void => {\n const before = area;\n const first = !sized;\n sized = true;\n setArea();\n if (first || !moved) {\n goTo(aim, false);\n return;\n }\n // A person moved the view: the point of the picture at the middle of the free area stays at the middle.\n const base = move?.to ?? view;\n hold(viewAt(toPicture(base, middleOf(before)), middleOf(area), base.k));\n };\n\n function tick(now: number): void {\n frame = 0;\n if (disposed) return;\n // The pixels of the screen change with no event when a window goes to a different screen.\n if (setSize()) fitAgain();\n if (!sized) return;\n const seconds = lastTime === 0 ? 1 / 60 : Math.min((now - lastTime) / 1000, 0.1);\n let active = false;\n if (move !== undefined) {\n const step = pictureMoveAt(move, now);\n view = step.view;\n if (step.done) move = undefined;\n active = !step.done;\n }\n context.setTransform(1, 0, 0, 1, 0, 0);\n context.clearRect(0, 0, canvas.width, canvas.height);\n context.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);\n const shown = highlights;\n const drawing = content.draw(context, { view, width, height, area, pixelRatio, seconds, settle: settle || lessMotion() }, theme, (record) => highlightOf(shown, record));\n settle = false;\n active = drawing || active;\n lastTime = active ? now : 0;\n if (told === undefined || !sameView(told, view)) {\n told = view;\n options.onView?.(view);\n }\n if (active) invalidate();\n }\n\n /** This function gives the position of a pointer in the picture, in CSS pixels from its top left corner. */\n const positionOf = (event: { readonly clientX: number; readonly clientY: number }): Point => {\n const box = canvas.getBoundingClientRect();\n return { x: event.clientX - box.left, y: event.clientY - box.top };\n };\n\n const pickAt = (screen: Point, slack: number): PicturePick<P> | undefined => content.pick({ point: toPicture(view, screen), screen, view, slack });\n\n const setHover = (pick: PicturePick<P> | undefined): void => {\n const record = pick?.record;\n if (record === highlights.hovered) return;\n highlights = { ...highlights, hovered: record };\n setCursor();\n invalidate();\n options.onHover?.(pick?.value);\n };\n\n const listeners = new AbortController();\n const signal = listeners.signal;\n canvas.addEventListener(\n \"pointerdown\",\n (event) => {\n if (event.button !== 0) return;\n inUse = true;\n canvas.focus({ preventScroll: true });\n try {\n // With the capture, a drag continues when the pointer goes out of the canvas.\n canvas.setPointerCapture(event.pointerId);\n } catch {\n // A pointer that the browser does not know has no capture. The drag then ends at the edge of the canvas.\n }\n if (move !== undefined) {\n // A pointer stops a move, as a hand stops a thing that moves.\n move = undefined;\n moved = true;\n }\n pointers = pointerDown(pointers, event.pointerId, positionOf(event));\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointermove\",\n (event) => {\n if (pointers.at.has(event.pointerId)) {\n const next = pointerMove(pointers, event.pointerId, positionOf(event), view, limits);\n pointers = next.pointers;\n if (sameView(next.view, view)) return;\n dragging = true;\n setCursor();\n steer(next.view);\n return;\n }\n // A finger is on the picture only while it is down, so it has no record below it before a click.\n if (event.pointerType !== \"touch\" && pointers.at.size === 0) setHover(pickAt(positionOf(event), PICK_SLACK));\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointerup\",\n (event) => {\n if (!pointers.at.has(event.pointerId)) return;\n const mouse = event.pointerType === \"mouse\";\n const position = positionOf(event);\n const up = pointerUp(pointers, event.pointerId, position, mouse ? CLICK_DISTANCE : TOUCH_CLICK_DISTANCE);\n pointers = up.pointers;\n if (pointers.at.size === 0) {\n dragging = false;\n setCursor();\n }\n if (!up.click) return;\n const pick = pickAt(position, mouse ? PICK_SLACK : TOUCH_PICK_SLACK);\n highlights = { ...highlights, selected: pick?.record };\n invalidate();\n options.onSelect?.(pick?.value);\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointercancel\",\n (event) => {\n pointers = pointerCancel(pointers, event.pointerId);\n if (pointers.at.size > 0) return;\n dragging = false;\n setCursor();\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointerleave\",\n (event) => {\n setHover(undefined);\n if (event.pointerType === \"mouse\") inUse = false;\n },\n { signal },\n );\n canvas.addEventListener(\n \"blur\",\n () => {\n inUse = false;\n },\n { signal },\n );\n canvas.addEventListener(\n \"wheel\",\n (event) => {\n // A browser gives a pinch on a touch pad as a wheel with the key `Control`. Without the stage, it changes the zoom of the page.\n if (wheel === \"in-use\" && !inUse && !event.ctrlKey) return;\n event.preventDefault();\n steer(zoomView(view, positionOf(event), wheelFactor(event.deltaY, event.deltaMode, event.ctrlKey), limits));\n },\n { signal, passive: false },\n );\n canvas.addEventListener(\n \"dblclick\",\n (event) => {\n event.preventDefault();\n moved = true;\n glide(keepRect(zoomView(view, positionOf(event), DOUBLE_CLICK_ZOOM, limits), content.bounds, area), true);\n },\n { signal },\n );\n canvas.addEventListener(\n \"keydown\",\n (event) => {\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const action = pictureKeyAction(event.key, view, area, { home, views: options.keys, limits });\n if (action === undefined) return;\n event.preventDefault();\n inUse = true;\n if (action.type === \"view\") goTo(action.view, true);\n else steer(action.to);\n },\n { signal },\n );\n\n const observer = new ResizeObserver(() => {\n if (!disposed && setSize()) fitAgain();\n });\n\n if (setSize()) fitAgain();\n observer.observe(container);\n invalidate();\n\n return {\n canvas,\n setContent(next: PictureContent<P, T>): void {\n if (disposed || next === content) return;\n content.dispose?.();\n content = next;\n const selected = highlights.selected !== undefined && content.has(highlights.selected) ? highlights.selected : undefined;\n highlights = { ...highlights, hovered: undefined, selected };\n settle = true;\n setCursor();\n setArea();\n if (moved) hold(move?.to ?? view);\n else goTo(aim, false);\n },\n setTheme(next: T): void {\n theme = next;\n invalidate();\n },\n setView(next: string | PictureAim, animate: boolean = true): void {\n goTo(next, animate);\n },\n setInsets(next: Partial<Insets>): void {\n insets = next;\n setArea();\n if (!sized) return;\n if (moved) hold(move?.to ?? view);\n else goTo(aim, true);\n },\n view: () => view,\n area: () => area,\n zoomBy(factor: number, animate: boolean = true): void {\n moved = true;\n // A second step of a button starts from the goal of the first step, so each step has its full factor.\n glide(keepRect(zoomView(move?.to ?? view, middleOf(area), factor, limits), content.bounds, area), animate);\n },\n highlight(records: readonly string[]): void {\n highlights = { ...highlights, highlighted: new Set(records) };\n invalidate();\n },\n select(record: string | undefined): void {\n highlights = { ...highlights, selected: record };\n invalidate();\n },\n refresh: invalidate,\n dispose(): void {\n if (disposed) return;\n disposed = true;\n cancelAnimationFrame(frame);\n observer.disconnect();\n listeners.abort();\n content.dispose?.();\n canvas.remove();\n },\n };\n}\n"],"mappings":";;;AAuBA,MAAa,cAA0B;CAAE,KAAK;CAAM,KAAK;AAAE;;AAG3D,MAAa,YAAyB;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;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,WAAW;EACb;EACA,OAAO,QAAkC;GACvC,aAAa;IAAE,GAAG;IAAY,UAAU;GAAO;GAC/C,WAAW;EACb;EACA,SAAS;EACT,UAAgB;GACd,IAAI,UAAU;GACd,WAAW;GACX,qBAAqB,KAAK;GAC1B,SAAS,WAAW;GACpB,UAAU,MAAM;GAChB,QAAQ,UAAU;GAClB,OAAO,OAAO;EAChB;CACF;AACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** The highlight of a record. 0 is no highlight. 1 is a record under the pointer or in the highlighted list. 2 is the selected record. */
|
|
2
|
+
type Highlight = 0 | 1 | 2;
|
|
3
|
+
/** The records of a stage that have a highlight. Each record has a name. */
|
|
4
|
+
interface Highlights {
|
|
5
|
+
/** The name of the record under the pointer. */
|
|
6
|
+
readonly hovered: string | undefined;
|
|
7
|
+
/** The name of the selected record. */
|
|
8
|
+
readonly selected: string | undefined;
|
|
9
|
+
/** The names of the records that the page highlights. */
|
|
10
|
+
readonly highlighted: ReadonlySet<string>;
|
|
11
|
+
}
|
|
12
|
+
/** The highlights of a stage with no pointer on it and no selected record. */
|
|
13
|
+
declare const NO_HIGHLIGHTS: Highlights;
|
|
14
|
+
/** This function gives the highlight of a record. The selected record has the highest highlight. */
|
|
15
|
+
declare function highlightOf(highlights: Highlights, record: string): Highlight;
|
|
16
|
+
/** A pointer that moves this distance or less between down and up makes a click, in CSS pixels. */
|
|
17
|
+
declare const CLICK_DISTANCE = 4;
|
|
18
|
+
/**
|
|
19
|
+
* This function tells if a pointer that went down and up made a click. A pointer that moved more than `limit` made a drag.
|
|
20
|
+
* The positions and the limit are in CSS pixels.
|
|
21
|
+
*/
|
|
22
|
+
declare function isClick(down: {
|
|
23
|
+
readonly x: number;
|
|
24
|
+
readonly y: number;
|
|
25
|
+
}, up: {
|
|
26
|
+
readonly x: number;
|
|
27
|
+
readonly y: number;
|
|
28
|
+
}, limit?: number): boolean;
|
|
29
|
+
export { highlightOf as a, NO_HIGHLIGHTS as i, Highlight as n, isClick as o, Highlights as r, CLICK_DISTANCE as t };
|
|
30
|
+
//# sourceMappingURL=highlight-BJ6xGp6V.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlight-BJ6xGp6V.d.ts","names":[],"sources":["../src/highlight.ts"],"mappings":";KACY;;UAGK;;WAEN;;WAEA;;WAEA,aAAa;;;cAIX,eAAe;;iBAGZ,YAAY,YAAY,YAAY,iBAAiB;;cAMxD;;;;;iBAMG,QAAQ;WAAiB;WAAoB;GAAa;WAAe;WAAoB;GAAa"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as placeBetween, D as viewAxes, E as turnBetween, O as viewOf, S as fitDistance, T as turnAcross, _ as ViewAngles, a as StageView, b as capDistance, c as capView, d as reachOf, f as stageLimits, g as PlaceLimits, h as Place, i as StageLimits, l as fitView, m as FIELD_OF_VIEW, n as FIT_MARGIN, o as ViewFrame, p as surfaceOf, r as StageExtent, s as ballView, t as StageTheme, u as nearDepth, v as ViewAxes, w as speedAt, x as clampPlace, y as cameraPosition } from "./theme-DBbBlCbC.js";
|
|
2
|
+
import { a as highlightOf, i as NO_HIGHLIGHTS, n as Highlight, o as isClick, r as Highlights, t as CLICK_DISTANCE } from "./highlight-BJ6xGp6V.js";
|
|
2
3
|
import { C as spanPart, S as spanOfTimes, _ as replayPause, a as REPLAY_STEP, b as replaySpan, c as changeAfter, d as changeTimes, f as isLive, g as replayOf, h as replayNextSpeed, i as REPLAY_SPEEDS, l as changeBefore, m as replayKey, n as REPLAY_DURATION, o as Replay, p as replayAdvance, r as REPLAY_PAGE, s as TimeSpan, t as Lifetime, u as changeIndex, v as replayPlay, w as spanTime, x as replayToggle, y as replaySeek } from "./replay-DvGYPe7T.js";
|
|
3
4
|
import { Point, Point3 } from "@mark1russell7/layout-contract";
|
|
4
5
|
/** The largest angle of one step of an arrow key, in radians. A camera far from a ball, or with no ball, turns by this angle. */
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/keys.ts","../src/motion.ts","../src/screen.ts","../src/support.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/keys.ts","../src/motion.ts","../src/screen.ts","../src/support.ts"],"mappings":";;;;;qBAGa;;qBAGA;;qBAGA;;KAGD;WAAuB;WAAwB,OAAO;;WAAqB;WAAuB;;;UAG7F;;WAEN;;WAEA,QAAQ,SAAS;;WAEjB;;WAEA;;;;;;;;;;wBAWK,UAAU,aAAa,KAAK,OAAO,SAAS,aAAa;;UC/BxD;WACN,MAAM;WACN,IAAI;;WAEJ;;WAEA;;;UAIM;WACN,OAAO;;WAEP;;;;;;wBAeK,UAAU;;;;;wBAiBV,OAAO,MAAM,MAAM,aAAa,mBAAsB;;;;;;;wBAYtD,SAAS,eAAe,cAAc,iBAAiB,cAAc;;;;;;;;;;wBC5CrE,YAAY,OAAO,QAAQ,MAAM,mBAAmB,YAAY,mBAAmB,eAAe,iBAAiB;;;;;;;;;;wBCPnH,eAAe,OAAM"}
|
package/build/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as nearDepth, c as surfaceOf, i as fitView, n as ballView, o as reachOf, r as capView, s as stageLimits, t as FIT_MARGIN } from "./extent-D2SsHJnP.js";
|
|
2
|
-
import {
|
|
2
|
+
import { c as highlightOf, d as KEY_TURN, f as KEY_ZOOM, i as moveAt, l as isClick, n as easeInOut, o as CLICK_DISTANCE, p as keyAction, s as NO_HIGHLIGHTS, t as approach, u as KEY_PART } from "./motion-VS13e4Pw.js";
|
|
3
3
|
import { _ as replaySpan, a as changeAfter, b as spanPart, c as changeTimes, d as replayKey, f as replayNextSpeed, g as replaySeek, h as replayPlay, i as REPLAY_STEP, l as isLive, m as replayPause, n as REPLAY_PAGE, o as changeBefore, p as replayOf, r as REPLAY_SPEEDS, s as changeIndex, t as REPLAY_DURATION, u as replayAdvance, v as replayToggle, x as spanTime, y as spanOfTimes } from "./replay-YdWMyFko.js";
|
|
4
4
|
import { t as screenPoint } from "./screen-DeOx4_90.js";
|
|
5
5
|
import { a as fitDistance, c as turnAcross, d as viewOf, i as clampPlace, l as turnBetween, n as cameraPosition, o as placeBetween, r as capDistance, s as speedAt, t as FIELD_OF_VIEW, u as viewAxes } from "./view-BB_EQx3I.js";
|
package/build/labels.d.ts
CHANGED
package/build/markers.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { s as Mark, y as Level } from "./mark-ubn709Qw.js";
|
|
2
|
-
import { r as StageContent } from "./stage-
|
|
3
|
-
import { t as StageTheme } from "./theme-
|
|
2
|
+
import { r as StageContent } from "./stage-D8JVM6wZ.js";
|
|
3
|
+
import { t as StageTheme } from "./theme-DBbBlCbC.js";
|
|
4
4
|
/** The colors of the marks of a stage. Each color is a CSS hex color, for example `#22364a`. */
|
|
5
5
|
interface MarkersTheme extends StageTheme {
|
|
6
6
|
/** The color of the marks of each level. */
|
|
@@ -96,6 +96,10 @@ function isClick(down, up, limit = 4) {
|
|
|
96
96
|
return Math.hypot(up.x - down.x, up.y - down.y) <= limit;
|
|
97
97
|
}
|
|
98
98
|
// src/motion.ts
|
|
99
|
+
/** This function tells if the person asks for less motion. A program with no browser gets false. */
|
|
100
|
+
function lessMotion() {
|
|
101
|
+
return typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
102
|
+
}
|
|
99
103
|
/**
|
|
100
104
|
* This function gives a part of a move with a slow start and a slow end. `part` goes from 0 to 1.
|
|
101
105
|
* The result goes from 0 to 1, and it is 0.5 at the middle.
|
|
@@ -105,11 +109,18 @@ function easeInOut(part) {
|
|
|
105
109
|
return clamped < .5 ? 4 * clamped * clamped * clamped : 1 - (-2 * clamped + 2) ** 3 / 2;
|
|
106
110
|
}
|
|
107
111
|
/**
|
|
112
|
+
* This function gives the part of a move that is complete at the time `now`, from 0 to 1.
|
|
113
|
+
* `start` is the time of the start of the move, and `duration` is the time that it takes. A move with no duration is complete.
|
|
114
|
+
*/
|
|
115
|
+
function partAt(start, duration, now) {
|
|
116
|
+
return duration > 0 ? Math.min(Math.max((now - start) / duration, 0), 1) : 1;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
108
119
|
* This function gives the place of a camera at the time `now` of a move, in milliseconds.
|
|
109
120
|
* A move with no duration is at its end immediately. `surface` is the radius of the ball around the target, or 0 for no ball.
|
|
110
121
|
*/
|
|
111
122
|
function moveAt(move, now, surface = 0) {
|
|
112
|
-
const part =
|
|
123
|
+
const part = partAt(move.start, move.duration, now);
|
|
113
124
|
if (part >= 1) return {
|
|
114
125
|
place: move.to,
|
|
115
126
|
done: true
|
|
@@ -130,6 +141,6 @@ function approach(value, goal, seconds, time, snap = .01) {
|
|
|
130
141
|
const next = value + (goal - value) * (1 - Math.exp(0 - seconds / time));
|
|
131
142
|
return Math.abs(goal - next) < snap ? goal : next;
|
|
132
143
|
}
|
|
133
|
-
export {
|
|
144
|
+
export { partAt as a, highlightOf as c, KEY_TURN as d, KEY_ZOOM as f, moveAt as i, isClick as l, easeInOut as n, CLICK_DISTANCE as o, keyAction as p, lessMotion as r, NO_HIGHLIGHTS as s, approach as t, KEY_PART as u };
|
|
134
145
|
|
|
135
|
-
//# sourceMappingURL=motion-
|
|
146
|
+
//# sourceMappingURL=motion-VS13e4Pw.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motion-
|
|
1
|
+
{"version":3,"file":"motion-VS13e4Pw.js","names":[],"sources":["../src/keys.ts","../src/highlight.ts","../src/motion.ts"],"sourcesContent":["import { FIELD_OF_VIEW, turnAcross, type Place } from \"./view.ts\";\n\n/** The largest angle of one step of an arrow key, in radians. A camera far from a ball, or with no ball, turns by this angle. */\nexport const KEY_TURN: number = Math.PI / 24;\n\n/** The part of the height of the picture by which one step of an arrow key moves the surface of a ball, near the ball. */\nexport const KEY_PART = 0.125;\n\n/** The factor of the height of a camera above the surface for one step of the key `+`. */\nexport const KEY_ZOOM = 0.85;\n\n/** What a key does on a stage: it moves the camera to a place, or it shows a view. */\nexport type KeyAction = { readonly type: \"place\"; readonly place: Place } | { readonly type: \"view\"; readonly view: string };\n\n/** The keys of a stage. */\nexport interface KeyOptions {\n /** The name of the view of the keys `Home` and `0`. */\n readonly home: string;\n /** The name of the view of each other key, for example `{ t: \"top\" }`. A letter has no case. */\n readonly views?: Readonly<Record<string, string>> | undefined;\n /** The radius of the ball around the target that the camera stays out of, or 0 for no ball. */\n readonly surface?: number | undefined;\n /** The vertical angle of the picture, in degrees. The default is `FIELD_OF_VIEW`. */\n readonly fieldOfView?: number | undefined;\n}\n\n/**\n * This function gives the action of a key on a stage, or `undefined` for a key with no action.\n *\n * The arrow keys turn the camera around the target. The keys `+` and `-` change the height above the surface.\n * The keys `Home` and `0` show the home view.\n * Near a ball, a step of an arrow key moves the surface by the part `KEY_PART` of the height of the picture.\n * The result has no limits: the stage puts the place in its limits.\n */\nexport function keyAction(key: string, now: Place, options: KeyOptions): KeyAction | undefined {\n const surface = options.surface ?? 0;\n const turn = Math.min(KEY_TURN, KEY_PART * turnAcross(now.distance, surface, options.fieldOfView ?? FIELD_OF_VIEW));\n const zoom = (factor: number): Place => ({ ...now, distance: surface + (now.distance - surface) * factor });\n switch (key) {\n case \"ArrowLeft\":\n return { type: \"place\", place: { ...now, azimuth: now.azimuth - turn } };\n case \"ArrowRight\":\n return { type: \"place\", place: { ...now, azimuth: now.azimuth + turn } };\n case \"ArrowUp\":\n return { type: \"place\", place: { ...now, polar: now.polar - turn } };\n case \"ArrowDown\":\n return { type: \"place\", place: { ...now, polar: now.polar + turn } };\n case \"+\":\n case \"=\":\n return { type: \"place\", place: zoom(KEY_ZOOM) };\n case \"-\":\n case \"_\":\n return { type: \"place\", place: zoom(1 / KEY_ZOOM) };\n case \"Home\":\n case \"0\":\n return { type: \"view\", view: options.home };\n default: {\n const view = key.length === 1 ? options.views?.[key.toLowerCase()] : undefined;\n return view === undefined ? undefined : { type: \"view\", view };\n }\n }\n}\n","/** The highlight of a record. 0 is no highlight. 1 is a record under the pointer or in the highlighted list. 2 is the selected record. */\nexport type Highlight = 0 | 1 | 2;\n\n/** The records of a stage that have a highlight. Each record has a name. */\nexport interface Highlights {\n /** The name of the record under the pointer. */\n readonly hovered: string | undefined;\n /** The name of the selected record. */\n readonly selected: string | undefined;\n /** The names of the records that the page highlights. */\n readonly highlighted: ReadonlySet<string>;\n}\n\n/** The highlights of a stage with no pointer on it and no selected record. */\nexport const NO_HIGHLIGHTS: Highlights = { hovered: undefined, selected: undefined, highlighted: new Set() };\n\n/** This function gives the highlight of a record. The selected record has the highest highlight. */\nexport function highlightOf(highlights: Highlights, record: string): Highlight {\n if (record === highlights.selected) return 2;\n return record === highlights.hovered || highlights.highlighted.has(record) ? 1 : 0;\n}\n\n/** A pointer that moves this distance or less between down and up makes a click, in CSS pixels. */\nexport const CLICK_DISTANCE = 4;\n\n/**\n * This function tells if a pointer that went down and up made a click. A pointer that moved more than `limit` made a drag.\n * The positions and the limit are in CSS pixels.\n */\nexport function isClick(down: { readonly x: number; readonly y: number }, up: { readonly x: number; readonly y: number }, limit: number = CLICK_DISTANCE): boolean {\n return Math.hypot(up.x - down.x, up.y - down.y) <= limit;\n}\n","import { placeBetween, type Place } from \"./view.ts\";\n\n/** A move of a camera from one place to a different place. */\nexport interface Move {\n readonly from: Place;\n readonly to: Place;\n /** The time of the start of the move, in milliseconds. */\n readonly start: number;\n /** The time that the move takes, in milliseconds. */\n readonly duration: number;\n}\n\n/** The place of a camera at one time of a move. */\nexport interface MoveStep {\n readonly place: Place;\n /** This value is true at the end of the move, and after it. */\n readonly done: boolean;\n}\n\n/** The time of the move of a camera between two views, in milliseconds. */\nexport const MOVE_TIME = 380;\n\n/** This function tells if the person asks for less motion. A program with no browser gets false. */\nexport function lessMotion(): boolean {\n return typeof matchMedia === \"function\" && matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n}\n\n/**\n * This function gives a part of a move with a slow start and a slow end. `part` goes from 0 to 1.\n * The result goes from 0 to 1, and it is 0.5 at the middle.\n */\nexport function easeInOut(part: number): number {\n const clamped = Math.min(Math.max(part, 0), 1);\n return clamped < 0.5 ? 4 * clamped * clamped * clamped : 1 - (-2 * clamped + 2) ** 3 / 2;\n}\n\n/**\n * This function gives the part of a move that is complete at the time `now`, from 0 to 1.\n * `start` is the time of the start of the move, and `duration` is the time that it takes. A move with no duration is complete.\n */\nexport function partAt(start: number, duration: number, now: number): number {\n return duration > 0 ? Math.min(Math.max((now - start) / duration, 0), 1) : 1;\n}\n\n/**\n * This function gives the place of a camera at the time `now` of a move, in milliseconds.\n * A move with no duration is at its end immediately. `surface` is the radius of the ball around the target, or 0 for no ball.\n */\nexport function moveAt(move: Move, now: number, surface: number = 0): MoveStep {\n const part = partAt(move.start, move.duration, now);\n if (part >= 1) return { place: move.to, done: true };\n return { place: placeBetween(move.from, move.to, easeInOut(part), surface), done: false };\n}\n\n/**\n * This function moves a value one step to its goal. Each step goes a constant part of the way that remains.\n *\n * `seconds` is the time of the step, and `time` is the time in which the value goes most of the way, in seconds.\n * A step with no time gives the goal. A value nearer to the goal than `snap` becomes the goal, so the steps have an end.\n */\nexport function approach(value: number, goal: number, seconds: number, time: number, snap: number = 0.01): number {\n if (!(seconds > 0) || !(time > 0)) return goal;\n const next = value + (goal - value) * (1 - Math.exp(0 - seconds / time));\n return Math.abs(goal - next) < snap ? goal : next;\n}\n"],"mappings":";;;AAGA,MAAa,WAAmB,KAAK,KAAK;;AAG1C,MAAa,WAAW;;AAGxB,MAAa,WAAW;;;;;;;;;AAyBxB,SAAgB,UAAU,KAAa,KAAY,SAA4C;CAC7F,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,OAAO,KAAK,IAAI,UAAU,WAAW,WAAW,IAAI,UAAU,SAAS,QAAQ,eAAA,EAA4B,CAAC;CAClH,MAAM,QAAQ,YAA2B;EAAE,GAAG;EAAK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;AACrD;;;ACRA,SAAgB,aAAsB;CACpC,OAAO,OAAO,eAAe,cAAc,WAAW,kCAAkC,CAAC,CAAC;AAC5F;;;;;AAMA,SAAgB,UAAU,MAAsB;CAC9C,MAAM,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,CAAC,GAAG,CAAC;CAC7C,OAAO,UAAU,KAAM,IAAI,UAAU,UAAU,UAAU,KAAK,KAAK,UAAU,MAAM,IAAI;AACzF;;;;;AAMA,SAAgB,OAAO,OAAe,UAAkB,KAAqB;CAC3E,OAAO,WAAW,IAAI,KAAK,IAAI,KAAK,KAAK,MAAM,SAAS,UAAU,CAAC,GAAG,CAAC,IAAI;AAC7E;;;;;AAMA,SAAgB,OAAO,MAAY,KAAa,UAAkB,GAAa;CAC7E,MAAM,OAAO,OAAO,KAAK,OAAO,KAAK,UAAU,GAAG;CAClD,IAAI,QAAQ,GAAG,OAAO;EAAE,OAAO,KAAK;EAAI,MAAM;CAAK;CACnD,OAAO;EAAE,OAAO,aAAa,KAAK,MAAM,KAAK,IAAI,UAAU,IAAI,GAAG,OAAO;EAAG,MAAM;CAAM;AAC1F;;;;;;;AAQA,SAAgB,SAAS,OAAe,MAAc,SAAiB,MAAc,OAAe,KAAc;CAChH,IAAI,EAAE,UAAU,MAAM,EAAE,OAAO,IAAI,OAAO;CAC1C,MAAM,OAAO,SAAS,OAAO,UAAU,IAAI,KAAK,IAAI,IAAI,UAAU,IAAI;CACtE,OAAO,KAAK,IAAI,OAAO,IAAI,IAAI,OAAO,OAAO;AAC/C"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as StageView, h as Place, r as StageExtent, t as StageTheme } from "./theme-DBbBlCbC.js";
|
|
2
|
+
import { n as Highlight } from "./highlight-BJ6xGp6V.js";
|
|
2
3
|
import { Object3D, PerspectiveCamera, Raycaster } from "three";
|
|
3
4
|
/** The record under the pointer: its name, and the value that the content gives for it. */
|
|
4
5
|
interface StagePick<P> {
|
|
@@ -126,4 +127,4 @@ declare const STAGE_LIGHTS: StageLights;
|
|
|
126
127
|
*/
|
|
127
128
|
declare function createStage<P, T extends StageTheme = StageTheme>(container: HTMLElement, options: StageOptions<P, T>): Stage<P, T> | undefined;
|
|
128
129
|
export { StageLights as a, createStage as c, StageFrame as i, Stage as n, StageOptions as o, StageContent as r, StagePick as s, STAGE_LIGHTS as t };
|
|
129
|
-
//# sourceMappingURL=stage-
|
|
130
|
+
//# sourceMappingURL=stage-D8JVM6wZ.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stage-D8JVM6wZ.d.ts","names":[],"sources":["../src/stage/stage.ts"],"mappings":";;;;UAYiB,UAAU;;WAEhB;;WAEA,OAAO;;;;;WAKP;;;UAIM;WACN,QAAQ;;WAER;;;;;WAKA;;WAEA;;WAEA;;;;;;UAOM,aAAa,GAAG,UAAU,aAAa;;WAE7C,kBAAkB;;WAElB,QAAQ;;EAEjB,IAAI;;EAEJ,KAAK,KAAK,YAAY,UAAU;;EAEhC,MAAM,OAAO,GAAG,YAAY,mBAAmB;;;;;EAK/C,MAAM,OAAO;;EAEb;;;UAIe;;WAEN;;WAEA;;WAEA;aAAiB;aAAoB;aAAoB;;;;UAInD,aAAa,GAAG,UAAU,aAAa;;WAE7C,SAAS,aAAa,GAAG;WACzB,OAAO;;WAEP;;WAEA,OAAO,SAAS,eAAe;;WAE/B;;WAEA,OAAO,SAAS;;WAEhB;;WAEA;aAAmB;aAAmC;;;WAEtD;WACA,SAAS;;WAET,YAAY,MAAM;;WAElB,aAAa,MAAM;;;UAIb,MAAM,GAAG,UAAU,aAAa;;WAEtC,QAAQ;;EAEjB,WAAW,SAAS,aAAa,GAAG;;EAEpC,SAAS,OAAO;;EAEhB,QAAQ,eAAe,WAAW;;EAElC,SAAS;;EAET,UAAU;;EAEV,OAAO;;EAEP;;EAEA;;;cAIW,cAAc;;;;;;;;;;;iBAwBX,YAAY,GAAG,UAAU,aAAa,YAAY,WAAW,aAAa,SAAS,aAAa,GAAG,KAAK,MAAM,GAAG"}
|
|
@@ -167,34 +167,6 @@ declare function stageLimits(frame: ViewFrame, views: readonly StageView[], pola
|
|
|
167
167
|
readonly min: number;
|
|
168
168
|
readonly max: number;
|
|
169
169
|
}): StageLimits;
|
|
170
|
-
/** The highlight of a record. 0 is no highlight. 1 is a record under the pointer or in the highlighted list. 2 is the selected record. */
|
|
171
|
-
type Highlight = 0 | 1 | 2;
|
|
172
|
-
/** The records of a stage that have a highlight. Each record has a name. */
|
|
173
|
-
interface Highlights {
|
|
174
|
-
/** The name of the record under the pointer. */
|
|
175
|
-
readonly hovered: string | undefined;
|
|
176
|
-
/** The name of the selected record. */
|
|
177
|
-
readonly selected: string | undefined;
|
|
178
|
-
/** The names of the records that the page highlights. */
|
|
179
|
-
readonly highlighted: ReadonlySet<string>;
|
|
180
|
-
}
|
|
181
|
-
/** The highlights of a stage with no pointer on it and no selected record. */
|
|
182
|
-
declare const NO_HIGHLIGHTS: Highlights;
|
|
183
|
-
/** This function gives the highlight of a record. The selected record has the highest highlight. */
|
|
184
|
-
declare function highlightOf(highlights: Highlights, record: string): Highlight;
|
|
185
|
-
/** A pointer that moves this distance or less between down and up makes a click, in CSS pixels. */
|
|
186
|
-
declare const CLICK_DISTANCE = 4;
|
|
187
|
-
/**
|
|
188
|
-
* This function tells if a pointer that went down and up made a click. A pointer that moved more than `limit` made a drag.
|
|
189
|
-
* The positions and the limit are in CSS pixels.
|
|
190
|
-
*/
|
|
191
|
-
declare function isClick(down: {
|
|
192
|
-
readonly x: number;
|
|
193
|
-
readonly y: number;
|
|
194
|
-
}, up: {
|
|
195
|
-
readonly x: number;
|
|
196
|
-
readonly y: number;
|
|
197
|
-
}, limit?: number): boolean;
|
|
198
170
|
/**
|
|
199
171
|
* The colors that each stage uses. Each color is a CSS hex color, for example `#22364a`.
|
|
200
172
|
* A stage has no background: the page shows behind the content. The theme of a content adds its own colors.
|
|
@@ -205,5 +177,5 @@ interface StageTheme {
|
|
|
205
177
|
/** The color of the light from below. */
|
|
206
178
|
readonly ground: string;
|
|
207
179
|
}
|
|
208
|
-
export {
|
|
209
|
-
//# sourceMappingURL=theme-
|
|
180
|
+
export { placeBetween as C, viewAxes as D, turnBetween as E, viewOf as O, fitDistance as S, turnAcross as T, ViewAngles as _, StageView as a, capDistance as b, capView as c, reachOf as d, stageLimits as f, PlaceLimits as g, Place as h, StageLimits as i, fitView as l, FIELD_OF_VIEW as m, FIT_MARGIN as n, ViewFrame as o, surfaceOf as p, StageExtent as r, ballView as s, StageTheme as t, nearDepth as u, ViewAxes as v, speedAt as w, clampPlace as x, cameraPosition as y };
|
|
181
|
+
//# sourceMappingURL=theme-DBbBlCbC.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-DBbBlCbC.d.ts","names":[],"sources":["../src/view.ts","../src/extent.ts","../src/theme.ts"],"mappings":";;;;;UAMiB;;WAEN;;WAEA;;;UAIM,cAAc;WACpB,QAAQ;WACR;;;UAIM;;WAEN,MAAM;;WAEN,OAAO;;WAEP,IAAI;;;UAIE;;WAEN;;WAEA;;WAEA;;WAEA;;;iBAIK,SAAS,MAAM,aAAa;;;;;;;;iBAwB5B,YAAY,iBAAiB,UAAU,QAAQ,QAAQ,MAAM,YAAY,aAAa;;;;;;;;;iBAsBtF,YAAY,gBAAgB,eAAe,aAAa;;iBAaxD,eAAe,QAAQ,QAAQ,MAAM,YAAY,mBAAmB;;iBAMpE,OAAO,QAAQ,QAAQ,QAAQ,SAAS;WAAwB;;;iBAUhE,YAAY,cAAc;;iBAO1B,WAAW,OAAO,OAAO,QAAQ,cAAc;;;;;;;;iBAgB/C,QAAQ,kBAAkB;;cAM7B;;;;;;;;;;;;;iBAiBG,WAAW,kBAAkB,iBAAiB;;;;;;;iBAe9C,aAAa,MAAM,OAAO,IAAI,OAAO,cAAc,mBAAsB;;UC9KxE;;WAEN,kBAAkB;;WAElB,QAAQ;;;;;WAKR;;WAEA;;WAEA;;;UAIM;WACN,QAAQ;;WAER;;WAEA;;;KAIC,aAAa,OAAO,cAAc;;UAG7B,oBAAoB;WAC1B;WACA;;;cAIE;;iBAGG,UAAU,QAAQ;;;;;iBASlB,QAAQ,QAAQ,YAAY,kBAA8B;;;;;;;iBAa1D,QAAQ,QAAQ,YAAY,eAAe,kBAA8B;;;;;;;;iBAezE,SAAS,iBAAiB,UAAU,kBAA8B;;iBAsClE,QAAQ,QAAQ;;;;;;;iBAYhB,UAAU,QAAQ,aAAa,QAAQ,aAAa;;;;;;;iBAWpD,YAAY,OAAO,WAAW,gBAAgB,aAAa;WAAkB;WAAsB;IAAgB;;;;;UCxIlH;;WAEN;;WAEA"}
|
package/build/three.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as StageLights, c as createStage, i as StageFrame, n as Stage, o as StageOptions, r as StageContent, s as StagePick, t as STAGE_LIGHTS } from "./stage-
|
|
2
|
-
import {
|
|
1
|
+
import { a as StageLights, c as createStage, i as StageFrame, n as Stage, o as StageOptions, r as StageContent, s as StagePick, t as STAGE_LIGHTS } from "./stage-D8JVM6wZ.js";
|
|
2
|
+
import { m as FIELD_OF_VIEW, t as StageTheme } from "./theme-DBbBlCbC.js";
|
|
3
3
|
/**
|
|
4
4
|
* This function makes one content from a list of contents, for a stage that shows them together.
|
|
5
5
|
* An example is a globe with a layer of labels, or a room with its marks.
|
package/build/three.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as nearDepth, c as surfaceOf, s as stageLimits } from "./extent-D2SsHJnP.js";
|
|
2
|
-
import {
|
|
2
|
+
import { c as highlightOf, i as moveAt, l as isClick, p as keyAction, r as lessMotion, s as NO_HIGHLIGHTS } from "./motion-VS13e4Pw.js";
|
|
3
3
|
import { c as turnAcross, d as viewOf, i as clampPlace, n as cameraPosition, s as speedAt, t as FIELD_OF_VIEW } from "./view-BB_EQx3I.js";
|
|
4
4
|
import { DirectionalLight, HemisphereLight, PerspectiveCamera, Raycaster, Scene, Vector2, WebGLRenderer } from "three";
|
|
5
5
|
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
|
|
@@ -14,8 +14,6 @@ const STAGE_LIGHTS = {
|
|
|
14
14
|
z: 15
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
-
/** The time of the move between two views, in milliseconds. */
|
|
18
|
-
const MOVE_TIME = 380;
|
|
19
17
|
/**
|
|
20
18
|
* The largest turn of the camera for a drag across the height of the picture, as a part of a full turn.
|
|
21
19
|
* A camera far from a ball, or with no ball, turns by this part.
|
|
@@ -25,10 +23,6 @@ const TURN_SPEED = .9;
|
|
|
25
23
|
const SMALLEST_POLAR = 5e-4;
|
|
26
24
|
/** The default largest polar angle: the camera stays above the plane of the target. */
|
|
27
25
|
const LARGEST_POLAR = Math.PI / 2 - .05;
|
|
28
|
-
/** This function tells if the person asks for less motion. */
|
|
29
|
-
function lessMotion() {
|
|
30
|
-
return typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
31
|
-
}
|
|
32
26
|
/**
|
|
33
27
|
* This function makes a stage in a container of a page. The stage fills the container, so give the container a size.
|
|
34
28
|
*
|
|
@@ -195,7 +189,7 @@ function createStage(container, options) {
|
|
|
195
189
|
from: placeNow(),
|
|
196
190
|
to,
|
|
197
191
|
start: performance.now(),
|
|
198
|
-
duration:
|
|
192
|
+
duration: 380
|
|
199
193
|
};
|
|
200
194
|
else {
|
|
201
195
|
move = void 0;
|
package/build/three.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"three.js","names":["World"],"sources":["../src/stage/stage.ts","../src/stage/stack.ts"],"sourcesContent":["import { DirectionalLight, HemisphereLight, PerspectiveCamera, Raycaster, Scene as World, Vector2, WebGLRenderer, type Object3D } from \"three\";\nimport { OrbitControls } from \"three/addons/controls/OrbitControls.js\";\nimport { nearDepth, stageLimits, surfaceOf, type StageExtent, type StageLimits, type StageView, type ViewFrame } from \"../extent.ts\";\nimport { keyAction } from \"../keys.ts\";\nimport { isClick, highlightOf, NO_HIGHLIGHTS, type Highlight, type Highlights } from \"../highlight.ts\";\nimport { moveAt, type Move } from \"../motion.ts\";\nimport type { StageTheme } from \"../theme.ts\";\nimport { cameraPosition, clampPlace, FIELD_OF_VIEW, speedAt, turnAcross, viewOf, type Place } from \"../view.ts\";\n\nexport { FIELD_OF_VIEW };\n\n/** The record under the pointer: its name, and the value that the content gives for it. */\nexport interface StagePick<P> {\n /** The name of the record. The highlights of the stage use this name. */\n readonly record: string;\n /** The value of the record for the page, for example its kind and its source. */\n readonly value: P;\n /**\n * The distance from the start of the ray to the record, in the unit of the space.\n * A stack of contents uses it to find the nearest record. A pick with no distance is above each other record.\n */\n readonly distance?: number | undefined;\n}\n\n/** One picture of a stage, for the step of its content. */\nexport interface StageFrame {\n readonly camera: PerspectiveCamera;\n /** The time since the last picture, in seconds. */\n readonly seconds: number;\n /**\n * This value is true for the first picture of a content, and for a person who asks for less motion.\n * Each change then has no time: the content sets each value to its goal immediately.\n */\n readonly settle: boolean;\n /** The height of the picture, in CSS pixels. */\n readonly height: number;\n /** The vertical angle of the picture, in degrees. */\n readonly fieldOfView: number;\n}\n\n/**\n * The content of a stage: the three.js objects of one scene, and what the stage asks of them.\n * `P` is the type of the value of a pick, and `T` is the type of the theme.\n */\nexport interface StageContent<P, T extends StageTheme = StageTheme> {\n /** The three.js objects of the content. The stage adds them to its world, and removes them. */\n readonly objects: readonly Object3D[];\n /** The space that the content fills. */\n readonly extent: StageExtent;\n /** This function tells if the content has a record with a name. */\n has(record: string): boolean;\n /** This function gives the record that a ray from the camera finds first, or `undefined` for no record. */\n pick(ray: Raycaster): StagePick<P> | undefined;\n /** This function gives each part its colors, from the theme and the highlight of its record. */\n paint(theme: T, highlight: (record: string) => Highlight): void;\n /**\n * This function changes the parts that depend on the camera or on the time, before each picture.\n * It gives true while a part continues to change. The stage then makes the next picture.\n */\n step?(frame: StageFrame): boolean;\n /** This function releases the memory of the graphics card that the content uses. */\n dispose(): void;\n}\n\n/** The lights of a stage. A content with materials that use no light ignores them. */\nexport interface StageLights {\n /** The strength of the light from above and below. */\n readonly sky: number;\n /** The strength of the light from one direction. */\n readonly sun: number;\n /** The position that the light from one direction comes from. */\n readonly from: { readonly x: number; readonly y: number; readonly z: number };\n}\n\n/** The options of a stage. */\nexport interface StageOptions<P, T extends StageTheme = StageTheme> {\n /** The first content. The stage disposes each content that it gets. */\n readonly content: StageContent<P, T>;\n readonly theme: T;\n /** The name of the picture for a screen reader. */\n readonly label: string;\n /** The views of the stage, each with a name. */\n readonly views: Readonly<Record<string, StageView>>;\n /** The name of the first view. The keys `Home` and `0` show it. */\n readonly home: string;\n /** The name of the view of a key, for example `{ t: \"top\" }`. A letter has no case. */\n readonly keys?: Readonly<Record<string, string>> | undefined;\n /** The vertical angle of the picture, in degrees. A small angle gives the look of a drawing. The default is 32. */\n readonly fieldOfView?: number | undefined;\n /** The smallest and the largest polar angle of the camera, in radians. The default keeps the camera above the plane of the target. */\n readonly polar?: { readonly min?: number | undefined; readonly max?: number | undefined } | undefined;\n /** This value is true if a person can move the target with a drag of the second button. The default is true. */\n readonly pan?: boolean | undefined;\n readonly lights?: StageLights | undefined;\n /** The stage starts this function when the pointer goes to a different record, or to no record. */\n readonly onHover?: ((pick: P | undefined) => void) | undefined;\n /** The stage starts this function when a person selects a record with the pointer, or selects no record. */\n readonly onSelect?: ((pick: P | undefined) => void) | undefined;\n}\n\n/** A stage in a page: one canvas with a camera that a person moves, and one content. */\nexport interface Stage<P, T extends StageTheme = StageTheme> {\n /** The canvas of the stage. It is in the container. */\n readonly canvas: HTMLCanvasElement;\n /** This function shows a different content, and disposes the old content. The view stays if a person moved it. */\n setContent(content: StageContent<P, T>): void;\n /** This function changes the colors. */\n setTheme(theme: T): void;\n /** This function moves the camera to a view: a name of the options, or a view function. `animate` has the default true. */\n setView(view: string | StageView, animate?: boolean): void;\n /** This function gives the place of the camera. */\n place(): Place;\n /** This function highlights records by their names, as the pointer does. An empty list removes the highlights. */\n highlight(records: readonly string[]): void;\n /** This function selects one record by its name, or no record. It does not start `onSelect`. */\n select(record: string | undefined): void;\n /** This function paints the content again and makes a new picture. Use it after a change of the content. */\n refresh(): void;\n /** This function removes the canvas and releases the memory of the graphics card. It disposes the content. */\n dispose(): void;\n}\n\n/** The default lights: a strong light from above and below, and a light from the front left. */\nexport const STAGE_LIGHTS: StageLights = { sky: 2.2, sun: 1.5, from: { x: -10, y: 24, z: 15 } };\n\n/** The time of the move between two views, in milliseconds. */\nconst MOVE_TIME = 380;\n\n/**\n * The largest turn of the camera for a drag across the height of the picture, as a part of a full turn.\n * A camera far from a ball, or with no ball, turns by this part.\n */\nconst TURN_SPEED = 0.9;\n\n/** The smallest polar angle. At 0, the azimuth of a camera has no meaning. */\nconst SMALLEST_POLAR = 0.0005;\n\n/** The default largest polar angle: the camera stays above the plane of the target. */\nconst LARGEST_POLAR = Math.PI / 2 - 0.05;\n\n/** This function tells if the person asks for less motion. */\nfunction lessMotion(): boolean {\n return typeof matchMedia === \"function\" && matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n}\n\n/**\n * This function makes a stage in a container of a page. The stage fills the container, so give the container a size.\n *\n * A person turns the content with a drag, and moves nearer with the wheel after a click in the picture.\n * A click selects the record under the pointer. With the keyboard, the arrow keys turn the content, `+` and `-` change the distance,\n * and `Home` shows the first view. The stage makes a picture only after a change.\n *\n * The function gives `undefined` when the browser has no WebGL 2. It does not throw, and it writes no error to the console.\n * The page then shows a different picture of the same data.\n */\nexport function createStage<P, T extends StageTheme = StageTheme>(container: HTMLElement, options: StageOptions<P, T>): Stage<P, T> | undefined {\n const canvas = container.ownerDocument.createElement(\"canvas\");\n const context = canvas.getContext(\"webgl2\", { alpha: true, antialias: true, depth: true, stencil: false, premultipliedAlpha: true, powerPreference: \"default\" });\n if (context === null) return undefined;\n let renderer: WebGLRenderer;\n try {\n renderer = new WebGLRenderer({ canvas, context, alpha: true, antialias: true });\n } catch {\n return undefined;\n }\n renderer.setClearColor(0x000000, 0);\n\n canvas.style.display = \"block\";\n canvas.style.width = \"100%\";\n canvas.style.height = \"100%\";\n canvas.style.cursor = \"grab\";\n canvas.style.touchAction = \"none\";\n canvas.tabIndex = 0;\n canvas.setAttribute(\"role\", \"application\");\n canvas.setAttribute(\"aria-label\", options.label);\n container.append(canvas);\n\n const fieldOfView = options.fieldOfView ?? FIELD_OF_VIEW;\n const polar = { min: options.polar?.min ?? SMALLEST_POLAR, max: options.polar?.max ?? LARGEST_POLAR };\n const lights = options.lights ?? STAGE_LIGHTS;\n const world = new World();\n const sky = new HemisphereLight(\"#ffffff\", \"#ffffff\", lights.sky);\n const sun = new DirectionalLight(\"#ffffff\", lights.sun);\n sun.position.set(lights.from.x, lights.from.y, lights.from.z);\n world.add(sky, sun);\n const camera = new PerspectiveCamera(fieldOfView, 1, 0.05, 1000);\n\n let content = options.content;\n let theme = options.theme;\n for (const object of content.objects) world.add(object);\n\n let highlights: Highlights = NO_HIGHLIGHTS;\n let view: string | StageView = options.home;\n let move: Move | undefined;\n /** This value is true after a person moved the view. Then a new size of the container does not move the camera. */\n let moved = false;\n /** This value is true until the content had a step with no time. */\n let settle = true;\n /** The height of the picture, in CSS pixels. */\n let height = 1;\n let frame = 0;\n let lastTime = 0;\n let disposed = false;\n\n const invalidate = (): void => {\n if (frame === 0 && !disposed) frame = requestAnimationFrame(tick);\n };\n\n const controls = new OrbitControls(camera, canvas);\n controls.enableDamping = !lessMotion();\n controls.dampingFactor = 0.14;\n controls.minPolarAngle = polar.min;\n controls.maxPolarAngle = polar.max;\n controls.rotateSpeed = TURN_SPEED;\n controls.screenSpacePanning = true;\n controls.enablePan = options.pan ?? true;\n // The wheel moves the page until a person uses the picture. Thus the picture does not stop a person who reads down the page.\n controls.enableZoom = false;\n\n const viewFrame = (): ViewFrame => ({ extent: content.extent, fieldOfView, aspect: camera.aspect });\n let limits: StageLimits = stageLimits(viewFrame(), Object.values(options.views), polar);\n\n const paint = (): void => {\n const now = highlights;\n content.paint(theme, (record) => highlightOf(now, record));\n invalidate();\n };\n\n /**\n * This function sets the turn speed and the zoom speed from the height of the camera above the surface.\n * The surface of a ball at the middle of the picture follows the pointer in a drag.\n */\n const setSpeed = (): void => {\n const distance = camera.position.distanceTo(controls.target);\n const surface = surfaceOf(content.extent);\n // The controls turn the camera by a full turn times the speed for a drag across the height of the picture.\n controls.rotateSpeed = Math.min(TURN_SPEED, turnAcross(distance, surface, fieldOfView) / (2 * Math.PI));\n controls.zoomSpeed = speedAt(distance, surface);\n };\n const placeNow = (): Place => {\n const target = { x: controls.target.x, y: controls.target.y, z: controls.target.z };\n return { target, ...viewOf(camera.position, target) };\n };\n const put = (to: Place): void => {\n const next = clampPlace(to, limits);\n const eye = cameraPosition(next.target, next, next.distance);\n controls.target.set(next.target.x, next.target.y, next.target.z);\n camera.position.set(eye.x, eye.y, eye.z);\n camera.lookAt(controls.target);\n setSpeed();\n };\n /** This function gives the view function of a view, or `undefined` for a name that the options do not have. */\n const viewFunction = (of: string | StageView): StageView | undefined => (typeof of === \"string\" ? options.views[of] : of);\n\n /**\n * This function sets the nearest depth that the camera draws, from the distance of the camera to the content.\n * A camera far from the content then has small steps of depth at the content, so a layer near a surface stays above it.\n */\n const setDepth = (): void => {\n const { center } = content.extent;\n const distance = Math.hypot(camera.position.x - center.x, camera.position.y - center.y, camera.position.z - center.z);\n const near = nearDepth(limits, content.extent, distance);\n if (near === camera.near && limits.far === camera.far) return;\n camera.near = near;\n camera.far = limits.far;\n camera.updateProjectionMatrix();\n };\n /** This function sets the limits of the camera from the content and the shape of the picture. */\n const setLimits = (): void => {\n limits = stageLimits(viewFrame(), Object.values(options.views), polar);\n controls.minDistance = limits.minDistance;\n controls.maxDistance = limits.maxDistance;\n setDepth();\n };\n /**\n * This function stops the turn that continues after a drag. The camera stays where it is.\n * Without it, the camera continues to turn after a move to a view, and the view is not exact.\n */\n const stopDrift = (): void => {\n if (!controls.enableDamping) return;\n const now = placeNow();\n // With no damping, an update of the controls uses all of the turn that remains. The camera then goes back.\n controls.enableDamping = false;\n controls.update();\n controls.enableDamping = true;\n put(now);\n };\n const goTo = (next: string | StageView, animate: boolean): void => {\n const found = viewFunction(next);\n if (found === undefined) return;\n view = next;\n moved = false;\n stopDrift();\n const to = found(viewFrame());\n if (animate && !lessMotion()) {\n move = { from: placeNow(), to, start: performance.now(), duration: MOVE_TIME };\n } else {\n move = undefined;\n put(to);\n }\n invalidate();\n };\n\n /** This function sets the size of the picture from the size of the container. It gives false for a container with no size. */\n const setSize = (): boolean => {\n const width = container.clientWidth;\n const tall = container.clientHeight;\n if (width === 0 || tall === 0) return false;\n height = tall;\n renderer.setPixelRatio(Math.min(globalThis.devicePixelRatio, 2));\n renderer.setSize(width, tall, false);\n camera.aspect = width / tall;\n camera.updateProjectionMatrix();\n return true;\n };\n\n /** This function moves the camera one step of a move between two views. It gives true while the move continues. */\n const stepMove = (now: number): boolean => {\n if (move === undefined) return false;\n const step = moveAt(move, now, surfaceOf(content.extent));\n put(step.place);\n if (step.done) move = undefined;\n return true;\n };\n\n function tick(now: number): void {\n frame = 0;\n if (disposed) return;\n const seconds = lastTime === 0 ? 1 / 60 : Math.min((now - lastTime) / 1000, 0.1);\n let active = stepMove(now);\n setSpeed();\n active = controls.update() || active;\n setDepth();\n const stepped = content.step?.({ camera, seconds, settle: settle || lessMotion(), height, fieldOfView }) ?? false;\n settle = false;\n renderer.render(world, camera);\n active = stepped || active;\n lastTime = active ? now : 0;\n if (active) invalidate();\n }\n\n const raycaster = new Raycaster();\n const pointer = new Vector2();\n /** This function gives the record under a pointer. */\n const pickAt = (event: PointerEvent): StagePick<P> | undefined => {\n const box = canvas.getBoundingClientRect();\n if (box.width === 0 || box.height === 0) return undefined;\n pointer.set(((event.clientX - box.left) / box.width) * 2 - 1, 1 - ((event.clientY - box.top) / box.height) * 2);\n raycaster.setFromCamera(pointer, camera);\n return content.pick(raycaster);\n };\n\n const setHover = (pick: StagePick<P> | undefined): void => {\n const record = pick?.record;\n if (record === highlights.hovered) return;\n highlights = { ...highlights, hovered: record };\n canvas.style.cursor = record === undefined ? \"grab\" : \"pointer\";\n paint();\n options.onHover?.(pick?.value);\n };\n\n const listeners = new AbortController();\n const signal = listeners.signal;\n let down: { readonly id: number; readonly x: number; readonly y: number } | undefined;\n const setInUse = (inUse: boolean): void => {\n controls.enableZoom = inUse;\n };\n canvas.addEventListener(\n \"pointerdown\",\n (event) => {\n setInUse(true);\n canvas.focus({ preventScroll: true });\n down = { id: event.pointerId, x: event.clientX, y: event.clientY };\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointermove\",\n (event) => {\n if (event.buttons === 0 && event.pointerType !== \"touch\") setHover(pickAt(event));\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointerup\",\n (event) => {\n const start = down;\n down = undefined;\n if (start === undefined || start.id !== event.pointerId) return;\n if (!isClick(start, { x: event.clientX, y: event.clientY })) return;\n const pick = pickAt(event);\n highlights = { ...highlights, selected: pick?.record };\n paint();\n options.onSelect?.(pick?.value);\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointercancel\",\n () => {\n down = undefined;\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointerleave\",\n (event) => {\n setHover(undefined);\n if (event.pointerType === \"mouse\") setInUse(false);\n },\n { signal },\n );\n canvas.addEventListener(\"blur\", () => setInUse(false), { signal });\n canvas.addEventListener(\n \"keydown\",\n (event) => {\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const action = keyAction(event.key, placeNow(), { home: options.home, views: options.keys, surface: surfaceOf(content.extent), fieldOfView });\n if (action === undefined) return;\n event.preventDefault();\n setInUse(true);\n if (action.type === \"view\") {\n goTo(action.view, true);\n return;\n }\n moved = true;\n move = undefined;\n stopDrift();\n put(action.place);\n invalidate();\n },\n { signal },\n );\n canvas.addEventListener(\"webglcontextlost\", (event) => event.preventDefault(), { signal });\n canvas.addEventListener(\"webglcontextrestored\", invalidate, { signal });\n\n controls.addEventListener(\"start\", () => {\n moved = true;\n move = undefined;\n canvas.style.cursor = \"grabbing\";\n invalidate();\n });\n controls.addEventListener(\"end\", () => {\n canvas.style.cursor = highlights.hovered === undefined ? \"grab\" : \"pointer\";\n });\n controls.addEventListener(\"change\", invalidate);\n\n const applyTheme = (): void => {\n sky.color.set(theme.sky);\n sky.groundColor.set(theme.ground);\n paint();\n };\n\n const observer = new ResizeObserver(() => {\n if (disposed || !setSize()) return;\n setLimits();\n if (!moved) goTo(view, false);\n invalidate();\n });\n\n setSize();\n setLimits();\n goTo(options.home, false);\n applyTheme();\n observer.observe(container);\n\n return {\n canvas,\n setContent(next: StageContent<P, T>): void {\n if (disposed || next === content) return;\n for (const object of content.objects) world.remove(object);\n content.dispose();\n content = next;\n for (const object of content.objects) world.add(object);\n const selected = highlights.selected !== undefined && content.has(highlights.selected) ? highlights.selected : undefined;\n highlights = { ...highlights, hovered: undefined, selected };\n settle = true;\n setLimits();\n if (!moved) goTo(view, false);\n paint();\n },\n setTheme(next: T): void {\n theme = next;\n applyTheme();\n },\n setView(next: string | StageView, animate: boolean = true): void {\n goTo(next, animate);\n },\n place: placeNow,\n highlight(records: readonly string[]): void {\n highlights = { ...highlights, highlighted: new Set(records) };\n paint();\n },\n select(record: string | undefined): void {\n highlights = { ...highlights, selected: record };\n paint();\n },\n refresh: paint,\n dispose(): void {\n if (disposed) return;\n disposed = true;\n cancelAnimationFrame(frame);\n observer.disconnect();\n listeners.abort();\n controls.dispose();\n for (const object of content.objects) world.remove(object);\n content.dispose();\n renderer.dispose();\n canvas.remove();\n },\n };\n}\n","import type { StageTheme } from \"../theme.ts\";\nimport type { StageContent, StagePick } from \"./stage.ts\";\n\n/**\n * This function makes one content from a list of contents, for a stage that shows them together.\n * An example is a globe with a layer of labels, or a room with its marks.\n *\n * - The first content gives the extent: the views and the limits of the camera come from it.\n * - The last content is on top. A pick asks the last content first.\n * - A pick with no distance ends the search, if no earlier pick has a distance. That pick is the record.\n * - A pick with a distance does not end the search. The record is then the pick with the smallest distance.\n * - A record that two contents have is one record: each of them gets its highlight.\n * - The stage disposes the stack, and the stack disposes each content.\n */\nexport function stackContents<P, T extends StageTheme = StageTheme>(contents: readonly [StageContent<P, T>, ...StageContent<P, T>[]]): StageContent<P, T> {\n const [first] = contents;\n return {\n objects: contents.flatMap((content) => content.objects),\n get extent() {\n return first.extent;\n },\n has: (record) => contents.some((content) => content.has(record)),\n pick(ray): StagePick<P> | undefined {\n // The nearest of the picks that have a distance. A content on top gets the pick when two distances are equal.\n let nearest: StagePick<P> | undefined;\n for (let at = contents.length - 1; at >= 0; at -= 1) {\n const pick = contents[at]?.pick(ray);\n if (pick === undefined) continue;\n // A pick with no distance tells nothing of its depth, so the search stops: a nearer pick of a content on top stays the record.\n if (pick.distance === undefined) return nearest ?? pick;\n if (nearest?.distance === undefined || pick.distance < nearest.distance) nearest = pick;\n }\n return nearest;\n },\n paint(theme, highlight): void {\n for (const content of contents) content.paint(theme, highlight);\n },\n step(frame): boolean {\n let active = false;\n // Each content has its step, also after a content that continues to change.\n for (const content of contents) active = (content.step?.(frame) ?? false) || active;\n return active;\n },\n dispose(): void {\n for (const content of contents) content.dispose();\n },\n };\n}\n"],"mappings":";;;;;;;AA2HA,MAAa,eAA4B;CAAE,KAAK;CAAK,KAAK;CAAK,MAAM;EAAE,GAAG;EAAK,GAAG;EAAI,GAAG;CAAG;AAAE;;AAG9F,MAAM,YAAY;;;;;AAMlB,MAAM,aAAa;;AAGnB,MAAM,iBAAiB;;AAGvB,MAAM,gBAAgB,KAAK,KAAK,IAAI;;AAGpC,SAAS,aAAsB;CAC7B,OAAO,OAAO,eAAe,cAAc,WAAW,kCAAkC,CAAC,CAAC;AAC5F;;;;;;;;;;;AAYA,SAAgB,YAAkD,WAAwB,SAAsD;CAC9I,MAAM,SAAS,UAAU,cAAc,cAAc,QAAQ;CAC7D,MAAM,UAAU,OAAO,WAAW,UAAU;EAAE,OAAO;EAAM,WAAW;EAAM,OAAO;EAAM,SAAS;EAAO,oBAAoB;EAAM,iBA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AE,KAAK,GAAG;IACnC,IAAI,SAAS,KAAA,GAAW;IAExB,IAAI,KAAK,aAAa,KAAA,GAAW,OAAO,WAAW;IACnD,IAAI,SAAS,aAAa,KAAA,KAAa,KAAK,WAAW,QAAQ,UAAU,UAAU;GACrF;GACA,OAAO;EACT;EACA,MAAM,OAAO,WAAiB;GAC5B,KAAK,MAAM,WAAW,UAAU,QAAQ,MAAM,OAAO,SAAS;EAChE;EACA,KAAK,OAAgB;GACnB,IAAI,SAAS;GAEb,KAAK,MAAM,WAAW,UAAU,UAAU,QAAQ,OAAO,KAAK,KAAK,UAAU;GAC7E,OAAO;EACT;EACA,UAAgB;GACd,KAAK,MAAM,WAAW,UAAU,QAAQ,QAAQ;EAClD;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"three.js","names":["World"],"sources":["../src/stage/stage.ts","../src/stage/stack.ts"],"sourcesContent":["import { DirectionalLight, HemisphereLight, PerspectiveCamera, Raycaster, Scene as World, Vector2, WebGLRenderer, type Object3D } from \"three\";\nimport { OrbitControls } from \"three/addons/controls/OrbitControls.js\";\nimport { nearDepth, stageLimits, surfaceOf, type StageExtent, type StageLimits, type StageView, type ViewFrame } from \"../extent.ts\";\nimport { keyAction } from \"../keys.ts\";\nimport { isClick, highlightOf, NO_HIGHLIGHTS, type Highlight, type Highlights } from \"../highlight.ts\";\nimport { lessMotion, moveAt, MOVE_TIME, type Move } from \"../motion.ts\";\nimport type { StageTheme } from \"../theme.ts\";\nimport { cameraPosition, clampPlace, FIELD_OF_VIEW, speedAt, turnAcross, viewOf, type Place } from \"../view.ts\";\n\nexport { FIELD_OF_VIEW };\n\n/** The record under the pointer: its name, and the value that the content gives for it. */\nexport interface StagePick<P> {\n /** The name of the record. The highlights of the stage use this name. */\n readonly record: string;\n /** The value of the record for the page, for example its kind and its source. */\n readonly value: P;\n /**\n * The distance from the start of the ray to the record, in the unit of the space.\n * A stack of contents uses it to find the nearest record. A pick with no distance is above each other record.\n */\n readonly distance?: number | undefined;\n}\n\n/** One picture of a stage, for the step of its content. */\nexport interface StageFrame {\n readonly camera: PerspectiveCamera;\n /** The time since the last picture, in seconds. */\n readonly seconds: number;\n /**\n * This value is true for the first picture of a content, and for a person who asks for less motion.\n * Each change then has no time: the content sets each value to its goal immediately.\n */\n readonly settle: boolean;\n /** The height of the picture, in CSS pixels. */\n readonly height: number;\n /** The vertical angle of the picture, in degrees. */\n readonly fieldOfView: number;\n}\n\n/**\n * The content of a stage: the three.js objects of one scene, and what the stage asks of them.\n * `P` is the type of the value of a pick, and `T` is the type of the theme.\n */\nexport interface StageContent<P, T extends StageTheme = StageTheme> {\n /** The three.js objects of the content. The stage adds them to its world, and removes them. */\n readonly objects: readonly Object3D[];\n /** The space that the content fills. */\n readonly extent: StageExtent;\n /** This function tells if the content has a record with a name. */\n has(record: string): boolean;\n /** This function gives the record that a ray from the camera finds first, or `undefined` for no record. */\n pick(ray: Raycaster): StagePick<P> | undefined;\n /** This function gives each part its colors, from the theme and the highlight of its record. */\n paint(theme: T, highlight: (record: string) => Highlight): void;\n /**\n * This function changes the parts that depend on the camera or on the time, before each picture.\n * It gives true while a part continues to change. The stage then makes the next picture.\n */\n step?(frame: StageFrame): boolean;\n /** This function releases the memory of the graphics card that the content uses. */\n dispose(): void;\n}\n\n/** The lights of a stage. A content with materials that use no light ignores them. */\nexport interface StageLights {\n /** The strength of the light from above and below. */\n readonly sky: number;\n /** The strength of the light from one direction. */\n readonly sun: number;\n /** The position that the light from one direction comes from. */\n readonly from: { readonly x: number; readonly y: number; readonly z: number };\n}\n\n/** The options of a stage. */\nexport interface StageOptions<P, T extends StageTheme = StageTheme> {\n /** The first content. The stage disposes each content that it gets. */\n readonly content: StageContent<P, T>;\n readonly theme: T;\n /** The name of the picture for a screen reader. */\n readonly label: string;\n /** The views of the stage, each with a name. */\n readonly views: Readonly<Record<string, StageView>>;\n /** The name of the first view. The keys `Home` and `0` show it. */\n readonly home: string;\n /** The name of the view of a key, for example `{ t: \"top\" }`. A letter has no case. */\n readonly keys?: Readonly<Record<string, string>> | undefined;\n /** The vertical angle of the picture, in degrees. A small angle gives the look of a drawing. The default is 32. */\n readonly fieldOfView?: number | undefined;\n /** The smallest and the largest polar angle of the camera, in radians. The default keeps the camera above the plane of the target. */\n readonly polar?: { readonly min?: number | undefined; readonly max?: number | undefined } | undefined;\n /** This value is true if a person can move the target with a drag of the second button. The default is true. */\n readonly pan?: boolean | undefined;\n readonly lights?: StageLights | undefined;\n /** The stage starts this function when the pointer goes to a different record, or to no record. */\n readonly onHover?: ((pick: P | undefined) => void) | undefined;\n /** The stage starts this function when a person selects a record with the pointer, or selects no record. */\n readonly onSelect?: ((pick: P | undefined) => void) | undefined;\n}\n\n/** A stage in a page: one canvas with a camera that a person moves, and one content. */\nexport interface Stage<P, T extends StageTheme = StageTheme> {\n /** The canvas of the stage. It is in the container. */\n readonly canvas: HTMLCanvasElement;\n /** This function shows a different content, and disposes the old content. The view stays if a person moved it. */\n setContent(content: StageContent<P, T>): void;\n /** This function changes the colors. */\n setTheme(theme: T): void;\n /** This function moves the camera to a view: a name of the options, or a view function. `animate` has the default true. */\n setView(view: string | StageView, animate?: boolean): void;\n /** This function gives the place of the camera. */\n place(): Place;\n /** This function highlights records by their names, as the pointer does. An empty list removes the highlights. */\n highlight(records: readonly string[]): void;\n /** This function selects one record by its name, or no record. It does not start `onSelect`. */\n select(record: string | undefined): void;\n /** This function paints the content again and makes a new picture. Use it after a change of the content. */\n refresh(): void;\n /** This function removes the canvas and releases the memory of the graphics card. It disposes the content. */\n dispose(): void;\n}\n\n/** The default lights: a strong light from above and below, and a light from the front left. */\nexport const STAGE_LIGHTS: StageLights = { sky: 2.2, sun: 1.5, from: { x: -10, y: 24, z: 15 } };\n\n/**\n * The largest turn of the camera for a drag across the height of the picture, as a part of a full turn.\n * A camera far from a ball, or with no ball, turns by this part.\n */\nconst TURN_SPEED = 0.9;\n\n/** The smallest polar angle. At 0, the azimuth of a camera has no meaning. */\nconst SMALLEST_POLAR = 0.0005;\n\n/** The default largest polar angle: the camera stays above the plane of the target. */\nconst LARGEST_POLAR = Math.PI / 2 - 0.05;\n\n/**\n * This function makes a stage in a container of a page. The stage fills the container, so give the container a size.\n *\n * A person turns the content with a drag, and moves nearer with the wheel after a click in the picture.\n * A click selects the record under the pointer. With the keyboard, the arrow keys turn the content, `+` and `-` change the distance,\n * and `Home` shows the first view. The stage makes a picture only after a change.\n *\n * The function gives `undefined` when the browser has no WebGL 2. It does not throw, and it writes no error to the console.\n * The page then shows a different picture of the same data.\n */\nexport function createStage<P, T extends StageTheme = StageTheme>(container: HTMLElement, options: StageOptions<P, T>): Stage<P, T> | undefined {\n const canvas = container.ownerDocument.createElement(\"canvas\");\n const context = canvas.getContext(\"webgl2\", { alpha: true, antialias: true, depth: true, stencil: false, premultipliedAlpha: true, powerPreference: \"default\" });\n if (context === null) return undefined;\n let renderer: WebGLRenderer;\n try {\n renderer = new WebGLRenderer({ canvas, context, alpha: true, antialias: true });\n } catch {\n return undefined;\n }\n renderer.setClearColor(0x000000, 0);\n\n canvas.style.display = \"block\";\n canvas.style.width = \"100%\";\n canvas.style.height = \"100%\";\n canvas.style.cursor = \"grab\";\n canvas.style.touchAction = \"none\";\n canvas.tabIndex = 0;\n canvas.setAttribute(\"role\", \"application\");\n canvas.setAttribute(\"aria-label\", options.label);\n container.append(canvas);\n\n const fieldOfView = options.fieldOfView ?? FIELD_OF_VIEW;\n const polar = { min: options.polar?.min ?? SMALLEST_POLAR, max: options.polar?.max ?? LARGEST_POLAR };\n const lights = options.lights ?? STAGE_LIGHTS;\n const world = new World();\n const sky = new HemisphereLight(\"#ffffff\", \"#ffffff\", lights.sky);\n const sun = new DirectionalLight(\"#ffffff\", lights.sun);\n sun.position.set(lights.from.x, lights.from.y, lights.from.z);\n world.add(sky, sun);\n const camera = new PerspectiveCamera(fieldOfView, 1, 0.05, 1000);\n\n let content = options.content;\n let theme = options.theme;\n for (const object of content.objects) world.add(object);\n\n let highlights: Highlights = NO_HIGHLIGHTS;\n let view: string | StageView = options.home;\n let move: Move | undefined;\n /** This value is true after a person moved the view. Then a new size of the container does not move the camera. */\n let moved = false;\n /** This value is true until the content had a step with no time. */\n let settle = true;\n /** The height of the picture, in CSS pixels. */\n let height = 1;\n let frame = 0;\n let lastTime = 0;\n let disposed = false;\n\n const invalidate = (): void => {\n if (frame === 0 && !disposed) frame = requestAnimationFrame(tick);\n };\n\n const controls = new OrbitControls(camera, canvas);\n controls.enableDamping = !lessMotion();\n controls.dampingFactor = 0.14;\n controls.minPolarAngle = polar.min;\n controls.maxPolarAngle = polar.max;\n controls.rotateSpeed = TURN_SPEED;\n controls.screenSpacePanning = true;\n controls.enablePan = options.pan ?? true;\n // The wheel moves the page until a person uses the picture. Thus the picture does not stop a person who reads down the page.\n controls.enableZoom = false;\n\n const viewFrame = (): ViewFrame => ({ extent: content.extent, fieldOfView, aspect: camera.aspect });\n let limits: StageLimits = stageLimits(viewFrame(), Object.values(options.views), polar);\n\n const paint = (): void => {\n const now = highlights;\n content.paint(theme, (record) => highlightOf(now, record));\n invalidate();\n };\n\n /**\n * This function sets the turn speed and the zoom speed from the height of the camera above the surface.\n * The surface of a ball at the middle of the picture follows the pointer in a drag.\n */\n const setSpeed = (): void => {\n const distance = camera.position.distanceTo(controls.target);\n const surface = surfaceOf(content.extent);\n // The controls turn the camera by a full turn times the speed for a drag across the height of the picture.\n controls.rotateSpeed = Math.min(TURN_SPEED, turnAcross(distance, surface, fieldOfView) / (2 * Math.PI));\n controls.zoomSpeed = speedAt(distance, surface);\n };\n const placeNow = (): Place => {\n const target = { x: controls.target.x, y: controls.target.y, z: controls.target.z };\n return { target, ...viewOf(camera.position, target) };\n };\n const put = (to: Place): void => {\n const next = clampPlace(to, limits);\n const eye = cameraPosition(next.target, next, next.distance);\n controls.target.set(next.target.x, next.target.y, next.target.z);\n camera.position.set(eye.x, eye.y, eye.z);\n camera.lookAt(controls.target);\n setSpeed();\n };\n /** This function gives the view function of a view, or `undefined` for a name that the options do not have. */\n const viewFunction = (of: string | StageView): StageView | undefined => (typeof of === \"string\" ? options.views[of] : of);\n\n /**\n * This function sets the nearest depth that the camera draws, from the distance of the camera to the content.\n * A camera far from the content then has small steps of depth at the content, so a layer near a surface stays above it.\n */\n const setDepth = (): void => {\n const { center } = content.extent;\n const distance = Math.hypot(camera.position.x - center.x, camera.position.y - center.y, camera.position.z - center.z);\n const near = nearDepth(limits, content.extent, distance);\n if (near === camera.near && limits.far === camera.far) return;\n camera.near = near;\n camera.far = limits.far;\n camera.updateProjectionMatrix();\n };\n /** This function sets the limits of the camera from the content and the shape of the picture. */\n const setLimits = (): void => {\n limits = stageLimits(viewFrame(), Object.values(options.views), polar);\n controls.minDistance = limits.minDistance;\n controls.maxDistance = limits.maxDistance;\n setDepth();\n };\n /**\n * This function stops the turn that continues after a drag. The camera stays where it is.\n * Without it, the camera continues to turn after a move to a view, and the view is not exact.\n */\n const stopDrift = (): void => {\n if (!controls.enableDamping) return;\n const now = placeNow();\n // With no damping, an update of the controls uses all of the turn that remains. The camera then goes back.\n controls.enableDamping = false;\n controls.update();\n controls.enableDamping = true;\n put(now);\n };\n const goTo = (next: string | StageView, animate: boolean): void => {\n const found = viewFunction(next);\n if (found === undefined) return;\n view = next;\n moved = false;\n stopDrift();\n const to = found(viewFrame());\n if (animate && !lessMotion()) {\n move = { from: placeNow(), to, start: performance.now(), duration: MOVE_TIME };\n } else {\n move = undefined;\n put(to);\n }\n invalidate();\n };\n\n /** This function sets the size of the picture from the size of the container. It gives false for a container with no size. */\n const setSize = (): boolean => {\n const width = container.clientWidth;\n const tall = container.clientHeight;\n if (width === 0 || tall === 0) return false;\n height = tall;\n renderer.setPixelRatio(Math.min(globalThis.devicePixelRatio, 2));\n renderer.setSize(width, tall, false);\n camera.aspect = width / tall;\n camera.updateProjectionMatrix();\n return true;\n };\n\n /** This function moves the camera one step of a move between two views. It gives true while the move continues. */\n const stepMove = (now: number): boolean => {\n if (move === undefined) return false;\n const step = moveAt(move, now, surfaceOf(content.extent));\n put(step.place);\n if (step.done) move = undefined;\n return true;\n };\n\n function tick(now: number): void {\n frame = 0;\n if (disposed) return;\n const seconds = lastTime === 0 ? 1 / 60 : Math.min((now - lastTime) / 1000, 0.1);\n let active = stepMove(now);\n setSpeed();\n active = controls.update() || active;\n setDepth();\n const stepped = content.step?.({ camera, seconds, settle: settle || lessMotion(), height, fieldOfView }) ?? false;\n settle = false;\n renderer.render(world, camera);\n active = stepped || active;\n lastTime = active ? now : 0;\n if (active) invalidate();\n }\n\n const raycaster = new Raycaster();\n const pointer = new Vector2();\n /** This function gives the record under a pointer. */\n const pickAt = (event: PointerEvent): StagePick<P> | undefined => {\n const box = canvas.getBoundingClientRect();\n if (box.width === 0 || box.height === 0) return undefined;\n pointer.set(((event.clientX - box.left) / box.width) * 2 - 1, 1 - ((event.clientY - box.top) / box.height) * 2);\n raycaster.setFromCamera(pointer, camera);\n return content.pick(raycaster);\n };\n\n const setHover = (pick: StagePick<P> | undefined): void => {\n const record = pick?.record;\n if (record === highlights.hovered) return;\n highlights = { ...highlights, hovered: record };\n canvas.style.cursor = record === undefined ? \"grab\" : \"pointer\";\n paint();\n options.onHover?.(pick?.value);\n };\n\n const listeners = new AbortController();\n const signal = listeners.signal;\n let down: { readonly id: number; readonly x: number; readonly y: number } | undefined;\n const setInUse = (inUse: boolean): void => {\n controls.enableZoom = inUse;\n };\n canvas.addEventListener(\n \"pointerdown\",\n (event) => {\n setInUse(true);\n canvas.focus({ preventScroll: true });\n down = { id: event.pointerId, x: event.clientX, y: event.clientY };\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointermove\",\n (event) => {\n if (event.buttons === 0 && event.pointerType !== \"touch\") setHover(pickAt(event));\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointerup\",\n (event) => {\n const start = down;\n down = undefined;\n if (start === undefined || start.id !== event.pointerId) return;\n if (!isClick(start, { x: event.clientX, y: event.clientY })) return;\n const pick = pickAt(event);\n highlights = { ...highlights, selected: pick?.record };\n paint();\n options.onSelect?.(pick?.value);\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointercancel\",\n () => {\n down = undefined;\n },\n { signal },\n );\n canvas.addEventListener(\n \"pointerleave\",\n (event) => {\n setHover(undefined);\n if (event.pointerType === \"mouse\") setInUse(false);\n },\n { signal },\n );\n canvas.addEventListener(\"blur\", () => setInUse(false), { signal });\n canvas.addEventListener(\n \"keydown\",\n (event) => {\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const action = keyAction(event.key, placeNow(), { home: options.home, views: options.keys, surface: surfaceOf(content.extent), fieldOfView });\n if (action === undefined) return;\n event.preventDefault();\n setInUse(true);\n if (action.type === \"view\") {\n goTo(action.view, true);\n return;\n }\n moved = true;\n move = undefined;\n stopDrift();\n put(action.place);\n invalidate();\n },\n { signal },\n );\n canvas.addEventListener(\"webglcontextlost\", (event) => event.preventDefault(), { signal });\n canvas.addEventListener(\"webglcontextrestored\", invalidate, { signal });\n\n controls.addEventListener(\"start\", () => {\n moved = true;\n move = undefined;\n canvas.style.cursor = \"grabbing\";\n invalidate();\n });\n controls.addEventListener(\"end\", () => {\n canvas.style.cursor = highlights.hovered === undefined ? \"grab\" : \"pointer\";\n });\n controls.addEventListener(\"change\", invalidate);\n\n const applyTheme = (): void => {\n sky.color.set(theme.sky);\n sky.groundColor.set(theme.ground);\n paint();\n };\n\n const observer = new ResizeObserver(() => {\n if (disposed || !setSize()) return;\n setLimits();\n if (!moved) goTo(view, false);\n invalidate();\n });\n\n setSize();\n setLimits();\n goTo(options.home, false);\n applyTheme();\n observer.observe(container);\n\n return {\n canvas,\n setContent(next: StageContent<P, T>): void {\n if (disposed || next === content) return;\n for (const object of content.objects) world.remove(object);\n content.dispose();\n content = next;\n for (const object of content.objects) world.add(object);\n const selected = highlights.selected !== undefined && content.has(highlights.selected) ? highlights.selected : undefined;\n highlights = { ...highlights, hovered: undefined, selected };\n settle = true;\n setLimits();\n if (!moved) goTo(view, false);\n paint();\n },\n setTheme(next: T): void {\n theme = next;\n applyTheme();\n },\n setView(next: string | StageView, animate: boolean = true): void {\n goTo(next, animate);\n },\n place: placeNow,\n highlight(records: readonly string[]): void {\n highlights = { ...highlights, highlighted: new Set(records) };\n paint();\n },\n select(record: string | undefined): void {\n highlights = { ...highlights, selected: record };\n paint();\n },\n refresh: paint,\n dispose(): void {\n if (disposed) return;\n disposed = true;\n cancelAnimationFrame(frame);\n observer.disconnect();\n listeners.abort();\n controls.dispose();\n for (const object of content.objects) world.remove(object);\n content.dispose();\n renderer.dispose();\n canvas.remove();\n },\n };\n}\n","import type { StageTheme } from \"../theme.ts\";\nimport type { StageContent, StagePick } from \"./stage.ts\";\n\n/**\n * This function makes one content from a list of contents, for a stage that shows them together.\n * An example is a globe with a layer of labels, or a room with its marks.\n *\n * - The first content gives the extent: the views and the limits of the camera come from it.\n * - The last content is on top. A pick asks the last content first.\n * - A pick with no distance ends the search, if no earlier pick has a distance. That pick is the record.\n * - A pick with a distance does not end the search. The record is then the pick with the smallest distance.\n * - A record that two contents have is one record: each of them gets its highlight.\n * - The stage disposes the stack, and the stack disposes each content.\n */\nexport function stackContents<P, T extends StageTheme = StageTheme>(contents: readonly [StageContent<P, T>, ...StageContent<P, T>[]]): StageContent<P, T> {\n const [first] = contents;\n return {\n objects: contents.flatMap((content) => content.objects),\n get extent() {\n return first.extent;\n },\n has: (record) => contents.some((content) => content.has(record)),\n pick(ray): StagePick<P> | undefined {\n // The nearest of the picks that have a distance. A content on top gets the pick when two distances are equal.\n let nearest: StagePick<P> | undefined;\n for (let at = contents.length - 1; at >= 0; at -= 1) {\n const pick = contents[at]?.pick(ray);\n if (pick === undefined) continue;\n // A pick with no distance tells nothing of its depth, so the search stops: a nearer pick of a content on top stays the record.\n if (pick.distance === undefined) return nearest ?? pick;\n if (nearest?.distance === undefined || pick.distance < nearest.distance) nearest = pick;\n }\n return nearest;\n },\n paint(theme, highlight): void {\n for (const content of contents) content.paint(theme, highlight);\n },\n step(frame): boolean {\n let active = false;\n // Each content has its step, also after a content that continues to change.\n for (const content of contents) active = (content.step?.(frame) ?? false) || active;\n return active;\n },\n dispose(): void {\n for (const content of contents) content.dispose();\n },\n };\n}\n"],"mappings":";;;;;;;AA2HA,MAAa,eAA4B;CAAE,KAAK;CAAK,KAAK;CAAK,MAAM;EAAE,GAAG;EAAK,GAAG;EAAI,GAAG;CAAG;AAAE;;;;;AAM9F,MAAM,aAAa;;AAGnB,MAAM,iBAAiB;;AAGvB,MAAM,gBAAgB,KAAK,KAAK,IAAI;;;;;;;;;;;AAYpC,SAAgB,YAAkD,WAAwB,SAAsD;CAC9I,MAAM,SAAS,UAAU,cAAc,cAAc,QAAQ;CAC7D,MAAM,UAAU,OAAO,WAAW,UAAU;EAAE,OAAO;EAAM,WAAW;EAAM,OAAO;EAAM,SAAS;EAAO,oBAAoB;EAAM,iBAAiB;CAAU,CAAC;CAC/J,IAAI,YAAY,MAAM,OAAO,KAAA;CAC7B,IAAI;CACJ,IAAI;EACF,WAAW,IAAI,cAAc;GAAE;GAAQ;GAAS,OAAO;GAAM,WAAW;EAAK,CAAC;CAChF,QAAQ;EACN;CACF;CACA,SAAS,cAAc,GAAU,CAAC;CAElC,OAAO,MAAM,UAAU;CACvB,OAAO,MAAM,QAAQ;CACrB,OAAO,MAAM,SAAS;CACtB,OAAO,MAAM,SAAS;CACtB,OAAO,MAAM,cAAc;CAC3B,OAAO,WAAW;CAClB,OAAO,aAAa,QAAQ,aAAa;CACzC,OAAO,aAAa,cAAc,QAAQ,KAAK;CAC/C,UAAU,OAAO,MAAM;CAEvB,MAAM,cAAc,QAAQ,eAAA;CAC5B,MAAM,QAAQ;EAAE,KAAK,QAAQ,OAAO,OAAO;EAAgB,KAAK,QAAQ,OAAO,OAAO;CAAc;CACpG,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAM,QAAQ,IAAIA,MAAM;CACxB,MAAM,MAAM,IAAI,gBAAgB,WAAW,WAAW,OAAO,GAAG;CAChE,MAAM,MAAM,IAAI,iBAAiB,WAAW,OAAO,G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