@reearth/core 0.0.7-alpha.0 → 0.0.7-alpha.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/dist/core.js +8865 -8890
- package/dist/core.umd.cjs +74 -74
- package/dist/index.d.ts +216 -212
- package/package.json +1 -1
- package/src/Map/ClusteredLayers/index.tsx +2 -2
- package/src/Map/Layer/index.tsx +3 -3
- package/src/Map/Layers/index.tsx +2 -2
- package/src/Map/Sketch/hooks.ts +46 -66
- package/src/Map/Sketch/index.tsx +2 -24
- package/src/Map/Sketch/preset.ts +2 -0
- package/src/Map/Sketch/types.ts +31 -0
- package/src/Map/hooks.ts +0 -4
- package/src/Map/index.tsx +8 -5
- package/src/Map/ref.ts +3 -7
- package/src/Map/types/index.ts +34 -216
- package/src/Map/types/viewerProperty.ts +215 -0
- package/src/Map/useTimelineManager.ts +5 -3
- package/src/Map/utils.ts +1 -43
- package/src/Visualizer/coreContext.tsx +1 -8
- package/src/Visualizer/hooks.ts +6 -75
- package/src/Visualizer/index.stories.tsx +4 -48
- package/src/Visualizer/index.tsx +8 -6
- package/src/Visualizer/useCoreAPI.ts +30 -0
- package/src/engines/Cesium/Feature/Ellipse/index.stories.tsx +1 -1
- package/src/engines/Cesium/Feature/Frustum/index.stories.tsx +1 -1
- package/src/engines/Cesium/Feature/Model/index.stories.tsx +1 -1
- package/src/engines/Cesium/Feature/Model/index.tsx +10 -9
- package/src/engines/Cesium/Feature/Polygon/index.stories.tsx +8 -6
- package/src/engines/Cesium/Feature/Raster/index.stories.tsx +2 -2
- package/src/engines/Cesium/Feature/Resource/index.stories.tsx +1 -1
- package/src/engines/Cesium/Feature/Tileset/hooks.ts +12 -11
- package/src/engines/Cesium/Feature/Tileset/index.stories.tsx +1 -1
- package/src/engines/Cesium/Feature/Tileset/index.tsx +4 -4
- package/src/engines/Cesium/Feature/index.tsx +5 -4
- package/src/engines/Cesium/Feature/utils.tsx +2 -2
- package/src/engines/Cesium/core/Globe.tsx +36 -68
- package/src/engines/Cesium/core/Imagery.test.ts +9 -9
- package/src/engines/Cesium/core/Imagery.tsx +17 -19
- package/src/engines/Cesium/core/Indicator/Indicator.tsx +8 -8
- package/src/engines/Cesium/hooks/useCamera.ts +135 -0
- package/src/engines/Cesium/{cameraLimiter.ts → hooks/useCameraLimiter.ts} +22 -45
- package/src/engines/Cesium/{useEngineRef.test.tsx → hooks/useEngineRef.test.tsx} +38 -34
- package/src/engines/Cesium/{useEngineRef.ts → hooks/useEngineRef.ts} +43 -41
- package/src/engines/Cesium/hooks/useExplicitRender.ts +65 -0
- package/src/engines/Cesium/hooks/useLayerDragDrop.ts +77 -0
- package/src/engines/Cesium/{VertexTerrainElevationMaterial.ts → hooks/useOverrideGlobeShader/VertexTerrainElevationMaterial.ts} +3 -2
- package/src/engines/Cesium/{useOverrideGlobeShader.ts → hooks/useOverrideGlobeShader/useOverrideGlobeShader.ts} +19 -16
- package/src/engines/Cesium/hooks/useViewerProperty.ts +90 -0
- package/src/engines/Cesium/hooks.ts +129 -365
- package/src/engines/Cesium/index.stories.tsx +1 -1
- package/src/engines/Cesium/index.tsx +60 -62
- package/src/engines/index.ts +1 -1
- package/src/mantle/compat/types.ts +7 -7
- /package/src/engines/Cesium/{JapanSeaLevelEllipsoid.ts → hooks/useOverrideGlobeShader/JapanSeaLevelEllipsoid.ts} +0 -0
- /package/src/engines/Cesium/{vertexTerrainElevationMaterial.glsl → hooks/useOverrideGlobeShader/vertexTerrainElevationMaterial.glsl} +0 -0
package/src/Map/types/index.ts
CHANGED
|
@@ -22,7 +22,6 @@ import type {
|
|
|
22
22
|
Feature,
|
|
23
23
|
ComputedFeature,
|
|
24
24
|
CameraPosition,
|
|
25
|
-
LUT,
|
|
26
25
|
} from "../../mantle";
|
|
27
26
|
import type {
|
|
28
27
|
CameraOptions,
|
|
@@ -39,10 +38,11 @@ import type {
|
|
|
39
38
|
LayerSelectionReason,
|
|
40
39
|
Ref as LayersRef,
|
|
41
40
|
} from "../Layers";
|
|
42
|
-
import { SketchComponentType } from "../Sketch";
|
|
43
|
-
import { SketchAppearance, SketchType } from "../Sketch/types";
|
|
41
|
+
import { SketchType, SketchOptions, SketchComponentType } from "../Sketch/types";
|
|
44
42
|
import type { TimelineManagerRef } from "../useTimelineManager";
|
|
45
43
|
|
|
44
|
+
import type { SceneMode, ViewerProperty } from "./viewerProperty";
|
|
45
|
+
|
|
46
46
|
export type {
|
|
47
47
|
FeatureComponentProps,
|
|
48
48
|
FeatureComponentType,
|
|
@@ -72,6 +72,7 @@ export type {
|
|
|
72
72
|
ValueType,
|
|
73
73
|
} from "../../mantle";
|
|
74
74
|
export * from "./event";
|
|
75
|
+
export * from "./viewerProperty";
|
|
75
76
|
|
|
76
77
|
export type EngineRef = {
|
|
77
78
|
name: string;
|
|
@@ -87,7 +88,7 @@ export type EngineRef = {
|
|
|
87
88
|
getLocationFromScreen: (x: number, y: number, withTerrain?: boolean) => LatLngHeight | undefined;
|
|
88
89
|
sampleTerrainHeight: (lng: number, lat: number) => Promise<number | undefined>;
|
|
89
90
|
computeGlobeHeight: (lng: number, lat: number, height?: number) => number | undefined;
|
|
90
|
-
getGlobeHeight: () =>
|
|
91
|
+
getGlobeHeight: () => number | undefined;
|
|
91
92
|
toXYZ: (
|
|
92
93
|
lng: number,
|
|
93
94
|
lat: number,
|
|
@@ -202,7 +203,8 @@ export type EngineProps = {
|
|
|
202
203
|
style?: CSSProperties;
|
|
203
204
|
isEditable?: boolean;
|
|
204
205
|
isBuilt?: boolean;
|
|
205
|
-
property?:
|
|
206
|
+
property?: ViewerProperty;
|
|
207
|
+
time?: string | Date;
|
|
206
208
|
camera?: Camera;
|
|
207
209
|
cameraForceHorizontalRoll?: boolean;
|
|
208
210
|
small?: boolean;
|
|
@@ -297,18 +299,18 @@ export type MouseEventCallback = (props: MouseEventProps) => void;
|
|
|
297
299
|
export type MouseWheelEventCallback = (props: MouseEventProps) => void;
|
|
298
300
|
export type MouseEventTypes =
|
|
299
301
|
| "click"
|
|
300
|
-
| "
|
|
301
|
-
| "
|
|
302
|
-
| "
|
|
303
|
-
| "
|
|
304
|
-
| "
|
|
305
|
-
| "
|
|
306
|
-
| "
|
|
307
|
-
| "
|
|
308
|
-
| "
|
|
309
|
-
| "
|
|
310
|
-
| "
|
|
311
|
-
| "
|
|
302
|
+
| "doubleClick"
|
|
303
|
+
| "mouseDown"
|
|
304
|
+
| "mouseUp"
|
|
305
|
+
| "rightClick"
|
|
306
|
+
| "rightDown"
|
|
307
|
+
| "rightUp"
|
|
308
|
+
| "middleClick"
|
|
309
|
+
| "middleDown"
|
|
310
|
+
| "middleUp"
|
|
311
|
+
| "mouseMove"
|
|
312
|
+
| "mouseEnter"
|
|
313
|
+
| "mouseLeave"
|
|
312
314
|
| "wheel";
|
|
313
315
|
|
|
314
316
|
export type MouseEvents = {
|
|
@@ -319,18 +321,18 @@ export type MouseEvents = {
|
|
|
319
321
|
|
|
320
322
|
export type MouseEventHandles = {
|
|
321
323
|
onClick: (fn: MouseEvents["click"]) => void;
|
|
322
|
-
onDoubleClick: (fn: MouseEvents["
|
|
323
|
-
onMouseDown: (fn: MouseEvents["
|
|
324
|
-
onMouseUp: (fn: MouseEvents["
|
|
325
|
-
onRightClick: (fn: MouseEvents["
|
|
326
|
-
onRightDown: (fn: MouseEvents["
|
|
327
|
-
onRightUp: (fn: MouseEvents["
|
|
328
|
-
onMiddleClick: (fn: MouseEvents["
|
|
329
|
-
onMiddleDown: (fn: MouseEvents["
|
|
330
|
-
onMiddleUp: (fn: MouseEvents["
|
|
331
|
-
onMouseMove: (fn: MouseEvents["
|
|
332
|
-
onMouseEnter: (fn: MouseEvents["
|
|
333
|
-
onMouseLeave: (fn: MouseEvents["
|
|
324
|
+
onDoubleClick: (fn: MouseEvents["doubleClick"]) => void;
|
|
325
|
+
onMouseDown: (fn: MouseEvents["mouseDown"]) => void;
|
|
326
|
+
onMouseUp: (fn: MouseEvents["mouseUp"]) => void;
|
|
327
|
+
onRightClick: (fn: MouseEvents["rightClick"]) => void;
|
|
328
|
+
onRightDown: (fn: MouseEvents["rightDown"]) => void;
|
|
329
|
+
onRightUp: (fn: MouseEvents["rightUp"]) => void;
|
|
330
|
+
onMiddleClick: (fn: MouseEvents["middleClick"]) => void;
|
|
331
|
+
onMiddleDown: (fn: MouseEvents["middleDown"]) => void;
|
|
332
|
+
onMiddleUp: (fn: MouseEvents["middleUp"]) => void;
|
|
333
|
+
onMouseMove: (fn: MouseEvents["mouseMove"]) => void;
|
|
334
|
+
onMouseEnter: (fn: MouseEvents["mouseEnter"]) => void;
|
|
335
|
+
onMouseLeave: (fn: MouseEvents["mouseLeave"]) => void;
|
|
334
336
|
onWheel: (fn: MouseEvents["wheel"]) => void;
|
|
335
337
|
};
|
|
336
338
|
|
|
@@ -339,186 +341,6 @@ export type MouseEventCallbacks = { [key in keyof MouseEvents]: MouseEvents[key]
|
|
|
339
341
|
export type TickEvent = (cb: TickEventCallback) => void;
|
|
340
342
|
export type TickEventCallback = (current: Date, clock: { start: Date; stop: Date }) => void;
|
|
341
343
|
|
|
342
|
-
export type SceneMode = "3d" | "2d" | "columbus";
|
|
343
|
-
export type IndicatorTypes = "default" | "crosshair" | "custom";
|
|
344
|
-
|
|
345
|
-
export type TerrainProperty = {
|
|
346
|
-
terrain?: boolean;
|
|
347
|
-
terrainType?: "cesium" | "arcgis" | "cesiumion"; // default: cesium
|
|
348
|
-
terrainExaggeration?: number; // default: 1
|
|
349
|
-
terrainExaggerationRelativeHeight?: number; // default: 0
|
|
350
|
-
depthTestAgainstTerrain?: boolean;
|
|
351
|
-
terrainCesiumIonAsset?: string;
|
|
352
|
-
terrainCesiumIonAccessToken?: string;
|
|
353
|
-
terrainCesiumIonUrl?: string;
|
|
354
|
-
terrainUrl?: string;
|
|
355
|
-
terrainNormal?: boolean;
|
|
356
|
-
// TODO: Add encode option
|
|
357
|
-
// Need to specify a tile from `tiles` option with `heatmap` option.
|
|
358
|
-
heatmapType?: "custom"; // TODO: Support Cesium's terrain heatmap as built-in: https://sandcastle.cesium.com/?src=Globe%20Materials.html
|
|
359
|
-
heatmapColorLUT?: LUT;
|
|
360
|
-
heatmapMinHeight?: number;
|
|
361
|
-
heatmapMaxHeight?: number;
|
|
362
|
-
heatmapLogarithmic?: boolean;
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
export type SceneProperty = {
|
|
366
|
-
main?: {
|
|
367
|
-
sceneMode?: SceneMode; // default: scene3d
|
|
368
|
-
ion?: string;
|
|
369
|
-
vr?: boolean;
|
|
370
|
-
};
|
|
371
|
-
tiles?: {
|
|
372
|
-
id: string;
|
|
373
|
-
tile_type?: string;
|
|
374
|
-
tile_url?: string;
|
|
375
|
-
tile_zoomLevel?: number[];
|
|
376
|
-
tile_zoomLevelForURL?: number[];
|
|
377
|
-
tile_opacity?: number;
|
|
378
|
-
heatmap?: boolean;
|
|
379
|
-
}[];
|
|
380
|
-
tileLabels?: {
|
|
381
|
-
id: string;
|
|
382
|
-
labelType: "japan_gsi_optimal_bvmap"; // | "other_map"
|
|
383
|
-
style: Record<string, any>; // Function isn't allowed
|
|
384
|
-
}[];
|
|
385
|
-
terrain?: {
|
|
386
|
-
terrain?: boolean;
|
|
387
|
-
terrainType?: "cesium" | "arcgis" | "cesiumion"; // default: cesium
|
|
388
|
-
terrainCesiumIonAsset?: string;
|
|
389
|
-
terrainCesiumIonAccessToken?: string;
|
|
390
|
-
terrainCesiumIonUrl?: string;
|
|
391
|
-
terrainExaggeration?: number; // default: 1
|
|
392
|
-
terrainExaggerationRelativeHeight?: number; // default: 0
|
|
393
|
-
depthTestAgainstTerrain?: boolean;
|
|
394
|
-
};
|
|
395
|
-
globeLighting?: {
|
|
396
|
-
globeLighting?: boolean;
|
|
397
|
-
};
|
|
398
|
-
globeShadow?: {
|
|
399
|
-
globeShadow?: boolean;
|
|
400
|
-
};
|
|
401
|
-
globeAtmosphere?: {
|
|
402
|
-
globeAtmosphere?: boolean;
|
|
403
|
-
globeAtmosphereIntensity?: number; // default: 10
|
|
404
|
-
};
|
|
405
|
-
skyBox?: {
|
|
406
|
-
skyBox?: boolean;
|
|
407
|
-
};
|
|
408
|
-
sun?: {
|
|
409
|
-
sun?: boolean;
|
|
410
|
-
};
|
|
411
|
-
moon?: {
|
|
412
|
-
moon?: boolean;
|
|
413
|
-
};
|
|
414
|
-
skyAtmosphere?: {
|
|
415
|
-
skyAtmosphere?: boolean;
|
|
416
|
-
skyAtmosphereIntensity?: number; // default: 50
|
|
417
|
-
};
|
|
418
|
-
camera?: {
|
|
419
|
-
camera?: Camera;
|
|
420
|
-
allowEnterGround?: boolean;
|
|
421
|
-
fov?: number;
|
|
422
|
-
};
|
|
423
|
-
render?: { showWireframe?: boolean };
|
|
424
|
-
} & LegacySceneProperty;
|
|
425
|
-
|
|
426
|
-
type LegacySceneProperty = {
|
|
427
|
-
default?: {
|
|
428
|
-
camera?: Camera;
|
|
429
|
-
allowEnterGround?: boolean;
|
|
430
|
-
skybox?: boolean;
|
|
431
|
-
bgcolor?: string;
|
|
432
|
-
ion?: string;
|
|
433
|
-
sceneMode?: SceneMode; // default: scene3d
|
|
434
|
-
vr?: boolean;
|
|
435
|
-
} & TerrainProperty; // compat
|
|
436
|
-
cameraLimiter?: {
|
|
437
|
-
cameraLimitterEnabled?: boolean;
|
|
438
|
-
cameraLimitterShowHelper?: boolean;
|
|
439
|
-
cameraLimitterTargetArea?: Camera;
|
|
440
|
-
cameraLimitterTargetWidth?: number;
|
|
441
|
-
cameraLimitterTargetLength?: number;
|
|
442
|
-
};
|
|
443
|
-
indicator?: {
|
|
444
|
-
indicator_type: IndicatorTypes;
|
|
445
|
-
indicator_image?: string;
|
|
446
|
-
indicator_image_scale?: number;
|
|
447
|
-
};
|
|
448
|
-
tiles?: {
|
|
449
|
-
id: string;
|
|
450
|
-
tile_type?: string;
|
|
451
|
-
tile_url?: string;
|
|
452
|
-
tile_zoomLevel?: number[];
|
|
453
|
-
tile_opacity?: number;
|
|
454
|
-
}[];
|
|
455
|
-
terrain?: TerrainProperty;
|
|
456
|
-
atmosphere?: {
|
|
457
|
-
enable_sun?: boolean;
|
|
458
|
-
enableMoon?: boolean;
|
|
459
|
-
enable_lighting?: boolean;
|
|
460
|
-
ground_atmosphere?: boolean;
|
|
461
|
-
sky_atmosphere?: boolean;
|
|
462
|
-
shadows?: boolean;
|
|
463
|
-
shadowResolution?: 1024 | 2048 | 4096;
|
|
464
|
-
softShadow?: boolean;
|
|
465
|
-
shadowDarkness?: number;
|
|
466
|
-
shadowMaximumDistance?: number;
|
|
467
|
-
fog?: boolean;
|
|
468
|
-
fog_density?: number;
|
|
469
|
-
hue_shift?: number;
|
|
470
|
-
brightness_shift?: number;
|
|
471
|
-
surturation_shift?: number;
|
|
472
|
-
skyboxBrightnessShift?: number;
|
|
473
|
-
skyboxSurturationShift?: number;
|
|
474
|
-
globeShadowDarkness?: number;
|
|
475
|
-
globeImageBasedLighting?: boolean;
|
|
476
|
-
globeBaseColor?: string;
|
|
477
|
-
};
|
|
478
|
-
timeline?: {
|
|
479
|
-
animation?: boolean;
|
|
480
|
-
visible?: boolean;
|
|
481
|
-
current?: string;
|
|
482
|
-
start?: string;
|
|
483
|
-
stop?: string;
|
|
484
|
-
stepType?: "rate" | "fixed";
|
|
485
|
-
multiplier?: number;
|
|
486
|
-
step?: number;
|
|
487
|
-
rangeType?: "unbounded" | "clamped" | "bounced";
|
|
488
|
-
};
|
|
489
|
-
googleAnalytics?: {
|
|
490
|
-
enableGA?: boolean;
|
|
491
|
-
trackingId?: string;
|
|
492
|
-
};
|
|
493
|
-
theme?: {
|
|
494
|
-
themeType?: "light" | "dark" | "forest" | "custom";
|
|
495
|
-
themeTextColor?: string;
|
|
496
|
-
themeSelectColor?: string;
|
|
497
|
-
themeBackgroundColor?: string;
|
|
498
|
-
};
|
|
499
|
-
ambientOcclusion?: {
|
|
500
|
-
enabled?: boolean;
|
|
501
|
-
quality?: "low" | "medium" | "high" | "extreme";
|
|
502
|
-
intensity?: number;
|
|
503
|
-
ambientOcclusionOnly?: boolean;
|
|
504
|
-
};
|
|
505
|
-
light?: {
|
|
506
|
-
lightType?: "sunLight" | "directionalLight";
|
|
507
|
-
lightDirectionX?: number;
|
|
508
|
-
lightDirectionY?: number;
|
|
509
|
-
lightDirectionZ?: number;
|
|
510
|
-
lightColor?: string;
|
|
511
|
-
lightIntensity?: number;
|
|
512
|
-
specularEnvironmentMaps?: string;
|
|
513
|
-
sphericalHarmonicCoefficients?: [x: number, y: number, z: number][];
|
|
514
|
-
imageBasedLightIntensity?: number;
|
|
515
|
-
};
|
|
516
|
-
render?: {
|
|
517
|
-
antialias?: "low" | "medium" | "high" | "extreme";
|
|
518
|
-
debugFramePerSecond?: boolean;
|
|
519
|
-
};
|
|
520
|
-
};
|
|
521
|
-
|
|
522
344
|
export type EngineComponent = ForwardRefExoticComponent<
|
|
523
345
|
PropsWithoutRef<EngineProps> & RefAttributes<EngineRef>
|
|
524
346
|
>;
|
|
@@ -534,12 +356,8 @@ export type Engine = {
|
|
|
534
356
|
export type RequestingRenderMode = -1 | 0 | 1; // -1: force render on every postUpdate, 0: no request to render, 1: request one frame
|
|
535
357
|
|
|
536
358
|
export type SketchRef = {
|
|
359
|
+
getType: () => SketchType | undefined;
|
|
537
360
|
setType: (type: SketchType | undefined, from?: "editor" | "plugin") => void;
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
disableShadow: (disable: boolean) => void;
|
|
541
|
-
enableRelativeHeight: (enable: boolean) => void;
|
|
542
|
-
createDataOnly: (dataOnly: boolean) => void;
|
|
543
|
-
allowRightClickToAbort: (allow: boolean) => void;
|
|
544
|
-
allowAutoResetInteractionMode: (allow: boolean) => void;
|
|
361
|
+
getOptions: () => SketchOptions;
|
|
362
|
+
overrideOptions: (options: SketchOptions) => void;
|
|
545
363
|
};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ViewerProperty Interface
|
|
3
|
+
* ------------------------
|
|
4
|
+
* The ViewerProperty interface defines a collection of sub-properties that represent different aspects of the viewer component.
|
|
5
|
+
* Each sub-property encapsulates specific settings and configurations related to the viewer's behavior and appearance.
|
|
6
|
+
|
|
7
|
+
* GlobeProperty: Settings related to the globe visualization, such as base color, lighting, and atmosphere.
|
|
8
|
+
* TerrainProperty: Configuration options for terrain visualization, including terrain type, height map, and normal mapping.
|
|
9
|
+
* SceneProperty: Scene-specific settings, such as background color, scene mode, vertical exaggeration, and lighting.
|
|
10
|
+
* TilesProperty: Properties for managing tile layers, including URLs, opacity, zoom levels, and heatmap settings.
|
|
11
|
+
* TileLabelProperty: Properties for managing tile labels, such as label type and style.
|
|
12
|
+
* SkyProperty: Settings for sky visualization, including skybox, sun, moon, fog, and sky atmosphere.
|
|
13
|
+
* CameraProperty: Camera-related settings, such as camera position, limiter, and ground entry.
|
|
14
|
+
* RenderProperty: Rendering settings, such as antialiasing and ambient occlusion.
|
|
15
|
+
* IndicatorProperty: Properties for customizing the viewer's indicator, such as type and image.
|
|
16
|
+
* AssetsProperty: Asset-related settings, such as access tokens and URLs for external assets.
|
|
17
|
+
* DebugProperty: Debugging options, such as wireframe display and FPS counter.
|
|
18
|
+
|
|
19
|
+
* Guidelines for Adding New Properties
|
|
20
|
+
* ------------------------------------
|
|
21
|
+
* When adding new properties to the ViewerProperty interface, follow these steps to ensure consistency and maintainability:
|
|
22
|
+
* 1. Determine the Appropriate Category: Identify the aspect of the viewer your new property will affect and choose the most relevant existing sub-property type (e.g., GlobeProperty, TerrainProperty, SceneProperty, etc.). If your property does not fit into an existing category, consider creating a new sub-property type.
|
|
23
|
+
* 2. Define the New Property: Add your new property to the chosen sub-property type. Ensure that the property name is descriptive and the type is correctly specified. If your property requires complex structures, define new types as needed.
|
|
24
|
+
* 3. Maintain Optional Properties: To keep the interface flexible, add new properties as optional (?) unless they are strictly required.
|
|
25
|
+
* 4. Follow Naming Rules:
|
|
26
|
+
* - Use CamelCase for property names.
|
|
27
|
+
* - Keep property names descriptive but concise.
|
|
28
|
+
* - Maintain consistency with existing naming patterns.
|
|
29
|
+
* - Avoid abbreviations unless widely understood and standard.
|
|
30
|
+
* 5. Document the Property: Add comments or documentation to describe the purpose and usage of the new property. This will help other developers understand its function and how to use it.
|
|
31
|
+
* 6. Update Usage Examples: If applicable, update any example configurations or documentation to include the new property, demonstrating how it should be used.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
import type { LUT, Camera } from "../../mantle";
|
|
35
|
+
|
|
36
|
+
export type SceneMode = "3d" | "2d" | "columbus";
|
|
37
|
+
|
|
38
|
+
export type ViewerProperty = {
|
|
39
|
+
globe?: GlobeProperty;
|
|
40
|
+
terrain?: TerrainProperty;
|
|
41
|
+
scene?: SceneProperty;
|
|
42
|
+
tiles?: TileProperty[];
|
|
43
|
+
tileLabels?: TileLabelProperty[];
|
|
44
|
+
sky?: SkyProperty;
|
|
45
|
+
camera?: CameraProperty;
|
|
46
|
+
render?: RenderPeropty;
|
|
47
|
+
assets?: AssetsProperty; // anything related to specific assets and its access tokens
|
|
48
|
+
debug?: DebugProperty;
|
|
49
|
+
indicator?: IndicatorProperty; // consider remove this if not needed in the future
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type GlobeProperty = {
|
|
53
|
+
baseColor?: string;
|
|
54
|
+
enableLighting?: boolean;
|
|
55
|
+
atmosphere?: GlobeAtmosphereProperty;
|
|
56
|
+
depthTestAgainstTerrain?: boolean;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type GlobeAtmosphereProperty = {
|
|
60
|
+
enabled?: boolean;
|
|
61
|
+
lightIntensity?: number;
|
|
62
|
+
brightnessShift?: number;
|
|
63
|
+
hueShift?: number;
|
|
64
|
+
saturationShift?: number;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type TerrainProperty = {
|
|
68
|
+
enabled?: boolean;
|
|
69
|
+
type?: "cesium" | "arcgis" | "cesiumion";
|
|
70
|
+
url?: string;
|
|
71
|
+
normal?: boolean;
|
|
72
|
+
elevationHeatMap?: ElevationHeatMapProperty;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export type ElevationHeatMapProperty = {
|
|
76
|
+
type?: "custom";
|
|
77
|
+
colorLUT?: LUT;
|
|
78
|
+
minHeight?: number;
|
|
79
|
+
maxHeight?: number;
|
|
80
|
+
logarithmic?: boolean;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type SceneProperty = {
|
|
84
|
+
backgroundColor?: string;
|
|
85
|
+
mode?: SceneMode;
|
|
86
|
+
verticalExaggeration?: number;
|
|
87
|
+
verticalExaggerationRelativeHeight?: number;
|
|
88
|
+
vr?: boolean;
|
|
89
|
+
light?: LightProperty;
|
|
90
|
+
shadow?: ShadowProperty;
|
|
91
|
+
imageBasedLighting?: ImageBasedLighting;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export type LightProperty = {
|
|
95
|
+
type?: "sunLight" | "directionalLight";
|
|
96
|
+
direction?: [x: number, y: number, z: number];
|
|
97
|
+
color?: string;
|
|
98
|
+
intensity?: number;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type ShadowProperty = {
|
|
102
|
+
enabled?: boolean;
|
|
103
|
+
darkness?: number;
|
|
104
|
+
shadowMap?: ShadowMapProperty;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export type ShadowMapProperty = {
|
|
108
|
+
size?: 1024 | 2048 | 4096;
|
|
109
|
+
softShadows?: boolean;
|
|
110
|
+
darkness?: number;
|
|
111
|
+
maximumDistance?: number;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export type ImageBasedLighting = {
|
|
115
|
+
enabled?: boolean;
|
|
116
|
+
intensity?: number;
|
|
117
|
+
specularEnvironmentMaps?: string;
|
|
118
|
+
sphericalHarmonicCoefficients?: [number, number, number][];
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export type TileProperty = {
|
|
122
|
+
id: string;
|
|
123
|
+
type?: string;
|
|
124
|
+
url?: string;
|
|
125
|
+
opacity?: number;
|
|
126
|
+
zoomLevel?: number[];
|
|
127
|
+
zoomLevelForURL?: number[];
|
|
128
|
+
heatmap?: boolean;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export type TileLabelProperty = {
|
|
132
|
+
id: string;
|
|
133
|
+
labelType: "japan_gsi_optimal_bvmap";
|
|
134
|
+
style: Record<string, any>;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export type SkyProperty = {
|
|
138
|
+
skyBox?: SkyBoxProperty;
|
|
139
|
+
sun?: SunProperty;
|
|
140
|
+
moon?: MoonProperty;
|
|
141
|
+
fog?: FogProperty;
|
|
142
|
+
skyAtmosphere?: SkyAtmosphereProperty;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export type SkyBoxProperty = {
|
|
146
|
+
show?: boolean;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export type SunProperty = {
|
|
150
|
+
show?: boolean;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export type MoonProperty = {
|
|
154
|
+
show?: boolean;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export type FogProperty = {
|
|
158
|
+
enabled?: boolean;
|
|
159
|
+
density?: number;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export type SkyAtmosphereProperty = {
|
|
163
|
+
show?: boolean;
|
|
164
|
+
lightIntensity?: number;
|
|
165
|
+
saturationShift?: number;
|
|
166
|
+
brightnessShift?: number;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export type CameraProperty = {
|
|
170
|
+
allowEnterGround?: boolean;
|
|
171
|
+
limiter?: CameraLimiterProperty;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export type CameraLimiterProperty = {
|
|
175
|
+
enabled?: boolean;
|
|
176
|
+
targetArea?: Camera;
|
|
177
|
+
targetWidth?: number;
|
|
178
|
+
targetLength?: number;
|
|
179
|
+
showHelper?: boolean;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export type RenderPeropty = {
|
|
183
|
+
antialias?: "low" | "medium" | "high" | "extreme";
|
|
184
|
+
ambientOcclusion?: AmbientOcclusionProperty;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export type AmbientOcclusionProperty = {
|
|
188
|
+
enabled?: boolean;
|
|
189
|
+
quality?: "low" | "medium" | "high" | "extreme";
|
|
190
|
+
intensity?: number;
|
|
191
|
+
ambientOcclusionOnly?: boolean;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export type IndicatorProperty = {
|
|
195
|
+
type?: "default" | "crosshair" | "custom";
|
|
196
|
+
image?: string;
|
|
197
|
+
imageScale?: number;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export type AssetsProperty = {
|
|
201
|
+
cesium?: AssetsCesiumProperty;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export type AssetsCesiumProperty = {
|
|
205
|
+
terrain?: {
|
|
206
|
+
ionAccessToken?: string;
|
|
207
|
+
ionAsset?: string;
|
|
208
|
+
ionUrl?: string;
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
export type DebugProperty = {
|
|
213
|
+
showGlobeWireframe?: boolean;
|
|
214
|
+
showFramesPerSecond?: boolean;
|
|
215
|
+
};
|
|
@@ -62,12 +62,12 @@ export type TimelineCommit = (PlayCommand | PauseCommand | SetTimeCommand | SetO
|
|
|
62
62
|
|
|
63
63
|
export type TimelineCommitter = {
|
|
64
64
|
source:
|
|
65
|
-
| "overrideSceneProperty"
|
|
66
65
|
| "widgetContext"
|
|
67
66
|
| "pluginAPI"
|
|
68
67
|
| "featureResource"
|
|
69
68
|
| "storyTimelineBlock"
|
|
70
|
-
| "storyPage"
|
|
69
|
+
| "storyPage"
|
|
70
|
+
| "initialize";
|
|
71
71
|
id?: string;
|
|
72
72
|
};
|
|
73
73
|
|
|
@@ -193,7 +193,9 @@ export default ({ init, engineRef, timelineManagerRef }: Props) => {
|
|
|
193
193
|
onCommit,
|
|
194
194
|
offCommit,
|
|
195
195
|
handleTick,
|
|
196
|
-
tick
|
|
196
|
+
get tick() {
|
|
197
|
+
return engineRef?.current?.tick;
|
|
198
|
+
},
|
|
197
199
|
};
|
|
198
200
|
}, [
|
|
199
201
|
options,
|
package/src/Map/utils.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type RefObject, useCallback, useRef, useState, useMemo } from "react";
|
|
1
|
+
import { type RefObject, useCallback, useRef } from "react";
|
|
3
2
|
|
|
4
3
|
export function useGet<T>(value: T): () => T {
|
|
5
4
|
const ref = useRef<T>(value);
|
|
@@ -15,47 +14,6 @@ export function wrapRef<T>(ref: RefObject<T>, keys: FunctionKeys<T>): WrappedRef
|
|
|
15
14
|
) as WrappedRef<T>;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
export function mergeProperty(a: any, b: any) {
|
|
19
|
-
const a2 = cloneDeep(a);
|
|
20
|
-
return mergeWith(
|
|
21
|
-
a2,
|
|
22
|
-
b,
|
|
23
|
-
(
|
|
24
|
-
s: any,
|
|
25
|
-
v: any,
|
|
26
|
-
_k: string | number | symbol,
|
|
27
|
-
_obj: any,
|
|
28
|
-
_src: any,
|
|
29
|
-
stack: { size: number },
|
|
30
|
-
) => (stack.size > 0 || Array.isArray(v) ? v ?? s : undefined),
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function useOverriddenProperty<T extends {}>(
|
|
35
|
-
property: T | undefined,
|
|
36
|
-
): [T, (pluginId: string, property: T) => void] {
|
|
37
|
-
const [overriddenProperties, setOverrideProperty] = useState<{
|
|
38
|
-
[pluginId: string]: any;
|
|
39
|
-
}>({});
|
|
40
|
-
const { overriddenPropertyCommon, overriddenProperty } = useMemo(() => {
|
|
41
|
-
const { "": overriddenPropertyCommon, ...overriddenProperty } = overriddenProperties;
|
|
42
|
-
return { overriddenPropertyCommon, overriddenProperty };
|
|
43
|
-
}, [overriddenProperties]);
|
|
44
|
-
|
|
45
|
-
const overrideProperty = useCallback((pluginId: string, property: any) => {
|
|
46
|
-
setOverrideProperty(p => (property ? { ...p, [pluginId || ""]: property } : omit(p, pluginId)));
|
|
47
|
-
}, []);
|
|
48
|
-
|
|
49
|
-
const mergedProperty = useMemo(() => {
|
|
50
|
-
return [overriddenPropertyCommon, ...Object.values(overriddenProperty)].reduce(
|
|
51
|
-
(p, v) => mergeProperty(p, v),
|
|
52
|
-
property,
|
|
53
|
-
);
|
|
54
|
-
}, [property, overriddenPropertyCommon, overriddenProperty]);
|
|
55
|
-
|
|
56
|
-
return [mergedProperty, overrideProperty];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
17
|
export type FunctionKeys<T> = {
|
|
60
18
|
[P in keyof T as T[P] extends (...args: any[]) => any ? P : never]: 1;
|
|
61
19
|
};
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { createContext } from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
LayerEditEvent,
|
|
5
|
-
LayerSelectionReason,
|
|
6
|
-
LayerVisibilityEvent,
|
|
7
|
-
SceneProperty,
|
|
8
|
-
} from "../engines";
|
|
3
|
+
import { LayerEditEvent, LayerSelectionReason, LayerVisibilityEvent } from "../engines";
|
|
9
4
|
import { ComputedFeature, ComputedLayer } from "../mantle";
|
|
10
5
|
import {
|
|
11
6
|
LayerLoadEvent,
|
|
@@ -28,8 +23,6 @@ type CoreContext = {
|
|
|
28
23
|
};
|
|
29
24
|
selectedComputedFeature?: ComputedFeature | undefined;
|
|
30
25
|
viewport?: Viewport;
|
|
31
|
-
overriddenSceneProperty?: SceneProperty;
|
|
32
|
-
overrideSceneProperty?: (pluginId: string, property: SceneProperty) => void;
|
|
33
26
|
handleCameraForceHorizontalRollChange?: (enable?: boolean) => void;
|
|
34
27
|
handleInteractionModeChange?: (mode?: InteractionModeType | undefined) => void;
|
|
35
28
|
onSketchPluginFeatureCreate?: (cb: SketchEventCallback) => void;
|