@reearth/core 0.0.7-alpha.5 → 0.0.7-alpha.50
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 +58676 -51066
- package/dist/core.umd.cjs +3959 -3915
- package/dist/{index-DqatWUTw.js → index-DqGWVPtz.js} +0 -1
- package/dist/index.d.ts +150 -34
- package/package.json +55 -39
- package/src/Map/ClusteredLayers/index.tsx +1 -1
- package/src/Map/Geoid/index.tsx +68 -0
- package/src/Map/Geoid/types.ts +8 -0
- package/src/Map/Layer/hooks.ts +7 -4
- package/src/Map/Layer/index.tsx +3 -1
- package/src/Map/Layers/hooks.ts +19 -2
- package/src/Map/Layers/index.tsx +13 -2
- package/src/Map/Layers/keys.ts +1 -0
- package/src/Map/Sketch/hooks.ts +453 -410
- package/src/Map/Sketch/index.tsx +67 -20
- package/src/Map/Sketch/sketchMachine.ts +359 -4
- package/src/Map/Sketch/sketchMachine.typegen.ts +58 -1
- package/src/Map/Sketch/types.ts +10 -20
- package/src/Map/Sketch/usePluginSketchLayer.ts +105 -0
- package/src/Map/Sketch/useSketch.ts +559 -0
- package/src/Map/Sketch/useSketchFeature.ts +198 -0
- package/src/Map/SpatialId/constants.ts +21 -0
- package/src/Map/SpatialId/hooks.ts +448 -0
- package/src/Map/SpatialId/index.tsx +63 -0
- package/src/Map/SpatialId/types.ts +68 -0
- package/src/Map/SpatialId/utils.ts +65 -0
- package/src/Map/hooks.ts +54 -8
- package/src/Map/index.tsx +41 -8
- package/src/Map/ref.ts +32 -3
- package/src/Map/types/index.ts +39 -3
- package/src/Map/types/viewerProperty.ts +10 -0
- package/src/Map/useTimelineManager.ts +2 -2
- package/src/Map/utils.ts +1 -1
- package/src/Visualizer/context.tsx +5 -5
- package/src/Visualizer/coreContext.tsx +2 -0
- package/src/Visualizer/hooks.ts +54 -20
- package/src/Visualizer/index.tsx +22 -3
- package/src/Visualizer/interactionMode.ts +2 -1
- package/src/Visualizer/useViewport.ts +1 -1
- package/src/engines/Cesium/Feature/Box/hooks/box.ts +4 -4
- package/src/engines/Cesium/Feature/HeatMap/HeatmapMesh.tsx +1 -1
- package/src/engines/Cesium/Feature/Model/index.tsx +3 -3
- package/src/engines/Cesium/Feature/PhotoOverlay/hooks.ts +1 -1
- package/src/engines/Cesium/Feature/PhotoOverlay/index.tsx +3 -1
- package/src/engines/Cesium/Feature/Polygon/index.tsx +6 -4
- package/src/engines/Cesium/Feature/Raster/mvt.ts +2 -1
- package/src/engines/Cesium/Feature/Resource/utils.ts +86 -91
- package/src/engines/Cesium/Feature/Tileset/hooks.ts +135 -70
- package/src/engines/Cesium/Feature/Tileset/index.tsx +1 -1
- package/src/engines/Cesium/Feature/Tileset/useClippingBox.ts +2 -2
- package/src/engines/Cesium/Feature/context.ts +1 -0
- package/src/engines/Cesium/Feature/index.tsx +7 -3
- package/src/engines/Cesium/Feature/utils.tsx +18 -7
- package/src/engines/Cesium/Shaders/OverriddenShaders/GlobeFS/IBL.glsl +6 -10
- package/src/engines/Cesium/Sketch/ControlPoint.tsx +128 -24
- package/src/engines/Cesium/Sketch/ExtrudedControlPoints.tsx +70 -25
- package/src/engines/Cesium/Sketch/ExtrudedMeasurement.tsx +3 -1
- package/src/engines/Cesium/Sketch/ExtrudedPolygonEntity.tsx +14 -14
- package/src/engines/Cesium/Sketch/PolylineEntity.tsx +7 -4
- package/src/engines/Cesium/Sketch/SurfaceAddingPoints.tsx +60 -0
- package/src/engines/Cesium/Sketch/SurfaceControlPoints.tsx +125 -35
- package/src/engines/Cesium/Sketch/constants.ts +5 -0
- package/src/engines/Cesium/Sketch/index.tsx +68 -29
- package/src/engines/Cesium/SpatialId/CoordinateIndicator.tsx +28 -0
- package/src/engines/Cesium/SpatialId/SpatialIdSpace.tsx +33 -0
- package/src/engines/Cesium/SpatialId/VerticalSpaceIndicator.tsx +32 -0
- package/src/engines/Cesium/SpatialId/index.ts +3 -0
- package/src/engines/Cesium/common.ts +52 -16
- package/src/engines/Cesium/core/Clock.tsx +1 -1
- package/src/engines/Cesium/core/Globe/index.tsx +73 -0
- package/src/engines/Cesium/core/Globe/useTerrainProviderPromise.ts +79 -0
- package/src/engines/Cesium/core/Imagery.test.ts +29 -11
- package/src/engines/Cesium/core/Imagery.tsx +22 -6
- package/src/engines/Cesium/core/Indicator/Indicator.tsx +1 -1
- package/src/engines/Cesium/core/labels/JapanGSIOptimalBVmapVectorMapLabel/JapanGSIOptimalBVmapLabelImagery.tsx +9 -2
- package/src/engines/Cesium/core/labels/JapanGSIOptimalBVmapVectorMapLabel/JapanGSIOptimalBVmapVectorMapLabel.tsx +14 -2
- package/src/engines/Cesium/core/labels/LabelImageryLayers.tsx +10 -1
- package/src/engines/Cesium/core/presets.ts +24 -28
- package/src/engines/Cesium/helpers/getGeometryFromEntity.ts +55 -0
- package/src/engines/Cesium/hooks/useCamera.ts +1 -1
- package/src/engines/Cesium/hooks/useCameraLimiter.ts +1 -1
- package/src/engines/Cesium/hooks/useEngineRef.ts +48 -3
- package/src/engines/Cesium/hooks/useExplicitRender.ts +2 -2
- package/src/engines/Cesium/hooks/useInstance.ts +1 -1
- package/src/engines/Cesium/hooks/useLayerDragDrop.ts +2 -2
- package/src/engines/Cesium/hooks/useLayerSelectWithRect.ts +1 -1
- package/src/engines/Cesium/hooks/useOverrideGlobeShader/useOverrideGlobeShader.ts +98 -52
- package/src/engines/Cesium/hooks/useViewerProperty.ts +1 -1
- package/src/engines/Cesium/hooks.ts +52 -10
- package/src/engines/Cesium/index.tsx +16 -3
- package/src/engines/Cesium/types.ts +1 -1
- package/src/mantle/atoms/compute.ts +8 -3
- package/src/mantle/data/geojson.ts +53 -22
- package/src/mantle/data/shapefile/parseZip.ts +1 -0
- package/src/mantle/evaluator/simple/expression/expression.test.ts +72 -0
- package/src/mantle/evaluator/simple/expression/node.ts +10 -12
- package/src/mantle/types/appearance.ts +4 -2
- package/src/mantle/types/index.ts +3 -0
- package/src/test/utils.tsx +1 -1
- package/src/utils/image.ts +2 -12
- package/src/utils/use-delayed-count.ts +1 -1
- package/src/utils/use-dnd/drop.ts +1 -1
- package/src/utils/util.ts +1 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_0.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_1.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_10.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_11.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_12.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_13.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_14.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_15.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_16.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_17.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_18.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_19.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_2.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_20.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_21.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_22.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_23.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_24.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_25.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_26.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_27.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_3.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_4.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_5.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_6.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_7.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_8.json +0 -1
- package/dist/cesium/Assets/IAU2006_XYS/IAU2006_XYS_9.json +0 -1
- package/dist/cesium/Assets/Images/bing_maps_credit.png +0 -0
- package/dist/cesium/Assets/Images/cesium_credit.png +0 -0
- package/dist/cesium/Assets/Images/google_earth_credit.png +0 -0
- package/dist/cesium/Assets/Images/ion-credit.png +0 -0
- package/dist/cesium/Assets/Textures/LensFlare/DirtMask.jpg +0 -0
- package/dist/cesium/Assets/Textures/LensFlare/StarBurst.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/0/0/0.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/0/1/0.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/1/0/0.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/1/0/1.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/1/1/0.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/1/1/1.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/1/2/0.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/1/2/1.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/1/3/0.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/1/3/1.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/0/0.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/0/1.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/0/2.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/0/3.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/1/0.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/1/1.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/1/2.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/1/3.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/2/0.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/2/1.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/2/2.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/2/3.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/3/0.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/3/1.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/3/2.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/3/3.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/4/0.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/4/1.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/4/2.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/4/3.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/5/0.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/5/1.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/5/2.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/5/3.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/6/0.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/6/1.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/6/2.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/6/3.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/7/0.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/7/1.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/7/2.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/2/7/3.jpg +0 -0
- package/dist/cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml +0 -14
- package/dist/cesium/Assets/Textures/SkyBox/tycho2t3_80_mx.jpg +0 -0
- package/dist/cesium/Assets/Textures/SkyBox/tycho2t3_80_my.jpg +0 -0
- package/dist/cesium/Assets/Textures/SkyBox/tycho2t3_80_mz.jpg +0 -0
- package/dist/cesium/Assets/Textures/SkyBox/tycho2t3_80_px.jpg +0 -0
- package/dist/cesium/Assets/Textures/SkyBox/tycho2t3_80_py.jpg +0 -0
- package/dist/cesium/Assets/Textures/SkyBox/tycho2t3_80_pz.jpg +0 -0
- package/dist/cesium/Assets/Textures/maki/airfield.png +0 -0
- package/dist/cesium/Assets/Textures/maki/airport.png +0 -0
- package/dist/cesium/Assets/Textures/maki/alcohol-shop.png +0 -0
- package/dist/cesium/Assets/Textures/maki/america-football.png +0 -0
- package/dist/cesium/Assets/Textures/maki/art-gallery.png +0 -0
- package/dist/cesium/Assets/Textures/maki/bakery.png +0 -0
- package/dist/cesium/Assets/Textures/maki/bank.png +0 -0
- package/dist/cesium/Assets/Textures/maki/bar.png +0 -0
- package/dist/cesium/Assets/Textures/maki/baseball.png +0 -0
- package/dist/cesium/Assets/Textures/maki/basketball.png +0 -0
- package/dist/cesium/Assets/Textures/maki/beer.png +0 -0
- package/dist/cesium/Assets/Textures/maki/bicycle.png +0 -0
- package/dist/cesium/Assets/Textures/maki/building.png +0 -0
- package/dist/cesium/Assets/Textures/maki/bus.png +0 -0
- package/dist/cesium/Assets/Textures/maki/cafe.png +0 -0
- package/dist/cesium/Assets/Textures/maki/camera.png +0 -0
- package/dist/cesium/Assets/Textures/maki/campsite.png +0 -0
- package/dist/cesium/Assets/Textures/maki/car.png +0 -0
- package/dist/cesium/Assets/Textures/maki/cemetery.png +0 -0
- package/dist/cesium/Assets/Textures/maki/cesium.png +0 -0
- package/dist/cesium/Assets/Textures/maki/chemist.png +0 -0
- package/dist/cesium/Assets/Textures/maki/cinema.png +0 -0
- package/dist/cesium/Assets/Textures/maki/circle-stroked.png +0 -0
- package/dist/cesium/Assets/Textures/maki/circle.png +0 -0
- package/dist/cesium/Assets/Textures/maki/city.png +0 -0
- package/dist/cesium/Assets/Textures/maki/clothing-store.png +0 -0
- package/dist/cesium/Assets/Textures/maki/college.png +0 -0
- package/dist/cesium/Assets/Textures/maki/commercial.png +0 -0
- package/dist/cesium/Assets/Textures/maki/cricket.png +0 -0
- package/dist/cesium/Assets/Textures/maki/cross.png +0 -0
- package/dist/cesium/Assets/Textures/maki/dam.png +0 -0
- package/dist/cesium/Assets/Textures/maki/danger.png +0 -0
- package/dist/cesium/Assets/Textures/maki/disability.png +0 -0
- package/dist/cesium/Assets/Textures/maki/dog-park.png +0 -0
- package/dist/cesium/Assets/Textures/maki/embassy.png +0 -0
- package/dist/cesium/Assets/Textures/maki/emergency-telephone.png +0 -0
- package/dist/cesium/Assets/Textures/maki/entrance.png +0 -0
- package/dist/cesium/Assets/Textures/maki/farm.png +0 -0
- package/dist/cesium/Assets/Textures/maki/fast-food.png +0 -0
- package/dist/cesium/Assets/Textures/maki/ferry.png +0 -0
- package/dist/cesium/Assets/Textures/maki/fire-station.png +0 -0
- package/dist/cesium/Assets/Textures/maki/fuel.png +0 -0
- package/dist/cesium/Assets/Textures/maki/garden.png +0 -0
- package/dist/cesium/Assets/Textures/maki/gift.png +0 -0
- package/dist/cesium/Assets/Textures/maki/golf.png +0 -0
- package/dist/cesium/Assets/Textures/maki/grocery.png +0 -0
- package/dist/cesium/Assets/Textures/maki/hairdresser.png +0 -0
- package/dist/cesium/Assets/Textures/maki/harbor.png +0 -0
- package/dist/cesium/Assets/Textures/maki/heart.png +0 -0
- package/dist/cesium/Assets/Textures/maki/heliport.png +0 -0
- package/dist/cesium/Assets/Textures/maki/hospital.png +0 -0
- package/dist/cesium/Assets/Textures/maki/ice-cream.png +0 -0
- package/dist/cesium/Assets/Textures/maki/industrial.png +0 -0
- package/dist/cesium/Assets/Textures/maki/land-use.png +0 -0
- package/dist/cesium/Assets/Textures/maki/laundry.png +0 -0
- package/dist/cesium/Assets/Textures/maki/library.png +0 -0
- package/dist/cesium/Assets/Textures/maki/lighthouse.png +0 -0
- package/dist/cesium/Assets/Textures/maki/lodging.png +0 -0
- package/dist/cesium/Assets/Textures/maki/logging.png +0 -0
- package/dist/cesium/Assets/Textures/maki/london-underground.png +0 -0
- package/dist/cesium/Assets/Textures/maki/marker-stroked.png +0 -0
- package/dist/cesium/Assets/Textures/maki/marker.png +0 -0
- package/dist/cesium/Assets/Textures/maki/minefield.png +0 -0
- package/dist/cesium/Assets/Textures/maki/mobilephone.png +0 -0
- package/dist/cesium/Assets/Textures/maki/monument.png +0 -0
- package/dist/cesium/Assets/Textures/maki/museum.png +0 -0
- package/dist/cesium/Assets/Textures/maki/music.png +0 -0
- package/dist/cesium/Assets/Textures/maki/oil-well.png +0 -0
- package/dist/cesium/Assets/Textures/maki/park.png +0 -0
- package/dist/cesium/Assets/Textures/maki/park2.png +0 -0
- package/dist/cesium/Assets/Textures/maki/parking-garage.png +0 -0
- package/dist/cesium/Assets/Textures/maki/parking.png +0 -0
- package/dist/cesium/Assets/Textures/maki/pharmacy.png +0 -0
- package/dist/cesium/Assets/Textures/maki/pitch.png +0 -0
- package/dist/cesium/Assets/Textures/maki/place-of-worship.png +0 -0
- package/dist/cesium/Assets/Textures/maki/playground.png +0 -0
- package/dist/cesium/Assets/Textures/maki/police.png +0 -0
- package/dist/cesium/Assets/Textures/maki/polling-place.png +0 -0
- package/dist/cesium/Assets/Textures/maki/post.png +0 -0
- package/dist/cesium/Assets/Textures/maki/prison.png +0 -0
- package/dist/cesium/Assets/Textures/maki/rail-above.png +0 -0
- package/dist/cesium/Assets/Textures/maki/rail-light.png +0 -0
- package/dist/cesium/Assets/Textures/maki/rail-metro.png +0 -0
- package/dist/cesium/Assets/Textures/maki/rail-underground.png +0 -0
- package/dist/cesium/Assets/Textures/maki/rail.png +0 -0
- package/dist/cesium/Assets/Textures/maki/religious-christian.png +0 -0
- package/dist/cesium/Assets/Textures/maki/religious-jewish.png +0 -0
- package/dist/cesium/Assets/Textures/maki/religious-muslim.png +0 -0
- package/dist/cesium/Assets/Textures/maki/restaurant.png +0 -0
- package/dist/cesium/Assets/Textures/maki/roadblock.png +0 -0
- package/dist/cesium/Assets/Textures/maki/rocket.png +0 -0
- package/dist/cesium/Assets/Textures/maki/school.png +0 -0
- package/dist/cesium/Assets/Textures/maki/scooter.png +0 -0
- package/dist/cesium/Assets/Textures/maki/shop.png +0 -0
- package/dist/cesium/Assets/Textures/maki/skiing.png +0 -0
- package/dist/cesium/Assets/Textures/maki/slaughterhouse.png +0 -0
- package/dist/cesium/Assets/Textures/maki/soccer.png +0 -0
- package/dist/cesium/Assets/Textures/maki/square-stroked.png +0 -0
- package/dist/cesium/Assets/Textures/maki/square.png +0 -0
- package/dist/cesium/Assets/Textures/maki/star-stroked.png +0 -0
- package/dist/cesium/Assets/Textures/maki/star.png +0 -0
- package/dist/cesium/Assets/Textures/maki/suitcase.png +0 -0
- package/dist/cesium/Assets/Textures/maki/swimming.png +0 -0
- package/dist/cesium/Assets/Textures/maki/telephone.png +0 -0
- package/dist/cesium/Assets/Textures/maki/tennis.png +0 -0
- package/dist/cesium/Assets/Textures/maki/theatre.png +0 -0
- package/dist/cesium/Assets/Textures/maki/toilets.png +0 -0
- package/dist/cesium/Assets/Textures/maki/town-hall.png +0 -0
- package/dist/cesium/Assets/Textures/maki/town.png +0 -0
- package/dist/cesium/Assets/Textures/maki/triangle-stroked.png +0 -0
- package/dist/cesium/Assets/Textures/maki/triangle.png +0 -0
- package/dist/cesium/Assets/Textures/maki/village.png +0 -0
- package/dist/cesium/Assets/Textures/maki/warehouse.png +0 -0
- package/dist/cesium/Assets/Textures/maki/waste-basket.png +0 -0
- package/dist/cesium/Assets/Textures/maki/water.png +0 -0
- package/dist/cesium/Assets/Textures/maki/wetland.png +0 -0
- package/dist/cesium/Assets/Textures/maki/zoo.png +0 -0
- package/dist/cesium/Assets/Textures/moonSmall.jpg +0 -0
- package/dist/cesium/Assets/Textures/pin.svg +0 -1
- package/dist/cesium/Assets/Textures/waterNormals.jpg +0 -0
- package/dist/cesium/Assets/Textures/waterNormalsSmall.jpg +0 -0
- package/dist/cesium/Assets/approximateTerrainHeights.json +0 -1
- package/dist/cesium/ThirdParty/Workers/package.json +0 -1
- package/dist/cesium/ThirdParty/Workers/pako_deflate.min.js +0 -1
- package/dist/cesium/ThirdParty/Workers/pako_inflate.min.js +0 -1
- package/dist/cesium/ThirdParty/Workers/z-worker-pako.js +0 -1
- package/dist/cesium/ThirdParty/basis_transcoder.wasm +0 -0
- package/dist/cesium/ThirdParty/draco_decoder.wasm +0 -0
- package/dist/cesium/ThirdParty/google-earth-dbroot-parser.js +0 -1
- package/dist/cesium/Widgets/Animation/Animation.css +0 -127
- package/dist/cesium/Widgets/Animation/lighter.css +0 -70
- package/dist/cesium/Widgets/BaseLayerPicker/BaseLayerPicker.css +0 -108
- package/dist/cesium/Widgets/BaseLayerPicker/lighter.css +0 -22
- package/dist/cesium/Widgets/Cesium3DTilesInspector/Cesium3DTilesInspector.css +0 -102
- package/dist/cesium/Widgets/CesiumInspector/CesiumInspector.css +0 -113
- package/dist/cesium/Widgets/CesiumWidget/CesiumWidget.css +0 -124
- package/dist/cesium/Widgets/CesiumWidget/lighter.css +0 -14
- package/dist/cesium/Widgets/FullscreenButton/FullscreenButton.css +0 -8
- package/dist/cesium/Widgets/Geocoder/Geocoder.css +0 -70
- package/dist/cesium/Widgets/Geocoder/lighter.css +0 -17
- package/dist/cesium/Widgets/I3SBuildingSceneLayerExplorer/I3SBuildingSceneLayerExplorer.css +0 -27
- package/dist/cesium/Widgets/Images/ImageryProviders/ArcGisMapServiceWorldHillshade.png +0 -0
- package/dist/cesium/Widgets/Images/ImageryProviders/ArcGisMapServiceWorldImagery.png +0 -0
- package/dist/cesium/Widgets/Images/ImageryProviders/ArcGisMapServiceWorldOcean.png +0 -0
- package/dist/cesium/Widgets/Images/ImageryProviders/bingAerial.png +0 -0
- package/dist/cesium/Widgets/Images/ImageryProviders/bingAerialLabels.png +0 -0
- package/dist/cesium/Widgets/Images/ImageryProviders/bingRoads.png +0 -0
- package/dist/cesium/Widgets/Images/ImageryProviders/blueMarble.png +0 -0
- package/dist/cesium/Widgets/Images/ImageryProviders/earthAtNight.png +0 -0
- package/dist/cesium/Widgets/Images/ImageryProviders/mapQuestOpenStreetMap.png +0 -0
- package/dist/cesium/Widgets/Images/ImageryProviders/mapboxSatellite.png +0 -0
- package/dist/cesium/Widgets/Images/ImageryProviders/mapboxStreets.png +0 -0
- package/dist/cesium/Widgets/Images/ImageryProviders/mapboxTerrain.png +0 -0
- package/dist/cesium/Widgets/Images/ImageryProviders/naturalEarthII.png +0 -0
- package/dist/cesium/Widgets/Images/ImageryProviders/openStreetMap.png +0 -0
- package/dist/cesium/Widgets/Images/ImageryProviders/sentinel-2.png +0 -0
- package/dist/cesium/Widgets/Images/ImageryProviders/stadiaAlidadeSmooth.png +0 -0
- package/dist/cesium/Widgets/Images/ImageryProviders/stadiaAlidadeSmoothDark.png +0 -0
- package/dist/cesium/Widgets/Images/ImageryProviders/stamenToner.png +0 -0
- package/dist/cesium/Widgets/Images/ImageryProviders/stamenWatercolor.png +0 -0
- package/dist/cesium/Widgets/Images/NavigationHelp/Mouse.svg +0 -84
- package/dist/cesium/Widgets/Images/NavigationHelp/MouseLeft.svg +0 -76
- package/dist/cesium/Widgets/Images/NavigationHelp/MouseMiddle.svg +0 -76
- package/dist/cesium/Widgets/Images/NavigationHelp/MouseRight.svg +0 -76
- package/dist/cesium/Widgets/Images/NavigationHelp/Touch.svg +0 -120
- package/dist/cesium/Widgets/Images/NavigationHelp/TouchDrag.svg +0 -129
- package/dist/cesium/Widgets/Images/NavigationHelp/TouchRotate.svg +0 -76
- package/dist/cesium/Widgets/Images/NavigationHelp/TouchTilt.svg +0 -135
- package/dist/cesium/Widgets/Images/NavigationHelp/TouchZoom.svg +0 -74
- package/dist/cesium/Widgets/Images/TerrainProviders/CesiumWorldTerrain.png +0 -0
- package/dist/cesium/Widgets/Images/TerrainProviders/Ellipsoid.png +0 -0
- package/dist/cesium/Widgets/Images/TimelineIcons.png +0 -0
- package/dist/cesium/Widgets/Images/info-loading.gif +0 -0
- package/dist/cesium/Widgets/InfoBox/InfoBox.css +0 -92
- package/dist/cesium/Widgets/InfoBox/InfoBoxDescription.css +0 -178
- package/dist/cesium/Widgets/NavigationHelpButton/NavigationHelpButton.css +0 -93
- package/dist/cesium/Widgets/NavigationHelpButton/lighter.css +0 -38
- package/dist/cesium/Widgets/PerformanceWatchdog/PerformanceWatchdog.css +0 -15
- package/dist/cesium/Widgets/ProjectionPicker/ProjectionPicker.css +0 -38
- package/dist/cesium/Widgets/SceneModePicker/SceneModePicker.css +0 -56
- package/dist/cesium/Widgets/SelectionIndicator/SelectionIndicator.css +0 -20
- package/dist/cesium/Widgets/Timeline/Timeline.css +0 -103
- package/dist/cesium/Widgets/Timeline/lighter.css +0 -23
- package/dist/cesium/Widgets/VRButton/VRButton.css +0 -8
- package/dist/cesium/Widgets/Viewer/Viewer.css +0 -107
- package/dist/cesium/Widgets/VoxelInspector/VoxelInspector.css +0 -16
- package/dist/cesium/Widgets/lighter.css +0 -237
- package/dist/cesium/Widgets/lighterShared.css +0 -46
- package/dist/cesium/Widgets/shared.css +0 -103
- package/dist/cesium/Widgets/widgets.css +0 -1346
- package/dist/cesium/Workers/chunk-2ED5WI77.js +0 -26
- package/dist/cesium/Workers/chunk-2MBPFWCP.js +0 -26
- package/dist/cesium/Workers/chunk-3C74MLG3.js +0 -26
- package/dist/cesium/Workers/chunk-45U7TTT3.js +0 -26
- package/dist/cesium/Workers/chunk-4N7SRDH5.js +0 -26
- package/dist/cesium/Workers/chunk-4T6AS6BZ.js +0 -26
- package/dist/cesium/Workers/chunk-5AG2MVRM.js +0 -26
- package/dist/cesium/Workers/chunk-5Z6L2FHX.js +0 -26
- package/dist/cesium/Workers/chunk-6AUUBDOF.js +0 -26
- package/dist/cesium/Workers/chunk-74N6MC2V.js +0 -26
- package/dist/cesium/Workers/chunk-7VJK3KHI.js +0 -26
- package/dist/cesium/Workers/chunk-7VZHIB6P.js +0 -26
- package/dist/cesium/Workers/chunk-7X2YQ6I4.js +0 -27
- package/dist/cesium/Workers/chunk-B2SKQ7LU.js +0 -26
- package/dist/cesium/Workers/chunk-B4TQDFIE.js +0 -26
- package/dist/cesium/Workers/chunk-B6TRTFAA.js +0 -26
- package/dist/cesium/Workers/chunk-BK3HCS7I.js +0 -26
- package/dist/cesium/Workers/chunk-BOPB43LN.js +0 -26
- package/dist/cesium/Workers/chunk-C6DMEJQ7.js +0 -26
- package/dist/cesium/Workers/chunk-CN7UN2OZ.js +0 -26
- package/dist/cesium/Workers/chunk-CSISXEG7.js +0 -26
- package/dist/cesium/Workers/chunk-CUOR5F7T.js +0 -28
- package/dist/cesium/Workers/chunk-DGCK3LD2.js +0 -30
- package/dist/cesium/Workers/chunk-DXEZYE3K.js +0 -62
- package/dist/cesium/Workers/chunk-EXBFEYPQ.js +0 -26
- package/dist/cesium/Workers/chunk-FK5KFB6H.js +0 -26
- package/dist/cesium/Workers/chunk-HPBHKP5S.js +0 -26
- package/dist/cesium/Workers/chunk-JCJ24DHF.js +0 -26
- package/dist/cesium/Workers/chunk-JEWHFDAA.js +0 -26
- package/dist/cesium/Workers/chunk-JZLZJJQD.js +0 -26
- package/dist/cesium/Workers/chunk-KRZBI2MU.js +0 -26
- package/dist/cesium/Workers/chunk-KTTUANTJ.js +0 -26
- package/dist/cesium/Workers/chunk-LDCAXLGS.js +0 -26
- package/dist/cesium/Workers/chunk-LOPN5R3I.js +0 -26
- package/dist/cesium/Workers/chunk-MDLPQIMP.js +0 -26
- package/dist/cesium/Workers/chunk-MRR3RGFO.js +0 -26
- package/dist/cesium/Workers/chunk-NPBZI5YA.js +0 -26
- package/dist/cesium/Workers/chunk-NUSW5B6A.js +0 -26
- package/dist/cesium/Workers/chunk-OUXRUXNB.js +0 -26
- package/dist/cesium/Workers/chunk-QPOPEH3M.js +0 -26
- package/dist/cesium/Workers/chunk-R2AN7EKC.js +0 -26
- package/dist/cesium/Workers/chunk-RURL6ZX2.js +0 -26
- package/dist/cesium/Workers/chunk-SUQM3OSW.js +0 -28
- package/dist/cesium/Workers/chunk-UBIRX2SP.js +0 -26
- package/dist/cesium/Workers/chunk-VAKC5J5C.js +0 -26
- package/dist/cesium/Workers/chunk-VHNZBQTR.js +0 -27
- package/dist/cesium/Workers/chunk-VKV642QV.js +0 -26
- package/dist/cesium/Workers/chunk-VMSXG4OA.js +0 -26
- package/dist/cesium/Workers/chunk-VQZSIOZW.js +0 -26
- package/dist/cesium/Workers/chunk-WZUWQMI7.js +0 -26
- package/dist/cesium/Workers/chunk-YBI55DLZ.js +0 -26
- package/dist/cesium/Workers/chunk-YEJWCH6C.js +0 -26
- package/dist/cesium/Workers/chunk-YPDO7SPO.js +0 -26
- package/dist/cesium/Workers/chunk-ZYWD6OQH.js +0 -26
- package/dist/cesium/Workers/combineGeometry.js +0 -26
- package/dist/cesium/Workers/createBoxGeometry.js +0 -26
- package/dist/cesium/Workers/createBoxOutlineGeometry.js +0 -26
- package/dist/cesium/Workers/createCircleGeometry.js +0 -26
- package/dist/cesium/Workers/createCircleOutlineGeometry.js +0 -26
- package/dist/cesium/Workers/createCoplanarPolygonGeometry.js +0 -26
- package/dist/cesium/Workers/createCoplanarPolygonOutlineGeometry.js +0 -26
- package/dist/cesium/Workers/createCorridorGeometry.js +0 -26
- package/dist/cesium/Workers/createCorridorOutlineGeometry.js +0 -26
- package/dist/cesium/Workers/createCylinderGeometry.js +0 -26
- package/dist/cesium/Workers/createCylinderOutlineGeometry.js +0 -26
- package/dist/cesium/Workers/createEllipseGeometry.js +0 -26
- package/dist/cesium/Workers/createEllipseOutlineGeometry.js +0 -26
- package/dist/cesium/Workers/createEllipsoidGeometry.js +0 -26
- package/dist/cesium/Workers/createEllipsoidOutlineGeometry.js +0 -26
- package/dist/cesium/Workers/createFrustumGeometry.js +0 -26
- package/dist/cesium/Workers/createFrustumOutlineGeometry.js +0 -26
- package/dist/cesium/Workers/createGeometry.js +0 -26
- package/dist/cesium/Workers/createGroundPolylineGeometry.js +0 -26
- package/dist/cesium/Workers/createPlaneGeometry.js +0 -26
- package/dist/cesium/Workers/createPlaneOutlineGeometry.js +0 -26
- package/dist/cesium/Workers/createPolygonGeometry.js +0 -26
- package/dist/cesium/Workers/createPolygonOutlineGeometry.js +0 -26
- package/dist/cesium/Workers/createPolylineGeometry.js +0 -26
- package/dist/cesium/Workers/createPolylineVolumeGeometry.js +0 -26
- package/dist/cesium/Workers/createPolylineVolumeOutlineGeometry.js +0 -26
- package/dist/cesium/Workers/createRectangleGeometry.js +0 -26
- package/dist/cesium/Workers/createRectangleOutlineGeometry.js +0 -26
- package/dist/cesium/Workers/createSimplePolylineGeometry.js +0 -26
- package/dist/cesium/Workers/createSphereGeometry.js +0 -26
- package/dist/cesium/Workers/createSphereOutlineGeometry.js +0 -26
- package/dist/cesium/Workers/createTaskProcessorWorker.js +0 -26
- package/dist/cesium/Workers/createVectorTileClampedPolylines.js +0 -26
- package/dist/cesium/Workers/createVectorTileGeometries.js +0 -26
- package/dist/cesium/Workers/createVectorTilePoints.js +0 -26
- package/dist/cesium/Workers/createVectorTilePolygons.js +0 -26
- package/dist/cesium/Workers/createVectorTilePolylines.js +0 -26
- package/dist/cesium/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +0 -26
- package/dist/cesium/Workers/createVerticesFromHeightmap.js +0 -26
- package/dist/cesium/Workers/createVerticesFromQuantizedTerrainMesh.js +0 -26
- package/dist/cesium/Workers/createWallGeometry.js +0 -26
- package/dist/cesium/Workers/createWallOutlineGeometry.js +0 -26
- package/dist/cesium/Workers/decodeDraco.js +0 -26
- package/dist/cesium/Workers/decodeGoogleEarthEnterprisePacket.js +0 -26
- package/dist/cesium/Workers/decodeI3S.js +0 -26
- package/dist/cesium/Workers/transcodeKTX2.js +0 -56
- package/dist/cesium/Workers/transferTypedArrayTest.js +0 -26
- package/dist/cesium/Workers/upsampleQuantizedTerrainMesh.js +0 -26
- package/src/engines/Cesium/core/Globe.tsx +0 -104
- /package/src/{Map/Sketch/utils.ts → utils/use-window-event.ts} +0 -0
package/src/Map/Sketch/hooks.ts
CHANGED
|
@@ -8,22 +8,17 @@ import {
|
|
|
8
8
|
useCallback,
|
|
9
9
|
useEffect,
|
|
10
10
|
useImperativeHandle,
|
|
11
|
+
useMemo,
|
|
11
12
|
useRef,
|
|
12
13
|
useState,
|
|
13
14
|
} from "react";
|
|
14
|
-
import invariant from "tiny-invariant";
|
|
15
15
|
import { v4 as uuidv4 } from "uuid";
|
|
16
|
+
import { InterpreterFrom, StateFrom } from "xstate";
|
|
16
17
|
|
|
18
|
+
import { ControlPointMouseEventHandler } from "../../engines/Cesium/Sketch";
|
|
19
|
+
import { useWindowEvent } from "../../utils/use-window-event";
|
|
17
20
|
import { InteractionModeType } from "../../Visualizer/interactionMode";
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
Feature,
|
|
21
|
-
EngineRef,
|
|
22
|
-
LayersRef,
|
|
23
|
-
MouseEventCallback,
|
|
24
|
-
MouseEventProps,
|
|
25
|
-
SketchRef,
|
|
26
|
-
} from "../types";
|
|
21
|
+
import { Feature, EngineRef, LayersRef, SketchRef } from "../types";
|
|
27
22
|
import { useGet } from "../utils";
|
|
28
23
|
|
|
29
24
|
import { PRESET_APPEARANCE, PRESET_COLOR } from "./preset";
|
|
@@ -34,8 +29,12 @@ import {
|
|
|
34
29
|
SketchFeature,
|
|
35
30
|
SketchEventProps,
|
|
36
31
|
SketchOptions,
|
|
32
|
+
SketchEditingFeature,
|
|
33
|
+
SketchEditFeatureChangeCb,
|
|
37
34
|
} from "./types";
|
|
38
|
-
import
|
|
35
|
+
import usePluginSketchLayer from "./usePluginSketchLayer";
|
|
36
|
+
import useSketch from "./useSketch";
|
|
37
|
+
import useSketchFeature from "./useSketchFeature";
|
|
39
38
|
|
|
40
39
|
import { OnLayerSelectType } from ".";
|
|
41
40
|
|
|
@@ -45,35 +44,63 @@ export type SketchFeatureCallback = (
|
|
|
45
44
|
|
|
46
45
|
type Props = {
|
|
47
46
|
ref: ForwardedRef<SketchRef>;
|
|
48
|
-
layersRef: RefObject<LayersRef>;
|
|
49
|
-
engineRef: RefObject<EngineRef>;
|
|
47
|
+
layersRef: RefObject<LayersRef | null>;
|
|
48
|
+
engineRef: RefObject<EngineRef | null>;
|
|
50
49
|
interactionMode: InteractionModeType;
|
|
51
50
|
selectedFeature?: Feature;
|
|
52
51
|
overrideInteractionMode?: (mode: InteractionModeType) => void;
|
|
53
52
|
onSketchTypeChange?: (type: SketchType | undefined, from?: "editor" | "plugin") => void;
|
|
54
53
|
onSketchFeatureCreate?: (feature: SketchFeature | null) => void;
|
|
55
54
|
onSketchPluginFeatureCreate?: (props: SketchEventProps) => void;
|
|
55
|
+
onSketchFeatureUpdate?: (feature: SketchFeature) => void;
|
|
56
|
+
onSketchPluginFeatureUpdate?: (props: SketchEventProps) => void;
|
|
57
|
+
onSketchFeatureDelete?: (layerId: string, featureId: string) => void;
|
|
58
|
+
onSketchPluginFeatureDelete?: (props: { layerId: string; featureId: string }) => void;
|
|
56
59
|
onLayerSelect?: OnLayerSelectType;
|
|
60
|
+
sketchEditingFeature?: SketchEditingFeature;
|
|
61
|
+
onSketchEditFeature?: (feature: SketchEditingFeature | undefined) => void;
|
|
62
|
+
onMount?: () => void;
|
|
57
63
|
};
|
|
58
64
|
|
|
59
|
-
const PLUGIN_LAYER_ID_LENGTH = 36;
|
|
60
|
-
|
|
61
65
|
const sketchMachine = createSketchMachine();
|
|
62
66
|
|
|
63
|
-
export
|
|
67
|
+
export type sketchState = StateFrom<typeof sketchMachine>;
|
|
68
|
+
export type SketchInterpreter = InterpreterFrom<typeof sketchMachine>;
|
|
69
|
+
|
|
70
|
+
export default function ({
|
|
64
71
|
ref,
|
|
65
72
|
engineRef,
|
|
66
73
|
layersRef,
|
|
74
|
+
interactionMode,
|
|
67
75
|
selectedFeature,
|
|
68
76
|
overrideInteractionMode,
|
|
69
77
|
onSketchTypeChange,
|
|
70
78
|
onSketchFeatureCreate,
|
|
71
79
|
onSketchPluginFeatureCreate,
|
|
80
|
+
onSketchFeatureUpdate,
|
|
81
|
+
onSketchPluginFeatureUpdate,
|
|
82
|
+
onSketchFeatureDelete,
|
|
83
|
+
onSketchPluginFeatureDelete,
|
|
72
84
|
onLayerSelect,
|
|
85
|
+
sketchEditingFeature,
|
|
86
|
+
onSketchEditFeature,
|
|
87
|
+
onMount,
|
|
73
88
|
}: Props) {
|
|
74
89
|
const [state, send] = useMachine(sketchMachine);
|
|
75
90
|
const [type, updateType] = useState<SketchType | undefined>();
|
|
76
91
|
const [from, updateFrom] = useState<"editor" | "plugin">("editor");
|
|
92
|
+
|
|
93
|
+
const setType = useCallback(
|
|
94
|
+
(type: SketchType | undefined, from?: "editor" | "plugin") => {
|
|
95
|
+
updateType(type);
|
|
96
|
+
updateFrom(from ?? "editor");
|
|
97
|
+
if (type) {
|
|
98
|
+
engineRef.current?.setCursor("crosshair");
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
[engineRef],
|
|
102
|
+
);
|
|
103
|
+
|
|
77
104
|
const [disableInteraction, setDisableInteraction] = useState(false);
|
|
78
105
|
|
|
79
106
|
const [sketchOptions, setSketchOptions] = useState<SketchOptions>({
|
|
@@ -81,9 +108,10 @@ export default function useHooks({
|
|
|
81
108
|
appearance: PRESET_APPEARANCE,
|
|
82
109
|
dataOnly: false,
|
|
83
110
|
disableShadow: false,
|
|
84
|
-
enableRelativeHeight: false,
|
|
85
111
|
rightClickToAbort: true,
|
|
86
112
|
autoResetInteractionMode: true,
|
|
113
|
+
// NOTE: Centroid extrude is not finalized yet
|
|
114
|
+
useCentroidExtrudedHeight: false,
|
|
87
115
|
});
|
|
88
116
|
|
|
89
117
|
const overrideOptions = useCallback((options: SketchOptions) => {
|
|
@@ -96,13 +124,16 @@ export default function useHooks({
|
|
|
96
124
|
|
|
97
125
|
const [geometryOptions, setGeometryOptions] = useState<GeometryOptionsXYZ | null>(null);
|
|
98
126
|
const [extrudedHeight, setExtrudedHeight] = useState(0);
|
|
127
|
+
const [extrudedPoint, setExtrudedPoint] = useState<Position3d | undefined>();
|
|
128
|
+
|
|
129
|
+
const [centroidBasePoint, setCentroidBasePoint] = useState<Position3d | undefined>();
|
|
130
|
+
const [centroidExtrudedPoint, setCentroidExtrudedPoint] = useState<Position3d | undefined>();
|
|
131
|
+
|
|
132
|
+
const [selectedControlPointIndex, setSelectedControlPointIndex] = useState<number | undefined>();
|
|
99
133
|
const markerGeometryRef = useRef<GeometryOptionsXYZ | null>(null);
|
|
100
|
-
const pointerLocationRef = useRef<[lng: number, lat: number, height: number]>();
|
|
134
|
+
const pointerLocationRef = useRef<[lng: number, lat: number, height: number]>(undefined);
|
|
101
135
|
|
|
102
|
-
const
|
|
103
|
-
updateType(type);
|
|
104
|
-
updateFrom(from ?? "editor");
|
|
105
|
-
}, []);
|
|
136
|
+
const isEditing = useMemo(() => state.matches("editing"), [state]);
|
|
106
137
|
|
|
107
138
|
const createFeature = useCallback(() => {
|
|
108
139
|
const geoOptions = type === "marker" ? markerGeometryRef.current : geometryOptions;
|
|
@@ -121,9 +152,26 @@ export default function useHooks({
|
|
|
121
152
|
});
|
|
122
153
|
}, [extrudedHeight, geometryOptions, markerGeometryRef, type, engineRef]);
|
|
123
154
|
|
|
155
|
+
const updateFeature = useCallback(() => {
|
|
156
|
+
if (geometryOptions == null || !selectedFeature?.id) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
const geometry = engineRef.current?.createGeometry(geometryOptions);
|
|
160
|
+
if (geometry == null) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
return feature(geometry, {
|
|
164
|
+
id: selectedFeature?.id,
|
|
165
|
+
type: geometryOptions?.type,
|
|
166
|
+
positions: geometryOptions?.controlPoints,
|
|
167
|
+
extrudedHeight,
|
|
168
|
+
});
|
|
169
|
+
}, [extrudedHeight, geometryOptions, selectedFeature, engineRef]);
|
|
170
|
+
|
|
124
171
|
const updateGeometryOptions = useCallback(
|
|
125
172
|
(controlPoint?: Position3d) => {
|
|
126
173
|
setExtrudedHeight(0);
|
|
174
|
+
setExtrudedPoint(undefined);
|
|
127
175
|
if (state.context.type == null || state.context.controlPoints == null) {
|
|
128
176
|
setGeometryOptions(null);
|
|
129
177
|
return;
|
|
@@ -139,396 +187,160 @@ export default function useHooks({
|
|
|
139
187
|
[state, setGeometryOptions, setExtrudedHeight],
|
|
140
188
|
);
|
|
141
189
|
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
const newLayer = layersRef.current?.add({
|
|
145
|
-
type: "simple",
|
|
146
|
-
data: {
|
|
147
|
-
type: "geojson",
|
|
148
|
-
isSketchLayer: true,
|
|
149
|
-
value: {
|
|
150
|
-
type: "FeatureCollection",
|
|
151
|
-
features: [{ ...feature, id: feature.properties.id }],
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
...sketchOptions.appearance,
|
|
155
|
-
});
|
|
156
|
-
return { layerId: newLayer?.id, featureId: feature.properties.id };
|
|
157
|
-
},
|
|
158
|
-
[layersRef, sketchOptions.appearance],
|
|
159
|
-
);
|
|
190
|
+
const updateGeometryOptionsRef = useRef(updateGeometryOptions);
|
|
191
|
+
updateGeometryOptionsRef.current = updateGeometryOptions;
|
|
160
192
|
|
|
161
|
-
const
|
|
162
|
-
(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
data: {
|
|
166
|
-
...layer.data,
|
|
167
|
-
type: "geojson",
|
|
168
|
-
value: {
|
|
169
|
-
type: "FeatureCollection",
|
|
170
|
-
features: [
|
|
171
|
-
...((layer.computed?.layer as LayerSimple)?.data?.value?.features ?? []),
|
|
172
|
-
{ ...feature, id: feature.properties.id },
|
|
173
|
-
],
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
});
|
|
177
|
-
return { layerId: layer.id, featureId: feature.properties.id };
|
|
178
|
-
},
|
|
179
|
-
[layersRef],
|
|
180
|
-
);
|
|
193
|
+
const updateCentroidPoints = useCallback(
|
|
194
|
+
async (controlPoints: Position3d[]) => {
|
|
195
|
+
const newExtrudeBasePoint = await getCentroid(controlPoints, engineRef);
|
|
196
|
+
setCentroidBasePoint(newExtrudeBasePoint);
|
|
181
197
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
type: "geojson",
|
|
189
|
-
value: {
|
|
190
|
-
type: "FeatureCollection",
|
|
191
|
-
features: [
|
|
192
|
-
...(layer.computed?.layer?.data?.value?.features ?? []).filter(
|
|
193
|
-
(feature: GeojsonFeature) => feature.id !== featureId,
|
|
194
|
-
),
|
|
195
|
-
],
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
});
|
|
198
|
+
if (!newExtrudeBasePoint) return;
|
|
199
|
+
const centroidExtrudedPoint = engineRef.current?.getExtrudedPoint(
|
|
200
|
+
newExtrudeBasePoint,
|
|
201
|
+
extrudedHeight,
|
|
202
|
+
);
|
|
203
|
+
setCentroidExtrudedPoint(centroidExtrudedPoint);
|
|
199
204
|
},
|
|
200
|
-
[
|
|
205
|
+
[engineRef, extrudedHeight],
|
|
201
206
|
);
|
|
202
207
|
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
const {
|
|
209
|
+
pluginSketchLayerCreate,
|
|
210
|
+
pluginSketchLayerFeatureAdd,
|
|
211
|
+
pluginSketchLayerFeatureUpdate,
|
|
212
|
+
pluginSketchLayerFeatureRemove,
|
|
213
|
+
} = usePluginSketchLayer({
|
|
214
|
+
layersRef,
|
|
215
|
+
sketchOptions,
|
|
216
|
+
});
|
|
210
217
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
// Wait until computed feature is ready
|
|
229
|
-
queueMicrotask(() => {
|
|
230
|
-
resolve(layersRef.current?.findById?.(layerId)?.computed);
|
|
231
|
-
});
|
|
232
|
-
})
|
|
233
|
-
: undefined,
|
|
234
|
-
undefined,
|
|
235
|
-
undefined,
|
|
236
|
-
);
|
|
237
|
-
});
|
|
238
|
-
onSketchPluginFeatureCreate?.({ layerId, featureId, feature });
|
|
239
|
-
}
|
|
240
|
-
} else {
|
|
241
|
-
onSketchPluginFeatureCreate?.({ feature });
|
|
242
|
-
}
|
|
243
|
-
},
|
|
244
|
-
[
|
|
245
|
-
layersRef,
|
|
246
|
-
from,
|
|
247
|
-
sketchOptions.dataOnly,
|
|
248
|
-
pluginSketchLayerCreate,
|
|
249
|
-
pluginSketchLayerFeatureAdd,
|
|
250
|
-
onSketchFeatureCreate,
|
|
251
|
-
onSketchPluginFeatureCreate,
|
|
252
|
-
onLayerSelect,
|
|
253
|
-
],
|
|
254
|
-
);
|
|
218
|
+
const { handleFeatureCreate, handleFeatureUpdate, handleFeatureDelete } = useSketchFeature({
|
|
219
|
+
layersRef,
|
|
220
|
+
sketchOptions,
|
|
221
|
+
from,
|
|
222
|
+
updateType,
|
|
223
|
+
onSketchFeatureCreate,
|
|
224
|
+
pluginSketchLayerCreate,
|
|
225
|
+
pluginSketchLayerFeatureAdd,
|
|
226
|
+
pluginSketchLayerFeatureUpdate,
|
|
227
|
+
pluginSketchLayerFeatureRemove,
|
|
228
|
+
onSketchPluginFeatureCreate,
|
|
229
|
+
onSketchPluginFeatureUpdate,
|
|
230
|
+
onSketchPluginFeatureDelete,
|
|
231
|
+
onSketchFeatureUpdate,
|
|
232
|
+
onSketchFeatureDelete,
|
|
233
|
+
onLayerSelect,
|
|
234
|
+
});
|
|
255
235
|
|
|
256
|
-
const
|
|
257
|
-
(
|
|
258
|
-
|
|
259
|
-
disableInteraction ||
|
|
260
|
-
!type ||
|
|
261
|
-
props.lng === undefined ||
|
|
262
|
-
props.lat === undefined ||
|
|
263
|
-
props.height === undefined ||
|
|
264
|
-
props.x === undefined ||
|
|
265
|
-
props.y === undefined
|
|
266
|
-
) {
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
if (!state.matches("idle")) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
invariant(state.context.lastControlPoint == null);
|
|
273
|
-
const controlPoint = engineRef.current?.toXYZ(props.lng, props.lat, props.height);
|
|
274
|
-
if (controlPoint == null) {
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
236
|
+
const editFeature = useCallback(
|
|
237
|
+
(feature: SketchEditingFeature | undefined) => {
|
|
238
|
+
onSketchEditFeature?.(feature);
|
|
277
239
|
|
|
240
|
+
if (!state.matches("idle") || !feature) return;
|
|
241
|
+
|
|
242
|
+
const type = feature?.feature?.properties?.type as SketchType;
|
|
278
243
|
send({
|
|
279
244
|
type: {
|
|
280
|
-
marker: "
|
|
281
|
-
polyline: "
|
|
282
|
-
circle: "
|
|
283
|
-
rectangle: "
|
|
284
|
-
polygon: "
|
|
285
|
-
extrudedCircle: "
|
|
286
|
-
extrudedRectangle: "
|
|
287
|
-
extrudedPolygon: "
|
|
245
|
+
marker: "EDIT_MARKER" as const,
|
|
246
|
+
polyline: "EDIT_POLYLINE" as const,
|
|
247
|
+
circle: "EDIT_CIRCLE" as const,
|
|
248
|
+
rectangle: "EDIT_RECTANGLE" as const,
|
|
249
|
+
polygon: "EDIT_POLYGON" as const,
|
|
250
|
+
extrudedCircle: "EDIT_EXTRUDED_CIRCLE" as const,
|
|
251
|
+
extrudedRectangle: "EDIT_EXTRUDED_RECTANGLE" as const,
|
|
252
|
+
extrudedPolygon: "EDIT_EXTRUDED_POLYGON" as const,
|
|
288
253
|
}[type],
|
|
289
|
-
|
|
290
|
-
|
|
254
|
+
controlPoints: feature?.feature?.properties?.positions,
|
|
255
|
+
extrudedHeight: feature?.feature?.properties?.extrudedHeight,
|
|
291
256
|
});
|
|
292
|
-
setGeometryOptions(
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
props.x === undefined ||
|
|
306
|
-
props.y === undefined ||
|
|
307
|
-
!engineRef.current
|
|
308
|
-
) {
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
pointerLocationRef.current = [props.lng, props.lat, props.height];
|
|
312
|
-
if (state.matches("drawing")) {
|
|
313
|
-
invariant(state.context.type != null);
|
|
314
|
-
invariant(state.context.controlPoints != null);
|
|
315
|
-
const controlPoint = engineRef.current?.toXYZ(props.lng, props.lat, props.height);
|
|
316
|
-
if (
|
|
317
|
-
controlPoint == null ||
|
|
318
|
-
hasDuplicate(engineRef.current.equalsEpsilon3d, controlPoint, state.context.controlPoints)
|
|
319
|
-
) {
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
updateGeometryOptions(controlPoint);
|
|
323
|
-
} else if (state.matches("extruding")) {
|
|
324
|
-
invariant(state.context.lastControlPoint != null);
|
|
325
|
-
const extrudedHeight = engineRef.current?.getExtrudedHeight(
|
|
326
|
-
state.context.lastControlPoint,
|
|
327
|
-
[props.x, props.y],
|
|
257
|
+
setGeometryOptions({
|
|
258
|
+
type,
|
|
259
|
+
controlPoints: feature?.feature?.properties?.positions,
|
|
260
|
+
});
|
|
261
|
+
if (feature?.feature?.properties?.extrudedHeight) {
|
|
262
|
+
setExtrudedHeight(feature.feature.properties.extrudedHeight);
|
|
263
|
+
setExtrudedPoint(
|
|
264
|
+
engineRef.current?.getExtrudedPoint(
|
|
265
|
+
feature?.feature?.properties?.positions[
|
|
266
|
+
feature?.feature?.properties?.positions.length - 1
|
|
267
|
+
],
|
|
268
|
+
feature.feature.properties.extrudedHeight,
|
|
269
|
+
),
|
|
328
270
|
);
|
|
329
|
-
if (extrudedHeight != null) {
|
|
330
|
-
setExtrudedHeight(extrudedHeight);
|
|
331
|
-
}
|
|
332
271
|
}
|
|
333
272
|
},
|
|
334
|
-
[
|
|
273
|
+
[engineRef, state, onSketchEditFeature, send],
|
|
335
274
|
);
|
|
336
275
|
|
|
337
|
-
const
|
|
338
|
-
(
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
props.x === undefined ||
|
|
345
|
-
props.y === undefined ||
|
|
346
|
-
!engineRef.current
|
|
347
|
-
) {
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
if (
|
|
351
|
-
state.context.controlPoints?.length === 1 &&
|
|
352
|
-
state.context.lastPointerPosition != null &&
|
|
353
|
-
state.context.type !== "marker" &&
|
|
354
|
-
engineRef.current?.equalsEpsilon2d(
|
|
355
|
-
[props.x, props.y],
|
|
356
|
-
state.context.lastPointerPosition,
|
|
357
|
-
0,
|
|
358
|
-
5,
|
|
359
|
-
)
|
|
360
|
-
) {
|
|
361
|
-
return; // Too close to the first position user clicked.
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
if (state.matches("drawing")) {
|
|
365
|
-
const controlPoint = engineRef.current?.toXYZ(props.lng, props.lat, props.height);
|
|
366
|
-
if (controlPoint == null) return;
|
|
367
|
-
|
|
368
|
-
if (state.context.type === "marker") {
|
|
369
|
-
markerGeometryRef.current = {
|
|
370
|
-
type: state.context.type,
|
|
371
|
-
controlPoints: [controlPoint],
|
|
372
|
-
};
|
|
373
|
-
const feature = createFeature();
|
|
374
|
-
markerGeometryRef.current = null;
|
|
375
|
-
if (feature == null) {
|
|
376
|
-
return;
|
|
377
|
-
}
|
|
378
|
-
handleFeatureCreate(feature);
|
|
379
|
-
send({ type: "CREATE" });
|
|
380
|
-
setGeometryOptions(null);
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
if (
|
|
384
|
-
hasDuplicate(
|
|
385
|
-
engineRef.current?.equalsEpsilon3d,
|
|
386
|
-
controlPoint,
|
|
387
|
-
state.context.controlPoints,
|
|
388
|
-
)
|
|
389
|
-
) {
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
if (
|
|
393
|
-
state.context.type === "circle" ||
|
|
394
|
-
(state.context.type === "rectangle" && state.context.controlPoints?.length === 2)
|
|
395
|
-
) {
|
|
396
|
-
const feature = createFeature();
|
|
397
|
-
if (feature == null) {
|
|
398
|
-
return;
|
|
399
|
-
}
|
|
400
|
-
handleFeatureCreate(feature);
|
|
401
|
-
send({ type: "CREATE" });
|
|
402
|
-
setGeometryOptions(null);
|
|
403
|
-
return;
|
|
404
|
-
} else {
|
|
405
|
-
if (props.x === undefined || props.y === undefined) return;
|
|
406
|
-
send({
|
|
407
|
-
type: "NEXT",
|
|
408
|
-
pointerPosition: [props.x, props.y],
|
|
409
|
-
controlPoint,
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
} else if (state.matches("extruding")) {
|
|
413
|
-
const feature = createFeature();
|
|
414
|
-
if (feature == null) {
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
handleFeatureCreate(feature);
|
|
418
|
-
send({ type: "CREATE" });
|
|
419
|
-
setGeometryOptions(null);
|
|
276
|
+
const cancelEdit = useCallback(
|
|
277
|
+
(ignoreAutoReSelect?: boolean) => {
|
|
278
|
+
send({ type: "EXIT_EDIT" });
|
|
279
|
+
updateGeometryOptions(undefined);
|
|
280
|
+
onSketchEditFeature?.(undefined);
|
|
281
|
+
if (ignoreAutoReSelect) {
|
|
282
|
+
ignoreAutoReSelectRef.current = true;
|
|
420
283
|
}
|
|
421
284
|
},
|
|
422
|
-
[
|
|
423
|
-
disableInteraction,
|
|
424
|
-
state,
|
|
425
|
-
engineRef,
|
|
426
|
-
send,
|
|
427
|
-
setGeometryOptions,
|
|
428
|
-
createFeature,
|
|
429
|
-
handleFeatureCreate,
|
|
430
|
-
],
|
|
285
|
+
[onSketchEditFeature, send, updateGeometryOptions],
|
|
431
286
|
);
|
|
432
287
|
|
|
433
|
-
const
|
|
434
|
-
(
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
props.lat === undefined ||
|
|
439
|
-
props.height === undefined ||
|
|
440
|
-
props.x === undefined ||
|
|
441
|
-
props.y === undefined
|
|
442
|
-
) {
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
if (state.matches("drawing.extrudedPolygon")) {
|
|
446
|
-
const controlPoint = engineRef.current?.toXYZ(props.lng, props.lat, props.height);
|
|
447
|
-
if (controlPoint == null) return;
|
|
448
|
-
send({
|
|
449
|
-
type: "EXTRUDE",
|
|
450
|
-
pointerPosition: [props.x, props.y],
|
|
451
|
-
controlPoint,
|
|
452
|
-
});
|
|
453
|
-
} else if (state.matches("drawing.polyline") || state.matches("drawing.polygon")) {
|
|
454
|
-
const feature = createFeature();
|
|
455
|
-
if (feature == null) {
|
|
456
|
-
return;
|
|
457
|
-
}
|
|
458
|
-
handleFeatureCreate(feature);
|
|
459
|
-
send({ type: "CREATE" });
|
|
460
|
-
setGeometryOptions(null);
|
|
288
|
+
const applyEdit = useCallback(() => {
|
|
289
|
+
if (sketchEditingFeature) {
|
|
290
|
+
const feature = updateFeature();
|
|
291
|
+
if (feature) {
|
|
292
|
+
handleFeatureUpdate({ ...feature, id: feature.properties.id });
|
|
461
293
|
}
|
|
462
|
-
},
|
|
463
|
-
[disableInteraction, state, engineRef, send, handleFeatureCreate, createFeature],
|
|
464
|
-
);
|
|
465
|
-
|
|
466
|
-
const handleRightClick = useCallback(() => {
|
|
467
|
-
if (!sketchOptions.rightClickToAbort) {
|
|
468
|
-
return;
|
|
469
|
-
}
|
|
470
|
-
if (type !== undefined) {
|
|
471
|
-
updateType(undefined);
|
|
472
294
|
}
|
|
473
|
-
|
|
474
|
-
send({ type: "ABORT" });
|
|
295
|
+
send({ type: "EXIT_EDIT" });
|
|
475
296
|
updateGeometryOptions(undefined);
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
mouseDoubleClickEventRef.current = handleDoubleClick;
|
|
486
|
-
const mouseRightClickEventRef = useRef<() => void>(handleRightClick);
|
|
487
|
-
mouseRightClickEventRef.current = handleRightClick;
|
|
488
|
-
|
|
489
|
-
const onMouseDown = useCallback(
|
|
490
|
-
(props: MouseEventProps) => {
|
|
491
|
-
mouseDownEventRef.current?.(props);
|
|
492
|
-
},
|
|
493
|
-
[mouseDownEventRef],
|
|
494
|
-
);
|
|
495
|
-
|
|
496
|
-
const onMouseMove = useCallback(
|
|
497
|
-
(props: MouseEventProps) => {
|
|
498
|
-
mouseMoveEventRef.current?.(props);
|
|
499
|
-
},
|
|
500
|
-
[mouseMoveEventRef],
|
|
501
|
-
);
|
|
502
|
-
|
|
503
|
-
const onMouseUp = useCallback(
|
|
504
|
-
(props: MouseEventProps) => {
|
|
505
|
-
mouseUpEventRef.current?.(props);
|
|
506
|
-
},
|
|
507
|
-
[mouseUpEventRef],
|
|
508
|
-
);
|
|
297
|
+
onSketchEditFeature?.(undefined);
|
|
298
|
+
}, [
|
|
299
|
+
sketchEditingFeature,
|
|
300
|
+
send,
|
|
301
|
+
updateGeometryOptions,
|
|
302
|
+
handleFeatureUpdate,
|
|
303
|
+
updateFeature,
|
|
304
|
+
onSketchEditFeature,
|
|
305
|
+
]);
|
|
509
306
|
|
|
510
|
-
const
|
|
511
|
-
(
|
|
512
|
-
|
|
307
|
+
const deleteFeature = useCallback(
|
|
308
|
+
(layerId: string, featureId: string) => {
|
|
309
|
+
handleFeatureDelete(layerId, featureId);
|
|
513
310
|
},
|
|
514
|
-
[
|
|
311
|
+
[handleFeatureDelete],
|
|
515
312
|
);
|
|
516
313
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
314
|
+
useSketch({
|
|
315
|
+
state,
|
|
316
|
+
engineRef,
|
|
317
|
+
disableInteraction,
|
|
318
|
+
type,
|
|
319
|
+
updateType,
|
|
320
|
+
sketchEditingFeature,
|
|
321
|
+
setSelectedControlPointIndex,
|
|
322
|
+
send,
|
|
323
|
+
setGeometryOptions,
|
|
324
|
+
markerGeometryRef,
|
|
325
|
+
pointerLocationRef,
|
|
326
|
+
geometryOptions,
|
|
327
|
+
updateGeometryOptions,
|
|
328
|
+
extrudedHeight,
|
|
329
|
+
setExtrudedHeight,
|
|
330
|
+
setExtrudedPoint,
|
|
331
|
+
updateCentroidPoints,
|
|
332
|
+
createFeature,
|
|
333
|
+
handleFeatureCreate,
|
|
334
|
+
applyEdit,
|
|
335
|
+
cancelEdit,
|
|
336
|
+
isEditing,
|
|
337
|
+
sketchOptions,
|
|
338
|
+
});
|
|
528
339
|
|
|
529
340
|
useWindowEvent("keydown", event => {
|
|
530
341
|
if (type === undefined) return;
|
|
531
342
|
if (event.code === "Space") {
|
|
343
|
+
tempSwitchToMoveMode.current = true;
|
|
532
344
|
setDisableInteraction(true);
|
|
533
345
|
overrideInteractionMode?.("move");
|
|
534
346
|
} else {
|
|
@@ -544,7 +356,7 @@ export default function useHooks({
|
|
|
544
356
|
updateGeometryOptions(controlPoint);
|
|
545
357
|
} else if (event.key === "Delete" && state.matches("idle") && selectedFeature?.id) {
|
|
546
358
|
const selectedLayer = layersRef.current?.selectedLayer();
|
|
547
|
-
if (selectedLayer?.id
|
|
359
|
+
if (selectedLayer && layersRef.current?.isTempLayer(selectedLayer?.id)) {
|
|
548
360
|
pluginSketchLayerFeatureRemove(selectedLayer, selectedFeature.id);
|
|
549
361
|
}
|
|
550
362
|
}
|
|
@@ -556,31 +368,148 @@ export default function useHooks({
|
|
|
556
368
|
if (event.code === "Space") {
|
|
557
369
|
overrideInteractionMode?.("sketch");
|
|
558
370
|
setDisableInteraction(false);
|
|
371
|
+
if (tempSwitchToMoveMode.current) {
|
|
372
|
+
tempSwitchToMoveMode.current = false;
|
|
373
|
+
}
|
|
559
374
|
}
|
|
560
375
|
});
|
|
561
376
|
|
|
562
377
|
useEffect(() => {
|
|
563
|
-
if (type === undefined) {
|
|
378
|
+
if (type === undefined && !sketchEditingFeature) {
|
|
564
379
|
send({ type: "ABORT" });
|
|
565
|
-
|
|
380
|
+
updateGeometryOptionsRef.current?.(undefined);
|
|
566
381
|
}
|
|
567
|
-
}, [type,
|
|
382
|
+
}, [type, sketchEditingFeature, send]);
|
|
383
|
+
|
|
384
|
+
const fromRef = useRef(from);
|
|
385
|
+
fromRef.current = from;
|
|
386
|
+
const overrideInteractionModeRef = useRef(overrideInteractionMode);
|
|
387
|
+
overrideInteractionModeRef.current = overrideInteractionMode;
|
|
388
|
+
const onSketchTypeChangeRef = useRef(onSketchTypeChange);
|
|
389
|
+
onSketchTypeChangeRef.current = onSketchTypeChange;
|
|
390
|
+
const interactionModeRef = useRef(interactionMode);
|
|
391
|
+
interactionModeRef.current = interactionMode;
|
|
568
392
|
|
|
569
393
|
useEffect(() => {
|
|
570
|
-
if (type) {
|
|
571
|
-
|
|
572
|
-
} else if (sketchOptions.autoResetInteractionMode) {
|
|
573
|
-
overrideInteractionMode?.("default");
|
|
394
|
+
if ((sketchEditingFeature || type) && interactionModeRef.current !== "sketch") {
|
|
395
|
+
overrideInteractionModeRef.current?.("sketch");
|
|
574
396
|
}
|
|
397
|
+
}, [type, sketchEditingFeature]);
|
|
575
398
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
399
|
+
const isEditingRef = useRef(isEditing);
|
|
400
|
+
isEditingRef.current = isEditing;
|
|
401
|
+
const cancelEditRef = useRef(cancelEdit);
|
|
402
|
+
cancelEditRef.current = cancelEdit;
|
|
403
|
+
|
|
404
|
+
useEffect(() => {
|
|
405
|
+
onSketchTypeChangeRef.current?.(type, fromRef.current);
|
|
406
|
+
if (isEditingRef.current) {
|
|
407
|
+
cancelEditRef.current();
|
|
408
|
+
}
|
|
409
|
+
if (type === undefined) {
|
|
410
|
+
overrideInteractionModeRef.current?.(
|
|
411
|
+
interactionModeRef.current === "sketch" ? "default" : interactionModeRef.current,
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
}, [type]);
|
|
415
|
+
|
|
416
|
+
const typeRef = useRef(type);
|
|
417
|
+
typeRef.current = type;
|
|
418
|
+
useEffect(() => {
|
|
419
|
+
if (tempSwitchToMoveMode.current) return;
|
|
420
|
+
if (interactionMode !== "sketch") {
|
|
421
|
+
if (isEditingRef.current) {
|
|
422
|
+
cancelEditRef.current();
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}, [interactionMode, updateType]);
|
|
426
|
+
|
|
427
|
+
// Edit
|
|
428
|
+
const onEditFeatureChangeCbs = useRef<SketchEditFeatureChangeCb[]>([]);
|
|
429
|
+
const onEditFeatureChange = useCallback((cb: SketchEditFeatureChangeCb) => {
|
|
430
|
+
onEditFeatureChangeCbs.current.push(cb);
|
|
431
|
+
}, []);
|
|
432
|
+
const onEditFeatureChangeRef = useRef(onEditFeatureChange);
|
|
433
|
+
onEditFeatureChangeRef.current = onEditFeatureChange;
|
|
434
|
+
|
|
435
|
+
const lastSketchEditingFeature = useRef<SketchEditingFeature | undefined>(undefined);
|
|
436
|
+
|
|
437
|
+
const catchedControlPointIndex = useMemo(
|
|
438
|
+
() => state.context.catchedControlPointIndex,
|
|
439
|
+
[state.context.catchedControlPointIndex],
|
|
440
|
+
);
|
|
441
|
+
|
|
442
|
+
const catchedExtrudedPoint = useMemo(
|
|
443
|
+
() => !!state.context.catchedExtrudedPoint,
|
|
444
|
+
[state.context.catchedExtrudedPoint],
|
|
445
|
+
);
|
|
446
|
+
|
|
447
|
+
const ignoreAutoReSelectRef = useRef(false);
|
|
448
|
+
|
|
449
|
+
useEffect(() => {
|
|
450
|
+
onEditFeatureChangeCbs.current.forEach(cb => {
|
|
451
|
+
cb(sketchEditingFeature);
|
|
452
|
+
});
|
|
453
|
+
if (sketchEditingFeature) lastSketchEditingFeature.current = sketchEditingFeature;
|
|
454
|
+
else {
|
|
455
|
+
// Select the feature after editing
|
|
456
|
+
if (ignoreAutoReSelectRef.current) {
|
|
457
|
+
ignoreAutoReSelectRef.current = false;
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
layersRef.current?.selectFeatures([
|
|
461
|
+
{
|
|
462
|
+
layerId: undefined,
|
|
463
|
+
featureId: [],
|
|
464
|
+
},
|
|
465
|
+
]);
|
|
466
|
+
setTimeout(() => {
|
|
467
|
+
if (lastSketchEditingFeature.current) {
|
|
468
|
+
layersRef.current?.selectFeatures([
|
|
469
|
+
{
|
|
470
|
+
layerId: lastSketchEditingFeature.current?.layerId,
|
|
471
|
+
featureId: [lastSketchEditingFeature.current?.feature.id],
|
|
472
|
+
},
|
|
473
|
+
]);
|
|
474
|
+
}
|
|
475
|
+
lastSketchEditingFeature.current = undefined;
|
|
476
|
+
}, 50);
|
|
477
|
+
}
|
|
478
|
+
}, [layersRef, sketchEditingFeature, onEditFeatureChangeCbs]);
|
|
479
|
+
|
|
480
|
+
const handleControlPointMouseEvent: ControlPointMouseEventHandler = useCallback(
|
|
481
|
+
(index, isExtrudedPoint, eventType) => {
|
|
482
|
+
if (!state.matches("editing") || !state.context.controlPoints) return;
|
|
483
|
+
|
|
484
|
+
if (eventType === "mousedown") {
|
|
485
|
+
if (isExtrudedPoint) {
|
|
486
|
+
send({
|
|
487
|
+
type: "CATCH",
|
|
488
|
+
catchedControlPointIndex: -1,
|
|
489
|
+
controlPoints: state.context.controlPoints,
|
|
490
|
+
catchedExtrudedPoint: true,
|
|
491
|
+
});
|
|
492
|
+
} else {
|
|
493
|
+
send({
|
|
494
|
+
type: "CATCH",
|
|
495
|
+
catchedControlPointIndex: index,
|
|
496
|
+
controlPoints: state.context.controlPoints,
|
|
497
|
+
catchedExtrudedPoint: false,
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
} else {
|
|
501
|
+
if (
|
|
502
|
+
!isExtrudedPoint &&
|
|
503
|
+
(((state.context.type === "polygon" || state.context.type === "extrudedPolygon") &&
|
|
504
|
+
state.context.controlPoints.length > 3) ||
|
|
505
|
+
(state.context.type === "polyline" && state.context.controlPoints.length > 2))
|
|
506
|
+
) {
|
|
507
|
+
setSelectedControlPointIndex(index);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
[state, send],
|
|
512
|
+
);
|
|
584
513
|
|
|
585
514
|
// API
|
|
586
515
|
const getType = useGet(type);
|
|
@@ -593,29 +522,143 @@ export default function useHooks({
|
|
|
593
522
|
setType,
|
|
594
523
|
getOptions,
|
|
595
524
|
overrideOptions,
|
|
525
|
+
editFeature,
|
|
526
|
+
cancelEdit,
|
|
527
|
+
applyEdit,
|
|
528
|
+
deleteFeature,
|
|
529
|
+
onEditFeatureChange: onEditFeatureChangeRef.current,
|
|
596
530
|
}),
|
|
597
|
-
[
|
|
531
|
+
[
|
|
532
|
+
getType,
|
|
533
|
+
setType,
|
|
534
|
+
getOptions,
|
|
535
|
+
overrideOptions,
|
|
536
|
+
editFeature,
|
|
537
|
+
deleteFeature,
|
|
538
|
+
cancelEdit,
|
|
539
|
+
applyEdit,
|
|
540
|
+
],
|
|
598
541
|
);
|
|
599
542
|
|
|
543
|
+
useEffect(() => {
|
|
544
|
+
onMount?.();
|
|
545
|
+
}, [onMount]);
|
|
546
|
+
|
|
547
|
+
const handleDeleteControlPoint = useCallback(() => {
|
|
548
|
+
if (selectedControlPointIndex !== undefined) {
|
|
549
|
+
const newControlPoints = state.context.controlPoints?.toSpliced(selectedControlPointIndex, 1);
|
|
550
|
+
if (!newControlPoints) return;
|
|
551
|
+
send({
|
|
552
|
+
type: "UPDATE",
|
|
553
|
+
controlPoints: newControlPoints,
|
|
554
|
+
});
|
|
555
|
+
setGeometryOptions(op =>
|
|
556
|
+
op
|
|
557
|
+
? {
|
|
558
|
+
type: op.type,
|
|
559
|
+
controlPoints: newControlPoints,
|
|
560
|
+
}
|
|
561
|
+
: null,
|
|
562
|
+
);
|
|
563
|
+
setSelectedControlPointIndex(undefined);
|
|
564
|
+
}
|
|
565
|
+
}, [selectedControlPointIndex, state.context.controlPoints, send, setGeometryOptions]);
|
|
566
|
+
|
|
567
|
+
const handleDeleteControlPointRef = useRef(handleDeleteControlPoint);
|
|
568
|
+
handleDeleteControlPointRef.current = handleDeleteControlPoint;
|
|
569
|
+
|
|
570
|
+
const handleAddControlPoint = useCallback(
|
|
571
|
+
(controlPoint: Position3d, index: number) => {
|
|
572
|
+
if (state.context.controlPoints == null) return;
|
|
573
|
+
const insertPosition = index + 1;
|
|
574
|
+
const newControlPoints = state.context.controlPoints.toSpliced(
|
|
575
|
+
insertPosition,
|
|
576
|
+
0,
|
|
577
|
+
controlPoint,
|
|
578
|
+
);
|
|
579
|
+
send({
|
|
580
|
+
type: "UPDATE",
|
|
581
|
+
controlPoints: newControlPoints,
|
|
582
|
+
});
|
|
583
|
+
setGeometryOptions(op =>
|
|
584
|
+
op
|
|
585
|
+
? {
|
|
586
|
+
type: op.type,
|
|
587
|
+
controlPoints: newControlPoints,
|
|
588
|
+
}
|
|
589
|
+
: null,
|
|
590
|
+
);
|
|
591
|
+
},
|
|
592
|
+
[state.context.controlPoints, send, setGeometryOptions],
|
|
593
|
+
);
|
|
594
|
+
|
|
595
|
+
//
|
|
596
|
+
const tempSwitchToMoveMode = useRef(false);
|
|
597
|
+
const stateRef = useRef(state);
|
|
598
|
+
stateRef.current = state;
|
|
599
|
+
|
|
600
|
+
useEffect(() => {
|
|
601
|
+
return window.addEventListener("keydown", event => {
|
|
602
|
+
if (event.code === "Space" && stateRef.current.matches("editing")) {
|
|
603
|
+
tempSwitchToMoveMode.current = true;
|
|
604
|
+
overrideInteractionMode?.("move");
|
|
605
|
+
} else if (event.code === "Delete" && stateRef.current.matches("editing")) {
|
|
606
|
+
handleDeleteControlPointRef.current();
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
}, [overrideInteractionMode]);
|
|
610
|
+
|
|
611
|
+
useEffect(() => {
|
|
612
|
+
return window.addEventListener("keyup", event => {
|
|
613
|
+
if (event.code === "Space" && tempSwitchToMoveMode.current) {
|
|
614
|
+
overrideInteractionMode?.("sketch");
|
|
615
|
+
tempSwitchToMoveMode.current = false;
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
}, [overrideInteractionMode]);
|
|
619
|
+
|
|
620
|
+
useEffect(() => {
|
|
621
|
+
if (!isEditing) {
|
|
622
|
+
overrideInteractionModeRef.current?.("default");
|
|
623
|
+
}
|
|
624
|
+
}, [isEditing]);
|
|
625
|
+
|
|
600
626
|
return {
|
|
601
627
|
state,
|
|
628
|
+
isEditing,
|
|
629
|
+
catchedControlPointIndex,
|
|
630
|
+
catchedExtrudedPoint,
|
|
602
631
|
extrudedHeight,
|
|
632
|
+
extrudedPoint,
|
|
633
|
+
centroidBasePoint,
|
|
634
|
+
centroidExtrudedPoint,
|
|
603
635
|
geometryOptions,
|
|
604
636
|
color: sketchOptions.color,
|
|
605
637
|
disableShadow: sketchOptions.disableShadow,
|
|
606
|
-
|
|
607
|
-
|
|
638
|
+
selectedControlPointIndex,
|
|
639
|
+
handleControlPointMouseEvent,
|
|
640
|
+
handleAddControlPoint,
|
|
641
|
+
};
|
|
608
642
|
}
|
|
609
643
|
|
|
610
|
-
function
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
controlPoint
|
|
618
|
-
|
|
619
|
-
)
|
|
620
|
-
|
|
644
|
+
async function getCentroid(
|
|
645
|
+
controlPoints: readonly Position3d[],
|
|
646
|
+
engineRef: RefObject<EngineRef | null>,
|
|
647
|
+
): Promise<Position3d | undefined> {
|
|
648
|
+
let totalLat = 0;
|
|
649
|
+
let totalLng = 0;
|
|
650
|
+
|
|
651
|
+
controlPoints.forEach(controlPoint => {
|
|
652
|
+
const p = engineRef.current?.toLngLatHeight(...controlPoint);
|
|
653
|
+
if (!p) return;
|
|
654
|
+
totalLng += p[0];
|
|
655
|
+
totalLat += p[1];
|
|
656
|
+
});
|
|
657
|
+
|
|
658
|
+
const centroidLat = totalLat / controlPoints.length;
|
|
659
|
+
const centroidLng = totalLng / controlPoints.length;
|
|
660
|
+
const centroidHeight =
|
|
661
|
+
(await engineRef.current?.sampleTerrainHeight(centroidLng, centroidLat)) ?? 0;
|
|
662
|
+
|
|
663
|
+
return engineRef.current?.toXYZ(centroidLng, centroidLat, centroidHeight);
|
|
621
664
|
}
|