@mark1russell7/visuals 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -1
- package/build/extent-D2SsHJnP.js +154 -0
- package/build/extent-D2SsHJnP.js.map +1 -0
- package/build/globe.d.ts +1 -1
- package/build/globe.js +1 -1
- package/build/index.js +3 -2
- package/build/index.js.map +1 -1
- package/build/labels.d.ts +1 -1
- package/build/mark-AZ5AuAIJ.js +98 -0
- package/build/mark-AZ5AuAIJ.js.map +1 -0
- package/build/mark-D8AdQYAS.d.ts +154 -0
- package/build/mark-D8AdQYAS.d.ts.map +1 -0
- package/build/markers.d.ts +67 -0
- package/build/markers.d.ts.map +1 -0
- package/build/markers.js +687 -0
- package/build/markers.js.map +1 -0
- package/build/marks.d.ts +2 -153
- package/build/marks.d.ts.map +1 -1
- package/build/marks.js +2 -95
- package/build/marks.js.map +1 -1
- package/build/{motion-dvvkaDwv.js → motion-BvRKIWAC.js} +2 -2
- package/build/{motion-dvvkaDwv.js.map → motion-BvRKIWAC.js.map} +1 -1
- package/build/{stage-Bhu1f7Dw.d.ts → stage-DmFfah2e.d.ts} +6 -1
- package/build/stage-DmFfah2e.d.ts.map +1 -0
- package/build/three.d.ts +4 -2
- package/build/three.d.ts.map +1 -1
- package/build/three.js +11 -4
- package/build/three.js.map +1 -1
- package/build/{extent-DC0qrxC5.js → view-BB_EQx3I.js} +2 -152
- package/build/view-BB_EQx3I.js.map +1 -0
- package/package.json +6 -1
- package/build/extent-DC0qrxC5.js.map +0 -1
- package/build/stage-Bhu1f7Dw.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markers.js","names":[],"sources":["../src/markers/content.ts"],"sourcesContent":["import {\n BufferAttribute,\n BufferGeometry,\n Color,\n DataTexture,\n DoubleSide,\n InstancedBufferAttribute,\n InstancedBufferGeometry,\n Mesh,\n MeshBasicMaterial,\n NearestFilter,\n Plane,\n RGBAFormat,\n ShaderMaterial,\n SRGBColorSpace,\n UnsignedByteType,\n Vector3,\n type Object3D,\n} from \"three\";\nimport type { Point3 } from \"@mark1russell7/layout-contract\";\nimport type { Highlight } from \"../highlight.ts\";\nimport { SHAPE_OUTLINES, levelShape, type Level, type ShapeOutline } from \"../marks/levels.ts\";\nimport { fieldRowStep, fieldValue, type FieldMark, type LinkMark, type Mark, type PointMark, type RunMark } from \"../marks/mark.ts\";\nimport type { StageContent, StageFrame, StagePick } from \"../stage/stage.ts\";\nimport type { StageTheme } from \"../theme.ts\";\nimport { FIELD_OF_VIEW } from \"../view.ts\";\n\n/** The colors of the marks of a stage. Each color is a CSS hex color, for example `#22364a`. */\nexport interface MarkersTheme extends StageTheme {\n /** The color of the marks of each level. */\n readonly levels: Readonly<Record<Level, string>>;\n /** The color of the line around a sign and around a run. Give the color of the page, so a mark is clear on each solid. */\n readonly halo: string;\n /** The color of the line around a mark whose record has a highlight. */\n readonly accent: string;\n /**\n * The colors of a field, from the value `min` of its scale to the value `max`.\n * A value between two colors gets a mix of them. A list with no color gives the color of the level of the field.\n */\n readonly field: readonly string[];\n /** The part of a field that is not clear, from 0 to 1. The default is 0.8. */\n readonly fieldOpacity?: number | undefined;\n}\n\n/** The options of the marks of a stage. */\nexport interface MarkersOptions {\n /** The radius of the sign of a point with no size, in CSS pixels. The default is `SIGN_RADIUS`. */\n readonly signRadius?: number | undefined;\n /** The width of the line of a link, in CSS pixels. The default is 2. */\n readonly linkWidth?: number | undefined;\n /** The lengths of a dash and of a gap of a link, in CSS pixels. The default is a dash of 6 and a gap of 4. */\n readonly linkDash?: readonly [dash: number, gap: number] | undefined;\n /**\n * The distance of a sign and of a field from their surface, in the unit of the space.\n * It is only for the test of what hides a mark: the surface of a mark does not hide it.\n * The default is 1/400 of the size of the space of the marks.\n */\n readonly lift?: number | undefined;\n}\n\n/** The content of a stage that draws marks. The value of a pick is the mark. */\nexport interface MarkersContent extends StageContent<Mark, MarkersTheme> {\n /**\n * This function shows only the marks that a test accepts, for example the marks of one kind. A mark that the picture does not show gets no pick.\n * Start `refresh` of the stage after it. A test that accepts each mark shows all of them again.\n */\n show(test: (mark: Mark) => boolean): void;\n}\n\n/** The radius of the sign of a point with no size, in CSS pixels. The sign of a disc has this radius. */\nexport const SIGN_RADIUS = 7;\n\n/** The width of the line around a sign, as a part of the radius of the sign. */\nconst HALO = 0.36;\n\n/** The width of the line around a run, in CSS pixels, for each highlight. */\nconst CASING: readonly [number, number, number] = [1.5, 2.5, 3];\n\n/** The size of a sign for each highlight, as a multiple of its size. */\nconst HIGHLIGHT_SIZE: readonly [number, number, number] = [1, 1.15, 1.3];\n\n/** The half of the width of the line around a field with a highlight, in CSS pixels, for each highlight. */\nconst BORDER: readonly [number, number, number] = [0, 1, 1.5];\n\n/** The half of the smallest width of a run in the picture, in CSS pixels. Thus a thin run far from the camera stays in the picture. */\nconst LEAST_RUN = 1;\n\n/** The part of a mark that is not clear while a solid hides it. */\nconst HIDDEN_OPACITY = 0.45;\n\n/** The distance around a mark where the pointer finds it, in CSS pixels. */\nconst PICK_MARGIN = 4;\n\n/** An outline with more sides than this value is a circle in the picture. The shaders have the same value. */\nconst ROUND_SIDES = 12;\n\n/** This function gives the radius of the circle around an outline and its line, for a disc with the radius 1. */\nfunction reachOf(outline: ShapeOutline): number {\n if (outline.sides > ROUND_SIDES) return outline.radius + HALO;\n const inner = Math.cos(Math.PI / outline.sides);\n return (outline.radius * inner + HALO) / inner;\n}\n\n/**\n * This function gives the radius of the sign of a level with the line around it, in CSS pixels.\n * `radius` is the radius of the sign of a disc. Give the result to the field `clear` of a label, so the text stays off the sign.\n */\nexport function signReach(level: Level, radius: number = SIGN_RADIUS): number {\n return radius * reachOf(SHAPE_OUTLINES[levelShape(level)]);\n}\n\n// The two shaders draw each mark as a square that looks at the camera. A fragment calculates its distance from the\n// edge of the shape, so one draw has each shape with a soft edge, at each size.\n// `shade` has two values: the part that is not clear in sight, and the same part behind a solid.\n// The pass `behind` draws with no depth test, and the second pass draws on it with the depth test.\n\nconst SIGN_VERTEX = `\nuniform float pixelAngle;\nuniform float halo;\nuniform float behind;\nattribute vec3 center;\nattribute vec3 lifted;\nattribute vec4 outline;\nattribute vec3 fill;\nattribute vec3 ring;\nattribute vec4 look;\nvarying vec2 vPlace;\nvarying vec4 vOutline;\nvarying vec3 vFill;\nvarying vec3 vRing;\nvarying float vOpacity;\nvoid main() {\n vOpacity = mix(look.z, look.w, behind);\n vOutline = outline;\n vFill = fill;\n vRing = ring;\n vec4 inView = modelViewMatrix * vec4(center, 1.0);\n float pixel = max(-inView.z, 0.0001) * pixelAngle;\n float radius = look.y > 0.0 ? look.y : look.x * pixel;\n float inner = outline.y > ${ROUND_SIDES.toFixed(1)} ? 1.0 : cos(3.141592653589793 / outline.y);\n // The square has the outline, the line around it and one pixel for the soft edge.\n float reach = (outline.x * inner + halo) / inner + pixel / max(radius, 0.000001);\n vPlace = position.xy * reach;\n vec3 above = (modelViewMatrix * vec4(lifted, 1.0)).xyz;\n // The direction out of the surface, in the space of the camera. Its length is the lift.\n vec3 normal = above - inView.xyz;\n inView.xy += position.xy * reach * radius;\n gl_Position = projectionMatrix * inView;\n // Each corner has the depth of the point of the lifted surface that is behind it, as a picture on the surface has.\n // Thus the surface of the sign hides no part of the sign, and a solid in front of the surface hides the sign.\n float slope = dot(normal, inView.xyz);\n float along = abs(slope) > 0.000000001 ? clamp(dot(normal, above) / slope, 0.5, 2.0) : 1.0;\n vec4 depthAt = projectionMatrix * vec4(inView.xyz * along, 1.0);\n gl_Position.z = depthAt.z / depthAt.w * gl_Position.w;\n if (vOpacity <= 0.0) gl_Position = vec4(2.0, 2.0, 2.0, 1.0);\n}`;\n\nconst SIGN_FRAGMENT = `\nuniform float halo;\nvarying vec2 vPlace;\nvarying vec4 vOutline;\nvarying vec3 vFill;\nvarying vec3 vRing;\nvarying float vOpacity;\nvoid main() {\n float radius = length(vPlace);\n // The distance from the edge of the outline: below 0 in the outline.\n float edge = radius - vOutline.x;\n if (vOutline.y <= ${ROUND_SIDES.toFixed(1)}) {\n float sector = 6.283185307179586 / vOutline.y;\n float turn = mod(atan(vPlace.y, vPlace.x) - vOutline.z, sector) - 0.5 * sector;\n edge = radius * cos(turn) - vOutline.x * cos(0.5 * sector);\n }\n float soft = max(fwidth(edge), 0.000001);\n float front = 1.0 - smoothstep(-soft, 0.0, edge);\n if (vOutline.w > 0.0) front *= smoothstep(vOutline.w - soft, vOutline.w, radius);\n float whole = 1.0 - smoothstep(halo - soft, halo, edge);\n gl_FragColor = vec4(mix(vRing, vFill, front), whole * vOpacity);\n if (gl_FragColor.a <= 0.0) discard;\n #include <colorspace_fragment>\n}`;\n\nconst SEGMENT_VERTEX = `\nuniform float pixelAngle;\nuniform float behind;\nattribute vec3 start;\nattribute vec3 finish;\nattribute vec3 fill;\nattribute vec3 wide;\nattribute vec2 shade;\nattribute vec2 dash;\nvarying float vAcross;\nvarying float vAlong;\nvarying float vLength;\nvarying float vBody;\nvarying float vScale;\nvarying vec2 vDash;\nvarying vec3 vFill;\nvarying float vOpacity;\nvoid main() {\n vOpacity = mix(shade.x, shade.y, behind);\n vFill = fill;\n vDash = dash;\n vec3 from = (modelViewMatrix * vec4(start, 1.0)).xyz;\n vec3 to = (modelViewMatrix * vec4(finish, 1.0)).xyz;\n vec3 here = mix(from, to, position.y);\n vec3 line = to - from;\n vLength = length(line);\n vec3 along = vLength > 0.0 ? line / vLength : vec3(1.0, 0.0, 0.0);\n float pixel = max(-here.z, 0.0001) * pixelAngle;\n // The half of the width: the width in the space, not less than a width in pixels, plus a width in pixels.\n vBody = max(wide.y, wide.z * pixel) + wide.x * pixel;\n float reach = vBody + pixel;\n // The square looks at the camera: its side is at a right angle to the line and to the sight line.\n vec3 side = cross(along, here);\n float sideLength = length(side);\n side = sideLength > 0.000001 ? side / sideLength : vec3(0.0, 1.0, 0.0);\n float cap = position.y * 2.0 - 1.0;\n vAcross = position.x * reach;\n vAlong = position.y * vLength + cap * reach;\n // A dash has its length in pixels at the middle of the line.\n vScale = 1.0 / (max(-0.5 * (from.z + to.z), 0.0001) * pixelAngle);\n gl_Position = projectionMatrix * vec4(here + side * vAcross + along * (cap * reach), 1.0);\n // Each corner has the depth of the side of a tube that is nearest to the camera.\n // Thus the surface below a run does not hide the half of the run that is nearest to it.\n vec4 depthAt = projectionMatrix * vec4(here * max(1.0 - reach / max(length(here), 0.0001), 0.5), 1.0);\n gl_Position.z = depthAt.z / depthAt.w * gl_Position.w;\n if (vOpacity <= 0.0) gl_Position = vec4(2.0, 2.0, 2.0, 1.0);\n}`;\n\nconst SEGMENT_FRAGMENT = `\nvarying float vAcross;\nvarying float vAlong;\nvarying float vLength;\nvarying float vBody;\nvarying float vScale;\nvarying vec2 vDash;\nvarying vec3 vFill;\nvarying float vOpacity;\nvoid main() {\n // The distance from the line between the two ends. Thus each end is round.\n float past = max(max(-vAlong, vAlong - vLength), 0.0);\n float away = length(vec2(vAcross, past));\n float soft = max(fwidth(away), 0.000001);\n float alpha = (1.0 - smoothstep(vBody - soft, vBody, away)) * vOpacity;\n if (vDash.x > 0.0 && mod(vAlong * vScale, vDash.x + vDash.y) > vDash.x) alpha = 0.0;\n gl_FragColor = vec4(vFill, alpha);\n if (gl_FragColor.a <= 0.0) discard;\n #include <colorspace_fragment>\n}`;\n\ninterface SignPart {\n readonly mark: PointMark;\n readonly at: Vector3;\n /** The radius of the sign in the unit of the space. A sign with a radius in pixels has 0. */\n readonly world: number;\n readonly outline: ShapeOutline;\n shown: boolean;\n highlight: Highlight;\n}\n\ninterface RunPart {\n readonly mark: RunMark;\n /** The points of the center line: each point of the path, at half of the width above its surface. */\n readonly points: readonly Vector3[];\n /** The index of the first segment of the line around the run, and of the run. */\n readonly casing: number;\n readonly body: number;\n shown: boolean;\n highlight: Highlight;\n}\n\ninterface LinkPart {\n readonly mark: LinkMark;\n readonly segment: number;\n shown: boolean;\n}\n\ninterface FieldPart {\n readonly mark: FieldMark;\n readonly mesh: Mesh<BufferGeometry, MeshBasicMaterial>;\n readonly texture: DataTexture;\n readonly plane: Plane;\n readonly origin: Vector3;\n readonly across: Vector3;\n readonly down: Vector3;\n /** The index of the first of the four segments around the field. */\n readonly border: number;\n shown: boolean;\n highlight: Highlight;\n}\n\nconst vector = (point: Point3): Vector3 => new Vector3(point.x, point.y, point.z);\n\n/** This function tells if a field has a grid that a texture can hold. */\nfunction hasGrid(field: FieldMark): boolean {\n return Number.isInteger(field.columns) && Number.isInteger(field.rows) && field.columns >= 1 && field.rows >= 1 && field.cell > 0;\n}\n\n/** This function makes the square of two triangles that each instance of a mesh uses. `low` is the y value of its first side. */\nfunction squareOf(low: number): InstancedBufferGeometry {\n const geometry = new InstancedBufferGeometry();\n geometry.setAttribute(\"position\", new BufferAttribute(new Float32Array([-1, low, 0, 1, low, 0, 1, 1, 0, -1, 1, 0]), 3));\n geometry.setIndex([0, 1, 2, 0, 2, 3]);\n return geometry;\n}\n\n/**\n * This function makes the content of a stage that draws marks. Examine the marks with `checkMarks` first.\n *\n * - A point is a sign with the shape and the color of its level. A sign looks at the camera.\n * A sign with no size keeps its size in the picture.\n * - A run is a round line with its width in the space. Its center is half of its width above its surface.\n * - A link is a dashed line. The picture shows it while its record, or the record of one of its ends, has a highlight.\n * - A field is a grid of colors on its plane. A cell with no value is clear.\n * - A meter has no place, so the content ignores it.\n *\n * A mark that a solid of an earlier content hides is less clear, and a mark with a highlight stays solid.\n * A sign gets a pick before each other record, and a run gets a pick before a field.\n * A run and a field give the distance of their pick.\n * Put the content after the content of the solids in `stackContents`.\n */\nexport function createMarkers(marks: readonly Mark[], options: MarkersOptions = {}): MarkersContent {\n const signRadius = options.signRadius ?? SIGN_RADIUS;\n const linkHalf = (options.linkWidth ?? 2) / 2;\n const linkDash = options.linkDash ?? [6, 4];\n const points = marks.filter((mark) => mark.type === \"point\");\n const paths = marks.filter((mark) => mark.type === \"run\");\n const lines = marks.filter((mark) => mark.type === \"link\");\n const grids = marks.filter((mark) => mark.type === \"field\").filter(hasGrid);\n const records = new Set([...points, ...paths, ...lines, ...grids].map((mark) => mark.record));\n\n // The space of the marks: the extent of the content, and the default of the lift.\n const corners: Vector3[] = [];\n for (const mark of points) corners.push(vector(mark.frame.at));\n for (const mark of paths) for (const frame of mark.path) corners.push(vector(frame.at));\n for (const mark of lines) corners.push(vector(mark.from.at), vector(mark.to.at));\n for (const mark of grids) {\n const origin = vector(mark.frame.at);\n const across = vector(mark.across).multiplyScalar(mark.columns * mark.cell);\n const down = vector(fieldRowStep(mark)).multiplyScalar(mark.rows * mark.cell);\n corners.push(origin, origin.clone().add(across), origin.clone().add(down), origin.clone().add(across).add(down));\n }\n const low = new Vector3(Infinity, Infinity, Infinity);\n const high = new Vector3(-Infinity, -Infinity, -Infinity);\n for (const corner of corners) {\n low.min(corner);\n high.max(corner);\n }\n const some = corners.length > 0;\n const size = some ? high.distanceTo(low) : 0;\n const lift = options.lift ?? (size > 0 ? size / 400 : 0.01);\n const center = some ? low.clone().add(high).multiplyScalar(0.5) : new Vector3();\n const box = some ? [0, 1, 2, 3, 4, 5, 6, 7].map((at) => ({ x: at & 1 ? high.x : low.x, y: at & 2 ? high.y : low.y, z: at & 4 ? high.z : low.z })) : [];\n\n /** The length of one CSS pixel at the distance 1 from the camera. The first step of the stage gives the correct value. */\n const pixelAngle = { value: (2 * Math.tan((FIELD_OF_VIEW * Math.PI) / 360)) / 720 };\n /** The direction of the camera at the last step. */\n let sight: Vector3 | undefined;\n const color = new Color();\n const put = (to: Float32Array, at: number, from: Color): void => {\n to[at * 3] = from.r;\n to[at * 3 + 1] = from.g;\n to[at * 3 + 2] = from.b;\n };\n\n // The signs: one instance for each point.\n const signs: SignPart[] = points.map((mark) => ({\n mark,\n at: vector(mark.frame.at),\n world: mark.size === undefined ? 0 : Math.max(mark.size, 0) / 2,\n outline: SHAPE_OUTLINES[levelShape(mark.level)],\n shown: true,\n highlight: 0,\n }));\n const signGeometry = squareOf(-1);\n const signCenters = new Float32Array(signs.length * 3);\n const signLifted = new Float32Array(signs.length * 3);\n const signOutlines = new Float32Array(signs.length * 4);\n signs.forEach((part, index) => {\n const above = vector(part.mark.frame.out).multiplyScalar(lift).add(part.at);\n signCenters.set([part.at.x, part.at.y, part.at.z], index * 3);\n signLifted.set([above.x, above.y, above.z], index * 3);\n signOutlines.set([part.outline.radius, part.outline.sides, part.outline.start, part.outline.hole], index * 4);\n });\n const signFills = new InstancedBufferAttribute(new Float32Array(signs.length * 3), 3);\n const signRings = new InstancedBufferAttribute(new Float32Array(signs.length * 3), 3);\n const signLooks = new InstancedBufferAttribute(new Float32Array(signs.length * 4), 4);\n signGeometry.setAttribute(\"center\", new InstancedBufferAttribute(signCenters, 3));\n signGeometry.setAttribute(\"lifted\", new InstancedBufferAttribute(signLifted, 3));\n signGeometry.setAttribute(\"outline\", new InstancedBufferAttribute(signOutlines, 4));\n signGeometry.setAttribute(\"fill\", signFills);\n signGeometry.setAttribute(\"ring\", signRings);\n signGeometry.setAttribute(\"look\", signLooks);\n signGeometry.instanceCount = signs.length;\n\n // The segments: the line around each run, each run, the line around each field, and each link, in this sequence.\n // A later segment is above an earlier segment. Thus the round end of a line around a run does not go across the run.\n const runSegments = paths.reduce((sum, mark) => sum + Math.max(mark.path.length - 1, 0), 0);\n const segmentCount = runSegments * 2 + grids.length * 4 + lines.length;\n const segmentGeometry = squareOf(0);\n const starts = new Float32Array(segmentCount * 3);\n const finishes = new Float32Array(segmentCount * 3);\n const dashes = new Float32Array(segmentCount * 2);\n const setSegment = (index: number, from: Vector3, to: Vector3): void => {\n starts.set([from.x, from.y, from.z], index * 3);\n finishes.set([to.x, to.y, to.z], index * 3);\n };\n let nextRun = 0;\n const runs: RunPart[] = paths.map((mark) => {\n const line = mark.path.map((frame) => vector(frame.out).multiplyScalar(Math.max(mark.width, 0) / 2).add(vector(frame.at)));\n const part: RunPart = { mark, points: line, casing: nextRun, body: runSegments + nextRun, shown: true, highlight: 0 };\n for (let at = 0; at + 1 < line.length; at += 1) {\n const from = line[at];\n const to = line[at + 1];\n if (from === undefined || to === undefined) continue;\n setSegment(part.casing + at, from, to);\n setSegment(part.body + at, from, to);\n }\n nextRun += Math.max(line.length - 1, 0);\n return part;\n });\n const fields: FieldPart[] = grids.map((mark, index) => {\n const out = vector(mark.frame.out);\n const origin = vector(mark.frame.at);\n const across = vector(mark.across);\n const down = vector(fieldRowStep(mark));\n const width = across.clone().multiplyScalar(mark.columns * mark.cell);\n const height = down.clone().multiplyScalar(mark.rows * mark.cell);\n const first = out.clone().multiplyScalar(lift).add(origin);\n const square = [first, first.clone().add(width), first.clone().add(width).add(height), first.clone().add(height)] as const;\n const geometry = new BufferGeometry();\n geometry.setAttribute(\"position\", new BufferAttribute(new Float32Array(square.flatMap((corner) => [corner.x, corner.y, corner.z])), 3));\n geometry.setAttribute(\"uv\", new BufferAttribute(new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]), 2));\n geometry.setIndex([0, 1, 2, 0, 2, 3]);\n const texture = new DataTexture(new Uint8Array(mark.columns * mark.rows * 4), mark.columns, mark.rows, RGBAFormat, UnsignedByteType);\n texture.colorSpace = SRGBColorSpace;\n // A cell has one color with a sharp edge.\n texture.magFilter = NearestFilter;\n texture.minFilter = NearestFilter;\n texture.generateMipmaps = false;\n const mesh = new Mesh(geometry, new MeshBasicMaterial({ map: texture, transparent: true, depthWrite: false, side: DoubleSide }));\n mesh.renderOrder = 7;\n const border = runSegments * 2 + index * 4;\n square.forEach((corner, at) => {\n setSegment(border + at, corner, square[(at + 1) % 4] ?? corner);\n });\n return { mark, mesh, texture, plane: new Plane().setFromNormalAndCoplanarPoint(out, first), origin, across, down, border, shown: true, highlight: 0 };\n });\n const links: LinkPart[] = lines.map((mark, index) => {\n const segment = runSegments * 2 + grids.length * 4 + index;\n setSegment(segment, vector(mark.from.at), vector(mark.to.at));\n dashes.set([Math.max(linkDash[0], 0), Math.max(linkDash[1], 0)], segment * 2);\n return { mark, segment, shown: true };\n });\n const segmentFills = new InstancedBufferAttribute(new Float32Array(segmentCount * 3), 3);\n const segmentWides = new InstancedBufferAttribute(new Float32Array(segmentCount * 3), 3);\n const segmentShades = new InstancedBufferAttribute(new Float32Array(segmentCount * 2), 2);\n segmentGeometry.setAttribute(\"start\", new InstancedBufferAttribute(starts, 3));\n segmentGeometry.setAttribute(\"finish\", new InstancedBufferAttribute(finishes, 3));\n segmentGeometry.setAttribute(\"dash\", new InstancedBufferAttribute(dashes, 2));\n segmentGeometry.setAttribute(\"fill\", segmentFills);\n segmentGeometry.setAttribute(\"wide\", segmentWides);\n segmentGeometry.setAttribute(\"shade\", segmentShades);\n segmentGeometry.instanceCount = segmentCount;\n\n // Each mesh has two passes. The first pass has no depth test, and it draws the part of a mark that a solid hides.\n const passes = (geometry: InstancedBufferGeometry, vertexShader: string, fragmentShader: string, order: number, count: number): Mesh<InstancedBufferGeometry, ShaderMaterial>[] =>\n [1, 0].map((behind, at) => {\n const material = new ShaderMaterial({\n uniforms: { pixelAngle, halo: { value: HALO }, behind: { value: behind } },\n vertexShader,\n fragmentShader,\n transparent: true,\n depthTest: behind === 0,\n depthWrite: false,\n side: DoubleSide,\n });\n const mesh = new Mesh(geometry, material);\n mesh.renderOrder = order + at;\n // The place of each instance comes from its attributes, so the bounds of the square tell nothing.\n mesh.frustumCulled = false;\n mesh.visible = count > 0;\n return mesh;\n });\n const segmentMeshes = passes(segmentGeometry, SEGMENT_VERTEX, SEGMENT_FRAGMENT, 8, segmentCount);\n const signMeshes = passes(signGeometry, SIGN_VERTEX, SIGN_FRAGMENT, 10, signs.length);\n\n let painted: MarkersTheme | undefined;\n\n /** This function gives each cell of each field its color. */\n const paintFields = (theme: MarkersTheme): void => {\n const stops = theme.field.map((hex) => color.set(hex).getRGB({ r: 0, g: 0, b: 0 }, SRGBColorSpace));\n for (const part of fields) {\n const { min, max } = part.mark.scale;\n const own = color.set(theme.levels[part.mark.level]).getRGB({ r: 0, g: 0, b: 0 }, SRGBColorSpace);\n const data = part.texture.image.data as Uint8Array;\n for (let cell = 0; cell < part.mark.columns * part.mark.rows; cell += 1) {\n const value = part.mark.values[cell];\n if (value === null || value === undefined || !Number.isFinite(value)) {\n data.fill(0, cell * 4, cell * 4 + 4);\n continue;\n }\n // The value as a part of the scale, and then as a place in the list of the colors.\n const part01 = max > min ? Math.min(Math.max((value - min) / (max - min), 0), 1) : 0;\n const place = part01 * Math.max(stops.length - 1, 0);\n const before = stops[Math.min(Math.floor(place), Math.max(stops.length - 2, 0))] ?? own;\n const after = stops[Math.min(Math.floor(place), Math.max(stops.length - 2, 0)) + 1] ?? before;\n const mix = place - Math.min(Math.floor(place), Math.max(stops.length - 2, 0));\n data[cell * 4] = Math.round((before.r + (after.r - before.r) * mix) * 255);\n data[cell * 4 + 1] = Math.round((before.g + (after.g - before.g) * mix) * 255);\n data[cell * 4 + 2] = Math.round((before.b + (after.b - before.b) * mix) * 255);\n data[cell * 4 + 3] = 255;\n }\n part.texture.needsUpdate = true;\n part.mesh.material.opacity = Math.min(Math.max(theme.fieldOpacity ?? 0.8, 0), 1);\n }\n };\n\n /** This function writes the colors, the sizes and the shades of each mark from its highlight and from the filter. */\n const sync = (theme: MarkersTheme): void => {\n signs.forEach((part, index) => {\n const lit = part.highlight !== 0;\n const grow = HIGHLIGHT_SIZE[part.highlight];\n put(signFills.array as Float32Array, index, color.set(theme.levels[part.mark.level]));\n put(signRings.array as Float32Array, index, color.set(lit ? theme.accent : theme.halo));\n // A sign with a highlight is solid also behind a solid, so that a person finds it.\n signLooks.array.set([part.world > 0 ? 0 : signRadius * grow, part.world * grow, part.shown ? 1 : 0, part.shown ? (lit ? 1 : HIDDEN_OPACITY) : 0], index * 4);\n });\n const fills = segmentFills.array as Float32Array;\n const setLook = (segment: number, pixels: number, world: number, least: number, inSight: number, hidden: number): void => {\n segmentWides.array.set([pixels, world, least], segment * 3);\n segmentShades.array.set([inSight, hidden], segment * 2);\n };\n for (const part of runs) {\n const lit = part.highlight !== 0;\n const half = Math.max(part.mark.width, 0) / 2;\n const inSight = part.shown ? 1 : 0;\n const hidden = part.shown ? (lit ? 1 : HIDDEN_OPACITY) : 0;\n for (let at = 0; at + 1 < part.points.length; at += 1) {\n put(fills, part.casing + at, color.set(lit ? theme.accent : theme.halo));\n setLook(part.casing + at, CASING[part.highlight], half, LEAST_RUN, inSight, hidden);\n put(fills, part.body + at, color.set(theme.levels[part.mark.level]));\n setLook(part.body + at, 0, half, LEAST_RUN, inSight, hidden);\n }\n }\n for (const part of fields) {\n const lit = part.shown && part.highlight !== 0;\n part.mesh.visible = part.shown;\n for (let at = 0; at < 4; at += 1) {\n put(fills, part.border + at, color.set(theme.accent));\n setLook(part.border + at, BORDER[part.highlight], 0, 0, lit ? 1 : 0, lit ? HIDDEN_OPACITY : 0);\n }\n }\n for (const part of links) {\n put(fills, part.segment, color.set(theme.levels[part.mark.level]));\n // A link is above each solid: it joins two records, and one of them can be behind a solid.\n setLook(part.segment, linkHalf, 0, 0, part.shown ? 1 : 0, part.shown ? 1 : 0);\n }\n signFills.needsUpdate = true;\n signRings.needsUpdate = true;\n signLooks.needsUpdate = true;\n segmentFills.needsUpdate = true;\n segmentWides.needsUpdate = true;\n segmentShades.needsUpdate = true;\n };\n\n /** The marks that the filter accepts. A link also needs a highlight, so it has its own state. */\n let accepted: (mark: Mark) => boolean = () => true;\n let lit: (record: string) => Highlight = () => 0;\n const setShown = (): void => {\n for (const part of signs) part.shown = accepted(part.mark);\n for (const part of runs) part.shown = accepted(part.mark);\n for (const part of fields) part.shown = accepted(part.mark);\n for (const part of links) part.shown = accepted(part.mark) && (lit(part.mark.record) !== 0 || lit(part.mark.from.record) !== 0 || lit(part.mark.to.record) !== 0);\n };\n\n const toMark = new Vector3();\n const onRay = new Vector3();\n const onLine = new Vector3();\n const hit = new Vector3();\n\n return {\n objects: [...fields.map((part) => part.mesh), ...segmentMeshes, ...signMeshes] satisfies Object3D[],\n extent: { center: { x: center.x, y: center.y, z: center.z }, corners: box },\n has: (record) => records.has(record),\n pick(ray): StagePick<Mark> | undefined {\n const { origin, direction } = ray.ray;\n const forward = sight ?? direction;\n const facing = direction.dot(forward);\n if (facing <= 1e-9) return undefined;\n // A sign is above each solid, so it gets the pick first. The sign nearest to the pointer is the record.\n let sign: SignPart | undefined;\n let nearest = Infinity;\n for (const part of signs) {\n if (!part.shown) continue;\n toMark.subVectors(part.at, origin);\n const depth = toMark.dot(forward);\n if (depth <= 0) continue;\n const pixel = depth * pixelAngle.value;\n const radius = (part.world > 0 ? part.world : signRadius * pixel) * HIGHLIGHT_SIZE[part.highlight] * part.outline.radius + PICK_MARGIN * pixel;\n // The point of the ray in the plane of the sign, from the center of the sign.\n const away = hit.copy(direction).multiplyScalar(depth / facing).sub(toMark).length();\n if (away > radius || away / pixel >= nearest) continue;\n sign = part;\n nearest = away / pixel;\n }\n if (sign !== undefined) return { record: sign.mark.record, value: sign.mark };\n // A run and a field are in the space with the solids, so their pick has a distance.\n let found: Mark | undefined;\n let distance = Infinity;\n for (const part of runs) {\n if (!part.shown) continue;\n for (let at = 0; at + 1 < part.points.length; at += 1) {\n const from = part.points[at];\n const to = part.points[at + 1];\n if (from === undefined || to === undefined) continue;\n const squared = ray.ray.distanceSqToSegment(from, to, onRay, onLine);\n const along = onRay.distanceTo(origin);\n const pixel = along * facing * pixelAngle.value;\n const reach = Math.max(part.mark.width / 2, LEAST_RUN * pixel) + (CASING[0] + PICK_MARGIN) * pixel;\n // The distance is to the side of the run that is nearest to the camera. The picture has the same depth.\n // Thus the surface below a run does not get the pick of the run.\n const side = Math.max(along - reach, 0);\n if (squared > reach * reach || side >= distance) continue;\n found = part.mark;\n distance = side;\n }\n }\n // The picture draws a run above each field. So a run gets the pick before a field.\n if (found !== undefined) return { record: found.record, value: found, distance };\n for (const part of fields) {\n if (!part.shown || ray.ray.intersectPlane(part.plane, hit) === null) continue;\n const along = hit.distanceTo(origin);\n if (along >= distance) continue;\n toMark.subVectors(hit, part.origin);\n const column = Math.floor(toMark.dot(part.across) / part.mark.cell);\n const row = Math.floor(toMark.dot(part.down) / part.mark.cell);\n if (fieldValue(part.mark, column, row) === null) continue;\n found = part.mark;\n distance = along;\n }\n return found === undefined ? undefined : { record: found.record, value: found, distance };\n },\n paint(theme, highlight): void {\n if (theme !== painted) paintFields(theme);\n painted = theme;\n lit = highlight;\n for (const part of signs) part.highlight = highlight(part.mark.record);\n for (const part of runs) part.highlight = highlight(part.mark.record);\n for (const part of fields) part.highlight = highlight(part.mark.record);\n setShown();\n sync(theme);\n },\n step(frame: StageFrame): boolean {\n pixelAngle.value = (2 * Math.tan((frame.fieldOfView * Math.PI) / 360)) / Math.max(frame.height, 1);\n sight = frame.camera.getWorldDirection(sight ?? new Vector3());\n return false;\n },\n show(test): void {\n accepted = test;\n setShown();\n if (painted !== undefined) sync(painted);\n },\n dispose(): void {\n signGeometry.dispose();\n segmentGeometry.dispose();\n for (const mesh of [...segmentMeshes, ...signMeshes]) mesh.material.dispose();\n for (const part of fields) {\n part.mesh.geometry.dispose();\n part.mesh.material.dispose();\n part.texture.dispose();\n }\n },\n };\n}\n"],"mappings":";;;;;AAsEA,MAAa,cAAc;;AAG3B,MAAM,OAAO;;AAGb,MAAM,SAA4C;CAAC;CAAK;CAAK;AAAC;;AAG9D,MAAM,iBAAoD;CAAC;CAAG;CAAM;AAAG;;AAGvE,MAAM,SAA4C;CAAC;CAAG;CAAG;AAAG;;AAG5D,MAAM,YAAY;;AAGlB,MAAM,iBAAiB;;AAGvB,MAAM,cAAc;;AAGpB,MAAM,cAAc;;AAGpB,SAAS,QAAQ,SAA+B;CAC9C,IAAI,QAAQ,QAAQ,aAAa,OAAO,QAAQ,SAAS;CACzD,MAAM,QAAQ,KAAK,IAAI,KAAK,KAAK,QAAQ,KAAK;CAC9C,QAAQ,QAAQ,SAAS,QAAQ,QAAQ;AAC3C;;;;;AAMA,SAAgB,UAAU,OAAc,SAAA,GAAsC;CAC5E,OAAO,SAAS,QAAQ,eAAe,WAAW,KAAK,EAAE;AAC3D;AAOA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;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S: readonly ["unknown", "ok", "near", "over"];
|
|
4
|
-
/**
|
|
5
|
-
* A level of a mark, in the scale of limits. `ok` is below a limit, `near` is near it and `over` is above it.
|
|
6
|
-
* A mark with no known value has `unknown`. The producer of a mark calculates the level, because each topic has its own limits.
|
|
7
|
-
*/
|
|
8
|
-
type Level = (typeof LEVELS)[number];
|
|
9
|
-
/**
|
|
10
|
-
* This function gives the rank of a level: 0 for `unknown` and 3 for `over`.
|
|
11
|
-
* A viewer draws the marks in the sequence of their ranks, so the worst level is always in view.
|
|
12
|
-
*/
|
|
13
|
-
export declare function levelRank(level: Level): number;
|
|
14
|
-
/** These are the shapes of the sign of a level. */
|
|
15
|
-
export declare const LEVEL_SHAPES: readonly ["ring", "disc", "triangle", "square"];
|
|
16
|
-
/** A shape of the sign of a level. A person who does not see a color reads the level from the shape. */
|
|
17
|
-
type LevelShape = (typeof LEVEL_SHAPES)[number];
|
|
18
|
-
/**
|
|
19
|
-
* This function gives the shape of the sign of a level: a disc for `ok`, a triangle for `near` and a square for `over`.
|
|
20
|
-
* The level `unknown` has a ring, and so has a record with no level.
|
|
21
|
-
*/
|
|
22
|
-
export declare function levelShape(level: Level | undefined): LevelShape;
|
|
23
|
-
/** The outline of the sign of a shape, as a regular polygon. A circle is a polygon with 40 sides. */
|
|
24
|
-
interface ShapeOutline {
|
|
25
|
-
/** The radius of the circle through the corners, for a disc with the radius 1. */
|
|
26
|
-
readonly radius: number;
|
|
27
|
-
/** The number of the sides. */
|
|
28
|
-
readonly sides: number;
|
|
29
|
-
/** The angle of the first corner, in radians, counter-clockwise from the x axis. */
|
|
30
|
-
readonly start: number;
|
|
31
|
-
/** The radius of the hole of the sign, for a disc with the radius 1. A sign with no hole has 0. */
|
|
32
|
-
readonly hole: number;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* The outline of the sign of each shape. Each viewer draws the signs from these values, so each viewer shows the same signs.
|
|
36
|
-
* A triangle and a square with the radius of the disc look small, so they are larger.
|
|
37
|
-
*/
|
|
38
|
-
export declare const SHAPE_OUTLINES: Readonly<Record<LevelShape, ShapeOutline>>;
|
|
39
|
-
/**
|
|
40
|
-
* This function gives the corners of the outline of a sign, counter-clockwise, with the y axis up.
|
|
41
|
-
* The center of the sign is the origin, and `radius` is the radius of a disc.
|
|
42
|
-
*/
|
|
43
|
-
export declare function shapeRing(shape: LevelShape, radius?: number): Ring;
|
|
44
|
-
/** A point of a surface, and the direction out of the surface. */
|
|
45
|
-
interface Frame {
|
|
46
|
-
/** The point. */
|
|
47
|
-
readonly at: Point3;
|
|
48
|
-
/** The unit vector out of the surface at the point. */
|
|
49
|
-
readonly out: Point3;
|
|
50
|
-
}
|
|
51
|
-
/** These are the types of a mark. */
|
|
52
|
-
export declare const MARK_TYPES: readonly ["point", "run", "link", "field", "meter"];
|
|
53
|
-
/** A type of a mark. */
|
|
54
|
-
type MarkType = (typeof MARK_TYPES)[number];
|
|
55
|
-
/**
|
|
56
|
-
* The parts that each mark has. A mark has no shape and no color.
|
|
57
|
-
* A viewer gets the shape from the level, and the color from the level and its theme. Thus a mark does not use color alone.
|
|
58
|
-
*/
|
|
59
|
-
interface MarkBase {
|
|
60
|
-
/** The name of the record of the mark. The pointer and the selection of a viewer use this name. */
|
|
61
|
-
readonly record: string;
|
|
62
|
-
/** A word of the producer for the legend and the filter, for example `outlet`. */
|
|
63
|
-
readonly kind: string;
|
|
64
|
-
/** The level of the mark. The producer calculates it. */
|
|
65
|
-
readonly level: Level;
|
|
66
|
-
/** One line of text: the name of the mark for a person and for a screen reader. */
|
|
67
|
-
readonly label: string;
|
|
68
|
-
}
|
|
69
|
-
/** A mark at one point of a surface, for example an outlet, a tap or a lamp. */
|
|
70
|
-
interface PointMark extends MarkBase {
|
|
71
|
-
readonly type: "point";
|
|
72
|
-
/** The point, and the direction out of its surface. */
|
|
73
|
-
readonly frame: Frame;
|
|
74
|
-
/** The width of the sign, in the unit of the space. A mark with no size gets the default size of the viewer. */
|
|
75
|
-
readonly size?: number | undefined;
|
|
76
|
-
}
|
|
77
|
-
/** A mark along a path on surfaces, for example a cable, a pipe or a duct. */
|
|
78
|
-
interface RunMark extends MarkBase {
|
|
79
|
-
readonly type: "run";
|
|
80
|
-
/** The points of the path, in sequence. Each point has its own direction, so a run can go across surfaces. A path has 2 or more points. */
|
|
81
|
-
readonly path: readonly Frame[];
|
|
82
|
-
/** The width of the run, in the unit of the space. */
|
|
83
|
-
readonly width: number;
|
|
84
|
-
}
|
|
85
|
-
/** One end of a link. */
|
|
86
|
-
interface LinkEnd {
|
|
87
|
-
/** The name of the record at this end. A viewer shows the link when the record of one end is selected or under the pointer. */
|
|
88
|
-
readonly record: string;
|
|
89
|
-
/** The point of this end. */
|
|
90
|
-
readonly at: Point3;
|
|
91
|
-
}
|
|
92
|
-
/** A mark between two records, for example a power line from an outlet to a computer. */
|
|
93
|
-
interface LinkMark extends MarkBase {
|
|
94
|
-
readonly type: "link";
|
|
95
|
-
readonly from: LinkEnd;
|
|
96
|
-
readonly to: LinkEnd;
|
|
97
|
-
}
|
|
98
|
-
/** The scale of the values of a field. The theme of a viewer gives the colors from `min` to `max`. */
|
|
99
|
-
interface FieldScale {
|
|
100
|
-
/** The value of the first color. It is less than `max`. */
|
|
101
|
-
readonly min: number;
|
|
102
|
-
/** The value of the last color. */
|
|
103
|
-
readonly max: number;
|
|
104
|
-
/** The text of the unit of the values, for example `lx`. */
|
|
105
|
-
readonly unit: string;
|
|
106
|
-
}
|
|
107
|
-
/** A grid of values on a plane, for example the light on a floor or the heat of a wall. */
|
|
108
|
-
interface FieldMark extends MarkBase {
|
|
109
|
-
readonly type: "field";
|
|
110
|
-
/** The corner of the first cell, and the direction out of the plane. */
|
|
111
|
-
readonly frame: Frame;
|
|
112
|
-
/** The unit vector of a column step, in the plane. The step of a row is the cross product of `frame.out` and `across`. */
|
|
113
|
-
readonly across: Point3;
|
|
114
|
-
/** The length of a side of a cell, in the unit of the space. */
|
|
115
|
-
readonly cell: number;
|
|
116
|
-
/** The number of the columns. */
|
|
117
|
-
readonly columns: number;
|
|
118
|
-
/** The number of the rows. */
|
|
119
|
-
readonly rows: number;
|
|
120
|
-
/**
|
|
121
|
-
* The values, row by row. The value of the column `c` and the row `r` has the index `r * columns + c`.
|
|
122
|
-
* A cell with no value has `null`, because JSON has no NaN.
|
|
123
|
-
*/
|
|
124
|
-
readonly values: readonly (number | null)[];
|
|
125
|
-
readonly scale: FieldScale;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* A value against a limit, for example the load of a circuit. A meter has no place.
|
|
129
|
-
* A page draws it in a panel, and a 3D view ignores it.
|
|
130
|
-
*/
|
|
131
|
-
interface MeterMark extends MarkBase {
|
|
132
|
-
readonly type: "meter";
|
|
133
|
-
readonly value: number;
|
|
134
|
-
/**
|
|
135
|
-
* The limit of the value. A meter with no limit has no `limit`, for example a circuit with a known load and no known breaker.
|
|
136
|
-
* A page shows only the value and the unit of that meter. A limit of 0 is a real limit, so it is not a sign for no limit.
|
|
137
|
-
*/
|
|
138
|
-
readonly limit?: number | undefined;
|
|
139
|
-
/** The text of the unit of the value and of the limit, for example `W`. */
|
|
140
|
-
readonly unit: string;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* A record that a viewer draws. A mark is plain data with no topic, so it goes through JSON with no change.
|
|
144
|
-
* Each point of a list of marks is in one space. The producer tells the unit and the axes of that space.
|
|
145
|
-
*/
|
|
146
|
-
type Mark = PointMark | RunMark | LinkMark | FieldMark | MeterMark;
|
|
147
|
-
/** This function gives the unit vector of a row step of a field: the cross product of `frame.out` and `across`. */
|
|
148
|
-
export declare function fieldRowStep(field: FieldMark): Point3;
|
|
149
|
-
/** This function gives the center of a cell of a field. The first cell has the column 0 and the row 0. */
|
|
150
|
-
export declare function fieldCellCenter(field: FieldMark, column: number, row: number): Point3;
|
|
151
|
-
/** This function gives the value of a cell of a field. A cell with no value gives `null`, and so does a cell that is not in the grid. */
|
|
152
|
-
export declare function fieldValue(field: FieldMark, column: number, row: number): number | null;
|
|
1
|
+
import { C as levelShape, S as levelRank, _ as LEVEL_SHAPES, a as LinkMark, b as SHAPE_OUTLINES, c as MarkBase, d as PointMark, f as RunMark, g as LEVELS, h as fieldValue, i as LinkEnd, l as MarkType, m as fieldRowStep, n as FieldScale, o as MARK_TYPES, p as fieldCellCenter, r as Frame, s as Mark, t as FieldMark, u as MeterMark, v as Level, w as shapeRing, x as ShapeOutline, y as LevelShape } from "./mark-D8AdQYAS.js";
|
|
153
2
|
/**
|
|
154
3
|
* These are the codes of the faults of a mark:
|
|
155
4
|
* - `type`: the type of the mark is not known. A list from a later version of a producer can have a new type.
|
|
@@ -192,5 +41,5 @@ export declare const DIRECTION_TOLERANCE = 1e-6;
|
|
|
192
41
|
* It does not examine the form of a mark: read a list from JSON through a schema first.
|
|
193
42
|
*/
|
|
194
43
|
export declare function checkMarks(marks: readonly Mark[]): readonly MarkFault[];
|
|
195
|
-
export type
|
|
44
|
+
export { type FieldMark, type FieldScale, type Frame, LEVELS, LEVEL_SHAPES, type Level, type LevelShape, type LinkEnd, type LinkMark, MARK_TYPES, type Mark, type MarkBase, type MarkFault, type MarkFaultCode, type MarkType, type MeterMark, type PointMark, type RunMark, SHAPE_OUTLINES, type ShapeOutline, fieldCellCenter, fieldRowStep, fieldValue, levelRank, levelShape, shapeRing };
|
|
196
45
|
//# sourceMappingURL=marks.d.ts.map
|
package/build/marks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marks.d.ts","names":[],"sources":["../src/marks/
|
|
1
|
+
{"version":3,"file":"marks.d.ts","names":[],"sources":["../src/marks/check.ts"],"mappings":";;;;;;;;;;;;;;;;qBAmBa;;KAgBD,wBAAwB;;UAGnB;WACN,MAAM;;WAEN;;WAEA;;WAEA;;WAEA;;;;;;qBAOE;;;;;;;wBAQG,WAAW,gBAAgB,kBAAkB"}
|
package/build/marks.js
CHANGED
|
@@ -1,74 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/** These are the levels of a mark, from the lowest to the highest. */
|
|
4
|
-
const LEVELS = [
|
|
5
|
-
"unknown",
|
|
6
|
-
"ok",
|
|
7
|
-
"near",
|
|
8
|
-
"over"
|
|
9
|
-
];
|
|
10
|
-
/**
|
|
11
|
-
* This function gives the rank of a level: 0 for `unknown` and 3 for `over`.
|
|
12
|
-
* A viewer draws the marks in the sequence of their ranks, so the worst level is always in view.
|
|
13
|
-
*/
|
|
14
|
-
function levelRank(level) {
|
|
15
|
-
return LEVELS.indexOf(level);
|
|
16
|
-
}
|
|
17
|
-
/** These are the shapes of the sign of a level. */
|
|
18
|
-
const LEVEL_SHAPES = [
|
|
19
|
-
"ring",
|
|
20
|
-
"disc",
|
|
21
|
-
"triangle",
|
|
22
|
-
"square"
|
|
23
|
-
];
|
|
24
|
-
/**
|
|
25
|
-
* This function gives the shape of the sign of a level: a disc for `ok`, a triangle for `near` and a square for `over`.
|
|
26
|
-
* The level `unknown` has a ring, and so has a record with no level.
|
|
27
|
-
*/
|
|
28
|
-
function levelShape(level) {
|
|
29
|
-
return level === "ok" ? "disc" : level === "near" ? "triangle" : level === "over" ? "square" : "ring";
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* The outline of the sign of each shape. Each viewer draws the signs from these values, so each viewer shows the same signs.
|
|
33
|
-
* A triangle and a square with the radius of the disc look small, so they are larger.
|
|
34
|
-
*/
|
|
35
|
-
const SHAPE_OUTLINES = {
|
|
36
|
-
ring: {
|
|
37
|
-
radius: 1,
|
|
38
|
-
sides: 40,
|
|
39
|
-
start: 0,
|
|
40
|
-
hole: .52
|
|
41
|
-
},
|
|
42
|
-
disc: {
|
|
43
|
-
radius: 1,
|
|
44
|
-
sides: 40,
|
|
45
|
-
start: 0,
|
|
46
|
-
hole: 0
|
|
47
|
-
},
|
|
48
|
-
triangle: {
|
|
49
|
-
radius: 1.3,
|
|
50
|
-
sides: 3,
|
|
51
|
-
start: Math.PI / 2,
|
|
52
|
-
hole: 0
|
|
53
|
-
},
|
|
54
|
-
square: {
|
|
55
|
-
radius: 1.25,
|
|
56
|
-
sides: 4,
|
|
57
|
-
start: Math.PI / 4,
|
|
58
|
-
hole: 0
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* This function gives the corners of the outline of a sign, counter-clockwise, with the y axis up.
|
|
63
|
-
* The center of the sign is the origin, and `radius` is the radius of a disc.
|
|
64
|
-
*/
|
|
65
|
-
function shapeRing(shape, radius = 1) {
|
|
66
|
-
const outline = SHAPE_OUTLINES[shape];
|
|
67
|
-
return Array.from({ length: outline.sides }, (_, index) => {
|
|
68
|
-
const angle = outline.start + index * 2 * Math.PI / outline.sides;
|
|
69
|
-
return [radius * outline.radius * Math.cos(angle), radius * outline.radius * Math.sin(angle)];
|
|
70
|
-
});
|
|
71
|
-
}
|
|
1
|
+
import { a as LEVELS, c as levelRank, i as fieldValue, l as levelShape, n as fieldCellCenter, o as LEVEL_SHAPES, r as fieldRowStep, s as SHAPE_OUTLINES, t as MARK_TYPES, u as shapeRing } from "./mark-AZ5AuAIJ.js";
|
|
2
|
+
import { dot3, length3 } from "@mark1russell7/layout-contract";
|
|
72
3
|
// src/marks/check.ts
|
|
73
4
|
/**
|
|
74
5
|
* These are the codes of the faults of a mark:
|
|
@@ -202,30 +133,6 @@ function checkMarks(marks) {
|
|
|
202
133
|
});
|
|
203
134
|
return faults;
|
|
204
135
|
}
|
|
205
|
-
// src/marks/mark.ts
|
|
206
|
-
/** These are the types of a mark. */
|
|
207
|
-
const MARK_TYPES = [
|
|
208
|
-
"point",
|
|
209
|
-
"run",
|
|
210
|
-
"link",
|
|
211
|
-
"field",
|
|
212
|
-
"meter"
|
|
213
|
-
];
|
|
214
|
-
/** This function gives the unit vector of a row step of a field: the cross product of `frame.out` and `across`. */
|
|
215
|
-
function fieldRowStep(field) {
|
|
216
|
-
return cross3(field.frame.out, field.across);
|
|
217
|
-
}
|
|
218
|
-
/** This function gives the center of a cell of a field. The first cell has the column 0 and the row 0. */
|
|
219
|
-
function fieldCellCenter(field, column, row) {
|
|
220
|
-
const across = scalePoint3(field.across, (column + .5) * field.cell);
|
|
221
|
-
const down = scalePoint3(fieldRowStep(field), (row + .5) * field.cell);
|
|
222
|
-
return addPoints3(field.frame.at, addPoints3(across, down));
|
|
223
|
-
}
|
|
224
|
-
/** This function gives the value of a cell of a field. A cell with no value gives `null`, and so does a cell that is not in the grid. */
|
|
225
|
-
function fieldValue(field, column, row) {
|
|
226
|
-
if (!Number.isInteger(column) || !Number.isInteger(row) || column < 0 || row < 0 || column >= field.columns || row >= field.rows) return null;
|
|
227
|
-
return field.values[row * field.columns + column] ?? null;
|
|
228
|
-
}
|
|
229
136
|
export { DIRECTION_TOLERANCE, LEVELS, LEVEL_SHAPES, MARK_FAULT_CODES, MARK_TYPES, SHAPE_OUTLINES, checkMarks, fieldCellCenter, fieldRowStep, fieldValue, levelRank, levelShape, shapeRing };
|
|
230
137
|
|
|
231
138
|
//# sourceMappingURL=marks.js.map
|
package/build/marks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marks.js","names":[],"sources":["../src/marks/levels.ts","../src/marks/check.ts","../src/marks/mark.ts"],"sourcesContent":["import type { Ring } from \"@mark1russell7/layout-contract\";\n\n/** These are the levels of a mark, from the lowest to the highest. */\nexport const LEVELS: readonly [\"unknown\", \"ok\", \"near\", \"over\"] = [\"unknown\", \"ok\", \"near\", \"over\"];\n\n/**\n * A level of a mark, in the scale of limits. `ok` is below a limit, `near` is near it and `over` is above it.\n * A mark with no known value has `unknown`. The producer of a mark calculates the level, because each topic has its own limits.\n */\nexport type Level = (typeof LEVELS)[number];\n\n/**\n * This function gives the rank of a level: 0 for `unknown` and 3 for `over`.\n * A viewer draws the marks in the sequence of their ranks, so the worst level is always in view.\n */\nexport function levelRank(level: Level): number {\n return LEVELS.indexOf(level);\n}\n\n/** These are the shapes of the sign of a level. */\nexport const LEVEL_SHAPES: readonly [\"ring\", \"disc\", \"triangle\", \"square\"] = [\"ring\", \"disc\", \"triangle\", \"square\"];\n\n/** A shape of the sign of a level. A person who does not see a color reads the level from the shape. */\nexport type LevelShape = (typeof LEVEL_SHAPES)[number];\n\n/**\n * This function gives the shape of the sign of a level: a disc for `ok`, a triangle for `near` and a square for `over`.\n * The level `unknown` has a ring, and so has a record with no level.\n */\nexport function levelShape(level: Level | undefined): LevelShape {\n return level === \"ok\" ? \"disc\" : level === \"near\" ? \"triangle\" : level === \"over\" ? \"square\" : \"ring\";\n}\n\n/** The outline of the sign of a shape, as a regular polygon. A circle is a polygon with 40 sides. */\nexport interface ShapeOutline {\n /** The radius of the circle through the corners, for a disc with the radius 1. */\n readonly radius: number;\n /** The number of the sides. */\n readonly sides: number;\n /** The angle of the first corner, in radians, counter-clockwise from the x axis. */\n readonly start: number;\n /** The radius of the hole of the sign, for a disc with the radius 1. A sign with no hole has 0. */\n readonly hole: number;\n}\n\n/**\n * The outline of the sign of each shape. Each viewer draws the signs from these values, so each viewer shows the same signs.\n * A triangle and a square with the radius of the disc look small, so they are larger.\n */\nexport const SHAPE_OUTLINES: Readonly<Record<LevelShape, ShapeOutline>> = {\n ring: { radius: 1, sides: 40, start: 0, hole: 0.52 },\n disc: { radius: 1, sides: 40, start: 0, hole: 0 },\n triangle: { radius: 1.3, sides: 3, start: Math.PI / 2, hole: 0 },\n square: { radius: 1.25, sides: 4, start: Math.PI / 4, hole: 0 },\n};\n\n/**\n * This function gives the corners of the outline of a sign, counter-clockwise, with the y axis up.\n * The center of the sign is the origin, and `radius` is the radius of a disc.\n */\nexport function shapeRing(shape: LevelShape, radius: number = 1): Ring {\n const outline = SHAPE_OUTLINES[shape];\n return Array.from({ length: outline.sides }, (_, index): readonly [number, number] => {\n const angle = outline.start + (index * 2 * Math.PI) / outline.sides;\n return [radius * outline.radius * Math.cos(angle), radius * outline.radius * Math.sin(angle)];\n });\n}\n","import { dot3, length3, type Point3 } from \"@mark1russell7/layout-contract\";\nimport { LEVELS } from \"./levels.ts\";\nimport type { Frame, Mark } from \"./mark.ts\";\n\n/**\n * These are the codes of the faults of a mark:\n * - `type`: the type of the mark is not known. A list from a later version of a producer can have a new type.\n * - `level`: the level of the mark is not known.\n * - `name`: a record name or the kind is empty.\n * - `label`: the label is empty, or it has more than one line.\n * - `number`: a number is not finite.\n * - `direction`: a direction is not a unit vector.\n * - `angle`: the column step of a field is not at a right angle to the direction out of its plane.\n * - `size`: a size, a width or a cell is not more than 0.\n * - `grid`: the number of the columns or of the rows of a field is not a whole number of 1 or more.\n * - `values`: a field does not have one value for each cell.\n * - `scale`: the `min` of the scale of a field is not less than its `max`.\n * - `path`: a run has fewer than 2 points.\n */\nexport const MARK_FAULT_CODES: readonly [\"type\", \"level\", \"name\", \"label\", \"number\", \"direction\", \"angle\", \"size\", \"grid\", \"values\", \"scale\", \"path\"] = [\n \"type\",\n \"level\",\n \"name\",\n \"label\",\n \"number\",\n \"direction\",\n \"angle\",\n \"size\",\n \"grid\",\n \"values\",\n \"scale\",\n \"path\",\n];\n\n/** A code of a fault of a mark. */\nexport type MarkFaultCode = (typeof MARK_FAULT_CODES)[number];\n\n/** One fault of a mark of a list. */\nexport interface MarkFault {\n readonly code: MarkFaultCode;\n /** The index of the mark in the list. */\n readonly index: number;\n /** The record name of the mark. */\n readonly record: string;\n /** The part of the mark with the fault, for example `path[2].out`. */\n readonly part: string;\n /** The fault in plain words, with the values. */\n readonly message: string;\n}\n\n/**\n * The tolerance of a direction. A unit vector has the length 1 with this tolerance.\n * Two directions are at a right angle when their dot product is 0 with this tolerance.\n */\nexport const DIRECTION_TOLERANCE = 1e-6;\n\n/**\n * This function gives the faults of a list of marks, in the sequence of the list. A list with no fault gives an empty list.\n * It examines the values that the types do not hold: finite numbers, unit vectors, sizes, the grid of a field and the names.\n * A producer of marks uses it as a gate in its tests, and a viewer uses it on a list that it did not make.\n * It does not examine the form of a mark: read a list from JSON through a schema first.\n */\nexport function checkMarks(marks: readonly Mark[]): readonly MarkFault[] {\n const faults: MarkFault[] = [];\n marks.forEach((mark, index) => {\n const fault = (code: MarkFaultCode, part: string, message: string): void => {\n faults.push({ code, index, record: mark.record, part, message });\n };\n const finite = (part: string, value: number): boolean => {\n if (Number.isFinite(value)) return true;\n fault(\"number\", part, `${part} is not a finite number: ${String(value)}`);\n return false;\n };\n const point = (part: string, value: Point3): boolean => {\n const x = finite(`${part}.x`, value.x);\n const y = finite(`${part}.y`, value.y);\n const z = finite(`${part}.z`, value.z);\n return x && y && z;\n };\n const direction = (part: string, value: Point3): boolean => {\n if (!point(part, value)) return false;\n const length = length3(value);\n if (Math.abs(length - 1) <= DIRECTION_TOLERANCE) return true;\n fault(\"direction\", part, `${part} is not a unit vector: its length is ${String(length)}`);\n return false;\n };\n const frame = (part: string, value: Frame): boolean => {\n const at = point(`${part}.at`, value.at);\n const out = direction(`${part}.out`, value.out);\n return at && out;\n };\n const positive = (part: string, value: number): void => {\n if (finite(part, value) && value <= 0) fault(\"size\", part, `${part} is not more than 0: ${String(value)}`);\n };\n const count = (part: string, value: number): boolean => {\n if (Number.isInteger(value) && value >= 1) return true;\n fault(\"grid\", part, `${part} is not a whole number of 1 or more: ${String(value)}`);\n return false;\n };\n\n if (mark.record === \"\") fault(\"name\", \"record\", \"the mark has no record name\");\n if (mark.kind === \"\") fault(\"name\", \"kind\", \"the mark has no kind\");\n if (!(LEVELS as readonly string[]).includes(mark.level)) fault(\"level\", \"level\", `the level is not known: ${String(mark.level)}`);\n if (mark.label.trim() === \"\") fault(\"label\", \"label\", \"the mark has no label\");\n else if (/[\\r\\n]/.test(mark.label)) fault(\"label\", \"label\", \"the label has more than one line\");\n\n switch (mark.type) {\n case \"point\":\n frame(\"frame\", mark.frame);\n if (mark.size !== undefined) positive(\"size\", mark.size);\n break;\n case \"run\":\n if (mark.path.length < 2) fault(\"path\", \"path\", `the path has ${String(mark.path.length)} points, and a run needs 2 or more`);\n mark.path.forEach((step, at) => frame(`path[${String(at)}]`, step));\n positive(\"width\", mark.width);\n break;\n case \"link\":\n for (const [name, end] of [\n [\"from\", mark.from],\n [\"to\", mark.to],\n ] as const) {\n if (end.record === \"\") fault(\"name\", `${name}.record`, `the end ${name} has no record name`);\n point(`${name}.at`, end.at);\n }\n break;\n case \"field\": {\n const hasFrame = frame(\"frame\", mark.frame);\n const hasAcross = direction(\"across\", mark.across);\n if (hasFrame && hasAcross) {\n const dot = dot3(mark.frame.out, mark.across);\n if (Math.abs(dot) > DIRECTION_TOLERANCE) fault(\"angle\", \"across\", `across is not at a right angle to frame.out: their dot product is ${String(dot)}`);\n }\n positive(\"cell\", mark.cell);\n const hasColumns = count(\"columns\", mark.columns);\n const hasRows = count(\"rows\", mark.rows);\n if (hasColumns && hasRows && mark.values.length !== mark.columns * mark.rows) {\n fault(\"values\", \"values\", `the field has ${String(mark.values.length)} values, and ${String(mark.columns)} columns of ${String(mark.rows)} rows need ${String(mark.columns * mark.rows)}`);\n }\n // A field can have many cells, so the values give one fault, not one fault for each cell.\n const bad = mark.values.flatMap((value, at) => (value === null || Number.isFinite(value) ? [] : [at]));\n const first = bad[0];\n if (first !== undefined) {\n fault(\"number\", `values[${String(first)}]`, `${String(bad.length)} of the values are not finite numbers, the first is values[${String(first)}]: ${String(mark.values[first])}`);\n }\n const hasMin = finite(\"scale.min\", mark.scale.min);\n const hasMax = finite(\"scale.max\", mark.scale.max);\n if (hasMin && hasMax && mark.scale.min >= mark.scale.max) {\n fault(\"scale\", \"scale\", `scale.min is not less than scale.max: ${String(mark.scale.min)} and ${String(mark.scale.max)}`);\n }\n break;\n }\n case \"meter\":\n finite(\"value\", mark.value);\n // A meter with no limit is correct. A list from JSON can have `null` there, and `null` is not a number.\n if (mark.limit !== undefined) finite(\"limit\", mark.limit);\n break;\n default:\n fault(\"type\", \"type\", `the type is not known: ${String((mark as { readonly type: unknown }).type)}`);\n }\n });\n return faults;\n}\n","import { addPoints3, cross3, scalePoint3, type Point3 } from \"@mark1russell7/layout-contract\";\nimport type { Level } from \"./levels.ts\";\n\n/** A point of a surface, and the direction out of the surface. */\nexport interface Frame {\n /** The point. */\n readonly at: Point3;\n /** The unit vector out of the surface at the point. */\n readonly out: Point3;\n}\n\n/** These are the types of a mark. */\nexport const MARK_TYPES: readonly [\"point\", \"run\", \"link\", \"field\", \"meter\"] = [\"point\", \"run\", \"link\", \"field\", \"meter\"];\n\n/** A type of a mark. */\nexport type MarkType = (typeof MARK_TYPES)[number];\n\n/**\n * The parts that each mark has. A mark has no shape and no color.\n * A viewer gets the shape from the level, and the color from the level and its theme. Thus a mark does not use color alone.\n */\nexport interface MarkBase {\n /** The name of the record of the mark. The pointer and the selection of a viewer use this name. */\n readonly record: string;\n /** A word of the producer for the legend and the filter, for example `outlet`. */\n readonly kind: string;\n /** The level of the mark. The producer calculates it. */\n readonly level: Level;\n /** One line of text: the name of the mark for a person and for a screen reader. */\n readonly label: string;\n}\n\n/** A mark at one point of a surface, for example an outlet, a tap or a lamp. */\nexport interface PointMark extends MarkBase {\n readonly type: \"point\";\n /** The point, and the direction out of its surface. */\n readonly frame: Frame;\n /** The width of the sign, in the unit of the space. A mark with no size gets the default size of the viewer. */\n readonly size?: number | undefined;\n}\n\n/** A mark along a path on surfaces, for example a cable, a pipe or a duct. */\nexport interface RunMark extends MarkBase {\n readonly type: \"run\";\n /** The points of the path, in sequence. Each point has its own direction, so a run can go across surfaces. A path has 2 or more points. */\n readonly path: readonly Frame[];\n /** The width of the run, in the unit of the space. */\n readonly width: number;\n}\n\n/** One end of a link. */\nexport interface LinkEnd {\n /** The name of the record at this end. A viewer shows the link when the record of one end is selected or under the pointer. */\n readonly record: string;\n /** The point of this end. */\n readonly at: Point3;\n}\n\n/** A mark between two records, for example a power line from an outlet to a computer. */\nexport interface LinkMark extends MarkBase {\n readonly type: \"link\";\n readonly from: LinkEnd;\n readonly to: LinkEnd;\n}\n\n/** The scale of the values of a field. The theme of a viewer gives the colors from `min` to `max`. */\nexport interface FieldScale {\n /** The value of the first color. It is less than `max`. */\n readonly min: number;\n /** The value of the last color. */\n readonly max: number;\n /** The text of the unit of the values, for example `lx`. */\n readonly unit: string;\n}\n\n/** A grid of values on a plane, for example the light on a floor or the heat of a wall. */\nexport interface FieldMark extends MarkBase {\n readonly type: \"field\";\n /** The corner of the first cell, and the direction out of the plane. */\n readonly frame: Frame;\n /** The unit vector of a column step, in the plane. The step of a row is the cross product of `frame.out` and `across`. */\n readonly across: Point3;\n /** The length of a side of a cell, in the unit of the space. */\n readonly cell: number;\n /** The number of the columns. */\n readonly columns: number;\n /** The number of the rows. */\n readonly rows: number;\n /**\n * The values, row by row. The value of the column `c` and the row `r` has the index `r * columns + c`.\n * A cell with no value has `null`, because JSON has no NaN.\n */\n readonly values: readonly (number | null)[];\n readonly scale: FieldScale;\n}\n\n/**\n * A value against a limit, for example the load of a circuit. A meter has no place.\n * A page draws it in a panel, and a 3D view ignores it.\n */\nexport interface MeterMark extends MarkBase {\n readonly type: \"meter\";\n readonly value: number;\n /**\n * The limit of the value. A meter with no limit has no `limit`, for example a circuit with a known load and no known breaker.\n * A page shows only the value and the unit of that meter. A limit of 0 is a real limit, so it is not a sign for no limit.\n */\n readonly limit?: number | undefined;\n /** The text of the unit of the value and of the limit, for example `W`. */\n readonly unit: string;\n}\n\n/**\n * A record that a viewer draws. A mark is plain data with no topic, so it goes through JSON with no change.\n * Each point of a list of marks is in one space. The producer tells the unit and the axes of that space.\n */\nexport type Mark = PointMark | RunMark | LinkMark | FieldMark | MeterMark;\n\n/** This function gives the unit vector of a row step of a field: the cross product of `frame.out` and `across`. */\nexport function fieldRowStep(field: FieldMark): Point3 {\n return cross3(field.frame.out, field.across);\n}\n\n/** This function gives the center of a cell of a field. The first cell has the column 0 and the row 0. */\nexport function fieldCellCenter(field: FieldMark, column: number, row: number): Point3 {\n const across = scalePoint3(field.across, (column + 0.5) * field.cell);\n const down = scalePoint3(fieldRowStep(field), (row + 0.5) * field.cell);\n return addPoints3(field.frame.at, addPoints3(across, down));\n}\n\n/** This function gives the value of a cell of a field. A cell with no value gives `null`, and so does a cell that is not in the grid. */\nexport function fieldValue(field: FieldMark, column: number, row: number): number | null {\n if (!Number.isInteger(column) || !Number.isInteger(row) || column < 0 || row < 0 || column >= field.columns || row >= field.rows) return null;\n return field.values[row * field.columns + column] ?? null;\n}\n"],"mappings":";;;AAGA,MAAa,SAAqD;CAAC;CAAW;CAAM;CAAQ;AAAM;;;;;AAYlG,SAAgB,UAAU,OAAsB;CAC9C,OAAO,OAAO,QAAQ,KAAK;AAC7B;;AAGA,MAAa,eAAgE;CAAC;CAAQ;CAAQ;CAAY;AAAQ;;;;;AASlH,SAAgB,WAAW,OAAsC;CAC/D,OAAO,UAAU,OAAO,SAAS,UAAU,SAAS,aAAa,UAAU,SAAS,WAAW;AACjG;;;;;AAkBA,MAAa,iBAA6D;CACxE,MAAM;EAAE,QAAQ;EAAG,OAAO;EAAI,OAAO;EAAG,MAAM;CAAK;CACnD,MAAM;EAAE,QAAQ;EAAG,OAAO;EAAI,OAAO;EAAG,MAAM;CAAE;CAChD,UAAU;EAAE,QAAQ;EAAK,OAAO;EAAG,OAAO,KAAK,KAAK;EAAG,MAAM;CAAE;CAC/D,QAAQ;EAAE,QAAQ;EAAM,OAAO;EAAG,OAAO,KAAK,KAAK;EAAG,MAAM;CAAE;AAChE;;;;;AAMA,SAAgB,UAAU,OAAmB,SAAiB,GAAS;CACrE,MAAM,UAAU,eAAe;CAC/B,OAAO,MAAM,KAAK,EAAE,QAAQ,QAAQ,MAAM,IAAI,GAAG,UAAqC;EACpF,MAAM,QAAQ,QAAQ,QAAS,QAAQ,IAAI,KAAK,KAAM,QAAQ;EAC9D,OAAO,CAAC,SAAS,QAAQ,SAAS,KAAK,IAAI,KAAK,GAAG,SAAS,QAAQ,SAAS,KAAK,IAAI,KAAK,CAAC;CAC9F,CAAC;AACH;;;;;;;;;;;;;;;;;AC/CA,MAAa,mBAA2I;CACtJ;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;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;AACT;;;ACrJA,MAAa,aAAkE;CAAC;CAAS;CAAO;CAAQ;CAAS;AAAO;;AA2GxH,SAAgB,aAAa,OAA0B;CACrD,OAAO,OAAO,MAAM,MAAM,KAAK,MAAM,MAAM;AAC7C;;AAGA,SAAgB,gBAAgB,OAAkB,QAAgB,KAAqB;CACrF,MAAM,SAAS,YAAY,MAAM,SAAS,SAAS,MAAO,MAAM,IAAI;CACpE,MAAM,OAAO,YAAY,aAAa,KAAK,IAAI,MAAM,MAAO,MAAM,IAAI;CACtE,OAAO,WAAW,MAAM,MAAM,IAAI,WAAW,QAAQ,IAAI,CAAC;AAC5D;;AAGA,SAAgB,WAAW,OAAkB,QAAgB,KAA4B;CACvF,IAAI,CAAC,OAAO,UAAU,MAAM,KAAK,CAAC,OAAO,UAAU,GAAG,KAAK,SAAS,KAAK,MAAM,KAAK,UAAU,MAAM,WAAW,OAAO,MAAM,MAAM,OAAO;CACzI,OAAO,MAAM,OAAO,MAAM,MAAM,UAAU,WAAW;AACvD"}
|
|
1
|
+
{"version":3,"file":"marks.js","names":[],"sources":["../src/marks/check.ts"],"sourcesContent":["import { dot3, length3, type Point3 } from \"@mark1russell7/layout-contract\";\nimport { LEVELS } from \"./levels.ts\";\nimport type { Frame, Mark } from \"./mark.ts\";\n\n/**\n * These are the codes of the faults of a mark:\n * - `type`: the type of the mark is not known. A list from a later version of a producer can have a new type.\n * - `level`: the level of the mark is not known.\n * - `name`: a record name or the kind is empty.\n * - `label`: the label is empty, or it has more than one line.\n * - `number`: a number is not finite.\n * - `direction`: a direction is not a unit vector.\n * - `angle`: the column step of a field is not at a right angle to the direction out of its plane.\n * - `size`: a size, a width or a cell is not more than 0.\n * - `grid`: the number of the columns or of the rows of a field is not a whole number of 1 or more.\n * - `values`: a field does not have one value for each cell.\n * - `scale`: the `min` of the scale of a field is not less than its `max`.\n * - `path`: a run has fewer than 2 points.\n */\nexport const MARK_FAULT_CODES: readonly [\"type\", \"level\", \"name\", \"label\", \"number\", \"direction\", \"angle\", \"size\", \"grid\", \"values\", \"scale\", \"path\"] = [\n \"type\",\n \"level\",\n \"name\",\n \"label\",\n \"number\",\n \"direction\",\n \"angle\",\n \"size\",\n \"grid\",\n \"values\",\n \"scale\",\n \"path\",\n];\n\n/** A code of a fault of a mark. */\nexport type MarkFaultCode = (typeof MARK_FAULT_CODES)[number];\n\n/** One fault of a mark of a list. */\nexport interface MarkFault {\n readonly code: MarkFaultCode;\n /** The index of the mark in the list. */\n readonly index: number;\n /** The record name of the mark. */\n readonly record: string;\n /** The part of the mark with the fault, for example `path[2].out`. */\n readonly part: string;\n /** The fault in plain words, with the values. */\n readonly message: string;\n}\n\n/**\n * The tolerance of a direction. A unit vector has the length 1 with this tolerance.\n * Two directions are at a right angle when their dot product is 0 with this tolerance.\n */\nexport const DIRECTION_TOLERANCE = 1e-6;\n\n/**\n * This function gives the faults of a list of marks, in the sequence of the list. A list with no fault gives an empty list.\n * It examines the values that the types do not hold: finite numbers, unit vectors, sizes, the grid of a field and the names.\n * A producer of marks uses it as a gate in its tests, and a viewer uses it on a list that it did not make.\n * It does not examine the form of a mark: read a list from JSON through a schema first.\n */\nexport function checkMarks(marks: readonly Mark[]): readonly MarkFault[] {\n const faults: MarkFault[] = [];\n marks.forEach((mark, index) => {\n const fault = (code: MarkFaultCode, part: string, message: string): void => {\n faults.push({ code, index, record: mark.record, part, message });\n };\n const finite = (part: string, value: number): boolean => {\n if (Number.isFinite(value)) return true;\n fault(\"number\", part, `${part} is not a finite number: ${String(value)}`);\n return false;\n };\n const point = (part: string, value: Point3): boolean => {\n const x = finite(`${part}.x`, value.x);\n const y = finite(`${part}.y`, value.y);\n const z = finite(`${part}.z`, value.z);\n return x && y && z;\n };\n const direction = (part: string, value: Point3): boolean => {\n if (!point(part, value)) return false;\n const length = length3(value);\n if (Math.abs(length - 1) <= DIRECTION_TOLERANCE) return true;\n fault(\"direction\", part, `${part} is not a unit vector: its length is ${String(length)}`);\n return false;\n };\n const frame = (part: string, value: Frame): boolean => {\n const at = point(`${part}.at`, value.at);\n const out = direction(`${part}.out`, value.out);\n return at && out;\n };\n const positive = (part: string, value: number): void => {\n if (finite(part, value) && value <= 0) fault(\"size\", part, `${part} is not more than 0: ${String(value)}`);\n };\n const count = (part: string, value: number): boolean => {\n if (Number.isInteger(value) && value >= 1) return true;\n fault(\"grid\", part, `${part} is not a whole number of 1 or more: ${String(value)}`);\n return false;\n };\n\n if (mark.record === \"\") fault(\"name\", \"record\", \"the mark has no record name\");\n if (mark.kind === \"\") fault(\"name\", \"kind\", \"the mark has no kind\");\n if (!(LEVELS as readonly string[]).includes(mark.level)) fault(\"level\", \"level\", `the level is not known: ${String(mark.level)}`);\n if (mark.label.trim() === \"\") fault(\"label\", \"label\", \"the mark has no label\");\n else if (/[\\r\\n]/.test(mark.label)) fault(\"label\", \"label\", \"the label has more than one line\");\n\n switch (mark.type) {\n case \"point\":\n frame(\"frame\", mark.frame);\n if (mark.size !== undefined) positive(\"size\", mark.size);\n break;\n case \"run\":\n if (mark.path.length < 2) fault(\"path\", \"path\", `the path has ${String(mark.path.length)} points, and a run needs 2 or more`);\n mark.path.forEach((step, at) => frame(`path[${String(at)}]`, step));\n positive(\"width\", mark.width);\n break;\n case \"link\":\n for (const [name, end] of [\n [\"from\", mark.from],\n [\"to\", mark.to],\n ] as const) {\n if (end.record === \"\") fault(\"name\", `${name}.record`, `the end ${name} has no record name`);\n point(`${name}.at`, end.at);\n }\n break;\n case \"field\": {\n const hasFrame = frame(\"frame\", mark.frame);\n const hasAcross = direction(\"across\", mark.across);\n if (hasFrame && hasAcross) {\n const dot = dot3(mark.frame.out, mark.across);\n if (Math.abs(dot) > DIRECTION_TOLERANCE) fault(\"angle\", \"across\", `across is not at a right angle to frame.out: their dot product is ${String(dot)}`);\n }\n positive(\"cell\", mark.cell);\n const hasColumns = count(\"columns\", mark.columns);\n const hasRows = count(\"rows\", mark.rows);\n if (hasColumns && hasRows && mark.values.length !== mark.columns * mark.rows) {\n fault(\"values\", \"values\", `the field has ${String(mark.values.length)} values, and ${String(mark.columns)} columns of ${String(mark.rows)} rows need ${String(mark.columns * mark.rows)}`);\n }\n // A field can have many cells, so the values give one fault, not one fault for each cell.\n const bad = mark.values.flatMap((value, at) => (value === null || Number.isFinite(value) ? [] : [at]));\n const first = bad[0];\n if (first !== undefined) {\n fault(\"number\", `values[${String(first)}]`, `${String(bad.length)} of the values are not finite numbers, the first is values[${String(first)}]: ${String(mark.values[first])}`);\n }\n const hasMin = finite(\"scale.min\", mark.scale.min);\n const hasMax = finite(\"scale.max\", mark.scale.max);\n if (hasMin && hasMax && mark.scale.min >= mark.scale.max) {\n fault(\"scale\", \"scale\", `scale.min is not less than scale.max: ${String(mark.scale.min)} and ${String(mark.scale.max)}`);\n }\n break;\n }\n case \"meter\":\n finite(\"value\", mark.value);\n // A meter with no limit is correct. A list from JSON can have `null` there, and `null` is not a number.\n if (mark.limit !== undefined) finite(\"limit\", mark.limit);\n break;\n default:\n fault(\"type\", \"type\", `the type is not known: ${String((mark as { readonly type: unknown }).type)}`);\n }\n });\n return faults;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,MAAa,mBAA2I;CACtJ;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;AAsBA,MAAa,sBAAsB;;;;;;;AAQnC,SAAgB,WAAW,OAA8C;CACvE,MAAM,SAAsB,CAAC;CAC7B,MAAM,SAAS,MAAM,UAAU;EAC7B,MAAM,SAAS,MAAqB,MAAc,YAA0B;GAC1E,OAAO,KAAK;IAAE;IAAM;IAAO,QAAQ,KAAK;IAAQ;IAAM;GAAQ,CAAC;EACjE;EACA,MAAM,UAAU,MAAc,UAA2B;GACvD,IAAI,OAAO,SAAS,KAAK,GAAG,OAAO;GACnC,MAAM,UAAU,MAAM,GAAG,KAAK,2BAA2B,OAAO,KAAK,GAAG;GACxE,OAAO;EACT;EACA,MAAM,SAAS,MAAc,UAA2B;GACtD,MAAM,IAAI,OAAO,G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U,KAAK,IAAI,GAAG;IAG3L,MAAM,MAAM,KAAK,OAAO,SAAS,OAAO,OAAQ,UAAU,QAAQ,OAAO,SAAS,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,CAAE;IACrG,MAAM,QAAQ,IAAI;IAClB,IAAI,UAAU,KAAA,GACZ,MAAM,UAAU,UAAU,OAAO,KAAK,EAAE,IAAI,GAAG,OAAO,IAAI,MAAM,EAAE,6DAA6D,OAAO,KAAK,EAAE,KAAK,OAAO,KAAK,OAAO,MAAM,GAAG;IAEhL,MAAM,SAAS,OAAO,aAAa,KAAK,MAAM,GAAG;IACjD,MAAM,SAAS,OAAO,aAAa,KAAK,MAAM,GAAG;IACjD,IAAI,UAAU,UAAU,KAAK,MAAM,OAAO,KAAK,MAAM,KACnD,MAAM,SAAS,SAAS,yCAAyC,OAAO,KAAK,MAAM,GAAG,EAAE,OAAO,OAAO,KAAK,MAAM,GAAG,GAAG;IAEzH;GACF;GACA,KAAK;IACH,OAAO,SAAS,KAAK,KAAK;IAE1B,IAAI,KAAK,UAAU,KAAA,GAAW,OAAO,SAAS,KAAK,KAAK;IACxD;GACF,SACE,MAAM,QAAQ,QAAQ,0BAA0B,OAAQ,KAAoC,IAAI,GAAG;EACvG;CACF,CAAC;CACD,OAAO;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as turnAcross, o as placeBetween } from "./view-BB_EQx3I.js";
|
|
2
2
|
// src/keys.ts
|
|
3
3
|
/** 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. */
|
|
4
4
|
const KEY_TURN = Math.PI / 24;
|
|
@@ -132,4 +132,4 @@ function approach(value, goal, seconds, time, snap = .01) {
|
|
|
132
132
|
}
|
|
133
133
|
export { NO_HIGHLIGHTS as a, KEY_PART as c, keyAction as d, CLICK_DISTANCE as i, KEY_TURN as l, easeInOut as n, highlightOf as o, moveAt as r, isClick as s, approach as t, KEY_ZOOM as u };
|
|
134
134
|
|
|
135
|
-
//# sourceMappingURL=motion-
|
|
135
|
+
//# sourceMappingURL=motion-BvRKIWAC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motion-
|
|
1
|
+
{"version":3,"file":"motion-BvRKIWAC.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/**\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 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 = move.duration > 0 ? Math.min(Math.max((now - move.start) / move.duration, 0), 1) : 1;\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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,QAAQ,MAAkD,IAAgD,QAAA,GAAyC;CACjK,OAAO,KAAK,MAAM,GAAG,IAAI,KAAK,GAAG,GAAG,IAAI,KAAK,CAAC,KAAK;AACrD;;;;;;ACRA,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,MAAY,KAAa,UAAkB,GAAa;CAC7E,MAAM,OAAO,KAAK,WAAW,IAAI,KAAK,IAAI,KAAK,KAAK,MAAM,KAAK,SAAS,KAAK,UAAU,CAAC,GAAG,CAAC,IAAI;CAChG,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"}
|
|
@@ -6,6 +6,11 @@ interface StagePick<P> {
|
|
|
6
6
|
readonly record: string;
|
|
7
7
|
/** The value of the record for the page, for example its kind and its source. */
|
|
8
8
|
readonly value: P;
|
|
9
|
+
/**
|
|
10
|
+
* The distance from the start of the ray to the record, in the unit of the space.
|
|
11
|
+
* A stack of contents uses it to find the nearest record. A pick with no distance is above each other record.
|
|
12
|
+
*/
|
|
13
|
+
readonly distance?: number | undefined;
|
|
9
14
|
}
|
|
10
15
|
/** One picture of a stage, for the step of its content. */
|
|
11
16
|
interface StageFrame {
|
|
@@ -121,4 +126,4 @@ declare const STAGE_LIGHTS: StageLights;
|
|
|
121
126
|
*/
|
|
122
127
|
declare function createStage<P, T extends StageTheme = StageTheme>(container: HTMLElement, options: StageOptions<P, T>): Stage<P, T> | undefined;
|
|
123
128
|
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 };
|
|
124
|
-
//# sourceMappingURL=stage-
|
|
129
|
+
//# sourceMappingURL=stage-DmFfah2e.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stage-DmFfah2e.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;;;;;;;;;;;iBAgCX,YAAY,GAAG,UAAU,aAAa,YAAY,WAAW,aAAa,SAAS,aAAa,GAAG,KAAK,MAAM,GAAG"}
|
package/build/three.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
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-
|
|
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-DmFfah2e.js";
|
|
2
2
|
import { b as FIELD_OF_VIEW, t as StageTheme } from "./theme-3EGbXXoP.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.
|
|
6
6
|
*
|
|
7
7
|
* - The first content gives the extent: the views and the limits of the camera come from it.
|
|
8
|
-
* - The last content is on top. A pick asks the last content first
|
|
8
|
+
* - The last content is on top. A pick asks the last content first.
|
|
9
|
+
* - A pick with no distance ends the search, if no earlier pick has a distance. That pick is the record.
|
|
10
|
+
* - A pick with a distance does not end the search. The record is then the pick with the smallest distance.
|
|
9
11
|
* - A record that two contents have is one record: each of them gets its highlight.
|
|
10
12
|
* - The stage disposes the stack, and the stack disposes each content.
|
|
11
13
|
*/
|
package/build/three.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"three.d.ts","names":[],"sources":["../src/stage/stack.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"three.d.ts","names":[],"sources":["../src/stage/stack.ts"],"mappings":";;;;;;;;;;;;;wBAcgB,cAAc,GAAG,UAAU,aAAa,YAAY,oBAAoB,aAAa,GAAG,OAAO,aAAa,GAAG,QAAQ,aAAa,GAAG"}
|
package/build/three.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { a as nearDepth, c as surfaceOf,
|
|
2
|
-
import { a as NO_HIGHLIGHTS, d as keyAction, o as highlightOf, r as moveAt, s as isClick } from "./motion-
|
|
1
|
+
import { a as nearDepth, c as surfaceOf, s as stageLimits } from "./extent-D2SsHJnP.js";
|
|
2
|
+
import { a as NO_HIGHLIGHTS, d as keyAction, o as highlightOf, r as moveAt, s as isClick } from "./motion-BvRKIWAC.js";
|
|
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";
|
|
3
4
|
import { DirectionalLight, HemisphereLight, PerspectiveCamera, Raycaster, Scene, Vector2, WebGLRenderer } from "three";
|
|
4
5
|
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
|
|
5
6
|
// src/stage/stage.ts
|
|
@@ -417,7 +418,9 @@ function createStage(container, options) {
|
|
|
417
418
|
* An example is a globe with a layer of labels, or a room with its marks.
|
|
418
419
|
*
|
|
419
420
|
* - The first content gives the extent: the views and the limits of the camera come from it.
|
|
420
|
-
* - The last content is on top. A pick asks the last content first
|
|
421
|
+
* - The last content is on top. A pick asks the last content first.
|
|
422
|
+
* - A pick with no distance ends the search, if no earlier pick has a distance. That pick is the record.
|
|
423
|
+
* - A pick with a distance does not end the search. The record is then the pick with the smallest distance.
|
|
421
424
|
* - A record that two contents have is one record: each of them gets its highlight.
|
|
422
425
|
* - The stage disposes the stack, and the stack disposes each content.
|
|
423
426
|
*/
|
|
@@ -430,10 +433,14 @@ function stackContents(contents) {
|
|
|
430
433
|
},
|
|
431
434
|
has: (record) => contents.some((content) => content.has(record)),
|
|
432
435
|
pick(ray) {
|
|
436
|
+
let nearest;
|
|
433
437
|
for (let at = contents.length - 1; at >= 0; at -= 1) {
|
|
434
438
|
const pick = contents[at]?.pick(ray);
|
|
435
|
-
if (pick
|
|
439
|
+
if (pick === void 0) continue;
|
|
440
|
+
if (pick.distance === void 0) return nearest ?? pick;
|
|
441
|
+
if (nearest?.distance === void 0 || pick.distance < nearest.distance) nearest = pick;
|
|
436
442
|
}
|
|
443
|
+
return nearest;
|
|
437
444
|
},
|
|
438
445
|
paint(theme, highlight) {
|
|
439
446
|
for (const content of contents) content.paint(theme, highlight);
|