@expofp/renderer 1.2.1
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/dist/index.d.ts +706 -0
- package/dist/index.js +3098 -0
- package/package.json +29 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,706 @@
|
|
|
1
|
+
import { default as default_2 } from 'stats-gl';
|
|
2
|
+
import { default as default_3 } from 'camera-controls';
|
|
3
|
+
import { EventManager } from 'mjolnir.js';
|
|
4
|
+
import { Vector2 } from 'three';
|
|
5
|
+
import { Vector2Like } from 'three';
|
|
6
|
+
import { Vector2Tuple } from 'three';
|
|
7
|
+
import { WebGLRenderer } from 'three';
|
|
8
|
+
|
|
9
|
+
export declare type ColorInput = string | number;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Options for the CameraControls class.
|
|
13
|
+
*/
|
|
14
|
+
declare interface ControlsOptions {
|
|
15
|
+
/** Whether the camera controls are enabled */
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
/** Time for zooming transitions (in seconds) */
|
|
18
|
+
zoomTime: number;
|
|
19
|
+
/** Options for the camera roll controller - see {@link RollOptions} */
|
|
20
|
+
roll: RollOptions;
|
|
21
|
+
/** Options for the camera inertia - see {@link InertiaOptions} */
|
|
22
|
+
inertia: InertiaOptions;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Converts multiple vector2 representations to a {@link Vector2} instance.
|
|
27
|
+
* @param vector2 Vector2 representation as a tuple/POJO
|
|
28
|
+
* @returns Vector2 instance
|
|
29
|
+
*/
|
|
30
|
+
export declare function createVector2(vector2: IVector2): Vector2;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Mapping of engine-wide events to their payloads
|
|
34
|
+
*/
|
|
35
|
+
export declare interface EngineEvents {
|
|
36
|
+
/** Camera change */
|
|
37
|
+
"navigation:change": void;
|
|
38
|
+
/** Camera stop */
|
|
39
|
+
"navigation:stop": void;
|
|
40
|
+
/** Camera roll */
|
|
41
|
+
"navigation:roll": number;
|
|
42
|
+
/** Mouse move */
|
|
43
|
+
"pointer:move": MouseEventData;
|
|
44
|
+
/** Mouse out */
|
|
45
|
+
"pointer:out": MouseEventData;
|
|
46
|
+
/** Mouse click */
|
|
47
|
+
"pointer:click": MouseEventData;
|
|
48
|
+
/** Viewport pixel to svg scale */
|
|
49
|
+
"viewport:ptscale": number;
|
|
50
|
+
/** Camera update */
|
|
51
|
+
"camera:update": void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export declare type EventHandler<Payload> = (payload: Payload) => void;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Public API for interacting with the event system
|
|
58
|
+
*/
|
|
59
|
+
export declare interface EventsAPI {
|
|
60
|
+
addEventListener<E extends keyof EngineEvents>(event: E, handler: EventHandler<EngineEvents[E]>): void;
|
|
61
|
+
removeEventListener<E extends keyof EngineEvents>(event: E, handler: EventHandler<EngineEvents[E]>): void;
|
|
62
|
+
hasListeners<E extends keyof EngineEvents>(event: E): boolean;
|
|
63
|
+
clear(): void;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Abstract base class for all interaction handlers.
|
|
68
|
+
* Provides common lifecycle management and access to camera controller, DOM element, and event manager.
|
|
69
|
+
* Subclasses can:
|
|
70
|
+
* - Configure camera-controls in onEnable/onDisable (e.g., set mouseButtons, limits)
|
|
71
|
+
* - Subscribe to DOM events or Mjolnir gestures in onEnable/onDisable
|
|
72
|
+
* - Or do both
|
|
73
|
+
* @template T Handler-specific options type (undefined if no options)
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* // Simple handler that just configures camera-controls
|
|
77
|
+
* class PanHandler extends Handler {
|
|
78
|
+
* protected onEnable(): void {
|
|
79
|
+
* this.controller.mouseButtons.left = CameraController.ACTION.TRUCK;
|
|
80
|
+
* }
|
|
81
|
+
*
|
|
82
|
+
* protected onDisable(): void {
|
|
83
|
+
* this.controller.mouseButtons.left = CameraController.ACTION.NONE;
|
|
84
|
+
* }
|
|
85
|
+
*
|
|
86
|
+
* reset(): void {
|
|
87
|
+
* // No custom state to reset
|
|
88
|
+
* }
|
|
89
|
+
* }
|
|
90
|
+
*
|
|
91
|
+
* // Handler with custom gesture recognition
|
|
92
|
+
* class RotateHandler extends Handler {
|
|
93
|
+
* private rotating = false;
|
|
94
|
+
*
|
|
95
|
+
* protected onEnable(): void {
|
|
96
|
+
* this.controller.touches.two = CameraController.ACTION.NONE; // Disable built-in
|
|
97
|
+
* this.eventManager.on('rotate', this.onRotate);
|
|
98
|
+
* this.domElement.addEventListener('pointerdown', this.onPointerDown);
|
|
99
|
+
* }
|
|
100
|
+
*
|
|
101
|
+
* protected onDisable(): void {
|
|
102
|
+
* this.eventManager.off('rotate', this.onRotate);
|
|
103
|
+
* this.domElement.removeEventListener('pointerdown', this.onPointerDown);
|
|
104
|
+
* this.rotating = false;
|
|
105
|
+
* }
|
|
106
|
+
*
|
|
107
|
+
* reset(): void {
|
|
108
|
+
* this.rotating = false;
|
|
109
|
+
* }
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
declare abstract class Handler<T = undefined> implements HandlerAPI<T> {
|
|
114
|
+
protected controller: default_3;
|
|
115
|
+
protected domElement: HTMLElement;
|
|
116
|
+
protected eventManager: EventManager;
|
|
117
|
+
/** Whether this handler is enabled */
|
|
118
|
+
protected enabled: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* @param controller The camera-controls instance for camera manipulation
|
|
121
|
+
* @param domElement The DOM element to attach event listeners to
|
|
122
|
+
* @param eventManager Shared Mjolnir EventManager for gesture recognition
|
|
123
|
+
*/
|
|
124
|
+
constructor(controller: default_3, domElement: HTMLElement, eventManager: EventManager);
|
|
125
|
+
/**
|
|
126
|
+
* Per-frame update for this handler.
|
|
127
|
+
* Called every frame in the render loop.
|
|
128
|
+
* Override if handler needs per-frame logic (e.g., smooth interpolation).
|
|
129
|
+
* @param delta Time elapsed since last frame in seconds
|
|
130
|
+
* @returns true if the handler made changes that require re-rendering
|
|
131
|
+
*/
|
|
132
|
+
update(delta: number): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Reset this handler to its initial state.
|
|
135
|
+
*/
|
|
136
|
+
abstract reset(): void;
|
|
137
|
+
/**
|
|
138
|
+
* Configure this handler with handler-specific options.
|
|
139
|
+
* Does NOT handle enabled state - use enable()/disable() for that.
|
|
140
|
+
* Subclasses should override to handle their specific options
|
|
141
|
+
* @param options Partial options to update (handler-specific, not including enabled flag)
|
|
142
|
+
*/
|
|
143
|
+
configure(options: T extends undefined ? never : Partial<T>): void;
|
|
144
|
+
/**
|
|
145
|
+
* Enable this handler.
|
|
146
|
+
* Calls onEnable() hook for subclass-specific enabling logic
|
|
147
|
+
*/
|
|
148
|
+
enable(): void;
|
|
149
|
+
/**
|
|
150
|
+
* Disable this handler.
|
|
151
|
+
* Calls onDisable() hook for subclass-specific disabling logic
|
|
152
|
+
*/
|
|
153
|
+
disable(): void;
|
|
154
|
+
/**
|
|
155
|
+
* Check if this handler is currently enabled
|
|
156
|
+
* @returns true if enabled, false otherwise
|
|
157
|
+
*/
|
|
158
|
+
isEnabled(): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Hook called when the handler is enabled.
|
|
161
|
+
* Subclasses override this to:
|
|
162
|
+
* - Configure camera-controls (set mouseButtons, touches, limits, etc.)
|
|
163
|
+
* - Subscribe to DOM events (addEventListener)
|
|
164
|
+
* - Subscribe to Mjolnir gestures (eventManager.on)
|
|
165
|
+
*/
|
|
166
|
+
protected abstract onEnable(): void;
|
|
167
|
+
/**
|
|
168
|
+
* Hook called when the handler is disabled.
|
|
169
|
+
* Subclasses override this to:
|
|
170
|
+
* - Reset camera-controls configuration
|
|
171
|
+
* - Unsubscribe from DOM events (removeEventListener)
|
|
172
|
+
* - Unsubscribe from Mjolnir gestures (eventManager.off)
|
|
173
|
+
*/
|
|
174
|
+
protected abstract onDisable(): void;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Public API interface exposed through renderer.controls.handlers.
|
|
179
|
+
* Each handler implements this interface to provide consistent enable/disable/configure functionality.
|
|
180
|
+
* @template T Handler-specific options type (can be undefined if handler has no options).
|
|
181
|
+
*/
|
|
182
|
+
declare interface HandlerAPI<T = undefined> {
|
|
183
|
+
/**
|
|
184
|
+
* Enable this handler
|
|
185
|
+
*/
|
|
186
|
+
enable(): void;
|
|
187
|
+
/**
|
|
188
|
+
* Disable this handler
|
|
189
|
+
*/
|
|
190
|
+
disable(): void;
|
|
191
|
+
/**
|
|
192
|
+
* Check if this handler is currently enabled
|
|
193
|
+
* @returns true if enabled, false otherwise
|
|
194
|
+
*/
|
|
195
|
+
isEnabled(): boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Configure this handler with new options.
|
|
198
|
+
* Only available if handler has options (T is not undefined)
|
|
199
|
+
* @param options Partial options to update
|
|
200
|
+
*/
|
|
201
|
+
configure(options: T extends undefined ? never : Partial<T>): void;
|
|
202
|
+
/**
|
|
203
|
+
* Reset this handler to its initial state.
|
|
204
|
+
*/
|
|
205
|
+
reset(): void;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Gesture handlers - all fields are readonly to prevent reassignment
|
|
210
|
+
*/
|
|
211
|
+
declare type Handlers = Readonly<{
|
|
212
|
+
/** Pan handler */
|
|
213
|
+
pan: PanHandler;
|
|
214
|
+
/** Roll handler */
|
|
215
|
+
roll: RollHandler;
|
|
216
|
+
}>;
|
|
217
|
+
|
|
218
|
+
/** Image definition */
|
|
219
|
+
export declare interface ImageDef extends SharedDef {
|
|
220
|
+
/** Image source. Not updatable. */
|
|
221
|
+
source: ImageSource;
|
|
222
|
+
/** Image's bounds */
|
|
223
|
+
bounds: Rect;
|
|
224
|
+
/**
|
|
225
|
+
* Image's anchor point. Defines the point on the image that is used as an origin point for transformations.
|
|
226
|
+
* [0, 0] is the top-left corner, [0.5, 0.5] is the center (default), [1, 1] is the bottom-right corner.
|
|
227
|
+
*/
|
|
228
|
+
origin?: [number, number];
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export declare type ImageSource = HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas;
|
|
232
|
+
|
|
233
|
+
export declare type Index = [number, number, number];
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Options for the InertiaController class.
|
|
237
|
+
*/
|
|
238
|
+
declare interface InertiaOptions {
|
|
239
|
+
/** Whether the inertia controller is enabled */
|
|
240
|
+
enabled?: boolean;
|
|
241
|
+
/** Minimum time in milliseconds to sample backwards to determine inertia */
|
|
242
|
+
minSampleMs?: number;
|
|
243
|
+
/** Inertial movement duration in milliseconds */
|
|
244
|
+
durationMs?: number;
|
|
245
|
+
/** Speed threshold after which inertia is stopped (in world units per ms) */
|
|
246
|
+
speedThreshold?: number;
|
|
247
|
+
/** Easing function for the inertia movement. Maps interval [0, 1] to [0, 1], default exp-in-ish */
|
|
248
|
+
ease?: (t: number) => number;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export declare function isImageDef(def: RenderableDef): def is ImageDef;
|
|
252
|
+
|
|
253
|
+
export declare function isImageLayer(layer: LayerDef): layer is TypedLayerDef<ImageDef>;
|
|
254
|
+
|
|
255
|
+
export declare function isLayerDef(def: RenderableDef): def is LayerDef;
|
|
256
|
+
|
|
257
|
+
export declare function isLayerLayer(layer: LayerDef): layer is TypedLayerDef<LayerDef>;
|
|
258
|
+
|
|
259
|
+
export declare function isLineDef(def: RenderableDef): def is LineDef;
|
|
260
|
+
|
|
261
|
+
export declare function isLineLayer(layer: LayerDef): layer is TypedLayerDef<LineDef>;
|
|
262
|
+
|
|
263
|
+
export declare function isShapeDef(def: RenderableDef): def is ShapeDef;
|
|
264
|
+
|
|
265
|
+
export declare function isShapeLayer(layer: LayerDef): layer is TypedLayerDef<ShapeDef>;
|
|
266
|
+
|
|
267
|
+
export declare function isTextDef(def: RenderableDef): def is TextDef;
|
|
268
|
+
|
|
269
|
+
export declare function isTextLayer(layer: LayerDef): layer is TypedLayerDef<TextDef>;
|
|
270
|
+
|
|
271
|
+
export declare type IVector2 = Vector2 | Vector2Like | Vector2Tuple;
|
|
272
|
+
|
|
273
|
+
/** Layer definition */
|
|
274
|
+
export declare interface LayerDef extends SharedDef {
|
|
275
|
+
/** Layer's name */
|
|
276
|
+
readonly name: string;
|
|
277
|
+
/** Whether to enable interaction with the layer (raycasting). */
|
|
278
|
+
interactive?: boolean;
|
|
279
|
+
/** Collection of layer's children. Mixing different types of children is not supported. */
|
|
280
|
+
children: RenderableDefCollection;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** Line definition */
|
|
284
|
+
export declare interface LineDef extends SharedDef {
|
|
285
|
+
/** Line's points. Not updatable. */
|
|
286
|
+
points: [Vector2Like, Vector2Like];
|
|
287
|
+
/** Line's color in css format */
|
|
288
|
+
color: ColorInput;
|
|
289
|
+
/** Line's width in screen-space units (pixels). */
|
|
290
|
+
width: number;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Data for mouse events
|
|
295
|
+
*/
|
|
296
|
+
export declare interface MouseEventData {
|
|
297
|
+
/** Original mouse event */
|
|
298
|
+
event: MouseEvent;
|
|
299
|
+
/** Point in svg coordinates */
|
|
300
|
+
point: Vector2Like;
|
|
301
|
+
/** Intersected defs */
|
|
302
|
+
defs: RenderableDef[];
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** Navigation system public API. */
|
|
306
|
+
declare interface NavigationAPI {
|
|
307
|
+
/** Zooms the camera by the given factor. */
|
|
308
|
+
zoomBy(zoom: number): void;
|
|
309
|
+
/** Zooms the camera to the given rectangle. */
|
|
310
|
+
zoomTo(rect: Rect, options?: Partial<ZoomToOptions>): void;
|
|
311
|
+
/** Resets the camera to the starting state. */
|
|
312
|
+
resetCamera(options?: Partial<ResetCameraOptions>): void;
|
|
313
|
+
/** Configures the camera controls. */
|
|
314
|
+
configure(options: Partial<ControlsOptions>): void;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Pan handler - wraps camera-controls TRUCK action.
|
|
319
|
+
* Handles both mouse drag (left-click) and single-finger touch pan.
|
|
320
|
+
* No custom event listeners needed - camera-controls handles everything
|
|
321
|
+
*/
|
|
322
|
+
declare class PanHandler extends Handler {
|
|
323
|
+
reset(): void;
|
|
324
|
+
/**
|
|
325
|
+
* Enable pan gestures.
|
|
326
|
+
* Configures camera-controls to handle left-click drag and single-touch drag
|
|
327
|
+
*/
|
|
328
|
+
protected onEnable(): void;
|
|
329
|
+
/**
|
|
330
|
+
* Disable pan gestures.
|
|
331
|
+
* Removes pan actions from camera-controls
|
|
332
|
+
*/
|
|
333
|
+
protected onDisable(): void;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** Polygon shape instance. */
|
|
337
|
+
export declare class Polygon {
|
|
338
|
+
/** Array of polygon vertices. */
|
|
339
|
+
readonly vertices: Vector2[];
|
|
340
|
+
/** Array of polygon indices. Each index is a triplet of vertex indices forming a triangle. */
|
|
341
|
+
readonly indices: Index[];
|
|
342
|
+
/**
|
|
343
|
+
* @param vertices Array of polygon vertices.
|
|
344
|
+
* @param indices Array of polygon indices. Each index is a triplet of vertex indices forming a triangle.
|
|
345
|
+
*/
|
|
346
|
+
constructor(vertices: IVector2[], indices: Index[]);
|
|
347
|
+
/**
|
|
348
|
+
* Converts a {@link Rect} to a {@link Polygon}.
|
|
349
|
+
* @param rect {@link Rect} instance
|
|
350
|
+
* @returns new {@link Polygon} instance
|
|
351
|
+
*/
|
|
352
|
+
static fromRect(rect: Rect): Polygon;
|
|
353
|
+
/**
|
|
354
|
+
* Merges multiple polygons into a single one.
|
|
355
|
+
* @param polygons Array of {@link Polygon} instances
|
|
356
|
+
* @returns new {@link Polygon} instance
|
|
357
|
+
*/
|
|
358
|
+
static merge(...polygons: Polygon[]): Polygon;
|
|
359
|
+
/**
|
|
360
|
+
* Rotates all vertices of the polygon around the given center.
|
|
361
|
+
* @param rotation Rotation angle in radians. Positive values rotate clockwise.
|
|
362
|
+
* @param center Center of the rotation.
|
|
363
|
+
* @returns this {@link Polygon} instance
|
|
364
|
+
*/
|
|
365
|
+
rotate(rotation: number, center: Vector2Like): Polygon;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/** Rectangle shape instance. */
|
|
369
|
+
export declare class Rect {
|
|
370
|
+
/** Top left corner of the rectangle. */
|
|
371
|
+
readonly min: Vector2;
|
|
372
|
+
/** Bottom right corner of the rectangle. */
|
|
373
|
+
readonly max: Vector2;
|
|
374
|
+
/** Optional rotation of the rectangle. In radians, around center. Positive values rotate clockwise. */
|
|
375
|
+
rotation: number;
|
|
376
|
+
private _center?;
|
|
377
|
+
private _size?;
|
|
378
|
+
/**
|
|
379
|
+
* @param min Top left corner of the rectangle.
|
|
380
|
+
* @param max Bottom right corner of the rectangle.
|
|
381
|
+
* @param rotation Optional rotation of the rectangle. In radians, around center. Positive values rotate clockwise.
|
|
382
|
+
*/
|
|
383
|
+
constructor(min: IVector2, max: IVector2, rotation?: number);
|
|
384
|
+
/** Center of the rectangle. Read-only, calculated on demand. */
|
|
385
|
+
get center(): Vector2;
|
|
386
|
+
/** Size of the rectangle. Read-only, calculated on demand. */
|
|
387
|
+
get size(): Vector2;
|
|
388
|
+
/**
|
|
389
|
+
* Creates a rectangle from an SVG rectangle element.
|
|
390
|
+
* @param rect {@link SVGRectElement} or {@link SVGImageElement}
|
|
391
|
+
* @param rotation Optional rotation of the rectangle. In radians, around center. Positive values rotate clockwise.
|
|
392
|
+
* @returns new {@link Rect} instance
|
|
393
|
+
*/
|
|
394
|
+
static fromSvg(rect: SVGRectElement | SVGImageElement, rotation?: number): Rect;
|
|
395
|
+
/**
|
|
396
|
+
* Increases the size of the rectangle by the given amount. Padding is added to both sides of the rectangle.
|
|
397
|
+
* @param x Horizontal padding.
|
|
398
|
+
* @param y Vertical padding. If omitted, defaults to the same value as `x`.
|
|
399
|
+
* @returns this {@link Rect} instance
|
|
400
|
+
*/
|
|
401
|
+
addPadding(x: number, y?: number): this;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
export declare type RenderableDef = LayerDef | ShapeDef | ImageDef | TextDef | LineDef;
|
|
405
|
+
|
|
406
|
+
export declare type RenderableDefCollection<T = RenderableDef> = T extends RenderableDef ? T[] : never;
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Main class for rendering the content of a {@link SceneDef}
|
|
410
|
+
*/
|
|
411
|
+
export declare class Renderer {
|
|
412
|
+
/** Whether to log debug information */
|
|
413
|
+
readonly debugLog: boolean;
|
|
414
|
+
/** {@link HTMLCanvasElement} that this renderer is rendering to */
|
|
415
|
+
readonly canvas: HTMLCanvasElement;
|
|
416
|
+
private ui?;
|
|
417
|
+
private clock;
|
|
418
|
+
private renderer;
|
|
419
|
+
private eventSystem;
|
|
420
|
+
private layerSystem;
|
|
421
|
+
private viewportSystem;
|
|
422
|
+
private interactionsSystem;
|
|
423
|
+
private memoryInfoExtension;
|
|
424
|
+
private memoryInfo;
|
|
425
|
+
private viewport?;
|
|
426
|
+
private needsRedraw;
|
|
427
|
+
private isExternalMode;
|
|
428
|
+
/**
|
|
429
|
+
* @param opts {@link RendererOptions}
|
|
430
|
+
*/
|
|
431
|
+
constructor(opts: RendererOptions);
|
|
432
|
+
/**
|
|
433
|
+
* {@link NavigationAPI} instance for controlling the viewport
|
|
434
|
+
*/
|
|
435
|
+
get controls(): NavigationAPI & {
|
|
436
|
+
handlers: Handlers;
|
|
437
|
+
controller: default_3;
|
|
438
|
+
};
|
|
439
|
+
/**
|
|
440
|
+
* {@link EventsAPI} instance for subscribing to internal events
|
|
441
|
+
*/
|
|
442
|
+
get events(): EventsAPI;
|
|
443
|
+
/**
|
|
444
|
+
* Optional sub-rectangle of the viewport that is used for positioning scene's viewbox
|
|
445
|
+
*/
|
|
446
|
+
get visibleRect(): Rect | undefined;
|
|
447
|
+
/**
|
|
448
|
+
* Optional sub-rectangle of the viewport that is used for positioning scene's viewbox
|
|
449
|
+
*/
|
|
450
|
+
set visibleRect(rect: Rect);
|
|
451
|
+
/**
|
|
452
|
+
* Underlying {@link WebGLRenderer} instance
|
|
453
|
+
*/
|
|
454
|
+
get context(): WebGLRenderer;
|
|
455
|
+
/* Excluded from this release type: size */
|
|
456
|
+
/**
|
|
457
|
+
* Sets the renderer to external mode, where parts of rendering process are not managed by the renderer (e.g. Mapbox GL JS).
|
|
458
|
+
* @param staticTransformMatrix static transform matrix to apply to the scene
|
|
459
|
+
*/
|
|
460
|
+
configureExternalMode(staticTransformMatrix: number[]): void;
|
|
461
|
+
/**
|
|
462
|
+
* Update scene matrix from dynamic transform matrix.
|
|
463
|
+
* @param dynamicTransformMatrix dynamic transform matrix (changes every frame)
|
|
464
|
+
*/
|
|
465
|
+
updateExternalTransformMatrix(dynamicTransformMatrix: number[]): void;
|
|
466
|
+
/**
|
|
467
|
+
* Initialize the scene and start the rendering loop
|
|
468
|
+
* @param sceneDef {@link SceneDef} to render
|
|
469
|
+
* @param startLoop whether to start the rendering loop
|
|
470
|
+
*/
|
|
471
|
+
start(sceneDef: SceneDef, startLoop?: boolean): void;
|
|
472
|
+
/**
|
|
473
|
+
* Update the given defs to make them reflect the current state
|
|
474
|
+
* @param defs {@link RenderableDef} array to update
|
|
475
|
+
*/
|
|
476
|
+
update(...defs: RenderableDef[]): void;
|
|
477
|
+
/**
|
|
478
|
+
* Converts coordinates from canvas space to SVG space.
|
|
479
|
+
* @param point point in canvas space (relative to the canvas's top left corner)
|
|
480
|
+
* @returns point in SVG space
|
|
481
|
+
*/
|
|
482
|
+
screenToSvg(point: Vector2Like): Vector2Like;
|
|
483
|
+
/**
|
|
484
|
+
* Main rendering loop
|
|
485
|
+
*/
|
|
486
|
+
render(): void;
|
|
487
|
+
private resizeCanvasToDisplaySize;
|
|
488
|
+
private updateMemoryInfo;
|
|
489
|
+
private onContextLost;
|
|
490
|
+
private onContextRestored;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Options for initializing the {@link Renderer}
|
|
495
|
+
*/
|
|
496
|
+
export declare interface RendererOptions {
|
|
497
|
+
/** {@link HTMLCanvasElement} to render to */
|
|
498
|
+
canvas: HTMLCanvasElement;
|
|
499
|
+
/** Optional {@link WebGLRenderingContext} to use (e.g. for Mapbox GL JS) */
|
|
500
|
+
gl?: WebGLRenderingContext;
|
|
501
|
+
/** Whether to log debug information */
|
|
502
|
+
debugLog?: boolean;
|
|
503
|
+
/** Optional partial {@link UI} configuration */
|
|
504
|
+
ui?: Partial<UI>;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/** Options for the {@link NavigationAPI.resetCamera} method. */
|
|
508
|
+
declare interface ResetCameraOptions {
|
|
509
|
+
/** Whether to reset the camera roll. */
|
|
510
|
+
roll: boolean;
|
|
511
|
+
/** Whether to reset the camera zoom. */
|
|
512
|
+
zoom: boolean;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Roll handler - implements custom two-finger rotation around arbitrary pivot point.
|
|
517
|
+
* Handles mouse drag (right-click) via camera-controls and custom touch rotation.
|
|
518
|
+
*
|
|
519
|
+
* Touch rotation keeps world points under both fingers fixed in screen space by:
|
|
520
|
+
* 1. Unprojecting finger midpoint to world plane
|
|
521
|
+
* 2. Rotating camera (azimuth)
|
|
522
|
+
* 3. Panning camera to compensate for midpoint movement
|
|
523
|
+
*/
|
|
524
|
+
declare class RollHandler extends Handler {
|
|
525
|
+
private rotating;
|
|
526
|
+
private startVector?;
|
|
527
|
+
private vector?;
|
|
528
|
+
private minDiameter;
|
|
529
|
+
private startBearing;
|
|
530
|
+
private raycaster;
|
|
531
|
+
private pivotWorld;
|
|
532
|
+
private tempVec2;
|
|
533
|
+
private tempVec3;
|
|
534
|
+
reset(): void;
|
|
535
|
+
/**
|
|
536
|
+
* Enable roll gestures.
|
|
537
|
+
* - Mobile: custom two-finger rotation with pivot compensation
|
|
538
|
+
*/
|
|
539
|
+
protected onEnable(): void;
|
|
540
|
+
/**
|
|
541
|
+
* Disable roll gestures.
|
|
542
|
+
* Restricts azimuth angle to zero and removes event listeners
|
|
543
|
+
*/
|
|
544
|
+
protected onDisable(): void;
|
|
545
|
+
private onRotateStart;
|
|
546
|
+
private onRotate;
|
|
547
|
+
private onRotateEnd;
|
|
548
|
+
/**
|
|
549
|
+
* Check if rotation is below threshold (Mapbox-style).
|
|
550
|
+
* Threshold is in pixels along circumference, scaled by touch circle diameter.
|
|
551
|
+
* @param vector Current vector between fingers
|
|
552
|
+
* @returns true if below threshold, false otherwise
|
|
553
|
+
*/
|
|
554
|
+
private isBelowThreshold;
|
|
555
|
+
/**
|
|
556
|
+
* Get signed angle between two vectors in degrees
|
|
557
|
+
* @param a First vector
|
|
558
|
+
* @param b Second vector
|
|
559
|
+
* @returns Angle difference in degrees
|
|
560
|
+
*/
|
|
561
|
+
private getBearingDelta;
|
|
562
|
+
/**
|
|
563
|
+
* Normalize screen pixel coordinates to NDC [-1, 1]
|
|
564
|
+
* @param screenPos Screen position in pixels
|
|
565
|
+
* @param out Output vector for NDC coordinates
|
|
566
|
+
* @returns NDC coordinates
|
|
567
|
+
*/
|
|
568
|
+
private normalizeScreenCoords;
|
|
569
|
+
/**
|
|
570
|
+
* Denormalize NDC coordinates to screen pixels
|
|
571
|
+
* @param ndc NDC coordinates [-1, 1]
|
|
572
|
+
* @param out Output vector for screen pixel coordinates
|
|
573
|
+
* @returns Screen pixel coordinates
|
|
574
|
+
*/
|
|
575
|
+
private denormalizeScreenCoords;
|
|
576
|
+
/**
|
|
577
|
+
* Unproject screen NDC coordinates to world plane (Z=0)
|
|
578
|
+
* @param ndc NDC coordinates [-1, 1]
|
|
579
|
+
* @param out Output vector for world coordinates
|
|
580
|
+
* @returns World coordinates on Z=0 plane
|
|
581
|
+
*/
|
|
582
|
+
private unprojectToWorldPlane;
|
|
583
|
+
/**
|
|
584
|
+
* Project world point to screen NDC coordinates
|
|
585
|
+
* @param worldPos World position
|
|
586
|
+
* @param out Output vector for NDC coordinates
|
|
587
|
+
* @returns NDC coordinates
|
|
588
|
+
*/
|
|
589
|
+
private projectWorldToScreen;
|
|
590
|
+
/**
|
|
591
|
+
* Convert screen-space pixel delta to world-space translation.
|
|
592
|
+
* For top-down view, this is a simple perspective calculation.
|
|
593
|
+
* @param deltaX Screen delta X in pixels
|
|
594
|
+
* @param deltaY Screen delta Y in pixels
|
|
595
|
+
* @returns World-space translation vector
|
|
596
|
+
*/
|
|
597
|
+
private screenDeltaToWorldDelta;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Options for the RollController class.
|
|
602
|
+
*/
|
|
603
|
+
declare interface RollOptions {
|
|
604
|
+
/** Whether the roll controller is enabled */
|
|
605
|
+
enabled?: boolean;
|
|
606
|
+
/** Speed in radians of arc length per pixel */
|
|
607
|
+
speed?: number;
|
|
608
|
+
/** Threshold in degrees for the roll gesture */
|
|
609
|
+
angleThreshold?: number;
|
|
610
|
+
/** Threshold in scale for the pinch gesture */
|
|
611
|
+
pinchThreshold?: number;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/** Scene definition */
|
|
615
|
+
export declare interface SceneDef {
|
|
616
|
+
/** Root layer of the scene tree */
|
|
617
|
+
rootLayer: LayerDef;
|
|
618
|
+
/** Background color in css format */
|
|
619
|
+
background?: ColorInput;
|
|
620
|
+
/** SVG viewbox */
|
|
621
|
+
viewbox: Rect;
|
|
622
|
+
/** Textures memory limit in megabytes */
|
|
623
|
+
memoryLimit?: number;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
export declare type Shape = Rect | Polygon;
|
|
627
|
+
|
|
628
|
+
/** Shape definition. */
|
|
629
|
+
export declare interface ShapeDef extends SharedDef {
|
|
630
|
+
/** Shape to render. Not updatable. */
|
|
631
|
+
shape: Shape;
|
|
632
|
+
/** Shape's color in css format */
|
|
633
|
+
color: ColorInput;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/** Shared properties for all renderable defs */
|
|
637
|
+
export declare interface SharedDef {
|
|
638
|
+
/** Whether the def is hidden */
|
|
639
|
+
hidden?: boolean;
|
|
640
|
+
/** Def's dim state. `true` to dim, `false` to skip dim, `undefined` to reset to ancestor's value. */
|
|
641
|
+
dim?: boolean;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/** Text alignment */
|
|
645
|
+
export declare interface TextAlignment {
|
|
646
|
+
/** Horizontal alignment */
|
|
647
|
+
horizontal: "left" | "center" | "right";
|
|
648
|
+
/** Vertical alignment */
|
|
649
|
+
vertical: "top" | "center" | "bottom";
|
|
650
|
+
/** Text alignment within the line. Optional. */
|
|
651
|
+
text?: "left" | "center" | "right";
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/** Text definition */
|
|
655
|
+
export declare interface TextDef extends SharedDef {
|
|
656
|
+
/** Array of text lines. Not updatable, but each line is updatable. */
|
|
657
|
+
lines: TextLineDef[];
|
|
658
|
+
/** Text's bounds */
|
|
659
|
+
bounds: Rect;
|
|
660
|
+
/** Text's padding [horizontal, vertical] */
|
|
661
|
+
padding: [number, number];
|
|
662
|
+
/** {@link TextAlignment} object describing text's alignment */
|
|
663
|
+
alignment: TextAlignment;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/** Single text line definition */
|
|
667
|
+
export declare interface TextLineDef {
|
|
668
|
+
/** Line's text */
|
|
669
|
+
text: string;
|
|
670
|
+
/** Line's color in css format */
|
|
671
|
+
color: ColorInput;
|
|
672
|
+
/** Line's font URL. Not updatable. Supported formats: .ttf, .otf, .woff (.woff2 is not supported). */
|
|
673
|
+
fontUrl: string;
|
|
674
|
+
/** Line's font size */
|
|
675
|
+
fontSize: number;
|
|
676
|
+
/** Line's stroke color & width. Optional. */
|
|
677
|
+
stroke?: {
|
|
678
|
+
color: ColorInput;
|
|
679
|
+
width: number;
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/** Typed layer definition. Useful for type-checking and type-casting. */
|
|
684
|
+
export declare interface TypedLayerDef<T extends RenderableDef> extends LayerDef {
|
|
685
|
+
children: RenderableDefCollection<T>;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Type describing debug UI elements
|
|
690
|
+
*/
|
|
691
|
+
export declare interface UI {
|
|
692
|
+
/** {@link Stats} instance for tracking performance metrics */
|
|
693
|
+
stats: default_2;
|
|
694
|
+
/** HTML element for displaying WebGL memory information */
|
|
695
|
+
memoryInfoPanel: HTMLDivElement;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/** Options for the {@link NavigationAPI.zoomTo} method. */
|
|
699
|
+
declare interface ZoomToOptions {
|
|
700
|
+
/** Maximum zoom factor. */
|
|
701
|
+
maxZoom: number;
|
|
702
|
+
/** Percentage of padding to add to the target rectangle. */
|
|
703
|
+
paddingPercent: number;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
export { }
|