@reearth/core 0.0.7-alpha.39 → 0.0.7-alpha.40

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reearth/core",
3
- "version": "0.0.7-alpha.39",
3
+ "version": "0.0.7-alpha.40",
4
4
  "author": "Re:Earth contributors <community@reearth.io>",
5
5
  "license": "Apache-2.0",
6
6
  "description": "A library that abstracts a map engine as one common API.",
@@ -92,14 +92,15 @@ const makeFeatureId = (
92
92
  }
93
93
  const featureId = getBuiltinFeatureId(tileFeature);
94
94
  return generateIDWithMD5(
95
- `${coordinates.x}-${coordinates.y}-${coordinates.z}-${featureId}-${!(tileFeature instanceof Model)
96
- ? JSON.stringify(
97
- // Read only root properties.
98
- Object.entries(convertCesium3DTileFeatureProperties(tileFeature))
99
- .filter((_k, v) => typeof v === "string" || typeof v === "number")
100
- .map(([k, v]) => `${k}${v}`),
101
- )
102
- : ""
95
+ `${coordinates.x}-${coordinates.y}-${coordinates.z}-${featureId}-${
96
+ !(tileFeature instanceof Model)
97
+ ? JSON.stringify(
98
+ // Read only root properties.
99
+ Object.entries(convertCesium3DTileFeatureProperties(tileFeature))
100
+ .filter((_k, v) => typeof v === "string" || typeof v === "number")
101
+ .map(([k, v]) => `${k}${v}`),
102
+ )
103
+ : ""
103
104
  }`,
104
105
  );
105
106
  };
@@ -222,20 +223,25 @@ const useFeature = ({
222
223
  const style = computedFeature?.["3dtiles"];
223
224
 
224
225
  COMMON_STYLE_PROPERTIES.forEach(({ name, convert }) => {
226
+ const val = convertStyle(style?.[name], convert);
227
+
225
228
  if (name === "color") {
226
- if (isFeatureSelected) {
227
- raw.color =
228
- typeof layer["3dtiles"]?.selectedFeatureColor === "string"
229
- ? toColor(layer["3dtiles"]?.selectedFeatureColor) ?? raw.color
230
- : raw.color;
231
- return;
229
+ // Reset color to default so that new style could update all.
230
+ raw.color = DEFAULT_FEATURE_COLOR;
231
+
232
+ // Apply color from style.
233
+ if (val !== undefined) {
234
+ raw.color = val;
232
235
  }
233
236
 
234
- raw.color = DEFAULT_FEATURE_COLOR;
235
- }
236
- const val = convertStyle(style?.[name], convert);
237
- if (val !== undefined) {
238
- raw[name] = val;
237
+ // Apply color for selected feature.
238
+ if (isFeatureSelected && typeof layer["3dtiles"]?.selectedFeatureColor === "string") {
239
+ raw.color = toColor(layer["3dtiles"]?.selectedFeatureColor) ?? val;
240
+ }
241
+ } else {
242
+ if (val !== undefined) {
243
+ raw[name] = val;
244
+ }
239
245
  }
240
246
  });
241
247
 
@@ -752,8 +758,8 @@ export const useHooks = ({
752
758
  const tilesetUrl = useMemo(() => {
753
759
  return type === "osm-buildings" && isVisible
754
760
  ? IonResource.fromAssetId(96188, {
755
- accessToken: meta?.cesiumIonAccessToken as string | undefined,
756
- }) // https://github.com/CesiumGS/cesium/blob/main/packages/engine/Source/Scene/createOsmBuildings.js#L53
761
+ accessToken: meta?.cesiumIonAccessToken as string | undefined,
762
+ }) // https://github.com/CesiumGS/cesium/blob/main/packages/engine/Source/Scene/createOsmBuildings.js#L53
757
763
  : googleMapPhotorealisticResource && isVisible
758
764
  ? googleMapPhotorealisticResource
759
765
  : type === "3dtiles" && isVisible
@@ -778,7 +784,7 @@ export const useHooks = ({
778
784
  property?.imageBasedLightIntensity ?? viewerProperty?.scene?.imageBasedLighting?.intensity;
779
785
  const sphericalHarmonicCoefficients = arrayToCartecian3(
780
786
  property?.sphericalHarmonicCoefficients ??
781
- viewerProperty?.scene?.imageBasedLighting?.sphericalHarmonicCoefficients,
787
+ viewerProperty?.scene?.imageBasedLighting?.sphericalHarmonicCoefficients,
782
788
  imageBasedLightIntensity,
783
789
  );
784
790