@pinkaphant/kolmo 0.0.0-stage → 0.1.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/README.md +44 -2
- package/bin/kolmo.mjs +112 -0
- package/dist/engine/index.d.ts +8 -0
- package/dist/engine/index.js +3 -0
- package/dist/engine/kolmoActor.d.ts +6 -0
- package/dist/engine/kolmoIsland.d.ts +17 -0
- package/dist/engine/kolmoLongDrive.d.ts +13 -0
- package/dist/engine/kolmoRigs.d.ts +13 -0
- package/dist/engine/kolmoStore.d.ts +68 -0
- package/dist/engine/kolmoSurface.d.ts +18 -0
- package/dist/engine/kolmoVehicle.d.ts +32 -0
- package/dist/engine/kolmoWorld.d.ts +51 -0
- package/dist/engine/longDriveKit.d.ts +19 -0
- package/dist/engine/mainlandMacroCell.d.ts +19 -0
- package/dist/engine-BiMeAPAi.js +1717 -0
- package/dist/importer/ChopShopPanel.d.ts +44 -0
- package/dist/importer/DomainWorkshopPanel.d.ts +17 -0
- package/dist/importer/GateHudBar.d.ts +29 -0
- package/dist/importer/GlbImportGate.d.ts +7 -0
- package/dist/importer/ImperativeVehicleRig.d.ts +9 -0
- package/dist/importer/Step1CalibrationPlinth.d.ts +38 -0
- package/dist/importer/Step2UniversalPad.d.ts +18 -0
- package/dist/importer/VfxEmitterPool.d.ts +8 -0
- package/dist/importer/chopShopActions.d.ts +44 -0
- package/dist/importer/gateStore.d.ts +73 -0
- package/dist/importer/glbNormalizer.d.ts +22 -0
- package/dist/importer/importerWebMcp.d.ts +37 -0
- package/dist/importer/index.d.ts +17 -0
- package/dist/importer/index.js +3 -0
- package/dist/importer/khrCompiler.d.ts +23 -0
- package/dist/importer/launcherBake.d.ts +15 -0
- package/dist/importer/meshIslands.d.ts +59 -0
- package/dist/importer/surfaceCutter.d.ts +27 -0
- package/dist/importer/surfaceTopology.d.ts +40 -0
- package/dist/importer/universalGateBake.d.ts +41 -0
- package/dist/importer/usdToGlb.d.ts +11 -0
- package/dist/importer/useChopShopController.d.ts +94 -0
- package/dist/importer/vehiclePanelAnim.d.ts +25 -0
- package/dist/importer/wheelAxlePairing.d.ts +19 -0
- package/dist/importer-Cz5w0mnC.js +5005 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +14 -0
- package/dist/junk/DestructibleTarget.d.ts +18 -0
- package/dist/junk/KolmoJunk.d.ts +14 -0
- package/dist/junk/ShardPieces.d.ts +10 -0
- package/dist/junk/TargetDecals.d.ts +18 -0
- package/dist/junk/bvhShatter.d.ts +7 -0
- package/dist/junk/bvhTriCollector.d.ts +20 -0
- package/dist/junk/index.d.ts +12 -0
- package/dist/junk/index.js +1 -0
- package/dist/junk/junkGeometry.d.ts +34 -0
- package/dist/junk/junkImportSanitize.d.ts +6 -0
- package/dist/junk/junkImporter.d.ts +25 -0
- package/dist/junk/junkLabelCanvas.d.ts +7 -0
- package/dist/junk/junkLabels.d.ts +31 -0
- package/dist/junk/junkTypes.d.ts +48 -0
- package/dist/junk/targetHelpers.d.ts +56 -0
- package/dist/junk/targetHitLogic.d.ts +30 -0
- package/dist/junk/useTargetAssets.d.ts +24 -0
- package/dist/junk-B4bC1zAl.js +1049 -0
- package/dist/kolmoSurface-DTnrFXH0.js +558 -0
- package/dist/schema/kolmoSchema.d.ts +69 -0
- package/dist/shaders/celestialBackdrop.d.ts +22 -0
- package/dist/shaders/index.d.ts +6 -0
- package/dist/shaders/index.js +1 -0
- package/dist/shaders/plumeAndSparkle.d.ts +14 -0
- package/dist/shaders/ps2GlslShared.d.ts +20 -0
- package/dist/shaders/ps2MaterialsTSL.d.ts +23 -0
- package/dist/shaders/ps2MaterialsWebGL.d.ts +15 -0
- package/dist/shaders/ps2RoadWebGL.d.ts +7 -0
- package/dist/shaders/ps2TerrainWebGL.d.ts +8 -0
- package/dist/shaders/ps2Textures.d.ts +22 -0
- package/dist/shaders/retroPalettes.d.ts +24 -0
- package/dist/shaders/retroShader.d.ts +69 -0
- package/dist/shaders-GS71Ek1A.js +1383 -0
- package/dist/world/frontage.d.ts +26 -0
- package/dist/world/index.d.ts +9 -0
- package/dist/world/index.js +3 -0
- package/dist/world/infiniteWorld2D.d.ts +24 -0
- package/dist/world/island.d.ts +29 -0
- package/dist/world/macroCellSchema.d.ts +72 -0
- package/dist/world/macroKnightAStar.d.ts +11 -0
- package/dist/world/random.d.ts +23 -0
- package/dist/world/road.d.ts +37 -0
- package/dist/world/roadRibbon.d.ts +44 -0
- package/dist/world/terrain.d.ts +62 -0
- package/dist/world/worldTypes.d.ts +39 -0
- package/dist/world-PRWPYrlx.js +947 -0
- package/dist/worldTypes-Z0KfdCd0.js +226 -0
- package/package.json +100 -4
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lots along a road: evenly spaced plots on either side, set back from the edge, facing the road.
|
|
3
|
+
* Towns, villages and cities (`@khr3/c12` settlements) place buildings on these.
|
|
4
|
+
*/
|
|
5
|
+
import type { Road, V3 } from "./road.js";
|
|
6
|
+
export interface FrontageLot {
|
|
7
|
+
/** Arc length of the lot's centre along the road. */
|
|
8
|
+
s: number;
|
|
9
|
+
side: "left" | "right";
|
|
10
|
+
/** Lot front-centre on the ground (metres), `setback` beyond the road edge. */
|
|
11
|
+
front: V3;
|
|
12
|
+
/** Unit horizontal direction from the lot toward the road. */
|
|
13
|
+
facing: V3;
|
|
14
|
+
/** Road surface height at the lot (the terrain verge is flat at this height). */
|
|
15
|
+
groundY: number;
|
|
16
|
+
}
|
|
17
|
+
export interface FrontageOptions {
|
|
18
|
+
/** Lot pitch along the road (metres). */
|
|
19
|
+
spacing: number;
|
|
20
|
+
/** Gap between the road edge and the lot front (metres). */
|
|
21
|
+
setback: number;
|
|
22
|
+
/** Skip this much road at each end (metres). */
|
|
23
|
+
margin?: number;
|
|
24
|
+
sides?: ReadonlyArray<"left" | "right">;
|
|
25
|
+
}
|
|
26
|
+
export declare function frontage(road: Road, o: FrontageOptions): FrontageLot[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { childSeed, fbm2, mulberry32, seedFrom, valueNoise2, type FbmOptions, type Rng } from "./random.js";
|
|
2
|
+
export { closedRoadFromPoints, growRoad, maxGrade, roadFromPoints, type GrowRoadOptions, type Road, type RoadSample, type V3, } from "./road.js";
|
|
3
|
+
export { SHOULDER_K, makeTerrain, sampleHeightfield, type NearestOnRoad, type RoadSplatSample, type Terrain, type TerrainOptions, } from "./terrain.js";
|
|
4
|
+
export { frontage, type FrontageLot, type FrontageOptions } from "./frontage.js";
|
|
5
|
+
export { makeIslandHeightfn, planIslandWorld, type IslandOptions, type IslandWorldPlan } from "./island.js";
|
|
6
|
+
export { SeededSimplex2D, SplitMix32, bakeWorldSplatMaps, hashSeed, type WorldGenConfig, type WorldGenResult, } from "./worldTypes.js";
|
|
7
|
+
export { buildDodecagonalCivicHub, routeMacroKnightAStar, } from "./macroKnightAStar.js";
|
|
8
|
+
export { C12TileKind, C12_TILE_M, FLOATING_ORIGIN_STEP_M, InfiniteLongDrivePlanner, MACRO_SIZE_M, TILES_PER_MACRO, quantizeFloatingOrigin192, type FloatingOriginFrame, type MacroCellPlan2D, type MacroSettlementTier, type RoadsideStop2D, type RoadsideStopKind, type SharedBorderPortal, type ZonedParcel2D, } from "./infiniteWorld2D.js";
|
|
9
|
+
export { buildCarvedTerrainGeometry, buildHighwayAsphaltTexture, buildRoadRibbonGeometry, planDirtSpurs, type BuiltCarvedTerrain, type BuiltRoadRibbon, type RoadRibbonOptions, type TJunctionSpec, } from "./roadRibbon.js";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "../worldTypes-Z0KfdCd0.js";
|
|
2
|
+
import { _ as f, a as p, b as m, c as h, d as g, f as _, g as v, h as y, i as b, l as x, m as S, n as C, o as w, p as T, r as E, s as D, t as O, u as k, v as A, y as j } from "../world-PRWPYrlx.js";
|
|
3
|
+
export { w as C12TileKind, D as C12_TILE_M, h as FLOATING_ORIGIN_STEP_M, p as InfiniteLongDrivePlanner, x as MACRO_SIZE_M, e as SHOULDER_K, u as SeededSimplex2D, o as SplitMix32, k as TILES_PER_MACRO, c as bakeWorldSplatMaps, O as buildCarvedTerrainGeometry, _ as buildDodecagonalCivicHub, C as buildHighwayAsphaltTexture, E as buildRoadRibbonGeometry, t as childSeed, f as closedRoadFromPoints, a as fbm2, v as frontage, A as growRoad, i as hashSeed, S as makeIslandHeightfn, s as makeTerrain, j as maxGrade, d as mulberry32, b as planDirtSpurs, y as planIslandWorld, g as quantizeFloatingOrigin192, m as roadFromPoints, T as routeMacroKnightAStar, l as sampleHeightfield, n as seedFrom, r as valueNoise2 };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stateless 2304m Macro-Lattice, 192m C12 Floating Origin, Causeway Bridge,
|
|
3
|
+
* Bounded 16-Way Knight A* Routing, Dodecagonal C12 Civic Hub, and SimCity R/C/I C12 Classifier.
|
|
4
|
+
*/
|
|
5
|
+
import { C12TileKind, C12_TILE_M, FLOATING_ORIGIN_STEP_M, MACRO_SIZE_M, TILES_PER_MACRO, quantizeFloatingOrigin192, type FloatingOriginFrame, type MacroCellPlan2D, type MacroSettlementTier, type RoadsideStop2D, type RoadsideStopKind, type SharedBorderPortal, type ZonedParcel2D } from "./macroCellSchema.js";
|
|
6
|
+
export { C12TileKind, C12_TILE_M, FLOATING_ORIGIN_STEP_M, MACRO_SIZE_M, TILES_PER_MACRO, quantizeFloatingOrigin192, type FloatingOriginFrame, type MacroCellPlan2D, type MacroSettlementTier, type RoadsideStop2D, type RoadsideStopKind, type SharedBorderPortal, type ZonedParcel2D, };
|
|
7
|
+
export declare class InfiniteLongDrivePlanner {
|
|
8
|
+
private readonly seedInt;
|
|
9
|
+
private readonly popNoise;
|
|
10
|
+
private readonly zoneNoise;
|
|
11
|
+
private readonly elevNoise;
|
|
12
|
+
private readonly windDir;
|
|
13
|
+
constructor(seed: string | number);
|
|
14
|
+
sampleMainlandHeight(wx: number, wz: number): number;
|
|
15
|
+
evalVerticalBorder(westMx: number, mz: number): SharedBorderPortal;
|
|
16
|
+
evalHorizontalBorder(mx: number, northMz: number): SharedBorderPortal;
|
|
17
|
+
private rawPopScore;
|
|
18
|
+
private isMetropolisPeak;
|
|
19
|
+
private isCityPeak;
|
|
20
|
+
resolveSettlementTier(mx: number, mz: number, roadDegree: number): MacroSettlementTier;
|
|
21
|
+
generateMacroCell2D(mx: number, mz: number): MacroCellPlan2D;
|
|
22
|
+
private evaluateSimCityZone;
|
|
23
|
+
classifySettlementC12Tile(worldX: number, worldZ: number, plan: MacroCellPlan2D): C12TileKind;
|
|
24
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Road, type V3 } from "./road.js";
|
|
2
|
+
import { type Terrain } from "./terrain.js";
|
|
3
|
+
export interface IslandOptions {
|
|
4
|
+
/** Square world extent in metres (default `960`, supports `512..4096`). */
|
|
5
|
+
readonly size?: number;
|
|
6
|
+
/** Peak interior mountain elevation in metres (default `56`). */
|
|
7
|
+
readonly peakHeight?: number;
|
|
8
|
+
/** Sea level in metres (default `0`). */
|
|
9
|
+
readonly waterLevel?: number;
|
|
10
|
+
/** Road half-width in metres (default `4.5` -> `9 m` two-lane highway). */
|
|
11
|
+
readonly halfWidth?: number;
|
|
12
|
+
/** Number of ring A* waypoints around the island (default `8`). */
|
|
13
|
+
readonly waypointCount?: number;
|
|
14
|
+
/** Coarse pathfinding grid resolution per side (default `96`). */
|
|
15
|
+
readonly pathGrid?: number;
|
|
16
|
+
/** Maximum target longitudinal grade after smoothing (default `0.08`). */
|
|
17
|
+
readonly maxGrade?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface IslandWorldPlan {
|
|
20
|
+
readonly seed: number;
|
|
21
|
+
readonly size: number;
|
|
22
|
+
readonly waterLevel: number;
|
|
23
|
+
readonly baseHeight: (x: number, z: number) => number;
|
|
24
|
+
readonly waypoints: readonly V3[];
|
|
25
|
+
readonly road: Road;
|
|
26
|
+
readonly terrain: Terrain;
|
|
27
|
+
}
|
|
28
|
+
export declare function makeIslandHeightfn(seed: number, size: number, peakHeight: number): (x: number, z: number) => number;
|
|
29
|
+
export declare function planIslandWorld(seed: number, opts?: IslandOptions): IslandWorldPlan;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { InstanceBatch } from "@khr3/c12";
|
|
2
|
+
export declare const MACRO_SIZE_M = 2304;
|
|
3
|
+
export declare const C12_TILE_M = 3;
|
|
4
|
+
export declare const TILES_PER_MACRO = 768;
|
|
5
|
+
export declare const FLOATING_ORIGIN_STEP_M = 192;
|
|
6
|
+
export type MacroSettlementTier = "ISLAND_RING" | "NONE_HIGHWAY" | "VILLAGE" | "SMALL_TOWN" | "SUBURBS_BIG_TOWN" | "CITY" | "METROPOLIS";
|
|
7
|
+
export type RoadsideStopKind = "GAS_STATION" | "REST_STOP";
|
|
8
|
+
export declare const C12TileKind: {
|
|
9
|
+
readonly EMPTY: 0;
|
|
10
|
+
readonly ROAD_LANE: 1;
|
|
11
|
+
readonly CROSSWALK: 2;
|
|
12
|
+
readonly INTERSECTION_BOX: 3;
|
|
13
|
+
readonly CURB_STRAIGHT: 4;
|
|
14
|
+
readonly CURB_RAMP_CORNER: 5;
|
|
15
|
+
readonly CURB_DRIVEWAY: 6;
|
|
16
|
+
readonly BOULEVARD_MEDIAN: 7;
|
|
17
|
+
readonly C12_BOULEVARD_30: 8;
|
|
18
|
+
readonly C12_PLAZA_HUB: 9;
|
|
19
|
+
readonly ZONE_RESIDENTIAL: 10;
|
|
20
|
+
readonly ZONE_COMMERCIAL: 11;
|
|
21
|
+
readonly ZONE_INDUSTRIAL: 12;
|
|
22
|
+
readonly ZONE_ROADSIDE_STOP: 13;
|
|
23
|
+
};
|
|
24
|
+
export type C12TileKind = (typeof C12TileKind)[keyof typeof C12TileKind];
|
|
25
|
+
export interface SharedBorderPortal {
|
|
26
|
+
readonly exists: boolean;
|
|
27
|
+
readonly isBridgeCauseway: boolean;
|
|
28
|
+
readonly offsetMeters: number;
|
|
29
|
+
}
|
|
30
|
+
export interface RoadsideStop2D {
|
|
31
|
+
readonly kind: RoadsideStopKind;
|
|
32
|
+
readonly worldX: number;
|
|
33
|
+
readonly worldZ: number;
|
|
34
|
+
readonly yaw: number;
|
|
35
|
+
readonly widthMeters: number;
|
|
36
|
+
readonly depthMeters: number;
|
|
37
|
+
}
|
|
38
|
+
export interface ZonedParcel2D {
|
|
39
|
+
readonly zone: "RESIDENTIAL" | "COMMERCIAL" | "INDUSTRIAL";
|
|
40
|
+
readonly minX: number;
|
|
41
|
+
readonly minZ: number;
|
|
42
|
+
readonly width: number;
|
|
43
|
+
readonly depth: number;
|
|
44
|
+
readonly yaw: number;
|
|
45
|
+
}
|
|
46
|
+
export interface MacroCellPlan2D {
|
|
47
|
+
readonly mx: number;
|
|
48
|
+
readonly mz: number;
|
|
49
|
+
readonly originWorldX: number;
|
|
50
|
+
readonly originWorldZ: number;
|
|
51
|
+
readonly tier: MacroSettlementTier;
|
|
52
|
+
readonly hubX: number;
|
|
53
|
+
readonly hubZ: number;
|
|
54
|
+
readonly settlementRadiusM: number;
|
|
55
|
+
readonly portals: {
|
|
56
|
+
readonly north: SharedBorderPortal;
|
|
57
|
+
readonly south: SharedBorderPortal;
|
|
58
|
+
readonly west: SharedBorderPortal;
|
|
59
|
+
readonly east: SharedBorderPortal;
|
|
60
|
+
};
|
|
61
|
+
readonly highwayPolylines: ReadonlyArray<ReadonlyArray<readonly [number, number]>>;
|
|
62
|
+
readonly roadsideStops: readonly RoadsideStop2D[];
|
|
63
|
+
readonly parcels: readonly ZonedParcel2D[];
|
|
64
|
+
readonly civicHubBatches: readonly InstanceBatch[];
|
|
65
|
+
}
|
|
66
|
+
export interface FloatingOriginFrame {
|
|
67
|
+
readonly chunkOriginX: number;
|
|
68
|
+
readonly chunkOriginZ: number;
|
|
69
|
+
readonly localX: number;
|
|
70
|
+
readonly localZ: number;
|
|
71
|
+
}
|
|
72
|
+
export declare function quantizeFloatingOrigin192(worldX: number, worldZ: number): FloatingOriginFrame;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type InstanceBatch } from "@khr3/c12";
|
|
2
|
+
/**
|
|
3
|
+
* Stateless bounded 16-way Knight A* pathfinder strictly inside one 2304m x 2304m Macro-Cell.
|
|
4
|
+
* Routes from `[startX, startZ]` (border portal) to `[goalX, goalZ]` (settlement gate) while avoiding steep grades.
|
|
5
|
+
*/
|
|
6
|
+
export declare function routeMacroKnightAStar(originWorldX: number, originWorldZ: number, startX: number, startZ: number, goalX: number, goalZ: number, sampleHeight: (wx: number, wz: number) => number): Array<[number, number]>;
|
|
7
|
+
/**
|
|
8
|
+
* Exact `@khr3/c12` Dodecagonal Civic Hub ring built from alternating `3 m` `FoundationSquare`
|
|
9
|
+
* and `60°` `FoundationTriangle` pieces over $\mathbb{Z}[1/2, \sqrt{3}]$, returned as `InstancedMesh` batches.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildDodecagonalCivicHub(hubX: number, hubZ: number, groundY: number): InstanceBatch[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic randomness. Same seed, same world, on every machine (pure 32-bit integer math).
|
|
3
|
+
*/
|
|
4
|
+
export type Rng = () => number;
|
|
5
|
+
/** mulberry32: a fast 32-bit PRNG returning floats in [0, 1). */
|
|
6
|
+
export declare function mulberry32(seed: number): Rng;
|
|
7
|
+
/** Hash a string seed ("rust-island-7") into a 32-bit integer seed. */
|
|
8
|
+
export declare function seedFrom(text: string | number): number;
|
|
9
|
+
/** Derive an independent child seed so subsystems (road, terrain, towns) never share a stream. */
|
|
10
|
+
export declare function childSeed(seed: number, salt: string): number;
|
|
11
|
+
/** Smooth value noise in [-1, 1], C2 continuous. */
|
|
12
|
+
export declare function valueNoise2(seed: number, x: number, z: number): number;
|
|
13
|
+
export interface FbmOptions {
|
|
14
|
+
/** Feature size of the first octave in metres. */
|
|
15
|
+
wavelength: number;
|
|
16
|
+
octaves: number;
|
|
17
|
+
/** Amplitude multiplier per octave. */
|
|
18
|
+
gain: number;
|
|
19
|
+
/** Frequency multiplier per octave. */
|
|
20
|
+
lacunarity: number;
|
|
21
|
+
}
|
|
22
|
+
/** Fractal value noise, normalised to roughly [-1, 1]. */
|
|
23
|
+
export declare function fbm2(seed: number, x: number, z: number, o: FbmOptions): number;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type V3 = [number, number, number];
|
|
2
|
+
export interface RoadSample {
|
|
3
|
+
/** Arc length from the start (metres). */
|
|
4
|
+
s: number;
|
|
5
|
+
pos: V3;
|
|
6
|
+
/** Unit horizontal tangent [x, 0, z]. */
|
|
7
|
+
tangent: V3;
|
|
8
|
+
/** Unit horizontal vector pointing to the road's left. */
|
|
9
|
+
left: V3;
|
|
10
|
+
}
|
|
11
|
+
export interface Road {
|
|
12
|
+
readonly halfWidth: number;
|
|
13
|
+
readonly length: number;
|
|
14
|
+
readonly closed: boolean;
|
|
15
|
+
/** Dense samples every `step` metres (centripetal Catmull-Rom through the control points). */
|
|
16
|
+
readonly samples: readonly RoadSample[];
|
|
17
|
+
readonly step: number;
|
|
18
|
+
/** Interpolated frame at arc length `s` (wrapped modulo `length` when `closed`, clamped when open). */
|
|
19
|
+
at(s: number): RoadSample;
|
|
20
|
+
}
|
|
21
|
+
/** Build an open or closed road through control points via centripetal Catmull-Rom + arc-length resampling. */
|
|
22
|
+
export declare function roadFromPoints(points: readonly V3[], halfWidth: number, step?: number, closed?: boolean): Road;
|
|
23
|
+
export declare function closedRoadFromPoints(points: readonly V3[], halfWidth: number, step?: number): Road;
|
|
24
|
+
export interface GrowRoadOptions {
|
|
25
|
+
length: number;
|
|
26
|
+
halfWidth: number;
|
|
27
|
+
controlSpacing: number;
|
|
28
|
+
maxTurn: number;
|
|
29
|
+
maxGrade: number;
|
|
30
|
+
hilliness: number;
|
|
31
|
+
start?: V3;
|
|
32
|
+
heading?: number;
|
|
33
|
+
}
|
|
34
|
+
/** Grow an open road from a seed: curvature-bounded walk, grade-clamped. */
|
|
35
|
+
export declare function growRoad(seed: number, o: GrowRoadOptions): Road;
|
|
36
|
+
/** Maximum grade between consecutive samples (including loop closure when `road.closed`). */
|
|
37
|
+
export declare function maxGrade(road: Road): number;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 7-Vertex Crowned Road Profile + 3-Way T-Junction Welder + Rural Dirt Spur Grower + Cavity-AO Terrain Builder.
|
|
3
|
+
* - 7-vertex cross-section `u = [0.00, 0.08, 0.18, 0.50, 0.82, 0.92, 1.00]`:
|
|
4
|
+
* crown (`u=0.50`), pavement edges (`0.18/0.82`), beveled collision aprons (`0.08/0.92`), buried skirts (`0/1`).
|
|
5
|
+
* - T-junction hub triangles keep `v <= 0.50` in the center so `smoothstep(0.56, 0.66, v)` clears yellow dashes,
|
|
6
|
+
* while quadratic Bezier corner fillets hold `u = 0.18` so white fog-lines curve cleanly around the turn.
|
|
7
|
+
* - Packs dual-stage cavity AO (`[0.45..1.06]`) into vertex `color.r` on both terrain and road meshes.
|
|
8
|
+
*/
|
|
9
|
+
import * as THREE from "three";
|
|
10
|
+
import type { IslandWorldPlan } from "./island.js";
|
|
11
|
+
import { type Road } from "./road.js";
|
|
12
|
+
import type { Terrain } from "./terrain.js";
|
|
13
|
+
export interface RoadRibbonOptions {
|
|
14
|
+
readonly apronWidth?: number;
|
|
15
|
+
readonly skirtWidth?: number;
|
|
16
|
+
readonly skirtDrop?: number;
|
|
17
|
+
readonly crownHeight?: number;
|
|
18
|
+
readonly surfaceLift?: number;
|
|
19
|
+
readonly dashPeriodM?: number;
|
|
20
|
+
readonly tJunctions?: readonly TJunctionSpec[];
|
|
21
|
+
}
|
|
22
|
+
export interface TJunctionSpec {
|
|
23
|
+
readonly ringS: number;
|
|
24
|
+
readonly side: "left" | "right";
|
|
25
|
+
readonly spurRoad: Road;
|
|
26
|
+
}
|
|
27
|
+
export interface BuiltRoadRibbon {
|
|
28
|
+
readonly geometry: THREE.BufferGeometry;
|
|
29
|
+
readonly colliderVertices: Float32Array;
|
|
30
|
+
readonly colliderIndices: Uint32Array;
|
|
31
|
+
}
|
|
32
|
+
export interface BuiltCarvedTerrain {
|
|
33
|
+
readonly geometry: THREE.BufferGeometry;
|
|
34
|
+
readonly colliderVertices: Float32Array;
|
|
35
|
+
readonly colliderIndices: Uint32Array;
|
|
36
|
+
}
|
|
37
|
+
export declare function buildHighwayAsphaltTexture(): THREE.DataTexture;
|
|
38
|
+
/** Grows scenic meandering rural dirt spurs from the asphalt ring road toward the interior hills. */
|
|
39
|
+
export declare function planDirtSpurs(plan: IslandWorldPlan, count?: number): {
|
|
40
|
+
spurs: Road[];
|
|
41
|
+
junctions: TJunctionSpec[];
|
|
42
|
+
};
|
|
43
|
+
export declare function buildRoadRibbonGeometry(road: Road, opts?: RoadRibbonOptions): BuiltRoadRibbon;
|
|
44
|
+
export declare function buildCarvedTerrainGeometry(terrain: Terrain, size: number, segments?: number): BuiltCarvedTerrain;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playable terrain shaped around an open or closed road:
|
|
3
|
+
* - Exact physics height at road level across `halfWidth + verge`
|
|
4
|
+
* - Visual sub-road carve (`visualHeight` drops `-roadbedDrop` under `d <= halfWidth` to prevent Z-fighting)
|
|
5
|
+
* - Walkable smoothstep embankment (`SHOULDER_K = 1.6`) into the base island / noise heightmap
|
|
6
|
+
* - Continuous gravel/asphalt splat & foliage/spawn exclusion mask (`roadMask`)
|
|
7
|
+
*/
|
|
8
|
+
import { type FbmOptions } from "./random.js";
|
|
9
|
+
import type { Road, V3 } from "./road.js";
|
|
10
|
+
export interface TerrainOptions {
|
|
11
|
+
/** Wild-land height amplitude (metres) used when `baseHeight` is omitted and for spatial-hash reach bound. */
|
|
12
|
+
amplitude: number;
|
|
13
|
+
noise: FbmOptions;
|
|
14
|
+
/** Steepest slope a player can walk, in radians (shoulder never exceeds it). */
|
|
15
|
+
maxSlope: number;
|
|
16
|
+
/** Minimum shoulder width (metres) beyond the road edge. */
|
|
17
|
+
minShoulder: number;
|
|
18
|
+
/** Extra flat verge at road height beyond the edge (metres), e.g. for kerbs and lots. */
|
|
19
|
+
verge: number;
|
|
20
|
+
/** Optional pre-generated base heightmap (e.g. island heightmap pathfound BEFORE building the spline). */
|
|
21
|
+
baseHeight?: (x: number, z: number) => number;
|
|
22
|
+
/** Optional tight upper bound on |wild - roadY| (metres) when road was pathfound over `baseHeight`. */
|
|
23
|
+
maxCutFill?: number;
|
|
24
|
+
/** Optional additional roads (e.g. crossroads / T-junction branches) that also carve the terrain. */
|
|
25
|
+
extraRoads?: readonly Road[];
|
|
26
|
+
}
|
|
27
|
+
export interface NearestOnRoad {
|
|
28
|
+
/** Horizontal distance from the centreline (metres). */
|
|
29
|
+
distance: number;
|
|
30
|
+
/** Road surface height at the nearest point. */
|
|
31
|
+
height: number;
|
|
32
|
+
s: number;
|
|
33
|
+
}
|
|
34
|
+
export interface RoadSplatSample {
|
|
35
|
+
/** 1 inside carriageway, 0 outside kerb. */
|
|
36
|
+
readonly asphalt: number;
|
|
37
|
+
/** [0..1] gravel/dirt embankment blend across verge + shoulder. */
|
|
38
|
+
readonly gravel: number;
|
|
39
|
+
/** True where trees, boulders, and wild props must NOT spawn. */
|
|
40
|
+
readonly exclude: boolean;
|
|
41
|
+
/** Horizontal distance to road centreline (`Infinity` outside spatial reach). */
|
|
42
|
+
readonly distance: number;
|
|
43
|
+
}
|
|
44
|
+
export interface Terrain {
|
|
45
|
+
readonly road: Road;
|
|
46
|
+
/** Exact physics ground height at (x, z) — flush with road surface on carriageway. */
|
|
47
|
+
height(x: number, z: number): number;
|
|
48
|
+
/** Visual mesh height at (x, z) — drops `-roadbedDrop` under `d <= halfWidth` so grid triangles never poke through asphalt. */
|
|
49
|
+
visualHeight(x: number, z: number, roadbedDrop?: number): number;
|
|
50
|
+
/** Base wild land with no road carving/embankment. */
|
|
51
|
+
wild(x: number, z: number): number;
|
|
52
|
+
/** Nearest point on the road within spatial hash reach. */
|
|
53
|
+
nearest(x: number, z: number): NearestOnRoad | null;
|
|
54
|
+
/** Splatmap & foliage/building exclusion query at (x, z). */
|
|
55
|
+
roadMask(x: number, z: number): RoadSplatSample;
|
|
56
|
+
}
|
|
57
|
+
/** Smoothstep peaks at 1.5x the mean slope; 1.6 keeps the peak under `maxSlope` with margin. */
|
|
58
|
+
export declare const SHOULDER_K = 1.6;
|
|
59
|
+
/** Build terrain conforming to `road` over `o.baseHeight` (or seeded FBM wild land). */
|
|
60
|
+
export declare function makeTerrain(seed: number, road: Road, o: TerrainOptions): Terrain;
|
|
61
|
+
/** Row-major heightfield (`(n + 1) x (n + 1)` vertices) for Rapier `HeightfieldCollider` or visual mesh (`visualDrop > 0`). */
|
|
62
|
+
export declare function sampleHeightfield(t: Terrain, origin: V3, size: number, n: number, visualDrop?: number): Float32Array;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PS2 World Splat & Seed Types (`splat0`, `splat1`, `alphaMap`) for `Kolmo/src/world/`.
|
|
3
|
+
* Aligns `flipY = false` `N x N` RGBA8 grids 1:1 with `(x + size/2) / size`, `(z + size/2) / size` terrain UVs.
|
|
4
|
+
*/
|
|
5
|
+
import type { IslandWorldPlan } from "./island.js";
|
|
6
|
+
import type { Road } from "./road.js";
|
|
7
|
+
export declare function hashSeed(seed: string | number): number;
|
|
8
|
+
export declare class SplitMix32 {
|
|
9
|
+
private state;
|
|
10
|
+
constructor(seed: number);
|
|
11
|
+
next(): number;
|
|
12
|
+
range(min: number, max: number): number;
|
|
13
|
+
}
|
|
14
|
+
/** Fast deterministic 2D Simplex noise in [-1, 1] for stateless Macro-Cell world generation. */
|
|
15
|
+
export declare class SeededSimplex2D {
|
|
16
|
+
private readonly perm;
|
|
17
|
+
constructor(seed: number);
|
|
18
|
+
noise2D(xin: number, yin: number): number;
|
|
19
|
+
}
|
|
20
|
+
export interface WorldGenConfig {
|
|
21
|
+
readonly seed: number | string;
|
|
22
|
+
readonly size: number;
|
|
23
|
+
readonly gridCells: number;
|
|
24
|
+
readonly waterLevel: number;
|
|
25
|
+
}
|
|
26
|
+
export interface WorldGenResult {
|
|
27
|
+
readonly config: WorldGenConfig;
|
|
28
|
+
/** RGBA8 linear weights: [0]=DIRT, [1]=GRASS, [2]=SAND, [3]=ROCK */
|
|
29
|
+
readonly splat0: Uint8Array;
|
|
30
|
+
/** RGBA8 linear weights: [4]=GRAVEL, [5]=FOREST, [6]=SNOW, [7]=ASPHALT */
|
|
31
|
+
readonly splat1: Uint8Array;
|
|
32
|
+
/** R8 cutout mask: 255 = solid terrain, 0 = cave/bunker portal cutout */
|
|
33
|
+
readonly alphaMap: Uint8Array;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Bakes `splat0`, `splat1`, and `alphaMap` (`N x N`, `flipY = false`) from an `IslandWorldPlan`
|
|
37
|
+
* and optional meandering rural `dirtRoads` so road embankments & skirts lock seamlessly to terrain texels.
|
|
38
|
+
*/
|
|
39
|
+
export declare function bakeWorldSplatMaps(plan: IslandWorldPlan, gridCells?: number, dirtRoads?: readonly Road[]): WorldGenResult;
|