@reearth/core 0.0.7-alpha.36 → 0.0.7-alpha.38

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 CHANGED
@@ -368,13 +368,21 @@ export declare type CoreVisualizerProps = {
368
368
  onSketchFeatureDelete?: (layerId: string, featureId: string) => void;
369
369
  onInteractionModeChange?: (mode: InteractionModeType) => void;
370
370
  onAPIReady?: () => void;
371
- onCreditsUpdate?: (credits: Credit[]) => void;
371
+ onCreditsUpdate?: (credits?: Credits) => void;
372
372
  };
373
373
 
374
- export declare type Credit = {
374
+ export declare type CreditItem = {
375
375
  html?: string;
376
376
  };
377
377
 
378
+ export declare type Credits = {
379
+ engine: {
380
+ cesium?: CreditItem;
381
+ };
382
+ lightbox: CreditItem[];
383
+ screen: CreditItem[];
384
+ };
385
+
378
386
  declare type CursorType = "default" | "auto" | "help" | "pointer" | "grab" | "crosshair" | "wait";
379
387
 
380
388
  export declare type Data = {
@@ -518,7 +526,7 @@ export declare type EngineProps = {
518
526
  onLayerSelectWithRectStart?: (e: LayerSelectWithRectStart) => void;
519
527
  onLayerSelectWithRectMove?: (e: LayerSelectWithRectMove) => void;
520
528
  onLayerSelectWithRectEnd?: (e: LayerSelectWithRectEnd) => void;
521
- onCreditsUpdate?: (credits: Credit[]) => void;
529
+ onCreditsUpdate?: (credits?: Credits) => void;
522
530
  };
523
531
 
524
532
  export declare type EngineRef = {
@@ -607,7 +615,7 @@ export declare type EngineRef = {
607
615
  unselectFeatures: (layerId: string, featureId: string[]) => void;
608
616
  pickManyFromViewport: (windowPosition: [x: number, y: number], windowWidth: number, windowHeight: number, condition?: (f: PickedFeature) => boolean) => PickedFeature[] | undefined;
609
617
  calcRectangleControlPoint: (p1: Position3d, p2: Position3d, p3: Position3d) => [p1: Position3d, p2: Position3d, p3: Position3d];
610
- getCredits: () => Credit[] | undefined;
618
+ getCredits: () => Credits | undefined;
611
619
  } & MouseEventHandles;
612
620
 
613
621
  export declare const engines: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reearth/core",
3
- "version": "0.0.7-alpha.36",
3
+ "version": "0.0.7-alpha.38",
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.",
@@ -212,7 +212,7 @@ export type EngineRef = {
212
212
  p2: Position3d,
213
213
  p3: Position3d,
214
214
  ) => [p1: Position3d, p2: Position3d, p3: Position3d];
215
- getCredits: () => Credit[] | undefined;
215
+ getCredits: () => Credits | undefined;
216
216
  } & MouseEventHandles;
217
217
 
218
218
  export type EngineProps = {
@@ -261,7 +261,7 @@ export type EngineProps = {
261
261
  onLayerSelectWithRectStart?: (e: LayerSelectWithRectStart) => void;
262
262
  onLayerSelectWithRectMove?: (e: LayerSelectWithRectMove) => void;
263
263
  onLayerSelectWithRectEnd?: (e: LayerSelectWithRectEnd) => void;
264
- onCreditsUpdate?: (credits: Credit[]) => void;
264
+ onCreditsUpdate?: (credits?: Credits) => void;
265
265
  };
266
266
 
267
267
  export type LayerEditEvent = {
@@ -386,6 +386,14 @@ export type SketchRef = {
386
386
  onEditFeatureChange: (cb: SketchEditFeatureChangeCb) => void;
387
387
  };
388
388
 
389
- export type Credit = {
389
+ export type CreditItem = {
390
390
  html?: string;
391
391
  };
392
+
393
+ export type Credits = {
394
+ engine: {
395
+ cesium?: CreditItem;
396
+ };
397
+ lightbox: CreditItem[];
398
+ screen: CreditItem[];
399
+ };
@@ -12,7 +12,7 @@ import {
12
12
  type LatLng,
13
13
  type Cluster,
14
14
  type ComputedLayer,
15
- type Credit,
15
+ type Credits,
16
16
  } from "../Map";
17
17
  import { SketchFeature, SketchType } from "../Map/Sketch/types";
18
18
 
@@ -64,7 +64,7 @@ export type CoreVisualizerProps = {
64
64
  onSketchFeatureDelete?: (layerId: string, featureId: string) => void;
65
65
  onInteractionModeChange?: (mode: InteractionModeType) => void;
66
66
  onAPIReady?: () => void;
67
- onCreditsUpdate?: (credits: Credit[]) => void;
67
+ onCreditsUpdate?: (credits?: Credits) => void;
68
68
  };
69
69
 
70
70
  export const CoreVisualizer = memo(
@@ -42,6 +42,7 @@ import { MutableRefObject, useMemo } from "react";
42
42
 
43
43
  import type { Camera, Clock } from "..";
44
44
  import { ClassificationType } from "../../mantle";
45
+ import { Credits } from "../../Map";
45
46
  import type {
46
47
  CameraOptions,
47
48
  FlyToDestination,
@@ -75,8 +76,8 @@ const drawIcon = (
75
76
 
76
77
  ctx.save();
77
78
 
78
- c.width = w + shadowBlur;
79
- c.height = h + shadowBlur;
79
+ c.width = w + shadowBlur * 2;
80
+ c.height = h + shadowBlur * 2;
80
81
  ctx.shadowBlur = shadowBlur;
81
82
  ctx.shadowOffsetX = shadowOffsetX;
82
83
  ctx.shadowOffsetY = shadowOffsetY;
@@ -87,14 +88,14 @@ const drawIcon = (
87
88
  if (crop === "circle") {
88
89
  ctx.fillStyle = "black";
89
90
  ctx.globalCompositeOperation = "destination-in";
90
- ctx.arc(w / 2, h / 2, Math.min(w, h) / 2, 0, 2 * Math.PI);
91
+ ctx.arc(c.width / 2, c.height / 2, Math.min(w, h) / 2, 0, 2 * Math.PI);
91
92
  ctx.fill();
92
93
 
93
94
  if (shadow) {
94
95
  ctx.shadowColor = shadowColor;
95
96
  ctx.globalCompositeOperation = "destination-over";
96
97
  ctx.fillStyle = "black";
97
- ctx.arc(w / 2, h / 2, Math.min(w, h) / 2, 0, 2 * Math.PI);
98
+ ctx.arc(c.width / 2, c.height / 2, Math.min(w, h) / 2, 0, 2 * Math.PI);
98
99
  ctx.fill();
99
100
  }
100
101
  } else if (shadow) {
@@ -919,17 +920,17 @@ export function getCredits(viewer: Viewer) {
919
920
  const { lightboxCredits, screenCredits } = creditDisplay?._currentFrameCredits || {};
920
921
  const cesiumCredits = creditDisplay._currentCesiumCredit;
921
922
 
922
- const credits: {
923
- html?: string;
924
- }[] = [
925
- ...(cesiumCredits?.html ? [{ html: cesiumCredits.html }] : []),
926
- ...Array.from(lightboxCredits?._array ?? []).map(c => ({
923
+ const credits: Credits = {
924
+ engine: {
925
+ cesium: cesiumCredits?.html ? { html: cesiumCredits.html } : undefined,
926
+ },
927
+ lightbox: Array.from(lightboxCredits?._array ?? []).map(c => ({
927
928
  html: c?.credit?.html,
928
929
  })),
929
- ...Array.from(screenCredits?._array ?? []).map(c => ({
930
+ screen: Array.from(screenCredits?._array ?? []).map(c => ({
930
931
  html: c?.credit?.html,
931
932
  })),
932
- ];
933
+ };
933
934
 
934
935
  return credits;
935
936
  }
@@ -27,7 +27,7 @@ import type {
27
27
  import { e2eAccessToken, setE2ECesiumViewer } from "../../e2eConfig";
28
28
  import { ComputedFeature, DataType, SelectedFeatureInfo, LatLng, Camera } from "../../mantle";
29
29
  import {
30
- Credit,
30
+ Credits,
31
31
  LayerLoadEvent,
32
32
  LayerSelectWithRectEnd,
33
33
  LayerSelectWithRectMove,
@@ -130,7 +130,7 @@ export default ({
130
130
  onLayerLoad?: (e: LayerLoadEvent) => void;
131
131
  onCameraChange?: (camera: Camera) => void;
132
132
  onMount?: () => void;
133
- onCreditsUpdate?: (credits: Credit[]) => void;
133
+ onCreditsUpdate?: (credits?: Credits) => void;
134
134
  }) => {
135
135
  const cesium = useRef<CesiumComponentRef<CesiumViewer>>(null);
136
136
 
@@ -665,7 +665,7 @@ export default ({
665
665
  if (!onCreditsUpdateRef.current) return;
666
666
  const viewer = cesium.current?.cesiumElement;
667
667
  if (!viewer || viewer.isDestroyed()) return;
668
- const credits: Credit[] = getCredits(viewer) ?? [];
668
+ const credits = getCredits(viewer);
669
669
  onCreditsUpdateRef.current(credits);
670
670
  }, 3000);
671
671
  }, []);