@reearth/core 0.0.7-alpha.19 → 0.0.7-alpha.20
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,15 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Entity,
|
|
3
|
-
Cartesian3,
|
|
4
|
-
PolygonHierarchy,
|
|
5
|
-
PointGraphics,
|
|
6
|
-
BillboardGraphics,
|
|
7
|
-
JulianDate,
|
|
8
|
-
} from "cesium";
|
|
1
|
+
import { Entity, PointGraphics, BillboardGraphics, JulianDate } from "cesium";
|
|
9
2
|
|
|
10
3
|
import { EvalFeature } from "../../..";
|
|
11
4
|
import { AppearanceTypes, ComputedFeature, ComputedLayer, Feature } from "../../../../mantle";
|
|
12
5
|
import { heightReference, shadowMode, toColor } from "../../common";
|
|
6
|
+
import { getMarkerCoordinates, getGeometryFromEntity } from "../../helpers/getGeometryFromEntity";
|
|
13
7
|
import { convertEntityDescription, convertEntityProperties } from "../../utils/utils";
|
|
14
8
|
import { attachTag, extractSimpleLayer, getTag, Tag } from "../utils";
|
|
15
9
|
|
|
@@ -132,16 +126,14 @@ export const attachStyle = (
|
|
|
132
126
|
const point = hasAppearance(layer, entity, ["marker", "point"]);
|
|
133
127
|
const billboard = hasAppearance(layer, entity, ["marker", "billboard"]);
|
|
134
128
|
const label = hasAppearance(layer, entity, ["marker", "label"]);
|
|
135
|
-
if (point || billboard || label) {
|
|
136
|
-
const
|
|
137
|
-
const
|
|
129
|
+
if (entity.point || entity.billboard || entity.label) {
|
|
130
|
+
const coordinates = getMarkerCoordinates(entity, currentTime);
|
|
131
|
+
const geometry = getGeometryFromEntity(currentTime, entity);
|
|
132
|
+
|
|
138
133
|
const feature: Feature = {
|
|
139
134
|
type: "feature",
|
|
140
135
|
id: makeFeatureId(entity),
|
|
141
|
-
geometry
|
|
142
|
-
type: "Point",
|
|
143
|
-
coordinates,
|
|
144
|
-
},
|
|
136
|
+
geometry,
|
|
145
137
|
properties: convertEntityProperties(currentTime, entity),
|
|
146
138
|
metaData: {
|
|
147
139
|
description: convertEntityDescription(currentTime, entity),
|
|
@@ -168,10 +160,10 @@ export const attachStyle = (
|
|
|
168
160
|
name: "show",
|
|
169
161
|
...(computedFeature?.marker?.style
|
|
170
162
|
? {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
163
|
+
override:
|
|
164
|
+
computedFeature?.marker?.style === "point" &&
|
|
165
|
+
(computedFeature?.marker.show ?? true),
|
|
166
|
+
}
|
|
175
167
|
: {}),
|
|
176
168
|
},
|
|
177
169
|
pixelSize: {
|
|
@@ -207,10 +199,10 @@ export const attachStyle = (
|
|
|
207
199
|
name: "show",
|
|
208
200
|
...(computedFeature?.marker?.style
|
|
209
201
|
? {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
202
|
+
override:
|
|
203
|
+
computedFeature?.marker?.style === "image" &&
|
|
204
|
+
(computedFeature?.marker.show ?? true),
|
|
205
|
+
}
|
|
214
206
|
: {}),
|
|
215
207
|
},
|
|
216
208
|
image: {
|
|
@@ -261,21 +253,14 @@ export const attachStyle = (
|
|
|
261
253
|
return [feature, computedFeature];
|
|
262
254
|
}
|
|
263
255
|
|
|
264
|
-
if (
|
|
256
|
+
if (entity.polyline) {
|
|
265
257
|
const entityPosition = entity.position?.getValue(currentTime);
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
position?.x ?? 0,
|
|
269
|
-
position?.y ?? 0,
|
|
270
|
-
position?.z ?? 0,
|
|
271
|
-
]);
|
|
258
|
+
const geometry = getGeometryFromEntity(currentTime, entity);
|
|
259
|
+
|
|
272
260
|
const feature: Feature = {
|
|
273
261
|
type: "feature",
|
|
274
262
|
id: makeFeatureId(entity),
|
|
275
|
-
geometry
|
|
276
|
-
type: "LineString",
|
|
277
|
-
coordinates,
|
|
278
|
-
},
|
|
263
|
+
geometry,
|
|
279
264
|
properties: convertEntityProperties(currentTime, entity),
|
|
280
265
|
metaData: {
|
|
281
266
|
description: convertEntityDescription(currentTime, entity),
|
|
@@ -290,42 +275,39 @@ export const attachStyle = (
|
|
|
290
275
|
if (!computedFeature) {
|
|
291
276
|
return;
|
|
292
277
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
278
|
+
if (hasAppearance(layer, entity, ["polyline", "polyline"])) {
|
|
279
|
+
attachProperties(entity, computedFeature, ["polyline", "polyline"], {
|
|
280
|
+
show: {
|
|
281
|
+
name: "show",
|
|
282
|
+
default: true,
|
|
283
|
+
},
|
|
284
|
+
width: {
|
|
285
|
+
name: "strokeWidth",
|
|
286
|
+
},
|
|
287
|
+
material: {
|
|
288
|
+
name: "strokeColor",
|
|
289
|
+
type: "color",
|
|
290
|
+
},
|
|
291
|
+
shadows: {
|
|
292
|
+
name: "shadows",
|
|
293
|
+
type: "shadows",
|
|
294
|
+
},
|
|
295
|
+
clampToGround: {
|
|
296
|
+
name: "clampToGround",
|
|
297
|
+
},
|
|
298
|
+
});
|
|
299
|
+
}
|
|
313
300
|
return [feature, computedFeature];
|
|
314
301
|
}
|
|
315
302
|
|
|
316
|
-
if (
|
|
303
|
+
if (entity.polygon) {
|
|
317
304
|
const entityPosition = entity.position?.getValue(currentTime);
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
hole.positions.map(position => [position?.x ?? 0, position?.y ?? 0, position?.z ?? 0]),
|
|
321
|
-
);
|
|
305
|
+
const geometry = getGeometryFromEntity(currentTime, entity);
|
|
306
|
+
|
|
322
307
|
const feature: Feature = {
|
|
323
308
|
type: "feature",
|
|
324
309
|
id: makeFeatureId(entity),
|
|
325
|
-
geometry
|
|
326
|
-
type: "Polygon",
|
|
327
|
-
coordinates,
|
|
328
|
-
},
|
|
310
|
+
geometry,
|
|
329
311
|
properties: convertEntityProperties(currentTime, entity),
|
|
330
312
|
metaData: {
|
|
331
313
|
description: convertEntityDescription(currentTime, entity),
|
|
@@ -340,40 +322,42 @@ export const attachStyle = (
|
|
|
340
322
|
if (!computedFeature) {
|
|
341
323
|
return;
|
|
342
324
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
325
|
+
if (hasAppearance(layer, entity, ["polygon", "polygon"])) {
|
|
326
|
+
attachProperties(entity, computedFeature, ["polygon", "polygon"], {
|
|
327
|
+
show: {
|
|
328
|
+
name: "show",
|
|
329
|
+
default: true,
|
|
330
|
+
},
|
|
331
|
+
fill: {
|
|
332
|
+
name: "fill",
|
|
333
|
+
},
|
|
334
|
+
material: {
|
|
335
|
+
name: "fillColor",
|
|
336
|
+
type: "color",
|
|
337
|
+
},
|
|
338
|
+
outline: {
|
|
339
|
+
name: "stroke",
|
|
340
|
+
},
|
|
341
|
+
outlineColor: {
|
|
342
|
+
name: "strokeColor",
|
|
343
|
+
type: "color",
|
|
344
|
+
},
|
|
345
|
+
outlineWidth: {
|
|
346
|
+
name: "strokeWidth",
|
|
347
|
+
},
|
|
348
|
+
shadows: {
|
|
349
|
+
name: "shadows",
|
|
350
|
+
type: "shadows",
|
|
351
|
+
},
|
|
352
|
+
heightReference: {
|
|
353
|
+
name: "heightReference",
|
|
354
|
+
type: "heightReference",
|
|
355
|
+
},
|
|
356
|
+
extrudedHeight: {
|
|
357
|
+
name: "extrudedHeight",
|
|
358
|
+
},
|
|
359
|
+
});
|
|
360
|
+
}
|
|
377
361
|
return [feature, computedFeature];
|
|
378
362
|
}
|
|
379
363
|
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Cartesian3, Entity, JulianDate, PolygonHierarchy } from "cesium";
|
|
2
|
+
|
|
3
|
+
import { Geometry } from "../../../mantle";
|
|
4
|
+
|
|
5
|
+
export function getMarkerCoordinates(
|
|
6
|
+
entity: Entity,
|
|
7
|
+
currentTime: JulianDate,
|
|
8
|
+
): [number, number, number] {
|
|
9
|
+
const position = entity.position?.getValue(currentTime) as Cartesian3 | undefined;
|
|
10
|
+
return [position?.x ?? 0, position?.y ?? 0, position?.z ?? 0];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function getGeometryFromEntity(currentTime: JulianDate, entity: Entity) {
|
|
14
|
+
if (entity.point || entity.billboard || entity.label) {
|
|
15
|
+
const coordinates = getMarkerCoordinates(entity, currentTime);
|
|
16
|
+
|
|
17
|
+
const geometry: Geometry = {
|
|
18
|
+
type: "Point",
|
|
19
|
+
coordinates,
|
|
20
|
+
};
|
|
21
|
+
return geometry;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (entity.polyline) {
|
|
25
|
+
const positions = entity.polyline?.positions?.getValue(currentTime) as Cartesian3[];
|
|
26
|
+
const coordinates = positions?.map(position => [
|
|
27
|
+
position?.x ?? 0,
|
|
28
|
+
position?.y ?? 0,
|
|
29
|
+
position?.z ?? 0,
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
const geometry: Geometry = {
|
|
33
|
+
type: "LineString",
|
|
34
|
+
coordinates,
|
|
35
|
+
};
|
|
36
|
+
return geometry;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (entity.polygon) {
|
|
40
|
+
const hierarchy = entity.polygon?.hierarchy?.getValue(currentTime) as PolygonHierarchy;
|
|
41
|
+
const coordinates = hierarchy?.positions?.map(position => [
|
|
42
|
+
position?.x ?? 0,
|
|
43
|
+
position?.y ?? 0,
|
|
44
|
+
position?.z ?? 0,
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
const geometry: Geometry = {
|
|
48
|
+
type: "Polygon",
|
|
49
|
+
coordinates: [coordinates],
|
|
50
|
+
};
|
|
51
|
+
return geometry;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
findEntity,
|
|
47
47
|
findFeaturesFromLayer,
|
|
48
48
|
} from "../utils/utils";
|
|
49
|
+
import { getGeometryFromEntity } from "../helpers/getGeometryFromEntity";
|
|
49
50
|
|
|
50
51
|
export default function useEngineRef(
|
|
51
52
|
ref: Ref<EngineRef>,
|
|
@@ -847,6 +848,7 @@ export default function useEngineRef(
|
|
|
847
848
|
tag.computedFeature ?? {
|
|
848
849
|
type: "computedFeature",
|
|
849
850
|
id: tag.featureId,
|
|
851
|
+
geometry: getGeometryFromEntity(viewer.clock.currentTime, entity),
|
|
850
852
|
properties: convertEntityProperties(viewer.clock.currentTime, entity),
|
|
851
853
|
metaData: {
|
|
852
854
|
description: convertEntityDescription(viewer.clock.currentTime, entity),
|