@pinkaphant/kolmo 0.2.3 → 0.4.0
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/LICENSE +1 -1
- package/README.md +36 -36
- package/bin/kolmo.mjs +12 -6
- package/dist/engine/causewayBridge.d.ts +14 -0
- package/dist/engine/causewayBridge.js +166 -0
- package/dist/engine/causewayBridge.js.map +1 -0
- package/dist/engine/index.d.ts +6 -4
- package/dist/engine/index.js +19 -12
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/islandSettlementMesh.d.ts +26 -0
- package/dist/engine/islandSettlementMesh.js +166 -0
- package/dist/engine/islandSettlementMesh.js.map +1 -0
- package/dist/engine/kolmoActions.d.ts +23 -0
- package/dist/engine/kolmoActions.js +164 -0
- package/dist/engine/kolmoActions.js.map +1 -0
- package/dist/engine/kolmoActor.js +242 -165
- package/dist/engine/kolmoActor.js.map +1 -0
- package/dist/engine/kolmoFloatingOrigin.d.ts +17 -0
- package/dist/engine/kolmoFloatingOrigin.js +98 -0
- package/dist/engine/kolmoFloatingOrigin.js.map +1 -0
- package/dist/engine/kolmoGame.d.ts +27 -0
- package/dist/engine/kolmoGame.js +80 -0
- package/dist/engine/kolmoGame.js.map +1 -0
- package/dist/engine/kolmoHud.d.ts +23 -0
- package/dist/engine/kolmoHud.js +195 -0
- package/dist/engine/kolmoHud.js.map +1 -0
- package/dist/engine/kolmoInput.d.ts +1 -1
- package/dist/engine/kolmoInput.js +57 -30
- package/dist/engine/kolmoInput.js.map +1 -0
- package/dist/engine/kolmoIsland.d.ts +5 -10
- package/dist/engine/kolmoIsland.js +182 -250
- package/dist/engine/kolmoIsland.js.map +1 -0
- package/dist/engine/kolmoLongDrive.d.ts +3 -4
- package/dist/engine/kolmoLongDrive.js +140 -205
- package/dist/engine/kolmoLongDrive.js.map +1 -0
- package/dist/engine/kolmoPilotMesh.d.ts +2 -0
- package/dist/engine/kolmoPilotMesh.js +64 -0
- package/dist/engine/kolmoPilotMesh.js.map +1 -0
- package/dist/engine/kolmoProcedural.d.ts +13 -0
- package/dist/engine/kolmoProcedural.js +101 -0
- package/dist/engine/kolmoProcedural.js.map +1 -0
- package/dist/engine/kolmoRigs.d.ts +1 -1
- package/dist/engine/kolmoRigs.js +88 -47
- package/dist/engine/kolmoRigs.js.map +1 -0
- package/dist/engine/kolmoStore.d.ts +3 -100
- package/dist/engine/kolmoSurface.d.ts +2 -2
- package/dist/engine/kolmoSurface.js +150 -134
- package/dist/engine/kolmoSurface.js.map +1 -0
- package/dist/engine/kolmoTraits.d.ts +128 -0
- package/dist/engine/kolmoTraits.js +140 -0
- package/dist/engine/kolmoTraits.js.map +1 -0
- package/dist/engine/kolmoVehicle.d.ts +3 -33
- package/dist/engine/kolmoVehicle.js +66 -240
- package/dist/engine/kolmoVehicle.js.map +1 -0
- package/dist/engine/kolmoVehicleConfig.d.ts +54 -0
- package/dist/engine/kolmoVehicleConfig.js +80 -0
- package/dist/engine/kolmoVehicleConfig.js.map +1 -0
- package/dist/engine/kolmoVehicleDriver.d.ts +4 -1
- package/dist/engine/kolmoVehicleDriver.js +116 -22
- package/dist/engine/kolmoVehicleDriver.js.map +1 -0
- package/dist/engine/kolmoVehicleInner.d.ts +7 -0
- package/dist/engine/kolmoVehicleInner.js +261 -0
- package/dist/engine/kolmoVehicleInner.js.map +1 -0
- package/dist/engine/kolmoWorld.d.ts +6 -4
- package/dist/engine/kolmoWorld.js +134 -116
- package/dist/engine/kolmoWorld.js.map +1 -0
- package/dist/engine/longDriveKit.d.ts +5 -12
- package/dist/engine/longDriveKit.js +121 -233
- package/dist/engine/longDriveKit.js.map +1 -0
- package/dist/engine/longDriveRoadside.d.ts +16 -0
- package/dist/engine/longDriveRoadside.js +171 -0
- package/dist/engine/longDriveRoadside.js.map +1 -0
- package/dist/engine/macroCellBuilder.d.ts +34 -0
- package/dist/engine/macroCellBuilder.js +145 -0
- package/dist/engine/macroCellBuilder.js.map +1 -0
- package/dist/engine/mainlandMacroCell.d.ts +2 -2
- package/dist/engine/mainlandMacroCell.js +77 -165
- package/dist/engine/mainlandMacroCell.js.map +1 -0
- package/dist/engine/shiftedFixedBody.d.ts +1 -1
- package/dist/engine/shiftedFixedBody.js +55 -28
- package/dist/engine/shiftedFixedBody.js.map +1 -0
- package/dist/importer/ChopShopPanel.d.ts +9 -1
- package/dist/importer/ChopShopPanel.js +303 -359
- package/dist/importer/ChopShopPanel.js.map +1 -0
- package/dist/importer/DomainWorkshopPanel.d.ts +2 -1
- package/dist/importer/DomainWorkshopPanel.js +172 -242
- package/dist/importer/DomainWorkshopPanel.js.map +1 -0
- package/dist/importer/GateHudBar.d.ts +8 -0
- package/dist/importer/GateHudBar.js +290 -279
- package/dist/importer/GateHudBar.js.map +1 -0
- package/dist/importer/GlbImportGate.d.ts +2 -1
- package/dist/importer/GlbImportGate.js +252 -225
- package/dist/importer/GlbImportGate.js.map +1 -0
- package/dist/importer/ImperativeVehicleRig.d.ts +2 -2
- package/dist/importer/ImperativeVehicleRig.js +223 -284
- package/dist/importer/ImperativeVehicleRig.js.map +1 -0
- package/dist/importer/LiveDrivePads.d.ts +20 -0
- package/dist/importer/LiveDrivePads.js +169 -0
- package/dist/importer/LiveDrivePads.js.map +1 -0
- package/dist/importer/PaperShellDebrisRig.d.ts +25 -0
- package/dist/importer/PaperShellDebrisRig.js +143 -0
- package/dist/importer/PaperShellDebrisRig.js.map +1 -0
- package/dist/importer/R2VaultDrawer.d.ts +12 -0
- package/dist/importer/R2VaultDrawer.js +90 -0
- package/dist/importer/R2VaultDrawer.js.map +1 -0
- package/dist/importer/Step1CalibrationPlinth.d.ts +23 -5
- package/dist/importer/Step1CalibrationPlinth.js +180 -251
- package/dist/importer/Step1CalibrationPlinth.js.map +1 -0
- package/dist/importer/Step1ExplodedIslands.d.ts +31 -0
- package/dist/importer/Step1ExplodedIslands.js +144 -0
- package/dist/importer/Step1ExplodedIslands.js.map +1 -0
- package/dist/importer/Step2UniversalPad.d.ts +7 -7
- package/dist/importer/Step2UniversalPad.js +49 -170
- package/dist/importer/Step2UniversalPad.js.map +1 -0
- package/dist/importer/VfxEmitterPool.js +59 -86
- package/dist/importer/VfxEmitterPool.js.map +1 -0
- package/dist/importer/WheelRingHandles3D.d.ts +11 -0
- package/dist/importer/WheelRingHandles3D.js +318 -0
- package/dist/importer/WheelRingHandles3D.js.map +1 -0
- package/dist/importer/archLinerGeom.d.ts +2 -0
- package/dist/importer/archLinerGeom.js +51 -0
- package/dist/importer/archLinerGeom.js.map +1 -0
- package/dist/importer/{vehiclePanelAnim.d.ts → chopHingeHelpers.d.ts} +0 -10
- package/dist/importer/chopHingeHelpers.js +193 -0
- package/dist/importer/chopHingeHelpers.js.map +1 -0
- package/dist/importer/chopShopActions.d.ts +20 -26
- package/dist/importer/chopShopActions.js +135 -210
- package/dist/importer/chopShopActions.js.map +1 -0
- package/dist/importer/chopShopHandlers.d.ts +26 -0
- package/dist/importer/chopShopHandlers.js +276 -0
- package/dist/importer/chopShopHandlers.js.map +1 -0
- package/dist/importer/chopShopIoActions.d.ts +15 -0
- package/dist/importer/chopShopIoActions.js +137 -0
- package/dist/importer/chopShopIoActions.js.map +1 -0
- package/dist/importer/chopShopMcpAction.d.ts +18 -0
- package/dist/importer/chopShopMcpAction.js +58 -0
- package/dist/importer/chopShopMcpAction.js.map +1 -0
- package/dist/importer/cylinderBooleanSlice.d.ts +14 -0
- package/dist/importer/cylinderBooleanSlice.js +110 -0
- package/dist/importer/cylinderBooleanSlice.js.map +1 -0
- package/dist/importer/cylinderSliceMath.d.ts +14 -0
- package/dist/importer/cylinderSliceMath.js +251 -0
- package/dist/importer/cylinderSliceMath.js.map +1 -0
- package/dist/importer/fusedWheelDetect.d.ts +4 -0
- package/dist/importer/fusedWheelDetect.js +175 -0
- package/dist/importer/fusedWheelDetect.js.map +1 -0
- package/dist/importer/fusedWheelFit.d.ts +13 -0
- package/dist/importer/fusedWheelFit.js +138 -0
- package/dist/importer/fusedWheelFit.js.map +1 -0
- package/dist/importer/gateStore.d.ts +1 -1
- package/dist/importer/gateStore.js +36 -27
- package/dist/importer/gateStore.js.map +1 -0
- package/dist/importer/glbNormalizer.js +118 -79
- package/dist/importer/glbNormalizer.js.map +1 -0
- package/dist/importer/importerWebMcp.d.ts +4 -3
- package/dist/importer/importerWebMcp.js +41 -336
- package/dist/importer/importerWebMcp.js.map +1 -0
- package/dist/importer/importerWebMcpTools.d.ts +2 -0
- package/dist/importer/importerWebMcpTools.js +340 -0
- package/dist/importer/importerWebMcpTools.js.map +1 -0
- package/dist/importer/index.d.ts +4 -0
- package/dist/importer/index.js +32 -22
- package/dist/importer/index.js.map +1 -0
- package/dist/importer/khrCarPlanHelpers.d.ts +28 -0
- package/dist/importer/khrCarPlanHelpers.js +221 -0
- package/dist/importer/khrCarPlanHelpers.js.map +1 -0
- package/dist/importer/khrCarPlanner.d.ts +7 -0
- package/dist/importer/khrCarPlanner.js +279 -0
- package/dist/importer/khrCarPlanner.js.map +1 -0
- package/dist/importer/khrCompiler.d.ts +4 -22
- package/dist/importer/khrCompiler.js +56 -424
- package/dist/importer/khrCompiler.js.map +1 -0
- package/dist/importer/khrCraftPropCompiler.d.ts +40 -0
- package/dist/importer/khrCraftPropCompiler.js +250 -0
- package/dist/importer/khrCraftPropCompiler.js.map +1 -0
- package/dist/importer/launcherBake.js +76 -35
- package/dist/importer/launcherBake.js.map +1 -0
- package/dist/importer/meshIslands.d.ts +4 -46
- package/dist/importer/meshIslands.js +84 -283
- package/dist/importer/meshIslands.js.map +1 -0
- package/dist/importer/meshSliceBuffers.d.ts +15 -0
- package/dist/importer/meshSliceBuffers.js +159 -0
- package/dist/importer/meshSliceBuffers.js.map +1 -0
- package/dist/importer/polygonEarClipYZ.d.ts +3 -0
- package/dist/importer/polygonEarClipYZ.js +67 -0
- package/dist/importer/polygonEarClipYZ.js.map +1 -0
- package/dist/importer/sceneSiNormalize.d.ts +19 -0
- package/dist/importer/sceneSiNormalize.js +138 -0
- package/dist/importer/sceneSiNormalize.js.map +1 -0
- package/dist/importer/starterScene.d.ts +3 -0
- package/dist/importer/starterScene.js +76 -0
- package/dist/importer/starterScene.js.map +1 -0
- package/dist/importer/surfaceCutter.d.ts +4 -15
- package/dist/importer/surfaceCutter.js +69 -240
- package/dist/importer/surfaceCutter.js.map +1 -0
- package/dist/importer/surfaceGeodesic.d.ts +7 -0
- package/dist/importer/surfaceGeodesic.js +130 -0
- package/dist/importer/surfaceGeodesic.js.map +1 -0
- package/dist/importer/surfaceLoopRefine.d.ts +6 -0
- package/dist/importer/surfaceLoopRefine.js +171 -0
- package/dist/importer/surfaceLoopRefine.js.map +1 -0
- package/dist/importer/surfacePeel.d.ts +11 -0
- package/dist/importer/surfacePeel.js +119 -0
- package/dist/importer/surfacePeel.js.map +1 -0
- package/dist/importer/surfaceTopology.d.ts +2 -6
- package/dist/importer/surfaceTopology.js +93 -133
- package/dist/importer/surfaceTopology.js.map +1 -0
- package/dist/importer/universalGateBake.d.ts +7 -3
- package/dist/importer/universalGateBake.js +104 -106
- package/dist/importer/universalGateBake.js.map +1 -0
- package/dist/importer/usdPhysicsSpecs.d.ts +3 -0
- package/dist/importer/usdPhysicsSpecs.js +245 -0
- package/dist/importer/usdPhysicsSpecs.js.map +1 -0
- package/dist/importer/usdTextParse.d.ts +12 -0
- package/dist/importer/usdTextParse.js +118 -0
- package/dist/importer/usdTextParse.js.map +1 -0
- package/dist/importer/usdToGlb.d.ts +3 -2
- package/dist/importer/usdToGlb.js +80 -280
- package/dist/importer/usdToGlb.js.map +1 -0
- package/dist/importer/useChopShopController.d.ts +50 -47
- package/dist/importer/useChopShopController.js +156 -338
- package/dist/importer/useChopShopController.js.map +1 -0
- package/dist/importer/useChopShopState.d.ts +103 -0
- package/dist/importer/useChopShopState.js +319 -0
- package/dist/importer/useChopShopState.js.map +1 -0
- package/dist/importer/useWasdKeyRef.d.ts +9 -0
- package/dist/importer/useWasdKeyRef.js +35 -0
- package/dist/importer/useWasdKeyRef.js.map +1 -0
- package/dist/importer/vehiclePartSplit.d.ts +33 -0
- package/dist/importer/vehiclePartSplit.js +178 -0
- package/dist/importer/vehiclePartSplit.js.map +1 -0
- package/dist/importer/wheelAxlePairing.js +106 -70
- package/dist/importer/wheelAxlePairing.js.map +1 -0
- package/dist/importer/wheelCutterHelpers.d.ts +42 -0
- package/dist/importer/wheelCutterHelpers.js +178 -0
- package/dist/importer/wheelCutterHelpers.js.map +1 -0
- package/dist/importer/wheelRingHandleMath.d.ts +20 -0
- package/dist/importer/wheelRingHandleMath.js +66 -0
- package/dist/importer/wheelRingHandleMath.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +90 -66
- package/dist/index.js.map +1 -0
- package/dist/junk/DestructibleTarget.d.ts +3 -3
- package/dist/junk/DestructibleTarget.js +177 -114
- package/dist/junk/DestructibleTarget.js.map +1 -0
- package/dist/junk/KolmoJunk.js +55 -44
- package/dist/junk/KolmoJunk.js.map +1 -0
- package/dist/junk/ShardPieces.d.ts +2 -1
- package/dist/junk/ShardPieces.js +80 -61
- package/dist/junk/ShardPieces.js.map +1 -0
- package/dist/junk/TargetDecals.d.ts +6 -15
- package/dist/junk/TargetDecals.js +66 -40
- package/dist/junk/TargetDecals.js.map +1 -0
- package/dist/junk/bvhShatter.d.ts +2 -6
- package/dist/junk/bvhShatter.js +89 -43
- package/dist/junk/bvhShatter.js.map +1 -0
- package/dist/junk/bvhTriCollector.d.ts +2 -6
- package/dist/junk/bvhTriCollector.js +111 -62
- package/dist/junk/bvhTriCollector.js.map +1 -0
- package/dist/junk/index.d.ts +2 -2
- package/dist/junk/index.js +11 -11
- package/dist/junk/index.js.map +1 -0
- package/dist/junk/junkGeometry.d.ts +5 -26
- package/dist/junk/junkGeometry.js +61 -43
- package/dist/junk/junkGeometry.js.map +1 -0
- package/dist/junk/junkImportSanitize.d.ts +4 -5
- package/dist/junk/junkImportSanitize.js +57 -37
- package/dist/junk/junkImportSanitize.js.map +1 -0
- package/dist/junk/junkImporter.d.ts +2 -13
- package/dist/junk/junkImporter.js +105 -76
- package/dist/junk/junkImporter.js.map +1 -0
- package/dist/junk/junkLabelCanvas.d.ts +1 -6
- package/dist/junk/junkLabelCanvas.js +147 -29
- package/dist/junk/junkLabelCanvas.js.map +1 -0
- package/dist/junk/junkLabels.d.ts +4 -26
- package/dist/junk/junkLabels.js +42 -28
- package/dist/junk/junkLabels.js.map +1 -0
- package/dist/junk/targetHelpers.d.ts +3 -4
- package/dist/junk/targetHelpers.js +121 -67
- package/dist/junk/targetHelpers.js.map +1 -0
- package/dist/junk/targetHitLogic.d.ts +8 -8
- package/dist/junk/targetHitLogic.js +131 -95
- package/dist/junk/targetHitLogic.js.map +1 -0
- package/dist/junk/useTargetAssets.d.ts +9 -14
- package/dist/junk/useTargetAssets.js +113 -85
- package/dist/junk/useTargetAssets.js.map +1 -0
- package/dist/physics/index.d.ts +1 -1
- package/dist/physics/index.js +79 -58
- package/dist/physics/index.js.map +1 -0
- package/dist/schema/kolmoSchema.d.ts +3 -64
- package/dist/schema/kolmoSchema.js +75 -149
- package/dist/schema/kolmoSchema.js.map +1 -0
- package/dist/schema/kolmoStamp.d.ts +6 -0
- package/dist/schema/kolmoStamp.js +71 -0
- package/dist/schema/kolmoStamp.js.map +1 -0
- package/dist/schema/kolmoTypes.d.ts +63 -0
- package/dist/schema/kolmoTypes.js +66 -0
- package/dist/schema/kolmoTypes.js.map +1 -0
- package/dist/shaders/celestialBackdrop.d.ts +2 -10
- package/dist/shaders/celestialBackdrop.js +128 -291
- package/dist/shaders/celestialBackdrop.js.map +1 -0
- package/dist/shaders/emitterShaders.d.ts +9 -0
- package/dist/shaders/emitterShaders.js +114 -0
- package/dist/shaders/emitterShaders.js.map +1 -0
- package/dist/shaders/index.d.ts +1 -1
- package/dist/shaders/index.js +12 -9
- package/dist/shaders/index.js.map +1 -0
- package/dist/shaders/plumeAndSparkle.d.ts +2 -4
- package/dist/shaders/plumeAndSparkle.js +152 -191
- package/dist/shaders/plumeAndSparkle.js.map +1 -0
- package/dist/shaders/ps2GlslShared.js +29 -2
- package/dist/shaders/ps2GlslShared.js.map +1 -0
- package/dist/shaders/ps2MaterialsTSL.js +132 -51
- package/dist/shaders/ps2MaterialsTSL.js.map +1 -0
- package/dist/shaders/ps2MaterialsWebGL.js +45 -28
- package/dist/shaders/ps2MaterialsWebGL.js.map +1 -0
- package/dist/shaders/ps2RoadWebGL.js +69 -32
- package/dist/shaders/ps2RoadWebGL.js.map +1 -0
- package/dist/shaders/ps2TerrainWebGL.js +107 -30
- package/dist/shaders/ps2TerrainWebGL.js.map +1 -0
- package/dist/shaders/ps2Textures.d.ts +1 -1
- package/dist/shaders/ps2Textures.js +116 -41
- package/dist/shaders/ps2Textures.js.map +1 -0
- package/dist/shaders/retroPalettes.d.ts +1 -1
- package/dist/shaders/retroPalettes.js +90 -57
- package/dist/shaders/retroPalettes.js.map +1 -0
- package/dist/shaders/retroShader.d.ts +2 -86
- package/dist/shaders/retroShader.js +65 -196
- package/dist/shaders/retroShader.js.map +1 -0
- package/dist/shaders/retroUniforms.d.ts +60 -0
- package/dist/shaders/retroUniforms.js +215 -0
- package/dist/shaders/retroUniforms.js.map +1 -0
- package/dist/shaders/skyboxShaders.d.ts +16 -0
- package/dist/shaders/skyboxShaders.js +266 -0
- package/dist/shaders/skyboxShaders.js.map +1 -0
- package/dist/shaders/tsl.d.ts +1 -1
- package/dist/shaders/tsl.js.map +1 -0
- package/dist/vite/index.js +39 -23
- package/dist/vite/index.js.map +1 -0
- package/dist/world/frontage.js +25 -21
- package/dist/world/frontage.js.map +1 -0
- package/dist/world/index.d.ts +4 -4
- package/dist/world/index.js +12 -11
- package/dist/world/index.js.map +1 -0
- package/dist/world/infiniteWorld2D.d.ts +0 -5
- package/dist/world/infiniteWorld2D.js +175 -200
- package/dist/world/infiniteWorld2D.js.map +1 -0
- package/dist/world/island.js +81 -166
- package/dist/world/island.js.map +1 -0
- package/dist/world/islandPathing.d.ts +6 -0
- package/dist/world/islandPathing.js +166 -0
- package/dist/world/islandPathing.js.map +1 -0
- package/dist/world/macroCellSchema.js +15 -8
- package/dist/world/macroCellSchema.js.map +1 -0
- package/dist/world/macroKnightAStar.js +140 -71
- package/dist/world/macroKnightAStar.js.map +1 -0
- package/dist/world/macroSettlementZones.d.ts +9 -0
- package/dist/world/macroSettlementZones.js +108 -0
- package/dist/world/macroSettlementZones.js.map +1 -0
- package/dist/world/random.js +50 -24
- package/dist/world/random.js.map +1 -0
- package/dist/world/road.js +152 -90
- package/dist/world/road.js.map +1 -0
- package/dist/world/roadRibbon.d.ts +4 -19
- package/dist/world/roadRibbon.js +129 -124
- package/dist/world/roadRibbon.js.map +1 -0
- package/dist/world/terrain.d.ts +1 -1
- package/dist/world/terrain.js +111 -65
- package/dist/world/terrain.js.map +1 -0
- package/dist/world/terrainGeometry.d.ts +14 -0
- package/dist/world/terrainGeometry.js +76 -0
- package/dist/world/terrainGeometry.js.map +1 -0
- package/dist/world/worldTypes.d.ts +3 -3
- package/dist/world/worldTypes.js +133 -67
- package/dist/world/worldTypes.js.map +1 -0
- package/docs/api-reference.md +187 -0
- package/package.json +58 -32
- package/dist/engine/kolmoStore.js +0 -211
- package/dist/importer/ImporterPlinthUikitTags.d.ts +0 -19
- package/dist/importer/ImporterPlinthUikitTags.js +0 -112
- package/dist/importer/vehiclePanelAnim.js +0 -214
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { createPS2TerrainMaterialWebGL } from "../shaders/ps2TerrainWebGL.js";
|
|
2
|
+
import { createPS2WorldTextures } from "../shaders/ps2Textures.js";
|
|
3
|
+
import { C12TileKind, MACRO_SIZE_M } from "../world/macroCellSchema.js";
|
|
4
|
+
import { roadFromPoints } from "../world/road.js";
|
|
5
|
+
import { buildRoadRibbonGeometry } from "../world/roadRibbon.js";
|
|
6
|
+
import { makeTerrain } from "../world/terrain.js";
|
|
7
|
+
import { buildCarvedTerrainGeometry } from "../world/terrainGeometry.js";
|
|
8
|
+
import { bakeMacroCellSplat } from "./shiftedFixedBody.js";
|
|
9
|
+
import * as THREE from "three";
|
|
10
|
+
// src/engine/macroCellBuilder.ts
|
|
11
|
+
function buildMacroCellData(mx, mz, planner, terrainMat) {
|
|
12
|
+
const plan2d = planner.generateMacroCell2D(mx, mz);
|
|
13
|
+
const hubGroundY = Math.max(2.5, planner.sampleMainlandHeight(plan2d.hubX, plan2d.hubZ));
|
|
14
|
+
const baseFn = (wx, wz) => {
|
|
15
|
+
const raw = planner.sampleMainlandHeight(wx, wz);
|
|
16
|
+
if (plan2d.settlementRadiusM <= 0) return raw;
|
|
17
|
+
const d = Math.hypot(wx - plan2d.hubX, wz - plan2d.hubZ);
|
|
18
|
+
if (d <= plan2d.settlementRadiusM) return hubGroundY;
|
|
19
|
+
const u = (d - plan2d.settlementRadiusM) / 96;
|
|
20
|
+
return u >= 1 ? raw : hubGroundY + (raw - hubGroundY) * (u * u * (3 - 2 * u));
|
|
21
|
+
};
|
|
22
|
+
const roads = plan2d.highwayPolylines.filter((p) => p.length >= 2).map((poly) => {
|
|
23
|
+
const pts = poly.map(([x, z]) => [
|
|
24
|
+
x,
|
|
25
|
+
Math.max(2, baseFn(x, z)),
|
|
26
|
+
z
|
|
27
|
+
]);
|
|
28
|
+
for (let pass = 0; pass < 4; pass++) for (let i = 1; i < pts.length - 1; i++) pts[i] = [
|
|
29
|
+
pts[i][0],
|
|
30
|
+
.5 * pts[i][1] + .25 * (pts[i - 1][1] + pts[i + 1][1]),
|
|
31
|
+
pts[i][2]
|
|
32
|
+
];
|
|
33
|
+
return roadFromPoints(pts, 4.5, 4, false);
|
|
34
|
+
});
|
|
35
|
+
const ribbons = roads.map((r) => buildRoadRibbonGeometry(r));
|
|
36
|
+
const primaryRoad = roads[0] ?? roadFromPoints([[
|
|
37
|
+
plan2d.originWorldX - 20,
|
|
38
|
+
hubGroundY,
|
|
39
|
+
plan2d.originWorldZ
|
|
40
|
+
], [
|
|
41
|
+
plan2d.originWorldX + 20,
|
|
42
|
+
hubGroundY,
|
|
43
|
+
plan2d.originWorldZ
|
|
44
|
+
]], 4.5, 4, false);
|
|
45
|
+
const terr = makeTerrain(mx * 73856093 ^ mz * 19349663, primaryRoad, {
|
|
46
|
+
amplitude: 28,
|
|
47
|
+
noise: {
|
|
48
|
+
wavelength: 300,
|
|
49
|
+
octaves: 2,
|
|
50
|
+
gain: .5,
|
|
51
|
+
lacunarity: 2
|
|
52
|
+
},
|
|
53
|
+
maxSlope: .55,
|
|
54
|
+
minShoulder: 12,
|
|
55
|
+
verge: 18,
|
|
56
|
+
baseHeight: baseFn,
|
|
57
|
+
maxCutFill: 16,
|
|
58
|
+
extraRoads: roads.slice(1)
|
|
59
|
+
});
|
|
60
|
+
const shiftedTerrain = {
|
|
61
|
+
...terr,
|
|
62
|
+
height: (lx, lz) => terr.height(plan2d.originWorldX + lx, plan2d.originWorldZ + lz),
|
|
63
|
+
visualHeight: (lx, lz, drop) => terr.visualHeight(plan2d.originWorldX + lx, plan2d.originWorldZ + lz, drop),
|
|
64
|
+
roadMask: (lx, lz) => terr.roadMask(plan2d.originWorldX + lx, plan2d.originWorldZ + lz)
|
|
65
|
+
};
|
|
66
|
+
const terrainGeo = buildCarvedTerrainGeometry(shiftedTerrain, MACRO_SIZE_M, 96);
|
|
67
|
+
const cellTex = terrainMat ? null : createPS2WorldTextures(bakeMacroCellSplat(mx, mz, plan2d, shiftedTerrain));
|
|
68
|
+
const cellTerrain = cellTex ? createPS2TerrainMaterialWebGL(cellTex) : null;
|
|
69
|
+
const dummy = new THREE.Object3D();
|
|
70
|
+
const poles = [], rdStr = [], rdCw = [], rdInt = [];
|
|
71
|
+
const cbStr = [], cbRmp = [], cbDrv = [];
|
|
72
|
+
const wallRes = [], wallCom = [], wallInd = [], roofAll = [];
|
|
73
|
+
for (const r of roads) for (let s = 36; s < r.length - 36; s += 48) {
|
|
74
|
+
const smp = r.at(s);
|
|
75
|
+
dummy.position.set(smp.pos[0] + smp.left[0] * 6.8, smp.pos[1], smp.pos[2] + smp.left[2] * 6.8);
|
|
76
|
+
dummy.rotation.set(0, Math.atan2(smp.tangent[0], smp.tangent[2]), 0);
|
|
77
|
+
dummy.scale.set(1, 1, 1);
|
|
78
|
+
dummy.updateMatrix();
|
|
79
|
+
poles.push(...dummy.matrix.elements);
|
|
80
|
+
}
|
|
81
|
+
if (plan2d.settlementRadiusM > 0) {
|
|
82
|
+
const tileReach = Math.min(84, Math.ceil(plan2d.settlementRadiusM / 3));
|
|
83
|
+
for (let tz = -tileReach; tz <= tileReach; tz++) for (let tx = -tileReach; tx <= tileReach; tx++) {
|
|
84
|
+
const wx = plan2d.hubX + tx * 3 + 1.5, wz = plan2d.hubZ + tz * 3 + 1.5;
|
|
85
|
+
const kind = planner.classifySettlementC12Tile(wx, wz, plan2d);
|
|
86
|
+
if (kind < C12TileKind.ROAD_LANE || kind > C12TileKind.C12_PLAZA_HUB) continue;
|
|
87
|
+
dummy.position.set(wx, hubGroundY + .02, wz);
|
|
88
|
+
dummy.rotation.set(0, 0, 0);
|
|
89
|
+
dummy.scale.set(1, 1, 1);
|
|
90
|
+
dummy.updateMatrix();
|
|
91
|
+
if (kind === C12TileKind.CROSSWALK) rdCw.push(...dummy.matrix.elements);
|
|
92
|
+
else if (kind === C12TileKind.INTERSECTION_BOX || kind === C12TileKind.C12_PLAZA_HUB) rdInt.push(...dummy.matrix.elements);
|
|
93
|
+
else if (kind === C12TileKind.CURB_RAMP_CORNER) cbRmp.push(...dummy.matrix.elements);
|
|
94
|
+
else if (kind === C12TileKind.CURB_DRIVEWAY) cbDrv.push(...dummy.matrix.elements);
|
|
95
|
+
else if (kind === C12TileKind.CURB_STRAIGHT || kind === C12TileKind.BOULEVARD_MEDIAN) cbStr.push(...dummy.matrix.elements);
|
|
96
|
+
else rdStr.push(...dummy.matrix.elements);
|
|
97
|
+
}
|
|
98
|
+
for (const p of plan2d.parcels.slice(0, 140)) {
|
|
99
|
+
const floors = p.zone === "COMMERCIAL" ? 4 : p.zone === "INDUSTRIAL" ? 2 : 1;
|
|
100
|
+
const targetWalls = p.zone === "COMMERCIAL" ? wallCom : p.zone === "INDUSTRIAL" ? wallInd : wallRes;
|
|
101
|
+
const cols = Math.max(2, Math.floor((p.width - 3) / 3)), rows = Math.max(2, Math.floor((p.depth - 3) / 3));
|
|
102
|
+
for (let f = 0; f < floors; f++) {
|
|
103
|
+
const wy = hubGroundY + f * 3 + 1.5;
|
|
104
|
+
for (let c = 0; c < cols; c++) for (const [zOff, yaw] of [[0, 0], [rows * 3, Math.PI]]) {
|
|
105
|
+
dummy.position.set(p.minX + 1.5 + c * 3 + 1.5, wy, p.minZ + 1.5 + zOff);
|
|
106
|
+
dummy.rotation.set(0, yaw, 0);
|
|
107
|
+
dummy.scale.set(1, 1, 1);
|
|
108
|
+
dummy.updateMatrix();
|
|
109
|
+
targetWalls.push(...dummy.matrix.elements);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) {
|
|
113
|
+
dummy.position.set(p.minX + 3 + c * 3, hubGroundY + floors * 3 + .12, p.minZ + 3 + r * 3);
|
|
114
|
+
dummy.rotation.set(0, 0, 0);
|
|
115
|
+
dummy.scale.set(1, 1, 1);
|
|
116
|
+
dummy.updateMatrix();
|
|
117
|
+
roofAll.push(...dummy.matrix.elements);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
plan2d,
|
|
123
|
+
ribbons,
|
|
124
|
+
terrainGeo,
|
|
125
|
+
shiftedTerrain,
|
|
126
|
+
cellTex,
|
|
127
|
+
cellTerrain,
|
|
128
|
+
poles: new Float32Array(poles),
|
|
129
|
+
rdStr: new Float32Array(rdStr),
|
|
130
|
+
rdCw: new Float32Array(rdCw),
|
|
131
|
+
rdInt: new Float32Array(rdInt),
|
|
132
|
+
cbStr: new Float32Array(cbStr),
|
|
133
|
+
cbRmp: new Float32Array(cbRmp),
|
|
134
|
+
cbDrv: new Float32Array(cbDrv),
|
|
135
|
+
wallRes: new Float32Array(wallRes),
|
|
136
|
+
wallCom: new Float32Array(wallCom),
|
|
137
|
+
wallInd: new Float32Array(wallInd),
|
|
138
|
+
roofAll: new Float32Array(roofAll),
|
|
139
|
+
sqHub: plan2d.civicHubBatches.find((b) => b.kind === "FoundationSquare")?.matrices ?? /* @__PURE__ */ new Float32Array(),
|
|
140
|
+
triHub: plan2d.civicHubBatches.find((b) => b.kind === "FoundationTriangle")?.matrices ?? /* @__PURE__ */ new Float32Array()
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export { buildMacroCellData };
|
|
144
|
+
|
|
145
|
+
//# sourceMappingURL=macroCellBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"macroCellBuilder.js","names":[],"sources":["../../src/engine/macroCellBuilder.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport { createPS2TerrainMaterialWebGL } from \"../shaders/ps2TerrainWebGL.js\";\nimport { createPS2WorldTextures } from \"../shaders/ps2Textures.js\";\nimport { C12TileKind, MACRO_SIZE_M } from \"../world/macroCellSchema.js\";\nimport { InfiniteLongDrivePlanner } from \"../world/infiniteWorld2D.js\";\nimport { roadFromPoints } from \"../world/road.js\";\nimport { buildCarvedTerrainGeometry, buildRoadRibbonGeometry } from \"../world/roadRibbon.js\";\nimport { makeTerrain } from \"../world/terrain.js\";\nimport { bakeMacroCellSplat } from \"./shiftedFixedBody.js\";\n\nexport function buildMacroCellData(\n mx: number,\n mz: number,\n planner: InfiniteLongDrivePlanner,\n terrainMat?: THREE.Material,\n) {\n const plan2d = planner.generateMacroCell2D(mx, mz);\n const hubGroundY = Math.max(2.5, planner.sampleMainlandHeight(plan2d.hubX, plan2d.hubZ));\n const baseFn = (wx: number, wz: number): number => {\n const raw = planner.sampleMainlandHeight(wx, wz);\n if (plan2d.settlementRadiusM <= 0) return raw;\n const d = Math.hypot(wx - plan2d.hubX, wz - plan2d.hubZ);\n if (d <= plan2d.settlementRadiusM) return hubGroundY;\n const u = (d - plan2d.settlementRadiusM) / 96;\n return u >= 1 ? raw : hubGroundY + (raw - hubGroundY) * (u * u * (3 - 2 * u));\n };\n\n const roads = plan2d.highwayPolylines.filter((p) => p.length >= 2).map((poly) => {\n const pts = poly.map(([x, z]): [number, number, number] => [x, Math.max(2, baseFn(x, z)), z]);\n for (let pass = 0; pass < 4; pass++) {\n for (let i = 1; i < pts.length - 1; i++)\n pts[i] = [pts[i][0], 0.5 * pts[i][1] + 0.25 * (pts[i - 1][1] + pts[i + 1][1]), pts[i][2]];\n }\n return roadFromPoints(pts, 4.5, 4, false);\n });\n\n const ribbons = roads.map((r) => buildRoadRibbonGeometry(r));\n const primaryRoad = roads[0] ?? roadFromPoints(\n [[plan2d.originWorldX - 20, hubGroundY, plan2d.originWorldZ], [plan2d.originWorldX + 20, hubGroundY, plan2d.originWorldZ]],\n 4.5, 4, false,\n );\n\n const terr = makeTerrain(mx * 73856093 ^ mz * 19349663, primaryRoad, {\n amplitude: 28, noise: { wavelength: 300, octaves: 2, gain: 0.5, lacunarity: 2 },\n maxSlope: 0.55, minShoulder: 12, verge: 18, baseHeight: baseFn, maxCutFill: 16, extraRoads: roads.slice(1),\n });\n const shiftedTerrain = {\n ...terr,\n height: (lx: number, lz: number) => terr.height(plan2d.originWorldX + lx, plan2d.originWorldZ + lz),\n visualHeight: (lx: number, lz: number, drop?: number) => terr.visualHeight(plan2d.originWorldX + lx, plan2d.originWorldZ + lz, drop),\n roadMask: (lx: number, lz: number) => terr.roadMask(plan2d.originWorldX + lx, plan2d.originWorldZ + lz),\n };\n const terrainGeo = buildCarvedTerrainGeometry(shiftedTerrain, MACRO_SIZE_M, 96);\n const cellTex = terrainMat ? null : createPS2WorldTextures(bakeMacroCellSplat(mx, mz, plan2d, shiftedTerrain));\n const cellTerrain = cellTex ? createPS2TerrainMaterialWebGL(cellTex) : null;\n\n const dummy = new THREE.Object3D();\n const poles: number[] = [], rdStr: number[] = [], rdCw: number[] = [], rdInt: number[] = [];\n const cbStr: number[] = [], cbRmp: number[] = [], cbDrv: number[] = [];\n const wallRes: number[] = [], wallCom: number[] = [], wallInd: number[] = [], roofAll: number[] = [];\n\n for (const r of roads) {\n for (let s = 36; s < r.length - 36; s += 48) {\n const smp = r.at(s);\n dummy.position.set(smp.pos[0] + smp.left[0] * 6.8, smp.pos[1], smp.pos[2] + smp.left[2] * 6.8);\n dummy.rotation.set(0, Math.atan2(smp.tangent[0], smp.tangent[2]), 0);\n dummy.scale.set(1, 1, 1);\n dummy.updateMatrix();\n poles.push(...dummy.matrix.elements);\n }\n }\n\n if (plan2d.settlementRadiusM > 0) {\n const tileReach = Math.min(84, Math.ceil(plan2d.settlementRadiusM / 3));\n for (let tz = -tileReach; tz <= tileReach; tz++) {\n for (let tx = -tileReach; tx <= tileReach; tx++) {\n const wx = plan2d.hubX + tx * 3 + 1.5, wz = plan2d.hubZ + tz * 3 + 1.5;\n const kind = planner.classifySettlementC12Tile(wx, wz, plan2d);\n if (kind < C12TileKind.ROAD_LANE || kind > C12TileKind.C12_PLAZA_HUB) continue;\n dummy.position.set(wx, hubGroundY + 0.02, wz);\n dummy.rotation.set(0, 0, 0);\n dummy.scale.set(1, 1, 1);\n dummy.updateMatrix();\n if (kind === C12TileKind.CROSSWALK) rdCw.push(...dummy.matrix.elements);\n else if (kind === C12TileKind.INTERSECTION_BOX || kind === C12TileKind.C12_PLAZA_HUB) rdInt.push(...dummy.matrix.elements);\n else if (kind === C12TileKind.CURB_RAMP_CORNER) cbRmp.push(...dummy.matrix.elements);\n else if (kind === C12TileKind.CURB_DRIVEWAY) cbDrv.push(...dummy.matrix.elements);\n else if (kind === C12TileKind.CURB_STRAIGHT || kind === C12TileKind.BOULEVARD_MEDIAN) cbStr.push(...dummy.matrix.elements);\n else rdStr.push(...dummy.matrix.elements);\n }\n }\n for (const p of plan2d.parcels.slice(0, 140)) {\n const floors = p.zone === \"COMMERCIAL\" ? 4 : p.zone === \"INDUSTRIAL\" ? 2 : 1;\n const targetWalls = p.zone === \"COMMERCIAL\" ? wallCom : p.zone === \"INDUSTRIAL\" ? wallInd : wallRes;\n const cols = Math.max(2, Math.floor((p.width - 3) / 3)), rows = Math.max(2, Math.floor((p.depth - 3) / 3));\n for (let f = 0; f < floors; f++) {\n const wy = hubGroundY + f * 3 + 1.5;\n for (let c = 0; c < cols; c++) {\n for (const [zOff, yaw] of [[0, 0], [rows * 3, Math.PI]]) {\n dummy.position.set(p.minX + 1.5 + c * 3 + 1.5, wy, p.minZ + 1.5 + zOff);\n dummy.rotation.set(0, yaw, 0); dummy.scale.set(1, 1, 1); dummy.updateMatrix();\n targetWalls.push(...dummy.matrix.elements);\n }\n }\n }\n for (let r = 0; r < rows; r++) {\n for (let c = 0; c < cols; c++) {\n dummy.position.set(p.minX + 3 + c * 3, hubGroundY + floors * 3 + 0.12, p.minZ + 3 + r * 3);\n dummy.rotation.set(0, 0, 0); dummy.scale.set(1, 1, 1); dummy.updateMatrix();\n roofAll.push(...dummy.matrix.elements);\n }\n }\n }\n }\n\n return {\n plan2d, ribbons, terrainGeo, shiftedTerrain, cellTex, cellTerrain,\n poles: new Float32Array(poles), rdStr: new Float32Array(rdStr), rdCw: new Float32Array(rdCw),\n rdInt: new Float32Array(rdInt), cbStr: new Float32Array(cbStr), cbRmp: new Float32Array(cbRmp),\n cbDrv: new Float32Array(cbDrv), wallRes: new Float32Array(wallRes), wallCom: new Float32Array(wallCom),\n wallInd: new Float32Array(wallInd), roofAll: new Float32Array(roofAll),\n sqHub: plan2d.civicHubBatches.find((b) => b.kind === \"FoundationSquare\")?.matrices ?? new Float32Array(),\n triHub: plan2d.civicHubBatches.find((b) => b.kind === \"FoundationTriangle\")?.matrices ?? new Float32Array(),\n };\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAgB,mBACZ,IACA,IACA,SACA,YACF;CACE,MAAM,SAAS,QAAQ,oBAAoB,IAAI,EAAE;CACjD,MAAM,aAAa,KAAK,IAAI,KAAK,QAAQ,qBAAqB,OAAO,MAAM,OA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AK;EAC7F,OAAO,IAAI,aAAa,KAAK;EAAG,SAAS,IAAI,aAAa,OAAO;EAAG,SAAS,IAAI,aAAa,OAAO;EACrG,SAAS,IAAI,aAAa,OAAO;EAAG,SAAS,IAAI,aAAa,OAAO;EACrE,OAAO,OAAO,gBAAgB,MAAM,MAAM,EAAE,SAAS,kBAAkB,CAAC,EAAE,4BAAY,IAAI,aAAa;EACvG,QAAQ,OAAO,gBAAgB,MAAM,MAAM,EAAE,SAAS,oBAAoB,CAAC,EAAE,4BAAY,IAAI,aAAa;CAC9G;AACJ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import * as THREE from "three";
|
|
3
|
-
import { InfiniteLongDrivePlanner, type MacroCellPlan2D } from "../world/
|
|
2
|
+
import type * as THREE from "three";
|
|
3
|
+
import { InfiniteLongDrivePlanner, type MacroCellPlan2D } from "../world/infiniteWorld2D.js";
|
|
4
4
|
import { ShiftedFixedBody, type ShiftedFixedBodyProps } from "./shiftedFixedBody.js";
|
|
5
5
|
export { ShiftedFixedBody, type ShiftedFixedBodyProps };
|
|
6
6
|
export declare function MainlandMacroCell({ mx, mz, planner, roadMat, terrainMat, offX, offZ, renderExtra, }: {
|
|
@@ -1,247 +1,159 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { ShiftedFixedBody as d, bakeMacroCellSplat as f } from "./shiftedFixedBody.js";
|
|
9
|
-
import { useEffect as p, useMemo as m } from "react";
|
|
10
|
-
import * as h from "three";
|
|
11
|
-
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
12
|
-
import { TrimeshCollider as v } from "@react-three/rapier";
|
|
1
|
+
import { InstancedC12Piece, InstancedWorldGlb } from "./longDriveKit.js";
|
|
2
|
+
import { RoadsideStopCompound } from "./longDriveRoadside.js";
|
|
3
|
+
import { buildMacroCellData } from "./macroCellBuilder.js";
|
|
4
|
+
import { ShiftedFixedBody } from "./shiftedFixedBody.js";
|
|
5
|
+
import { useEffect, useMemo } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { TrimeshCollider } from "@react-three/rapier";
|
|
13
8
|
// src/engine/mainlandMacroCell.tsx
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (r <= c.settlementRadiusM) return l;
|
|
21
|
-
let i = (r - c.settlementRadiusM) / 96;
|
|
22
|
-
return i >= 1 ? n : l + (n - l) * (i * i * (3 - 2 * i));
|
|
23
|
-
}, d = c.highwayPolylines.filter((e) => e.length >= 2).map((e) => {
|
|
24
|
-
let t = e.map(([e, t]) => [
|
|
25
|
-
e,
|
|
26
|
-
Math.max(2, u(e, t)),
|
|
27
|
-
t
|
|
28
|
-
]);
|
|
29
|
-
for (let e = 0; e < 4; e++) for (let e = 1; e < t.length - 1; e++) t[e] = [
|
|
30
|
-
t[e][0],
|
|
31
|
-
.5 * t[e][1] + .25 * (t[e - 1][1] + t[e + 1][1]),
|
|
32
|
-
t[e][2]
|
|
33
|
-
];
|
|
34
|
-
return s(t, 4.5, 4, !1);
|
|
35
|
-
}), p = d.map((e) => a(e)), m = d[0] ?? s([[
|
|
36
|
-
c.originWorldX - 20,
|
|
37
|
-
l,
|
|
38
|
-
c.originWorldZ
|
|
39
|
-
], [
|
|
40
|
-
c.originWorldX + 20,
|
|
41
|
-
l,
|
|
42
|
-
c.originWorldZ
|
|
43
|
-
]], 4.5, 4, !1), g = o(y * 73856093 ^ b * 19349663, m, {
|
|
44
|
-
amplitude: 28,
|
|
45
|
-
noise: {
|
|
46
|
-
wavelength: 300,
|
|
47
|
-
octaves: 2,
|
|
48
|
-
gain: .5,
|
|
49
|
-
lacunarity: 2
|
|
50
|
-
},
|
|
51
|
-
maxSlope: .55,
|
|
52
|
-
minShoulder: 12,
|
|
53
|
-
verge: 18,
|
|
54
|
-
baseHeight: u,
|
|
55
|
-
maxCutFill: 16,
|
|
56
|
-
extraRoads: d.slice(1)
|
|
57
|
-
}), _ = {
|
|
58
|
-
...g,
|
|
59
|
-
height: (e, t) => g.height(c.originWorldX + e, c.originWorldZ + t),
|
|
60
|
-
visualHeight: (e, t, n) => g.visualHeight(c.originWorldX + e, c.originWorldZ + t, n),
|
|
61
|
-
roadMask: (e, t) => g.roadMask(c.originWorldX + e, c.originWorldZ + t)
|
|
62
|
-
}, v = i(_, r, 96), S = C ? null : t(f(y, b, c, _)), w = S ? e(S) : null, T = new h.Object3D(), E = [], D = [], O = [], k = [], A = [], j = [], M = [], N = [], P = [], F = [], I = [];
|
|
63
|
-
for (let e of d) for (let t = 36; t < e.length - 36; t += 48) {
|
|
64
|
-
let n = e.at(t);
|
|
65
|
-
T.position.set(n.pos[0] + n.left[0] * 6.8, n.pos[1], n.pos[2] + n.left[2] * 6.8), T.rotation.set(0, Math.atan2(n.tangent[0], n.tangent[2]), 0), T.scale.set(1, 1, 1), T.updateMatrix(), E.push(...T.matrix.elements);
|
|
66
|
-
}
|
|
67
|
-
if (c.settlementRadiusM > 0) {
|
|
68
|
-
let e = Math.min(84, Math.ceil(c.settlementRadiusM / 3));
|
|
69
|
-
for (let t = -e; t <= e; t++) for (let r = -e; r <= e; r++) {
|
|
70
|
-
let e = c.hubX + r * 3 + 1.5, i = c.hubZ + t * 3 + 1.5, a = x.classifySettlementC12Tile(e, i, c);
|
|
71
|
-
a < n.ROAD_LANE || a > n.C12_PLAZA_HUB || (T.position.set(e, l + .02, i), T.rotation.set(0, 0, 0), T.scale.set(1, 1, 1), T.updateMatrix(), a === n.CROSSWALK ? O.push(...T.matrix.elements) : a === n.INTERSECTION_BOX || a === n.C12_PLAZA_HUB ? k.push(...T.matrix.elements) : a === n.CURB_RAMP_CORNER ? j.push(...T.matrix.elements) : a === n.CURB_DRIVEWAY ? M.push(...T.matrix.elements) : a === n.CURB_STRAIGHT || a === n.BOULEVARD_MEDIAN ? A.push(...T.matrix.elements) : D.push(...T.matrix.elements));
|
|
72
|
-
}
|
|
73
|
-
for (let e of c.parcels.slice(0, 140)) {
|
|
74
|
-
let t = e.zone === "COMMERCIAL" ? 4 : e.zone === "INDUSTRIAL" ? 2 : 1, n = e.zone === "COMMERCIAL" ? P : e.zone === "INDUSTRIAL" ? F : N, r = Math.max(2, Math.floor((e.width - 3) / 3)), i = Math.max(2, Math.floor((e.depth - 3) / 3));
|
|
75
|
-
for (let a = 0; a < t; a++) {
|
|
76
|
-
let t = l + a * 3 + 1.5;
|
|
77
|
-
for (let a = 0; a < r; a++) for (let [r, o] of [[0, 0], [i * 3, Math.PI]]) T.position.set(e.minX + 1.5 + a * 3 + 1.5, t, e.minZ + 1.5 + r), T.rotation.set(0, o, 0), T.scale.set(1, 1, 1), T.updateMatrix(), n.push(...T.matrix.elements);
|
|
78
|
-
}
|
|
79
|
-
for (let n = 0; n < i; n++) for (let i = 0; i < r; i++) T.position.set(e.minX + 3 + i * 3, l + t * 3 + .12, e.minZ + 3 + n * 3), T.rotation.set(0, 0, 0), T.scale.set(1, 1, 1), T.updateMatrix(), I.push(...T.matrix.elements);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
let L = c.civicHubBatches.find((e) => e.kind === "FoundationSquare")?.matrices ?? /* @__PURE__ */ new Float32Array(), R = c.civicHubBatches.find((e) => e.kind === "FoundationTriangle")?.matrices ?? /* @__PURE__ */ new Float32Array();
|
|
83
|
-
return {
|
|
84
|
-
plan2d: c,
|
|
85
|
-
ribbons: p,
|
|
86
|
-
terrainGeo: v,
|
|
87
|
-
shiftedTerrain: _,
|
|
88
|
-
cellTex: S,
|
|
89
|
-
cellTerrain: w,
|
|
90
|
-
poles: new Float32Array(E),
|
|
91
|
-
rdStr: new Float32Array(D),
|
|
92
|
-
rdCw: new Float32Array(O),
|
|
93
|
-
rdInt: new Float32Array(k),
|
|
94
|
-
cbStr: new Float32Array(A),
|
|
95
|
-
cbRmp: new Float32Array(j),
|
|
96
|
-
cbDrv: new Float32Array(M),
|
|
97
|
-
wallRes: new Float32Array(N),
|
|
98
|
-
wallCom: new Float32Array(P),
|
|
99
|
-
wallInd: new Float32Array(F),
|
|
100
|
-
roofAll: new Float32Array(I),
|
|
101
|
-
sqHub: L,
|
|
102
|
-
triHub: R
|
|
103
|
-
};
|
|
104
|
-
}, [
|
|
105
|
-
y,
|
|
106
|
-
b,
|
|
107
|
-
x,
|
|
108
|
-
C
|
|
9
|
+
function MainlandMacroCell({ mx, mz, planner, roadMat, terrainMat, offX, offZ, renderExtra }) {
|
|
10
|
+
const built = useMemo(() => buildMacroCellData(mx, mz, planner, terrainMat), [
|
|
11
|
+
mx,
|
|
12
|
+
mz,
|
|
13
|
+
planner,
|
|
14
|
+
terrainMat
|
|
109
15
|
]);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
16
|
+
useEffect(() => () => {
|
|
17
|
+
built.terrainGeo.geometry.dispose();
|
|
18
|
+
built.ribbons.forEach((r) => r.geometry.dispose());
|
|
19
|
+
built.cellTerrain?.material.dispose();
|
|
20
|
+
built.cellTerrain?.depthMaterial.dispose();
|
|
21
|
+
built.cellTex?.dispose();
|
|
22
|
+
}, [built]);
|
|
23
|
+
const activeTerrainMat = terrainMat ?? built.cellTerrain.material;
|
|
24
|
+
return /* @__PURE__ */ jsxs("group", { children: [
|
|
25
|
+
/* @__PURE__ */ jsxs(ShiftedFixedBody, {
|
|
26
|
+
x: built.plan2d.originWorldX + offX,
|
|
27
|
+
z: built.plan2d.originWorldZ + offZ,
|
|
118
28
|
friction: .9,
|
|
119
|
-
children: [/* @__PURE__ */
|
|
120
|
-
geometry:
|
|
121
|
-
material:
|
|
122
|
-
receiveShadow:
|
|
29
|
+
children: [/* @__PURE__ */ jsx(TrimeshCollider, { args: [built.terrainGeo.colliderVertices, built.terrainGeo.colliderIndices] }), /* @__PURE__ */ jsx("mesh", {
|
|
30
|
+
geometry: built.terrainGeo.geometry,
|
|
31
|
+
material: activeTerrainMat,
|
|
32
|
+
receiveShadow: true
|
|
123
33
|
})]
|
|
124
34
|
}),
|
|
125
|
-
|
|
126
|
-
x:
|
|
127
|
-
z:
|
|
35
|
+
built.ribbons.map((r, idx) => /* @__PURE__ */ jsxs(ShiftedFixedBody, {
|
|
36
|
+
x: offX,
|
|
37
|
+
z: offZ,
|
|
128
38
|
friction: 1.05,
|
|
129
|
-
children: [/* @__PURE__ */
|
|
130
|
-
geometry:
|
|
131
|
-
material:
|
|
132
|
-
receiveShadow:
|
|
39
|
+
children: [/* @__PURE__ */ jsx(TrimeshCollider, { args: [r.colliderVertices, r.colliderIndices] }), /* @__PURE__ */ jsx("mesh", {
|
|
40
|
+
geometry: r.geometry,
|
|
41
|
+
material: roadMat,
|
|
42
|
+
receiveShadow: true
|
|
133
43
|
})]
|
|
134
|
-
}, `hwy_${
|
|
135
|
-
/* @__PURE__ */
|
|
44
|
+
}, `hwy_${idx}`)),
|
|
45
|
+
/* @__PURE__ */ jsxs("group", {
|
|
136
46
|
position: [
|
|
137
|
-
|
|
47
|
+
offX,
|
|
138
48
|
0,
|
|
139
|
-
|
|
49
|
+
offZ
|
|
140
50
|
],
|
|
141
51
|
children: [
|
|
142
|
-
/* @__PURE__ */
|
|
52
|
+
/* @__PURE__ */ jsx(InstancedWorldGlb, {
|
|
143
53
|
kitKey: "light_pole",
|
|
144
54
|
fitSpan: [
|
|
145
55
|
.6,
|
|
146
56
|
6.8,
|
|
147
57
|
.6
|
|
148
58
|
],
|
|
149
|
-
matrices:
|
|
59
|
+
matrices: built.poles
|
|
150
60
|
}),
|
|
151
|
-
/* @__PURE__ */
|
|
61
|
+
/* @__PURE__ */ jsx(InstancedWorldGlb, {
|
|
152
62
|
kitKey: "road_straight",
|
|
153
63
|
fitSpan: [
|
|
154
64
|
3,
|
|
155
65
|
.08,
|
|
156
66
|
3
|
|
157
67
|
],
|
|
158
|
-
matrices:
|
|
68
|
+
matrices: built.rdStr
|
|
159
69
|
}),
|
|
160
|
-
/* @__PURE__ */
|
|
70
|
+
/* @__PURE__ */ jsx(InstancedWorldGlb, {
|
|
161
71
|
kitKey: "road_crosswalk",
|
|
162
72
|
fitSpan: [
|
|
163
73
|
3,
|
|
164
74
|
.08,
|
|
165
75
|
3
|
|
166
76
|
],
|
|
167
|
-
matrices:
|
|
77
|
+
matrices: built.rdCw
|
|
168
78
|
}),
|
|
169
|
-
/* @__PURE__ */
|
|
79
|
+
/* @__PURE__ */ jsx(InstancedWorldGlb, {
|
|
170
80
|
kitKey: "road_intersection",
|
|
171
81
|
fitSpan: [
|
|
172
82
|
3,
|
|
173
83
|
.08,
|
|
174
84
|
3
|
|
175
85
|
],
|
|
176
|
-
matrices:
|
|
86
|
+
matrices: built.rdInt
|
|
177
87
|
}),
|
|
178
|
-
/* @__PURE__ */
|
|
88
|
+
/* @__PURE__ */ jsx(InstancedWorldGlb, {
|
|
179
89
|
kitKey: "curb_straight",
|
|
180
90
|
fitSpan: [
|
|
181
91
|
3,
|
|
182
92
|
.18,
|
|
183
93
|
3
|
|
184
94
|
],
|
|
185
|
-
matrices:
|
|
95
|
+
matrices: built.cbStr
|
|
186
96
|
}),
|
|
187
|
-
/* @__PURE__ */
|
|
97
|
+
/* @__PURE__ */ jsx(InstancedWorldGlb, {
|
|
188
98
|
kitKey: "curb_ramp",
|
|
189
99
|
fitSpan: [
|
|
190
100
|
3,
|
|
191
101
|
.18,
|
|
192
102
|
3
|
|
193
103
|
],
|
|
194
|
-
matrices:
|
|
104
|
+
matrices: built.cbRmp
|
|
195
105
|
}),
|
|
196
|
-
/* @__PURE__ */
|
|
106
|
+
/* @__PURE__ */ jsx(InstancedWorldGlb, {
|
|
197
107
|
kitKey: "curb_driveway",
|
|
198
108
|
fitSpan: [
|
|
199
109
|
3,
|
|
200
110
|
.14,
|
|
201
111
|
3
|
|
202
112
|
],
|
|
203
|
-
matrices:
|
|
113
|
+
matrices: built.cbDrv
|
|
204
114
|
}),
|
|
205
|
-
/* @__PURE__ */
|
|
206
|
-
matrices:
|
|
115
|
+
/* @__PURE__ */ jsx(InstancedC12Piece, {
|
|
116
|
+
matrices: built.sqHub,
|
|
207
117
|
kind: "square",
|
|
208
118
|
color: "#94a3b8"
|
|
209
119
|
}),
|
|
210
|
-
/* @__PURE__ */
|
|
211
|
-
matrices:
|
|
120
|
+
/* @__PURE__ */ jsx(InstancedC12Piece, {
|
|
121
|
+
matrices: built.triHub,
|
|
212
122
|
kind: "triangle",
|
|
213
123
|
color: "#cbd5e1"
|
|
214
124
|
}),
|
|
215
|
-
/* @__PURE__ */
|
|
216
|
-
matrices:
|
|
125
|
+
/* @__PURE__ */ jsx(InstancedC12Piece, {
|
|
126
|
+
matrices: built.wallRes,
|
|
217
127
|
kind: "wall",
|
|
218
128
|
color: "#d6c7b2"
|
|
219
129
|
}),
|
|
220
|
-
/* @__PURE__ */
|
|
221
|
-
matrices:
|
|
130
|
+
/* @__PURE__ */ jsx(InstancedC12Piece, {
|
|
131
|
+
matrices: built.wallCom,
|
|
222
132
|
kind: "wall",
|
|
223
133
|
color: "#38bdf8"
|
|
224
134
|
}),
|
|
225
|
-
/* @__PURE__ */
|
|
226
|
-
matrices:
|
|
135
|
+
/* @__PURE__ */ jsx(InstancedC12Piece, {
|
|
136
|
+
matrices: built.wallInd,
|
|
227
137
|
kind: "wall",
|
|
228
138
|
color: "#b45309"
|
|
229
139
|
}),
|
|
230
|
-
/* @__PURE__ */
|
|
231
|
-
matrices:
|
|
140
|
+
/* @__PURE__ */ jsx(InstancedC12Piece, {
|
|
141
|
+
matrices: built.roofAll,
|
|
232
142
|
kind: "roof",
|
|
233
143
|
color: "#334155"
|
|
234
144
|
})
|
|
235
145
|
]
|
|
236
146
|
}),
|
|
237
|
-
|
|
238
|
-
stop
|
|
239
|
-
groundY: Math.max(2,
|
|
240
|
-
offX
|
|
241
|
-
offZ
|
|
242
|
-
cellTag: `stop_${
|
|
243
|
-
}, `stop_${
|
|
244
|
-
|
|
147
|
+
built.plan2d.roadsideStops.map((stop, idx) => /* @__PURE__ */ jsx(RoadsideStopCompound, {
|
|
148
|
+
stop,
|
|
149
|
+
groundY: Math.max(2, built.shiftedTerrain.height(stop.worldX - built.plan2d.originWorldX, stop.worldZ - built.plan2d.originWorldZ)),
|
|
150
|
+
offX,
|
|
151
|
+
offZ,
|
|
152
|
+
cellTag: `stop_${mx}_${mz}_${idx}`
|
|
153
|
+
}, `stop_${idx}`)),
|
|
154
|
+
renderExtra?.(mx, mz, built.plan2d, offX, offZ)
|
|
245
155
|
] });
|
|
246
156
|
}
|
|
247
|
-
export {
|
|
157
|
+
export { MainlandMacroCell, ShiftedFixedBody };
|
|
158
|
+
|
|
159
|
+
//# sourceMappingURL=mainlandMacroCell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mainlandMacroCell.js","names":[],"sources":["../../src/engine/mainlandMacroCell.tsx"],"sourcesContent":["import React, { useEffect, useMemo } from \"react\";\nimport type * as THREE from \"three\";\nimport { TrimeshCollider } from \"@react-three/rapier\";\nimport { InfiniteLongDrivePlanner, type MacroCellPlan2D } from \"../world/infiniteWorld2D.js\";\nimport { InstancedC12Piece, InstancedWorldGlb, RoadsideStopCompound } from \"./longDriveKit.js\";\nimport { buildMacroCellData } from \"./macroCellBuilder.js\";\nimport { ShiftedFixedBody, type ShiftedFixedBodyProps } from \"./shiftedFixedBody.js\";\n\nexport { ShiftedFixedBody, type ShiftedFixedBodyProps };\n\nexport function MainlandMacroCell({\n mx,\n mz,\n planner,\n roadMat,\n terrainMat,\n offX,\n offZ,\n renderExtra,\n}: {\n readonly mx: number;\n readonly mz: number;\n readonly planner: InfiniteLongDrivePlanner;\n readonly roadMat: THREE.Material;\n readonly terrainMat?: THREE.Material;\n readonly offX: number;\n readonly offZ: number;\n readonly renderExtra?: (mx: number, mz: number, plan: MacroCellPlan2D, offX: number, offZ: number) => React.ReactNode;\n}): React.JSX.Element {\n const built = useMemo(() => buildMacroCellData(mx, mz, planner, terrainMat), [mx, mz, planner, terrainMat]);\n\n useEffect(() => () => {\n built.terrainGeo.geometry.dispose();\n built.ribbons.forEach((r) => r.geometry.dispose());\n built.cellTerrain?.material.dispose();\n built.cellTerrain?.depthMaterial.dispose();\n built.cellTex?.dispose();\n }, [built]);\n\n const activeTerrainMat = terrainMat ?? built.cellTerrain!.material;\n\n return (\n <group>\n <ShiftedFixedBody x={built.plan2d.originWorldX + offX} z={built.plan2d.originWorldZ + offZ} friction={0.9}>\n <TrimeshCollider args={[built.terrainGeo.colliderVertices, built.terrainGeo.colliderIndices]} />\n <mesh geometry={built.terrainGeo.geometry} material={activeTerrainMat} receiveShadow />\n </ShiftedFixedBody>\n {built.ribbons.map((r, idx) => (\n <ShiftedFixedBody key={`hwy_${idx}`} x={offX} z={offZ} friction={1.05}>\n <TrimeshCollider args={[r.colliderVertices, r.colliderIndices]} />\n <mesh geometry={r.geometry} material={roadMat} receiveShadow />\n </ShiftedFixedBody>\n ))}\n <group position={[offX, 0, offZ]}>\n <InstancedWorldGlb kitKey=\"light_pole\" fitSpan={[0.6, 6.8, 0.6]} matrices={built.poles} />\n <InstancedWorldGlb kitKey=\"road_straight\" fitSpan={[3, 0.08, 3]} matrices={built.rdStr} />\n <InstancedWorldGlb kitKey=\"road_crosswalk\" fitSpan={[3, 0.08, 3]} matrices={built.rdCw} />\n <InstancedWorldGlb kitKey=\"road_intersection\" fitSpan={[3, 0.08, 3]} matrices={built.rdInt} />\n <InstancedWorldGlb kitKey=\"curb_straight\" fitSpan={[3, 0.18, 3]} matrices={built.cbStr} />\n <InstancedWorldGlb kitKey=\"curb_ramp\" fitSpan={[3, 0.18, 3]} matrices={built.cbRmp} />\n <InstancedWorldGlb kitKey=\"curb_driveway\" fitSpan={[3, 0.14, 3]} matrices={built.cbDrv} />\n <InstancedC12Piece matrices={built.sqHub} kind=\"square\" color=\"#94a3b8\" />\n <InstancedC12Piece matrices={built.triHub} kind=\"triangle\" color=\"#cbd5e1\" />\n <InstancedC12Piece matrices={built.wallRes} kind=\"wall\" color=\"#d6c7b2\" />\n <InstancedC12Piece matrices={built.wallCom} kind=\"wall\" color=\"#38bdf8\" />\n <InstancedC12Piece matrices={built.wallInd} kind=\"wall\" color=\"#b45309\" />\n <InstancedC12Piece matrices={built.roofAll} kind=\"roof\" color=\"#334155\" />\n </group>\n {built.plan2d.roadsideStops.map((stop, idx) => (\n <RoadsideStopCompound\n key={`stop_${idx}`}\n stop={stop}\n groundY={Math.max(\n 2,\n built.shiftedTerrain.height(stop.worldX - built.plan2d.originWorldX, stop.worldZ - built.plan2d.originWorldZ),\n )}\n offX={offX}\n offZ={offZ}\n cellTag={`stop_${mx}_${mz}_${idx}`}\n />\n ))}\n {renderExtra?.(mx, mz, built.plan2d, offX, offZ)}\n </group>\n );\n}\n"],"mappings":";;;;;;;;AAUA,SAAgB,kBAAkB,EAC9B,IACA,IACA,SACA,SACA,YACA,MACA,MACA,eAUkB;CAClB,MAAM,QAAQ,cAAc,mBAAmB,IAAI,IAAI,SAAS,UAAU,GAAG;EAAC;EAAI;EAAI;EAAS;CAAU,CAAC;CAE1G,sBAAsB;EAClB,MAAM,WAAW,SAAS,QAAQ;EAClC,MAAM,QAAQ,SAAS,MAAM,EAAE,SAAS,QAAQ,CAAC;EACjD,MAAM,aAAa,SAAS,QAAQ;EACpC,MAAM,aAAa,cAAc,QAAQ;EACzC,MAAM,SAAS,QAAQ;CAC3B,GAAG,CAAC,KAAK,CAAC;CAEV,MAAM,mBAAmB,cAAc,MAAM,YAAa;CAE1D,OACI,qBAAC,SAAD,EAAA,UAAA;EACI,qBAAC,kBAAD;GAAkB,GAAG,MAAM,OAAO,eAAe;GAAM,GAAG,MAAM,OAAO,eAAe;GAAM,UAAU;GAAtG,UAAA,CACI,oBAAC,iBAAD,EAAiB,MAAM,CAAC,MAAM,WAAW,kBAAkB,MAAM,WAAW,eAAe,EAA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AAW,CAAA;IACzE,oBAAC,mBAAD;KAAmB,UAAU,MAAM;KAAQ,MAAK;KAAW,OAAM;IAAW,CAAA;IAC5E,oBAAC,mBAAD;KAAmB,UAAU,MAAM;KAAS,MAAK;KAAO,OAAM;IAAW,CAAA;IACzE,oBAAC,mBAAD;KAAmB,UAAU,MAAM;KAAS,MAAK;KAAO,OAAM;IAAW,CAAA;IACzE,oBAAC,mBAAD;KAAmB,UAAU,MAAM;KAAS,MAAK;KAAO,OAAM;IAAW,CAAA;IACzE,oBAAC,mBAAD;KAAmB,UAAU,MAAM;KAAS,MAAK;KAAO,OAAM;IAAW,CAAA;GACtE;;EACN,MAAM,OAAO,cAAc,KAAK,MAAM,QACnC,oBAAC,sBAAD;GAEU;GACN,SAAS,KAAK,IACV,GACA,MAAM,eAAe,OAAO,KAAK,SAAS,MAAM,OAAO,cAAc,KAAK,SAAS,MAAM,OAAO,YAAY,CAChH;GACM;GACA;GACN,SAAS,QAAQ,GAAG,GAAG,GAAG,GAAG;EAChC,GATQ,QAAQ,KAShB,CACJ;EACA,cAAc,IAAI,IAAI,MAAM,QAAQ,MAAM,IAAI;CAC5C,EAAA,CAAA;AAEf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import type { MacroCellPlan2D, Terrain, WorldGenResult } from "../world/index.js";
|
|
3
3
|
export interface ShiftedFixedBodyProps {
|
|
4
4
|
readonly x: number;
|
|
5
5
|
readonly y?: number;
|
|
@@ -1,48 +1,75 @@
|
|
|
1
|
-
import { MACRO_SIZE_M
|
|
1
|
+
import { MACRO_SIZE_M } from "../world/macroCellSchema.js";
|
|
2
2
|
import "react";
|
|
3
|
-
import { jsx
|
|
4
|
-
import { RigidBody
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { RigidBody } from "@react-three/rapier";
|
|
5
5
|
// src/engine/shiftedFixedBody.tsx
|
|
6
|
-
function
|
|
7
|
-
return /* @__PURE__ */
|
|
6
|
+
function ShiftedFixedBody({ x, y = 0, z, yaw = 0, friction = 1, userData, children }) {
|
|
7
|
+
return /* @__PURE__ */ jsx(RigidBody, {
|
|
8
8
|
type: "fixed",
|
|
9
9
|
position: [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
x,
|
|
11
|
+
y,
|
|
12
|
+
z
|
|
13
13
|
],
|
|
14
14
|
rotation: [
|
|
15
15
|
0,
|
|
16
|
-
|
|
16
|
+
yaw,
|
|
17
17
|
0
|
|
18
18
|
],
|
|
19
|
-
colliders:
|
|
20
|
-
friction
|
|
21
|
-
...
|
|
22
|
-
children
|
|
19
|
+
colliders: false,
|
|
20
|
+
friction,
|
|
21
|
+
...userData === void 0 ? {} : { userData },
|
|
22
|
+
children
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
function bakeMacroCellSplat(mx, mz, plan2d, shiftedTerrain) {
|
|
26
|
+
const half = MACRO_SIZE_M * .5;
|
|
27
|
+
const alphaMap = (/* @__PURE__ */ new Uint8Array(9216)).fill(255);
|
|
28
|
+
const splat0 = /* @__PURE__ */ new Uint8Array(36864);
|
|
29
|
+
const splat1 = /* @__PURE__ */ new Uint8Array(36864);
|
|
30
|
+
for (let r = 0; r < 96; r++) {
|
|
31
|
+
const z = -half + r / 95 * MACRO_SIZE_M;
|
|
32
|
+
for (let c = 0; c < 96; c++) {
|
|
33
|
+
const x = -half + c / 95 * MACRO_SIZE_M;
|
|
34
|
+
const idx = (r * 96 + c) * 4;
|
|
35
|
+
const h = shiftedTerrain.height(x, z);
|
|
36
|
+
const mask = shiftedTerrain.roadMask(x, z);
|
|
37
|
+
const wx = plan2d.originWorldX + x;
|
|
38
|
+
const wz = plan2d.originWorldZ + z;
|
|
39
|
+
const inSettlement = plan2d.settlementRadiusM > 0 && Math.hypot(wx - plan2d.hubX, wz - plan2d.hubZ) <= plan2d.settlementRadiusM;
|
|
40
|
+
if (mask.asphalt > .35) {
|
|
41
|
+
splat1[idx + 3] = 230;
|
|
42
|
+
splat1[idx] = 25;
|
|
43
|
+
} else if (mask.gravel > .15 || inSettlement) {
|
|
44
|
+
splat1[idx] = inSettlement ? 175 : Math.round(190 * mask.gravel);
|
|
45
|
+
splat0[idx] = 65;
|
|
46
|
+
splat0[idx + 1] = 35;
|
|
47
|
+
} else if (h > 44) {
|
|
48
|
+
splat1[idx + 2] = 190;
|
|
49
|
+
splat0[idx + 3] = 65;
|
|
50
|
+
} else if (h > 24) {
|
|
51
|
+
splat0[idx + 3] = 125;
|
|
52
|
+
splat1[idx + 1] = 95;
|
|
53
|
+
splat0[idx] = 35;
|
|
54
|
+
} else {
|
|
55
|
+
splat0[idx + 1] = 145;
|
|
56
|
+
splat1[idx + 1] = 75;
|
|
57
|
+
splat0[idx] = 35;
|
|
58
|
+
}
|
|
34
59
|
}
|
|
35
60
|
}
|
|
36
61
|
return {
|
|
37
62
|
config: {
|
|
38
|
-
seed: `mc_${
|
|
39
|
-
size:
|
|
63
|
+
seed: `mc_${mx}_${mz}`,
|
|
64
|
+
size: MACRO_SIZE_M,
|
|
40
65
|
gridCells: 96,
|
|
41
66
|
waterLevel: 0
|
|
42
67
|
},
|
|
43
|
-
alphaMap
|
|
44
|
-
splat0
|
|
45
|
-
splat1
|
|
68
|
+
alphaMap,
|
|
69
|
+
splat0,
|
|
70
|
+
splat1
|
|
46
71
|
};
|
|
47
72
|
}
|
|
48
|
-
export {
|
|
73
|
+
export { ShiftedFixedBody, bakeMacroCellSplat };
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=shiftedFixedBody.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shiftedFixedBody.js","names":[],"sources":["../../src/engine/shiftedFixedBody.tsx"],"sourcesContent":["import React from \"react\";\nimport { RigidBody } from \"@react-three/rapier\";\nimport { MACRO_SIZE_M } from \"../world/macroCellSchema.js\";\nimport type { MacroCellPlan2D, Terrain, WorldGenResult } from \"../world/index.js\";\n\nexport interface ShiftedFixedBodyProps {\n readonly x: number;\n readonly y?: number;\n readonly z: number;\n readonly yaw?: number;\n readonly friction?: number;\n readonly userData?: Record<string, unknown>;\n readonly children: React.ReactNode;\n}\n\nexport function ShiftedFixedBody({\n x,\n y = 0,\n z,\n yaw = 0,\n friction = 1,\n userData,\n children,\n}: ShiftedFixedBodyProps): React.JSX.Element {\n return (\n <RigidBody\n type=\"fixed\"\n position={[x, y, z]}\n rotation={[0, yaw, 0]}\n colliders={false}\n friction={friction}\n {...(userData === undefined ? {} : { userData })}\n >\n {children}\n </RigidBody>\n );\n}\n\nexport function bakeMacroCellSplat(\n mx: number,\n mz: number,\n plan2d: MacroCellPlan2D,\n shiftedTerrain: Terrain,\n): WorldGenResult {\n const half = MACRO_SIZE_M * 0.5;\n const alphaMap = new Uint8Array(96 * 96).fill(255);\n const splat0 = new Uint8Array(96 * 96 * 4);\n const splat1 = new Uint8Array(96 * 96 * 4);\n for (let r = 0; r < 96; r++) {\n const z = -half + (r / 95) * MACRO_SIZE_M;\n for (let c = 0; c < 96; c++) {\n const x = -half + (c / 95) * MACRO_SIZE_M;\n const idx = (r * 96 + c) * 4;\n const h = shiftedTerrain.height(x, z);\n const mask = shiftedTerrain.roadMask(x, z);\n const wx = plan2d.originWorldX + x;\n const wz = plan2d.originWorldZ + z;\n const inSettlement = plan2d.settlementRadiusM > 0 && Math.hypot(wx - plan2d.hubX, wz - plan2d.hubZ) <= plan2d.settlementRadiusM;\n if (mask.asphalt > 0.35) {\n splat1[idx + 3] = 230;\n splat1[idx] = 25;\n }\n else if (mask.gravel > 0.15 || inSettlement) {\n splat1[idx] = inSettlement ? 175 : Math.round(190 * mask.gravel);\n splat0[idx] = 65;\n splat0[idx + 1] = 35;\n }\n else if (h > 44) {\n splat1[idx + 2] = 190;\n splat0[idx + 3] = 65;\n }\n else if (h > 24) {\n splat0[idx + 3] = 125;\n splat1[idx + 1] = 95;\n splat0[idx] = 35;\n }\n else {\n splat0[idx + 1] = 145;\n splat1[idx + 1] = 75;\n splat0[idx] = 35;\n }\n }\n }\n return {\n config: { seed: `mc_${mx}_${mz}`, size: MACRO_SIZE_M, gridCells: 96, waterLevel: 0 },\n alphaMap,\n splat0,\n splat1,\n };\n}\n"],"mappings":";;;;;AAeA,SAAgB,iBAAiB,EAC7B,GACA,IAAI,GACJ,GACA,MAAM,GACN,WAAW,GACX,UACA,YACyC;CACzC,OACI,oBAAC,WAAD;EACI,MAAK;EACL,UAAU;GAAC;GAAG;GAAG;EAAC;EAClB,UAAU;GAAC;GAAG;GAAK;EAAC;EACpB,WAAW;EACD;EACV,GAAK,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS;EAE7C;CACM,CAAA;AAEnB;AAEA,SAAgB,mBACZ,IACA,IACA,QACA,gBACc;CACd,MAAM,OAAO,eAAe;CAC5B,MAAM,4BAAW,IAAI,WAAW,IAAO,EAAA,CAAE,KAAK,GAAG;CACjD,MAAM,yBAAS,IAAI,WAAW,KAAW;CACzC,MAAM,yBAAS,IAAI,WAAW,KAAW;CACzC,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK;EACzB,MAAM,IAAI,CAAC,OAAQ,IAAI,KAAM;EAC7B,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK;GACzB,MAAM,IAAI,CAAC,OAAQ,IAAI,KAAM;GAC7B,MAAM,OAAO,IAAI,KAAK,KAAK;GAC3B,MAAM,IAAI,eAAe,OAAO,GAAG,CAAC;GACpC,MAAM,OAAO,eAAe,SAAS,GAAG,CAAC;GACzC,MAAM,KAAK,OAAO,eAAe;GACjC,MAAM,KAAK,OAAO,eAAe;GACjC,MAAM,eAAe,OAAO,oBAAoB,KAAK,KAAK,MAAM,KAAK,OAAO,MAAM,KAAK,OAAO,IAAI,KAAK,OAAO;GAC9G,IAAI,KAA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