@reearth/core 0.0.7-alpha.16 → 0.0.7-alpha.17
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 +1670 -1672
- package/dist/core.umd.cjs +30 -30
- package/dist/index.d.ts +3 -1
- package/package.json +1 -1
- package/src/engines/Cesium/Feature/Tileset/hooks.ts +21 -22
- package/src/mantle/types/appearance.ts +0 -1
- package/src/mantle/types/index.ts +3 -0
package/dist/index.d.ts
CHANGED
|
@@ -169,7 +169,6 @@ export declare type Cesium3DTilesAppearance = {
|
|
|
169
169
|
selectedFeatureColor?: string;
|
|
170
170
|
disableIndexingFeature?: boolean;
|
|
171
171
|
tileset?: string;
|
|
172
|
-
apiKey?: string;
|
|
173
172
|
experimental_clipping?: EXPERIMENTAL_clipping;
|
|
174
173
|
pointSize?: number;
|
|
175
174
|
meta?: unknown;
|
|
@@ -389,6 +388,9 @@ export declare type Data = {
|
|
|
389
388
|
updateInterval?: number;
|
|
390
389
|
parameters?: Record<string, any>;
|
|
391
390
|
idProperty?: string;
|
|
391
|
+
serviceTokens?: {
|
|
392
|
+
googleMapApiKey?: string;
|
|
393
|
+
};
|
|
392
394
|
time?: {
|
|
393
395
|
property?: string;
|
|
394
396
|
interval?: number;
|
package/package.json
CHANGED
|
@@ -15,13 +15,11 @@ import {
|
|
|
15
15
|
Cesium3DTileFeature,
|
|
16
16
|
Model,
|
|
17
17
|
Cesium3DTilePointFeature,
|
|
18
|
-
GoogleMaps as CesiumGoogleMaps,
|
|
19
|
-
Resource,
|
|
20
|
-
defaultValue,
|
|
21
18
|
ImageBasedLighting,
|
|
22
19
|
Cesium3DTileContent,
|
|
23
20
|
Color,
|
|
24
21
|
Viewer,
|
|
22
|
+
createGooglePhotorealistic3DTileset,
|
|
25
23
|
} from "cesium";
|
|
26
24
|
import { pick } from "lodash-es";
|
|
27
25
|
import { MutableRefObject, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
@@ -57,7 +55,6 @@ import {
|
|
|
57
55
|
} from "../utils";
|
|
58
56
|
|
|
59
57
|
import { TilesetFeatureIndex } from "./TilesetFeatureIndex";
|
|
60
|
-
import { GoogleMaps } from "./types";
|
|
61
58
|
import { useClippingBox } from "./useClippingBox";
|
|
62
59
|
import { useDrawClipping } from "./useDrawClipping";
|
|
63
60
|
|
|
@@ -77,6 +74,7 @@ const useData = (layer: ComputedLayer | undefined) => {
|
|
|
77
74
|
? data.layers.join(",")
|
|
78
75
|
: data?.layers
|
|
79
76
|
: undefined,
|
|
77
|
+
googleMapApiKey: data?.serviceTokens?.googleMapApiKey,
|
|
80
78
|
};
|
|
81
79
|
}, [layer]);
|
|
82
80
|
};
|
|
@@ -460,7 +458,6 @@ export const useHooks = ({
|
|
|
460
458
|
edgeColor,
|
|
461
459
|
edgeWidth,
|
|
462
460
|
experimental_clipping,
|
|
463
|
-
apiKey,
|
|
464
461
|
selectedFeatureColor,
|
|
465
462
|
disableIndexingFeature,
|
|
466
463
|
} = property ?? {};
|
|
@@ -481,7 +478,7 @@ export const useHooks = ({
|
|
|
481
478
|
} = useClippingBox({ clipping: experimental_clipping, boxId });
|
|
482
479
|
|
|
483
480
|
const [style, setStyle] = useState<Cesium3DTileStyle>();
|
|
484
|
-
const { url, type, idProperty } = useData(layer);
|
|
481
|
+
const { url, type, idProperty, googleMapApiKey } = useData(layer);
|
|
485
482
|
const shouldUseFeatureIndex = !disableIndexingFeature && !!idProperty;
|
|
486
483
|
|
|
487
484
|
const [isTilesetReady, setIsTilesetReady] = useState(false);
|
|
@@ -708,31 +705,33 @@ export const useHooks = ({
|
|
|
708
705
|
})();
|
|
709
706
|
}, [styleUrl]);
|
|
710
707
|
|
|
711
|
-
const
|
|
712
|
-
if (type !== "google-photorealistic" || !isVisible) return;
|
|
713
|
-
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
}
|
|
723
|
-
|
|
708
|
+
const googleMapPhotorealisticResource = useMemo(() => {
|
|
709
|
+
if (type !== "google-photorealistic" || !isVisible) return null;
|
|
710
|
+
|
|
711
|
+
const loadTileset = async () => {
|
|
712
|
+
try {
|
|
713
|
+
const tileset = await createGooglePhotorealistic3DTileset(googleMapApiKey);
|
|
714
|
+
return tileset.resource;
|
|
715
|
+
} catch (error) {
|
|
716
|
+
console.error(`Error loading Photorealistic 3D Tiles tileset: ${error}`);
|
|
717
|
+
throw error;
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
|
|
721
|
+
return loadTileset();
|
|
722
|
+
}, [type, isVisible, googleMapApiKey]);
|
|
724
723
|
|
|
725
724
|
const tilesetUrl = useMemo(() => {
|
|
726
725
|
return type === "osm-buildings" && isVisible
|
|
727
726
|
? IonResource.fromAssetId(96188, {
|
|
728
727
|
accessToken: meta?.cesiumIonAccessToken as string | undefined,
|
|
729
728
|
}) // https://github.com/CesiumGS/cesium/blob/main/packages/engine/Source/Scene/createOsmBuildings.js#L53
|
|
730
|
-
:
|
|
731
|
-
?
|
|
729
|
+
: googleMapPhotorealisticResource && isVisible
|
|
730
|
+
? googleMapPhotorealisticResource
|
|
732
731
|
: type === "3dtiles" && isVisible
|
|
733
732
|
? url ?? tileset
|
|
734
733
|
: null;
|
|
735
|
-
}, [
|
|
734
|
+
}, [type, isVisible, meta?.cesiumIonAccessToken, googleMapPhotorealisticResource, url, tileset]);
|
|
736
735
|
|
|
737
736
|
const imageBasedLighting = useMemo(() => {
|
|
738
737
|
if (
|
|
@@ -200,7 +200,6 @@ export type Cesium3DTilesAppearance = {
|
|
|
200
200
|
selectedFeatureColor?: string; // This doesn't support expression
|
|
201
201
|
disableIndexingFeature?: boolean;
|
|
202
202
|
tileset?: string;
|
|
203
|
-
apiKey?: string;
|
|
204
203
|
experimental_clipping?: EXPERIMENTAL_clipping;
|
|
205
204
|
pointSize?: number;
|
|
206
205
|
meta?: unknown;
|