@reearth/core 0.0.7-alpha.57 → 0.0.7-alpha.59
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 +52257 -49819
- package/dist/core.umd.cjs +4023 -3940
- package/dist/index.d.ts +3 -3
- package/package.json +10 -9
- package/src/Map/Sketch/hooks.ts +2 -2
- package/src/Map/Sketch/sketchMachine.ts +147 -177
- package/src/Map/Sketch/useSketch.ts +3 -4
- package/src/engines/Cesium/core/labels/JapanGSIOptimalBVmapVectorMapLabel/JapanGSIOptimalBVmapLabelImagery.tsx +1 -1
- package/src/engines/Cesium/core/labels/JapanGSIOptimalBVmapVectorMapLabel/JapanGSIOptimalBVmapLabelImageryProvider.ts +2 -2
- package/src/engines/Cesium/core/labels/JapanGSIOptimalBVmapVectorMapLabel/helpers.ts +1 -1
- package/src/engines/Cesium/index.tsx +1 -1
- package/src/mantle/atoms/compute.ts +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -280,7 +280,7 @@ declare type CommonProps = {
|
|
|
280
280
|
sketchEditingFeature?: SketchEditingFeature;
|
|
281
281
|
};
|
|
282
282
|
|
|
283
|
-
export declare function computeAtom(cache?: typeof globalDataFeaturesCache): WritableAtom<ComputedLayer | undefined, Command, void>;
|
|
283
|
+
export declare function computeAtom(cache?: typeof globalDataFeaturesCache): WritableAtom<ComputedLayer | undefined, [Command], void>;
|
|
284
284
|
|
|
285
285
|
export declare type ComputedFeature = CommonFeature<"computedFeature"> & Partial<AppearanceTypes>;
|
|
286
286
|
|
|
@@ -794,11 +794,11 @@ export declare function getCompat(l: Layer | undefined): LayerCompat | undefined
|
|
|
794
794
|
|
|
795
795
|
declare const globalDataFeaturesCache: {
|
|
796
796
|
get: Atom_2<(key: string, key2: string) => Feature[] | undefined>;
|
|
797
|
-
set: WritableAtom<null, {
|
|
797
|
+
set: WritableAtom<null, [value: {
|
|
798
798
|
key: string;
|
|
799
799
|
key2: string;
|
|
800
800
|
value?: Feature[] | undefined;
|
|
801
|
-
}, void> & {
|
|
801
|
+
}], void> & {
|
|
802
802
|
init: null;
|
|
803
803
|
};
|
|
804
804
|
getAll: Atom_2<(key: string) => Feature[][] | undefined>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reearth/core",
|
|
3
|
-
"version": "0.0.7-alpha.
|
|
3
|
+
"version": "0.0.7-alpha.59",
|
|
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.",
|
|
@@ -42,21 +42,21 @@
|
|
|
42
42
|
"@radix-ui/react-slot": "^1.2.4",
|
|
43
43
|
"@radix-ui/react-switch": "^1.2.6",
|
|
44
44
|
"@radix-ui/react-toggle": "^1.1.10",
|
|
45
|
-
"@reearth/cesium-mvt-imagery-provider": "1.6.
|
|
45
|
+
"@reearth/cesium-mvt-imagery-provider": "1.6.2",
|
|
46
46
|
"@reearth/spatial-id-sdk": "0.0.0",
|
|
47
47
|
"@rot1024/use-transition": "1.0.0",
|
|
48
48
|
"@seznam/compose-react-refs": "1.0.6",
|
|
49
49
|
"@turf/invariant": "^7.3.3",
|
|
50
50
|
"@turf/turf": "^7.3.3",
|
|
51
51
|
"@ungap/event-target": "0.2.4",
|
|
52
|
-
"@xstate/react": "
|
|
52
|
+
"@xstate/react": "^6.1.0",
|
|
53
53
|
"cesium-dnd": "1.1.0",
|
|
54
54
|
"csv-parse": "^6.1.0",
|
|
55
55
|
"d3": "^7.9.0",
|
|
56
56
|
"fast-xml-parser": "^5.3.3",
|
|
57
57
|
"framer-motion": "^12.29.2",
|
|
58
58
|
"geojson": "0.5.0",
|
|
59
|
-
"jotai": "
|
|
59
|
+
"jotai": "^2.18.0",
|
|
60
60
|
"js-md5": "^0.8.3",
|
|
61
61
|
"jsep": "^1.4.0",
|
|
62
62
|
"jsonpath-plus": "^10.3.0",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"lru-cache": "^11.2.5",
|
|
66
66
|
"pbf": "^4.0.1",
|
|
67
67
|
"proj4": "^2.20.2",
|
|
68
|
-
"protomaps": "1.
|
|
68
|
+
"protomaps-leaflet": "^5.1.0",
|
|
69
69
|
"react-dnd": "16.0.1",
|
|
70
70
|
"react-dnd-html5-backend": "16.0.1",
|
|
71
71
|
"react-error-boundary": "^6.1.0",
|
|
@@ -73,14 +73,14 @@
|
|
|
73
73
|
"react-use": "^17.6.0",
|
|
74
74
|
"resium": "^1.19.3",
|
|
75
75
|
"suspend-react": "0.1.3",
|
|
76
|
-
"tailwind-merge": "^
|
|
77
|
-
"tailwindcss": "^
|
|
76
|
+
"tailwind-merge": "^3.5.0",
|
|
77
|
+
"tailwindcss": "^4.2.1",
|
|
78
78
|
"tailwindcss-animate": "^1.0.7",
|
|
79
79
|
"tiny-invariant": "1.3.3",
|
|
80
80
|
"use-callback-ref": "1.3.3",
|
|
81
81
|
"use-custom-compare": "1.5.0",
|
|
82
82
|
"uuid": "^13.0.0",
|
|
83
|
-
"xstate": "
|
|
83
|
+
"xstate": "^5.28.0"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@apollo/client": "^4.1.2",
|
|
@@ -105,6 +105,7 @@
|
|
|
105
105
|
"@types/scheduler": "^0.26.0",
|
|
106
106
|
"@vitejs/plugin-react": "^5.1.2",
|
|
107
107
|
"@xstate/cli": "0.5.17",
|
|
108
|
+
"@tailwindcss/postcss": "^4.2.1",
|
|
108
109
|
"autoprefixer": "^10.4.23",
|
|
109
110
|
"cesium": "^1.137.0",
|
|
110
111
|
"class-variance-authority": "^0.7.1",
|
|
@@ -112,7 +113,7 @@
|
|
|
112
113
|
"eslint": "8.57.0",
|
|
113
114
|
"eslint-config-reearth": "0.3.0",
|
|
114
115
|
"eslint-plugin-storybook": "^10.2.3",
|
|
115
|
-
"jsdom": "^
|
|
116
|
+
"jsdom": "^28.1.0",
|
|
116
117
|
"postcss": "^8.5.6",
|
|
117
118
|
"prettier": "^3.8.1",
|
|
118
119
|
"react": "^19.2.4",
|
package/src/Map/Sketch/hooks.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
useState,
|
|
14
14
|
} from "react";
|
|
15
15
|
import { v4 as uuidv4 } from "uuid";
|
|
16
|
-
import {
|
|
16
|
+
import { ActorRefFrom, StateFrom } from "xstate";
|
|
17
17
|
|
|
18
18
|
import { ControlPointMouseEventHandler } from "../../engines/Cesium/Sketch";
|
|
19
19
|
import { InteractionModeType } from "../../shared/interactionMode";
|
|
@@ -65,7 +65,7 @@ type Props = {
|
|
|
65
65
|
const sketchMachine = createSketchMachine();
|
|
66
66
|
|
|
67
67
|
export type sketchState = StateFrom<typeof sketchMachine>;
|
|
68
|
-
export type SketchInterpreter =
|
|
68
|
+
export type SketchInterpreter = ActorRefFrom<typeof sketchMachine>;
|
|
69
69
|
|
|
70
70
|
export default function ({
|
|
71
71
|
ref,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// TODO: Refactor: move cesium related code to engine.
|
|
2
2
|
import invariant from "tiny-invariant";
|
|
3
|
-
import { createMachine, type StateFrom } from "xstate";
|
|
3
|
+
import { createMachine, assign, type StateFrom } from "xstate";
|
|
4
4
|
|
|
5
5
|
import { type SketchType } from "./types";
|
|
6
6
|
|
|
@@ -133,6 +133,7 @@ export function createSketchMachine() {
|
|
|
133
133
|
},
|
|
134
134
|
},
|
|
135
135
|
drawing: {
|
|
136
|
+
initial: "marker",
|
|
136
137
|
states: {
|
|
137
138
|
marker: {
|
|
138
139
|
initial: "vertex",
|
|
@@ -147,7 +148,7 @@ export function createSketchMachine() {
|
|
|
147
148
|
on: {
|
|
148
149
|
NEXT: {
|
|
149
150
|
target: "vertex",
|
|
150
|
-
|
|
151
|
+
reenter: false,
|
|
151
152
|
actions: ["pushPosition"],
|
|
152
153
|
},
|
|
153
154
|
},
|
|
@@ -175,7 +176,7 @@ export function createSketchMachine() {
|
|
|
175
176
|
NEXT: [
|
|
176
177
|
{
|
|
177
178
|
target: "vertex",
|
|
178
|
-
|
|
179
|
+
reenter: false,
|
|
179
180
|
actions: ["pushPosition"],
|
|
180
181
|
},
|
|
181
182
|
],
|
|
@@ -191,12 +192,12 @@ export function createSketchMachine() {
|
|
|
191
192
|
NEXT: [
|
|
192
193
|
{
|
|
193
194
|
target: "#sketch.extruding",
|
|
194
|
-
|
|
195
|
+
guard: "willRectangleComplete",
|
|
195
196
|
actions: ["pushPosition", "recordOriginalControlPoint"],
|
|
196
197
|
},
|
|
197
198
|
{
|
|
198
199
|
target: "vertex",
|
|
199
|
-
|
|
200
|
+
reenter: false,
|
|
200
201
|
actions: ["pushPosition"],
|
|
201
202
|
},
|
|
202
203
|
],
|
|
@@ -211,7 +212,7 @@ export function createSketchMachine() {
|
|
|
211
212
|
on: {
|
|
212
213
|
NEXT: {
|
|
213
214
|
target: "vertex",
|
|
214
|
-
|
|
215
|
+
reenter: false,
|
|
215
216
|
actions: ["pushPosition"],
|
|
216
217
|
},
|
|
217
218
|
},
|
|
@@ -225,7 +226,7 @@ export function createSketchMachine() {
|
|
|
225
226
|
on: {
|
|
226
227
|
NEXT: {
|
|
227
228
|
target: "vertex",
|
|
228
|
-
|
|
229
|
+
reenter: false,
|
|
229
230
|
actions: ["pushPosition"],
|
|
230
231
|
},
|
|
231
232
|
EXTRUDE: {
|
|
@@ -244,7 +245,7 @@ export function createSketchMachine() {
|
|
|
244
245
|
CANCEL: [
|
|
245
246
|
{
|
|
246
247
|
target: ".history",
|
|
247
|
-
|
|
248
|
+
guard: "canPopPosition",
|
|
248
249
|
actions: ["popPosition"],
|
|
249
250
|
},
|
|
250
251
|
{
|
|
@@ -279,6 +280,7 @@ export function createSketchMachine() {
|
|
|
279
280
|
},
|
|
280
281
|
},
|
|
281
282
|
editing: {
|
|
283
|
+
initial: "marker",
|
|
282
284
|
states: {
|
|
283
285
|
marker: {
|
|
284
286
|
initial: "waiting",
|
|
@@ -287,7 +289,7 @@ export function createSketchMachine() {
|
|
|
287
289
|
on: {
|
|
288
290
|
CATCH: {
|
|
289
291
|
target: "moving",
|
|
290
|
-
|
|
292
|
+
reenter: false,
|
|
291
293
|
actions: ["catchControlPoint"],
|
|
292
294
|
},
|
|
293
295
|
},
|
|
@@ -296,7 +298,7 @@ export function createSketchMachine() {
|
|
|
296
298
|
on: {
|
|
297
299
|
MOVE: {
|
|
298
300
|
target: "moving",
|
|
299
|
-
|
|
301
|
+
reenter: false,
|
|
300
302
|
actions: ["moveControlPoint"],
|
|
301
303
|
},
|
|
302
304
|
RELEASE: {
|
|
@@ -314,12 +316,12 @@ export function createSketchMachine() {
|
|
|
314
316
|
on: {
|
|
315
317
|
CATCH: {
|
|
316
318
|
target: "moving",
|
|
317
|
-
|
|
319
|
+
reenter: false,
|
|
318
320
|
actions: ["catchControlPoint"],
|
|
319
321
|
},
|
|
320
322
|
UPDATE: {
|
|
321
323
|
target: "waiting",
|
|
322
|
-
|
|
324
|
+
reenter: false,
|
|
323
325
|
actions: ["updateControlPoints"],
|
|
324
326
|
},
|
|
325
327
|
},
|
|
@@ -328,7 +330,7 @@ export function createSketchMachine() {
|
|
|
328
330
|
on: {
|
|
329
331
|
MOVE: {
|
|
330
332
|
target: "moving",
|
|
331
|
-
|
|
333
|
+
reenter: false,
|
|
332
334
|
actions: ["moveControlPoint"],
|
|
333
335
|
},
|
|
334
336
|
RELEASE: {
|
|
@@ -346,7 +348,7 @@ export function createSketchMachine() {
|
|
|
346
348
|
on: {
|
|
347
349
|
CATCH: {
|
|
348
350
|
target: "moving",
|
|
349
|
-
|
|
351
|
+
reenter: false,
|
|
350
352
|
actions: ["catchControlPoint"],
|
|
351
353
|
},
|
|
352
354
|
},
|
|
@@ -355,7 +357,7 @@ export function createSketchMachine() {
|
|
|
355
357
|
on: {
|
|
356
358
|
MOVE: {
|
|
357
359
|
target: "moving",
|
|
358
|
-
|
|
360
|
+
reenter: false,
|
|
359
361
|
actions: ["moveControlPoint"],
|
|
360
362
|
},
|
|
361
363
|
RELEASE: {
|
|
@@ -373,7 +375,7 @@ export function createSketchMachine() {
|
|
|
373
375
|
on: {
|
|
374
376
|
CATCH: {
|
|
375
377
|
target: "moving",
|
|
376
|
-
|
|
378
|
+
reenter: false,
|
|
377
379
|
actions: ["catchControlPoint"],
|
|
378
380
|
},
|
|
379
381
|
},
|
|
@@ -382,7 +384,7 @@ export function createSketchMachine() {
|
|
|
382
384
|
on: {
|
|
383
385
|
MOVE: {
|
|
384
386
|
target: "moving",
|
|
385
|
-
|
|
387
|
+
reenter: false,
|
|
386
388
|
actions: ["moveControlPoint"],
|
|
387
389
|
},
|
|
388
390
|
RELEASE: {
|
|
@@ -400,12 +402,12 @@ export function createSketchMachine() {
|
|
|
400
402
|
on: {
|
|
401
403
|
CATCH: {
|
|
402
404
|
target: "moving",
|
|
403
|
-
|
|
405
|
+
reenter: false,
|
|
404
406
|
actions: ["catchControlPoint"],
|
|
405
407
|
},
|
|
406
408
|
UPDATE: {
|
|
407
409
|
target: "waiting",
|
|
408
|
-
|
|
410
|
+
reenter: false,
|
|
409
411
|
actions: ["updateControlPoints"],
|
|
410
412
|
},
|
|
411
413
|
},
|
|
@@ -414,7 +416,7 @@ export function createSketchMachine() {
|
|
|
414
416
|
on: {
|
|
415
417
|
MOVE: {
|
|
416
418
|
target: "moving",
|
|
417
|
-
|
|
419
|
+
reenter: false,
|
|
418
420
|
actions: ["moveControlPoint"],
|
|
419
421
|
},
|
|
420
422
|
RELEASE: {
|
|
@@ -432,7 +434,7 @@ export function createSketchMachine() {
|
|
|
432
434
|
on: {
|
|
433
435
|
CATCH: {
|
|
434
436
|
target: "moving",
|
|
435
|
-
|
|
437
|
+
reenter: false,
|
|
436
438
|
actions: ["catchControlPoint"],
|
|
437
439
|
},
|
|
438
440
|
},
|
|
@@ -441,7 +443,7 @@ export function createSketchMachine() {
|
|
|
441
443
|
on: {
|
|
442
444
|
MOVE: {
|
|
443
445
|
target: "moving",
|
|
444
|
-
|
|
446
|
+
reenter: false,
|
|
445
447
|
actions: ["moveControlPoint"],
|
|
446
448
|
},
|
|
447
449
|
RELEASE: {
|
|
@@ -459,7 +461,7 @@ export function createSketchMachine() {
|
|
|
459
461
|
on: {
|
|
460
462
|
CATCH: {
|
|
461
463
|
target: "moving",
|
|
462
|
-
|
|
464
|
+
reenter: false,
|
|
463
465
|
actions: ["catchControlPoint"],
|
|
464
466
|
},
|
|
465
467
|
},
|
|
@@ -468,7 +470,7 @@ export function createSketchMachine() {
|
|
|
468
470
|
on: {
|
|
469
471
|
MOVE: {
|
|
470
472
|
target: "moving",
|
|
471
|
-
|
|
473
|
+
reenter: false,
|
|
472
474
|
actions: ["moveControlPoint"],
|
|
473
475
|
},
|
|
474
476
|
RELEASE: {
|
|
@@ -486,12 +488,12 @@ export function createSketchMachine() {
|
|
|
486
488
|
on: {
|
|
487
489
|
CATCH: {
|
|
488
490
|
target: "moving",
|
|
489
|
-
|
|
491
|
+
reenter: false,
|
|
490
492
|
actions: ["catchControlPoint"],
|
|
491
493
|
},
|
|
492
494
|
UPDATE: {
|
|
493
495
|
target: "waiting",
|
|
494
|
-
|
|
496
|
+
reenter: false,
|
|
495
497
|
actions: ["updateControlPoints"],
|
|
496
498
|
},
|
|
497
499
|
},
|
|
@@ -500,7 +502,7 @@ export function createSketchMachine() {
|
|
|
500
502
|
on: {
|
|
501
503
|
MOVE: {
|
|
502
504
|
target: "moving",
|
|
503
|
-
|
|
505
|
+
reenter: false,
|
|
504
506
|
actions: ["moveControlPoint"],
|
|
505
507
|
},
|
|
506
508
|
RELEASE: {
|
|
@@ -520,158 +522,126 @@ export function createSketchMachine() {
|
|
|
520
522
|
},
|
|
521
523
|
},
|
|
522
524
|
},
|
|
523
|
-
schema: {
|
|
524
|
-
events: {} as unknown as EventObject,
|
|
525
|
-
},
|
|
526
|
-
predictableActionArguments: true,
|
|
527
|
-
preserveActionOrder: true,
|
|
528
|
-
tsTypes: {} as import("./sketchMachine.typegen").Typegen0,
|
|
529
525
|
},
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
clearDrawing: context => {
|
|
648
|
-
delete context.lastControlPoint;
|
|
649
|
-
delete context.type;
|
|
650
|
-
delete context.controlPoints;
|
|
651
|
-
delete context.catchedControlPointIndex;
|
|
652
|
-
delete context.catchedExtrudedPoint;
|
|
653
|
-
delete context.originalControlPoint;
|
|
654
|
-
},
|
|
655
|
-
catchControlPoint: (context, event) => {
|
|
656
|
-
context.catchedControlPointIndex = event.catchedControlPointIndex;
|
|
657
|
-
context.catchedExtrudedPoint = event.catchedExtrudedPoint;
|
|
658
|
-
},
|
|
659
|
-
moveControlPoint: (context, event) => {
|
|
660
|
-
context.controlPoints = event.controlPoints;
|
|
661
|
-
},
|
|
662
|
-
releaseControlPoint: context => {
|
|
663
|
-
delete context.catchedControlPointIndex;
|
|
664
|
-
delete context.catchedExtrudedPoint;
|
|
665
|
-
},
|
|
666
|
-
updateControlPoints: (context, event) => {
|
|
667
|
-
context.controlPoints = event.controlPoints;
|
|
668
|
-
},
|
|
669
|
-
recordOriginalControlPoint: (context, event) => {
|
|
670
|
-
context.originalControlPoint = [...event.controlPoint] as Position3d;
|
|
671
|
-
},
|
|
672
|
-
},
|
|
526
|
+
).provide({
|
|
527
|
+
guards: {
|
|
528
|
+
canPopPosition: ({ context }) => context.controlPoints != null && context.controlPoints.length > 1,
|
|
529
|
+
willRectangleComplete: ({ context }) => context.controlPoints != null && context.controlPoints.length === 2,
|
|
530
|
+
},
|
|
531
|
+
actions: {
|
|
532
|
+
createMarker: assign(({ event }) => {
|
|
533
|
+
const e = event as Extract<EventObject, { type: "MARKER" }>;
|
|
534
|
+
const controlPoint = [...e.controlPoint] as Position3d;
|
|
535
|
+
return { lastPointerPosition: [...e.pointerPosition] as Position2d, lastControlPoint: controlPoint, type: "marker" as SketchType, controlPoints: [controlPoint] };
|
|
536
|
+
}),
|
|
537
|
+
editMarker: assign(({ event }) => {
|
|
538
|
+
const e = event as Extract<EventObject, { type: "EDIT_MARKER" }>;
|
|
539
|
+
return { lastControlPoint: undefined, type: "marker" as SketchType, controlPoints: e.controlPoints };
|
|
540
|
+
}),
|
|
541
|
+
createPolyline: assign(({ event }) => {
|
|
542
|
+
const e = event as Extract<EventObject, { type: "POLYLINE" }>;
|
|
543
|
+
const controlPoint = [...e.controlPoint] as Position3d;
|
|
544
|
+
return { lastPointerPosition: [...e.pointerPosition] as Position2d, lastControlPoint: controlPoint, type: "polyline" as SketchType, controlPoints: [controlPoint] };
|
|
545
|
+
}),
|
|
546
|
+
editPolyline: assign(({ event }) => {
|
|
547
|
+
const e = event as Extract<EventObject, { type: "EDIT_POLYLINE" }>;
|
|
548
|
+
return { lastControlPoint: undefined, type: "polyline" as SketchType, controlPoints: e.controlPoints };
|
|
549
|
+
}),
|
|
550
|
+
createCircle: assign(({ event }) => {
|
|
551
|
+
const e = event as Extract<EventObject, { type: "CIRCLE" }>;
|
|
552
|
+
const controlPoint = [...e.controlPoint] as Position3d;
|
|
553
|
+
return { lastPointerPosition: [...e.pointerPosition] as Position2d, lastControlPoint: controlPoint, type: "circle" as SketchType, controlPoints: [controlPoint] };
|
|
554
|
+
}),
|
|
555
|
+
editCircle: assign(({ event }) => {
|
|
556
|
+
const e = event as Extract<EventObject, { type: "EDIT_CIRCLE" }>;
|
|
557
|
+
return { lastControlPoint: undefined, type: "circle" as SketchType, controlPoints: e.controlPoints };
|
|
558
|
+
}),
|
|
559
|
+
createRectangle: assign(({ event }) => {
|
|
560
|
+
const e = event as Extract<EventObject, { type: "RECTANGLE" }>;
|
|
561
|
+
const controlPoint = [...e.controlPoint] as Position3d;
|
|
562
|
+
return { lastPointerPosition: [...e.pointerPosition] as Position2d, lastControlPoint: controlPoint, type: "rectangle" as SketchType, controlPoints: [controlPoint] };
|
|
563
|
+
}),
|
|
564
|
+
editRectangle: assign(({ event }) => {
|
|
565
|
+
const e = event as Extract<EventObject, { type: "EDIT_RECTANGLE" }>;
|
|
566
|
+
return { lastControlPoint: undefined, type: "rectangle" as SketchType, controlPoints: e.controlPoints };
|
|
567
|
+
}),
|
|
568
|
+
createPolygon: assign(({ event }) => {
|
|
569
|
+
const e = event as Extract<EventObject, { type: "POLYGON" }>;
|
|
570
|
+
const controlPoint = [...e.controlPoint] as Position3d;
|
|
571
|
+
return { lastPointerPosition: [...e.pointerPosition] as Position2d, lastControlPoint: controlPoint, type: "polygon" as SketchType, controlPoints: [controlPoint] };
|
|
572
|
+
}),
|
|
573
|
+
editPolygon: assign(({ event }) => {
|
|
574
|
+
const e = event as Extract<EventObject, { type: "EDIT_POLYGON" }>;
|
|
575
|
+
return { lastControlPoint: undefined, type: "polygon" as SketchType, controlPoints: e.controlPoints };
|
|
576
|
+
}),
|
|
577
|
+
createExtrudedCircle: assign(({ event }) => {
|
|
578
|
+
const e = event as Extract<EventObject, { type: "EXTRUDED_CIRCLE" }>;
|
|
579
|
+
const controlPoint = [...e.controlPoint] as Position3d;
|
|
580
|
+
return { lastPointerPosition: [...e.pointerPosition] as Position2d, lastControlPoint: controlPoint, type: "extrudedCircle" as SketchType, controlPoints: [controlPoint] };
|
|
581
|
+
}),
|
|
582
|
+
editExtrudedCircle: assign(({ event }) => {
|
|
583
|
+
const e = event as Extract<EventObject, { type: "EDIT_EXTRUDED_CIRCLE" }>;
|
|
584
|
+
return { lastControlPoint: undefined, type: "extrudedCircle" as SketchType, controlPoints: e.controlPoints };
|
|
585
|
+
}),
|
|
586
|
+
createExtrudedRectangle: assign(({ event }) => {
|
|
587
|
+
const e = event as Extract<EventObject, { type: "EXTRUDED_RECTANGLE" }>;
|
|
588
|
+
const controlPoint = [...e.controlPoint] as Position3d;
|
|
589
|
+
return { lastPointerPosition: [...e.pointerPosition] as Position2d, lastControlPoint: controlPoint, type: "extrudedRectangle" as SketchType, controlPoints: [controlPoint] };
|
|
590
|
+
}),
|
|
591
|
+
editExtrudedRectangle: assign(({ event }) => {
|
|
592
|
+
const e = event as Extract<EventObject, { type: "EDIT_EXTRUDED_RECTANGLE" }>;
|
|
593
|
+
return { lastControlPoint: undefined, type: "extrudedRectangle" as SketchType, controlPoints: e.controlPoints };
|
|
594
|
+
}),
|
|
595
|
+
createExtrudedPolygon: assign(({ event }) => {
|
|
596
|
+
const e = event as Extract<EventObject, { type: "EXTRUDED_POLYGON" }>;
|
|
597
|
+
const controlPoint = [...e.controlPoint] as Position3d;
|
|
598
|
+
return { lastPointerPosition: [...e.pointerPosition] as Position2d, lastControlPoint: controlPoint, type: "extrudedPolygon" as SketchType, controlPoints: [controlPoint] };
|
|
599
|
+
}),
|
|
600
|
+
editExtrudedPolygon: assign(({ event }) => {
|
|
601
|
+
const e = event as Extract<EventObject, { type: "EDIT_EXTRUDED_POLYGON" }>;
|
|
602
|
+
return { lastControlPoint: undefined, type: "extrudedPolygon" as SketchType, controlPoints: e.controlPoints };
|
|
603
|
+
}),
|
|
604
|
+
pushPosition: assign(({ context, event }) => {
|
|
605
|
+
const e = event as Extract<EventObject, { type: "NEXT" | "EXTRUDE" }>;
|
|
606
|
+
const controlPoint = [...e.controlPoint] as Position3d;
|
|
607
|
+
return {
|
|
608
|
+
lastPointerPosition: [...e.pointerPosition] as Position2d,
|
|
609
|
+
lastControlPoint: controlPoint,
|
|
610
|
+
controlPoints: [...(context.controlPoints ?? []), controlPoint],
|
|
611
|
+
};
|
|
612
|
+
}),
|
|
613
|
+
popPosition: assign(({ context }) => {
|
|
614
|
+
invariant(context.controlPoints != null);
|
|
615
|
+
invariant(context.controlPoints.length > 1);
|
|
616
|
+
return { controlPoints: context.controlPoints.slice(0, -1) };
|
|
617
|
+
}),
|
|
618
|
+
clearDrawing: assign(() => ({
|
|
619
|
+
lastControlPoint: undefined,
|
|
620
|
+
type: undefined,
|
|
621
|
+
controlPoints: undefined,
|
|
622
|
+
catchedControlPointIndex: undefined,
|
|
623
|
+
catchedExtrudedPoint: undefined,
|
|
624
|
+
originalControlPoint: undefined,
|
|
625
|
+
})),
|
|
626
|
+
catchControlPoint: assign(({ event }) => {
|
|
627
|
+
const e = event as Extract<EventObject, { type: "CATCH" }>;
|
|
628
|
+
return { catchedControlPointIndex: e.catchedControlPointIndex, catchedExtrudedPoint: e.catchedExtrudedPoint };
|
|
629
|
+
}),
|
|
630
|
+
moveControlPoint: assign(({ event }) => {
|
|
631
|
+
const e = event as Extract<EventObject, { type: "MOVE" }>;
|
|
632
|
+
return { controlPoints: e.controlPoints };
|
|
633
|
+
}),
|
|
634
|
+
releaseControlPoint: assign(() => ({ catchedControlPointIndex: undefined, catchedExtrudedPoint: undefined })),
|
|
635
|
+
updateControlPoints: assign(({ event }) => {
|
|
636
|
+
const e = event as Extract<EventObject, { type: "UPDATE" }>;
|
|
637
|
+
return { controlPoints: e.controlPoints };
|
|
638
|
+
}),
|
|
639
|
+
recordOriginalControlPoint: assign(({ event }) => {
|
|
640
|
+
const e = event as Extract<EventObject, { type: "NEXT" }>;
|
|
641
|
+
return { originalControlPoint: [...e.controlPoint] as Position3d };
|
|
642
|
+
}),
|
|
673
643
|
},
|
|
674
|
-
);
|
|
644
|
+
});
|
|
675
645
|
}
|
|
676
646
|
|
|
677
647
|
export type SketchMachine = ReturnType<typeof createSketchMachine>;
|