@edv4h/usketch-plugin-elevation 0.5.1 → 0.6.0

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.
@@ -1,4 +1,4 @@
1
- import { type BoardStore, type GroundDecalApi, type View3dApi, type View3dGlApi } from "@edv4h/usketch-shared";
1
+ import { type BoardStore, type GroundDecalApi, type Quad3d, type View3dApi, type View3dGlApi, type View3dShapeFaces } from "@edv4h/usketch-shared";
2
2
  import type { ElevationDisplay } from "./elevation-shade.js";
3
3
  import type { ReactiveStore } from "./reactive-store.js";
4
4
  export declare const MESH_LAYER_ID = "usketch-elevation:mesh";
@@ -6,6 +6,59 @@ export declare const MESH_LAYER_ID = "usketch-elevation:mesh";
6
6
  export interface MeshState {
7
7
  drawing: boolean;
8
8
  }
9
+ /** The layer with the cover canvas: the hills drawn again over the shapes they hide. */
10
+ export declare const COVER_LAYER_ID = "usketch-elevation:cover";
11
+ /** The cover canvas, while its layer is mounted. */
12
+ export interface CoverTarget {
13
+ canvas: HTMLCanvasElement | null;
14
+ }
15
+ /** What the mesh needs to cover the shapes the hills hide. */
16
+ export interface MeshCover {
17
+ target: ReactiveStore<CoverTarget>;
18
+ /** The shapes' faces drawn in the 3D view now (the canvas's 3D pick). */
19
+ faces: () => readonly View3dShapeFaces[];
20
+ }
21
+ /**
22
+ * How much nearer the eye (px of depth) the ground must be than a shape to cover it: a
23
+ * shape lying on the ground isn't swallowed by the ground just around it.
24
+ */
25
+ export declare const COVER_DEPTH_BIAS = 6;
26
+ /**
27
+ * How far the ground rises above a face lying flat (both its sides level), world units:
28
+ * the highest of a grid of samples over it, above the face. `0` for a face that isn't
29
+ * level. A lying shape is judged as if that much higher, so the slope it lies on doesn't
30
+ * swallow it — only a hill between it and the eye covers it. Pure.
31
+ */
32
+ export declare function coverLift(q: Quad3d, groundAt: (x: number, y: number) => number,
33
+ /** World units between samples (the terrain's spacing); more past {@link MAX_LIFT_SAMPLES}. */
34
+ step?: number): number;
35
+ /** Floats per cover vertex: where it is drawn (x, y, height), then where its depth is taken. */
36
+ export declare const COVER_VERTEX_FLOATS = 6;
37
+ /**
38
+ * The triangles of the shapes' faces, 6 vertices per cell of a quad, each {@link COVER_VERTEX_FLOATS}
39
+ * floats: where it is drawn — x, y relative to `origin`, height — then the point its
40
+ * depth is taken at: the same, or for a lying face with {@link coverLift} above 0 the
41
+ * point toward `eye` on its line of sight that is that much higher (drawn on the same
42
+ * pixel, so the ground just around the face isn't nearer than it). Pure.
43
+ */
44
+ export declare function coverVertices(faces: readonly View3dShapeFaces[], origin: {
45
+ x: number;
46
+ y: number;
47
+ }, ground?: {
48
+ /** A lying face's {@link coverLift}. */
49
+ liftOf: (q: Quad3d) => number;
50
+ /** The view's eye (`cameraEye`). */
51
+ eye: {
52
+ x: number;
53
+ y: number;
54
+ height: number;
55
+ };
56
+ },
57
+ /**
58
+ * Largest cell, world units: a face is cut into cells so its depth (linear in depth,
59
+ * as the mesh's) is right across it, not only at its corners.
60
+ */
61
+ cell?: number): Float32Array;
9
62
  /**
10
63
  * Decal bitmap texels (re)painted per frame at most — about one 1024² tile, or many
11
64
  * small far ones; the rest wait for the next frames. The first paint of a frame always
@@ -17,7 +70,7 @@ export declare const DECAL_TEXELS_PER_FRAME = 1200000;
17
70
  * drawn this frame are dropped (they repaint when seen again).
18
71
  */
19
72
  export declare const DECAL_TEXTURE_BYTES: number;
20
- export declare function ElevationMeshLayer({ store, display, overscan, view3d, state, decals, gpu, }: {
73
+ export declare function ElevationMeshLayer({ store, display, overscan, view3d, state, decals, gpu, cover, }: {
21
74
  store: BoardStore;
22
75
  display: ReactiveStore<ElevationDisplay>;
23
76
  overscan: ReactiveStore<{
@@ -29,6 +82,16 @@ export declare function ElevationMeshLayer({ store, display, overscan, view3d, s
29
82
  decals?: GroundDecalApi;
30
83
  /** The board's GPU drawing hook: while a GPU 3D renderer draws, it draws the mesh. */
31
84
  gpu?: View3dGlApi;
85
+ /** Cover the shapes the hills hide (absent: the shapes stay in front). */
86
+ cover?: MeshCover;
87
+ }): import("react").JSX.Element | null;
88
+ /**
89
+ * The cover canvas (see the file comment), over the shapes, while the mesh draws the
90
+ * ground on its own canvas. The mesh paints it; this only mounts it.
91
+ */
92
+ export declare function ElevationCoverLayer({ target, state, }: {
93
+ target: ReactiveStore<CoverTarget>;
94
+ state: ReactiveStore<MeshState>;
32
95
  }): import("react").JSX.Element | null;
33
96
  /**
34
97
  * The mesh as a drawable of a GPU 3D renderer (`view3dGl` in shared): drawn into its
@@ -1 +1 @@
1
- {"version":3,"file":"elevation-mesh-layer.d.ts","sourceRoot":"","sources":["../src/elevation-mesh-layer.tsx"],"names":[],"mappings":"AASA,OAAO,EACN,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,WAAW,EAMhB,MAAM,uBAAuB,CAAC;AAwB/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,eAAO,MAAM,aAAa,2BAA2B,CAAC;AAEtD,mFAAmF;AACnF,MAAM,WAAW,SAAS;IACzB,OAAO,EAAE,OAAO,CAAC;CACjB;AAmFD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,UAAY,CAAC;AAGhD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,QAAmB,CAAC;AAyXpD,wBAAgB,kBAAkB,CAAC,EAClC,KAAK,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,GAAG,GACH,EAAE;IACF,KAAK,EAAE,UAAU,CAAC;IAClB,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACzC,QAAQ,EAAE,aAAa,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,SAAS,GAAG,SAAS,CAAC;IACpC,KAAK,EAAE,aAAa,CAAC,SAAS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