@3driseai/3drise-viewer 0.1.42 → 0.1.43
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/animationsV2/ClipsRuntime.d.ts +16 -1
- package/dist/animationsV2/ClipsRuntime.d.ts.map +1 -1
- package/dist/animationsV2/ClipsRuntime.js +144 -25
- package/dist/animationsV2/appliers.d.ts +9 -0
- package/dist/animationsV2/appliers.d.ts.map +1 -1
- package/dist/animationsV2/appliers.js +62 -2
- package/dist/animationsV2/clipUtils.d.ts +30 -0
- package/dist/animationsV2/clipUtils.d.ts.map +1 -1
- package/dist/animationsV2/clipUtils.js +163 -17
- package/dist/animationsV2/elementSettings.d.ts +5 -0
- package/dist/animationsV2/elementSettings.d.ts.map +1 -1
- package/dist/animationsV2/elementSettings.js +6 -3
- package/dist/animationsV2/sequenceUtils.js +4 -4
- package/dist/animationsV2/types.d.ts +23 -0
- package/dist/animationsV2/types.d.ts.map +1 -1
- package/dist/api/sceneHandle.js +2 -2
- package/dist/components/CreatedObject.d.ts +3 -0
- package/dist/components/CreatedObject.d.ts.map +1 -1
- package/dist/components/CreatedObject.js +6 -2
- package/dist/components/CustomPrimitive.d.ts.map +1 -1
- package/dist/components/CustomPrimitive.js +1 -10
- package/dist/components/EnvironmentManager.d.ts.map +1 -1
- package/dist/components/EnvironmentManager.js +11 -5
- package/dist/components/GeometryShape.d.ts +5 -2
- package/dist/components/GeometryShape.d.ts.map +1 -1
- package/dist/components/GeometryShape.js +71 -10
- package/dist/components/LandObject.d.ts.map +1 -1
- package/dist/components/LandObject.js +1 -1
- package/dist/components/LayoutInstances.d.ts +2 -1
- package/dist/components/LayoutInstances.d.ts.map +1 -1
- package/dist/components/LayoutInstances.js +39 -6
- package/dist/components/LightObject.d.ts.map +1 -1
- package/dist/components/LightObject.js +3 -0
- package/dist/components/ObjectNode.d.ts.map +1 -1
- package/dist/components/ObjectNode.js +62 -13
- package/dist/components/OceanBuilder.d.ts +2 -0
- package/dist/components/OceanBuilder.d.ts.map +1 -1
- package/dist/components/OceanBuilder.js +2 -1
- package/dist/components/RenderEffects.d.ts +8 -0
- package/dist/components/RenderEffects.d.ts.map +1 -0
- package/dist/components/RenderEffects.js +120 -0
- package/dist/components/SceneBuilder.d.ts.map +1 -1
- package/dist/components/SceneBuilder.js +18 -9
- package/dist/components/SportsObject.d.ts +9 -0
- package/dist/components/SportsObject.d.ts.map +1 -0
- package/dist/components/SportsObject.js +20 -0
- package/dist/components/UrbanObject.d.ts +9 -0
- package/dist/components/UrbanObject.d.ts.map +1 -0
- package/dist/components/UrbanObject.js +28 -0
- package/dist/components/VegetationObject.d.ts +9 -0
- package/dist/components/VegetationObject.d.ts.map +1 -0
- package/dist/components/VegetationObject.js +26 -0
- package/dist/components/WaterObject.d.ts +15 -0
- package/dist/components/WaterObject.d.ts.map +1 -0
- package/dist/components/WaterObject.js +29 -0
- package/dist/components/index.d.ts +7 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +6 -1
- package/dist/components/land/LandPatch.d.ts +3 -1
- package/dist/components/land/LandPatch.d.ts.map +1 -1
- package/dist/components/land/LandPatch.js +80 -7
- package/dist/components/layout/InstancedLayout.d.ts +19 -0
- package/dist/components/layout/InstancedLayout.d.ts.map +1 -0
- package/dist/components/layout/InstancedLayout.js +154 -0
- package/dist/components/layout/LayoutGrounds.d.ts +19 -0
- package/dist/components/layout/LayoutGrounds.d.ts.map +1 -0
- package/dist/components/layout/LayoutGrounds.js +104 -0
- package/dist/components/layout/LinkProxies.d.ts +5 -0
- package/dist/components/layout/LinkProxies.d.ts.map +1 -0
- package/dist/components/layout/LinkProxies.js +51 -0
- package/dist/components/layout/LinkedSource.d.ts +14 -0
- package/dist/components/layout/LinkedSource.d.ts.map +1 -0
- package/dist/components/layout/LinkedSource.js +129 -0
- package/dist/components/projector/Projector.d.ts +14 -0
- package/dist/components/projector/Projector.d.ts.map +1 -0
- package/dist/components/projector/Projector.js +44 -0
- package/dist/components/projector/index.d.ts +4 -0
- package/dist/components/projector/index.d.ts.map +1 -0
- package/dist/components/projector/index.js +2 -0
- package/dist/components/projector/projectorCore.d.ts +19 -0
- package/dist/components/projector/projectorCore.d.ts.map +1 -0
- package/dist/components/projector/projectorCore.js +545 -0
- package/dist/components/sports/SportsBall.d.ts +9 -0
- package/dist/components/sports/SportsBall.d.ts.map +1 -0
- package/dist/components/sports/SportsBall.js +23 -0
- package/dist/components/sports/SportsCourt.d.ts +9 -0
- package/dist/components/sports/SportsCourt.d.ts.map +1 -0
- package/dist/components/sports/SportsCourt.js +23 -0
- package/dist/components/sports/SportsEquipment.d.ts +9 -0
- package/dist/components/sports/SportsEquipment.d.ts.map +1 -0
- package/dist/components/sports/SportsEquipment.js +23 -0
- package/dist/components/sports/SportsGoal.d.ts +9 -0
- package/dist/components/sports/SportsGoal.d.ts.map +1 -0
- package/dist/components/sports/SportsGoal.js +23 -0
- package/dist/components/sports/core/ball.d.ts +166 -0
- package/dist/components/sports/core/ball.d.ts.map +1 -0
- package/dist/components/sports/core/ball.js +402 -0
- package/dist/components/sports/core/court.d.ts +442 -0
- package/dist/components/sports/core/court.d.ts.map +1 -0
- package/dist/components/sports/core/court.js +658 -0
- package/dist/components/sports/core/equipment.d.ts +103 -0
- package/dist/components/sports/core/equipment.d.ts.map +1 -0
- package/dist/components/sports/core/equipment.js +403 -0
- package/dist/components/sports/core/goal.d.ts +98 -0
- package/dist/components/sports/core/goal.d.ts.map +1 -0
- package/dist/components/sports/core/goal.js +44 -0
- package/dist/components/sports/index.d.ts +11 -0
- package/dist/components/sports/index.d.ts.map +1 -0
- package/dist/components/sports/index.js +8 -0
- package/dist/components/sports/sportsCore.d.ts +195 -0
- package/dist/components/sports/sportsCore.d.ts.map +1 -0
- package/dist/components/sports/sportsCore.js +758 -0
- package/dist/components/sports/useSportsInstance.d.ts +35 -0
- package/dist/components/sports/useSportsInstance.d.ts.map +1 -0
- package/dist/components/sports/useSportsInstance.js +47 -0
- package/dist/components/terrain/TerrainSurface.d.ts.map +1 -1
- package/dist/components/terrain/TerrainSurface.js +14 -0
- package/dist/components/urban/UrbanBlock.d.ts +9 -0
- package/dist/components/urban/UrbanBlock.d.ts.map +1 -0
- package/dist/components/urban/UrbanBlock.js +23 -0
- package/dist/components/urban/UrbanBuilding.d.ts +9 -0
- package/dist/components/urban/UrbanBuilding.d.ts.map +1 -0
- package/dist/components/urban/UrbanBuilding.js +23 -0
- package/dist/components/urban/UrbanJunction.d.ts +9 -0
- package/dist/components/urban/UrbanJunction.d.ts.map +1 -0
- package/dist/components/urban/UrbanJunction.js +23 -0
- package/dist/components/urban/UrbanPark.d.ts +9 -0
- package/dist/components/urban/UrbanPark.d.ts.map +1 -0
- package/dist/components/urban/UrbanPark.js +23 -0
- package/dist/components/urban/UrbanParkingLot.d.ts +9 -0
- package/dist/components/urban/UrbanParkingLot.d.ts.map +1 -0
- package/dist/components/urban/UrbanParkingLot.js +23 -0
- package/dist/components/urban/UrbanPlaza.d.ts +9 -0
- package/dist/components/urban/UrbanPlaza.d.ts.map +1 -0
- package/dist/components/urban/UrbanPlaza.js +23 -0
- package/dist/components/urban/UrbanRoad.d.ts +9 -0
- package/dist/components/urban/UrbanRoad.d.ts.map +1 -0
- package/dist/components/urban/UrbanRoad.js +23 -0
- package/dist/components/urban/UrbanSignage.d.ts +9 -0
- package/dist/components/urban/UrbanSignage.d.ts.map +1 -0
- package/dist/components/urban/UrbanSignage.js +23 -0
- package/dist/components/urban/UrbanSkyline.d.ts +9 -0
- package/dist/components/urban/UrbanSkyline.d.ts.map +1 -0
- package/dist/components/urban/UrbanSkyline.js +23 -0
- package/dist/components/urban/UrbanStreetFurniture.d.ts +9 -0
- package/dist/components/urban/UrbanStreetFurniture.d.ts.map +1 -0
- package/dist/components/urban/UrbanStreetFurniture.js +23 -0
- package/dist/components/urban/UrbanStreetGrid.d.ts +9 -0
- package/dist/components/urban/UrbanStreetGrid.d.ts.map +1 -0
- package/dist/components/urban/UrbanStreetGrid.js +34 -0
- package/dist/components/urban/UrbanTraffic.d.ts +9 -0
- package/dist/components/urban/UrbanTraffic.d.ts.map +1 -0
- package/dist/components/urban/UrbanTraffic.js +23 -0
- package/dist/components/urban/core/block.d.ts +119 -0
- package/dist/components/urban/core/block.d.ts.map +1 -0
- package/dist/components/urban/core/block.js +266 -0
- package/dist/components/urban/core/building.d.ts +128 -0
- package/dist/components/urban/core/building.d.ts.map +1 -0
- package/dist/components/urban/core/building.js +741 -0
- package/dist/components/urban/core/junction.d.ts +152 -0
- package/dist/components/urban/core/junction.d.ts.map +1 -0
- package/dist/components/urban/core/junction.js +617 -0
- package/dist/components/urban/core/park.d.ts +67 -0
- package/dist/components/urban/core/park.d.ts.map +1 -0
- package/dist/components/urban/core/park.js +176 -0
- package/dist/components/urban/core/parkingLot.d.ts +82 -0
- package/dist/components/urban/core/parkingLot.d.ts.map +1 -0
- package/dist/components/urban/core/parkingLot.js +284 -0
- package/dist/components/urban/core/plaza.d.ts +24 -0
- package/dist/components/urban/core/plaza.d.ts.map +1 -0
- package/dist/components/urban/core/plaza.js +243 -0
- package/dist/components/urban/core/road.d.ts +113 -0
- package/dist/components/urban/core/road.d.ts.map +1 -0
- package/dist/components/urban/core/road.js +347 -0
- package/dist/components/urban/core/signage.d.ts +83 -0
- package/dist/components/urban/core/signage.d.ts.map +1 -0
- package/dist/components/urban/core/signage.js +209 -0
- package/dist/components/urban/core/skyline.d.ts +100 -0
- package/dist/components/urban/core/skyline.d.ts.map +1 -0
- package/dist/components/urban/core/skyline.js +89 -0
- package/dist/components/urban/core/streetFurniture.d.ts +75 -0
- package/dist/components/urban/core/streetFurniture.d.ts.map +1 -0
- package/dist/components/urban/core/streetFurniture.js +193 -0
- package/dist/components/urban/core/streetGrid.d.ts +134 -0
- package/dist/components/urban/core/streetGrid.d.ts.map +1 -0
- package/dist/components/urban/core/streetGrid.js +422 -0
- package/dist/components/urban/core/traffic.d.ts +125 -0
- package/dist/components/urban/core/traffic.d.ts.map +1 -0
- package/dist/components/urban/core/traffic.js +305 -0
- package/dist/components/urban/index.d.ts +29 -0
- package/dist/components/urban/index.d.ts.map +1 -0
- package/dist/components/urban/index.js +16 -0
- package/dist/components/urban/textureSetResolver.d.ts +8 -0
- package/dist/components/urban/textureSetResolver.d.ts.map +1 -0
- package/dist/components/urban/textureSetResolver.js +16 -0
- package/dist/components/urban/urbanCore.d.ts +262 -0
- package/dist/components/urban/urbanCore.d.ts.map +1 -0
- package/dist/components/urban/urbanCore.js +928 -0
- package/dist/components/urban/useUrbanInstance.d.ts +53 -0
- package/dist/components/urban/useUrbanInstance.d.ts.map +1 -0
- package/dist/components/urban/useUrbanInstance.js +100 -0
- package/dist/components/vegetation/VegetationBush.d.ts +9 -0
- package/dist/components/vegetation/VegetationBush.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationBush.js +23 -0
- package/dist/components/vegetation/VegetationCrops.d.ts +9 -0
- package/dist/components/vegetation/VegetationCrops.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationCrops.js +23 -0
- package/dist/components/vegetation/VegetationFlowers.d.ts +9 -0
- package/dist/components/vegetation/VegetationFlowers.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationFlowers.js +23 -0
- package/dist/components/vegetation/VegetationForest.d.ts +9 -0
- package/dist/components/vegetation/VegetationForest.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationForest.js +23 -0
- package/dist/components/vegetation/VegetationFruit.d.ts +9 -0
- package/dist/components/vegetation/VegetationFruit.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationFruit.js +23 -0
- package/dist/components/vegetation/VegetationGrass.d.ts +9 -0
- package/dist/components/vegetation/VegetationGrass.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationGrass.js +23 -0
- package/dist/components/vegetation/VegetationHedge.d.ts +9 -0
- package/dist/components/vegetation/VegetationHedge.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationHedge.js +23 -0
- package/dist/components/vegetation/VegetationIvy.d.ts +9 -0
- package/dist/components/vegetation/VegetationIvy.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationIvy.js +23 -0
- package/dist/components/vegetation/VegetationTree.d.ts +9 -0
- package/dist/components/vegetation/VegetationTree.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationTree.js +23 -0
- package/dist/components/vegetation/VegetationVegetable.d.ts +9 -0
- package/dist/components/vegetation/VegetationVegetable.d.ts.map +1 -0
- package/dist/components/vegetation/VegetationVegetable.js +23 -0
- package/dist/components/vegetation/core/bush.d.ts +1256 -0
- package/dist/components/vegetation/core/bush.d.ts.map +1 -0
- package/dist/components/vegetation/core/bush.js +376 -0
- package/dist/components/vegetation/core/crops.d.ts +1033 -0
- package/dist/components/vegetation/core/crops.d.ts.map +1 -0
- package/dist/components/vegetation/core/crops.js +378 -0
- package/dist/components/vegetation/core/flowers.d.ts +648 -0
- package/dist/components/vegetation/core/flowers.d.ts.map +1 -0
- package/dist/components/vegetation/core/flowers.js +225 -0
- package/dist/components/vegetation/core/forest.d.ts +138 -0
- package/dist/components/vegetation/core/forest.d.ts.map +1 -0
- package/dist/components/vegetation/core/forest.js +310 -0
- package/dist/components/vegetation/core/fruit.d.ts +99 -0
- package/dist/components/vegetation/core/fruit.d.ts.map +1 -0
- package/dist/components/vegetation/core/fruit.js +77 -0
- package/dist/components/vegetation/core/grass.d.ts +103 -0
- package/dist/components/vegetation/core/grass.d.ts.map +1 -0
- package/dist/components/vegetation/core/grass.js +102 -0
- package/dist/components/vegetation/core/hedge.d.ts +193 -0
- package/dist/components/vegetation/core/hedge.d.ts.map +1 -0
- package/dist/components/vegetation/core/hedge.js +243 -0
- package/dist/components/vegetation/core/ivy.d.ts +213 -0
- package/dist/components/vegetation/core/ivy.d.ts.map +1 -0
- package/dist/components/vegetation/core/ivy.js +173 -0
- package/dist/components/vegetation/core/tree.d.ts +1117 -0
- package/dist/components/vegetation/core/tree.d.ts.map +1 -0
- package/dist/components/vegetation/core/tree.js +408 -0
- package/dist/components/vegetation/core/vegetable.d.ts +99 -0
- package/dist/components/vegetation/core/vegetable.d.ts.map +1 -0
- package/dist/components/vegetation/core/vegetable.js +76 -0
- package/dist/components/vegetation/index.d.ts +23 -0
- package/dist/components/vegetation/index.d.ts.map +1 -0
- package/dist/components/vegetation/index.js +14 -0
- package/dist/components/vegetation/produceCore.d.ts +929 -0
- package/dist/components/vegetation/produceCore.d.ts.map +1 -0
- package/dist/components/vegetation/produceCore.js +723 -0
- package/dist/components/vegetation/useVegetationInstance.d.ts +39 -0
- package/dist/components/vegetation/useVegetationInstance.d.ts.map +1 -0
- package/dist/components/vegetation/useVegetationInstance.js +45 -0
- package/dist/components/vegetation/vegetationCore.d.ts +412 -0
- package/dist/components/vegetation/vegetationCore.d.ts.map +1 -0
- package/dist/components/vegetation/vegetationCore.js +1728 -0
- package/dist/components/volumetricClouds/VolumetricCloudsPass.d.ts +5 -0
- package/dist/components/volumetricClouds/VolumetricCloudsPass.d.ts.map +1 -1
- package/dist/components/volumetricClouds/VolumetricCloudsPass.js +39 -13
- package/dist/components/water/OceanSurface.d.ts.map +1 -1
- package/dist/components/water/OceanSurface.js +3 -2
- package/dist/components/water/WaterBody.d.ts.map +1 -1
- package/dist/components/water/WaterBody.js +31 -10
- package/dist/components/water/WaterFountain.d.ts +9 -0
- package/dist/components/water/WaterFountain.d.ts.map +1 -0
- package/dist/components/water/WaterFountain.js +24 -0
- package/dist/components/water/WaterStream.d.ts +9 -0
- package/dist/components/water/WaterStream.d.ts.map +1 -0
- package/dist/components/water/WaterStream.js +24 -0
- package/dist/components/water/WaterWaterfall.d.ts +9 -0
- package/dist/components/water/WaterWaterfall.d.ts.map +1 -0
- package/dist/components/water/WaterWaterfall.js +24 -0
- package/dist/components/water/core/fountain.d.ts +70 -0
- package/dist/components/water/core/fountain.d.ts.map +1 -0
- package/dist/components/water/core/fountain.js +619 -0
- package/dist/components/water/core/stream.d.ts +72 -0
- package/dist/components/water/core/stream.d.ts.map +1 -0
- package/dist/components/water/core/stream.js +167 -0
- package/dist/components/water/core/waterfall.d.ts +78 -0
- package/dist/components/water/core/waterfall.d.ts.map +1 -0
- package/dist/components/water/core/waterfall.js +325 -0
- package/dist/components/water/index.d.ts +8 -0
- package/dist/components/water/index.d.ts.map +1 -1
- package/dist/components/water/index.js +7 -0
- package/dist/components/water/types.d.ts +3 -0
- package/dist/components/water/types.d.ts.map +1 -1
- package/dist/components/water/useWaterInstance.d.ts +43 -0
- package/dist/components/water/useWaterInstance.d.ts.map +1 -0
- package/dist/components/water/useWaterInstance.js +89 -0
- package/dist/components/water/waterCore.d.ts +179 -0
- package/dist/components/water/waterCore.d.ts.map +1 -0
- package/dist/components/water/waterCore.js +516 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +9 -1
- package/dist/hooks/index.d.ts +7 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +5 -2
- package/dist/hooks/useActionPatch.d.ts +23 -0
- package/dist/hooks/useActionPatch.d.ts.map +1 -0
- package/dist/hooks/useActionPatch.js +38 -0
- package/dist/hooks/useCloudSun.d.ts.map +1 -1
- package/dist/hooks/useCloudSun.js +3 -2
- package/dist/hooks/useCommittedInstance.d.ts +6 -0
- package/dist/hooks/useCommittedInstance.d.ts.map +1 -0
- package/dist/hooks/useCommittedInstance.js +42 -0
- package/dist/hooks/useConfigLive.d.ts +1 -1
- package/dist/hooks/useConfigLive.d.ts.map +1 -1
- package/dist/hooks/useContinuousEffects.d.ts.map +1 -1
- package/dist/hooks/useContinuousEffects.js +36 -20
- package/dist/hooks/useGridLayout.d.ts +7 -0
- package/dist/hooks/useGridLayout.d.ts.map +1 -0
- package/dist/hooks/useGridLayout.js +10 -0
- package/dist/hooks/useInteractionEffects.d.ts.map +1 -1
- package/dist/hooks/useInteractionEffects.js +48 -9
- package/dist/hooks/useLightLive.d.ts.map +1 -1
- package/dist/hooks/useLightLive.js +2 -0
- package/dist/hooks/useLinkStatus.d.ts +7 -0
- package/dist/hooks/useLinkStatus.d.ts.map +1 -0
- package/dist/hooks/useLinkStatus.js +20 -0
- package/dist/hooks/useMaterialApplication.d.ts +6 -1
- package/dist/hooks/useMaterialApplication.d.ts.map +1 -1
- package/dist/hooks/useMaterialApplication.js +7 -2
- package/dist/hooks/useOceanMaterial.d.ts +11 -1
- package/dist/hooks/useOceanMaterial.d.ts.map +1 -1
- package/dist/hooks/useOceanMaterial.js +185 -27
- package/dist/hooks/usePathAnimation.d.ts +8 -0
- package/dist/hooks/usePathAnimation.d.ts.map +1 -1
- package/dist/hooks/usePathAnimation.js +140 -59
- package/dist/hooks/useResolvedLayout.d.ts +10 -0
- package/dist/hooks/useResolvedLayout.d.ts.map +1 -0
- package/dist/hooks/useResolvedLayout.js +17 -0
- package/dist/hooks/useTimeLighting.d.ts +36 -0
- package/dist/hooks/useTimeLighting.d.ts.map +1 -0
- package/dist/hooks/useTimeLighting.js +67 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/operations/catalogue/shaderLayers.d.ts.map +1 -1
- package/dist/operations/catalogue/shaderLayers.js +26 -3
- package/dist/render/renderLive.d.ts +11 -0
- package/dist/render/renderLive.d.ts.map +1 -0
- package/dist/render/renderLive.js +57 -0
- package/dist/shaders/glsl/oceanCore.glsl.d.ts +2 -2
- package/dist/shaders/glsl/oceanCore.glsl.d.ts.map +1 -1
- package/dist/shaders/glsl/oceanCore.glsl.js +35 -5
- package/dist/shaders/ocean/OceanSurfaceMaterial.d.ts +12 -0
- package/dist/shaders/ocean/OceanSurfaceMaterial.d.ts.map +1 -1
- package/dist/shaders/ocean/OceanSurfaceMaterial.js +55 -7
- package/dist/shaders/terrain/TerrainMaterial.d.ts.map +1 -1
- package/dist/shaders/terrain/TerrainMaterial.js +28 -0
- package/dist/triggers/kinds/change.js +1 -1
- package/dist/utils/composerHostedPass.d.ts +74 -0
- package/dist/utils/composerHostedPass.d.ts.map +1 -0
- package/dist/utils/composerHostedPass.js +63 -0
- package/dist/utils/geometryScript.d.ts +17 -0
- package/dist/utils/geometryScript.d.ts.map +1 -0
- package/dist/utils/geometryScript.js +92 -0
- package/dist/utils/geometryScript.worker.d.ts +2 -0
- package/dist/utils/geometryScript.worker.d.ts.map +1 -0
- package/dist/utils/geometryScript.worker.js +42 -0
- package/dist/utils/groundRegistry.d.ts +11 -0
- package/dist/utils/groundRegistry.d.ts.map +1 -0
- package/dist/utils/groundRegistry.js +39 -0
- package/dist/utils/instancingSupport.d.ts +9 -0
- package/dist/utils/instancingSupport.d.ts.map +1 -0
- package/dist/utils/instancingSupport.js +13 -0
- package/dist/utils/landPatch.d.ts +26 -5
- package/dist/utils/landPatch.d.ts.map +1 -1
- package/dist/utils/landPatch.js +124 -9
- package/dist/utils/layoutPlacement.d.ts +30 -0
- package/dist/utils/layoutPlacement.d.ts.map +1 -0
- package/dist/utils/layoutPlacement.js +113 -0
- package/dist/utils/linkRegistry.d.ts +15 -0
- package/dist/utils/linkRegistry.d.ts.map +1 -0
- package/dist/utils/linkRegistry.js +11 -0
- package/dist/utils/shapes.d.ts +28 -2
- package/dist/utils/shapes.d.ts.map +1 -1
- package/dist/utils/shapes.js +32 -3
- package/dist/utils/sharedParts.d.ts +61 -0
- package/dist/utils/sharedParts.d.ts.map +1 -0
- package/dist/utils/sharedParts.js +268 -0
- package/dist/utils/svgAsset.d.ts +6 -0
- package/dist/utils/svgAsset.d.ts.map +1 -0
- package/dist/utils/svgAsset.js +46 -0
- package/dist/utils/waterLight.d.ts +29 -0
- package/dist/utils/waterLight.d.ts.map +1 -0
- package/dist/utils/waterLight.js +67 -0
- package/dist/utils/waterReflection.d.ts +185 -0
- package/dist/utils/waterReflection.d.ts.map +1 -0
- package/dist/utils/waterReflection.js +616 -0
- package/package.json +4 -3
|
@@ -4,20 +4,30 @@ import { useFrame } from '@react-three/fiber';
|
|
|
4
4
|
import { useCloudSun } from './useCloudSun.js';
|
|
5
5
|
import { OCEAN_LIVE_KEY } from './useOceanLive.js';
|
|
6
6
|
import { OceanSurfaceMaterial } from '../shaders/ocean/OceanSurfaceMaterial.js';
|
|
7
|
-
import {
|
|
8
|
-
import { applyTerrainAmbient, applyTerrainFieldUniforms } from '../utils/terrainUniforms.js';
|
|
7
|
+
import { applyTerrainFieldUniforms } from '../utils/terrainUniforms.js';
|
|
9
8
|
import { applyOceanUniforms } from '../utils/oceanUniforms.js';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
* runs the moon at ~0.1 of the sun; the water gets a little more so the glitter
|
|
13
|
-
* path reads at night. Tuning knob. */
|
|
14
|
-
const MOON_WATER_STRENGTH = 0.15;
|
|
9
|
+
import { applyWaterLight, createWaterLightScratch } from '../utils/waterLight.js';
|
|
10
|
+
import { PlanarReflector, applyWaterReflection, electedWaterSurface, noteWaterViewer, registerWaterSurface, WaterProbe, WaterVisibility, waterProbeSize, waterViewerPosition, isWaterMirrorPass, } from '../utils/waterReflection.js';
|
|
15
11
|
import { getAnimatableProperties } from '@3driseai/3drise-core';
|
|
16
12
|
import { applyConfigKeyframeAnimations, applyConfigMouseMove, } from '../utils/configAnimations.js';
|
|
17
|
-
export function useOceanMaterial({ id, config, quality, skySettings, timeSettings, sunIntensity = 1, animations, mouseMove, terrain, onFrame, }) {
|
|
13
|
+
export function useOceanMaterial({ id, config, quality, skySettings, timeSettings, sunIntensity = 1, animations, mouseMove, terrain, onFrame, world = false, }) {
|
|
18
14
|
const { state: sun, update: updateSun } = useCloudSun({ skySettings, timeSettings });
|
|
19
|
-
const
|
|
15
|
+
const light = useMemo(createWaterLightScratch, []);
|
|
20
16
|
const material = useMemo(() => new OceanSurfaceMaterial(), []);
|
|
17
|
+
// A placed body sits just above whatever is under it (a lawn, a plaza, a
|
|
18
|
+
// basin mesh). Far away the depth buffer cannot separate a few centimetres
|
|
19
|
+
// (24-bit depth with near 0.1: ~10 cm at 400 m, ~40 cm at 800 m), so water
|
|
20
|
+
// and ground z-fight — speckle that only raising the water fixed. A depth bias
|
|
21
|
+
// toward the camera, counted in depth-buffer steps, makes the water win at
|
|
22
|
+
// every distance without moving it. Bodies only: on the world ocean it would
|
|
23
|
+
// let the waterline creep up the beaches at distance.
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const body = !world;
|
|
26
|
+
material.polygonOffset = body;
|
|
27
|
+
material.polygonOffsetFactor = body ? -2 : 0;
|
|
28
|
+
material.polygonOffsetUnits = body ? -8 : 0;
|
|
29
|
+
material.needsUpdate = true;
|
|
30
|
+
}, [material, world]);
|
|
21
31
|
useEffect(() => () => { material.dispose(); }, [material]);
|
|
22
32
|
// Live controller overrides. A slider drag writes here on every pointer-move
|
|
23
33
|
// and the frame loop reads it on top of the config, so the water responds
|
|
@@ -55,25 +65,104 @@ export function useOceanMaterial({ id, config, quality, skySettings, timeSetting
|
|
|
55
65
|
root.userData[OCEAN_LIVE_KEY] = liveHandle;
|
|
56
66
|
return () => { delete root.userData[OCEAN_LIVE_KEY]; };
|
|
57
67
|
}, [id, liveHandle]);
|
|
58
|
-
|
|
68
|
+
// The reflection election (utils/waterReflection.ts). What this surface
|
|
69
|
+
// asks for is read from the config it is rendering this frame — live drag
|
|
70
|
+
// included — so the knob answers at once. The pass itself is created the
|
|
71
|
+
// first time this surface wins and kept while it is mounted.
|
|
72
|
+
const frame = useRef({ mode: 'env', elected: false, scale: 0.5, drawn: -1, baked: -1, n: 0 });
|
|
73
|
+
const reflector = useRef(null);
|
|
74
|
+
useEffect(() => () => { reflector.current?.dispose(); reflector.current = null; }, []);
|
|
75
|
+
// 'baked': this surface's own probe (utils/waterReflection.ts WaterProbe).
|
|
76
|
+
const probe = useRef(null);
|
|
77
|
+
useEffect(() => () => { probe.current?.dispose(); probe.current = null; }, []);
|
|
78
|
+
const probeAt = useMemo(() => new THREE.Vector3(), []);
|
|
79
|
+
// Is any of this body's water actually on screen? (occlusion query; utils/waterReflection.ts)
|
|
80
|
+
const visibility = useMemo(() => new WaterVisibility(), []);
|
|
81
|
+
useEffect(() => () => visibility.dispose(), [visibility]);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
const root = rootRef.current;
|
|
84
|
+
if (!root)
|
|
85
|
+
return;
|
|
86
|
+
return registerWaterSurface({
|
|
87
|
+
id,
|
|
88
|
+
world,
|
|
89
|
+
object: root,
|
|
90
|
+
size: () => config.size,
|
|
91
|
+
mode: () => frame.current.mode,
|
|
92
|
+
visible: world ? undefined : () => visibility.isVisible(),
|
|
93
|
+
});
|
|
94
|
+
}, [id, world, config.size, visibility]);
|
|
95
|
+
const planePoint = useMemo(() => new THREE.Vector3(), []);
|
|
96
|
+
// A placed body's outline on its plane, world space: the mirror renders only
|
|
97
|
+
// the rectangle it covers (utils/waterReflection.ts).
|
|
98
|
+
const corners = useMemo(() => [new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3()], []);
|
|
99
|
+
const sizeRef = useRef([1, 1]);
|
|
100
|
+
sizeRef.current = config.size;
|
|
101
|
+
const bodyScale = useMemo(() => new THREE.Vector3(1, 1, 1), []);
|
|
102
|
+
// Scratch for the current (no per-frame allocation).
|
|
103
|
+
const [flowLocal, flowWorld, flowVec, flowQuat] = useMemo(() => [new THREE.Vector2(), new THREE.Vector2(), new THREE.Vector3(), new THREE.Quaternion()], []);
|
|
104
|
+
const onBeforeRender = useMemo(() => (renderer, scene, camera) => {
|
|
105
|
+
noteWaterViewer(camera);
|
|
106
|
+
bakeProbe(renderer, scene, camera);
|
|
107
|
+
renderMirror(renderer, scene, camera);
|
|
108
|
+
// Last: the query must enclose only this mesh's own draw.
|
|
109
|
+
if (!world)
|
|
110
|
+
visibility.begin(renderer);
|
|
111
|
+
}, [world, visibility]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
112
|
+
const onAfterRender = useMemo(() => () => { if (!world)
|
|
113
|
+
visibility.end(); }, [world, visibility]);
|
|
114
|
+
// One probe face per frame while the capture is stale — only while this water
|
|
115
|
+
// is actually being drawn (a body behind the city waits until it is seen).
|
|
116
|
+
function bakeProbe(renderer, scene, camera) {
|
|
117
|
+
const f = frame.current;
|
|
118
|
+
const p = probe.current;
|
|
119
|
+
const root = rootRef.current;
|
|
120
|
+
if (f.mode !== 'baked' || !p || !root || !p.stale || isWaterMirrorPass())
|
|
121
|
+
return;
|
|
122
|
+
if (f.baked === f.n)
|
|
123
|
+
return;
|
|
124
|
+
if (!world && !visibility.isVisible())
|
|
125
|
+
return;
|
|
126
|
+
f.baked = f.n;
|
|
127
|
+
p.step(renderer, scene, root, camera.layers.mask);
|
|
128
|
+
if (p.valid)
|
|
129
|
+
applyWaterReflection(material.uniforms, 'baked', null, p);
|
|
130
|
+
}
|
|
131
|
+
function renderMirror(renderer, scene, camera) {
|
|
132
|
+
const f = frame.current;
|
|
133
|
+
const root = rootRef.current;
|
|
134
|
+
// Never from inside another pass (a probe capture draws this mesh too).
|
|
135
|
+
if (!f.elected || !root || isWaterMirrorPass())
|
|
136
|
+
return;
|
|
137
|
+
// Once per frame, whichever of the host's meshes asks first (the world
|
|
138
|
+
// ocean has a ring per clipmap level).
|
|
139
|
+
if (f.drawn === f.n)
|
|
140
|
+
return;
|
|
141
|
+
f.drawn = f.n;
|
|
142
|
+
const r = (reflector.current ??= new PlanarReflector());
|
|
143
|
+
if (world)
|
|
144
|
+
planePoint.set(camera.position.x, material.uniforms.u_waterLevel.value, camera.position.z);
|
|
145
|
+
else
|
|
146
|
+
root.getWorldPosition(planePoint);
|
|
147
|
+
let outline = null;
|
|
148
|
+
if (!world) {
|
|
149
|
+
const [w, d] = sizeRef.current ?? [1, 1];
|
|
150
|
+
corners[0].set(-w / 2, 0, -d / 2);
|
|
151
|
+
corners[1].set(w / 2, 0, -d / 2);
|
|
152
|
+
corners[2].set(w / 2, 0, d / 2);
|
|
153
|
+
corners[3].set(-w / 2, 0, d / 2);
|
|
154
|
+
for (const c of corners)
|
|
155
|
+
c.applyMatrix4(root.matrixWorld);
|
|
156
|
+
outline = corners;
|
|
157
|
+
}
|
|
158
|
+
r.render(renderer, scene, camera, root, planePoint, f.scale, outline);
|
|
159
|
+
applyWaterReflection(material.uniforms, 'planar', r);
|
|
160
|
+
}
|
|
161
|
+
useFrame((state, delta) => {
|
|
59
162
|
const shader = material;
|
|
163
|
+
visibility.tick();
|
|
60
164
|
updateSun();
|
|
61
|
-
|
|
62
|
-
// Overwrites the two ambient colours applySunUniforms just set. Those are
|
|
63
|
-
// the cloud curve, tuned for cloud interiors; water has to be lit by — and
|
|
64
|
-
// reflect — the sky actually being drawn behind it, or a sunset sea comes
|
|
65
|
-
// out black under a blazing sky.
|
|
66
|
-
applyTerrainAmbient(shader, sun);
|
|
67
|
-
// The moon's glitter path and light on the water, from the same moon
|
|
68
|
-
// as the key light and the disc (resolveMoon), and the same strength
|
|
69
|
-
// curve (moonlightFactor), so all three appear and fade together.
|
|
70
|
-
const m = resolveMoon(timeSettings, sun.direction, moon.current);
|
|
71
|
-
const sunElevation = THREE.MathUtils.radToDeg(Math.asin(THREE.MathUtils.clamp(sun.direction.y, -1, 1)));
|
|
72
|
-
const k = MOON_WATER_STRENGTH * moonlightFactor(sunElevation, m) * (skySettings?.sunSystem?.moonIntensity ?? 1);
|
|
73
|
-
if (shader.uniforms.u_moonDir)
|
|
74
|
-
shader.uniforms.u_moonDir.value.copy(m.direction);
|
|
75
|
-
if (shader.uniforms.u_moonColor)
|
|
76
|
-
shader.uniforms.u_moonColor.value.setRGB(MOON_LIGHT_COLOR.r * k, MOON_LIGHT_COLOR.g * k, MOON_LIGHT_COLOR.b * k);
|
|
165
|
+
applyWaterLight(shader, sun, sunIntensity, timeSettings, skySettings, light);
|
|
77
166
|
const o = override.current;
|
|
78
167
|
applyConfigKeyframeAnimations(animations?.ocean?.animations, startValues.current, config, o, performance.now() - animStart.current, animatable);
|
|
79
168
|
if (mouseMove?.enabled && mouseMove.ocean?.enabled) {
|
|
@@ -103,6 +192,75 @@ export function useOceanMaterial({ id, config, quality, skySettings, timeSetting
|
|
|
103
192
|
u.u_shadowDistance.value = Math.max(qual.terrainShadowDistance ?? 4000, 1);
|
|
104
193
|
}
|
|
105
194
|
shader.uniforms.u_time.value = state.clock.getElapsedTime();
|
|
195
|
+
// A placed body is sized by its transform: the shader evaluates the waves
|
|
196
|
+
// in world metres (local x scale) and divides the displacement back out.
|
|
197
|
+
if (cfg.host === 'object' && rootRef.current)
|
|
198
|
+
rootRef.current.getWorldScale(bodyScale);
|
|
199
|
+
else
|
|
200
|
+
bodyScale.set(1, 1, 1);
|
|
201
|
+
u.u_bodyScale.value.copy(bodyScale);
|
|
202
|
+
// The current. Integrated here, never speed * time in the shader, so a
|
|
203
|
+
// keyframed or dragged speed changes the rate without moving the water.
|
|
204
|
+
// The waves live in the field's frame (a body's own axes); the per-fragment
|
|
205
|
+
// ripple in world XZ, so the direction is rotated by the root's world turn.
|
|
206
|
+
const speed = Math.max(Number(cfg.flowSpeed) || 0, 0);
|
|
207
|
+
const bearing = ((Number(cfg.flowDirection) || 0) * Math.PI) / 180;
|
|
208
|
+
flowLocal.set(Math.sin(bearing), Math.cos(bearing));
|
|
209
|
+
if (cfg.host === 'object' && rootRef.current) {
|
|
210
|
+
rootRef.current.getWorldQuaternion(flowQuat);
|
|
211
|
+
flowVec.set(flowLocal.x, 0, flowLocal.y).applyQuaternion(flowQuat);
|
|
212
|
+
flowWorld.set(flowVec.x, flowVec.z);
|
|
213
|
+
if (flowWorld.lengthSq() > 1e-8)
|
|
214
|
+
flowWorld.normalize();
|
|
215
|
+
else
|
|
216
|
+
flowWorld.set(1, 0);
|
|
217
|
+
}
|
|
218
|
+
else
|
|
219
|
+
flowWorld.copy(flowLocal);
|
|
220
|
+
const step = speed * Math.min(delta, 0.1);
|
|
221
|
+
u.u_flowOffset.value.addScaledVector(flowLocal, step);
|
|
222
|
+
u.u_flowOffsetW.value.addScaledVector(flowWorld, step);
|
|
223
|
+
u.u_flowDirW.value.copy(flowWorld);
|
|
224
|
+
u.u_flowStretch.value = Math.min(speed * 1.5, 4);
|
|
225
|
+
// Reflection: ask, and find out whether this surface won this frame. The
|
|
226
|
+
// sky (or nothing) is set here for everyone; the winner overwrites it
|
|
227
|
+
// from onBeforeRender once its pass has drawn.
|
|
228
|
+
const f = frame.current;
|
|
229
|
+
f.n++;
|
|
230
|
+
f.mode = (cfg.reflection ?? 'env');
|
|
231
|
+
f.scale = qual.reflectionScale ?? 0.5;
|
|
232
|
+
f.elected = f.mode === 'planar' && electedWaterSurface(state) === id;
|
|
233
|
+
if (f.mode === 'baked') {
|
|
234
|
+
// The probe sits 1.5 m above the water's centre (a placed body), or
|
|
235
|
+
// follows the viewer over the world ocean, re-captured every 40 m.
|
|
236
|
+
const size = waterProbeSize(f.scale);
|
|
237
|
+
if (probe.current && probe.current.size !== size) {
|
|
238
|
+
probe.current.dispose();
|
|
239
|
+
probe.current = null;
|
|
240
|
+
}
|
|
241
|
+
const p = (probe.current ??= new WaterProbe(size));
|
|
242
|
+
const root = rootRef.current;
|
|
243
|
+
if (world) {
|
|
244
|
+
const v = waterViewerPosition() ?? state.camera.position;
|
|
245
|
+
probeAt.set(v.x, u.u_waterLevel.value + 2, v.z);
|
|
246
|
+
p.radius = 0;
|
|
247
|
+
p.request(probeAt, sun.direction, 40, state.clock.elapsedTime);
|
|
248
|
+
}
|
|
249
|
+
else if (root) {
|
|
250
|
+
root.getWorldPosition(probeAt);
|
|
251
|
+
probeAt.y += 1.5;
|
|
252
|
+
const [w, d] = sizeRef.current ?? [1, 1];
|
|
253
|
+
const half = 0.5 * Math.hypot(w * bodyScale.x, d * bodyScale.z);
|
|
254
|
+
// Parallax sphere: the bank and what stands around it.
|
|
255
|
+
p.radius = Math.max(120, half * 1.5);
|
|
256
|
+
p.request(probeAt, sun.direction, 0.25, state.clock.elapsedTime);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else if (probe.current) {
|
|
260
|
+
probe.current.dispose();
|
|
261
|
+
probe.current = null;
|
|
262
|
+
}
|
|
263
|
+
applyWaterReflection(u, f.mode, null, probe.current);
|
|
106
264
|
// World size of one pixel at unit distance. The detail fade and the
|
|
107
265
|
// specular filtering are both screen-space decisions — whether a ripple
|
|
108
266
|
// is a shape or a shimmer depends on the field of view and the
|
|
@@ -115,6 +273,6 @@ export function useOceanMaterial({ id, config, quality, skySettings, timeSetting
|
|
|
115
273
|
}
|
|
116
274
|
onFrame?.(cfg, qual, state);
|
|
117
275
|
});
|
|
118
|
-
return { material, rootRef };
|
|
276
|
+
return { material, rootRef, onBeforeRender, onAfterRender };
|
|
119
277
|
}
|
|
120
278
|
export default useOceanMaterial;
|
|
@@ -9,12 +9,20 @@ export interface PathAnimationOptions {
|
|
|
9
9
|
faceDirection?: boolean;
|
|
10
10
|
applyRotation?: boolean;
|
|
11
11
|
offset?: Vector3Array;
|
|
12
|
+
/** Run the path from its end to its start. */
|
|
13
|
+
reverse?: boolean;
|
|
14
|
+
/** Seconds to wait at the path's start before the first run (not before each loop). */
|
|
15
|
+
delay?: number;
|
|
16
|
+
/** The object's own rotation (radians, XYZ): how the model sits relative to the direction of travel. With 0, its +Z faces forward. */
|
|
17
|
+
restRotation?: Vector3Array;
|
|
12
18
|
keepOriginalTransform?: boolean;
|
|
13
19
|
onComplete?: () => void;
|
|
14
20
|
}
|
|
15
21
|
export declare const usePathAnimation: () => {
|
|
16
22
|
startPathAnimation: (pathId: string, duration: number, options?: PathAnimationOptions) => boolean;
|
|
17
23
|
stopPathAnimation: () => void;
|
|
24
|
+
/** Change how the running animation sits on its path (offset, rotation…) without restarting it. */
|
|
25
|
+
setPathOptions: (options: PathAnimationOptions) => void;
|
|
18
26
|
updatePathAnimation: (delta: number, object: Object3D) => boolean;
|
|
19
27
|
isAnimating: () => boolean;
|
|
20
28
|
getPositionAt: (t: number) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePathAnimation.d.ts","sourceRoot":"","sources":["../../src/hooks/usePathAnimation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,MAAM,WAAW,oBAAoB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;
|
|
1
|
+
{"version":3,"file":"usePathAnimation.d.ts","sourceRoot":"","sources":["../../src/hooks/usePathAnimation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,MAAM,WAAW,oBAAoB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uFAAuF;IACvF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sIAAsI;IACtI,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;AAyBD,eAAO,MAAM,gBAAgB,QAAO;IAC5B,kBAAkB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,KAAK,OAAO,CAAC;IAClG,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,mGAAmG;IACnG,cAAc,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACxD,mBAAmB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,KAAK,OAAO,CAAC;IAClE,WAAW,EAAE,MAAM,OAAO,CAAC;IAC3B,aAAa,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK;QAC1B,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC;QACxB,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC;KAC5B,CAAC;CA8KT,CAAC;AACF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,12 +1,38 @@
|
|
|
1
1
|
import { useRef, useCallback, useEffect } from 'react';
|
|
2
2
|
import * as THREE from 'three';
|
|
3
|
-
import {
|
|
3
|
+
import { applyEasing, resolveEasing, buildPathLine, offsetPathLine, reversePathLine, pathLinePointAt, pathLineDirectionAt, pathLineHeading } from '@3driseai/3drise-core';
|
|
4
4
|
import { AnimationsManager } from '@3driseai/3drise-core';
|
|
5
|
+
// A path animation follows the path's finished line (core pathLine): built once (or taken from
|
|
6
|
+
// the registry entry, which layouts provide), moved by the use's offset once, then each frame only
|
|
7
|
+
// reads the point and direction at a distance along it. No curve is fitted here.
|
|
8
|
+
//
|
|
9
|
+
/** The line a registry entry stands for: its own `line`, or its points taken as the line. */
|
|
10
|
+
function lineOf(cfg) {
|
|
11
|
+
if (cfg.line)
|
|
12
|
+
return cfg.line;
|
|
13
|
+
return buildPathLine({ points: cfg.points, smoothCorners: (cfg.smoothCorners ?? 0) / 100, loop: !!cfg.closed });
|
|
14
|
+
}
|
|
15
|
+
const EULER = new THREE.Euler();
|
|
16
|
+
/** The object's own rotation as a quaternion (identity when none). */
|
|
17
|
+
function setRest(q, r) {
|
|
18
|
+
if (r && r.length === 3)
|
|
19
|
+
q.setFromEuler(EULER.set(r[0] || 0, r[1] || 0, r[2] || 0));
|
|
20
|
+
else
|
|
21
|
+
q.identity();
|
|
22
|
+
}
|
|
23
|
+
/** Longest frame step the animation takes: a hitch slows the run for a moment instead of jumping it. */
|
|
24
|
+
const MAX_STEP = 1 / 20;
|
|
25
|
+
/** How fast the heading catches up with the path (per second); higher is stiffer. */
|
|
26
|
+
const TURN_RATE = 14;
|
|
5
27
|
export const usePathAnimation = () => {
|
|
6
|
-
const
|
|
28
|
+
const pathIdRef = useRef(null);
|
|
29
|
+
/** The registry entry the line was built from (a new entry = the path changed). */
|
|
30
|
+
const cfgRef = useRef(null);
|
|
31
|
+
/** The path's line, and this use's copy of it (offset applied). */
|
|
32
|
+
const baseLineRef = useRef(null);
|
|
33
|
+
const lineRef = useRef(null);
|
|
7
34
|
const progressRef = useRef(0);
|
|
8
35
|
const durationRef = useRef(1);
|
|
9
|
-
const splineRef = useRef(null);
|
|
10
36
|
const activeRef = useRef(false);
|
|
11
37
|
const directionRef = useRef(1);
|
|
12
38
|
const easeRef = useRef(null);
|
|
@@ -16,18 +42,32 @@ export const usePathAnimation = () => {
|
|
|
16
42
|
const faceRef = useRef(true);
|
|
17
43
|
const applyRotRef = useRef(true);
|
|
18
44
|
const offsetRef = useRef(null);
|
|
45
|
+
const reverseRef = useRef(false);
|
|
46
|
+
const delayLeftRef = useRef(0);
|
|
47
|
+
const restQuatRef = useRef(new THREE.Quaternion());
|
|
48
|
+
const parentQuatRef = useRef(new THREE.Quaternion());
|
|
19
49
|
const onCompleteRef = useRef(null);
|
|
50
|
+
const snapRef = useRef(true);
|
|
51
|
+
const posRef = useRef(new THREE.Vector3());
|
|
52
|
+
const dirRef = useRef(new THREE.Vector3());
|
|
53
|
+
const aheadRef = useRef(new THREE.Vector3());
|
|
20
54
|
const targetQuatRef = useRef(new THREE.Quaternion());
|
|
21
|
-
|
|
55
|
+
const reline = useCallback(() => {
|
|
56
|
+
const base = baseLineRef.current;
|
|
57
|
+
// this use's line: reversed and offset once, so the frame loop only reads it
|
|
58
|
+
lineRef.current = base ? offsetPathLine(reverseRef.current ? reversePathLine(base) : base, offsetRef.current) : null;
|
|
59
|
+
}, []);
|
|
60
|
+
useEffect(() => () => { lineRef.current = null; baseLineRef.current = null; }, []);
|
|
22
61
|
const startPathAnimation = useCallback((pathId, duration, options = {}) => {
|
|
23
62
|
const cfg = AnimationsManager.getPath(pathId);
|
|
24
|
-
if (!cfg || cfg.points
|
|
63
|
+
if (!cfg || (cfg.points?.length ?? 0) < 2)
|
|
64
|
+
return false;
|
|
65
|
+
const base = lineOf(cfg);
|
|
66
|
+
if (base.count < 2)
|
|
25
67
|
return false;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
: cfg.points;
|
|
30
|
-
pointsRef.current = pts;
|
|
68
|
+
pathIdRef.current = pathId;
|
|
69
|
+
cfgRef.current = cfg;
|
|
70
|
+
baseLineRef.current = base;
|
|
31
71
|
progressRef.current = 0;
|
|
32
72
|
durationRef.current = duration;
|
|
33
73
|
activeRef.current = true;
|
|
@@ -39,42 +79,84 @@ export const usePathAnimation = () => {
|
|
|
39
79
|
faceRef.current = options.faceDirection ?? true;
|
|
40
80
|
applyRotRef.current = options.applyRotation ?? cfg.applyRotation ?? true;
|
|
41
81
|
offsetRef.current = options.offset ?? cfg.offset ?? null;
|
|
82
|
+
reverseRef.current = !!options.reverse;
|
|
83
|
+
delayLeftRef.current = Math.max(0, options.delay ?? 0);
|
|
84
|
+
setRest(restQuatRef.current, options.restRotation);
|
|
42
85
|
onCompleteRef.current = options.onComplete ?? null;
|
|
43
|
-
|
|
44
|
-
|
|
86
|
+
snapRef.current = true;
|
|
87
|
+
reline();
|
|
45
88
|
return true;
|
|
46
|
-
}, []);
|
|
89
|
+
}, [reline]);
|
|
47
90
|
const stopPathAnimation = useCallback(() => {
|
|
48
91
|
activeRef.current = false;
|
|
49
|
-
|
|
92
|
+
lineRef.current = null;
|
|
93
|
+
baseLineRef.current = null;
|
|
50
94
|
progressRef.current = 0;
|
|
51
95
|
directionRef.current = 1;
|
|
52
96
|
}, []);
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
97
|
+
const setPathOptions = useCallback((options = {}) => {
|
|
98
|
+
const cfg = cfgRef.current;
|
|
99
|
+
if ('offset' in options) {
|
|
100
|
+
const next = options.offset ?? cfg?.offset ?? null;
|
|
101
|
+
const same = JSON.stringify(next) === JSON.stringify(offsetRef.current);
|
|
102
|
+
offsetRef.current = next;
|
|
103
|
+
if (!same)
|
|
104
|
+
reline(); // the whole line moves once
|
|
105
|
+
}
|
|
106
|
+
if ('reverse' in options && !!options.reverse !== reverseRef.current) {
|
|
107
|
+
reverseRef.current = !!options.reverse;
|
|
108
|
+
reline();
|
|
109
|
+
progressRef.current = 1 - progressRef.current; // stay where it is, now heading the other way
|
|
62
110
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
111
|
+
if ('restRotation' in options)
|
|
112
|
+
setRest(restQuatRef.current, options.restRotation);
|
|
113
|
+
if ('applyRotation' in options)
|
|
114
|
+
applyRotRef.current = options.applyRotation ?? cfg?.applyRotation ?? true;
|
|
115
|
+
if ('faceDirection' in options)
|
|
116
|
+
faceRef.current = options.faceDirection ?? true;
|
|
117
|
+
if ('speed' in options)
|
|
118
|
+
speedRef.current = options.speed ?? 1;
|
|
119
|
+
if ('loop' in options)
|
|
120
|
+
loopRef.current = options.loop ?? false;
|
|
121
|
+
if ('yoyo' in options)
|
|
122
|
+
yoyoRef.current = options.yoyo ?? false;
|
|
123
|
+
if ('ease' in options)
|
|
124
|
+
easeRef.current = options.ease ?? null;
|
|
125
|
+
}, [reline]);
|
|
126
|
+
const getPositionAt = useCallback((t) => {
|
|
127
|
+
const line = lineRef.current;
|
|
128
|
+
const position = new THREE.Vector3(), direction = new THREE.Vector3();
|
|
129
|
+
if (!line)
|
|
130
|
+
return { position, direction };
|
|
131
|
+
const d = Math.max(0, Math.min(1, t)) * line.length;
|
|
132
|
+
pathLinePointAt(line, d, position);
|
|
133
|
+
pathLineDirectionAt(line, d, 0.5, direction);
|
|
134
|
+
return { position, direction };
|
|
71
135
|
}, []);
|
|
72
136
|
const updatePathAnimation = useCallback((delta, object) => {
|
|
73
137
|
if (!activeRef.current)
|
|
74
138
|
return false;
|
|
75
|
-
|
|
139
|
+
// the path changed in the registry (edited / re-saved): follow the new line from where we are
|
|
140
|
+
const live = pathIdRef.current ? AnimationsManager.getPath(pathIdRef.current) : undefined;
|
|
141
|
+
if (live && live !== cfgRef.current && (live.points?.length ?? 0) >= 2) {
|
|
142
|
+
cfgRef.current = live;
|
|
143
|
+
baseLineRef.current = lineOf(live);
|
|
144
|
+
reline();
|
|
145
|
+
}
|
|
146
|
+
const line = lineRef.current;
|
|
147
|
+
if (!line || line.count < 2)
|
|
148
|
+
return false;
|
|
149
|
+
const step = Math.min(delta, MAX_STEP);
|
|
150
|
+
// the delay: held at the start, then the rest of this frame's time moves it
|
|
151
|
+
let advance = step;
|
|
152
|
+
if (delayLeftRef.current > 0) {
|
|
153
|
+
const used = Math.min(delayLeftRef.current, step);
|
|
154
|
+
delayLeftRef.current -= used;
|
|
155
|
+
advance = step - used;
|
|
156
|
+
}
|
|
157
|
+
progressRef.current += (advance / durationRef.current) * speedRef.current * directionRef.current;
|
|
76
158
|
let p = progressRef.current;
|
|
77
|
-
if (p >= 1 || p <= 0) {
|
|
159
|
+
if (advance > 0 && (p >= 1 || p <= 0)) {
|
|
78
160
|
if (yoyoRef.current) {
|
|
79
161
|
directionRef.current *= -1;
|
|
80
162
|
p = Math.max(0, Math.min(1, p));
|
|
@@ -97,34 +179,33 @@ export const usePathAnimation = () => {
|
|
|
97
179
|
}
|
|
98
180
|
}
|
|
99
181
|
const eased = easeRef.current ? applyEasing(resolveEasing(easeRef.current), p) : p;
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
object.quaternion.slerp(targetQuatRef.current, 1);
|
|
182
|
+
const d = eased * line.length;
|
|
183
|
+
// the line is in world space (drawn on the scene): put the object on it wherever its parent is
|
|
184
|
+
const position = pathLinePointAt(line, d, posRef.current);
|
|
185
|
+
const parent = object.parent;
|
|
186
|
+
if (parent)
|
|
187
|
+
parent.updateWorldMatrix(true, false);
|
|
188
|
+
object.position.copy(parent ? parent.worldToLocal(aheadRef.current.copy(position)) : position);
|
|
189
|
+
if (applyRotRef.current && faceRef.current) {
|
|
190
|
+
const dir = pathLineDirectionAt(line, d, 0.5, dirRef.current);
|
|
191
|
+
if (directionRef.current < 0)
|
|
192
|
+
dir.negate(); // yoyo back: face the way it goes
|
|
193
|
+
// heading (core pathLineHeading — shared with clips' curved tracks): +Z along the travel,
|
|
194
|
+
// pitching with the slope, no roll, the object's own rotation on top; then into the parent's space
|
|
195
|
+
if (dir.lengthSq() > 1e-8 && pathLineHeading(dir, restQuatRef.current, targetQuatRef.current)) {
|
|
196
|
+
if (parent)
|
|
197
|
+
targetQuatRef.current.premultiply(parent.getWorldQuaternion(parentQuatRef.current).invert());
|
|
198
|
+
if (snapRef.current) {
|
|
199
|
+
object.quaternion.copy(targetQuatRef.current);
|
|
200
|
+
snapRef.current = false;
|
|
201
|
+
}
|
|
202
|
+
else
|
|
203
|
+
object.quaternion.slerp(targetQuatRef.current, 1 - Math.exp(-TURN_RATE * step));
|
|
204
|
+
}
|
|
124
205
|
}
|
|
125
206
|
return true;
|
|
126
|
-
}, [
|
|
207
|
+
}, [reline]);
|
|
127
208
|
const isAnimating = useCallback(() => activeRef.current, []);
|
|
128
|
-
return { startPathAnimation, stopPathAnimation, updatePathAnimation, isAnimating, getPositionAt };
|
|
209
|
+
return { startPathAnimation, stopPathAnimation, setPathOptions, updatePathAnimation, isAnimating, getPositionAt };
|
|
129
210
|
};
|
|
130
211
|
export default usePathAnimation;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ResolvedLayout } from '@3driseai/3drise-core';
|
|
2
|
+
/**
|
|
3
|
+
* Changes when the layout a reference names is registered or edited (core layoutRefs — areas,
|
|
4
|
+
* paths and grids); 0 and no subscription without a reference, so a mesh with no saved layout never
|
|
5
|
+
* rebuilds when other layouts load.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useLayoutRefVersion(ref: string | null | undefined): number;
|
|
8
|
+
/** The layout a reference names ('preset:<id>' or a saved layout's asset id), kept current: null until a saved one is registered. */
|
|
9
|
+
export declare function useResolvedLayout(ref: string | null | undefined): ResolvedLayout | null;
|
|
10
|
+
//# sourceMappingURL=useResolvedLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResolvedLayout.d.ts","sourceRoot":"","sources":["../../src/hooks/useResolvedLayout.ts"],"names":[],"mappings":"AACA,OAAO,EAAmD,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAK7G;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAE1E;AAED,qIAAqI;AACrI,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,cAAc,GAAG,IAAI,CAGvF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useMemo, useSyncExternalStore } from 'react';
|
|
2
|
+
import { layoutsVersion, resolveLayout, subscribeLayouts } from '@3driseai/3drise-core';
|
|
3
|
+
const noSubscribe = () => () => { };
|
|
4
|
+
const zero = () => 0;
|
|
5
|
+
/**
|
|
6
|
+
* Changes when the layout a reference names is registered or edited (core layoutRefs — areas,
|
|
7
|
+
* paths and grids); 0 and no subscription without a reference, so a mesh with no saved layout never
|
|
8
|
+
* rebuilds when other layouts load.
|
|
9
|
+
*/
|
|
10
|
+
export function useLayoutRefVersion(ref) {
|
|
11
|
+
return useSyncExternalStore(ref ? subscribeLayouts : noSubscribe, ref ? layoutsVersion : zero, ref ? layoutsVersion : zero);
|
|
12
|
+
}
|
|
13
|
+
/** The layout a reference names ('preset:<id>' or a saved layout's asset id), kept current: null until a saved one is registered. */
|
|
14
|
+
export function useResolvedLayout(ref) {
|
|
15
|
+
const version = useLayoutRefVersion(ref);
|
|
16
|
+
return useMemo(() => resolveLayout(ref), [ref, version]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
17
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import { type RootState } from '@react-three/fiber';
|
|
4
|
+
import { type createLampField } from '../components/urban/urbanCore';
|
|
5
|
+
type Uniforms = Record<string, {
|
|
6
|
+
value: any;
|
|
7
|
+
}>;
|
|
8
|
+
/** One lamp-gathering target (bounds in the instance's local space): a uniform set to fill with the
|
|
9
|
+
* nearest lamps, or a baked lamp field (createLampField) for a large merged surface. */
|
|
10
|
+
export type LampTarget = {
|
|
11
|
+
u?: Uniforms;
|
|
12
|
+
field?: ReturnType<typeof createLampField>;
|
|
13
|
+
bounds: THREE.Box3;
|
|
14
|
+
};
|
|
15
|
+
/** What a time-lit instance exposes. */
|
|
16
|
+
export interface TimeLit {
|
|
17
|
+
/** The uniform sets that take the sun block (sets without uSunDir are skipped). */
|
|
18
|
+
uniformSets?: Uniforms[];
|
|
19
|
+
/** Local-space bounds (the hook applies the object's world matrix). */
|
|
20
|
+
bounds?(): THREE.Box3;
|
|
21
|
+
/** Lamp targets; defaults to every uniform set with lamp uniforms (uLamps) at bounds(). */
|
|
22
|
+
lampTargets?(): LampTarget[];
|
|
23
|
+
}
|
|
24
|
+
export interface TimeLightingOptions {
|
|
25
|
+
rootRef: RefObject<THREE.Object3D | null>;
|
|
26
|
+
instance: TimeLit;
|
|
27
|
+
/** The object's lighting override: 'auto' (follow the time of day) | 'day' | 'night'. */
|
|
28
|
+
lighting?: string;
|
|
29
|
+
/** The instance's per-frame work, run after the sun and before the lamp gathering. */
|
|
30
|
+
update?: (dt: number, state: RootState) => void;
|
|
31
|
+
}
|
|
32
|
+
export declare function useTimeLighting({ rootRef, instance, lighting, update }: TimeLightingOptions): {
|
|
33
|
+
relight: () => void;
|
|
34
|
+
};
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=useTimeLighting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTimeLighting.d.ts","sourceRoot":"","sources":["../../src/hooks/useTimeLighting.ts"],"names":[],"mappings":"AAqBA,OAAO,EAA2C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAChF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAsD,KAAK,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEzH,KAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,GAAG,CAAA;CAAE,CAAC,CAAC;AAE/C;yFACyF;AACzF,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,CAAC,EAAE,QAAQ,CAAC;IAAC,KAAK,CAAC,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAA;CAAE,CAAC;AAE1G,wCAAwC;AACxC,MAAM,WAAW,OAAO;IACpB,mFAAmF;IACnF,WAAW,CAAC,EAAE,QAAQ,EAAE,CAAC;IACzB,uEAAuE;IACvE,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC;IACtB,2FAA2F;IAC3F,WAAW,CAAC,IAAI,UAAU,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IAC1C,QAAQ,EAAE,OAAO,CAAC;IAClB,yFAAyF;IACzF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sFAAsF;IACtF,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;CACnD;AAID,wBAAgB,eAAe,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,mBAAmB,GAAG;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAkCrH"}
|