@navaramap/three-plugins 0.0.4 → 0.0.6
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 +1 -1
- package/dist/index.d.ts +289 -12
- package/dist/index.js +356 -159
- package/dist/index.umd.cjs +1 -1
- package/package.json +5 -5
- package/src/PersonViewPlugin.test.ts +784 -0
- package/src/PersonViewPlugin.ts +709 -76
- package/src/TileJsonPlugin.test.ts +119 -3
- package/src/TileJsonPlugin.ts +145 -32
- package/src/index.ts +7 -0
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ overlay.onUpdate(({ projected }) => {
|
|
|
51
51
|
|
|
52
52
|
## Documentation
|
|
53
53
|
|
|
54
|
-
Each plugin's options and events are documented at https://navara-docs.
|
|
54
|
+
Each plugin's options and events are documented at https://navara-docs.reearth.workers.dev//.
|
|
55
55
|
|
|
56
56
|
## License
|
|
57
57
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { default as default_2 } from '@navaramap/three';
|
|
2
2
|
import { DefaultDescriptions } from '@navaramap/three-default-plugin';
|
|
3
|
+
import { GLTFModelDesc } from '@navaramap/three-default-descs';
|
|
3
4
|
import { Layer } from '@navaramap/three';
|
|
5
|
+
import { MeshHandle } from '@navaramap/three';
|
|
4
6
|
import { Plugin as Plugin_2 } from '@navaramap/three';
|
|
5
7
|
import { QuantizedMeshSource } from '@navaramap/three';
|
|
6
8
|
import { Source } from '@navaramap/three';
|
|
7
9
|
import { TerrainSourceLayer } from '@navaramap/three';
|
|
8
10
|
import { ViewContext } from '@navaramap/three';
|
|
9
11
|
|
|
12
|
+
declare type ActionListener = (action: PersonViewAction) => void;
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* Animation configuration for the model.
|
|
12
16
|
* Clip names are model-specific — check your GLTF file for available clips.
|
|
@@ -22,8 +26,14 @@ export declare type AnimationConfig = {
|
|
|
22
26
|
walkClip?: string;
|
|
23
27
|
/** Clip name played while the model is dashing (dash key held). */
|
|
24
28
|
dashClip: string;
|
|
25
|
-
/** Playback speed
|
|
26
|
-
speed
|
|
29
|
+
/** Playback speed for any clip without a per-clip override below. */
|
|
30
|
+
speed?: number;
|
|
31
|
+
/** Playback speed for the idle clip (falls back to {@link speed}). */
|
|
32
|
+
idleSpeed?: number;
|
|
33
|
+
/** Playback speed for the walk clip (falls back to {@link speed}). */
|
|
34
|
+
walkSpeed?: number;
|
|
35
|
+
/** Playback speed for the dash clip (falls back to {@link speed}). */
|
|
36
|
+
dashSpeed?: number;
|
|
27
37
|
/** Duration in seconds for cross-fade transitions between clips. */
|
|
28
38
|
crossfadeDuration: number;
|
|
29
39
|
};
|
|
@@ -87,6 +97,57 @@ export declare type CharacterConfig = {
|
|
|
87
97
|
receiveShadow?: boolean;
|
|
88
98
|
};
|
|
89
99
|
|
|
100
|
+
/** Terrain collision configuration. See {@link CollisionMode}. */
|
|
101
|
+
export declare type CollisionConfig = {
|
|
102
|
+
/** @defaultValue `"off"` */
|
|
103
|
+
mode?: CollisionMode;
|
|
104
|
+
/**
|
|
105
|
+
* Height (meters) kept above the sampled terrain surface — the character's
|
|
106
|
+
* feet in `"ground"` mode, the floor it cannot sink below in `"clamp"`.
|
|
107
|
+
* @defaultValue `0`
|
|
108
|
+
*/
|
|
109
|
+
groundOffset?: number;
|
|
110
|
+
/**
|
|
111
|
+
* Tilt the character to match the slope it stands on. Costs several extra
|
|
112
|
+
* terrain lookups per frame, and fades out as it leaves the ground in
|
|
113
|
+
* `"clamp"` mode.
|
|
114
|
+
* @defaultValue `true`
|
|
115
|
+
*/
|
|
116
|
+
alignToSlope?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Footprint (meters) the slope under the character is averaged over. The
|
|
119
|
+
* default suits the triangle spacing terrain meshes arrive at; below that
|
|
120
|
+
* there is nothing left to average and the tilt starts to step.
|
|
121
|
+
* @defaultValue `4`
|
|
122
|
+
*/
|
|
123
|
+
slopeSampleDistance?: number;
|
|
124
|
+
/**
|
|
125
|
+
* Largest tilt (radians) {@link alignToSlope} may apply, so ground far
|
|
126
|
+
* steeper than anything walkable does not lay the character flat against it.
|
|
127
|
+
* @defaultValue `Math.PI / 4` (45°)
|
|
128
|
+
*/
|
|
129
|
+
maxSlopeTilt?: number;
|
|
130
|
+
/**
|
|
131
|
+
* How much of the terrain's slope the camera pitch follows, from `0` (fixed
|
|
132
|
+
* pitch, so a steep hillside fills the frame) to `1` (the view runs parallel
|
|
133
|
+
* to the slope, looking up a climb and down a descent). Applies to the TPV
|
|
134
|
+
* chase camera and the FPV eye line alike.
|
|
135
|
+
* @defaultValue `1`
|
|
136
|
+
*/
|
|
137
|
+
cameraSlopeFollow?: number;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* How the character's altitude reacts to the terrain surface.
|
|
142
|
+
*
|
|
143
|
+
* - `"off"` — altitude is driven purely by the ascend / descend keys.
|
|
144
|
+
* - `"clamp"` — free flight, but the terrain acts as a floor: the character is
|
|
145
|
+
* pushed up whenever it would end up below the surface.
|
|
146
|
+
* - `"ground"` — the character is glued to the terrain surface, so it walks up
|
|
147
|
+
* and down slopes. The ascend / descend keys have no effect in this mode.
|
|
148
|
+
*/
|
|
149
|
+
export declare type CollisionMode = "off" | "clamp" | "ground";
|
|
150
|
+
|
|
90
151
|
/**
|
|
91
152
|
* Keyboard bindings. Each entry takes an array of `KeyboardEvent.code`
|
|
92
153
|
* values (e.g. `["KeyW"]`, `["ArrowUp", "ControlLeft"]`) so multiple
|
|
@@ -158,8 +219,20 @@ export declare type OverlayState = {
|
|
|
158
219
|
projected: Map<string, ProjectedPosition>;
|
|
159
220
|
};
|
|
160
221
|
|
|
222
|
+
/**
|
|
223
|
+
* A recognized control input. Delivered to {@link PersonViewPlugin.onAction}
|
|
224
|
+
* listeners on each keypress — e.g. to dismiss an on-screen controls hint once
|
|
225
|
+
* the user starts driving the character.
|
|
226
|
+
*/
|
|
227
|
+
export declare type PersonViewAction = "forward" | "backward" | "turnLeft" | "turnRight" | "ascend" | "descend" | "dash" | "orbitCamera" | "toggleView";
|
|
228
|
+
|
|
161
229
|
export declare type PersonViewConfig = {
|
|
162
230
|
character?: CharacterConfig;
|
|
231
|
+
/**
|
|
232
|
+
* Terrain collision. Off by default — the character flies freely and ignores
|
|
233
|
+
* the terrain surface.
|
|
234
|
+
*/
|
|
235
|
+
collision?: CollisionConfig;
|
|
163
236
|
/** When true, the camera is always free (no Alt-hold required). */
|
|
164
237
|
allowCameraControl?: boolean;
|
|
165
238
|
/** Initial view mode. */
|
|
@@ -170,6 +243,11 @@ export declare type PersonViewConfig = {
|
|
|
170
243
|
rotationSpeed?: number;
|
|
171
244
|
/** m/s */
|
|
172
245
|
altSpeed?: number;
|
|
246
|
+
/**
|
|
247
|
+
* Factor applied to {@link moveSpeed} while the dash key is held.
|
|
248
|
+
* @defaultValue `2.5`
|
|
249
|
+
*/
|
|
250
|
+
dashSpeedMultiplier?: number;
|
|
173
251
|
minAlt?: number;
|
|
174
252
|
maxAlt?: number;
|
|
175
253
|
cameraDistance?: number;
|
|
@@ -223,17 +301,23 @@ export declare type PersonViewConfig = {
|
|
|
223
301
|
export declare class PersonViewPlugin extends Plugin_2<View, ViewContext> {
|
|
224
302
|
private view?;
|
|
225
303
|
private config;
|
|
304
|
+
private collision;
|
|
226
305
|
private character;
|
|
227
306
|
private keys;
|
|
228
307
|
private keyToAction;
|
|
229
308
|
private handle;
|
|
230
309
|
private modelRef;
|
|
231
310
|
private animId;
|
|
311
|
+
/** Whether the character has been placed, so `start()` resumes from here. */
|
|
312
|
+
private placed;
|
|
232
313
|
private lastTime;
|
|
233
314
|
private state;
|
|
234
315
|
private listeners;
|
|
316
|
+
private actionListeners;
|
|
235
317
|
private heldActions;
|
|
236
|
-
|
|
318
|
+
/** Whether the dash key is held. Kept separate from the numeric speed factor
|
|
319
|
+
* so the dash animation still plays when `dashSpeedMultiplier` is 1 (or <1). */
|
|
320
|
+
private dashHeld;
|
|
237
321
|
private orbitKeyHeld;
|
|
238
322
|
private orbitLatched;
|
|
239
323
|
private currentAnimState;
|
|
@@ -249,18 +333,69 @@ export declare class PersonViewPlugin extends Plugin_2<View, ViewContext> {
|
|
|
249
333
|
private _north;
|
|
250
334
|
private _worldForward;
|
|
251
335
|
private _offset;
|
|
336
|
+
private _probePos;
|
|
252
337
|
private _headingMatrix;
|
|
338
|
+
private _tiltMatrix;
|
|
253
339
|
private _characterFrame;
|
|
340
|
+
/** Smoothed pitch (radians) the chase camera gives up to follow the slope. */
|
|
341
|
+
private cameraSlopePitch;
|
|
342
|
+
private slopeGradEast;
|
|
343
|
+
private slopeGradNorth;
|
|
344
|
+
/**
|
|
345
|
+
* Terrain height (meters) sampled under the character last frame, with the
|
|
346
|
+
* position it was taken at, so the next frame can re-sample the same spot and
|
|
347
|
+
* tell a change in the terrain data apart from the character having moved.
|
|
348
|
+
*/
|
|
349
|
+
private lastGroundSample?;
|
|
350
|
+
/** Meters of terrain data shift not yet passed on to the character. */
|
|
351
|
+
private unabsorbedGroundShift;
|
|
352
|
+
/** Speed (m/s) that shift is being worked off at, positive when rising. */
|
|
353
|
+
private settleVelocity;
|
|
354
|
+
/** Surface height (meters) the character stands on, once settling is applied. */
|
|
355
|
+
private groundSurfaceHeight?;
|
|
254
356
|
constructor(config?: PersonViewConfig);
|
|
255
357
|
init(view: View, _ctx: ViewContext): Promise<void>;
|
|
358
|
+
/**
|
|
359
|
+
* Take over the camera and start reading the movement keys. Calling it again
|
|
360
|
+
* after {@link stop} resumes from wherever the character was left, rather
|
|
361
|
+
* than starting over at the configured position.
|
|
362
|
+
*/
|
|
256
363
|
start(): void;
|
|
364
|
+
/**
|
|
365
|
+
* Hand the camera back to the view's own controls and stop reading the
|
|
366
|
+
* movement keys, leaving the character where it stands. {@link start}
|
|
367
|
+
* resumes from there — use the two to step out of person view and back
|
|
368
|
+
* without losing the position.
|
|
369
|
+
*/
|
|
370
|
+
stop(): void;
|
|
371
|
+
/** Stop the per-frame loop and the key handling, keeping everything else. */
|
|
372
|
+
private releaseControl;
|
|
373
|
+
/**
|
|
374
|
+
* Run the per-frame loop from now. The clock restarts with it, so a pause
|
|
375
|
+
* between `stop()` and `start()` is not delivered as one enormous frame.
|
|
376
|
+
*/
|
|
377
|
+
private resumeLoop;
|
|
257
378
|
/** Instantly move to a new geographic position. */
|
|
258
379
|
teleport(options: TeleportOptions): void;
|
|
259
380
|
getState(): PersonViewState;
|
|
260
381
|
onStateChange(fn: StateListener): () => void;
|
|
382
|
+
/**
|
|
383
|
+
* Subscribe to control-input events. The callback fires once per keypress of
|
|
384
|
+
* any bound action (movement, dash, view toggle, orbit) — for example, to
|
|
385
|
+
* hide an on-screen controls hint once the user starts driving the
|
|
386
|
+
* character. Returns an unsubscribe function.
|
|
387
|
+
*/
|
|
388
|
+
onAction(fn: ActionListener): () => void;
|
|
261
389
|
setViewMode(mode: ViewMode): void;
|
|
262
390
|
toggleViewMode(): void;
|
|
263
391
|
setAllowCameraControl(value: boolean): void;
|
|
392
|
+
/**
|
|
393
|
+
* Update the terrain collision settings at runtime. Only the given fields
|
|
394
|
+
* change; the rest keep their current values.
|
|
395
|
+
*/
|
|
396
|
+
setCollision(collision: CollisionConfig): void;
|
|
397
|
+
/** Current terrain collision settings. */
|
|
398
|
+
getCollision(): Readonly<ResolvedCollision>;
|
|
264
399
|
/**
|
|
265
400
|
* Rotate the character to the given heading in radians (0 = north,
|
|
266
401
|
* increasing clockwise) without changing position. Snaps the chase camera to
|
|
@@ -293,7 +428,29 @@ export declare class PersonViewPlugin extends Plugin_2<View, ViewContext> {
|
|
|
293
428
|
setFpvHeightOffset(meters: number): void;
|
|
294
429
|
/** Current FPV eye height offset in meters. */
|
|
295
430
|
getFpvHeightOffset(): number;
|
|
431
|
+
/**
|
|
432
|
+
* Set the base animation playback speed — the fallback used by any clip
|
|
433
|
+
* without a per-clip override (`idleSpeed` / `walkSpeed` / `dashSpeed`).
|
|
434
|
+
* Re-applies to the clip currently playing, so it takes effect immediately.
|
|
435
|
+
*/
|
|
436
|
+
setAnimationSpeed(speed: number): void;
|
|
437
|
+
/** Current base animation playback speed (per-clip overrides aside). */
|
|
438
|
+
getAnimationSpeed(): number;
|
|
439
|
+
/**
|
|
440
|
+
* The loaded character model's mesh handle, or `null` before {@link start}
|
|
441
|
+
* has loaded it (or when no character is configured). Its `ref` is the
|
|
442
|
+
* GLTFModelDesc — reach the model itself through it, e.g. `model.ref.raw`
|
|
443
|
+
* for the underlying three.js object or `model.ref.getWorldPosition()`.
|
|
444
|
+
*/
|
|
445
|
+
get model(): MeshHandle<GLTFModelDesc> | null;
|
|
446
|
+
/**
|
|
447
|
+
* Resolve the effective playback speed for a clip: its per-clip override
|
|
448
|
+
* (`idleSpeed` / `walkSpeed` / `dashSpeed`) if set, else the base `speed`.
|
|
449
|
+
*/
|
|
450
|
+
private clipSpeed;
|
|
296
451
|
dispose(): void;
|
|
452
|
+
/** Cross-fade the model onto `clip`, unless it is already the one playing. */
|
|
453
|
+
private playAnimation;
|
|
297
454
|
private resolveCharacter;
|
|
298
455
|
private buildKeyMap;
|
|
299
456
|
private isFreeCamera;
|
|
@@ -309,6 +466,26 @@ export declare class PersonViewPlugin extends Plugin_2<View, ViewContext> {
|
|
|
309
466
|
* the model, staying aimed at it so the model remains centered.
|
|
310
467
|
*/
|
|
311
468
|
private placeChaseCamera;
|
|
469
|
+
/**
|
|
470
|
+
* Tilt `configured` (radians) with the slope the character is walking along,
|
|
471
|
+
* eased in over time. Position in degrees, `alt` in meters.
|
|
472
|
+
*
|
|
473
|
+
* A fixed pitch hugs a horizontal plane while the ground does not: on a steep
|
|
474
|
+
* climb the view runs into the hillside and the frame fills with ground. The
|
|
475
|
+
* slope is taken over the chase distance either side of the character, and
|
|
476
|
+
* fades out as it rises off the surface so a flying character in `"clamp"`
|
|
477
|
+
* mode keeps the pitch it was configured with.
|
|
478
|
+
*/
|
|
479
|
+
private followSlopeWithPitch;
|
|
480
|
+
/**
|
|
481
|
+
* How much the ground still applies to a character at `alt`: `1` standing on
|
|
482
|
+
* the surface, fading to `0` once it is `scale` meters above it. Nothing the
|
|
483
|
+
* terrain does should tilt a character that is flying over it in `"clamp"`
|
|
484
|
+
* mode — neither the model nor the view follows a slope it has left behind.
|
|
485
|
+
*/
|
|
486
|
+
private groundedFactor;
|
|
487
|
+
/** Terrain height `meters` along `heading` from a position in degrees. */
|
|
488
|
+
private terrainAlong;
|
|
312
489
|
/**
|
|
313
490
|
* Compose the character's world matrix as `ENU * Rz(-heading)`.
|
|
314
491
|
*
|
|
@@ -323,11 +500,53 @@ export declare class PersonViewPlugin extends Plugin_2<View, ViewContext> {
|
|
|
323
500
|
* its "facing-north, upright" rest pose. Heading then rotates the
|
|
324
501
|
* already-upright model around world-up, regardless of which axis
|
|
325
502
|
* the GLTF treats as forward.
|
|
503
|
+
*
|
|
504
|
+
* After the heading the frame's axes are X = right, Y = forward,
|
|
505
|
+
* Z = up, so `alignToSlope` tilts around X (nose up when climbing)
|
|
506
|
+
* then around Y (roll onto the side of the slope).
|
|
326
507
|
*/
|
|
327
508
|
private composeCharacterFrame;
|
|
509
|
+
/** Eye-line height (meters) for a character standing at `alt`. */
|
|
510
|
+
private eyeHeightAt;
|
|
511
|
+
/** Terrain height at a position in radians, or `undefined` if not loaded. */
|
|
512
|
+
private sampleTerrain;
|
|
513
|
+
/**
|
|
514
|
+
* Apply terrain collision to a candidate altitude (meters). Positions are in
|
|
515
|
+
* radians. `deltaTime` drives the absorption of terrain data changes — pass
|
|
516
|
+
* `0` to land on the terrain the sampler reports right now.
|
|
517
|
+
*/
|
|
518
|
+
private resolveGroundHeight;
|
|
519
|
+
/**
|
|
520
|
+
* Absorb terrain that moved because its *data* changed rather than because
|
|
521
|
+
* the character did, and return how much of that shift is still being held
|
|
522
|
+
* back (meters, positive when the data rose).
|
|
523
|
+
*
|
|
524
|
+
* Only one of the two is real ground: walking onto higher ground has to move
|
|
525
|
+
* the character at once or a climb buries it, while a tile re-measured at a
|
|
526
|
+
* finer LOD moving the surface hundreds of meters must not. Re-sampling the
|
|
527
|
+
* *previous* frame's position separates them — whatever the height there has
|
|
528
|
+
* changed by is data, and the rest is the character having moved.
|
|
529
|
+
*/
|
|
530
|
+
private absorbGroundDataShift;
|
|
531
|
+
/** Drop the terrain history, so the next sample starts a fresh landing. */
|
|
532
|
+
private forgetGroundSamples;
|
|
533
|
+
/**
|
|
534
|
+
* Refresh the terrain gradient the slope tilt is built from, by probing a
|
|
535
|
+
* ring of points around the character (position in radians, `alt` in meters).
|
|
536
|
+
* `deltaTime` drives the smoothing — pass `0` to snap.
|
|
537
|
+
*/
|
|
538
|
+
private updateSlopeTilt;
|
|
539
|
+
/**
|
|
540
|
+
* Terrain gradient (rise per meter, east and north) under a point given in
|
|
541
|
+
* radians, fitted to a ring of probes, or `undefined` while any of them is
|
|
542
|
+
* over terrain that has not loaded. The probes sit a few meters apart, so
|
|
543
|
+
* they share one ENU frame rather than each re-deriving its own.
|
|
544
|
+
*/
|
|
545
|
+
private measureSlopeGradient;
|
|
328
546
|
/** Advance a (lat,lng) point by `meters` along the given ENU heading. */
|
|
329
547
|
private advanceLatLng;
|
|
330
548
|
private notify;
|
|
549
|
+
private emitAction;
|
|
331
550
|
private onKeyDown;
|
|
332
551
|
private onKeyUp;
|
|
333
552
|
private tick;
|
|
@@ -353,6 +572,8 @@ export declare type ProjectedPosition = {
|
|
|
353
572
|
distance: number;
|
|
354
573
|
};
|
|
355
574
|
|
|
575
|
+
declare type ResolvedCollision = Required<CollisionConfig>;
|
|
576
|
+
|
|
356
577
|
declare type StateListener = (s: PersonViewState) => void;
|
|
357
578
|
|
|
358
579
|
/** Options for {@link PersonViewPlugin.teleport}. */
|
|
@@ -388,8 +609,28 @@ export declare type TileJson = {
|
|
|
388
609
|
maxzoom?: number;
|
|
389
610
|
/** Tiling scheme. `"tms"` flips the Y axis (raster sources only). @defaultValue "xyz" */
|
|
390
611
|
scheme?: "xyz" | "tms";
|
|
612
|
+
/**
|
|
613
|
+
* Tile size in pixels. Not part of the TileJSON spec, but emitted by
|
|
614
|
+
* MapLibre-oriented tile servers; applied to `raster-dem` sources only.
|
|
615
|
+
* @defaultValue 512
|
|
616
|
+
*/
|
|
617
|
+
tileSize?: number;
|
|
618
|
+
/**
|
|
619
|
+
* Elevation encoding of DEM tiles. Not part of the TileJSON spec, but
|
|
620
|
+
* emitted by MapLibre-oriented tile servers; applied to `raster-dem` sources
|
|
621
|
+
* only.
|
|
622
|
+
* @defaultValue "mapbox"
|
|
623
|
+
*/
|
|
624
|
+
encoding?: TileJsonDemEncoding;
|
|
391
625
|
};
|
|
392
626
|
|
|
627
|
+
/**
|
|
628
|
+
* How a `raster-dem` document's RGB tiles encode elevation, matching MapLibre's
|
|
629
|
+
* `encoding` values. MapLibre's `"custom"` (free-form decode factors) is not
|
|
630
|
+
* supported.
|
|
631
|
+
*/
|
|
632
|
+
export declare type TileJsonDemEncoding = "mapbox" | "terrarium";
|
|
633
|
+
|
|
393
634
|
/** Detail passed to the {@link TileJsonPlugin} `loaded` event. */
|
|
394
635
|
export declare type TileJsonLoadedEvent = {
|
|
395
636
|
/** The Navara source created for the document. */
|
|
@@ -420,9 +661,13 @@ export declare class TileJsonPlugin extends Plugin_2<View_4, ViewContext> {
|
|
|
420
661
|
*
|
|
421
662
|
* `desc.url` is the TileJSON document URL; the plugin fetches it, then creates
|
|
422
663
|
* one source of the requested `desc.type` using the document's first tile
|
|
423
|
-
* endpoint, `minzoom`/`maxzoom`, and `scheme
|
|
424
|
-
*
|
|
425
|
-
*
|
|
664
|
+
* endpoint, `minzoom`/`maxzoom`, and `scheme` — plus, for `raster-dem`, the
|
|
665
|
+
* MapLibre-compatible `tileSize` and `encoding` fields (defaulting to
|
|
666
|
+
* MapLibre's 512 and `"mapbox"`). Each of those fields can also be set on
|
|
667
|
+
* `desc` itself, taking precedence over the document. The document's
|
|
668
|
+
* `attribution` is surfaced through the view's built-in attribution UI
|
|
669
|
+
* (`view.attribution`), and a `loaded` event is emitted carrying the source,
|
|
670
|
+
* document, and attribution.
|
|
426
671
|
*
|
|
427
672
|
* A TileJSON `tiles` array lists mirror endpoints for the same tileset (as in
|
|
428
673
|
* MapLibre, which shards requests across them). Navara sources take a single
|
|
@@ -456,15 +701,36 @@ export declare type TileJsonPluginEventMap = {
|
|
|
456
701
|
loaded: (event: TileJsonLoadedEvent) => void;
|
|
457
702
|
};
|
|
458
703
|
|
|
704
|
+
/** Registers a TileJSON document as a `raster-dem` (elevation) source. */
|
|
705
|
+
export declare type TileJsonRasterDemSourceDescription = TileJsonSourceDescriptionBase & {
|
|
706
|
+
type: "raster-dem";
|
|
707
|
+
/** Overrides the document's `tileSize` when set. @defaultValue 512 */
|
|
708
|
+
tileSize?: number;
|
|
709
|
+
/** Overrides the document's `encoding` when set. @defaultValue "mapbox" */
|
|
710
|
+
encoding?: TileJsonDemEncoding;
|
|
711
|
+
};
|
|
712
|
+
|
|
713
|
+
/** Registers a TileJSON document as a `raster-tile` (imagery) source. */
|
|
714
|
+
export declare type TileJsonRasterTileSourceDescription = TileJsonSourceDescriptionBase & {
|
|
715
|
+
type: "raster-tile";
|
|
716
|
+
};
|
|
717
|
+
|
|
459
718
|
/**
|
|
460
719
|
* Describes a TileJSON tile source to register via {@link TileJsonPlugin.addSource}.
|
|
461
720
|
* Mirrors the shape of {@link ThreeView.addSource}, except `url` is the TileJSON
|
|
462
721
|
* document URL (not a tile template) — the plugin fetches it and derives the tile
|
|
463
|
-
* URL, zoom range, and attribution from the document.
|
|
722
|
+
* URL, zoom range, and attribution from the document. Document-derived fields
|
|
723
|
+
* (`minzoom`, `maxzoom`, `scheme` — plus `tileSize` and `encoding` for
|
|
724
|
+
* `raster-dem`) can also be set here to take precedence over the document.
|
|
464
725
|
*/
|
|
465
|
-
export declare type TileJsonSourceDescription =
|
|
466
|
-
|
|
467
|
-
|
|
726
|
+
export declare type TileJsonSourceDescription = TileJsonRasterTileSourceDescription | TileJsonVectorTileSourceDescription | TileJsonRasterDemSourceDescription;
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* Fields shared by every {@link TileJsonSourceDescription} variant. Alongside
|
|
730
|
+
* `url` and `id`, it accepts the same optional fields the TileJSON document
|
|
731
|
+
* carries; a field set here takes precedence over the fetched document's value.
|
|
732
|
+
*/
|
|
733
|
+
declare type TileJsonSourceDescriptionBase = {
|
|
468
734
|
/** URL of the TileJSON 3.0.0 document to fetch and expand. */
|
|
469
735
|
url: string;
|
|
470
736
|
/**
|
|
@@ -473,14 +739,25 @@ export declare type TileJsonSourceDescription = {
|
|
|
473
739
|
* handle. When omitted, the engine generates one.
|
|
474
740
|
*/
|
|
475
741
|
id?: string;
|
|
742
|
+
/** Overrides the document's `minzoom` when set. */
|
|
743
|
+
minzoom?: number;
|
|
744
|
+
/** Overrides the document's `maxzoom` when set. */
|
|
745
|
+
maxzoom?: number;
|
|
746
|
+
/** Overrides the document's `scheme` when set. */
|
|
747
|
+
scheme?: "xyz" | "tms";
|
|
476
748
|
};
|
|
477
749
|
|
|
478
750
|
/**
|
|
479
751
|
* Which Navara source type a TileJSON document is materialized into. Declared by
|
|
480
752
|
* the caller because TileJSON has no field that reliably distinguishes raster
|
|
481
|
-
* imagery from vector tiles.
|
|
753
|
+
* imagery from vector or elevation tiles.
|
|
482
754
|
*/
|
|
483
|
-
export declare type TileJsonSourceType = "raster-tile" | "vector-tile";
|
|
755
|
+
export declare type TileJsonSourceType = "raster-tile" | "vector-tile" | "raster-dem";
|
|
756
|
+
|
|
757
|
+
/** Registers a TileJSON document as a `vector-tile` (MVT) source. */
|
|
758
|
+
export declare type TileJsonVectorTileSourceDescription = TileJsonSourceDescriptionBase & {
|
|
759
|
+
type: "vector-tile";
|
|
760
|
+
};
|
|
484
761
|
|
|
485
762
|
declare type UpdateListener = (state: OverlayState) => void;
|
|
486
763
|
|