cube.gl 2.0.2 → 2.0.4
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 +4 -0
- package/dist/cubegl.es.js +1 -1
- package/dist/cubegl.umd.js +147 -147
- package/dist/cubegl.umd.js.map +1 -1
- package/dist/{index-htwAux5a.js → index-BWsuqkzq.js} +4277 -4256
- package/dist/{index-htwAux5a.js.map → index-BWsuqkzq.js.map} +1 -1
- package/dist/{lerc-BKX0pRXj.js → lerc-yahGc1q-.js} +2 -2
- package/dist/{lerc-BKX0pRXj.js.map → lerc-yahGc1q-.js.map} +1 -1
- package/package.json +5 -2
- package/types/index.d.ts +697 -0
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cube.gl",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "CUBE.gl core. A WebGL-powered geographic data visualization framework build upon three.js.",
|
|
5
5
|
"main": "./dist/cubegl.umd.js",
|
|
6
6
|
"module": "./dist/cubegl.es.js",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"types": "./types/index.d.ts",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
11
|
+
"types": "./types/index.d.ts",
|
|
10
12
|
"import": "./dist/cubegl.es.js",
|
|
11
13
|
"require": "./dist/cubegl.umd.js",
|
|
12
14
|
"default": "./dist/cubegl.umd.js"
|
|
@@ -32,7 +34,8 @@
|
|
|
32
34
|
},
|
|
33
35
|
"files": [
|
|
34
36
|
"dist/*.js",
|
|
35
|
-
"dist/*.js.map"
|
|
37
|
+
"dist/*.js.map",
|
|
38
|
+
"types/"
|
|
36
39
|
],
|
|
37
40
|
"keywords": [
|
|
38
41
|
"CUBE.gl",
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,697 @@
|
|
|
1
|
+
import * as THREE from 'three'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CUBE.gl - WebGL-powered geographic data visualization framework
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// ============ Core ============
|
|
8
|
+
|
|
9
|
+
export interface CubeConfig {
|
|
10
|
+
/** Map scale factor */
|
|
11
|
+
scale: number
|
|
12
|
+
/** Map center GPS coordinate */
|
|
13
|
+
center: GPSCoordinate
|
|
14
|
+
/** Background color hex string (without #), e.g. "333333" */
|
|
15
|
+
background?: string
|
|
16
|
+
/** Camera configuration */
|
|
17
|
+
camera?: {
|
|
18
|
+
name?: string
|
|
19
|
+
type?: string
|
|
20
|
+
near?: number
|
|
21
|
+
far?: number
|
|
22
|
+
position?: { x: number; y: number; z: number }
|
|
23
|
+
}
|
|
24
|
+
/** Renderer configuration */
|
|
25
|
+
renderer?: {
|
|
26
|
+
antialias?: boolean
|
|
27
|
+
shadowMap?: { enabled: boolean }
|
|
28
|
+
}
|
|
29
|
+
/** Controls configuration */
|
|
30
|
+
controls?: {
|
|
31
|
+
type?: string
|
|
32
|
+
rotateSpeed?: number
|
|
33
|
+
damping?: { enabled: boolean; factor: number }
|
|
34
|
+
screenSpacePanning?: boolean
|
|
35
|
+
autoRotate?: { enabled: boolean; speed: number }
|
|
36
|
+
minDistance?: number
|
|
37
|
+
maxDistance?: number
|
|
38
|
+
}
|
|
39
|
+
/** Light configuration array */
|
|
40
|
+
lights?: LightConfig[]
|
|
41
|
+
/** Fog configuration */
|
|
42
|
+
fog?: {
|
|
43
|
+
enabled: boolean
|
|
44
|
+
color: string
|
|
45
|
+
near: number
|
|
46
|
+
far: number
|
|
47
|
+
}
|
|
48
|
+
/** Interaction configuration */
|
|
49
|
+
interaction?: {
|
|
50
|
+
enable: boolean
|
|
51
|
+
select?: boolean
|
|
52
|
+
hover?: boolean
|
|
53
|
+
}
|
|
54
|
+
/** Enable debug mode (shows FPS stats) */
|
|
55
|
+
debug?: boolean
|
|
56
|
+
/** Lab features */
|
|
57
|
+
lab?: {
|
|
58
|
+
wasm?: boolean
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface LightConfig {
|
|
63
|
+
/** Light name identifier */
|
|
64
|
+
name: string
|
|
65
|
+
/** Light type: "Ambient" | "Point" | "Directional" | "Hemisphere" */
|
|
66
|
+
type: 'Ambient' | 'Point' | 'Directional' | 'Hemisphere'
|
|
67
|
+
/** Color hex string (without #), e.g. "fafafa" */
|
|
68
|
+
color: string
|
|
69
|
+
/** Light intensity. Ambient: multiplier (0.5-5), Point: candela (1000-100000), Directional: lux (1-10) */
|
|
70
|
+
intensity?: number
|
|
71
|
+
/** @deprecated Use intensity instead */
|
|
72
|
+
opacity?: number
|
|
73
|
+
/** Enable shadow casting */
|
|
74
|
+
shadow?: boolean
|
|
75
|
+
/** Light position (for Point and Directional) */
|
|
76
|
+
position?: { x: number; y: number; z: number }
|
|
77
|
+
/** Decay rate for Point lights (default: 2, physically correct) */
|
|
78
|
+
decay?: number
|
|
79
|
+
/** Max distance for Point lights (0 = infinite) */
|
|
80
|
+
distance?: number
|
|
81
|
+
/** Ground color for Hemisphere lights */
|
|
82
|
+
groundColor?: string
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface GPSCoordinate {
|
|
86
|
+
latitude: number
|
|
87
|
+
longitude: number
|
|
88
|
+
altitude?: number
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface WorldCoordinate {
|
|
92
|
+
x: number
|
|
93
|
+
y: number
|
|
94
|
+
z: number
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Main CUBE.gl space instance - manages scene, camera, renderer and runtime
|
|
99
|
+
*/
|
|
100
|
+
export class Space {
|
|
101
|
+
/** Three.js module reference */
|
|
102
|
+
three: typeof THREE
|
|
103
|
+
/** Three.js scene */
|
|
104
|
+
scene: THREE.Scene
|
|
105
|
+
/** Three.js camera */
|
|
106
|
+
camera: THREE.PerspectiveCamera
|
|
107
|
+
/** Three.js renderer */
|
|
108
|
+
renderer: THREE.WebGLRenderer
|
|
109
|
+
/** Map controls */
|
|
110
|
+
controls: any
|
|
111
|
+
/** Space options */
|
|
112
|
+
options: CubeConfig
|
|
113
|
+
/** Map scale */
|
|
114
|
+
scale: number
|
|
115
|
+
/** Action handler (available when interaction is enabled) */
|
|
116
|
+
Action: Action
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Create a CUBE.gl space
|
|
120
|
+
* @param container - DOM element to render into
|
|
121
|
+
* @param opt - Configuration options (center and scale are required)
|
|
122
|
+
*/
|
|
123
|
+
constructor(container: HTMLElement, opt: CubeConfig)
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Add a 3D object to the scene or a group
|
|
127
|
+
* @param object3D - Three.js Object3D to add
|
|
128
|
+
* @param group - Target group (name string, Group object, or undefined for scene root)
|
|
129
|
+
* @returns The added object
|
|
130
|
+
*/
|
|
131
|
+
Add(object3D: THREE.Object3D, group?: THREE.Group | string): THREE.Object3D
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Remove and dispose a 3D object
|
|
135
|
+
* @param object3D - Object to remove
|
|
136
|
+
* @param group - Group to remove from (defaults to scene)
|
|
137
|
+
*/
|
|
138
|
+
Delete(object3D: THREE.Object3D, group?: THREE.Group): boolean
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Create and add a named group (layer) to the scene
|
|
142
|
+
* @param name - Layer name
|
|
143
|
+
* @returns The created group
|
|
144
|
+
*/
|
|
145
|
+
AddLayer(name: string): THREE.Group
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Remove a layer and dispose all its children
|
|
149
|
+
* @param name - Layer name to delete
|
|
150
|
+
*/
|
|
151
|
+
DeleteLayer(name: string): void
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Find an object in the scene by name, id, or reference
|
|
155
|
+
* @param obj - Name string, numeric id, or Object3D reference
|
|
156
|
+
* @param group - Group to search in (defaults to scene)
|
|
157
|
+
*/
|
|
158
|
+
Find(obj: string | number | THREE.Object3D, group?: THREE.Group): THREE.Object3D | undefined
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Make an object always face the camera
|
|
162
|
+
* @param object - Object to set look-at behavior
|
|
163
|
+
*/
|
|
164
|
+
SetLookAt(object: THREE.Object3D): void
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Remove look-at behavior from an object
|
|
168
|
+
* @param obj - Object to remove look-at from
|
|
169
|
+
*/
|
|
170
|
+
RemoveLookAt(obj: THREE.Object3D): void
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Runtime loop - call this in requestAnimationFrame
|
|
174
|
+
*/
|
|
175
|
+
Runtime(): void
|
|
176
|
+
|
|
177
|
+
/** Get the current AnimationEngine */
|
|
178
|
+
GetAniEngine(): AnimationEngine | undefined
|
|
179
|
+
|
|
180
|
+
/** Set an AnimationEngine instance */
|
|
181
|
+
SetAniEngine(aniEngine: AnimationEngine): void
|
|
182
|
+
|
|
183
|
+
/** Get the current ShaderEngine */
|
|
184
|
+
GetShaderEngine(): ShaderEngine | undefined
|
|
185
|
+
|
|
186
|
+
/** Set a ShaderEngine instance */
|
|
187
|
+
SetShaderEngine(shaderEngine: ShaderEngine): void
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Cast a ray to detect clicked/touched objects
|
|
191
|
+
* @param event - DOM event from cube-select or cube-hover listener
|
|
192
|
+
* @param layer - Optional layer/group to search in
|
|
193
|
+
* @returns The intersected object, or null
|
|
194
|
+
*/
|
|
195
|
+
Ray(event: CustomEvent, layer?: THREE.Group | string): THREE.Object3D | null
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Export a 3D object to OBJ format string
|
|
199
|
+
* @param obj - Object to export
|
|
200
|
+
* @returns OBJ format string
|
|
201
|
+
*/
|
|
202
|
+
exportOBJ(obj: THREE.Object3D): string
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// ============ Layers ============
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Base layer class
|
|
209
|
+
*/
|
|
210
|
+
export class Layer {
|
|
211
|
+
constructor(name: string)
|
|
212
|
+
/** Return the Three.js Group */
|
|
213
|
+
Layer(): THREE.Group
|
|
214
|
+
/** Add an object to this layer */
|
|
215
|
+
Add(object3D: THREE.Object3D): THREE.Group
|
|
216
|
+
/** Remove and dispose an object from this layer */
|
|
217
|
+
Delete(object3D: THREE.Object3D): THREE.Group
|
|
218
|
+
/** Remove all objects from this layer */
|
|
219
|
+
Clear(): THREE.Group
|
|
220
|
+
/** Find an object by name */
|
|
221
|
+
Find(name: string): THREE.Object3D | undefined
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface BuildingOptions {
|
|
225
|
+
/** Merge geometries for better performance (default: false) */
|
|
226
|
+
merge?: boolean
|
|
227
|
+
/** Building color */
|
|
228
|
+
color?: number
|
|
229
|
+
/** Enable invisible colliders for raycasting when merged */
|
|
230
|
+
collider?: boolean
|
|
231
|
+
/** Terrain object for altitude fitting */
|
|
232
|
+
terrain?: THREE.Group
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export interface RoadOptions {
|
|
236
|
+
/** Road color (default: 0x4287f5) */
|
|
237
|
+
color?: number
|
|
238
|
+
/** Road width (default: 12) */
|
|
239
|
+
width?: number
|
|
240
|
+
/** Terrain object for altitude fitting */
|
|
241
|
+
terrain?: THREE.Group
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export interface RoadSpOptions extends RoadOptions {
|
|
245
|
+
/** Enable dash line animation */
|
|
246
|
+
animation?: boolean
|
|
247
|
+
/** AnimationEngine instance (required when animation is true) */
|
|
248
|
+
animationEngine?: AnimationEngine
|
|
249
|
+
/** Animation line color (default: 0x00FFFF) */
|
|
250
|
+
animationColor?: number
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export interface AdministrativeMapOptions {
|
|
254
|
+
/** Show borders */
|
|
255
|
+
border?: boolean
|
|
256
|
+
/** Extrude height */
|
|
257
|
+
height?: number
|
|
258
|
+
/** Merge geometries for performance */
|
|
259
|
+
merge?: boolean
|
|
260
|
+
/** Enable colliders */
|
|
261
|
+
collider?: boolean
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export interface PolygonOptions {
|
|
265
|
+
/** Polygon color */
|
|
266
|
+
color?: number
|
|
267
|
+
/** Extrude height */
|
|
268
|
+
height?: number
|
|
269
|
+
/** Merge geometries for performance */
|
|
270
|
+
merge?: boolean
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Geographic layer for buildings, roads, water, and administrative maps
|
|
275
|
+
*/
|
|
276
|
+
export class GeoLayer {
|
|
277
|
+
/**
|
|
278
|
+
* @param name - Layer name
|
|
279
|
+
* @param geojson - GeoJSON data object
|
|
280
|
+
*/
|
|
281
|
+
constructor(name: string, geojson: any)
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Render administrative/political map boundaries
|
|
285
|
+
* @param options - Map options
|
|
286
|
+
* @param matMap - Optional replacement material for map faces
|
|
287
|
+
* @param matLine - Optional replacement material for borders
|
|
288
|
+
*/
|
|
289
|
+
AdministrativeMap(options?: AdministrativeMapOptions, matMap?: THREE.Material, matLine?: THREE.Material): THREE.Group
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Render buildings from GeoJSON data
|
|
293
|
+
* @param options - Building options
|
|
294
|
+
* @param mat - Optional replacement material
|
|
295
|
+
*/
|
|
296
|
+
Buildings(options?: BuildingOptions, mat?: THREE.Material): THREE.Group
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Render roads as fat lines (Line2)
|
|
300
|
+
* @param options - Road options
|
|
301
|
+
* @param mat - Optional replacement material
|
|
302
|
+
*/
|
|
303
|
+
Road(options?: RoadOptions, mat?: THREE.Material): THREE.Group
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Render roads with optional dash animation
|
|
307
|
+
* @param options - Road options with animation support
|
|
308
|
+
* @param mat - Optional replacement material
|
|
309
|
+
*/
|
|
310
|
+
RoadSp(options?: RoadSpOptions, mat?: THREE.Material): THREE.Group
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Render water bodies
|
|
314
|
+
* @param options - { merge?: boolean }
|
|
315
|
+
*/
|
|
316
|
+
Water(options?: { merge?: boolean }): THREE.Group
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Render custom polygons
|
|
320
|
+
* @param options - Polygon options
|
|
321
|
+
* @param mat - Optional replacement material
|
|
322
|
+
*/
|
|
323
|
+
Polygon(options?: PolygonOptions, mat?: THREE.Material): THREE.Group
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** @deprecated Use GeoLayer instead */
|
|
327
|
+
export const GeoJsonLayer: typeof GeoLayer
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Bitmap tile map layer
|
|
331
|
+
*/
|
|
332
|
+
export class BitmapLayer {
|
|
333
|
+
constructor(name: string)
|
|
334
|
+
/**
|
|
335
|
+
* Create a tile map from OpenStreetMap or custom tile source
|
|
336
|
+
* @param opt - { source?: string, size?: number }
|
|
337
|
+
*/
|
|
338
|
+
TileMap(opt?: { source?: string; size?: number }): THREE.Group
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Terrain layer for ground, water ground, and GeoTIFF elevation
|
|
343
|
+
*/
|
|
344
|
+
export class Terrain {
|
|
345
|
+
constructor(name?: string)
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Create a flat ground plane
|
|
349
|
+
* @param sizeX - Width (default: 20)
|
|
350
|
+
* @param sizeY - Height (default: 20)
|
|
351
|
+
* @param segments - Quality segments (default: 32)
|
|
352
|
+
*/
|
|
353
|
+
Ground(sizeX?: number, sizeY?: number, segments?: number): THREE.Group
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Create a water surface ground
|
|
357
|
+
*/
|
|
358
|
+
WaterGround(sizeX?: number, sizeY?: number, segments?: number): THREE.Group
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Create terrain from GeoTIFF elevation data
|
|
362
|
+
* @param tiffData - ArrayBuffer of TIFF image
|
|
363
|
+
* @param heightScale - Height multiplier (default: 30)
|
|
364
|
+
* @param options - { color?: number }
|
|
365
|
+
* @param mat - Optional replacement material
|
|
366
|
+
*/
|
|
367
|
+
GeoTiff(tiffData: ArrayBuffer, heightScale?: number, options?: { color?: number }, mat?: THREE.Material): Promise<THREE.Group>
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Custom polygon layer
|
|
372
|
+
*/
|
|
373
|
+
export class Polygon {
|
|
374
|
+
constructor(name: string, coors: number[][][])
|
|
375
|
+
/**
|
|
376
|
+
* Create an extruded polygon
|
|
377
|
+
* @param info - Polygon metadata
|
|
378
|
+
* @param options - { height?: number, color?: number }
|
|
379
|
+
* @param mat - Optional replacement material
|
|
380
|
+
*/
|
|
381
|
+
Ground(info?: object, options?: { height?: number; color?: number }, mat?: THREE.Material): THREE.Group
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// ============ Data Visualization ============
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Single data point visualization (sphere, bar, cylinder, arc, text)
|
|
388
|
+
*/
|
|
389
|
+
export class Data {
|
|
390
|
+
constructor(name?: string)
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Create a sphere at a GPS coordinate
|
|
394
|
+
* @param coordinate - GPS position
|
|
395
|
+
* @param value - Size multiplier (default: 1)
|
|
396
|
+
* @param size - Base size (default: 2)
|
|
397
|
+
* @param yOffset - Vertical offset (default: 0)
|
|
398
|
+
* @param color - Color (default: 0xff6600)
|
|
399
|
+
* @param mat - Optional replacement material
|
|
400
|
+
*/
|
|
401
|
+
Sphere(coordinate: GPSCoordinate, value?: number, size?: number, yOffset?: number, color?: number, mat?: THREE.Material): THREE.Mesh
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Create a vertical bar (box) at a GPS coordinate
|
|
405
|
+
* @param coordinate - GPS position
|
|
406
|
+
* @param value - Height multiplier (default: 1)
|
|
407
|
+
* @param size - Base size (default: 0.5)
|
|
408
|
+
* @param yOffset - Vertical offset (default: 0)
|
|
409
|
+
* @param color - Color (default: 0xff6600)
|
|
410
|
+
* @param mat - Optional replacement material
|
|
411
|
+
*/
|
|
412
|
+
Bar(coordinate: GPSCoordinate, value?: number, size?: number, yOffset?: number, color?: number, mat?: THREE.Material): THREE.Mesh
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Create a cylinder at a GPS coordinate
|
|
416
|
+
*/
|
|
417
|
+
Cylinder(coordinate: GPSCoordinate, value?: number, size?: number, yOffset?: number, color?: number, mat?: THREE.Material): THREE.Mesh
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Create a semicircular arc between two GPS coordinates
|
|
421
|
+
* @param coorA - Start GPS position
|
|
422
|
+
* @param coorB - End GPS position
|
|
423
|
+
* @param height - Arc peak height (default: 5). When height equals half the distance between A and B, it forms a perfect semicircle
|
|
424
|
+
* @param yOffset - Vertical offset (default: 0)
|
|
425
|
+
* @param color - Color (default: 0xff6600)
|
|
426
|
+
* @param mat - Optional replacement material
|
|
427
|
+
*/
|
|
428
|
+
Arc(coorA: GPSCoordinate, coorB: GPSCoordinate, height?: number, yOffset?: number, color?: number, mat?: THREE.Material): THREE.Line
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Create 3D text at a GPS coordinate
|
|
432
|
+
* @param coordinate - GPS position
|
|
433
|
+
* @param text - Text content
|
|
434
|
+
* @param size - Font size (default: 30)
|
|
435
|
+
* @param color - Color (default: 0xff0000)
|
|
436
|
+
* @param thickness - Text depth/thickness (default: 0.1)
|
|
437
|
+
* @param fontface - Custom font JSON object
|
|
438
|
+
* @param mat - Optional replacement material
|
|
439
|
+
*/
|
|
440
|
+
Text(coordinate: GPSCoordinate, text: string, size?: number, color?: number, thickness?: number, fontface?: object, mat?: THREE.Material): THREE.Mesh
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Dataset visualization for arrays of data points (point cloud, heatmap)
|
|
445
|
+
*/
|
|
446
|
+
export class Datasets extends Data {
|
|
447
|
+
/**
|
|
448
|
+
* @param name - Dataset name
|
|
449
|
+
* @param data - Array of { location: GPSCoordinate, val: number }
|
|
450
|
+
*/
|
|
451
|
+
constructor(name: string, data: Array<{ location: GPSCoordinate; val: number }>)
|
|
452
|
+
|
|
453
|
+
/** Create a point cloud from the dataset */
|
|
454
|
+
PointCloud(): THREE.Group
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Create a heatmap from the dataset
|
|
458
|
+
* @param size - Canvas size (default: 60)
|
|
459
|
+
* @param radius - Highlight radius (default: 2.5)
|
|
460
|
+
*/
|
|
461
|
+
Heatmap(size?: number, radius?: number): THREE.Group
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// ============ Model ============
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* 3D model loader (GLTF)
|
|
468
|
+
*/
|
|
469
|
+
export class Model {
|
|
470
|
+
/**
|
|
471
|
+
* @param coordinate - World position { x, y, z }
|
|
472
|
+
*/
|
|
473
|
+
constructor(coordinate: WorldCoordinate)
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Load a GLTF/GLB model
|
|
477
|
+
* @param url - URL to the GLTF file
|
|
478
|
+
* @param name - Object name
|
|
479
|
+
* @param displayName - Display name
|
|
480
|
+
* @param scale - Uniform scale factor
|
|
481
|
+
* @returns Promise resolving to the loaded Object3D
|
|
482
|
+
*/
|
|
483
|
+
LoadGLTF(url: string, name: string, displayName?: string, scale?: number): Promise<THREE.Object3D>
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Attach other objects to the loaded model
|
|
487
|
+
* @param obj - Object or array of objects to attach
|
|
488
|
+
*/
|
|
489
|
+
Attach(obj: THREE.Object3D | THREE.Object3D[]): THREE.Object3D
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// ============ Shapes ============
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Basic 3D shape primitives
|
|
496
|
+
*/
|
|
497
|
+
export class Shapes {
|
|
498
|
+
/**
|
|
499
|
+
* @param name - Shape name (default: "shape")
|
|
500
|
+
* @param position - World position (default: {x:0, y:0, z:0})
|
|
501
|
+
*/
|
|
502
|
+
constructor(name?: string, position?: THREE.Vector3 | WorldCoordinate)
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Create a box
|
|
506
|
+
* @param size - Box size (default: 1)
|
|
507
|
+
* @param color - Color (default: 0x00ff00)
|
|
508
|
+
*/
|
|
509
|
+
Box(size?: number, color?: number): THREE.Mesh
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Create a sphere
|
|
513
|
+
* @param size - Sphere diameter (default: 1)
|
|
514
|
+
* @param color - Color (default: 0xff6600)
|
|
515
|
+
*/
|
|
516
|
+
Sphere(size?: number, color?: number): THREE.Mesh
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Create a cylinder
|
|
520
|
+
* @param size - Cylinder size (default: 1)
|
|
521
|
+
* @param color - Color (default: 0xff6600)
|
|
522
|
+
*/
|
|
523
|
+
Cylinder(size?: number, color?: number): THREE.Mesh
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
// ============ Animation ============
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Animation definition for objects
|
|
530
|
+
*/
|
|
531
|
+
export class Animation {
|
|
532
|
+
/** Current state: 0=stop, 1=playing, 2=paused, 99=infinite */
|
|
533
|
+
state: number
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* @param name - Animation name
|
|
537
|
+
* @param object - 3D object to animate
|
|
538
|
+
* @param type - Animation type identifier
|
|
539
|
+
* @param options - { startNow?: boolean, delay?: number, haveEnd?: boolean, repeat?: boolean }
|
|
540
|
+
*/
|
|
541
|
+
constructor(name: string, object: THREE.Object3D, type?: string, options?: {
|
|
542
|
+
startNow?: boolean
|
|
543
|
+
delay?: number
|
|
544
|
+
haveEnd?: boolean
|
|
545
|
+
repeat?: boolean
|
|
546
|
+
})
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Animate along a GPS path
|
|
550
|
+
* @param paths - Array of GPS coordinates (with optional altitude)
|
|
551
|
+
* @param duration - Animation duration in ms
|
|
552
|
+
*/
|
|
553
|
+
GPSPath(paths: GPSCoordinate[], duration: number): Animation
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Move object to a position
|
|
557
|
+
* @param endPosi - Target position or array of waypoints
|
|
558
|
+
* @param duration - Duration in ms
|
|
559
|
+
* @param options - { easing?: "linear" | "ease-out" }
|
|
560
|
+
*/
|
|
561
|
+
MoveTo(endPosi: THREE.Vector3 | WorldCoordinate | WorldCoordinate[], duration: number, options?: { easing?: string }): Animation
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Dash line animation
|
|
565
|
+
* @param distance - Total line length
|
|
566
|
+
*/
|
|
567
|
+
DashLine(distance: number): Animation
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Circular orbit animation
|
|
571
|
+
* @param radius - Orbit radius (default: 5)
|
|
572
|
+
* @param height - Orbit height (default: 5)
|
|
573
|
+
*/
|
|
574
|
+
Circular(radius?: number, height?: number): Animation
|
|
575
|
+
|
|
576
|
+
/** Play the animation */
|
|
577
|
+
Play(): void
|
|
578
|
+
/** Stop the animation */
|
|
579
|
+
Stop(): void
|
|
580
|
+
/** Pause the animation */
|
|
581
|
+
Pause(): void
|
|
582
|
+
/** Loop the animation infinitely */
|
|
583
|
+
Loop(): void
|
|
584
|
+
/** Destroy/cleanup the animation */
|
|
585
|
+
Destroy(): void
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Animation engine - manages and updates all registered animations
|
|
590
|
+
*/
|
|
591
|
+
export class AnimationEngine {
|
|
592
|
+
/**
|
|
593
|
+
* @param ins - CUBE.Space instance
|
|
594
|
+
*/
|
|
595
|
+
constructor(ins: Space)
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Register an animation to be managed by this engine
|
|
599
|
+
* @param animation - Animation instance to register
|
|
600
|
+
*/
|
|
601
|
+
Register(animation: Animation): void
|
|
602
|
+
|
|
603
|
+
/** Clear all animations */
|
|
604
|
+
Clear(): void
|
|
605
|
+
|
|
606
|
+
/** Update all animations (called automatically by Space.Runtime) */
|
|
607
|
+
Update(): void
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// ============ Shader ============
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* Shader engine for custom visual effects
|
|
614
|
+
*/
|
|
615
|
+
export class ShaderEngine {
|
|
616
|
+
constructor(ins: Space)
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Register a shader uniform for animation
|
|
620
|
+
* @param object - Object with ShaderMaterial
|
|
621
|
+
* @param type - "uniforms"
|
|
622
|
+
* @param node - Uniform name
|
|
623
|
+
* @param range - { max: number, step: number, min: number }
|
|
624
|
+
*/
|
|
625
|
+
Register(object: THREE.Mesh, type: string, node: string, range: { max: number; step: number; min: number }): void
|
|
626
|
+
|
|
627
|
+
/** Update all registered shaders */
|
|
628
|
+
Update(): void
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// ============ Coordinate ============
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Coordinate transformation between GPS (WGS84) and Three.js world positions
|
|
635
|
+
*/
|
|
636
|
+
export class Coordinate {
|
|
637
|
+
/** Computed world coordinate */
|
|
638
|
+
world: WorldCoordinate
|
|
639
|
+
/** GPS coordinate */
|
|
640
|
+
gps: GPSCoordinate
|
|
641
|
+
/** Tile coordinate */
|
|
642
|
+
tile: { x: number; y: number; centerOffset: { x: number; y: number } }
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* @param type - "GPS" or "World"
|
|
646
|
+
* @param coor - GPS coordinate { latitude, longitude, altitude? } or World coordinate { x, y, z }
|
|
647
|
+
*/
|
|
648
|
+
constructor(type: 'GPS' | 'World', coor: GPSCoordinate | WorldCoordinate)
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Convert GPS coordinate to Three.js world position (relative to center)
|
|
652
|
+
* @returns this (for chaining)
|
|
653
|
+
*/
|
|
654
|
+
ComputeWorldCoordinate(): Coordinate
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* Convert GPS coordinate to tile map coordinate
|
|
658
|
+
* @param zoom - Tile zoom level
|
|
659
|
+
* @returns this (for chaining)
|
|
660
|
+
*/
|
|
661
|
+
ComputeTileCoordinate(zoom: number): Coordinate
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Reverse tile coordinate back to GPS
|
|
665
|
+
* @param zoom - Tile zoom level
|
|
666
|
+
*/
|
|
667
|
+
ReverseTileToGPS(zoom: number): GPSCoordinate | undefined
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// ============ High-level API ============
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* High-level city API - downloads and renders city data from OpenStreetMap
|
|
674
|
+
*/
|
|
675
|
+
export class City {
|
|
676
|
+
/**
|
|
677
|
+
* @param range - City range in meters (default: 1000)
|
|
678
|
+
* @param options - { API_MAP?: string, API_TERRAIN?: string }
|
|
679
|
+
*/
|
|
680
|
+
constructor(range?: number, options?: { API_MAP?: string; API_TERRAIN?: string })
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Download and render buildings
|
|
684
|
+
* @param name - Layer name (default: "building")
|
|
685
|
+
* @param options - Building options (default: { merge: true, color: 0xE5E5E5 })
|
|
686
|
+
* @param material - Optional replacement material
|
|
687
|
+
*/
|
|
688
|
+
Buildings(name?: string, options?: BuildingOptions, material?: THREE.Material): Promise<THREE.Group>
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Download and render roads
|
|
692
|
+
* @param name - Layer name (default: "roads")
|
|
693
|
+
* @param options - Road options
|
|
694
|
+
* @param material - Optional replacement material
|
|
695
|
+
*/
|
|
696
|
+
Roads(name?: string, options?: RoadOptions, material?: THREE.Material): Promise<THREE.Group>
|
|
697
|
+
}
|