@reearth/core 0.0.7-alpha.62 → 0.0.7-alpha.64

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.
@@ -58,548 +58,620 @@ export interface Context {
58
58
  }
59
59
 
60
60
  export function createSketchMachine() {
61
- return createMachine(
62
- {
63
- id: "sketch",
64
- initial: "idle",
65
- context: {} as Context,
66
- states: {
67
- idle: {
68
- on: {
69
- MARKER: {
70
- target: "drawing.marker",
71
- actions: ["createMarker"],
72
- },
73
- POLYLINE: {
74
- target: "drawing.polyline",
75
- actions: ["createPolyline"],
76
- },
77
- CIRCLE: {
78
- target: "drawing.circle",
79
- actions: ["createCircle"],
80
- },
81
- RECTANGLE: {
82
- target: "drawing.rectangle",
83
- actions: ["createRectangle"],
84
- },
85
- POLYGON: {
86
- target: "drawing.polygon",
87
- actions: ["createPolygon"],
88
- },
89
- EXTRUDED_CIRCLE: {
90
- target: "drawing.circle",
91
- actions: ["createExtrudedCircle"],
92
- },
93
- EXTRUDED_RECTANGLE: {
94
- target: "drawing.extrudedRectangle",
95
- actions: ["createExtrudedRectangle"],
96
- },
97
- EXTRUDED_POLYGON: {
98
- target: "drawing.extrudedPolygon",
99
- actions: ["createExtrudedPolygon"],
100
- },
101
- EDIT_MARKER: {
102
- target: "editing.marker",
103
- actions: ["editMarker"],
104
- },
105
- EDIT_POLYLINE: {
106
- target: "editing.polyline",
107
- actions: ["editPolyline"],
108
- },
109
- EDIT_CIRCLE: {
110
- target: "editing.circle",
111
- actions: ["editCircle"],
112
- },
113
- EDIT_RECTANGLE: {
114
- target: "editing.rectangle",
115
- actions: ["editRectangle"],
116
- },
117
- EDIT_POLYGON: {
118
- target: "editing.polygon",
119
- actions: ["editPolygon"],
120
- },
121
- EDIT_EXTRUDED_CIRCLE: {
122
- target: "editing.circle",
123
- actions: ["editExtrudedCircle"],
124
- },
125
- EDIT_EXTRUDED_RECTANGLE: {
126
- target: "editing.extrudedRectangle",
127
- actions: ["editExtrudedRectangle"],
128
- },
129
- EDIT_EXTRUDED_POLYGON: {
130
- target: "editing.extrudedPolygon",
131
- actions: ["editExtrudedPolygon"],
132
- },
61
+ return createMachine({
62
+ id: "sketch",
63
+ initial: "idle",
64
+ context: {} as Context,
65
+ states: {
66
+ idle: {
67
+ on: {
68
+ MARKER: {
69
+ target: "drawing.marker",
70
+ actions: ["createMarker"],
71
+ },
72
+ POLYLINE: {
73
+ target: "drawing.polyline",
74
+ actions: ["createPolyline"],
75
+ },
76
+ CIRCLE: {
77
+ target: "drawing.circle",
78
+ actions: ["createCircle"],
79
+ },
80
+ RECTANGLE: {
81
+ target: "drawing.rectangle",
82
+ actions: ["createRectangle"],
83
+ },
84
+ POLYGON: {
85
+ target: "drawing.polygon",
86
+ actions: ["createPolygon"],
87
+ },
88
+ EXTRUDED_CIRCLE: {
89
+ target: "drawing.circle",
90
+ actions: ["createExtrudedCircle"],
91
+ },
92
+ EXTRUDED_RECTANGLE: {
93
+ target: "drawing.extrudedRectangle",
94
+ actions: ["createExtrudedRectangle"],
95
+ },
96
+ EXTRUDED_POLYGON: {
97
+ target: "drawing.extrudedPolygon",
98
+ actions: ["createExtrudedPolygon"],
99
+ },
100
+ EDIT_MARKER: {
101
+ target: "editing.marker",
102
+ actions: ["editMarker"],
103
+ },
104
+ EDIT_POLYLINE: {
105
+ target: "editing.polyline",
106
+ actions: ["editPolyline"],
107
+ },
108
+ EDIT_CIRCLE: {
109
+ target: "editing.circle",
110
+ actions: ["editCircle"],
111
+ },
112
+ EDIT_RECTANGLE: {
113
+ target: "editing.rectangle",
114
+ actions: ["editRectangle"],
115
+ },
116
+ EDIT_POLYGON: {
117
+ target: "editing.polygon",
118
+ actions: ["editPolygon"],
119
+ },
120
+ EDIT_EXTRUDED_CIRCLE: {
121
+ target: "editing.circle",
122
+ actions: ["editExtrudedCircle"],
123
+ },
124
+ EDIT_EXTRUDED_RECTANGLE: {
125
+ target: "editing.extrudedRectangle",
126
+ actions: ["editExtrudedRectangle"],
127
+ },
128
+ EDIT_EXTRUDED_POLYGON: {
129
+ target: "editing.extrudedPolygon",
130
+ actions: ["editExtrudedPolygon"],
133
131
  },
134
132
  },
135
- drawing: {
136
- initial: "marker",
137
- states: {
138
- marker: {
139
- initial: "vertex",
140
- states: {
141
- vertex: {},
142
- },
143
- },
144
- polyline: {
145
- initial: "vertex",
146
- states: {
147
- vertex: {
148
- on: {
149
- NEXT: {
150
- target: "vertex",
151
- reenter: false,
152
- actions: ["pushPosition"],
153
- },
154
- },
155
- },
156
- },
157
- },
158
- circle: {
159
- initial: "vertex",
160
- states: {
161
- vertex: {
162
- on: {
163
- NEXT: {
164
- target: "#sketch.extruding",
165
- actions: ["pushPosition"],
166
- },
167
- },
168
- },
169
- },
133
+ },
134
+ drawing: {
135
+ initial: "marker",
136
+ states: {
137
+ marker: {
138
+ initial: "vertex",
139
+ states: {
140
+ vertex: {},
170
141
  },
171
- rectangle: {
172
- initial: "vertex",
173
- states: {
174
- vertex: {
175
- on: {
176
- NEXT: [
177
- {
178
- target: "vertex",
179
- reenter: false,
180
- actions: ["pushPosition"],
181
- },
182
- ],
142
+ },
143
+ polyline: {
144
+ initial: "vertex",
145
+ states: {
146
+ vertex: {
147
+ on: {
148
+ NEXT: {
149
+ target: "vertex",
150
+ reenter: false,
151
+ actions: ["pushPosition"],
183
152
  },
184
153
  },
185
154
  },
186
155
  },
187
- extrudedRectangle: {
188
- initial: "vertex",
189
- states: {
190
- vertex: {
191
- on: {
192
- NEXT: [
193
- {
194
- target: "#sketch.extruding",
195
- guard: "willRectangleComplete",
196
- actions: ["pushPosition", "recordOriginalControlPoint"],
197
- },
198
- {
199
- target: "vertex",
200
- reenter: false,
201
- actions: ["pushPosition"],
202
- },
203
- ],
156
+ },
157
+ circle: {
158
+ initial: "vertex",
159
+ states: {
160
+ vertex: {
161
+ on: {
162
+ NEXT: {
163
+ target: "#sketch.extruding",
164
+ actions: ["pushPosition"],
204
165
  },
205
166
  },
206
167
  },
207
168
  },
208
- polygon: {
209
- initial: "vertex",
210
- states: {
211
- vertex: {
212
- on: {
213
- NEXT: {
169
+ },
170
+ rectangle: {
171
+ initial: "vertex",
172
+ states: {
173
+ vertex: {
174
+ on: {
175
+ NEXT: [
176
+ {
214
177
  target: "vertex",
215
178
  reenter: false,
216
179
  actions: ["pushPosition"],
217
180
  },
218
- },
181
+ ],
219
182
  },
220
183
  },
221
184
  },
222
- extrudedPolygon: {
223
- initial: "vertex",
224
- states: {
225
- vertex: {
226
- on: {
227
- NEXT: {
185
+ },
186
+ extrudedRectangle: {
187
+ initial: "vertex",
188
+ states: {
189
+ vertex: {
190
+ on: {
191
+ NEXT: [
192
+ {
193
+ target: "#sketch.extruding",
194
+ guard: "willRectangleComplete",
195
+ actions: ["pushPosition", "recordOriginalControlPoint"],
196
+ },
197
+ {
228
198
  target: "vertex",
229
199
  reenter: false,
230
200
  actions: ["pushPosition"],
231
201
  },
232
- EXTRUDE: {
233
- target: "#sketch.extruding",
234
- actions: ["pushPosition"],
235
- },
236
- },
202
+ ],
237
203
  },
238
204
  },
239
205
  },
240
- history: {
241
- type: "history",
242
- },
243
206
  },
244
- on: {
245
- CANCEL: [
246
- {
247
- target: ".history",
248
- guard: "canPopPosition",
249
- actions: ["popPosition"],
250
- },
251
- {
252
- target: "idle",
253
- actions: ["clearDrawing"],
207
+ polygon: {
208
+ initial: "vertex",
209
+ states: {
210
+ vertex: {
211
+ on: {
212
+ NEXT: {
213
+ target: "vertex",
214
+ reenter: false,
215
+ actions: ["pushPosition"],
216
+ },
217
+ },
254
218
  },
255
- ],
256
- ABORT: {
257
- target: "idle",
258
- actions: ["clearDrawing"],
259
219
  },
260
- CREATE: {
261
- target: "idle",
262
- actions: ["clearDrawing"],
220
+ },
221
+ extrudedPolygon: {
222
+ initial: "vertex",
223
+ states: {
224
+ vertex: {
225
+ on: {
226
+ NEXT: {
227
+ target: "vertex",
228
+ reenter: false,
229
+ actions: ["pushPosition"],
230
+ },
231
+ EXTRUDE: {
232
+ target: "#sketch.extruding",
233
+ actions: ["pushPosition"],
234
+ },
235
+ },
236
+ },
263
237
  },
264
238
  },
239
+ history: {
240
+ type: "history",
241
+ },
265
242
  },
266
- extruding: {
267
- on: {
268
- CREATE: {
269
- target: "idle",
270
- actions: ["clearDrawing"],
271
- },
272
- CANCEL: {
273
- target: "drawing.history",
243
+ on: {
244
+ CANCEL: [
245
+ {
246
+ target: ".history",
247
+ guard: "canPopPosition",
274
248
  actions: ["popPosition"],
275
249
  },
276
- ABORT: {
250
+ {
277
251
  target: "idle",
278
252
  actions: ["clearDrawing"],
279
253
  },
254
+ ],
255
+ ABORT: {
256
+ target: "idle",
257
+ actions: ["clearDrawing"],
258
+ },
259
+ CREATE: {
260
+ target: "idle",
261
+ actions: ["clearDrawing"],
280
262
  },
281
263
  },
282
- editing: {
283
- initial: "marker",
284
- states: {
285
- marker: {
286
- initial: "waiting",
287
- states: {
288
- waiting: {
289
- on: {
290
- CATCH: {
291
- target: "moving",
292
- reenter: false,
293
- actions: ["catchControlPoint"],
294
- },
264
+ },
265
+ extruding: {
266
+ on: {
267
+ CREATE: {
268
+ target: "idle",
269
+ actions: ["clearDrawing"],
270
+ },
271
+ CANCEL: {
272
+ target: "drawing.history",
273
+ actions: ["popPosition"],
274
+ },
275
+ ABORT: {
276
+ target: "idle",
277
+ actions: ["clearDrawing"],
278
+ },
279
+ },
280
+ },
281
+ editing: {
282
+ initial: "marker",
283
+ states: {
284
+ marker: {
285
+ initial: "waiting",
286
+ states: {
287
+ waiting: {
288
+ on: {
289
+ CATCH: {
290
+ target: "moving",
291
+ reenter: false,
292
+ actions: ["catchControlPoint"],
295
293
  },
296
294
  },
297
- moving: {
298
- on: {
299
- MOVE: {
300
- target: "moving",
301
- reenter: false,
302
- actions: ["moveControlPoint"],
303
- },
304
- RELEASE: {
305
- target: "waiting",
306
- actions: ["releaseControlPoint"],
307
- },
295
+ },
296
+ moving: {
297
+ on: {
298
+ MOVE: {
299
+ target: "moving",
300
+ reenter: false,
301
+ actions: ["moveControlPoint"],
302
+ },
303
+ RELEASE: {
304
+ target: "waiting",
305
+ actions: ["releaseControlPoint"],
308
306
  },
309
307
  },
310
308
  },
311
309
  },
312
- polyline: {
313
- initial: "waiting",
314
- states: {
315
- waiting: {
316
- on: {
317
- CATCH: {
318
- target: "moving",
319
- reenter: false,
320
- actions: ["catchControlPoint"],
321
- },
322
- UPDATE: {
323
- target: "waiting",
324
- reenter: false,
325
- actions: ["updateControlPoints"],
326
- },
310
+ },
311
+ polyline: {
312
+ initial: "waiting",
313
+ states: {
314
+ waiting: {
315
+ on: {
316
+ CATCH: {
317
+ target: "moving",
318
+ reenter: false,
319
+ actions: ["catchControlPoint"],
320
+ },
321
+ UPDATE: {
322
+ target: "waiting",
323
+ reenter: false,
324
+ actions: ["updateControlPoints"],
327
325
  },
328
326
  },
329
- moving: {
330
- on: {
331
- MOVE: {
332
- target: "moving",
333
- reenter: false,
334
- actions: ["moveControlPoint"],
335
- },
336
- RELEASE: {
337
- target: "waiting",
338
- actions: ["releaseControlPoint"],
339
- },
327
+ },
328
+ moving: {
329
+ on: {
330
+ MOVE: {
331
+ target: "moving",
332
+ reenter: false,
333
+ actions: ["moveControlPoint"],
334
+ },
335
+ RELEASE: {
336
+ target: "waiting",
337
+ actions: ["releaseControlPoint"],
340
338
  },
341
339
  },
342
340
  },
343
341
  },
344
- circle: {
345
- initial: "waiting",
346
- states: {
347
- waiting: {
348
- on: {
349
- CATCH: {
350
- target: "moving",
351
- reenter: false,
352
- actions: ["catchControlPoint"],
353
- },
342
+ },
343
+ circle: {
344
+ initial: "waiting",
345
+ states: {
346
+ waiting: {
347
+ on: {
348
+ CATCH: {
349
+ target: "moving",
350
+ reenter: false,
351
+ actions: ["catchControlPoint"],
354
352
  },
355
353
  },
356
- moving: {
357
- on: {
358
- MOVE: {
359
- target: "moving",
360
- reenter: false,
361
- actions: ["moveControlPoint"],
362
- },
363
- RELEASE: {
364
- target: "waiting",
365
- actions: ["releaseControlPoint"],
366
- },
354
+ },
355
+ moving: {
356
+ on: {
357
+ MOVE: {
358
+ target: "moving",
359
+ reenter: false,
360
+ actions: ["moveControlPoint"],
361
+ },
362
+ RELEASE: {
363
+ target: "waiting",
364
+ actions: ["releaseControlPoint"],
367
365
  },
368
366
  },
369
367
  },
370
368
  },
371
- rectangle: {
372
- initial: "waiting",
373
- states: {
374
- waiting: {
375
- on: {
376
- CATCH: {
377
- target: "moving",
378
- reenter: false,
379
- actions: ["catchControlPoint"],
380
- },
369
+ },
370
+ rectangle: {
371
+ initial: "waiting",
372
+ states: {
373
+ waiting: {
374
+ on: {
375
+ CATCH: {
376
+ target: "moving",
377
+ reenter: false,
378
+ actions: ["catchControlPoint"],
381
379
  },
382
380
  },
383
- moving: {
384
- on: {
385
- MOVE: {
386
- target: "moving",
387
- reenter: false,
388
- actions: ["moveControlPoint"],
389
- },
390
- RELEASE: {
391
- target: "waiting",
392
- actions: ["releaseControlPoint"],
393
- },
381
+ },
382
+ moving: {
383
+ on: {
384
+ MOVE: {
385
+ target: "moving",
386
+ reenter: false,
387
+ actions: ["moveControlPoint"],
388
+ },
389
+ RELEASE: {
390
+ target: "waiting",
391
+ actions: ["releaseControlPoint"],
394
392
  },
395
393
  },
396
394
  },
397
395
  },
398
- polygon: {
399
- initial: "waiting",
400
- states: {
401
- waiting: {
402
- on: {
403
- CATCH: {
404
- target: "moving",
405
- reenter: false,
406
- actions: ["catchControlPoint"],
407
- },
408
- UPDATE: {
409
- target: "waiting",
410
- reenter: false,
411
- actions: ["updateControlPoints"],
412
- },
396
+ },
397
+ polygon: {
398
+ initial: "waiting",
399
+ states: {
400
+ waiting: {
401
+ on: {
402
+ CATCH: {
403
+ target: "moving",
404
+ reenter: false,
405
+ actions: ["catchControlPoint"],
406
+ },
407
+ UPDATE: {
408
+ target: "waiting",
409
+ reenter: false,
410
+ actions: ["updateControlPoints"],
413
411
  },
414
412
  },
415
- moving: {
416
- on: {
417
- MOVE: {
418
- target: "moving",
419
- reenter: false,
420
- actions: ["moveControlPoint"],
421
- },
422
- RELEASE: {
423
- target: "waiting",
424
- actions: ["releaseControlPoint"],
425
- },
413
+ },
414
+ moving: {
415
+ on: {
416
+ MOVE: {
417
+ target: "moving",
418
+ reenter: false,
419
+ actions: ["moveControlPoint"],
420
+ },
421
+ RELEASE: {
422
+ target: "waiting",
423
+ actions: ["releaseControlPoint"],
426
424
  },
427
425
  },
428
426
  },
429
427
  },
430
- extrudedCircle: {
431
- initial: "waiting",
432
- states: {
433
- waiting: {
434
- on: {
435
- CATCH: {
436
- target: "moving",
437
- reenter: false,
438
- actions: ["catchControlPoint"],
439
- },
428
+ },
429
+ extrudedCircle: {
430
+ initial: "waiting",
431
+ states: {
432
+ waiting: {
433
+ on: {
434
+ CATCH: {
435
+ target: "moving",
436
+ reenter: false,
437
+ actions: ["catchControlPoint"],
440
438
  },
441
439
  },
442
- moving: {
443
- on: {
444
- MOVE: {
445
- target: "moving",
446
- reenter: false,
447
- actions: ["moveControlPoint"],
448
- },
449
- RELEASE: {
450
- target: "waiting",
451
- actions: ["releaseControlPoint"],
452
- },
440
+ },
441
+ moving: {
442
+ on: {
443
+ MOVE: {
444
+ target: "moving",
445
+ reenter: false,
446
+ actions: ["moveControlPoint"],
447
+ },
448
+ RELEASE: {
449
+ target: "waiting",
450
+ actions: ["releaseControlPoint"],
453
451
  },
454
452
  },
455
453
  },
456
454
  },
457
- extrudedRectangle: {
458
- initial: "waiting",
459
- states: {
460
- waiting: {
461
- on: {
462
- CATCH: {
463
- target: "moving",
464
- reenter: false,
465
- actions: ["catchControlPoint"],
466
- },
455
+ },
456
+ extrudedRectangle: {
457
+ initial: "waiting",
458
+ states: {
459
+ waiting: {
460
+ on: {
461
+ CATCH: {
462
+ target: "moving",
463
+ reenter: false,
464
+ actions: ["catchControlPoint"],
467
465
  },
468
466
  },
469
- moving: {
470
- on: {
471
- MOVE: {
472
- target: "moving",
473
- reenter: false,
474
- actions: ["moveControlPoint"],
475
- },
476
- RELEASE: {
477
- target: "waiting",
478
- actions: ["releaseControlPoint"],
479
- },
467
+ },
468
+ moving: {
469
+ on: {
470
+ MOVE: {
471
+ target: "moving",
472
+ reenter: false,
473
+ actions: ["moveControlPoint"],
474
+ },
475
+ RELEASE: {
476
+ target: "waiting",
477
+ actions: ["releaseControlPoint"],
480
478
  },
481
479
  },
482
480
  },
483
481
  },
484
- extrudedPolygon: {
485
- initial: "waiting",
486
- states: {
487
- waiting: {
488
- on: {
489
- CATCH: {
490
- target: "moving",
491
- reenter: false,
492
- actions: ["catchControlPoint"],
493
- },
494
- UPDATE: {
495
- target: "waiting",
496
- reenter: false,
497
- actions: ["updateControlPoints"],
498
- },
482
+ },
483
+ extrudedPolygon: {
484
+ initial: "waiting",
485
+ states: {
486
+ waiting: {
487
+ on: {
488
+ CATCH: {
489
+ target: "moving",
490
+ reenter: false,
491
+ actions: ["catchControlPoint"],
492
+ },
493
+ UPDATE: {
494
+ target: "waiting",
495
+ reenter: false,
496
+ actions: ["updateControlPoints"],
499
497
  },
500
498
  },
501
- moving: {
502
- on: {
503
- MOVE: {
504
- target: "moving",
505
- reenter: false,
506
- actions: ["moveControlPoint"],
507
- },
508
- RELEASE: {
509
- target: "waiting",
510
- actions: ["releaseControlPoint"],
511
- },
499
+ },
500
+ moving: {
501
+ on: {
502
+ MOVE: {
503
+ target: "moving",
504
+ reenter: false,
505
+ actions: ["moveControlPoint"],
506
+ },
507
+ RELEASE: {
508
+ target: "waiting",
509
+ actions: ["releaseControlPoint"],
512
510
  },
513
511
  },
514
512
  },
515
513
  },
516
514
  },
517
- on: {
518
- EXIT_EDIT: {
519
- target: "idle",
520
- actions: ["clearDrawing"],
521
- },
515
+ },
516
+ on: {
517
+ EXIT_EDIT: {
518
+ target: "idle",
519
+ actions: ["clearDrawing"],
522
520
  },
523
521
  },
524
522
  },
525
523
  },
526
- ).provide({
524
+ }).provide({
527
525
  guards: {
528
- canPopPosition: ({ context }) => context.controlPoints != null && context.controlPoints.length > 1,
529
- willRectangleComplete: ({ context }) => context.controlPoints != null && context.controlPoints.length === 2,
526
+ canPopPosition: ({ context }) =>
527
+ context.controlPoints != null && context.controlPoints.length > 1,
528
+ willRectangleComplete: ({ context }) =>
529
+ context.controlPoints != null && context.controlPoints.length === 2,
530
530
  },
531
531
  actions: {
532
532
  createMarker: assign(({ event }) => {
533
533
  const e = event as Extract<EventObject, { type: "MARKER" }>;
534
534
  const controlPoint = [...e.controlPoint] as Position3d;
535
- return { lastPointerPosition: [...e.pointerPosition] as Position2d, lastControlPoint: controlPoint, type: "marker" as SketchType, controlPoints: [controlPoint] };
535
+ return {
536
+ lastPointerPosition: [...e.pointerPosition] as Position2d,
537
+ lastControlPoint: controlPoint,
538
+ type: "marker" as SketchType,
539
+ controlPoints: [controlPoint],
540
+ };
536
541
  }),
537
542
  editMarker: assign(({ event }) => {
538
543
  const e = event as Extract<EventObject, { type: "EDIT_MARKER" }>;
539
- return { lastControlPoint: undefined, type: "marker" as SketchType, controlPoints: e.controlPoints };
544
+ return {
545
+ lastControlPoint: undefined,
546
+ type: "marker" as SketchType,
547
+ controlPoints: e.controlPoints,
548
+ };
540
549
  }),
541
550
  createPolyline: assign(({ event }) => {
542
551
  const e = event as Extract<EventObject, { type: "POLYLINE" }>;
543
552
  const controlPoint = [...e.controlPoint] as Position3d;
544
- return { lastPointerPosition: [...e.pointerPosition] as Position2d, lastControlPoint: controlPoint, type: "polyline" as SketchType, controlPoints: [controlPoint] };
553
+ return {
554
+ lastPointerPosition: [...e.pointerPosition] as Position2d,
555
+ lastControlPoint: controlPoint,
556
+ type: "polyline" as SketchType,
557
+ controlPoints: [controlPoint],
558
+ };
545
559
  }),
546
560
  editPolyline: assign(({ event }) => {
547
561
  const e = event as Extract<EventObject, { type: "EDIT_POLYLINE" }>;
548
- return { lastControlPoint: undefined, type: "polyline" as SketchType, controlPoints: e.controlPoints };
562
+ return {
563
+ lastControlPoint: undefined,
564
+ type: "polyline" as SketchType,
565
+ controlPoints: e.controlPoints,
566
+ };
549
567
  }),
550
568
  createCircle: assign(({ event }) => {
551
569
  const e = event as Extract<EventObject, { type: "CIRCLE" }>;
552
570
  const controlPoint = [...e.controlPoint] as Position3d;
553
- return { lastPointerPosition: [...e.pointerPosition] as Position2d, lastControlPoint: controlPoint, type: "circle" as SketchType, controlPoints: [controlPoint] };
571
+ return {
572
+ lastPointerPosition: [...e.pointerPosition] as Position2d,
573
+ lastControlPoint: controlPoint,
574
+ type: "circle" as SketchType,
575
+ controlPoints: [controlPoint],
576
+ };
554
577
  }),
555
578
  editCircle: assign(({ event }) => {
556
579
  const e = event as Extract<EventObject, { type: "EDIT_CIRCLE" }>;
557
- return { lastControlPoint: undefined, type: "circle" as SketchType, controlPoints: e.controlPoints };
580
+ return {
581
+ lastControlPoint: undefined,
582
+ type: "circle" as SketchType,
583
+ controlPoints: e.controlPoints,
584
+ };
558
585
  }),
559
586
  createRectangle: assign(({ event }) => {
560
587
  const e = event as Extract<EventObject, { type: "RECTANGLE" }>;
561
588
  const controlPoint = [...e.controlPoint] as Position3d;
562
- return { lastPointerPosition: [...e.pointerPosition] as Position2d, lastControlPoint: controlPoint, type: "rectangle" as SketchType, controlPoints: [controlPoint] };
589
+ return {
590
+ lastPointerPosition: [...e.pointerPosition] as Position2d,
591
+ lastControlPoint: controlPoint,
592
+ type: "rectangle" as SketchType,
593
+ controlPoints: [controlPoint],
594
+ };
563
595
  }),
564
596
  editRectangle: assign(({ event }) => {
565
597
  const e = event as Extract<EventObject, { type: "EDIT_RECTANGLE" }>;
566
- return { lastControlPoint: undefined, type: "rectangle" as SketchType, controlPoints: e.controlPoints };
598
+ return {
599
+ lastControlPoint: undefined,
600
+ type: "rectangle" as SketchType,
601
+ controlPoints: e.controlPoints,
602
+ };
567
603
  }),
568
604
  createPolygon: assign(({ event }) => {
569
605
  const e = event as Extract<EventObject, { type: "POLYGON" }>;
570
606
  const controlPoint = [...e.controlPoint] as Position3d;
571
- return { lastPointerPosition: [...e.pointerPosition] as Position2d, lastControlPoint: controlPoint, type: "polygon" as SketchType, controlPoints: [controlPoint] };
607
+ return {
608
+ lastPointerPosition: [...e.pointerPosition] as Position2d,
609
+ lastControlPoint: controlPoint,
610
+ type: "polygon" as SketchType,
611
+ controlPoints: [controlPoint],
612
+ };
572
613
  }),
573
614
  editPolygon: assign(({ event }) => {
574
615
  const e = event as Extract<EventObject, { type: "EDIT_POLYGON" }>;
575
- return { lastControlPoint: undefined, type: "polygon" as SketchType, controlPoints: e.controlPoints };
616
+ return {
617
+ lastControlPoint: undefined,
618
+ type: "polygon" as SketchType,
619
+ controlPoints: e.controlPoints,
620
+ };
576
621
  }),
577
622
  createExtrudedCircle: assign(({ event }) => {
578
623
  const e = event as Extract<EventObject, { type: "EXTRUDED_CIRCLE" }>;
579
624
  const controlPoint = [...e.controlPoint] as Position3d;
580
- return { lastPointerPosition: [...e.pointerPosition] as Position2d, lastControlPoint: controlPoint, type: "extrudedCircle" as SketchType, controlPoints: [controlPoint] };
625
+ return {
626
+ lastPointerPosition: [...e.pointerPosition] as Position2d,
627
+ lastControlPoint: controlPoint,
628
+ type: "extrudedCircle" as SketchType,
629
+ controlPoints: [controlPoint],
630
+ };
581
631
  }),
582
632
  editExtrudedCircle: assign(({ event }) => {
583
633
  const e = event as Extract<EventObject, { type: "EDIT_EXTRUDED_CIRCLE" }>;
584
- return { lastControlPoint: undefined, type: "extrudedCircle" as SketchType, controlPoints: e.controlPoints };
634
+ return {
635
+ lastControlPoint: undefined,
636
+ type: "extrudedCircle" as SketchType,
637
+ controlPoints: e.controlPoints,
638
+ };
585
639
  }),
586
640
  createExtrudedRectangle: assign(({ event }) => {
587
641
  const e = event as Extract<EventObject, { type: "EXTRUDED_RECTANGLE" }>;
588
642
  const controlPoint = [...e.controlPoint] as Position3d;
589
- return { lastPointerPosition: [...e.pointerPosition] as Position2d, lastControlPoint: controlPoint, type: "extrudedRectangle" as SketchType, controlPoints: [controlPoint] };
643
+ return {
644
+ lastPointerPosition: [...e.pointerPosition] as Position2d,
645
+ lastControlPoint: controlPoint,
646
+ type: "extrudedRectangle" as SketchType,
647
+ controlPoints: [controlPoint],
648
+ };
590
649
  }),
591
650
  editExtrudedRectangle: assign(({ event }) => {
592
651
  const e = event as Extract<EventObject, { type: "EDIT_EXTRUDED_RECTANGLE" }>;
593
- return { lastControlPoint: undefined, type: "extrudedRectangle" as SketchType, controlPoints: e.controlPoints };
652
+ return {
653
+ lastControlPoint: undefined,
654
+ type: "extrudedRectangle" as SketchType,
655
+ controlPoints: e.controlPoints,
656
+ };
594
657
  }),
595
658
  createExtrudedPolygon: assign(({ event }) => {
596
659
  const e = event as Extract<EventObject, { type: "EXTRUDED_POLYGON" }>;
597
660
  const controlPoint = [...e.controlPoint] as Position3d;
598
- return { lastPointerPosition: [...e.pointerPosition] as Position2d, lastControlPoint: controlPoint, type: "extrudedPolygon" as SketchType, controlPoints: [controlPoint] };
661
+ return {
662
+ lastPointerPosition: [...e.pointerPosition] as Position2d,
663
+ lastControlPoint: controlPoint,
664
+ type: "extrudedPolygon" as SketchType,
665
+ controlPoints: [controlPoint],
666
+ };
599
667
  }),
600
668
  editExtrudedPolygon: assign(({ event }) => {
601
669
  const e = event as Extract<EventObject, { type: "EDIT_EXTRUDED_POLYGON" }>;
602
- return { lastControlPoint: undefined, type: "extrudedPolygon" as SketchType, controlPoints: e.controlPoints };
670
+ return {
671
+ lastControlPoint: undefined,
672
+ type: "extrudedPolygon" as SketchType,
673
+ controlPoints: e.controlPoints,
674
+ };
603
675
  }),
604
676
  pushPosition: assign(({ context, event }) => {
605
677
  const e = event as Extract<EventObject, { type: "NEXT" | "EXTRUDE" }>;
@@ -625,13 +697,19 @@ export function createSketchMachine() {
625
697
  })),
626
698
  catchControlPoint: assign(({ event }) => {
627
699
  const e = event as Extract<EventObject, { type: "CATCH" }>;
628
- return { catchedControlPointIndex: e.catchedControlPointIndex, catchedExtrudedPoint: e.catchedExtrudedPoint };
700
+ return {
701
+ catchedControlPointIndex: e.catchedControlPointIndex,
702
+ catchedExtrudedPoint: e.catchedExtrudedPoint,
703
+ };
629
704
  }),
630
705
  moveControlPoint: assign(({ event }) => {
631
706
  const e = event as Extract<EventObject, { type: "MOVE" }>;
632
707
  return { controlPoints: e.controlPoints };
633
708
  }),
634
- releaseControlPoint: assign(() => ({ catchedControlPointIndex: undefined, catchedExtrudedPoint: undefined })),
709
+ releaseControlPoint: assign(() => ({
710
+ catchedControlPointIndex: undefined,
711
+ catchedExtrudedPoint: undefined,
712
+ })),
635
713
  updateControlPoints: assign(({ event }) => {
636
714
  const e = event as Extract<EventObject, { type: "UPDATE" }>;
637
715
  return { controlPoints: e.controlPoints };