@pinkaphant/kolmo 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +16 -14
- package/bin/kolmo.mjs +19 -54
- package/dist/body/HeldItem.d.ts +22 -0
- package/dist/body/HeldItem.js +171 -0
- package/dist/body/KhrBody.d.ts +26 -0
- package/dist/body/KhrBody.js +179 -0
- package/dist/body/bodySi.d.ts +59 -0
- package/dist/body/bodySi.js +61 -0
- package/dist/body/index.d.ts +3 -0
- package/dist/body/index.js +4 -0
- package/dist/engine/index.d.ts +4 -4
- package/dist/engine/index.js +12 -3
- package/dist/engine/kolmoActor.d.ts +11 -4
- package/dist/engine/kolmoActor.js +197 -0
- package/dist/engine/kolmoInput.d.ts +12 -0
- package/dist/engine/kolmoInput.js +80 -0
- package/dist/engine/kolmoIsland.d.ts +3 -1
- package/dist/engine/kolmoIsland.js +311 -0
- package/dist/engine/kolmoLongDrive.js +223 -0
- package/dist/engine/kolmoRigs.js +59 -0
- package/dist/engine/kolmoStore.d.ts +53 -27
- package/dist/engine/kolmoStore.js +211 -0
- package/dist/engine/kolmoSurface.d.ts +1 -1
- package/dist/engine/kolmoSurface.js +182 -0
- package/dist/engine/kolmoVehicle.d.ts +2 -1
- package/dist/engine/kolmoVehicle.js +244 -0
- package/dist/engine/kolmoVehicleDriver.d.ts +30 -0
- package/dist/engine/kolmoVehicleDriver.js +38 -0
- package/dist/engine/kolmoWorld.d.ts +7 -15
- package/dist/engine/kolmoWorld.js +136 -0
- package/dist/engine/longDriveKit.d.ts +4 -2
- package/dist/engine/longDriveKit.js +254 -0
- package/dist/engine/mainlandMacroCell.d.ts +3 -7
- package/dist/engine/mainlandMacroCell.js +247 -0
- package/dist/engine/shiftedFixedBody.d.ts +13 -0
- package/dist/engine/shiftedFixedBody.js +64 -0
- package/dist/importer/ChopShopPanel.js +465 -0
- package/dist/importer/DomainWorkshopPanel.d.ts +9 -4
- package/dist/importer/DomainWorkshopPanel.js +385 -0
- package/dist/importer/GateHudBar.js +312 -0
- package/dist/importer/GlbImportGate.js +250 -0
- package/dist/importer/ImperativeVehicleRig.js +336 -0
- package/dist/importer/ImporterPlinthUikitTags.js +112 -0
- package/dist/importer/Step1CalibrationPlinth.js +275 -0
- package/dist/importer/Step2UniversalPad.js +244 -0
- package/dist/importer/VfxEmitterPool.js +91 -0
- package/dist/importer/chopShopActions.d.ts +22 -2
- package/dist/importer/chopShopActions.js +232 -0
- package/dist/importer/gateStore.d.ts +1 -1
- package/dist/importer/gateStore.js +92 -0
- package/dist/importer/glbNormalizer.js +133 -0
- package/dist/importer/importerWebMcp.d.ts +17 -6
- package/dist/importer/importerWebMcp.js +343 -0
- package/dist/importer/index.js +22 -3
- package/dist/importer/khrCompiler.d.ts +1 -1
- package/dist/importer/khrCompiler.js +434 -0
- package/dist/importer/launcherBake.js +51 -0
- package/dist/importer/meshIslands.d.ts +1 -1
- package/dist/importer/meshIslands.js +301 -0
- package/dist/importer/surfaceCutter.js +254 -0
- package/dist/importer/surfaceTopology.js +183 -0
- package/dist/importer/universalGateBake.js +162 -0
- package/dist/importer/usdToGlb.js +294 -0
- package/dist/importer/useChopShopController.d.ts +11 -2
- package/dist/importer/useChopShopController.js +364 -0
- package/dist/importer/vehiclePanelAnim.js +214 -0
- package/dist/importer/wheelAxlePairing.d.ts +1 -2
- package/dist/importer/wheelAxlePairing.js +102 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +69 -14
- package/dist/junk/DestructibleTarget.js +154 -0
- package/dist/junk/KolmoJunk.js +65 -0
- package/dist/junk/ShardPieces.d.ts +6 -4
- package/dist/junk/ShardPieces.js +74 -0
- package/dist/junk/TargetDecals.js +51 -0
- package/dist/junk/bvhShatter.js +55 -0
- package/dist/junk/bvhTriCollector.js +78 -0
- package/dist/junk/index.js +11 -1
- package/dist/junk/junkGeometry.js +69 -0
- package/dist/junk/junkImportSanitize.js +54 -0
- package/dist/junk/junkImporter.js +95 -0
- package/dist/junk/junkLabelCanvas.js +67 -0
- package/dist/junk/junkLabels.js +35 -0
- package/dist/junk/targetHelpers.js +103 -0
- package/dist/junk/targetHitLogic.js +128 -0
- package/dist/junk/useTargetAssets.js +102 -0
- package/dist/physics/index.d.ts +26 -0
- package/dist/physics/index.js +84 -0
- package/dist/schema/kolmoSchema.d.ts +2 -1
- package/dist/schema/kolmoSchema.js +184 -0
- package/dist/shaders/celestialBackdrop.d.ts +1 -1
- package/dist/shaders/celestialBackdrop.js +344 -0
- package/dist/shaders/index.d.ts +0 -1
- package/dist/shaders/index.js +9 -1
- package/dist/shaders/plumeAndSparkle.js +271 -0
- package/dist/shaders/ps2GlslShared.d.ts +1 -1
- package/dist/shaders/ps2GlslShared.js +3 -0
- package/dist/shaders/ps2MaterialsTSL.js +65 -0
- package/dist/shaders/ps2MaterialsWebGL.js +40 -0
- package/dist/shaders/ps2RoadWebGL.js +101 -0
- package/dist/shaders/ps2TerrainWebGL.js +54 -0
- package/dist/shaders/ps2Textures.js +224 -0
- package/dist/shaders/retroPalettes.js +188 -0
- package/dist/shaders/retroShader.d.ts +31 -3
- package/dist/shaders/retroShader.js +249 -0
- package/dist/shaders/tsl.d.ts +1 -0
- package/dist/shaders/tsl.js +1 -0
- package/dist/vite/index.d.ts +15 -0
- package/dist/vite/index.js +90 -0
- package/dist/world/frontage.js +32 -0
- package/dist/world/index.d.ts +1 -1
- package/dist/world/index.js +11 -3
- package/dist/world/infiniteWorld2D.js +244 -0
- package/dist/world/island.js +201 -0
- package/dist/world/macroCellSchema.js +27 -0
- package/dist/world/macroKnightAStar.js +171 -0
- package/dist/world/random.js +33 -0
- package/dist/world/road.js +136 -0
- package/dist/world/roadRibbon.d.ts +6 -6
- package/dist/world/roadRibbon.js +161 -0
- package/dist/world/terrain.js +87 -0
- package/dist/world/worldTypes.js +111 -0
- package/package.json +36 -19
- package/dist/engine-BeKvBM8d.js +0 -1745
- package/dist/importer-D9bdcGTh.js +0 -5113
- package/dist/junk-B4bC1zAl.js +0 -1049
- package/dist/kolmoSurface-DTnrFXH0.js +0 -558
- package/dist/shaders-GS71Ek1A.js +0 -1383
- package/dist/world-PRWPYrlx.js +0 -947
- package/dist/worldTypes-Z0KfdCd0.js +0 -226
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { createPS2TerrainMaterialWebGL as e } from "../shaders/ps2TerrainWebGL.js";
|
|
2
|
+
import { createPS2WorldTextures as t } from "../shaders/ps2Textures.js";
|
|
3
|
+
import { C12TileKind as n, MACRO_SIZE_M as r } from "../world/macroCellSchema.js";
|
|
4
|
+
import { buildCarvedTerrainGeometry as i, buildRoadRibbonGeometry as a } from "../world/roadRibbon.js";
|
|
5
|
+
import { makeTerrain as o } from "../world/terrain.js";
|
|
6
|
+
import { roadFromPoints as s } from "../world/road.js";
|
|
7
|
+
import { InstancedC12Piece as c, InstancedWorldGlb as l, RoadsideStopCompound as u } from "./longDriveKit.js";
|
|
8
|
+
import { ShiftedFixedBody as d, bakeMacroCellSplat as f } from "./shiftedFixedBody.js";
|
|
9
|
+
import { useEffect as p, useMemo as m } from "react";
|
|
10
|
+
import * as h from "three";
|
|
11
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
12
|
+
import { TrimeshCollider as v } from "@react-three/rapier";
|
|
13
|
+
// src/engine/mainlandMacroCell.tsx
|
|
14
|
+
function y({ mx: y, mz: b, planner: x, roadMat: S, terrainMat: C, offX: w, offZ: T, renderExtra: E }) {
|
|
15
|
+
let D = m(() => {
|
|
16
|
+
let c = x.generateMacroCell2D(y, b), l = Math.max(2.5, x.sampleMainlandHeight(c.hubX, c.hubZ)), u = (e, t) => {
|
|
17
|
+
let n = x.sampleMainlandHeight(e, t);
|
|
18
|
+
if (c.settlementRadiusM <= 0) return n;
|
|
19
|
+
let r = Math.hypot(e - c.hubX, t - c.hubZ);
|
|
20
|
+
if (r <= c.settlementRadiusM) return l;
|
|
21
|
+
let i = (r - c.settlementRadiusM) / 96;
|
|
22
|
+
return i >= 1 ? n : l + (n - l) * (i * i * (3 - 2 * i));
|
|
23
|
+
}, d = c.highwayPolylines.filter((e) => e.length >= 2).map((e) => {
|
|
24
|
+
let t = e.map(([e, t]) => [
|
|
25
|
+
e,
|
|
26
|
+
Math.max(2, u(e, t)),
|
|
27
|
+
t
|
|
28
|
+
]);
|
|
29
|
+
for (let e = 0; e < 4; e++) for (let e = 1; e < t.length - 1; e++) t[e] = [
|
|
30
|
+
t[e][0],
|
|
31
|
+
.5 * t[e][1] + .25 * (t[e - 1][1] + t[e + 1][1]),
|
|
32
|
+
t[e][2]
|
|
33
|
+
];
|
|
34
|
+
return s(t, 4.5, 4, !1);
|
|
35
|
+
}), p = d.map((e) => a(e)), m = d[0] ?? s([[
|
|
36
|
+
c.originWorldX - 20,
|
|
37
|
+
l,
|
|
38
|
+
c.originWorldZ
|
|
39
|
+
], [
|
|
40
|
+
c.originWorldX + 20,
|
|
41
|
+
l,
|
|
42
|
+
c.originWorldZ
|
|
43
|
+
]], 4.5, 4, !1), g = o(y * 73856093 ^ b * 19349663, m, {
|
|
44
|
+
amplitude: 28,
|
|
45
|
+
noise: {
|
|
46
|
+
wavelength: 300,
|
|
47
|
+
octaves: 2,
|
|
48
|
+
gain: .5,
|
|
49
|
+
lacunarity: 2
|
|
50
|
+
},
|
|
51
|
+
maxSlope: .55,
|
|
52
|
+
minShoulder: 12,
|
|
53
|
+
verge: 18,
|
|
54
|
+
baseHeight: u,
|
|
55
|
+
maxCutFill: 16,
|
|
56
|
+
extraRoads: d.slice(1)
|
|
57
|
+
}), _ = {
|
|
58
|
+
...g,
|
|
59
|
+
height: (e, t) => g.height(c.originWorldX + e, c.originWorldZ + t),
|
|
60
|
+
visualHeight: (e, t, n) => g.visualHeight(c.originWorldX + e, c.originWorldZ + t, n),
|
|
61
|
+
roadMask: (e, t) => g.roadMask(c.originWorldX + e, c.originWorldZ + t)
|
|
62
|
+
}, v = i(_, r, 96), S = C ? null : t(f(y, b, c, _)), w = S ? e(S) : null, T = new h.Object3D(), E = [], D = [], O = [], k = [], A = [], j = [], M = [], N = [], P = [], F = [], I = [];
|
|
63
|
+
for (let e of d) for (let t = 36; t < e.length - 36; t += 48) {
|
|
64
|
+
let n = e.at(t);
|
|
65
|
+
T.position.set(n.pos[0] + n.left[0] * 6.8, n.pos[1], n.pos[2] + n.left[2] * 6.8), T.rotation.set(0, Math.atan2(n.tangent[0], n.tangent[2]), 0), T.scale.set(1, 1, 1), T.updateMatrix(), E.push(...T.matrix.elements);
|
|
66
|
+
}
|
|
67
|
+
if (c.settlementRadiusM > 0) {
|
|
68
|
+
let e = Math.min(84, Math.ceil(c.settlementRadiusM / 3));
|
|
69
|
+
for (let t = -e; t <= e; t++) for (let r = -e; r <= e; r++) {
|
|
70
|
+
let e = c.hubX + r * 3 + 1.5, i = c.hubZ + t * 3 + 1.5, a = x.classifySettlementC12Tile(e, i, c);
|
|
71
|
+
a < n.ROAD_LANE || a > n.C12_PLAZA_HUB || (T.position.set(e, l + .02, i), T.rotation.set(0, 0, 0), T.scale.set(1, 1, 1), T.updateMatrix(), a === n.CROSSWALK ? O.push(...T.matrix.elements) : a === n.INTERSECTION_BOX || a === n.C12_PLAZA_HUB ? k.push(...T.matrix.elements) : a === n.CURB_RAMP_CORNER ? j.push(...T.matrix.elements) : a === n.CURB_DRIVEWAY ? M.push(...T.matrix.elements) : a === n.CURB_STRAIGHT || a === n.BOULEVARD_MEDIAN ? A.push(...T.matrix.elements) : D.push(...T.matrix.elements));
|
|
72
|
+
}
|
|
73
|
+
for (let e of c.parcels.slice(0, 140)) {
|
|
74
|
+
let t = e.zone === "COMMERCIAL" ? 4 : e.zone === "INDUSTRIAL" ? 2 : 1, n = e.zone === "COMMERCIAL" ? P : e.zone === "INDUSTRIAL" ? F : N, r = Math.max(2, Math.floor((e.width - 3) / 3)), i = Math.max(2, Math.floor((e.depth - 3) / 3));
|
|
75
|
+
for (let a = 0; a < t; a++) {
|
|
76
|
+
let t = l + a * 3 + 1.5;
|
|
77
|
+
for (let a = 0; a < r; a++) for (let [r, o] of [[0, 0], [i * 3, Math.PI]]) T.position.set(e.minX + 1.5 + a * 3 + 1.5, t, e.minZ + 1.5 + r), T.rotation.set(0, o, 0), T.scale.set(1, 1, 1), T.updateMatrix(), n.push(...T.matrix.elements);
|
|
78
|
+
}
|
|
79
|
+
for (let n = 0; n < i; n++) for (let i = 0; i < r; i++) T.position.set(e.minX + 3 + i * 3, l + t * 3 + .12, e.minZ + 3 + n * 3), T.rotation.set(0, 0, 0), T.scale.set(1, 1, 1), T.updateMatrix(), I.push(...T.matrix.elements);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
let L = c.civicHubBatches.find((e) => e.kind === "FoundationSquare")?.matrices ?? /* @__PURE__ */ new Float32Array(), R = c.civicHubBatches.find((e) => e.kind === "FoundationTriangle")?.matrices ?? /* @__PURE__ */ new Float32Array();
|
|
83
|
+
return {
|
|
84
|
+
plan2d: c,
|
|
85
|
+
ribbons: p,
|
|
86
|
+
terrainGeo: v,
|
|
87
|
+
shiftedTerrain: _,
|
|
88
|
+
cellTex: S,
|
|
89
|
+
cellTerrain: w,
|
|
90
|
+
poles: new Float32Array(E),
|
|
91
|
+
rdStr: new Float32Array(D),
|
|
92
|
+
rdCw: new Float32Array(O),
|
|
93
|
+
rdInt: new Float32Array(k),
|
|
94
|
+
cbStr: new Float32Array(A),
|
|
95
|
+
cbRmp: new Float32Array(j),
|
|
96
|
+
cbDrv: new Float32Array(M),
|
|
97
|
+
wallRes: new Float32Array(N),
|
|
98
|
+
wallCom: new Float32Array(P),
|
|
99
|
+
wallInd: new Float32Array(F),
|
|
100
|
+
roofAll: new Float32Array(I),
|
|
101
|
+
sqHub: L,
|
|
102
|
+
triHub: R
|
|
103
|
+
};
|
|
104
|
+
}, [
|
|
105
|
+
y,
|
|
106
|
+
b,
|
|
107
|
+
x,
|
|
108
|
+
C
|
|
109
|
+
]);
|
|
110
|
+
p(() => () => {
|
|
111
|
+
D.terrainGeo.geometry.dispose(), D.ribbons.forEach((e) => e.geometry.dispose()), D.cellTerrain?.material.dispose(), D.cellTerrain?.depthMaterial.dispose(), D.cellTex?.dispose();
|
|
112
|
+
}, [D]);
|
|
113
|
+
let O = C ?? D.cellTerrain.material;
|
|
114
|
+
return /* @__PURE__ */ _("group", { children: [
|
|
115
|
+
/* @__PURE__ */ _(d, {
|
|
116
|
+
x: D.plan2d.originWorldX + w,
|
|
117
|
+
z: D.plan2d.originWorldZ + T,
|
|
118
|
+
friction: .9,
|
|
119
|
+
children: [/* @__PURE__ */ g(v, { args: [D.terrainGeo.colliderVertices, D.terrainGeo.colliderIndices] }), /* @__PURE__ */ g("mesh", {
|
|
120
|
+
geometry: D.terrainGeo.geometry,
|
|
121
|
+
material: O,
|
|
122
|
+
receiveShadow: !0
|
|
123
|
+
})]
|
|
124
|
+
}),
|
|
125
|
+
D.ribbons.map((e, t) => /* @__PURE__ */ _(d, {
|
|
126
|
+
x: w,
|
|
127
|
+
z: T,
|
|
128
|
+
friction: 1.05,
|
|
129
|
+
children: [/* @__PURE__ */ g(v, { args: [e.colliderVertices, e.colliderIndices] }), /* @__PURE__ */ g("mesh", {
|
|
130
|
+
geometry: e.geometry,
|
|
131
|
+
material: S,
|
|
132
|
+
receiveShadow: !0
|
|
133
|
+
})]
|
|
134
|
+
}, `hwy_${t}`)),
|
|
135
|
+
/* @__PURE__ */ _("group", {
|
|
136
|
+
position: [
|
|
137
|
+
w,
|
|
138
|
+
0,
|
|
139
|
+
T
|
|
140
|
+
],
|
|
141
|
+
children: [
|
|
142
|
+
/* @__PURE__ */ g(l, {
|
|
143
|
+
kitKey: "light_pole",
|
|
144
|
+
fitSpan: [
|
|
145
|
+
.6,
|
|
146
|
+
6.8,
|
|
147
|
+
.6
|
|
148
|
+
],
|
|
149
|
+
matrices: D.poles
|
|
150
|
+
}),
|
|
151
|
+
/* @__PURE__ */ g(l, {
|
|
152
|
+
kitKey: "road_straight",
|
|
153
|
+
fitSpan: [
|
|
154
|
+
3,
|
|
155
|
+
.08,
|
|
156
|
+
3
|
|
157
|
+
],
|
|
158
|
+
matrices: D.rdStr
|
|
159
|
+
}),
|
|
160
|
+
/* @__PURE__ */ g(l, {
|
|
161
|
+
kitKey: "road_crosswalk",
|
|
162
|
+
fitSpan: [
|
|
163
|
+
3,
|
|
164
|
+
.08,
|
|
165
|
+
3
|
|
166
|
+
],
|
|
167
|
+
matrices: D.rdCw
|
|
168
|
+
}),
|
|
169
|
+
/* @__PURE__ */ g(l, {
|
|
170
|
+
kitKey: "road_intersection",
|
|
171
|
+
fitSpan: [
|
|
172
|
+
3,
|
|
173
|
+
.08,
|
|
174
|
+
3
|
|
175
|
+
],
|
|
176
|
+
matrices: D.rdInt
|
|
177
|
+
}),
|
|
178
|
+
/* @__PURE__ */ g(l, {
|
|
179
|
+
kitKey: "curb_straight",
|
|
180
|
+
fitSpan: [
|
|
181
|
+
3,
|
|
182
|
+
.18,
|
|
183
|
+
3
|
|
184
|
+
],
|
|
185
|
+
matrices: D.cbStr
|
|
186
|
+
}),
|
|
187
|
+
/* @__PURE__ */ g(l, {
|
|
188
|
+
kitKey: "curb_ramp",
|
|
189
|
+
fitSpan: [
|
|
190
|
+
3,
|
|
191
|
+
.18,
|
|
192
|
+
3
|
|
193
|
+
],
|
|
194
|
+
matrices: D.cbRmp
|
|
195
|
+
}),
|
|
196
|
+
/* @__PURE__ */ g(l, {
|
|
197
|
+
kitKey: "curb_driveway",
|
|
198
|
+
fitSpan: [
|
|
199
|
+
3,
|
|
200
|
+
.14,
|
|
201
|
+
3
|
|
202
|
+
],
|
|
203
|
+
matrices: D.cbDrv
|
|
204
|
+
}),
|
|
205
|
+
/* @__PURE__ */ g(c, {
|
|
206
|
+
matrices: D.sqHub,
|
|
207
|
+
kind: "square",
|
|
208
|
+
color: "#94a3b8"
|
|
209
|
+
}),
|
|
210
|
+
/* @__PURE__ */ g(c, {
|
|
211
|
+
matrices: D.triHub,
|
|
212
|
+
kind: "triangle",
|
|
213
|
+
color: "#cbd5e1"
|
|
214
|
+
}),
|
|
215
|
+
/* @__PURE__ */ g(c, {
|
|
216
|
+
matrices: D.wallRes,
|
|
217
|
+
kind: "wall",
|
|
218
|
+
color: "#d6c7b2"
|
|
219
|
+
}),
|
|
220
|
+
/* @__PURE__ */ g(c, {
|
|
221
|
+
matrices: D.wallCom,
|
|
222
|
+
kind: "wall",
|
|
223
|
+
color: "#38bdf8"
|
|
224
|
+
}),
|
|
225
|
+
/* @__PURE__ */ g(c, {
|
|
226
|
+
matrices: D.wallInd,
|
|
227
|
+
kind: "wall",
|
|
228
|
+
color: "#b45309"
|
|
229
|
+
}),
|
|
230
|
+
/* @__PURE__ */ g(c, {
|
|
231
|
+
matrices: D.roofAll,
|
|
232
|
+
kind: "roof",
|
|
233
|
+
color: "#334155"
|
|
234
|
+
})
|
|
235
|
+
]
|
|
236
|
+
}),
|
|
237
|
+
D.plan2d.roadsideStops.map((e, t) => /* @__PURE__ */ g(u, {
|
|
238
|
+
stop: e,
|
|
239
|
+
groundY: Math.max(2, D.shiftedTerrain.height(e.worldX - D.plan2d.originWorldX, e.worldZ - D.plan2d.originWorldZ)),
|
|
240
|
+
offX: w,
|
|
241
|
+
offZ: T,
|
|
242
|
+
cellTag: `stop_${y}_${b}_${t}`
|
|
243
|
+
}, `stop_${t}`)),
|
|
244
|
+
E?.(y, b, D.plan2d, w, T)
|
|
245
|
+
] });
|
|
246
|
+
}
|
|
247
|
+
export { y as MainlandMacroCell, d as ShiftedFixedBody };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type MacroCellPlan2D, type Terrain, type WorldGenResult } from "../world/index.js";
|
|
3
|
+
export interface ShiftedFixedBodyProps {
|
|
4
|
+
readonly x: number;
|
|
5
|
+
readonly y?: number;
|
|
6
|
+
readonly z: number;
|
|
7
|
+
readonly yaw?: number;
|
|
8
|
+
readonly friction?: number;
|
|
9
|
+
readonly userData?: Record<string, unknown>;
|
|
10
|
+
readonly children: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export declare function ShiftedFixedBody({ x, y, z, yaw, friction, userData, children, }: ShiftedFixedBodyProps): React.JSX.Element;
|
|
13
|
+
export declare function bakeMacroCellSplat(mx: number, mz: number, plan2d: MacroCellPlan2D, shiftedTerrain: Terrain): WorldGenResult;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { MACRO_SIZE_M as e } from "../world/macroCellSchema.js";
|
|
2
|
+
import { useLayoutEffect as t, useRef as n } from "react";
|
|
3
|
+
import * as r from "three";
|
|
4
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
5
|
+
import { RigidBody as a } from "@react-three/rapier";
|
|
6
|
+
// src/engine/shiftedFixedBody.tsx
|
|
7
|
+
var o = new r.Euler(), s = new r.Quaternion();
|
|
8
|
+
function c({ x: e, y: r = 0, z: c, yaw: l = 0, friction: u = 1, userData: d, children: f }) {
|
|
9
|
+
let p = n(null);
|
|
10
|
+
return t(() => {
|
|
11
|
+
let t = p.current;
|
|
12
|
+
t && (t.setTranslation({
|
|
13
|
+
x: e,
|
|
14
|
+
y: r,
|
|
15
|
+
z: c
|
|
16
|
+
}, !1), o.set(0, l, 0), s.setFromEuler(o), t.setRotation(s, !1));
|
|
17
|
+
}, [
|
|
18
|
+
e,
|
|
19
|
+
r,
|
|
20
|
+
c,
|
|
21
|
+
l
|
|
22
|
+
]), /* @__PURE__ */ i(a, {
|
|
23
|
+
ref: p,
|
|
24
|
+
type: "fixed",
|
|
25
|
+
position: [
|
|
26
|
+
e,
|
|
27
|
+
r,
|
|
28
|
+
c
|
|
29
|
+
],
|
|
30
|
+
rotation: [
|
|
31
|
+
0,
|
|
32
|
+
l,
|
|
33
|
+
0
|
|
34
|
+
],
|
|
35
|
+
colliders: !1,
|
|
36
|
+
friction: u,
|
|
37
|
+
...d === void 0 ? {} : { userData: d },
|
|
38
|
+
children: f
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function l(t, n, r, i) {
|
|
42
|
+
let a = e * .5, o = /* @__PURE__ */ new Uint8Array(9216);
|
|
43
|
+
o.fill(255);
|
|
44
|
+
let s = /* @__PURE__ */ new Uint8Array(36864), c = /* @__PURE__ */ new Uint8Array(36864);
|
|
45
|
+
for (let t = 0; t < 96; t++) {
|
|
46
|
+
let n = -a + t / 95 * e;
|
|
47
|
+
for (let o = 0; o < 96; o++) {
|
|
48
|
+
let l = -a + o / 95 * e, u = (t * 96 + o) * 4, d = i.height(l, n), f = i.roadMask(l, n), p = r.originWorldX + l, m = r.originWorldZ + n, h = r.settlementRadiusM > 0 && Math.hypot(p - r.hubX, m - r.hubZ) <= r.settlementRadiusM;
|
|
49
|
+
f.asphalt > .35 ? (c[u + 3] = 230, c[u] = 25) : f.gravel > .15 || h ? (c[u] = h ? 175 : Math.round(190 * f.gravel), s[u] = 65, s[u + 1] = 35) : d > 44 ? (c[u + 2] = 190, s[u + 3] = 65) : d > 24 ? (s[u + 3] = 125, c[u + 1] = 95, s[u] = 35) : (s[u + 1] = 145, c[u + 1] = 75, s[u] = 35);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
config: {
|
|
54
|
+
seed: `mc_${t}_${n}`,
|
|
55
|
+
size: e,
|
|
56
|
+
gridCells: 96,
|
|
57
|
+
waterLevel: 0
|
|
58
|
+
},
|
|
59
|
+
alphaMap: o,
|
|
60
|
+
splat0: s,
|
|
61
|
+
splat1: c
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export { c as ShiftedFixedBody, l as bakeMacroCellSplat };
|