@3driseai/3drise-viewer 0.1.41 → 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/ui/UiLayers.d.ts +17 -1
- package/dist/ui/UiLayers.d.ts.map +1 -1
- package/dist/ui/UiLayers.js +76 -3
- package/dist/ui/index.d.ts +2 -2
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.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
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { GoalSportsConfig } from '@3driseai/3drise-core';
|
|
3
|
+
import type { SportsVariantProps } from './useSportsInstance';
|
|
4
|
+
export interface SportsGoalProps extends SportsVariantProps {
|
|
5
|
+
config: GoalSportsConfig;
|
|
6
|
+
}
|
|
7
|
+
declare const SportsGoal: React.FC<SportsGoalProps>;
|
|
8
|
+
export default SportsGoal;
|
|
9
|
+
//# sourceMappingURL=SportsGoal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SportsGoal.d.ts","sourceRoot":"","sources":["../../../src/components/sports/SportsGoal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAc,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAmB1E,MAAM,WAAW,eAAgB,SAAQ,kBAAkB;IACvD,MAAM,EAAE,gBAAgB,CAAC;CAC5B;AAED,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAOzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DEFAULT_SPORTS_OBJECTS, SPORTS_OBJECTS_ANIMATABLE } from '@3driseai/3drise-core';
|
|
3
|
+
import { useSportsInstance } from './useSportsInstance.js';
|
|
4
|
+
import { createUniforms, build, STRUCTURAL } from './core/goal.js';
|
|
5
|
+
// =============================================================================
|
|
6
|
+
// SportsGoal — Goal (type 'sports', config.type 'goal')
|
|
7
|
+
// =============================================================================
|
|
8
|
+
// A regulation goal, net or hoop standing on the ground: football, futsal or handball goal with its sagging net, ice-hockey net, basketball hoop with backboard and pole, volleyball, tennis or badminton net on posts, rugby or American-football uprights, in real metres with wear. Use for pitches, courts, playgrounds, backyards and arenas.
|
|
9
|
+
// The construction lives in core/goal.ts (emitted from the lab); this component wires it into
|
|
10
|
+
// the config pattern through useSportsInstance.
|
|
11
|
+
const CORE = {
|
|
12
|
+
DEFAULTS: DEFAULT_SPORTS_OBJECTS.goal,
|
|
13
|
+
STRUCTURAL,
|
|
14
|
+
/** Knobs a keyframe or pointer binding may drive per frame — exactly what the push applies. */
|
|
15
|
+
ANIMATABLE: new Set(SPORTS_OBJECTS_ANIMATABLE.goal.map((p) => p.value)),
|
|
16
|
+
createUniforms,
|
|
17
|
+
build,
|
|
18
|
+
};
|
|
19
|
+
const SportsGoal = (props) => {
|
|
20
|
+
const { rootRef, instance } = useSportsInstance(CORE, props);
|
|
21
|
+
return (_jsx("group", { ref: rootRef, children: _jsx("primitive", { object: instance.object }) }));
|
|
22
|
+
};
|
|
23
|
+
export default SportsGoal;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
/** The balls: semi-axes (metres; a along x, b across), natural colours [panel, second panel, seam / stitch], seam width (m), surface roughness. */
|
|
3
|
+
export declare const BALLS: {
|
|
4
|
+
football: {
|
|
5
|
+
a: number;
|
|
6
|
+
b: number;
|
|
7
|
+
colors: string[];
|
|
8
|
+
seam: number;
|
|
9
|
+
rough: number;
|
|
10
|
+
};
|
|
11
|
+
basketball: {
|
|
12
|
+
a: number;
|
|
13
|
+
b: number;
|
|
14
|
+
colors: string[];
|
|
15
|
+
seam: number;
|
|
16
|
+
rough: number;
|
|
17
|
+
};
|
|
18
|
+
tennis: {
|
|
19
|
+
a: number;
|
|
20
|
+
b: number;
|
|
21
|
+
colors: string[];
|
|
22
|
+
seam: number;
|
|
23
|
+
rough: number;
|
|
24
|
+
};
|
|
25
|
+
baseball: {
|
|
26
|
+
a: number;
|
|
27
|
+
b: number;
|
|
28
|
+
colors: string[];
|
|
29
|
+
seam: number;
|
|
30
|
+
rough: number;
|
|
31
|
+
};
|
|
32
|
+
volleyball: {
|
|
33
|
+
a: number;
|
|
34
|
+
b: number;
|
|
35
|
+
colors: string[];
|
|
36
|
+
seam: number;
|
|
37
|
+
rough: number;
|
|
38
|
+
};
|
|
39
|
+
rugby: {
|
|
40
|
+
a: number;
|
|
41
|
+
b: number;
|
|
42
|
+
colors: string[];
|
|
43
|
+
seam: number;
|
|
44
|
+
rough: number;
|
|
45
|
+
};
|
|
46
|
+
americanFootball: {
|
|
47
|
+
a: number;
|
|
48
|
+
b: number;
|
|
49
|
+
colors: string[];
|
|
50
|
+
seam: number;
|
|
51
|
+
rough: number;
|
|
52
|
+
};
|
|
53
|
+
golf: {
|
|
54
|
+
a: number;
|
|
55
|
+
b: number;
|
|
56
|
+
colors: string[];
|
|
57
|
+
seam: number;
|
|
58
|
+
rough: number;
|
|
59
|
+
};
|
|
60
|
+
cricket: {
|
|
61
|
+
a: number;
|
|
62
|
+
b: number;
|
|
63
|
+
colors: string[];
|
|
64
|
+
seam: number;
|
|
65
|
+
rough: number;
|
|
66
|
+
};
|
|
67
|
+
bowling: {
|
|
68
|
+
a: number;
|
|
69
|
+
b: number;
|
|
70
|
+
colors: string[];
|
|
71
|
+
seam: number;
|
|
72
|
+
rough: number;
|
|
73
|
+
};
|
|
74
|
+
beachBall: {
|
|
75
|
+
a: number;
|
|
76
|
+
b: number;
|
|
77
|
+
colors: string[];
|
|
78
|
+
seam: number;
|
|
79
|
+
rough: number;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
export declare const BALL_LIST: string[];
|
|
83
|
+
export declare function createUniforms(): {
|
|
84
|
+
uTime: {
|
|
85
|
+
value: number;
|
|
86
|
+
};
|
|
87
|
+
uColor: {
|
|
88
|
+
value: THREE.Color;
|
|
89
|
+
};
|
|
90
|
+
uSecondaryColor: {
|
|
91
|
+
value: THREE.Color;
|
|
92
|
+
};
|
|
93
|
+
uAccentColor: {
|
|
94
|
+
value: THREE.Color;
|
|
95
|
+
};
|
|
96
|
+
uWear: {
|
|
97
|
+
value: number;
|
|
98
|
+
};
|
|
99
|
+
uGloss: {
|
|
100
|
+
value: number;
|
|
101
|
+
};
|
|
102
|
+
uOpacity: {
|
|
103
|
+
value: number;
|
|
104
|
+
};
|
|
105
|
+
uSeed: {
|
|
106
|
+
value: number;
|
|
107
|
+
};
|
|
108
|
+
} & {
|
|
109
|
+
uBall: {
|
|
110
|
+
value: number;
|
|
111
|
+
};
|
|
112
|
+
uAxes: {
|
|
113
|
+
value: THREE.Vector3;
|
|
114
|
+
};
|
|
115
|
+
uSeamW: {
|
|
116
|
+
value: number;
|
|
117
|
+
};
|
|
118
|
+
uSeamDepth: {
|
|
119
|
+
value: number;
|
|
120
|
+
};
|
|
121
|
+
uBulge: {
|
|
122
|
+
value: number;
|
|
123
|
+
};
|
|
124
|
+
uBaseRough: {
|
|
125
|
+
value: number;
|
|
126
|
+
};
|
|
127
|
+
uPanelCol: {
|
|
128
|
+
value: THREE.Color;
|
|
129
|
+
};
|
|
130
|
+
uPanel2Col: {
|
|
131
|
+
value: THREE.Color;
|
|
132
|
+
};
|
|
133
|
+
uSeamCol: {
|
|
134
|
+
value: THREE.Color;
|
|
135
|
+
};
|
|
136
|
+
uCells: {
|
|
137
|
+
value: THREE.Vector3[];
|
|
138
|
+
};
|
|
139
|
+
uSeamPts: {
|
|
140
|
+
value: any[];
|
|
141
|
+
};
|
|
142
|
+
uSeamS: {
|
|
143
|
+
value: any[];
|
|
144
|
+
};
|
|
145
|
+
uSeamLen: {
|
|
146
|
+
value: number;
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
export declare function applyConfig(u: any, c: any, mats?: any): void;
|
|
150
|
+
export declare function ballMaterial(u: any): {
|
|
151
|
+
material: THREE.MeshStandardMaterial;
|
|
152
|
+
depth: THREE.MeshDepthMaterial;
|
|
153
|
+
};
|
|
154
|
+
export declare function build(u: any, c: any): {
|
|
155
|
+
object: THREE.Group<THREE.Object3DEventMap>;
|
|
156
|
+
materials: THREE.MeshStandardMaterial[];
|
|
157
|
+
apply: (cfg: any) => void;
|
|
158
|
+
update: (dt: any) => void;
|
|
159
|
+
stats: {
|
|
160
|
+
verts: number;
|
|
161
|
+
};
|
|
162
|
+
dispose: () => void;
|
|
163
|
+
};
|
|
164
|
+
/** Knobs whose change rebuilds the object (dispose + build); every other knob is a live push through apply. */
|
|
165
|
+
export declare const STRUCTURAL: string[];
|
|
166
|
+
//# sourceMappingURL=ball.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ball.d.ts","sourceRoot":"","sources":["../../../../src/components/sports/core/ball.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,mJAAmJ;AACnJ,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAYjB,CAAC;AACF,eAAO,MAAM,SAAS,UAAqB,CAAC;AAyC5C,wBAAgB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAO7B;AAED,wBAAgB,WAAW,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA,EAAE,IAAI,MAAY,QAWjD;AAiHD,wBAAgB,YAAY,CAAC,CAAC,KAAA;;;EAuK7B;AAED,wBAAgB,KAAK,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA;;;;;;;;;EAqBzB;AAED,+GAA+G;AAC/G,eAAO,MAAM,UAAU,UAA+B,CAAC"}
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
// Emitted from Claude outputs/sports-lab/ball.mjs by gen_family.mjs — edit the lab module and re-emit.
|
|
2
|
+
// sports/core/ball — Ball (type 'sports', config.type 'ball'). Shared core: ../sportsCore.
|
|
3
|
+
// Construction: one ball at its real diameter, resting on the ground, with its panels and seams
|
|
4
|
+
// built from the geometry of each ball rather than painted: a truncated icosahedron as a spherical
|
|
5
|
+
// Voronoi of 32 cells (football), two great circles and two lobe loops (basketball), the figure-of-
|
|
6
|
+
// eight seam curve of a tennis ball and a baseball (with its V stitches laid along the arc length),
|
|
7
|
+
// 18 cube-face strips (volleyball), a prolate spheroid with four panel seams and laces (rugby,
|
|
8
|
+
// American football), 332 dimples found by an inverse spherical Fibonacci lattice (golf), an
|
|
9
|
+
// equatorial six-row stitched seam (cricket), a marbled resin with three finger holes (bowling) and
|
|
10
|
+
// six gores (beach ball). Seams are grooves (height → bump), panels puff out between them, wear
|
|
11
|
+
// scuffs the leather and dirties the grooves. Size: real metres; the transform places it.
|
|
12
|
+
import * as THREE from 'three';
|
|
13
|
+
import { createCommonUniforms, applyCommonConfig, updateCommon, QUALITY_S, litMaterial, propMesh, disposePair, setColor } from '../sportsCore.js';
|
|
14
|
+
/** The balls: semi-axes (metres; a along x, b across), natural colours [panel, second panel, seam / stitch], seam width (m), surface roughness. */
|
|
15
|
+
export const BALLS = {
|
|
16
|
+
football: { a: 0.11, b: 0.11, colors: ['#f2f2f0', '#1c1c1e', '#2a2a2c'], seam: 0.0035, rough: 0.5 },
|
|
17
|
+
basketball: { a: 0.121, b: 0.121, colors: ['#c8622a', '#c8622a', '#1a1a1a'], seam: 0.006, rough: 0.75 },
|
|
18
|
+
tennis: { a: 0.0335, b: 0.0335, colors: ['#d3e22b', '#d3e22b', '#f4f4e8'], seam: 0.004, rough: 1.0 },
|
|
19
|
+
baseball: { a: 0.037, b: 0.037, colors: ['#f1ece2', '#f1ece2', '#b8242a'], seam: 0.0012, rough: 0.55 },
|
|
20
|
+
volleyball: { a: 0.105, b: 0.105, colors: ['#f4f4f0', '#2d5fb0', '#1a1a1a'], seam: 0.003, rough: 0.5 },
|
|
21
|
+
rugby: { a: 0.15, b: 0.095, colors: ['#f0efe9', '#1d4f9c', '#2a2a2a'], seam: 0.003, rough: 0.65 },
|
|
22
|
+
americanFootball: { a: 0.14, b: 0.085, colors: ['#7a3b1e', '#f2f2f2', '#f4f4f4'], seam: 0.003, rough: 0.7 },
|
|
23
|
+
golf: { a: 0.02135, b: 0.02135, colors: ['#f6f6f4', '#f6f6f4', '#9a9a9a'], seam: 0.0, rough: 0.35 },
|
|
24
|
+
cricket: { a: 0.036, b: 0.036, colors: ['#8d1f1f', '#8d1f1f', '#f4f0e6'], seam: 0.0015, rough: 0.35 },
|
|
25
|
+
bowling: { a: 0.109, b: 0.109, colors: ['#1b2a5c', '#7a3b9c', '#101010'], seam: 0.0, rough: 0.1 },
|
|
26
|
+
beachBall: { a: 0.2, b: 0.2, colors: ['#e23a2e', '#2b6fd1', '#f2c230'], seam: 0.002, rough: 0.25 },
|
|
27
|
+
};
|
|
28
|
+
export const BALL_LIST = Object.keys(BALLS);
|
|
29
|
+
// ---------------------------------------------------------------------------- CPU tables shared with the shader
|
|
30
|
+
/** The 32 cell centres of a truncated icosahedron: 12 icosahedron vertices (pentagons) then 20 face centres (hexagons). */
|
|
31
|
+
function footballCells() {
|
|
32
|
+
const t = (1 + Math.sqrt(5)) / 2;
|
|
33
|
+
const V = [[-1, t, 0], [1, t, 0], [-1, -t, 0], [1, -t, 0], [0, -1, t], [0, 1, t], [0, -1, -t], [0, 1, -t], [t, 0, -1], [t, 0, 1], [-t, 0, -1], [-t, 0, 1]]
|
|
34
|
+
.map((v) => new THREE.Vector3(...v).normalize());
|
|
35
|
+
const F = [[0, 11, 5], [0, 5, 1], [0, 1, 7], [0, 7, 10], [0, 10, 11], [1, 5, 9], [5, 11, 4], [11, 10, 2], [10, 7, 6], [7, 1, 8], [3, 9, 4], [3, 4, 2], [3, 2, 6], [3, 6, 8], [3, 8, 9], [4, 9, 5], [2, 4, 11], [6, 2, 10], [8, 6, 7], [9, 8, 1]];
|
|
36
|
+
const cells = V.slice();
|
|
37
|
+
for (const [a, b, c] of F)
|
|
38
|
+
cells.push(V[a].clone().add(V[b]).add(V[c]).normalize());
|
|
39
|
+
// tilt so a pentagon does not sit exactly on the pole / toward the camera
|
|
40
|
+
const q = new THREE.Quaternion().setFromEuler(new THREE.Euler(0.3, 0.2, 0.1));
|
|
41
|
+
return cells.map((c) => c.applyQuaternion(q));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The seam of a tennis ball / baseball: where two dumbbell-shaped pieces meet. Thompson's curve
|
|
45
|
+
* x = a cos t + b cos 3t, y = a sin t − b sin 3t, z = 2√(ab) sin 2t, a + b = 1
|
|
46
|
+
* lies exactly on the unit sphere (x² + y² + z² = a² + b² + 2ab = 1) and splits it into two congruent
|
|
47
|
+
* halves; b sets how deep the lobes reach (≈ 0.29 matches a tennis ball, a baseball is close to it).
|
|
48
|
+
* N samples + their arc length.
|
|
49
|
+
*/
|
|
50
|
+
function seamCurve(N, b) {
|
|
51
|
+
const a = 1 - b, c = 2 * Math.sqrt(a * b);
|
|
52
|
+
const pts = [], s = [];
|
|
53
|
+
let len = 0, prev = null;
|
|
54
|
+
for (let i = 0; i < N; i++) {
|
|
55
|
+
const t = (i / N) * Math.PI * 2;
|
|
56
|
+
const p = new THREE.Vector3(a * Math.cos(t) + b * Math.cos(3 * t), a * Math.sin(t) - b * Math.sin(3 * t), c * Math.sin(2 * t)).normalize();
|
|
57
|
+
if (prev)
|
|
58
|
+
len += p.distanceTo(prev);
|
|
59
|
+
s.push(len);
|
|
60
|
+
pts.push(p);
|
|
61
|
+
prev = p;
|
|
62
|
+
}
|
|
63
|
+
len += pts[0].distanceTo(prev);
|
|
64
|
+
// tilt so the ball does not show the curve exactly edge-on from the default camera
|
|
65
|
+
const q = new THREE.Quaternion().setFromEuler(new THREE.Euler(0.5, 0.35, 0.2));
|
|
66
|
+
for (const p of pts)
|
|
67
|
+
p.applyQuaternion(q);
|
|
68
|
+
return { pts, s, len };
|
|
69
|
+
}
|
|
70
|
+
const CELLS = footballCells();
|
|
71
|
+
const SEAM = seamCurve(96, 0.29);
|
|
72
|
+
export function createUniforms() {
|
|
73
|
+
return Object.assign(createCommonUniforms(), {
|
|
74
|
+
uBall: { value: 0 }, uAxes: { value: new THREE.Vector3(0.11, 0.11, 0.11) }, uSeamW: { value: 0.0035 }, uSeamDepth: { value: 1 }, uBulge: { value: 0.5 },
|
|
75
|
+
uBaseRough: { value: 0.5 },
|
|
76
|
+
uPanelCol: { value: new THREE.Color() }, uPanel2Col: { value: new THREE.Color() }, uSeamCol: { value: new THREE.Color() },
|
|
77
|
+
uCells: { value: CELLS }, uSeamPts: { value: SEAM.pts }, uSeamS: { value: SEAM.s }, uSeamLen: { value: SEAM.len },
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
export function applyConfig(u, c, mats = undefined) {
|
|
81
|
+
applyCommonConfig(u, c, mats);
|
|
82
|
+
const B = BALLS[c.sport] || BALLS.football;
|
|
83
|
+
const nat = c.naturalColors !== false;
|
|
84
|
+
setColor(u.uPanelCol, nat ? B.colors[0] : c.color);
|
|
85
|
+
setColor(u.uPanel2Col, nat ? B.colors[1] : c.secondaryColor);
|
|
86
|
+
setColor(u.uSeamCol, nat ? B.colors[2] : c.accentColor);
|
|
87
|
+
if (c.sport !== undefined) {
|
|
88
|
+
u.uBall.value = Math.max(0, BALL_LIST.indexOf(c.sport));
|
|
89
|
+
u.uAxes.value.set(B.a, B.b, B.b);
|
|
90
|
+
u.uBaseRough.value = B.rough;
|
|
91
|
+
}
|
|
92
|
+
if (c.seamWidth !== undefined)
|
|
93
|
+
u.uSeamW.value = B.seam * c.seamWidth;
|
|
94
|
+
if (c.seamDepth !== undefined)
|
|
95
|
+
u.uSeamDepth.value = c.seamDepth;
|
|
96
|
+
if (c.bulge !== undefined)
|
|
97
|
+
u.uBulge.value = c.bulge;
|
|
98
|
+
}
|
|
99
|
+
// ---------------------------------------------------------------------------- GLSL
|
|
100
|
+
// Shared by the vertex (panel bulge) and the fragment: the seam distance of every ball in metres on
|
|
101
|
+
// the unit direction n (object space, normalised by the semi-axes).
|
|
102
|
+
const BALL_GLSL = /* glsl */ `
|
|
103
|
+
uniform float uBall, uSeamW, uSeamDepth, uBulge, uBaseRough, uSeamLen;
|
|
104
|
+
uniform vec3 uAxes, uPanelCol, uPanel2Col, uSeamCol;
|
|
105
|
+
uniform vec3 uCells[32];
|
|
106
|
+
uniform vec3 uSeamPts[96];
|
|
107
|
+
uniform float uSeamS[96];
|
|
108
|
+
const float PI_B = 3.14159265;
|
|
109
|
+
float gcDist(vec3 n, vec3 axis) { return asin(clamp(abs(dot(n, axis)), 0.0, 1.0)); } // angular distance to a great circle
|
|
110
|
+
// basketball lobe loop around the side point s: radius ρ0(ψ) = 0.70 + 0.73 sin²ψ
|
|
111
|
+
float lobeDist(vec3 n, vec3 s) {
|
|
112
|
+
float rho = acos(clamp(dot(n, s), -1.0, 1.0));
|
|
113
|
+
vec3 e1 = vec3(0.0, 1.0, 0.0), e2 = cross(s, e1);
|
|
114
|
+
float psi = atan(dot(n, e1), dot(n, e2));
|
|
115
|
+
float sp = sin(psi);
|
|
116
|
+
return abs(rho - (0.70 + 0.73 * sp * sp));
|
|
117
|
+
}
|
|
118
|
+
// nearest point on the sampled seam curve: chord distance and the arc length there (both unit-sphere)
|
|
119
|
+
void seamCurve(vec3 n, out float dist, out float along, out float side) {
|
|
120
|
+
float best = 1e9; int bi = 0;
|
|
121
|
+
for (int i = 0; i < 96; i++) { float d = dot(n - uSeamPts[i], n - uSeamPts[i]); if (d < best) { best = d; bi = i; } }
|
|
122
|
+
int i0 = bi, i1 = (bi + 1) % 96, im = (bi + 95) % 96;
|
|
123
|
+
// refine on the two neighbouring segments
|
|
124
|
+
vec3 a = uSeamPts[i0], b = uSeamPts[i1], c = uSeamPts[im];
|
|
125
|
+
vec3 ab = b - a; float tb = clamp(dot(n - a, ab) / dot(ab, ab), 0.0, 1.0); vec3 pb = a + ab * tb;
|
|
126
|
+
vec3 ac = c - a; float tc = clamp(dot(n - a, ac) / dot(ac, ac), 0.0, 1.0); vec3 pc = a + ac * tc;
|
|
127
|
+
float db = length(n - pb), dc = length(n - pc);
|
|
128
|
+
vec3 p = db < dc ? pb : pc; vec3 tang = db < dc ? ab : -ac;
|
|
129
|
+
dist = min(db, dc);
|
|
130
|
+
along = db < dc ? uSeamS[i0] + tb * length(ab) : uSeamS[i0] - tc * length(ac);
|
|
131
|
+
side = sign(dot(cross(normalize(tang), p), n - p));
|
|
132
|
+
}
|
|
133
|
+
// inverse spherical Fibonacci lattice (I. Quilez): nearest of N points to n, returns its squared distance
|
|
134
|
+
float sfNearest(vec3 p, float n) {
|
|
135
|
+
const float PHI = 1.61803398875;
|
|
136
|
+
float m = 1.0 - 1.0 / n;
|
|
137
|
+
float phi = min(atan(p.y, p.x), PI_B), cosTheta = p.z;
|
|
138
|
+
float k = max(2.0, floor(log(n * PI_B * sqrt(5.0) * (1.0 - cosTheta * cosTheta)) / log(PHI + 1.0)));
|
|
139
|
+
float Fk = pow(PHI, k) / sqrt(5.0);
|
|
140
|
+
vec2 F = vec2(floor(Fk + 0.5), floor(Fk * PHI + 0.5));
|
|
141
|
+
vec2 ka = 2.0 * F / n; vec2 kb = 2.0 * PI_B * (fract((F + 1.0) * PHI) - (PHI - 1.0));
|
|
142
|
+
mat2 iB = mat2(ka.y, -ka.x, kb.y, -kb.x) / (ka.y * kb.x - ka.x * kb.y);
|
|
143
|
+
vec2 c = floor(iB * vec2(phi, cosTheta - m));
|
|
144
|
+
float d = 8.0;
|
|
145
|
+
for (int s = 0; s < 4; s++) {
|
|
146
|
+
vec2 uv = vec2(float(s - 2 * (s / 2)), float(s / 2));
|
|
147
|
+
float i = dot(F, uv + c);
|
|
148
|
+
float ph = 2.0 * PI_B * fract(i * PHI);
|
|
149
|
+
float ct = m - 2.0 * i / n;
|
|
150
|
+
float st = sqrt(1.0 - ct * ct);
|
|
151
|
+
vec3 q = vec3(cos(ph) * st, sin(ph) * st, ct);
|
|
152
|
+
d = min(d, dot(q - p, q - p));
|
|
153
|
+
}
|
|
154
|
+
return d;
|
|
155
|
+
}
|
|
156
|
+
// The seam distance (metres) and which panel we are on (0 main, 1 second, 2 third) for the panelled balls.
|
|
157
|
+
float seamDist(vec3 n, out float panel) {
|
|
158
|
+
panel = 0.0;
|
|
159
|
+
int b = int(uBall + 0.5);
|
|
160
|
+
float r = uAxes.y;
|
|
161
|
+
if (b == 0) { // football: spherical Voronoi of 32 cells, pentagons biased smaller
|
|
162
|
+
float a1 = 1e9, a2 = 1e9; int c1 = 0;
|
|
163
|
+
for (int i = 0; i < 32; i++) {
|
|
164
|
+
float a = acos(clamp(dot(n, uCells[i]), -1.0, 1.0)) + (i < 12 ? 0.045 : 0.0);
|
|
165
|
+
if (a < a1) { a2 = a1; a1 = a; c1 = i; } else if (a < a2) a2 = a;
|
|
166
|
+
}
|
|
167
|
+
panel = c1 < 12 ? 1.0 : 0.0;
|
|
168
|
+
return (a2 - a1) * 0.5 * r;
|
|
169
|
+
} else if (b == 1) { // basketball: equator, meridian, two lobe loops
|
|
170
|
+
float d = min(gcDist(n, vec3(0, 1, 0)), gcDist(n, vec3(1, 0, 0)));
|
|
171
|
+
d = min(d, min(lobeDist(n, vec3(0, 0, 1)), lobeDist(n, vec3(0, 0, -1))));
|
|
172
|
+
return d * r;
|
|
173
|
+
} else if (b == 2 || b == 3) { // tennis / baseball: the figure-of-eight curve
|
|
174
|
+
float d, s, sd; seamCurve(n, d, s, sd);
|
|
175
|
+
return d * r;
|
|
176
|
+
} else if (b == 4) { // volleyball: 6 cube faces × 3 strips, strips turned on alternate faces
|
|
177
|
+
vec3 an = abs(n);
|
|
178
|
+
float axis = an.x >= an.y && an.x >= an.z ? 0.0 : an.y >= an.z ? 1.0 : 2.0;
|
|
179
|
+
vec2 uv = axis == 0.0 ? n.yz / an.x : axis == 1.0 ? n.xz / an.y : n.xy / an.z; // gnomonic, -1..1
|
|
180
|
+
float sgn = axis == 0.0 ? sign(n.x) : axis == 1.0 ? sign(n.y) : sign(n.z);
|
|
181
|
+
vec2 ang = atan(uv); // -45°..45°
|
|
182
|
+
float edge = 0.7854 - max(abs(ang.x), abs(ang.y)); // to the face edge
|
|
183
|
+
float flip = mod(axis + (sgn > 0.0 ? 0.0 : 1.0), 2.0); // which way the strips run
|
|
184
|
+
float t = flip < 0.5 ? ang.x : ang.y;
|
|
185
|
+
float strip = floor((t + 0.7854) / 0.5236); // 3 strips of 30°
|
|
186
|
+
float ds = abs(mod(t + 0.7854, 0.5236) - 0.2618);
|
|
187
|
+
ds = 0.2618 - ds; // to the strip seam
|
|
188
|
+
panel = strip == 1.0 ? 1.0 : 0.0;
|
|
189
|
+
return min(edge, ds) * r;
|
|
190
|
+
} else if (b == 5 || b == 6) { // rugby / american: four panel seams around the long axis (x)
|
|
191
|
+
float phi = atan(n.z, n.y);
|
|
192
|
+
float d = abs(mod(phi + PI_B * 0.25, PI_B * 0.5) - PI_B * 0.25); // to the nearest of 4 meridians
|
|
193
|
+
float lat = asin(clamp(n.x, -1.0, 1.0));
|
|
194
|
+
return d * cos(lat) * r;
|
|
195
|
+
} else if (b == 8) { // cricket: the equatorial seam (x = 0)
|
|
196
|
+
return gcDist(n, vec3(1, 0, 0)) * r;
|
|
197
|
+
} else if (b == 10) { // beach ball: six gores
|
|
198
|
+
float phi = atan(n.z, n.x);
|
|
199
|
+
float d = abs(mod(phi + PI_B / 6.0, PI_B / 3.0) - PI_B / 6.0);
|
|
200
|
+
float gore = floor((phi + PI_B) / (PI_B / 3.0) + 0.5);
|
|
201
|
+
panel = mod(gore, 2.0) < 0.5 ? 0.0 : (mod(gore, 6.0) < 2.5 ? 1.0 : (mod(gore, 6.0) < 4.5 ? 2.0 : 3.0));
|
|
202
|
+
float lat = asin(clamp(n.y, -1.0, 1.0));
|
|
203
|
+
float cap = 1.25 - abs(lat); // polar caps
|
|
204
|
+
return min(d * cos(lat), abs(cap)) * r;
|
|
205
|
+
}
|
|
206
|
+
return 1e9;
|
|
207
|
+
}
|
|
208
|
+
`;
|
|
209
|
+
export function ballMaterial(u) {
|
|
210
|
+
return litMaterial(u, {
|
|
211
|
+
name: 'ball', roughness: 0.5, metalness: 0, envMapIntensity: 0.7,
|
|
212
|
+
vPars: BALL_GLSL,
|
|
213
|
+
vCode: /* glsl */ `
|
|
214
|
+
{
|
|
215
|
+
// panels puff out between the seams (a leather ball is stitched and inflated), seams stay on the sphere
|
|
216
|
+
vec3 nn = normalize(position / uAxes);
|
|
217
|
+
float pnl; float sd = seamDist(nn, pnl);
|
|
218
|
+
float w = max(uSeamW, 0.002);
|
|
219
|
+
float puff = smoothstep(0.0, w * 4.0, sd) * (uBall < 0.5 || uBall == 1.0 || uBall == 4.0 ? 1.0 : 0.0);
|
|
220
|
+
transformed += normal * uBulge * puff * uAxes.y * 0.012;
|
|
221
|
+
}`,
|
|
222
|
+
pars: BALL_GLSL + /* glsl */ `
|
|
223
|
+
float ballRough; float ballH;
|
|
224
|
+
// stitch rows: short threads every pitch along s at a lateral offset, as a coverage (0..1) and a height
|
|
225
|
+
float threads(float s, float lat, float pitch, float off, float len, float tw, out float h) {
|
|
226
|
+
float k = floor(s / pitch); float c = (k + 0.5) * pitch;
|
|
227
|
+
// a thread runs from (c - len/2, off) to (c + len/2, off + len*0.5): a slanted stitch
|
|
228
|
+
vec2 a = vec2(c - len * 0.5, off), b = vec2(c + len * 0.5, off + len * 0.6);
|
|
229
|
+
vec2 p = vec2(s, lat);
|
|
230
|
+
vec2 ab = b - a; float t = clamp(dot(p - a, ab) / dot(ab, ab), 0.0, 1.0);
|
|
231
|
+
float d = length(p - a - ab * t);
|
|
232
|
+
float fw = fwidth(s) + 1e-6;
|
|
233
|
+
float cov = 1.0 - smoothstep(tw - fw, tw + fw, d);
|
|
234
|
+
h = cov * tw;
|
|
235
|
+
return cov;
|
|
236
|
+
}`,
|
|
237
|
+
color: /* glsl */ `
|
|
238
|
+
vec3 n = normalize(vObj / uAxes);
|
|
239
|
+
float r = uAxes.y;
|
|
240
|
+
int b = int(uBall + 0.5);
|
|
241
|
+
float pnl; float sd = seamDist(n, pnl);
|
|
242
|
+
float w = uSeamW;
|
|
243
|
+
float worn = scuffs(vObj * 1.0, 60.0 / r, 0.5);
|
|
244
|
+
vec3 col = pnl < 0.5 ? uPanelCol : pnl < 1.5 ? uPanel2Col : pnl < 2.5 ? uSeamCol : vec3(0.95);
|
|
245
|
+
if (b == 10 && pnl > 2.5) col = vec3(0.95);
|
|
246
|
+
float rough = uBaseRough;
|
|
247
|
+
float h = 0.0;
|
|
248
|
+
// the seam: a groove with a dark floor; seam-coloured thread on the balls that show one
|
|
249
|
+
float fw = fwidth(sd) * 0.8 + 1e-6;
|
|
250
|
+
float groove = 1.0 - smoothstep(w * 0.5 - fw, w * 0.5 + fw, sd);
|
|
251
|
+
float inGroove = 1.0 - smoothstep(0.0, w * 1.2, sd);
|
|
252
|
+
if (b == 0) { // football: pebbled PU, dark groove, dirt in the seams when worn
|
|
253
|
+
float peb = snoise3(vObj * 2200.0 / (r / 0.11));
|
|
254
|
+
col *= 0.93 + 0.1 * peb;
|
|
255
|
+
col = mix(col, col * 0.35 + uSeamCol * 0.3, groove);
|
|
256
|
+
h = -inGroove * 0.0012 * uSeamDepth + peb * 0.00004;
|
|
257
|
+
rough = mix(uBaseRough, 0.85, inGroove) + 0.06 * peb;
|
|
258
|
+
} else if (b == 1) { // basketball: pebble grain, black channels
|
|
259
|
+
float peb = snoise3(vObj * 1600.0 / (r / 0.12)) * 0.6 + snoise3(vObj * 4800.0 / (r / 0.12)) * 0.4;
|
|
260
|
+
col *= 0.86 + 0.26 * peb;
|
|
261
|
+
col = mix(col, uSeamCol, groove);
|
|
262
|
+
h = -inGroove * 0.0025 * uSeamDepth + peb * 0.00012 * (1.0 - groove);
|
|
263
|
+
rough = mix(uBaseRough + 0.1 * peb, 0.9, groove);
|
|
264
|
+
} else if (b == 2) { // tennis: felt nap with a sheen at grazing angles; the seam a pale recessed band
|
|
265
|
+
float d, s, sdn; seamCurve(n, d, s, sdn);
|
|
266
|
+
float nap = snoise3(vObj * 9000.0) * 0.5 + snoise3(vObj * 2600.0 + 3.0) * 0.5;
|
|
267
|
+
float band = 1.0 - smoothstep(w * 0.5 - fw, w * 0.5 + fw, sd);
|
|
268
|
+
col = mix(col * (0.85 + 0.3 * nap), uSeamCol * (0.9 + 0.15 * nap), band);
|
|
269
|
+
float sheen = pow(1.0 - abs(dot(normalize(vNormal), normalize(vViewPosition))), 2.5);
|
|
270
|
+
col *= 1.0 + 0.55 * sheen * (1.0 - band);
|
|
271
|
+
h = -band * 0.0007 * uSeamDepth + nap * 0.00015;
|
|
272
|
+
rough = 1.0;
|
|
273
|
+
} else if (b == 3) { // baseball: leather, two rows of red V stitches along the seam
|
|
274
|
+
float d, s, sdn; seamCurve(n, d, s, sdn);
|
|
275
|
+
float lat = d * r * sdn; // signed lateral distance, metres
|
|
276
|
+
float sm = s * r; // arc length, metres
|
|
277
|
+
float pitch = uSeamLen * r / 54.0; // 108 stitches = 54 pairs around the curve
|
|
278
|
+
float h1, h2;
|
|
279
|
+
float st = max(threads(sm, lat, pitch, 0.0018, pitch * 0.55, 0.0005 * uSeamW / max(uSeamW, 1e-3) + 0.00025, h1),
|
|
280
|
+
threads(sm, -lat, pitch, 0.0018, pitch * 0.55, 0.0005 * uSeamW / max(uSeamW, 1e-3) + 0.00025, h2));
|
|
281
|
+
float grain = snoise3(vObj * 3000.0);
|
|
282
|
+
col *= 0.95 + 0.08 * grain;
|
|
283
|
+
float cut = 1.0 - smoothstep(0.0, 0.0012, sd); // the leather edges meet along the curve
|
|
284
|
+
col = mix(col, col * 0.75, cut * 0.6);
|
|
285
|
+
col = mix(col, uSeamCol, st);
|
|
286
|
+
h = -cut * 0.0004 + max(h1, h2) * 1.4 * uSeamDepth;
|
|
287
|
+
rough = mix(uBaseRough, 0.7, st);
|
|
288
|
+
} else if (b == 4) { // volleyball: soft leather panels, fine seam lines
|
|
289
|
+
float grain = snoise3(vObj * 2500.0);
|
|
290
|
+
col *= 0.95 + 0.08 * grain;
|
|
291
|
+
col = mix(col, col * 0.4 + uSeamCol * 0.2, groove);
|
|
292
|
+
h = -inGroove * 0.001 * uSeamDepth;
|
|
293
|
+
rough = mix(uBaseRough, 0.8, inGroove);
|
|
294
|
+
} else if (b == 5 || b == 6) { // rugby / american: pimpled grain, panel seams, end stripes, laces
|
|
295
|
+
float pim = snoise3(vObj * 1800.0 / (r / 0.09)) * 0.6 + snoise3(vObj * 5000.0 / (r / 0.09)) * 0.4;
|
|
296
|
+
col *= 0.9 + 0.2 * pim;
|
|
297
|
+
float ax = abs(n.x);
|
|
298
|
+
float stripe = smoothstep(0.58, 0.6, ax) * (1.0 - smoothstep(0.7, 0.72, ax));
|
|
299
|
+
col = mix(col, uPanel2Col, stripe * (b == 6 ? 1.0 : 0.85));
|
|
300
|
+
col = mix(col, col * 0.45, groove);
|
|
301
|
+
h = pim * 0.00014 * (1.0 - groove) - inGroove * 0.0015 * uSeamDepth;
|
|
302
|
+
rough = uBaseRough + 0.08 * pim;
|
|
303
|
+
if (b == 6) {
|
|
304
|
+
// laces: a strip on top (+y meridian) from x = -0.22 to 0.22 of the length, one long lace and eight cross laces
|
|
305
|
+
float phi = atan(n.z, n.y);
|
|
306
|
+
float lx = asin(clamp(n.x, -1.0, 1.0)) * uAxes.x; // metres along the ball
|
|
307
|
+
float lz = phi * r; // metres across the top
|
|
308
|
+
float inStrip = step(abs(lx), 0.047) * step(abs(lz), 0.014);
|
|
309
|
+
float longLace = (1.0 - smoothstep(0.0022, 0.0032, abs(lz))) * step(abs(lx), 0.047);
|
|
310
|
+
float k = floor((lx + 0.047) / 0.0118);
|
|
311
|
+
float cx = (k + 0.5) * 0.0118 - 0.047;
|
|
312
|
+
float cross = (1.0 - smoothstep(0.0022, 0.0032, abs(lx - cx))) * step(abs(lz), 0.012) * step(abs(lx), 0.045);
|
|
313
|
+
float lace = max(longLace, cross);
|
|
314
|
+
col = mix(col, col * 0.6, inStrip * (1.0 - lace) * 0.5);
|
|
315
|
+
col = mix(col, uSeamCol, lace);
|
|
316
|
+
h += lace * 0.0022 - inStrip * 0.0008;
|
|
317
|
+
rough = mix(rough, 0.6, lace);
|
|
318
|
+
}
|
|
319
|
+
} else if (b == 7) { // golf: dimples on an inverse Fibonacci lattice
|
|
320
|
+
float d2 = sfNearest(n, 332.0);
|
|
321
|
+
float dd = sqrt(d2);
|
|
322
|
+
float dr = 0.085;
|
|
323
|
+
float t = clamp(dd / dr, 0.0, 1.0);
|
|
324
|
+
float dimple = (1.0 - t * t); dimple *= dimple;
|
|
325
|
+
h = -dimple * 0.0011 * (0.5 + uSeamDepth * 0.5);
|
|
326
|
+
col *= 0.97 + 0.03 * snoise3(vObj * 20000.0);
|
|
327
|
+
col *= 1.0 - 0.18 * dimple; // a touch of occlusion in the dimples
|
|
328
|
+
col = mix(col, col * 0.88, worn * 0.5);
|
|
329
|
+
rough = uBaseRough + 0.1 * dimple;
|
|
330
|
+
} else if (b == 8) { // cricket: polished red leather, raised equatorial seam with six rows of stitches
|
|
331
|
+
float lat = asin(clamp(n.x, -1.0, 1.0)) * r; // metres from the seam
|
|
332
|
+
float lon = atan(n.z, n.y) * r; // metres along it
|
|
333
|
+
float ridge = 1.0 - smoothstep(0.0, 0.0024, abs(lat));
|
|
334
|
+
float h1, h2, h3;
|
|
335
|
+
float st = threads(lon, abs(lat), 0.0032, 0.0025, 0.0018, 0.0004, h1);
|
|
336
|
+
st = max(st, threads(lon + 0.0016, abs(lat), 0.0032, 0.0048, 0.0018, 0.0004, h2));
|
|
337
|
+
st = max(st, threads(lon, abs(lat), 0.0032, 0.0071, 0.0018, 0.0004, h3));
|
|
338
|
+
float quarter = (1.0 - smoothstep(0.0003, 0.0007, gcDist(n, vec3(0, 0, 1)) * r)) * step(0.012, abs(lat));
|
|
339
|
+
float grain = snoise3(vObj * 4000.0);
|
|
340
|
+
col *= 0.93 + 0.12 * grain;
|
|
341
|
+
col = mix(col, col * 0.6, ridge * 0.4 + quarter * 0.5);
|
|
342
|
+
col = mix(col, uSeamCol, st);
|
|
343
|
+
h = ridge * 0.0008 * uSeamDepth + max(max(h1, h2), h3) * 1.2 - quarter * 0.0002;
|
|
344
|
+
rough = mix(uBaseRough, 0.75, max(st, ridge));
|
|
345
|
+
// polished on one side (the shine side), scuffed on the other
|
|
346
|
+
rough = mix(rough, 0.6, smoothstep(0.0, 0.3, n.z) * worn);
|
|
347
|
+
} else if (b == 9) { // bowling: marbled resin, three finger holes near the top
|
|
348
|
+
float swirl = sfbm3(n * 2.5 + uSeed) ;
|
|
349
|
+
float veins = 1.0 - abs(2.0 * sfbm3(n * 5.0 + vec3(swirl * 2.0)) - 1.0);
|
|
350
|
+
col = mix(uPanelCol, uPanel2Col, smoothstep(0.35, 0.65, swirl));
|
|
351
|
+
col = mix(col, col * 1.6, smoothstep(0.85, 0.98, veins) * 0.6);
|
|
352
|
+
vec3 hA = normalize(vec3(0.0, 0.93, 0.36)), hB = normalize(vec3(0.17, 0.98, -0.08)), hC = normalize(vec3(-0.17, 0.98, -0.08));
|
|
353
|
+
float holes = min(acos(clamp(dot(n, hA), -1.0, 1.0)) - 0.13, min(acos(clamp(dot(n, hB), -1.0, 1.0)), acos(clamp(dot(n, hC), -1.0, 1.0))) - 0.105);
|
|
354
|
+
float hole = 1.0 - smoothstep(-0.01, 0.01, holes);
|
|
355
|
+
col = mix(col, uSeamCol, hole);
|
|
356
|
+
h = -hole * 0.004;
|
|
357
|
+
rough = mix(uBaseRough, 0.9, hole) + worn * 0.25;
|
|
358
|
+
} else { // beach ball: glossy vinyl gores
|
|
359
|
+
col *= 0.97 + 0.05 * snoise3(vObj * 600.0);
|
|
360
|
+
col = mix(col, col * 0.6, groove * 0.7);
|
|
361
|
+
h = -inGroove * 0.0006;
|
|
362
|
+
rough = uBaseRough + worn * 0.3;
|
|
363
|
+
}
|
|
364
|
+
// wear: scuffs lighten leather and rubber, dirt collects in the grooves
|
|
365
|
+
if (b != 7 && b != 9) {
|
|
366
|
+
col = mix(col, col * 1.25 + 0.04, worn * 0.6 * (1.0 - groove));
|
|
367
|
+
col = mix(col, col * 0.55, uWear * 0.6 * inGroove);
|
|
368
|
+
rough = mix(rough, 0.85, worn * 0.5);
|
|
369
|
+
}
|
|
370
|
+
ballRough = clamp(rough / max(uGloss, 0.05), 0.03, 1.0);
|
|
371
|
+
ballH = h;
|
|
372
|
+
diffuseColor.rgb *= col;`,
|
|
373
|
+
rough: 'ballRough',
|
|
374
|
+
normal: /* glsl */ `normal = bumpNormal(normal, ballH);`,
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
export function build(u, c) {
|
|
378
|
+
const B = BALLS[c.sport] || BALLS.football;
|
|
379
|
+
const q = QUALITY_S[c.quality] || 1;
|
|
380
|
+
const seg = Math.round(56 * Math.sqrt(q)) * 2;
|
|
381
|
+
const geo = new THREE.SphereGeometry(1, seg, Math.round(seg * 0.6));
|
|
382
|
+
geo.scale(B.a, B.b, B.b);
|
|
383
|
+
geo.computeVertexNormals();
|
|
384
|
+
// centred geometry (the seams and panels are functions of the direction from the centre); the mesh is lifted so it rests on the ground
|
|
385
|
+
const pair = ballMaterial(u);
|
|
386
|
+
const mesh = propMesh(geo, pair, 'ball');
|
|
387
|
+
mesh.position.y = B.b;
|
|
388
|
+
const object = new THREE.Group();
|
|
389
|
+
object.name = 'ball';
|
|
390
|
+
object.add(mesh);
|
|
391
|
+
const mats = [pair.material];
|
|
392
|
+
applyConfig(u, c, mats);
|
|
393
|
+
return {
|
|
394
|
+
object, materials: mats,
|
|
395
|
+
apply: function (cfg) { applyConfig(u, cfg, mats); },
|
|
396
|
+
update: function (dt) { updateCommon(u, dt); },
|
|
397
|
+
stats: { verts: geo.attributes.position.count },
|
|
398
|
+
dispose: function () { geo.dispose(); disposePair(pair); },
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
/** Knobs whose change rebuilds the object (dispose + build); every other knob is a live push through apply. */
|
|
402
|
+
export const STRUCTURAL = ['sport', 'quality', 'seed'];
|