@nayan-ui/games 1.20.0 → 1.21.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/lib/module/games/arrows/Arrows.js +1 -1
- package/lib/module/games/arrows/ArrowsScene.js +1 -1
- package/lib/module/games/balloon-blaster/BalloonBlaster.js +1 -1
- package/lib/module/games/balloon-blaster/BalloonBlasterScene.js +1 -1
- package/lib/module/games/bike-racing/BikeMeshes.js +1 -1
- package/lib/module/games/bike-racing/BikeRacing.js +1 -1
- package/lib/module/games/bike-racing/BikeRacingConstants.js +1 -1
- package/lib/module/games/bike-racing/BikeRacingScene.js +1 -1
- package/lib/module/games/block-blast/BlockBlast.js +1 -1
- package/lib/module/games/block-blast/BlockBlastScene.js +1 -1
- package/lib/module/games/block-breaker/BlockBreaker.js +1 -1
- package/lib/module/games/block-breaker/BlockBreakerScene.js +1 -1
- package/lib/module/games/bluk/Bluk.js +1 -1
- package/lib/module/games/bluk/BlukScene.js +1 -1
- package/lib/module/games/bubble-shooter/BubbleShooter.js +1 -1
- package/lib/module/games/bubble-shooter/BubbleShooterScene.js +1 -1
- package/lib/module/games/candy-crush/CandyCrush.js +1 -1
- package/lib/module/games/candy-crush/CandyCrushScene.js +1 -1
- package/lib/module/games/car-racing/CarMeshes.js +1 -1
- package/lib/module/games/car-racing/CarRacing.js +1 -1
- package/lib/module/games/car-racing/CarRacingScene.js +1 -1
- package/lib/module/games/chameleon-run/ChameleonRun.js +1 -1
- package/lib/module/games/chameleon-run/ChameleonRunBackdrop.js +1 -1
- package/lib/module/games/chameleon-run/ChameleonRunMeshes.js +1 -1
- package/lib/module/games/checkers/Checkers.js +1 -1
- package/lib/module/games/checkers/CheckersScene.js +1 -1
- package/lib/module/games/color-switch/ColorSwitch.js +1 -1
- package/lib/module/games/color-switch/ColorSwitchScene.js +1 -1
- package/lib/module/games/colors-sort/ColorsSort.js +1 -1
- package/lib/module/games/colors-sort/ColorsSortScene.js +1 -1
- package/lib/module/games/connect-em-all/ConnectEmAll.js +1 -1
- package/lib/module/games/connect-em-all/ConnectEmAllScene.js +1 -1
- package/lib/module/games/crossy-road/CrossyRoad.js +1 -1
- package/lib/module/games/crossy-road/CrossyRoadMeshes.js +1 -1
- package/lib/module/games/crossy-road/CrossyRoadPerson.js +1 -1
- package/lib/module/games/dino-jump/DinoJump.js +1 -1
- package/lib/module/games/dino-jump/DinoJumpScene.js +1 -1
- package/lib/module/games/dots-and-boxes/DotsAndBoxes.js +1 -1
- package/lib/module/games/dots-and-boxes/DotsAndBoxesScene.js +1 -1
- package/lib/module/games/falling-sticks/FallingSticks.js +1 -1
- package/lib/module/games/falling-sticks/FallingSticksScene.js +1 -1
- package/lib/module/games/find-different-number/FindDifferentNumber.js +1 -1
- package/lib/module/games/find-different-number/FindDifferentNumberScene.js +1 -1
- package/lib/module/games/flappy-bird/FlappyBird.js +1 -1
- package/lib/module/games/flappy-bird/FlappyBirdScene.js +1 -1
- package/lib/module/games/fruit-merger/FruitMerger.js +1 -1
- package/lib/module/games/fruit-merger/FruitMergerScene.js +1 -1
- package/lib/module/games/fruit-ninja/FruitNinja.js +1 -1
- package/lib/module/games/fruit-ninja/FruitNinjaScene.js +1 -1
- package/lib/module/games/fruit-ninja/FruitNinjaWorld.js +1 -1
- package/lib/module/games/game-2048/Game2048.js +1 -1
- package/lib/module/games/game-2048/Game2048Scene.js +1 -1
- package/lib/module/games/knife-hit/KnifeHit.js +1 -1
- package/lib/module/games/knife-hit/KnifeHitScene.js +1 -1
- package/lib/module/games/ludo-king/LudoKing.js +1 -1
- package/lib/module/games/ludo-king/LudoKingScene.js +1 -1
- package/lib/module/games/maze-runner/MazeRunner.js +1 -1
- package/lib/module/games/maze-runner/MazeRunnerScene.js +1 -1
- package/lib/module/games/memory-match/MemoryMatch.js +1 -1
- package/lib/module/games/memory-match/MemoryMatchScene.js +1 -1
- package/lib/module/games/mine-sweeper/MineSweeper.js +1 -1
- package/lib/module/games/mine-sweeper/MineSweeperScene.js +1 -1
- package/lib/module/games/mob-control/MobControl.js +1 -1
- package/lib/module/games/mob-control/MobControlGame.js +1 -1
- package/lib/module/games/mob-control/MobControlMeshes.js +1 -1
- package/lib/module/games/mob-control/MobControlRenderer.js +1 -1
- package/lib/module/games/mob-control/MobControlRules.js +1 -1
- package/lib/module/games/mob-control/MobControlScene.js +1 -1
- package/lib/module/games/nuts-and-bolts/NutsAndBolts.js +1 -1
- package/lib/module/games/nuts-and-bolts/NutsAndBoltsScene.js +1 -1
- package/lib/module/games/pac-man/PacMan.js +1 -1
- package/lib/module/games/pac-man/PacManGame.js +1 -1
- package/lib/module/games/pac-man/PacManScene.js +1 -1
- package/lib/module/games/paper-io/PaperIo.js +1 -1
- package/lib/module/games/paper-io/PaperIoMeshes.js +1 -1
- package/lib/module/games/paper-io/PaperIoScene.js +1 -1
- package/lib/module/games/penguin-run/PenguinMeshes.js +1 -1
- package/lib/module/games/penguin-run/PenguinRun.js +1 -1
- package/lib/module/games/penguin-run/PenguinRunScene.js +1 -1
- package/lib/module/games/perfect-circle/PerfectCircle.js +1 -1
- package/lib/module/games/perfect-circle/PerfectCircleScene.js +1 -1
- package/lib/module/games/pipe-connect/PipeConnect.js +1 -1
- package/lib/module/games/pipe-connect/PipeConnectScene.js +1 -1
- package/lib/module/games/play-with-tua/PlayWithTua.js +1 -1
- package/lib/module/games/popit-fidget/PopitFidget.js +1 -1
- package/lib/module/games/popit-fidget/PopitFidgetScene.js +1 -1
- package/lib/module/games/reversi/Reversi.js +1 -1
- package/lib/module/games/reversi/ReversiScene.js +1 -1
- package/lib/module/games/search-grid/SearchGrid.js +1 -1
- package/lib/module/games/search-grid/SearchGridScene.js +1 -1
- package/lib/module/games/shared/BackdropCard.js +1 -1
- package/lib/module/games/shared/EngineBackdrop.js +1 -1
- package/lib/module/games/shared/EngineBlasts.js +1 -1
- package/lib/module/games/shared/EngineBlocks.js +1 -1
- package/lib/module/games/shared/EngineDice.js +1 -1
- package/lib/module/games/shared/EngineFruits.js +1 -1
- package/lib/module/games/shared/EngineGameLoader.js +1 -1
- package/lib/module/games/shared/EngineGameScreen.js +1 -1
- package/lib/module/games/shared/EngineGlyphs.js +1 -1
- package/lib/module/games/shared/EngineHud.js +1 -1
- package/lib/module/games/shared/EngineMeadow.js +1 -1
- package/lib/module/games/shared/EngineTouchSurface.js +1 -1
- package/lib/module/games/shared/GameActivity.js +1 -1
- package/lib/module/games/shared/GameLoading.js +1 -1
- package/lib/module/games/shared/GameLoadingTransition.js +1 -1
- package/lib/module/games/sliding-numbers/SlidingNumbers.js +1 -1
- package/lib/module/games/sliding-numbers/SlidingNumbersScene.js +1 -1
- package/lib/module/games/snake-3d/Snake3D.js +1 -1
- package/lib/module/games/snake-3d/Snake3DScene.js +1 -1
- package/lib/module/games/snakes-and-ladders/SnakesAndLadders.js +1 -1
- package/lib/module/games/snakes-and-ladders/SnakesAndLaddersScene.js +1 -1
- package/lib/module/games/space-fighter/SpaceFighter.js +1 -1
- package/lib/module/games/space-fighter/SpaceFighterScene.js +1 -1
- package/lib/module/games/spider-solitaire/SpiderSolitaire.js +1 -1
- package/lib/module/games/spider-solitaire/SpiderSolitaireScene.js +1 -1
- package/lib/module/games/stack-tower/StackTower.js +1 -1
- package/lib/module/games/stack-tower/StackTowerScene.js +1 -1
- package/lib/module/games/sudoku/Sudoku.js +1 -1
- package/lib/module/games/sudoku/SudokuScene.js +1 -1
- package/lib/module/games/tangram/Tangram.js +1 -1
- package/lib/module/games/tangram/TangramScene.js +1 -1
- package/lib/module/games/tank-1990/Tank1990.js +1 -1
- package/lib/module/games/tank-1990/Tank1990Scene.js +1 -1
- package/lib/module/games/tic-tac-toe/TicTacToe.js +1 -1
- package/lib/module/games/tic-tac-toe/TicTacToeScene.js +1 -1
- package/lib/module/games/tile-home/TileHome.js +1 -1
- package/lib/module/games/tile-home/TileHomeScene.js +1 -1
- package/lib/module/games/treasure-hunt/TreasureHunt.js +1 -1
- package/lib/module/games/treasure-hunt/TreasureHuntConstants.js +1 -1
- package/lib/module/games/treasure-hunt/TreasureHuntModel.js +1 -1
- package/lib/module/games/treasure-hunt/TreasureHuntScene.js +1 -1
- package/lib/module/games/whack-a-mole/WhackAMole.js +1 -1
- package/lib/module/games/whack-a-mole/WhackAMoleScene.js +1 -1
- package/lib/module/helpers/GameSettingsModal.js +1 -1
- package/lib/module/helpers/GameTheme.js +1 -1
- package/package.json +1 -2
- package/src/assets/fonts/Inter-SemiBold.ttf +0 -0
- package/src/assets/models/explorer/explorer.glb +0 -0
- package/src/assets/models/explorer/params.json +0 -51
- package/src/assets/models/explorer/source.json +0 -222
- package/src/assets/models/play-with-tua/play-with-tua.glb +0 -0
- package/src/assets/models/play-with-tua/sources.json +0 -141
- package/src/assets/sfx/balloon_pop.wav +0 -0
- package/src/assets/sfx/blocked.wav +0 -0
- package/src/assets/sfx/boing.wav +0 -0
- package/src/assets/sfx/bonus.wav +0 -0
- package/src/assets/sfx/boom.wav +0 -0
- package/src/assets/sfx/bump.wav +0 -0
- package/src/assets/sfx/cannon.wav +0 -0
- package/src/assets/sfx/capture.wav +0 -0
- package/src/assets/sfx/card_flip.wav +0 -0
- package/src/assets/sfx/card_place.wav +0 -0
- package/src/assets/sfx/catch.wav +0 -0
- package/src/assets/sfx/chime.wav +0 -0
- package/src/assets/sfx/chomp.wav +0 -0
- package/src/assets/sfx/chomp_alt.wav +0 -0
- package/src/assets/sfx/clack.wav +0 -0
- package/src/assets/sfx/clang.wav +0 -0
- package/src/assets/sfx/clash.wav +0 -0
- package/src/assets/sfx/click.wav +0 -0
- package/src/assets/sfx/coin.wav +0 -0
- package/src/assets/sfx/combo.wav +0 -0
- package/src/assets/sfx/crash.wav +0 -0
- package/src/assets/sfx/crunch.wav +0 -0
- package/src/assets/sfx/dance.wav +0 -0
- package/src/assets/sfx/deselect.wav +0 -0
- package/src/assets/sfx/dice_roll.wav +0 -0
- package/src/assets/sfx/die.wav +0 -0
- package/src/assets/sfx/draw.wav +0 -0
- package/src/assets/sfx/drop.wav +0 -0
- package/src/assets/sfx/eat.wav +0 -0
- package/src/assets/sfx/engine.wav +0 -0
- package/src/assets/sfx/error.wav +0 -0
- package/src/assets/sfx/flag.wav +0 -0
- package/src/assets/sfx/flap.wav +0 -0
- package/src/assets/sfx/flip_disc.wav +0 -0
- package/src/assets/sfx/footstep_run.wav +0 -0
- package/src/assets/sfx/footstep_walk.wav +0 -0
- package/src/assets/sfx/game_over.wav +0 -0
- package/src/assets/sfx/gate.wav +0 -0
- package/src/assets/sfx/hit.wav +0 -0
- package/src/assets/sfx/hop.wav +0 -0
- package/src/assets/sfx/hurt.wav +0 -0
- package/src/assets/sfx/invalid.wav +0 -0
- package/src/assets/sfx/jump.wav +0 -0
- package/src/assets/sfx/ladder.wav +0 -0
- package/src/assets/sfx/land.wav +0 -0
- package/src/assets/sfx/laugh.wav +0 -0
- package/src/assets/sfx/lose.wav +0 -0
- package/src/assets/sfx/merge.wav +0 -0
- package/src/assets/sfx/miss.wav +0 -0
- package/src/assets/sfx/nitro.wav +0 -0
- package/src/assets/sfx/pew.wav +0 -0
- package/src/assets/sfx/place.wav +0 -0
- package/src/assets/sfx/pling.wav +0 -0
- package/src/assets/sfx/point.wav +0 -0
- package/src/assets/sfx/pop.wav +0 -0
- package/src/assets/sfx/pop_soft.wav +0 -0
- package/src/assets/sfx/power_up.wav +0 -0
- package/src/assets/sfx/reveal.wav +0 -0
- package/src/assets/sfx/robot.wav +0 -0
- package/src/assets/sfx/rotate.wav +0 -0
- package/src/assets/sfx/run_steps.wav +0 -0
- package/src/assets/sfx/select.wav +0 -0
- package/src/assets/sfx/shuffle.wav +0 -0
- package/src/assets/sfx/six.wav +0 -0
- package/src/assets/sfx/slice.wav +0 -0
- package/src/assets/sfx/slide.wav +0 -0
- package/src/assets/sfx/snake.wav +0 -0
- package/src/assets/sfx/snap.wav +0 -0
- package/src/assets/sfx/splash.wav +0 -0
- package/src/assets/sfx/star.wav +0 -0
- package/src/assets/sfx/start.wav +0 -0
- package/src/assets/sfx/swoosh.wav +0 -0
- package/src/assets/sfx/tap.wav +0 -0
- package/src/assets/sfx/thud.wav +0 -0
- package/src/assets/sfx/thunk.wav +0 -0
- package/src/assets/sfx/tick.wav +0 -0
- package/src/assets/sfx/time_up.wav +0 -0
- package/src/assets/sfx/tock.wav +0 -0
- package/src/assets/sfx/walk_steps.wav +0 -0
- package/src/assets/sfx/warning.wav +0 -0
- package/src/assets/sfx/whack.wav +0 -0
- package/src/assets/sfx/whoosh.wav +0 -0
- package/src/assets/sfx/win.wav +0 -0
- package/src/assets/sfx/zap.wav +0 -0
- package/src/assets/textures/ad_bolt.png +0 -0
- package/src/assets/textures/ad_bubbles.png +0 -0
- package/src/assets/textures/ad_chevrons.png +0 -0
- package/src/assets/textures/asphalt.png +0 -0
- package/src/assets/textures/bark.jpg +0 -0
- package/src/assets/textures/explorer-atlas.png +0 -0
- package/src/assets/textures/facade.png +0 -0
- package/src/assets/textures/grass.png +0 -0
- package/src/assets/textures/leaves.png +0 -0
- package/src/assets/textures/limestone.jpg +0 -0
- package/src/assets/textures/meadow.jpg +0 -0
- package/src/assets/textures/nature-sources.json +0 -87
- package/src/assets/textures/pine.png +0 -0
- package/src/assets/textures/river.jpg +0 -0
- package/src/assets/textures/soft_glow.png +0 -0
- package/src/games/arrows/Arrows.tsx +0 -69
- package/src/games/arrows/ArrowsConstants.ts +0 -107
- package/src/games/arrows/ArrowsGame.ts +0 -735
- package/src/games/arrows/ArrowsScene.ts +0 -395
- package/src/games/balloon-blaster/BalloonBlaster.tsx +0 -75
- package/src/games/balloon-blaster/BalloonBlasterConstants.ts +0 -79
- package/src/games/balloon-blaster/BalloonBlasterGame.ts +0 -287
- package/src/games/balloon-blaster/BalloonBlasterPhysics.ts +0 -95
- package/src/games/balloon-blaster/BalloonBlasterScene.ts +0 -225
- package/src/games/bike-racing/BikeMeshes.ts +0 -273
- package/src/games/bike-racing/BikeRacing.tsx +0 -211
- package/src/games/bike-racing/BikeRacingConstants.ts +0 -103
- package/src/games/bike-racing/BikeRacingGame.ts +0 -557
- package/src/games/bike-racing/BikeRacingScene.ts +0 -119
- package/src/games/block-blast/BlockBlast.tsx +0 -73
- package/src/games/block-blast/BlockBlastConstants.ts +0 -179
- package/src/games/block-blast/BlockBlastGame.ts +0 -471
- package/src/games/block-blast/BlockBlastScene.ts +0 -156
- package/src/games/block-breaker/BlockBreaker.tsx +0 -79
- package/src/games/block-breaker/BlockBreakerConstants.ts +0 -139
- package/src/games/block-breaker/BlockBreakerGame.ts +0 -459
- package/src/games/block-breaker/BlockBreakerScene.ts +0 -257
- package/src/games/bluk/Bluk.tsx +0 -82
- package/src/games/bluk/BlukConstants.ts +0 -121
- package/src/games/bluk/BlukGame.ts +0 -323
- package/src/games/bluk/BlukRules.ts +0 -154
- package/src/games/bluk/BlukScene.ts +0 -514
- package/src/games/bubble-shooter/BubbleShooter.tsx +0 -76
- package/src/games/bubble-shooter/BubbleShooterConstants.ts +0 -103
- package/src/games/bubble-shooter/BubbleShooterGame.ts +0 -459
- package/src/games/bubble-shooter/BubbleShooterScene.ts +0 -158
- package/src/games/candy-crush/CandyCrush.tsx +0 -77
- package/src/games/candy-crush/CandyCrushConstants.ts +0 -94
- package/src/games/candy-crush/CandyCrushGame.ts +0 -477
- package/src/games/candy-crush/CandyCrushScene.ts +0 -209
- package/src/games/car-racing/CarMeshes.ts +0 -440
- package/src/games/car-racing/CarRacing.tsx +0 -211
- package/src/games/car-racing/CarRacingConstants.ts +0 -167
- package/src/games/car-racing/CarRacingFacade.ts +0 -40
- package/src/games/car-racing/CarRacingGame.ts +0 -539
- package/src/games/car-racing/CarRacingScene.ts +0 -1026
- package/src/games/car-racing/CarRacingScenery.ts +0 -265
- package/src/games/chameleon-run/ChameleonRun.tsx +0 -96
- package/src/games/chameleon-run/ChameleonRunBackdrop.ts +0 -186
- package/src/games/chameleon-run/ChameleonRunConstants.ts +0 -47
- package/src/games/chameleon-run/ChameleonRunGame.ts +0 -309
- package/src/games/chameleon-run/ChameleonRunMeshes.ts +0 -305
- package/src/games/chameleon-run/ChameleonRunRules.ts +0 -252
- package/src/games/chameleon-run/ChameleonRunScene.ts +0 -310
- package/src/games/checkers/Checkers.tsx +0 -83
- package/src/games/checkers/CheckersAI.ts +0 -255
- package/src/games/checkers/CheckersConstants.ts +0 -68
- package/src/games/checkers/CheckersGame.ts +0 -322
- package/src/games/checkers/CheckersRules.ts +0 -167
- package/src/games/checkers/CheckersScene.ts +0 -308
- package/src/games/color-switch/ColorSwitch.tsx +0 -75
- package/src/games/color-switch/ColorSwitchConstants.ts +0 -61
- package/src/games/color-switch/ColorSwitchGame.ts +0 -329
- package/src/games/color-switch/ColorSwitchScene.ts +0 -220
- package/src/games/colors-sort/ColorsSort.tsx +0 -82
- package/src/games/colors-sort/ColorsSortConstants.ts +0 -119
- package/src/games/colors-sort/ColorsSortGame.ts +0 -246
- package/src/games/colors-sort/ColorsSortScene.ts +0 -315
- package/src/games/connect-em-all/ConnectEmAll.tsx +0 -70
- package/src/games/connect-em-all/ConnectEmAllConstants.ts +0 -77
- package/src/games/connect-em-all/ConnectEmAllGame.ts +0 -401
- package/src/games/connect-em-all/ConnectEmAllScene.ts +0 -235
- package/src/games/crossy-road/CrossyRoad.tsx +0 -74
- package/src/games/crossy-road/CrossyRoadCamera.ts +0 -59
- package/src/games/crossy-road/CrossyRoadConstants.ts +0 -132
- package/src/games/crossy-road/CrossyRoadGame.ts +0 -293
- package/src/games/crossy-road/CrossyRoadMeshes.ts +0 -195
- package/src/games/crossy-road/CrossyRoadPerson.ts +0 -198
- package/src/games/crossy-road/CrossyRoadRules.ts +0 -99
- package/src/games/crossy-road/CrossyRoadScene.ts +0 -355
- package/src/games/dino-jump/DinoJump.tsx +0 -77
- package/src/games/dino-jump/DinoJumpConstants.ts +0 -80
- package/src/games/dino-jump/DinoJumpGame.ts +0 -344
- package/src/games/dino-jump/DinoJumpScene.ts +0 -686
- package/src/games/dots-and-boxes/DotsAndBoxes.tsx +0 -83
- package/src/games/dots-and-boxes/DotsAndBoxesConstants.ts +0 -77
- package/src/games/dots-and-boxes/DotsAndBoxesGame.ts +0 -271
- package/src/games/dots-and-boxes/DotsAndBoxesScene.ts +0 -249
- package/src/games/falling-sticks/FallingSticks.tsx +0 -72
- package/src/games/falling-sticks/FallingSticksConstants.ts +0 -62
- package/src/games/falling-sticks/FallingSticksGame.ts +0 -220
- package/src/games/falling-sticks/FallingSticksRules.ts +0 -145
- package/src/games/falling-sticks/FallingSticksScene.ts +0 -245
- package/src/games/find-different-number/FindDifferentNumber.tsx +0 -74
- package/src/games/find-different-number/FindDifferentNumberConstants.ts +0 -74
- package/src/games/find-different-number/FindDifferentNumberGame.ts +0 -174
- package/src/games/find-different-number/FindDifferentNumberRules.ts +0 -43
- package/src/games/find-different-number/FindDifferentNumberScene.ts +0 -193
- package/src/games/flappy-bird/FlappyBird.tsx +0 -73
- package/src/games/flappy-bird/FlappyBirdConstants.ts +0 -95
- package/src/games/flappy-bird/FlappyBirdGame.ts +0 -375
- package/src/games/flappy-bird/FlappyBirdScene.ts +0 -630
- package/src/games/fruit-merger/FruitMerger.tsx +0 -73
- package/src/games/fruit-merger/FruitMergerConstants.ts +0 -102
- package/src/games/fruit-merger/FruitMergerGame.ts +0 -285
- package/src/games/fruit-merger/FruitMergerRules.ts +0 -286
- package/src/games/fruit-merger/FruitMergerScene.ts +0 -498
- package/src/games/fruit-ninja/FruitNinja.tsx +0 -129
- package/src/games/fruit-ninja/FruitNinjaConstants.ts +0 -107
- package/src/games/fruit-ninja/FruitNinjaGame.ts +0 -391
- package/src/games/fruit-ninja/FruitNinjaScene.ts +0 -319
- package/src/games/fruit-ninja/FruitNinjaWorld.ts +0 -17
- package/src/games/game-2048/Game2048.tsx +0 -84
- package/src/games/game-2048/Game2048Constants.ts +0 -68
- package/src/games/game-2048/Game2048Game.ts +0 -181
- package/src/games/game-2048/Game2048Rules.ts +0 -101
- package/src/games/game-2048/Game2048Scene.ts +0 -206
- package/src/games/knife-hit/KnifeHit.tsx +0 -78
- package/src/games/knife-hit/KnifeHitConstants.ts +0 -89
- package/src/games/knife-hit/KnifeHitGame.ts +0 -264
- package/src/games/knife-hit/KnifeHitScene.ts +0 -360
- package/src/games/ludo-king/LudoKing.tsx +0 -86
- package/src/games/ludo-king/LudoKingConstants.ts +0 -212
- package/src/games/ludo-king/LudoKingGame.ts +0 -326
- package/src/games/ludo-king/LudoKingRules.ts +0 -143
- package/src/games/ludo-king/LudoKingScene.ts +0 -397
- package/src/games/maze-runner/MazeRunner.tsx +0 -88
- package/src/games/maze-runner/MazeRunnerConstants.ts +0 -65
- package/src/games/maze-runner/MazeRunnerGame.ts +0 -176
- package/src/games/maze-runner/MazeRunnerRules.ts +0 -161
- package/src/games/maze-runner/MazeRunnerScene.ts +0 -245
- package/src/games/memory-match/MemoryMatch.tsx +0 -77
- package/src/games/memory-match/MemoryMatchConstants.ts +0 -105
- package/src/games/memory-match/MemoryMatchGame.ts +0 -222
- package/src/games/memory-match/MemoryMatchRules.ts +0 -38
- package/src/games/memory-match/MemoryMatchScene.ts +0 -268
- package/src/games/mine-sweeper/MineSweeper.tsx +0 -77
- package/src/games/mine-sweeper/MineSweeperConstants.ts +0 -94
- package/src/games/mine-sweeper/MineSweeperGame.ts +0 -234
- package/src/games/mine-sweeper/MineSweeperRules.ts +0 -67
- package/src/games/mine-sweeper/MineSweeperScene.ts +0 -262
- package/src/games/mob-control/MobControl.tsx +0 -73
- package/src/games/mob-control/MobControlConstants.ts +0 -106
- package/src/games/mob-control/MobControlGame.ts +0 -176
- package/src/games/mob-control/MobControlMeshes.ts +0 -85
- package/src/games/mob-control/MobControlRenderer.ts +0 -108
- package/src/games/mob-control/MobControlRules.ts +0 -522
- package/src/games/mob-control/MobControlScene.ts +0 -399
- package/src/games/number-search/NumberSearch.tsx +0 -18
- package/src/games/number-search/NumberSearchNumbers.ts +0 -623
- package/src/games/nuts-and-bolts/NutsAndBolts.tsx +0 -85
- package/src/games/nuts-and-bolts/NutsAndBoltsConstants.ts +0 -75
- package/src/games/nuts-and-bolts/NutsAndBoltsGame.ts +0 -298
- package/src/games/nuts-and-bolts/NutsAndBoltsRules.ts +0 -474
- package/src/games/nuts-and-bolts/NutsAndBoltsScene.ts +0 -498
- package/src/games/pac-man/PacMan.tsx +0 -86
- package/src/games/pac-man/PacManConstants.ts +0 -169
- package/src/games/pac-man/PacManGame.ts +0 -406
- package/src/games/pac-man/PacManRules.ts +0 -255
- package/src/games/pac-man/PacManScene.ts +0 -387
- package/src/games/paper-io/PaperIo.tsx +0 -91
- package/src/games/paper-io/PaperIoConstants.ts +0 -86
- package/src/games/paper-io/PaperIoGame.ts +0 -193
- package/src/games/paper-io/PaperIoMeshes.ts +0 -233
- package/src/games/paper-io/PaperIoRules.ts +0 -315
- package/src/games/paper-io/PaperIoScene.ts +0 -310
- package/src/games/penguin-run/PenguinMeshes.ts +0 -269
- package/src/games/penguin-run/PenguinModel.ts +0 -712
- package/src/games/penguin-run/PenguinRun.tsx +0 -77
- package/src/games/penguin-run/PenguinRunConstants.ts +0 -69
- package/src/games/penguin-run/PenguinRunGame.ts +0 -406
- package/src/games/penguin-run/PenguinRunScene.ts +0 -949
- package/src/games/perfect-circle/PerfectCircle.tsx +0 -74
- package/src/games/perfect-circle/PerfectCircleConstants.ts +0 -52
- package/src/games/perfect-circle/PerfectCircleGame.ts +0 -153
- package/src/games/perfect-circle/PerfectCircleRules.ts +0 -111
- package/src/games/perfect-circle/PerfectCircleScene.ts +0 -176
- package/src/games/pipe-connect/PipeConnect.tsx +0 -69
- package/src/games/pipe-connect/PipeConnectConstants.ts +0 -101
- package/src/games/pipe-connect/PipeConnectGame.ts +0 -179
- package/src/games/pipe-connect/PipeConnectRules.ts +0 -326
- package/src/games/pipe-connect/PipeConnectScene.ts +0 -271
- package/src/games/play-with-tua/PlayWithTua.tsx +0 -123
- package/src/games/play-with-tua/PlayWithTuaConstants.ts +0 -70
- package/src/games/play-with-tua/PlayWithTuaGame.ts +0 -167
- package/src/games/play-with-tua/PlayWithTuaModel.ts +0 -42
- package/src/games/play-with-tua/PlayWithTuaScene.ts +0 -36
- package/src/games/popit-fidget/PopitFidget.tsx +0 -72
- package/src/games/popit-fidget/PopitFidgetConstants.ts +0 -71
- package/src/games/popit-fidget/PopitFidgetGame.ts +0 -148
- package/src/games/popit-fidget/PopitFidgetScene.ts +0 -242
- package/src/games/reversi/Reversi.tsx +0 -94
- package/src/games/reversi/ReversiConstants.ts +0 -67
- package/src/games/reversi/ReversiGame.ts +0 -266
- package/src/games/reversi/ReversiRules.ts +0 -176
- package/src/games/reversi/ReversiScene.ts +0 -240
- package/src/games/search-grid/SearchGrid.tsx +0 -92
- package/src/games/search-grid/SearchGridConstants.ts +0 -178
- package/src/games/search-grid/SearchGridGame.ts +0 -209
- package/src/games/search-grid/SearchGridScene.ts +0 -301
- package/src/games/shared/BackdropCard.tsx +0 -54
- package/src/games/shared/EngineBackdrop.ts +0 -300
- package/src/games/shared/EngineBlasts.ts +0 -136
- package/src/games/shared/EngineBlocks.ts +0 -91
- package/src/games/shared/EngineControlText.ts +0 -17
- package/src/games/shared/EngineDice.ts +0 -250
- package/src/games/shared/EngineFootprint.ts +0 -35
- package/src/games/shared/EngineFruits.ts +0 -1435
- package/src/games/shared/EngineGameLoader.tsx +0 -88
- package/src/games/shared/EngineGameScreen.tsx +0 -325
- package/src/games/shared/EngineGameWidth.ts +0 -3
- package/src/games/shared/EngineGameWidth.web.ts +0 -3
- package/src/games/shared/EngineGlyphs.ts +0 -178
- package/src/games/shared/EngineHud.ts +0 -815
- package/src/games/shared/EngineLoading.ts +0 -477
- package/src/games/shared/EngineMeadow.ts +0 -725
- package/src/games/shared/EngineMeshCache.ts +0 -15
- package/src/games/shared/EngineMeshes.ts +0 -10
- package/src/games/shared/EngineRacingChase.ts +0 -21
- package/src/games/shared/EngineRacingHandling.ts +0 -48
- package/src/games/shared/EngineReadyContext.ts +0 -4
- package/src/games/shared/EngineTilt.ts +0 -44
- package/src/games/shared/EngineTouchSurface.tsx +0 -103
- package/src/games/shared/EngineUtils.ts +0 -52
- package/src/games/shared/GameActivity.ts +0 -13
- package/src/games/shared/GameLoading.tsx +0 -202
- package/src/games/shared/GameLoadingTransition.tsx +0 -61
- package/src/games/shared/ProceduralCacheVersion.ts +0 -2
- package/src/games/shared/useEngineGame.ts +0 -240
- package/src/games/shared/useGameResource.ts +0 -21
- package/src/games/shared/useLiveState.ts +0 -58
- package/src/games/sliding-numbers/SlidingNumbers.tsx +0 -71
- package/src/games/sliding-numbers/SlidingNumbersConstants.ts +0 -65
- package/src/games/sliding-numbers/SlidingNumbersGame.ts +0 -192
- package/src/games/sliding-numbers/SlidingNumbersRules.ts +0 -79
- package/src/games/sliding-numbers/SlidingNumbersScene.ts +0 -193
- package/src/games/snake-3d/Snake3D.tsx +0 -76
- package/src/games/snake-3d/Snake3DConstants.ts +0 -61
- package/src/games/snake-3d/Snake3DGame.ts +0 -192
- package/src/games/snake-3d/Snake3DMotion.ts +0 -22
- package/src/games/snake-3d/Snake3DRules.ts +0 -116
- package/src/games/snake-3d/Snake3DScene.ts +0 -322
- package/src/games/snakes-and-ladders/SnakesAndLadders.tsx +0 -87
- package/src/games/snakes-and-ladders/SnakesAndLaddersConstants.ts +0 -136
- package/src/games/snakes-and-ladders/SnakesAndLaddersGame.ts +0 -310
- package/src/games/snakes-and-ladders/SnakesAndLaddersScene.ts +0 -515
- package/src/games/space-fighter/SpaceFighter.tsx +0 -74
- package/src/games/space-fighter/SpaceFighterConstants.ts +0 -86
- package/src/games/space-fighter/SpaceFighterGame.ts +0 -292
- package/src/games/space-fighter/SpaceFighterScene.ts +0 -550
- package/src/games/spider-solitaire/SpiderSolitaire.tsx +0 -80
- package/src/games/spider-solitaire/SpiderSolitaireConstants.ts +0 -107
- package/src/games/spider-solitaire/SpiderSolitaireGame.ts +0 -387
- package/src/games/spider-solitaire/SpiderSolitaireRules.ts +0 -123
- package/src/games/spider-solitaire/SpiderSolitaireScene.ts +0 -352
- package/src/games/stack-tower/StackTower.tsx +0 -76
- package/src/games/stack-tower/StackTowerConstants.ts +0 -74
- package/src/games/stack-tower/StackTowerGame.ts +0 -236
- package/src/games/stack-tower/StackTowerScene.ts +0 -186
- package/src/games/sudoku/Sudoku.tsx +0 -73
- package/src/games/sudoku/SudokuConstants.ts +0 -127
- package/src/games/sudoku/SudokuGame.ts +0 -250
- package/src/games/sudoku/SudokuRules.ts +0 -125
- package/src/games/sudoku/SudokuScene.ts +0 -304
- package/src/games/tangram/Tangram.tsx +0 -79
- package/src/games/tangram/TangramConstants.ts +0 -64
- package/src/games/tangram/TangramGame.ts +0 -356
- package/src/games/tangram/TangramRules.ts +0 -409
- package/src/games/tangram/TangramScene.ts +0 -203
- package/src/games/tank-1990/Tank1990.tsx +0 -78
- package/src/games/tank-1990/Tank1990Constants.ts +0 -81
- package/src/games/tank-1990/Tank1990Game.ts +0 -331
- package/src/games/tank-1990/Tank1990Rules.ts +0 -390
- package/src/games/tank-1990/Tank1990Scene.ts +0 -434
- package/src/games/tic-tac-toe/TicTacToe.tsx +0 -98
- package/src/games/tic-tac-toe/TicTacToeConstants.ts +0 -69
- package/src/games/tic-tac-toe/TicTacToeGame.ts +0 -200
- package/src/games/tic-tac-toe/TicTacToeRules.ts +0 -103
- package/src/games/tic-tac-toe/TicTacToeScene.ts +0 -245
- package/src/games/tile-home/TileHome.tsx +0 -92
- package/src/games/tile-home/TileHomeConstants.ts +0 -139
- package/src/games/tile-home/TileHomeGame.ts +0 -435
- package/src/games/tile-home/TileHomeScene.ts +0 -154
- package/src/games/treasure-hunt/TreasureHunt.tsx +0 -206
- package/src/games/treasure-hunt/TreasureHuntConstants.ts +0 -266
- package/src/games/treasure-hunt/TreasureHuntControls.ts +0 -280
- package/src/games/treasure-hunt/TreasureHuntGame.ts +0 -402
- package/src/games/treasure-hunt/TreasureHuntMeshes.ts +0 -422
- package/src/games/treasure-hunt/TreasureHuntModel.ts +0 -506
- package/src/games/treasure-hunt/TreasureHuntRules.ts +0 -1210
- package/src/games/treasure-hunt/TreasureHuntScene.ts +0 -586
- package/src/games/whack-a-mole/WhackAMole.tsx +0 -79
- package/src/games/whack-a-mole/WhackAMoleConstants.ts +0 -94
- package/src/games/whack-a-mole/WhackAMoleGame.ts +0 -233
- package/src/games/whack-a-mole/WhackAMoleScene.ts +0 -349
- package/src/games/word-search/WordSearch.tsx +0 -18
- package/src/games/word-search/WordSearchWords.ts +0 -1642
- package/src/helpers/GamePatternData.ts +0 -120
- package/src/helpers/GameSettingsModal.tsx +0 -384
- package/src/helpers/GameTheme.tsx +0 -37
- package/src/helpers/IconPaths.ts +0 -6
- package/src/helpers/index.ts +0 -2
- package/src/index.tsx +0 -60
- package/src/services/GameAssetLoader.ts +0 -111
- package/src/services/GameAssets.ts +0 -149
- package/src/services/GameLoaders.ts +0 -93
- package/src/services/GamesConstants.ts +0 -193
- package/src/services/GamesMetadata.ts +0 -711
- package/src/services/GamesService.ts +0 -116
- package/src/services/HapticsService.ts +0 -48
- package/src/services/ScoringService.ts +0 -19
- package/src/services/SfxSources.ts +0 -81
- package/src/services/SoundsService.ts +0 -582
- package/src/services/ThemeService.ts +0 -281
- package/src/services/UtilsService.ts +0 -134
- package/src/services/index.ts +0 -6
|
@@ -1,1026 +0,0 @@
|
|
|
1
|
-
// Everything Car Racing draws: the track (where a distance along the road and an offset across it are
|
|
2
|
-
// in the world), the cars, the road with its roadside and horizon, and fire.
|
|
3
|
-
import {
|
|
4
|
-
block,
|
|
5
|
-
type Camera,
|
|
6
|
-
type Color,
|
|
7
|
-
type Entity,
|
|
8
|
-
type Font,
|
|
9
|
-
merge,
|
|
10
|
-
type Model,
|
|
11
|
-
type Quat,
|
|
12
|
-
type Texture,
|
|
13
|
-
tube,
|
|
14
|
-
type Vec3,
|
|
15
|
-
type World
|
|
16
|
-
} from '@nayan-ui/engine';
|
|
17
|
-
|
|
18
|
-
type GeometryPart = Parameters<typeof merge>[0][number];
|
|
19
|
-
import { cacheGameAsset, createGameMesh as createShape } from '../shared/EngineMeshes';
|
|
20
|
-
import { CAR_LAMPS } from './CarMeshes';
|
|
21
|
-
import { type Assets, BEHIND, LAMP, LAMP_LIT, LANE_W, LINE, RAIL, ROAD_HALF, RS, SEG_LEN, SEGMENTS } from './CarRacingConstants';
|
|
22
|
-
import { sceneryMeshes } from './CarRacingScenery';
|
|
23
|
-
|
|
24
|
-
export const rand = (min: number, max: number) => min + Math.random() * (max - min);
|
|
25
|
-
export const pick = <T>(items: readonly T[]) => items[Math.floor(Math.random() * items.length)]!;
|
|
26
|
-
export const clamp = (v: number, lo: number, hi: number) => Math.max(lo, Math.min(hi, v));
|
|
27
|
-
|
|
28
|
-
// ── Track ─────────────────────────────────────────────────────────────
|
|
29
|
-
|
|
30
|
-
/** A straight start, then sweeping bends and rolling hills. */
|
|
31
|
-
const fadeIn = (s: number) => Math.min(1, Math.max(0, (s - 60) / 200));
|
|
32
|
-
const curvature = (s: number) => (0.0052 * Math.sin(s / 95) + 0.0034 * Math.sin(s / 41 + 1.3)) * fadeIn(s);
|
|
33
|
-
const elevation = (s: number) => (7 * Math.sin(s / 150) + 2.5 * Math.sin(s / 57 + 0.7)) * fadeIn(s);
|
|
34
|
-
|
|
35
|
-
export type Sample = { x: number; y: number; z: number; heading: number; pitch: number };
|
|
36
|
-
export const newSample = (): Sample => ({ x: 0, y: 0, z: 0, heading: 0, pitch: 0 });
|
|
37
|
-
|
|
38
|
-
/** The centre line, integrated a metre at a time as the player drives. */
|
|
39
|
-
export class Track {
|
|
40
|
-
private xs = [0];
|
|
41
|
-
private zs = [0];
|
|
42
|
-
private hs = [0];
|
|
43
|
-
|
|
44
|
-
private ensure(s: number) {
|
|
45
|
-
for (let i = this.xs.length; i <= s + 1; i++) {
|
|
46
|
-
const h = this.hs[i - 1]! + curvature(i);
|
|
47
|
-
this.hs.push(h);
|
|
48
|
-
this.xs.push(this.xs[i - 1]! + Math.sin(h));
|
|
49
|
-
this.zs.push(this.zs[i - 1]! - Math.cos(h));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
sample(s: number, out: Sample): Sample {
|
|
54
|
-
if (s < 0) {
|
|
55
|
-
// Behind the start line the road runs straight back (the start-screen camera sees it).
|
|
56
|
-
out.x = 0;
|
|
57
|
-
out.y = 0;
|
|
58
|
-
out.z = -s;
|
|
59
|
-
out.heading = 0;
|
|
60
|
-
out.pitch = 0;
|
|
61
|
-
return out;
|
|
62
|
-
}
|
|
63
|
-
const t = s;
|
|
64
|
-
this.ensure(t);
|
|
65
|
-
const i = Math.floor(t);
|
|
66
|
-
const f = t - i;
|
|
67
|
-
out.x = this.xs[i]! + (this.xs[i + 1]! - this.xs[i]!) * f;
|
|
68
|
-
out.z = this.zs[i]! + (this.zs[i + 1]! - this.zs[i]!) * f;
|
|
69
|
-
out.heading = this.hs[i]! + (this.hs[i + 1]! - this.hs[i]!) * f;
|
|
70
|
-
out.y = elevation(t);
|
|
71
|
-
out.pitch = Math.atan(elevation(t + 0.5) - elevation(t - 0.5));
|
|
72
|
-
return out;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Heading 0 drives toward -z with +x on the right; a positive heading bends right.
|
|
77
|
-
export const forwardOf = (h: number): Vec3 => [Math.sin(h), 0, -Math.cos(h)];
|
|
78
|
-
export const rightOf = (h: number): Vec3 => [Math.cos(h), 0, Math.sin(h)];
|
|
79
|
-
|
|
80
|
-
/** The world point at a track sample, `d` to the right and `h` above the road. */
|
|
81
|
-
export function placeAt(t: Sample, d: number, h: number, out: [number, number, number]) {
|
|
82
|
-
out[0] = t.x + Math.cos(t.heading) * d;
|
|
83
|
-
out[1] = t.y + h;
|
|
84
|
-
out[2] = t.z + Math.sin(t.heading) * d;
|
|
85
|
-
return out;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/** Facing along `heading` (turned `yaw` further right), nose up by `pitch`, rolled left by `roll`. */
|
|
89
|
-
export function orient(heading: number, pitch: number, yaw = 0, roll = 0, out: [number, number, number, number] = [0, 0, 0, 1]): Quat {
|
|
90
|
-
const a = -(heading + yaw) / 2;
|
|
91
|
-
const sy = Math.sin(a),
|
|
92
|
-
cy = Math.cos(a),
|
|
93
|
-
sx = Math.sin(pitch / 2),
|
|
94
|
-
cx = Math.cos(pitch / 2);
|
|
95
|
-
const sz = Math.sin(roll / 2),
|
|
96
|
-
cz = Math.cos(roll / 2);
|
|
97
|
-
const x = cy * sx,
|
|
98
|
-
y = sy * cx,
|
|
99
|
-
z = -sy * sx,
|
|
100
|
-
w = cy * cx;
|
|
101
|
-
out[0] = x * cz + y * sz;
|
|
102
|
-
out[1] = -x * sz + y * cz;
|
|
103
|
-
out[2] = w * sz + z * cz;
|
|
104
|
-
out[3] = w * cz - z * sz;
|
|
105
|
-
return out;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// ── Cars ──────────────────────────────────────────────────────────────
|
|
109
|
-
|
|
110
|
-
/** A car: an invisible root at its middle (the collider's centre once wrecked) with body, glass and trim attached. */
|
|
111
|
-
export function spawnCar(world: World, a: Assets, paint: Color, position: Vec3, night: boolean) {
|
|
112
|
-
const model = a.car;
|
|
113
|
-
const root = world.spawn({ mesh: 'none', position });
|
|
114
|
-
const lift = -model.size[1] / 2;
|
|
115
|
-
const offset: Vec3 = [0, lift, 0];
|
|
116
|
-
const body = world.spawn({ mesh: model.body, parent: root, position: offset, color: paint });
|
|
117
|
-
const glass = world.spawn({ mesh: model.glass, parent: root, position: offset });
|
|
118
|
-
const trim = world.spawn({ mesh: model.trim, parent: root, position: offset });
|
|
119
|
-
const car = { root, body, glass, trim, lights: [] as Entity[] };
|
|
120
|
-
setCarNight(world, car, night, model.size[1]);
|
|
121
|
-
return car;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/** Toggle lamp meshes in place so switching theme preserves every car's pose and physics. */
|
|
125
|
-
export function setCarNight(world: World, car: { root: Entity; lights: Entity[] }, night: boolean, height: number) {
|
|
126
|
-
for (const entity of car.lights) world.despawn(entity);
|
|
127
|
-
car.lights.length = 0;
|
|
128
|
-
if (!night || !world.has(car.root)) return;
|
|
129
|
-
const lift = -height / 2;
|
|
130
|
-
for (const [x, y, z] of CAR_LAMPS.headlights)
|
|
131
|
-
car.lights.push(
|
|
132
|
-
world.spawn({
|
|
133
|
-
mesh: 'cube',
|
|
134
|
-
parent: car.root,
|
|
135
|
-
position: [x, lift + y, z],
|
|
136
|
-
scale: CAR_LAMPS.headlightSize,
|
|
137
|
-
color: [2, 1.95, 1.7],
|
|
138
|
-
pickable: false
|
|
139
|
-
})
|
|
140
|
-
);
|
|
141
|
-
const [x, y, z] = CAR_LAMPS.tail;
|
|
142
|
-
car.lights.push(
|
|
143
|
-
world.spawn({
|
|
144
|
-
mesh: 'cube',
|
|
145
|
-
parent: car.root,
|
|
146
|
-
position: [x, lift + y, z],
|
|
147
|
-
scale: CAR_LAMPS.tailSize,
|
|
148
|
-
color: [2, 0.16, 0.1],
|
|
149
|
-
pickable: false
|
|
150
|
-
})
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// ── Road and scenery ──────────────────────────────────────────────────
|
|
155
|
-
|
|
156
|
-
// Segments that leapfrog ahead, the roadside for each zone, and the mountains on the horizon.
|
|
157
|
-
|
|
158
|
-
/** A stretch of road; `props` is its scenery, rebuilt for the zone it lands in each time it jumps ahead. */
|
|
159
|
-
export type Segment = {
|
|
160
|
-
root: Entity;
|
|
161
|
-
s: number;
|
|
162
|
-
props: Entity[];
|
|
163
|
-
lights: { entity: Entity; day: Color; night: Color }[];
|
|
164
|
-
};
|
|
165
|
-
/** What the scenery needs from the game. */
|
|
166
|
-
export type SceneryContext = { world: World; assets: Assets; night: boolean; track: Track };
|
|
167
|
-
|
|
168
|
-
const segmentSample = newSample();
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Road segments: a root carrying the ground collider, with asphalt, curbs, markings, rails and
|
|
172
|
-
* scenery attached. Segments that fall behind jump ahead with everything on them.
|
|
173
|
-
*/
|
|
174
|
-
export function buildRoad(world: World, a: Assets): Segment[] {
|
|
175
|
-
const segments: Segment[] = [];
|
|
176
|
-
for (let i = 0; i < SEGMENTS; i++) {
|
|
177
|
-
const root = world.spawn({
|
|
178
|
-
mesh: 'none',
|
|
179
|
-
physics: { type: 'fixed', size: [90, 0.4, SEG_LEN + 0.4], layer: 4, mask: 0, friction: 0.7 }
|
|
180
|
-
});
|
|
181
|
-
const add = (mesh: 'cube' | 'cylinder' | Model, position: Vec3, scale: Vec3 | number, color: Color, texture?: Texture) =>
|
|
182
|
-
world.spawn({ mesh, parent: root, position, scale, color, texture, pickable: false });
|
|
183
|
-
const lift = (i % 2) * 0.004; // overlapping neighbours never z-fight
|
|
184
|
-
const len = SEG_LEN + 0.35;
|
|
185
|
-
add('cube', [0, RS - 0.05 + lift, 0], [ROAD_HALF * 2 + 0.6, 0.1, len], [1, 1, 1], a.asphalt);
|
|
186
|
-
for (const side of [-1, 1]) {
|
|
187
|
-
// Wide verge strips need extra overlap where the track bends, so distant ground has no gaps.
|
|
188
|
-
add(
|
|
189
|
-
a.scenery.grassGround,
|
|
190
|
-
[side * (ROAD_HALF + 31), RS - 0.04 + lift, 0],
|
|
191
|
-
[62, 1, SEG_LEN + 4],
|
|
192
|
-
i % 2 ? [1, 1, 1] : [0.94, 0.97, 0.92],
|
|
193
|
-
a.grass
|
|
194
|
-
);
|
|
195
|
-
for (const z of [-SEG_LEN / 4, SEG_LEN / 4]) {
|
|
196
|
-
const red = (i * 2 + (z > 0 ? 1 : 0)) % 2 === 0;
|
|
197
|
-
add('cube', [side * (ROAD_HALF + 0.2), RS + 0.01 + lift, z], [0.5, 0.08, SEG_LEN / 2], red ? [0.85, 0.12, 0.1] : [0.95, 0.95, 0.95]);
|
|
198
|
-
}
|
|
199
|
-
add('cube', [side * (ROAD_HALF - 0.12), RS + 0.004 + lift, 0], [0.14, 0.02, len], LINE);
|
|
200
|
-
add('cube', [side * (LANE_W / 2), RS + 0.004 + lift, 0], [0.14, 0.02, 2.6], LINE);
|
|
201
|
-
add('cube', [side * (ROAD_HALF + 1.1), RS + 0.55, 0], [0.1, 0.26, len], RAIL);
|
|
202
|
-
add('cube', [side * (ROAD_HALF + 1.15), RS + 0.3, 0], [0.12, 0.6, 0.12], [0.45, 0.46, 0.5]);
|
|
203
|
-
}
|
|
204
|
-
segments.push({ root, s: (i - BEHIND) * SEG_LEN, props: [], lights: [] });
|
|
205
|
-
}
|
|
206
|
-
return segments;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/** Mountains and rolling hills all around (and, at night, a moon and stars), on a root that rides along with the player so they never get closer. */
|
|
210
|
-
export function buildHorizon(world: World, night: boolean): Entity {
|
|
211
|
-
const horizon = world.spawn({ mesh: 'none' });
|
|
212
|
-
for (let i = 0; i < 26; i++) {
|
|
213
|
-
const angle = (i / 26) * Math.PI * 2 + rand(-0.08, 0.08);
|
|
214
|
-
const r = rand(150, 210);
|
|
215
|
-
const size = rand(40, 75);
|
|
216
|
-
world.spawn({
|
|
217
|
-
mesh: 'sphere',
|
|
218
|
-
parent: horizon,
|
|
219
|
-
position: [Math.sin(angle) * r, -size * 0.32, -Math.cos(angle) * r],
|
|
220
|
-
scale: [size * 1.6, size * 0.9, size * 1.6],
|
|
221
|
-
color: [0.3 + rand(0, 0.06), 0.52 + rand(0, 0.08), 0.24],
|
|
222
|
-
pickable: false
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
for (let i = 0; i < 18; i++) {
|
|
226
|
-
const angle = (i / 18) * Math.PI * 2 + rand(-0.1, 0.1);
|
|
227
|
-
const size = rand(45, 80);
|
|
228
|
-
world.spawn({
|
|
229
|
-
mesh: 'cone',
|
|
230
|
-
parent: horizon,
|
|
231
|
-
position: [Math.sin(angle) * 330, size * 0.35 - 10, -Math.cos(angle) * 330],
|
|
232
|
-
scale: [size * 1.7, size, size * 1.7],
|
|
233
|
-
color: [0.45 + rand(0, 0.08), 0.55 + rand(0, 0.06), 0.68],
|
|
234
|
-
pickable: false
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
setHorizonNight(world, horizon, night);
|
|
239
|
-
return horizon;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
const nightSkies = new WeakMap<World, Map<Entity, Entity[]>>();
|
|
243
|
-
export function setHorizonNight(world: World, horizon: Entity, night: boolean) {
|
|
244
|
-
let skies = nightSkies.get(world);
|
|
245
|
-
if (!skies) {
|
|
246
|
-
skies = new Map();
|
|
247
|
-
nightSkies.set(world, skies);
|
|
248
|
-
}
|
|
249
|
-
const lights = skies.get(horizon) ?? [];
|
|
250
|
-
for (const entity of lights) world.despawn(entity);
|
|
251
|
-
lights.length = 0;
|
|
252
|
-
// Low-contrast cloud banks sit behind the existing skyline and mountains.
|
|
253
|
-
for (let i = 0; i < 5; i++) {
|
|
254
|
-
const angle = i * 1.256 + 0.7;
|
|
255
|
-
lights.push(
|
|
256
|
-
world.spawn({
|
|
257
|
-
mesh: sceneryMeshes().cloud,
|
|
258
|
-
parent: horizon,
|
|
259
|
-
position: [Math.sin(angle) * 160, 35 + (i % 3) * 8, -Math.cos(angle) * 160],
|
|
260
|
-
scale: [1.4 + (i % 2) * 0.5, 1, 1.1],
|
|
261
|
-
color: night ? [0.55, 0.58, 0.68] : [1.4, 1.43, 1.45],
|
|
262
|
-
pickable: false
|
|
263
|
-
})
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
if (night) {
|
|
267
|
-
// A moon and stars, riding along with the horizon.
|
|
268
|
-
lights.push(
|
|
269
|
-
world.spawn({
|
|
270
|
-
mesh: 'sphere',
|
|
271
|
-
parent: horizon,
|
|
272
|
-
position: [-120, 120, -230],
|
|
273
|
-
scale: 26,
|
|
274
|
-
color: [2, 1.95, 1.8],
|
|
275
|
-
pickable: false
|
|
276
|
-
})
|
|
277
|
-
);
|
|
278
|
-
for (let i = 0; i < 70; i++) {
|
|
279
|
-
const angle = rand(0, Math.PI * 2);
|
|
280
|
-
lights.push(
|
|
281
|
-
world.spawn({
|
|
282
|
-
mesh: 'sphere',
|
|
283
|
-
parent: horizon,
|
|
284
|
-
position: [Math.sin(angle) * 280, rand(50, 190), -Math.cos(angle) * 280],
|
|
285
|
-
scale: rand(0.6, 1.4),
|
|
286
|
-
color: [2, 2, 2.2],
|
|
287
|
-
pickable: false
|
|
288
|
-
})
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
skies.set(horizon, lights);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/** Puts a segment where its distance along the track is. */
|
|
296
|
-
export function placeSegment(g: SceneryContext, seg: Segment) {
|
|
297
|
-
const t = g.track.sample(seg.s, segmentSample);
|
|
298
|
-
g.world.set(seg.root, { position: [t.x, t.y - RS, t.z], rotation: orient(t.heading, t.pitch) });
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
type Zone = 'city' | 'suburb' | 'country';
|
|
302
|
-
/** Every 600 m the roadside changes. */
|
|
303
|
-
const zoneAt = (s: number): Zone => (['city', 'suburb', 'country'] as const)[Math.floor(Math.max(0, s + 300) / 600) % 3]!;
|
|
304
|
-
|
|
305
|
-
const HOUSE_WALLS: Color[] = [
|
|
306
|
-
[0.95, 0.9, 0.78],
|
|
307
|
-
[0.86, 0.9, 0.95],
|
|
308
|
-
[0.95, 0.82, 0.75],
|
|
309
|
-
[0.9, 0.93, 0.82]
|
|
310
|
-
];
|
|
311
|
-
const ROOFS: Color[] = [
|
|
312
|
-
[0.62, 0.2, 0.15],
|
|
313
|
-
[0.35, 0.25, 0.2],
|
|
314
|
-
[0.3, 0.32, 0.38]
|
|
315
|
-
];
|
|
316
|
-
|
|
317
|
-
/** Fills a segment's roadside for its zone. Positions are in the segment's frame: x across, z along, y up. */
|
|
318
|
-
export function spawnProps(g: SceneryContext, seg: Segment) {
|
|
319
|
-
const { world, assets: a } = g;
|
|
320
|
-
const add = (options: Parameters<World['spawn']>[0] & {}) => {
|
|
321
|
-
const entity = world.spawn({ parent: seg.root, pickable: false, ...options });
|
|
322
|
-
seg.props.push(entity);
|
|
323
|
-
return entity;
|
|
324
|
-
};
|
|
325
|
-
const addLight = (options: Parameters<World['spawn']>[0], day: Color, night: Color) => {
|
|
326
|
-
const entity = add({ ...options, color: g.night ? night : day });
|
|
327
|
-
seg.lights.push({ entity, day, night });
|
|
328
|
-
};
|
|
329
|
-
const index = Math.round(seg.s / SEG_LEN);
|
|
330
|
-
const zone = zoneAt(seg.s);
|
|
331
|
-
const z = () => rand(-SEG_LEN / 2, SEG_LEN / 2);
|
|
332
|
-
const detailIndex = Math.abs(index);
|
|
333
|
-
const detail = a.scenery;
|
|
334
|
-
const decorateTower = (x: number, zz: number, w: number, h: number, depth: number, style: number) => {
|
|
335
|
-
// Keep the original textured tower and silhouette; these are thin architectural layers.
|
|
336
|
-
add({ mesh: detail.podium, position: [x, RS, zz], scale: [w, 1, depth] });
|
|
337
|
-
add({ mesh: detail.roofs[style % 2], position: [x, RS + h, zz], scale: [w, 1, depth] });
|
|
338
|
-
add({ mesh: detail.facades[style % 3], position: [x, RS + h / 2, zz], scale: [w, h, depth] });
|
|
339
|
-
addLight({ mesh: detail.windows, position: [x, RS + h / 2, zz], scale: [w, h, depth] }, [1, 1, 1, 0], [1, 1, 1]);
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
for (const side of [-1, 1]) {
|
|
343
|
-
// Bushes along the rail, everywhere.
|
|
344
|
-
if (Math.random() < 0.55) {
|
|
345
|
-
add({
|
|
346
|
-
mesh: 'sphere',
|
|
347
|
-
position: [side * (ROAD_HALF + rand(2.2, 3.4)), RS + 0.25, z()],
|
|
348
|
-
scale: [rand(1, 1.8), rand(0.7, 1.1), rand(1, 1.8)],
|
|
349
|
-
color: [0.18 + rand(0, 0.08), 0.4 + rand(0, 0.12), 0.14]
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
if (zone === 'city') {
|
|
353
|
-
add({
|
|
354
|
-
mesh: detail.pavement,
|
|
355
|
-
position: [side * (ROAD_HALF + 3.2), RS + 0.05, 0]
|
|
356
|
-
}); // sidewalk
|
|
357
|
-
if ((index + (side > 0 ? 1 : 0)) % 2 === 0) {
|
|
358
|
-
const h = rand(14, 42);
|
|
359
|
-
const tone = rand(0.72, 1);
|
|
360
|
-
const x = side * (ROAD_HALF + rand(10, 15)),
|
|
361
|
-
zz = rand(-1, 1);
|
|
362
|
-
const width = rand(8, 12),
|
|
363
|
-
depth = rand(8, 11);
|
|
364
|
-
add({
|
|
365
|
-
mesh: 'cube',
|
|
366
|
-
texture: a.facade,
|
|
367
|
-
position: [x, RS + h / 2, zz],
|
|
368
|
-
scale: [width, h, depth],
|
|
369
|
-
color: [tone, tone * rand(0.92, 1), tone * rand(0.86, 1)]
|
|
370
|
-
});
|
|
371
|
-
decorateTower(x, zz, width, h, depth, detailIndex + (side > 0 ? 1 : 0));
|
|
372
|
-
if (Math.random() < 0.5) {
|
|
373
|
-
const h2 = rand(20, 55);
|
|
374
|
-
add({
|
|
375
|
-
mesh: 'cube',
|
|
376
|
-
texture: a.facade,
|
|
377
|
-
position: [side * (ROAD_HALF + rand(24, 32)), RS + h2 / 2, rand(-2, 2)],
|
|
378
|
-
scale: [rand(9, 14), h2, rand(9, 12)],
|
|
379
|
-
color: [0.8, 0.82, 0.88]
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
const rhythm = detailIndex + (side > 0 ? 2 : 0);
|
|
384
|
-
const streetX = side * (ROAD_HALF + 3.2);
|
|
385
|
-
if (rhythm % 5 === 1) {
|
|
386
|
-
add({ mesh: detail.planter, position: [streetX, RS + 0.1, 0] });
|
|
387
|
-
add({
|
|
388
|
-
mesh: 'cylinder',
|
|
389
|
-
position: [streetX, RS + 1.7, 0],
|
|
390
|
-
scale: [0.28, 2.7, 0.28],
|
|
391
|
-
color: [0.35, 0.26, 0.16]
|
|
392
|
-
});
|
|
393
|
-
add({
|
|
394
|
-
mesh: 'sphere',
|
|
395
|
-
position: [streetX, RS + 3.6, 0],
|
|
396
|
-
scale: [2.1, 2.7, 2.0],
|
|
397
|
-
color: [0.23, 0.41, 0.19]
|
|
398
|
-
});
|
|
399
|
-
add({
|
|
400
|
-
mesh: 'sphere',
|
|
401
|
-
position: [streetX + side * 0.45, RS + 3.2, 0.35],
|
|
402
|
-
scale: [1.5, 1.8, 1.5],
|
|
403
|
-
color: [0.27, 0.44, 0.2]
|
|
404
|
-
});
|
|
405
|
-
} else if (rhythm % 5 === 3) {
|
|
406
|
-
add({ mesh: detail.planter, position: [streetX, RS + 0.1, 0] });
|
|
407
|
-
add({ mesh: detail.flowers, position: [streetX, RS + 0.67, 0], scale: [1.3, 1.2, 1.3] });
|
|
408
|
-
}
|
|
409
|
-
if (rhythm % 9 === 4) {
|
|
410
|
-
add({
|
|
411
|
-
mesh: detail.bench,
|
|
412
|
-
position: [streetX, RS + 0.12, 0],
|
|
413
|
-
rotation: [0, Math.sin((side * Math.PI) / 4), 0, Math.cos((side * Math.PI) / 4)]
|
|
414
|
-
});
|
|
415
|
-
add({ mesh: detail.bin, position: [streetX, RS + 0.12, 1.8] });
|
|
416
|
-
}
|
|
417
|
-
if (rhythm % 19 === 8) add({ mesh: detail.shelter, position: [streetX, RS + 0.12, 0] });
|
|
418
|
-
} else if (zone === 'suburb') {
|
|
419
|
-
if ((index + (side > 0 ? 1 : 0)) % 3 === 0) {
|
|
420
|
-
// A house: walls, a door, two windows, a gable roof (a cube turned 45° under a flattened group), a fence.
|
|
421
|
-
const x = side * (ROAD_HALF + rand(10, 14));
|
|
422
|
-
const wall = pick(HOUSE_WALLS);
|
|
423
|
-
const face = x - side * 2.52; // the wall facing the road
|
|
424
|
-
add({ mesh: 'cube', position: [x, RS + 1.6, 0], scale: [5, 3.2, 5.6], color: wall });
|
|
425
|
-
add({ mesh: detail.house, position: [x, RS, 0] });
|
|
426
|
-
add({
|
|
427
|
-
mesh: detail.flowers,
|
|
428
|
-
position: [face - side * 0.45, RS, -1.0],
|
|
429
|
-
scale: [0.8, 1, 1.4]
|
|
430
|
-
});
|
|
431
|
-
add({
|
|
432
|
-
mesh: 'cube',
|
|
433
|
-
position: [side * (ROAD_HALF + 7.3), RS - 0.005, 0.9],
|
|
434
|
-
scale: [4.5, 0.035, 1.8],
|
|
435
|
-
color: [0.48, 0.49, 0.46]
|
|
436
|
-
});
|
|
437
|
-
add({
|
|
438
|
-
mesh: 'cube',
|
|
439
|
-
position: [face, RS + 0.95, 0.9],
|
|
440
|
-
scale: [0.06, 1.9, 0.9],
|
|
441
|
-
color: [0.35, 0.22, 0.14]
|
|
442
|
-
});
|
|
443
|
-
for (const wz of [-1.4, 2.2])
|
|
444
|
-
add({
|
|
445
|
-
mesh: 'cube',
|
|
446
|
-
position: [face, RS + 2, wz],
|
|
447
|
-
scale: [0.06, 0.8, 0.9],
|
|
448
|
-
color: [0.55, 0.7, 0.85]
|
|
449
|
-
});
|
|
450
|
-
const roof = world.spawn({
|
|
451
|
-
mesh: 'none',
|
|
452
|
-
parent: seg.root,
|
|
453
|
-
pickable: false,
|
|
454
|
-
position: [x, RS + 3.2, 0],
|
|
455
|
-
scale: [1, 0.55, 1]
|
|
456
|
-
});
|
|
457
|
-
seg.props.push(roof);
|
|
458
|
-
seg.props.push(
|
|
459
|
-
world.spawn({
|
|
460
|
-
mesh: 'cube',
|
|
461
|
-
parent: roof,
|
|
462
|
-
pickable: false,
|
|
463
|
-
rotation: [0, 0, Math.sin(Math.PI / 8), Math.cos(Math.PI / 8)],
|
|
464
|
-
scale: [4, 4, 6.2],
|
|
465
|
-
color: pick(ROOFS)
|
|
466
|
-
})
|
|
467
|
-
);
|
|
468
|
-
add({
|
|
469
|
-
mesh: 'cube',
|
|
470
|
-
position: [side * (ROAD_HALF + 6.5), RS + 0.35, 0],
|
|
471
|
-
scale: [0.08, 0.6, SEG_LEN],
|
|
472
|
-
color: [0.95, 0.95, 0.95]
|
|
473
|
-
}); // fence
|
|
474
|
-
} else {
|
|
475
|
-
const x = side * (ROAD_HALF + rand(7, 16));
|
|
476
|
-
const zz = z();
|
|
477
|
-
const h = rand(1.6, 2.6);
|
|
478
|
-
add({
|
|
479
|
-
mesh: 'cylinder',
|
|
480
|
-
position: [x, RS + h / 2, zz],
|
|
481
|
-
scale: [0.35, h, 0.35],
|
|
482
|
-
color: [0.42, 0.29, 0.17]
|
|
483
|
-
});
|
|
484
|
-
add({
|
|
485
|
-
mesh: 'sphere',
|
|
486
|
-
position: [x, RS + h + 1.1, zz],
|
|
487
|
-
scale: rand(2.6, 3.6),
|
|
488
|
-
color: [0.24 + rand(0, 0.08), 0.5 + rand(0, 0.12), 0.2]
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
} else {
|
|
492
|
-
// Countryside: a pine forest, rocks, a wooden fence and the odd power pole.
|
|
493
|
-
for (let t = 0; t < 3; t++)
|
|
494
|
-
add({
|
|
495
|
-
mesh: a.tree,
|
|
496
|
-
position: [side * (ROAD_HALF + rand(5, 28)), RS, z()],
|
|
497
|
-
scale: rand(2.4, 4.2),
|
|
498
|
-
color: [1, 1, 1]
|
|
499
|
-
});
|
|
500
|
-
if (Math.random() < 0.35)
|
|
501
|
-
add({
|
|
502
|
-
mesh: 'sphere',
|
|
503
|
-
position: [side * (ROAD_HALF + rand(4, 12)), RS, z()],
|
|
504
|
-
scale: [rand(0.8, 1.8), rand(0.5, 0.9), rand(0.8, 1.6)],
|
|
505
|
-
color: [0.52, 0.5, 0.48]
|
|
506
|
-
});
|
|
507
|
-
for (const y of [0.45, 0.85])
|
|
508
|
-
add({
|
|
509
|
-
mesh: 'cube',
|
|
510
|
-
position: [side * (ROAD_HALF + 4.2), RS + y, 0],
|
|
511
|
-
scale: [0.07, 0.1, SEG_LEN + 0.3],
|
|
512
|
-
color: [0.48, 0.34, 0.2]
|
|
513
|
-
});
|
|
514
|
-
add({
|
|
515
|
-
mesh: 'cube',
|
|
516
|
-
position: [side * (ROAD_HALF + 4.2), RS + 0.5, 0],
|
|
517
|
-
scale: [0.12, 1, 0.12],
|
|
518
|
-
color: [0.4, 0.28, 0.16]
|
|
519
|
-
});
|
|
520
|
-
if (index % 6 === (side > 0 ? 0 : 3)) {
|
|
521
|
-
add({
|
|
522
|
-
mesh: 'cylinder',
|
|
523
|
-
position: [side * (ROAD_HALF + 7), RS + 4.5, 0],
|
|
524
|
-
scale: [0.22, 9, 0.22],
|
|
525
|
-
color: [0.38, 0.27, 0.18]
|
|
526
|
-
});
|
|
527
|
-
add({
|
|
528
|
-
mesh: 'cube',
|
|
529
|
-
position: [side * (ROAD_HALF + 7), RS + 8.4, 0],
|
|
530
|
-
scale: [2.2, 0.14, 0.14],
|
|
531
|
-
color: [0.38, 0.27, 0.18]
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
if (detailIndex % 2 === 0) {
|
|
536
|
-
const vergeX = side * (ROAD_HALF + (zone === 'city' ? 1.8 : 3.2));
|
|
537
|
-
add({
|
|
538
|
-
mesh: detail.grass,
|
|
539
|
-
position: [vergeX, RS - 0.025, -1.6],
|
|
540
|
-
scale: zone === 'city' ? 0.8 : 1.4
|
|
541
|
-
});
|
|
542
|
-
if (zone !== 'city') add({ mesh: detail.grass, position: [vergeX + side * 0.8, RS - 0.025, 1.6], scale: 1.1 });
|
|
543
|
-
}
|
|
544
|
-
if (zone === 'country' && detailIndex % 4 === 1) add({ mesh: detail.flowers, position: [side * (ROAD_HALF + 3.1), RS - 0.02, 0], scale: 1.1 });
|
|
545
|
-
if (zone === 'city' && detailIndex % 3 === 0) add({ mesh: detail.drain, position: [side * (ROAD_HALF - 0.4), RS + 0.008, 0] });
|
|
546
|
-
if (detailIndex % 2 === 1)
|
|
547
|
-
addLight(
|
|
548
|
-
{
|
|
549
|
-
mesh: 'cube',
|
|
550
|
-
position: [side * (ROAD_HALF + 1.04), RS + 0.61, 0],
|
|
551
|
-
scale: [0.1, 0.08, 0.07]
|
|
552
|
-
},
|
|
553
|
-
[0.9, 0.88, 0.75],
|
|
554
|
-
[1.45, 1.3, 0.8]
|
|
555
|
-
);
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
// Street lights (closer together in the city) and, now and then, a billboard angled toward traffic.
|
|
559
|
-
const side = index % 2 ? 1 : -1;
|
|
560
|
-
if (index % (zone === 'city' ? 2 : 4) === 0) {
|
|
561
|
-
add({
|
|
562
|
-
mesh: 'cylinder',
|
|
563
|
-
position: [side * (ROAD_HALF + 1.7), RS + 3.2, 0],
|
|
564
|
-
scale: [0.16, 6.4, 0.16],
|
|
565
|
-
color: [0.35, 0.36, 0.4]
|
|
566
|
-
});
|
|
567
|
-
add({
|
|
568
|
-
mesh: 'cube',
|
|
569
|
-
position: [side * (ROAD_HALF + 0.8), RS + 6.35, 0],
|
|
570
|
-
scale: [1.9, 0.1, 0.12],
|
|
571
|
-
color: [0.35, 0.36, 0.4]
|
|
572
|
-
});
|
|
573
|
-
addLight(
|
|
574
|
-
{
|
|
575
|
-
mesh: 'cube',
|
|
576
|
-
position: [side * (ROAD_HALF - 0.05), RS + 6.25, 0],
|
|
577
|
-
scale: [0.7, 0.1, 0.32]
|
|
578
|
-
},
|
|
579
|
-
LAMP,
|
|
580
|
-
LAMP_LIT
|
|
581
|
-
);
|
|
582
|
-
}
|
|
583
|
-
if (detailIndex % 17 === 7) {
|
|
584
|
-
const signX = side * (ROAD_HALF + 4.6);
|
|
585
|
-
for (const dx of [-1.65, 1.65])
|
|
586
|
-
add({
|
|
587
|
-
mesh: 'cylinder',
|
|
588
|
-
position: [signX + dx, RS + 2, 0],
|
|
589
|
-
scale: [0.1, 4, 0.1],
|
|
590
|
-
color: [0.4, 0.44, 0.42]
|
|
591
|
-
});
|
|
592
|
-
add({ mesh: detail.routeSign, position: [signX, RS + 4.15, 0] });
|
|
593
|
-
addLight(
|
|
594
|
-
{
|
|
595
|
-
text: zone === 'city' ? 'CITY' : zone === 'suburb' ? 'HILLS' : 'FOREST',
|
|
596
|
-
font: a.font,
|
|
597
|
-
position: [signX - 0.35, RS + 3.92, 0.09],
|
|
598
|
-
scale: 0.48,
|
|
599
|
-
letterSpacing: 0.04
|
|
600
|
-
},
|
|
601
|
-
[0.94, 0.95, 0.88],
|
|
602
|
-
[1.4, 1.4, 1.25]
|
|
603
|
-
);
|
|
604
|
-
}
|
|
605
|
-
if (index % 11 === 5) {
|
|
606
|
-
const x = -side * (ROAD_HALF + 6);
|
|
607
|
-
for (const px of [-2.2, 2.2])
|
|
608
|
-
add({
|
|
609
|
-
mesh: 'cylinder',
|
|
610
|
-
position: [x + px, RS + 2.5, 0],
|
|
611
|
-
scale: [0.25, 5, 0.25],
|
|
612
|
-
color: [0.3, 0.3, 0.34]
|
|
613
|
-
});
|
|
614
|
-
addLight(
|
|
615
|
-
{
|
|
616
|
-
mesh: 'cube',
|
|
617
|
-
texture: pick(a.ads),
|
|
618
|
-
position: [x, RS + 6, 0],
|
|
619
|
-
scale: [7.5, 3.6, 0.25],
|
|
620
|
-
rotation: [0, Math.sin((side * 0.35) / 2), 0, Math.cos((side * 0.35) / 2)]
|
|
621
|
-
},
|
|
622
|
-
[1, 1, 1],
|
|
623
|
-
[1.7, 1.7, 1.7]
|
|
624
|
-
); // lit at night
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
/** Segments left behind jump to the front, with fresh scenery. */
|
|
629
|
-
export function recycleRoad(g: SceneryContext, segments: Segment[], s: number) {
|
|
630
|
-
for (const seg of segments) {
|
|
631
|
-
if (seg.s >= s - SEG_LEN * BEHIND) continue;
|
|
632
|
-
seg.s += SEGMENTS * SEG_LEN;
|
|
633
|
-
placeSegment(g, seg);
|
|
634
|
-
for (const e of seg.props) g.world.despawn(e);
|
|
635
|
-
seg.props.length = 0;
|
|
636
|
-
seg.lights.length = 0;
|
|
637
|
-
spawnProps(g, seg);
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
// ── Fire ──────────────────────────────────────────────────────────────
|
|
642
|
-
|
|
643
|
-
// Flames are "flame" particles: soft sprites facing the camera that add their light to what's behind
|
|
644
|
-
// them, so overlapping flames build up to a hot white core and stay bright over smoke and through fog.
|
|
645
|
-
// Each one cools over its life (`endColor`: yellow, orange, then a deep red that fades) while shrinking
|
|
646
|
-
// (`endSize`), the way a tongue of fire tapers as it rises. Smoke is "puff" particles, painted over the
|
|
647
|
-
// scene: dark and dense at first, swelling and thinning as it climbs. Channels above 1 glow (self-lit).
|
|
648
|
-
|
|
649
|
-
const FLASH: Color = [2, 1.95, 1.7, 0.9];
|
|
650
|
-
const FIREBALL: Color[] = [
|
|
651
|
-
[2, 1.7, 0.8, 0.6],
|
|
652
|
-
[2, 1.45, 0.5, 0.6],
|
|
653
|
-
[2, 1.2, 0.35, 0.6]
|
|
654
|
-
];
|
|
655
|
-
const FLAME_CORE: Color[] = [
|
|
656
|
-
[2, 1.85, 1.1, 0.5],
|
|
657
|
-
[2, 1.7, 0.75, 0.5]
|
|
658
|
-
];
|
|
659
|
-
const FLAME: Color[] = [
|
|
660
|
-
[2, 1.6, 0.55, 0.42],
|
|
661
|
-
[2, 1.35, 0.38, 0.42],
|
|
662
|
-
[2, 1.1, 0.25, 0.42]
|
|
663
|
-
];
|
|
664
|
-
const COOLED: Color = [2, 0.35, 0.08, 0]; // a deep red, fading out
|
|
665
|
-
const SMOKE: Color[] = [
|
|
666
|
-
[0.1, 0.095, 0.09, 0.5],
|
|
667
|
-
[0.14, 0.13, 0.12, 0.45],
|
|
668
|
-
[0.18, 0.17, 0.16, 0.4]
|
|
669
|
-
];
|
|
670
|
-
const SMOKE_END: Color = [0.45, 0.44, 0.43, 0];
|
|
671
|
-
const EMBER: Color[] = [
|
|
672
|
-
[2, 1.4, 0.5],
|
|
673
|
-
[2, 1, 0.25]
|
|
674
|
-
];
|
|
675
|
-
const DEBRIS: Color[] = [
|
|
676
|
-
[0.06, 0.06, 0.07],
|
|
677
|
-
[0.18, 0.18, 0.2]
|
|
678
|
-
];
|
|
679
|
-
|
|
680
|
-
/** A wreck on fire: flames and smoke come off it until `until` (game time). */
|
|
681
|
-
export type Fire = { root: Entity; until: number; flame: number; smoke: number; ember: number };
|
|
682
|
-
export const burning = (root: Entity, until: number): Fire => ({
|
|
683
|
-
root,
|
|
684
|
-
until,
|
|
685
|
-
flame: 0,
|
|
686
|
-
smoke: 0,
|
|
687
|
-
ember: 0
|
|
688
|
-
});
|
|
689
|
-
|
|
690
|
-
/**
|
|
691
|
-
* A crash: a white-hot flash, a fireball that swells and cools to red, sparks and car bits thrown out,
|
|
692
|
-
* and smoke that billows up and thins.
|
|
693
|
-
*/
|
|
694
|
-
export function explode(w: World, at: Vec3) {
|
|
695
|
-
const up: Vec3 = [0, 1, 0];
|
|
696
|
-
w.burst({
|
|
697
|
-
position: at,
|
|
698
|
-
mesh: 'flame',
|
|
699
|
-
count: 3,
|
|
700
|
-
size: 3.2,
|
|
701
|
-
speed: 0.5,
|
|
702
|
-
lifetime: 0.22,
|
|
703
|
-
gravity: 0,
|
|
704
|
-
color: FLASH,
|
|
705
|
-
endSize: 1.8,
|
|
706
|
-
endColor: [2, 1.4, 0.4, 0]
|
|
707
|
-
});
|
|
708
|
-
w.burst({
|
|
709
|
-
position: at,
|
|
710
|
-
mesh: 'flame',
|
|
711
|
-
count: 30,
|
|
712
|
-
size: 1.1,
|
|
713
|
-
speed: 4.5,
|
|
714
|
-
lifetime: 0.85,
|
|
715
|
-
gravity: 3,
|
|
716
|
-
color: FIREBALL,
|
|
717
|
-
endSize: 2.2,
|
|
718
|
-
endColor: COOLED
|
|
719
|
-
});
|
|
720
|
-
w.burst({
|
|
721
|
-
position: [at[0], at[1] + 0.4, at[2]],
|
|
722
|
-
mesh: 'flame',
|
|
723
|
-
count: 14,
|
|
724
|
-
size: 0.9,
|
|
725
|
-
speed: 5.5,
|
|
726
|
-
lifetime: 0.9,
|
|
727
|
-
gravity: 5,
|
|
728
|
-
direction: up,
|
|
729
|
-
spread: 0.55,
|
|
730
|
-
color: FLAME,
|
|
731
|
-
endSize: 1.4,
|
|
732
|
-
endColor: COOLED
|
|
733
|
-
});
|
|
734
|
-
w.burst({
|
|
735
|
-
position: at,
|
|
736
|
-
mesh: 'flame',
|
|
737
|
-
count: 30,
|
|
738
|
-
size: 0.16,
|
|
739
|
-
speed: 14,
|
|
740
|
-
lifetime: 0.7,
|
|
741
|
-
gravity: -9.81,
|
|
742
|
-
color: EMBER,
|
|
743
|
-
endSize: 0.3,
|
|
744
|
-
endColor: [2, 0.3, 0.05, 0]
|
|
745
|
-
}); // sparks fall
|
|
746
|
-
w.burst({
|
|
747
|
-
position: at,
|
|
748
|
-
count: 10,
|
|
749
|
-
size: 0.14,
|
|
750
|
-
speed: 8,
|
|
751
|
-
lifetime: 1.4,
|
|
752
|
-
gravity: -9.81,
|
|
753
|
-
direction: up,
|
|
754
|
-
spread: 1.2,
|
|
755
|
-
color: DEBRIS
|
|
756
|
-
}); // bits of car
|
|
757
|
-
w.burst({
|
|
758
|
-
position: [at[0], at[1] + 1.4, at[2]],
|
|
759
|
-
mesh: 'puff',
|
|
760
|
-
count: 6,
|
|
761
|
-
size: 1,
|
|
762
|
-
speed: 2,
|
|
763
|
-
lifetime: 2,
|
|
764
|
-
gravity: 2,
|
|
765
|
-
direction: up,
|
|
766
|
-
spread: 0.6,
|
|
767
|
-
color: SMOKE,
|
|
768
|
-
endSize: 3,
|
|
769
|
-
endColor: SMOKE_END
|
|
770
|
-
});
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
/**
|
|
774
|
-
* Burning wrecks, at a steady rate whatever the frame rate: flame tongues licking up from across the
|
|
775
|
-
* car, a hot core low down, embers drifting up, and smoke rolling off the top. They're launched with
|
|
776
|
-
* the wreck's own velocity (plus a rise), so they ride along with it and stream off behind. A wreck that
|
|
777
|
-
* has dropped back to the camera stops emitting, so fire never fills the screen from up close.
|
|
778
|
-
*/
|
|
779
|
-
const firePosition: [number, number, number] = [0, 0, 0];
|
|
780
|
-
const wreckVelocity: [number, number, number] = [0, 0, 0];
|
|
781
|
-
const FLAMES_PER_SECOND = 120;
|
|
782
|
-
const SMOKE_PER_SECOND = 10;
|
|
783
|
-
const EMBERS_PER_SECOND = 14;
|
|
784
|
-
const FIRE_MIN_DISTANCE = 5; // metres in front of the camera
|
|
785
|
-
type Emit = {
|
|
786
|
-
size: number;
|
|
787
|
-
lifetime: number;
|
|
788
|
-
color: Color[];
|
|
789
|
-
endSize: number;
|
|
790
|
-
endColor: Color;
|
|
791
|
-
spread: number;
|
|
792
|
-
mesh: 'flame' | 'puff';
|
|
793
|
-
};
|
|
794
|
-
export function burn(world: World, camera: Camera, fires: Fire[], time: number, dt: number) {
|
|
795
|
-
const { eye, target } = camera;
|
|
796
|
-
const fx = target[0] - eye[0];
|
|
797
|
-
const fy = target[1] - eye[1];
|
|
798
|
-
const fz = target[2] - eye[2];
|
|
799
|
-
const fl = Math.hypot(fx, fy, fz) || 1;
|
|
800
|
-
for (let i = fires.length - 1; i >= 0; i--) {
|
|
801
|
-
const fire = fires[i]!;
|
|
802
|
-
const p = world.worldPosition(fire.root, firePosition);
|
|
803
|
-
if (!p || time > fire.until) {
|
|
804
|
-
fires.splice(i, 1);
|
|
805
|
-
continue;
|
|
806
|
-
}
|
|
807
|
-
const ahead = ((p[0] - eye[0]) * fx + (p[1] - eye[1]) * fy + (p[2] - eye[2]) * fz) / fl;
|
|
808
|
-
if (ahead < FIRE_MIN_DISTANCE) continue;
|
|
809
|
-
const v = world.velocity(fire.root, wreckVelocity) ?? [0, 0, 0];
|
|
810
|
-
const emit = (rise: number, y: number, spreadX: number, spreadZ: number, o: Emit) => {
|
|
811
|
-
const dir: Vec3 = [v[0], v[1] + rise, v[2]];
|
|
812
|
-
const speed = Math.hypot(dir[0], dir[1], dir[2]);
|
|
813
|
-
world.burst({
|
|
814
|
-
position: [p[0] + rand(-spreadX, spreadX), p[1] + y, p[2] + rand(-spreadZ, spreadZ)],
|
|
815
|
-
mesh: o.mesh,
|
|
816
|
-
count: 1,
|
|
817
|
-
size: o.size,
|
|
818
|
-
speed,
|
|
819
|
-
lifetime: o.lifetime,
|
|
820
|
-
gravity: rise * 1.5, // keeps climbing, as hot gas does
|
|
821
|
-
direction: [dir[0] / speed, dir[1] / speed, dir[2] / speed],
|
|
822
|
-
spread: o.spread,
|
|
823
|
-
color: o.color,
|
|
824
|
-
endSize: o.endSize,
|
|
825
|
-
endColor: o.endColor
|
|
826
|
-
});
|
|
827
|
-
};
|
|
828
|
-
fire.flame += dt * FLAMES_PER_SECOND;
|
|
829
|
-
while (fire.flame >= 1) {
|
|
830
|
-
fire.flame -= 1;
|
|
831
|
-
// Tongues: rising fast, so they stretch into columns that taper and redden toward the tips.
|
|
832
|
-
emit(4.2, 0.8, 0.75, 1.5, {
|
|
833
|
-
mesh: 'flame',
|
|
834
|
-
size: rand(0.8, 1.1),
|
|
835
|
-
lifetime: rand(0.45, 0.65),
|
|
836
|
-
color: FLAME,
|
|
837
|
-
endSize: 0.25,
|
|
838
|
-
endColor: COOLED,
|
|
839
|
-
spread: 0.2
|
|
840
|
-
});
|
|
841
|
-
// Every other one, the white-yellow heart of the fire, low on the car.
|
|
842
|
-
if (Math.random() < 0.5)
|
|
843
|
-
emit(1.5, 0.7, 0.55, 1.2, {
|
|
844
|
-
mesh: 'flame',
|
|
845
|
-
size: rand(0.7, 0.95),
|
|
846
|
-
lifetime: rand(0.18, 0.28),
|
|
847
|
-
color: FLAME_CORE,
|
|
848
|
-
endSize: 0.7,
|
|
849
|
-
endColor: [2, 1.4, 0.4, 0],
|
|
850
|
-
spread: 0.2
|
|
851
|
-
});
|
|
852
|
-
}
|
|
853
|
-
fire.smoke += dt * SMOKE_PER_SECOND;
|
|
854
|
-
while (fire.smoke >= 1) {
|
|
855
|
-
fire.smoke -= 1;
|
|
856
|
-
emit(2.6, 2, 0.5, 1, {
|
|
857
|
-
mesh: 'puff',
|
|
858
|
-
size: rand(1, 1.3),
|
|
859
|
-
lifetime: rand(1.6, 2.1),
|
|
860
|
-
color: SMOKE,
|
|
861
|
-
endSize: 3,
|
|
862
|
-
endColor: SMOKE_END,
|
|
863
|
-
spread: 0.35
|
|
864
|
-
});
|
|
865
|
-
}
|
|
866
|
-
fire.ember += dt * EMBERS_PER_SECOND;
|
|
867
|
-
while (fire.ember >= 1) {
|
|
868
|
-
fire.ember -= 1;
|
|
869
|
-
emit(4.5, 1, 0.6, 1.3, {
|
|
870
|
-
mesh: 'flame',
|
|
871
|
-
size: 0.14,
|
|
872
|
-
lifetime: rand(0.8, 1.3),
|
|
873
|
-
color: EMBER,
|
|
874
|
-
endSize: 0.3,
|
|
875
|
-
endColor: [2, 0.3, 0.05, 0],
|
|
876
|
-
spread: 0.6
|
|
877
|
-
});
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
// ── Start and finish ──────────────────────────────────────────────────
|
|
883
|
-
|
|
884
|
-
/** Gantry posts stand outside the rails; the banner and its crossbar span the road between them. */
|
|
885
|
-
const GANTRY_X = ROAD_HALF + 1.7;
|
|
886
|
-
const GANTRY_H = 6.4;
|
|
887
|
-
const BANNER_Y = 5.5;
|
|
888
|
-
const markerMeshes = new Map<string, Model>();
|
|
889
|
-
const markerMesh = (key: string, build: () => Model) => {
|
|
890
|
-
let m = markerMeshes.get(key);
|
|
891
|
-
if (!m) markerMeshes.set(key, (m = cacheGameAsset('car-racing/CarRacingScene:' + key, build)));
|
|
892
|
-
return m;
|
|
893
|
-
};
|
|
894
|
-
|
|
895
|
-
/** Twin posts, a crossbar and a banner across the road, over the finish. */
|
|
896
|
-
function gantryParts(frame: Color, banner: Color): GeometryPart[] {
|
|
897
|
-
const parts: GeometryPart[] = [];
|
|
898
|
-
for (const side of [-1, 1]) {
|
|
899
|
-
parts.push({
|
|
900
|
-
geometry: block(0.55, GANTRY_H, 0.55, 6),
|
|
901
|
-
position: [side * GANTRY_X, GANTRY_H / 2, 0],
|
|
902
|
-
color: frame
|
|
903
|
-
});
|
|
904
|
-
parts.push({
|
|
905
|
-
geometry: block(0.9, 0.3, 0.9, 6),
|
|
906
|
-
position: [side * GANTRY_X, 0.15, 0],
|
|
907
|
-
color: frame
|
|
908
|
-
}); // footings
|
|
909
|
-
}
|
|
910
|
-
parts.push(
|
|
911
|
-
{
|
|
912
|
-
geometry: block(GANTRY_X * 2 + 0.9, 0.45, 0.6),
|
|
913
|
-
position: [0, GANTRY_H + 0.1, 0],
|
|
914
|
-
color: frame
|
|
915
|
-
},
|
|
916
|
-
{
|
|
917
|
-
geometry: block(GANTRY_X * 2 - 1.4, 1.25, 0.12),
|
|
918
|
-
position: [0, BANNER_Y, 0.08],
|
|
919
|
-
color: banner
|
|
920
|
-
},
|
|
921
|
-
{
|
|
922
|
-
geometry: block(GANTRY_X * 2 - 2.2, 0.08, 0.04),
|
|
923
|
-
position: [0, BANNER_Y - 0.5, 0.15],
|
|
924
|
-
color: [1, 0.9, 0.5]
|
|
925
|
-
},
|
|
926
|
-
{
|
|
927
|
-
geometry: block(GANTRY_X * 2 - 2.2, 0.08, 0.04),
|
|
928
|
-
position: [0, BANNER_Y + 0.5, 0.15],
|
|
929
|
-
color: [1, 0.9, 0.5]
|
|
930
|
-
}
|
|
931
|
-
);
|
|
932
|
-
return parts;
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
/** The finish: a checkered band across the road under a golden gantry, a red banner and pennants. */
|
|
936
|
-
const finishMesh = () =>
|
|
937
|
-
markerMesh('finish', () => {
|
|
938
|
-
const squares: GeometryPart[] = [];
|
|
939
|
-
const size = 0.7;
|
|
940
|
-
const across = Math.ceil((ROAD_HALF * 2 + 0.6) / size);
|
|
941
|
-
for (let i = 0; i < across; i++)
|
|
942
|
-
for (let j = 0; j < 2; j++)
|
|
943
|
-
squares.push({
|
|
944
|
-
geometry: block(size, 0.03, size, 8),
|
|
945
|
-
position: [(i - (across - 1) / 2) * size, 0.016, (j - 0.5) * size],
|
|
946
|
-
color: (i + j) % 2 ? [0.96, 0.96, 0.94] : [0.08, 0.08, 0.1]
|
|
947
|
-
});
|
|
948
|
-
const pennants: GeometryPart[] = [-4, -2, 0, 2, 4].map((x, i) => ({
|
|
949
|
-
geometry: tube(
|
|
950
|
-
[
|
|
951
|
-
[x, GANTRY_H - 0.15, 0.32],
|
|
952
|
-
[x + 0.06, GANTRY_H - 0.8, 0.33]
|
|
953
|
-
],
|
|
954
|
-
{
|
|
955
|
-
radius: (t) => 0.2 * (1 - t),
|
|
956
|
-
shape: (a) => 0.2 + 0.8 * Math.abs(Math.cos(a * Math.PI * 2)),
|
|
957
|
-
sides: 6
|
|
958
|
-
}
|
|
959
|
-
),
|
|
960
|
-
color: (
|
|
961
|
-
[
|
|
962
|
-
[0.2, 0.5, 0.95],
|
|
963
|
-
[1, 0.8, 0.15],
|
|
964
|
-
[0.2, 0.75, 0.3]
|
|
965
|
-
] as Color[]
|
|
966
|
-
)[i % 3]!
|
|
967
|
-
}));
|
|
968
|
-
return createShape(merge([...squares, ...gantryParts([0.95, 0.72, 0.2], [0.85, 0.12, 0.14]), ...pennants]), { center: false, shine: 0.5 });
|
|
969
|
-
});
|
|
970
|
-
|
|
971
|
-
/** The start line: a white band across the road. */
|
|
972
|
-
const startMesh = () =>
|
|
973
|
-
markerMesh('start', () =>
|
|
974
|
-
createShape(
|
|
975
|
-
merge([
|
|
976
|
-
{
|
|
977
|
-
geometry: block(ROAD_HALF * 2 + 0.4, 0.03, 0.5, 8),
|
|
978
|
-
position: [0, 0.016, 0],
|
|
979
|
-
color: [0.96, 0.96, 0.92]
|
|
980
|
-
}
|
|
981
|
-
]),
|
|
982
|
-
{
|
|
983
|
-
center: false,
|
|
984
|
-
shine: 0.3
|
|
985
|
-
}
|
|
986
|
-
)
|
|
987
|
-
);
|
|
988
|
-
|
|
989
|
-
const markerSample = newSample();
|
|
990
|
-
const markerAt: [number, number, number] = [0, 0, 0];
|
|
991
|
-
|
|
992
|
-
/**
|
|
993
|
-
* The race's start line (at `startS`) and finish gate (at `finishS`), placed on the road and facing the
|
|
994
|
-
* driver, with FINISH written on the gate's banner once the HUD's font is in.
|
|
995
|
-
*/
|
|
996
|
-
export function spawnRaceMarkers(world: World, track: Track, startS: number, finishS: number, font: Font) {
|
|
997
|
-
const place = (mesh: Model, s: number, label?: string) => {
|
|
998
|
-
const t = track.sample(s, markerSample);
|
|
999
|
-
placeAt(t, 0, 0, markerAt);
|
|
1000
|
-
const root = world.spawn({
|
|
1001
|
-
mesh,
|
|
1002
|
-
position: [markerAt[0], markerAt[1], markerAt[2]],
|
|
1003
|
-
rotation: orient(t.heading, t.pitch),
|
|
1004
|
-
pickable: false
|
|
1005
|
-
});
|
|
1006
|
-
if (!label) return root;
|
|
1007
|
-
world.spawn({
|
|
1008
|
-
text: label,
|
|
1009
|
-
font,
|
|
1010
|
-
parent: root,
|
|
1011
|
-
position: [0, BANNER_Y - 0.36, 0.16],
|
|
1012
|
-
scale: 0.78,
|
|
1013
|
-
color: [1, 1, 1],
|
|
1014
|
-
letterSpacing: 0.12,
|
|
1015
|
-
pickable: false
|
|
1016
|
-
});
|
|
1017
|
-
return root;
|
|
1018
|
-
};
|
|
1019
|
-
return { start: place(startMesh(), startS), finish: place(finishMesh(), finishS, 'FINISH') };
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
/** Reusable assets; the game loader advances one builder per frame. */
|
|
1023
|
-
export function* warmAssets(): Iterable<() => unknown> {
|
|
1024
|
-
yield finishMesh;
|
|
1025
|
-
yield startMesh;
|
|
1026
|
-
}
|