@threenative/terrain 0.1.9 → 0.1.12
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 +40 -59
- package/THIRD_PARTY_NOTICES.md +2 -1
- package/dist/bake-DJ5cxg0C.d.ts +82 -0
- package/dist/editor/index.d.ts +4 -4
- package/dist/editor/index.js +130 -128
- package/dist/editor/server.d.ts +2 -2
- package/dist/editor/server.js +38 -35
- package/dist/editor/worker.d.ts +1 -1
- package/dist/editor/worker.js +101 -101
- package/dist/export.d.ts +1 -1
- package/dist/index.d.ts +156 -273
- package/dist/index.js +562 -378
- package/dist/kit-world.d.ts +107 -0
- package/dist/kit-world.js +5134 -0
- package/dist/kit.d.ts +21 -4
- package/dist/kit.js +337 -223
- package/dist/mcp/cook-child.js +1963 -1543
- package/dist/mcp/server.js +716 -429
- package/dist/prop-package-Dwz0EWoB.d.ts +141 -0
- package/dist/{server-B5RdvEAC.d.ts → server-LnFwY8sr.d.ts} +1 -1
- package/dist/starter.d.ts +1142 -7
- package/dist/starter.js +2102 -120
- package/dist/{terrain-CAEaW0mQ.d.ts → terrain-DYCyAOCJ.d.ts} +1 -1
- package/dist/three.d.ts +1 -1
- package/dist/three.js +1 -1
- package/dist/{types-BpH00qsx.d.ts → types-kpI0C4hW.d.ts} +1 -1
- package/dist/{world-package-B8QgHjAQ.d.ts → world-package-DqJC3-Nn.d.ts} +2 -2
- package/docs/authoring/editor.md +73 -0
- package/docs/authoring/new-environment.md +97 -0
- package/docs/authoring/recipes.md +97 -0
- package/docs/authoring/world-export.md +66 -0
- package/package.json +24 -8
- package/starter/alpine/README.md +22 -12
- package/starter/alpine/bake.mjs +14 -1
- package/starter/alpine/biome.data.json +187 -25
- package/starter/alpine/heightmap.r16 +0 -0
- package/starter/alpine/playerRig.ts +89 -0
- package/starter/alpine/recipe.json +169 -15
- package/starter/alpine/render/bakedFile.ts +17 -0
- package/starter/alpine/render/benchmark.ts +77 -0
- package/starter/alpine/render/biomeData.ts +14 -0
- package/starter/alpine/render/biomes.ts +687 -0
- package/starter/alpine/render/ground/cover.ts +565 -0
- package/starter/alpine/render/ground/horizon.ts +219 -0
- package/starter/alpine/render/ground/palette.d.ts +1 -0
- package/starter/alpine/render/ground/palette.js +11 -0
- package/starter/alpine/render/ground/scatter.ts +104 -0
- package/starter/alpine/render/ground/terrain.ts +1860 -0
- package/starter/alpine/render/kitAssets.ts +28 -0
- package/starter/alpine/render/loading.ts +354 -0
- package/starter/alpine/render/lookKnobs.ts +37 -0
- package/starter/alpine/render/orbitCamera.ts +155 -0
- package/starter/alpine/render/props/farForest.ts +94 -0
- package/starter/alpine/render/props/pack.ts +1114 -0
- package/starter/alpine/render/props/prepared.ts +225 -0
- package/starter/alpine/render/props/propMaterials.ts +1239 -0
- package/starter/alpine/render/props/propProgress.ts +2 -0
- package/starter/alpine/render/props/propWorld.ts +105 -0
- package/starter/alpine/render/props/props.ts +633 -0
- package/starter/alpine/render/props/spruce.ts +440 -0
- package/starter/alpine/render/sky/atmosphere.ts +329 -0
- package/starter/alpine/render/sky/sky.ts +382 -0
- package/starter/alpine/render/texturePreparation.ts +135 -0
- package/starter/alpine/render/water/river.ts +1132 -0
- package/starter/alpine/render/worldNames.ts +6 -0
- package/starter/alpine/scene.ts +715 -0
- package/starter/alpine/sceneProps.ts +561 -0
- package/starter/alpine/sceneState.ts +33 -0
- package/starter/alpine/world/terrainAssets.ts +145 -0
- package/starter/alpine/world/walkBand.ts +47 -0
- package/starter/alpine/world/water.ts +74 -0
- package/starter/alpine/worlds.ts +13 -0
- package/starter/arbor/wind.ts +84 -0
- package/starter/coastal/README.md +26 -25
- package/starter/coastal/assets.json +10 -0
- package/starter/coastal/bake.mjs +14 -1
- package/starter/coastal/biome.data.json +18 -3
- package/starter/coastal/playerRig.ts +89 -0
- package/starter/coastal/recipe.json +220 -18
- package/starter/coastal/render/bakedFile.ts +17 -0
- package/starter/coastal/render/benchmark.ts +81 -0
- package/starter/coastal/render/biomeData.ts +14 -0
- package/starter/coastal/render/biomes.ts +678 -0
- package/starter/coastal/render/ground/cover.ts +565 -0
- package/starter/coastal/render/ground/horizon.ts +219 -0
- package/starter/coastal/render/ground/palette.d.ts +1 -0
- package/starter/coastal/render/ground/palette.js +11 -0
- package/starter/coastal/render/ground/scatter.ts +104 -0
- package/starter/coastal/render/ground/terrain.ts +1829 -0
- package/starter/coastal/render/kitAssets.ts +28 -0
- package/starter/coastal/render/loading.ts +354 -0
- package/starter/coastal/render/lookKnobs.ts +37 -0
- package/starter/coastal/render/orbitCamera.ts +155 -0
- package/starter/coastal/render/props/farForest.ts +94 -0
- package/starter/coastal/render/props/pack.ts +1109 -0
- package/starter/coastal/render/props/prepared.ts +225 -0
- package/starter/coastal/render/props/propMaterials.ts +1239 -0
- package/starter/coastal/render/props/propProgress.ts +2 -0
- package/starter/coastal/render/props/propWorld.ts +105 -0
- package/starter/coastal/render/props/props.ts +633 -0
- package/starter/coastal/render/props/spruce.ts +440 -0
- package/starter/coastal/render/sky/atmosphere.ts +329 -0
- package/starter/coastal/render/sky/sky.ts +382 -0
- package/starter/coastal/render/texturePreparation.ts +135 -0
- package/starter/coastal/render/water/ocean.ts +284 -0
- package/starter/coastal/render/water/river.ts +1132 -0
- package/starter/coastal/render/worldNames.ts +6 -0
- package/starter/coastal/scene.ts +740 -0
- package/starter/coastal/sceneProps.ts +559 -0
- package/starter/coastal/sceneState.ts +33 -0
- package/starter/coastal/world/terrainAssets.ts +151 -0
- package/starter/coastal/world/walkBand.ts +47 -0
- package/starter/coastal/world/water.ts +74 -0
- package/starter/coastal/worlds.ts +13 -0
- package/starter/desert/README.md +51 -23
- package/starter/desert/bake-flora.mjs +142 -0
- package/starter/desert/bake-rocks.mjs +291 -0
- package/starter/desert/bake.mjs +14 -1
- package/starter/desert/biome.data.json +24 -12
- package/starter/desert/playerRig.ts +89 -0
- package/starter/desert/recipe.json +63 -16
- package/starter/desert/render/bakedFile.ts +17 -0
- package/starter/desert/render/benchmark.ts +79 -0
- package/starter/desert/render/biomeData.ts +14 -0
- package/starter/desert/render/biomes.ts +660 -0
- package/starter/desert/render/ground/cover.ts +565 -0
- package/starter/desert/render/ground/debris.ts +136 -0
- package/starter/desert/render/ground/horizon.ts +219 -0
- package/starter/desert/render/ground/palette.d.ts +1 -0
- package/starter/desert/render/ground/palette.js +11 -0
- package/starter/desert/render/ground/scatter.ts +104 -0
- package/starter/desert/render/ground/terrain.ts +1854 -0
- package/starter/desert/render/kitAssets.ts +28 -0
- package/starter/desert/render/loading.ts +354 -0
- package/starter/desert/render/lookKnobs.ts +37 -0
- package/starter/desert/render/orbitCamera.ts +155 -0
- package/starter/desert/render/props/farForest.ts +96 -0
- package/starter/desert/render/props/formations.ts +630 -0
- package/starter/desert/render/props/pack.ts +1195 -0
- package/starter/desert/render/props/prepared.ts +225 -0
- package/starter/desert/render/props/propMaterials.ts +1255 -0
- package/starter/desert/render/props/propProgress.ts +2 -0
- package/starter/desert/render/props/propWorld.ts +105 -0
- package/starter/desert/render/props/props.ts +624 -0
- package/starter/desert/render/props/spruce.ts +440 -0
- package/starter/desert/render/sand.ts +581 -0
- package/starter/desert/render/sky/atmosphere.ts +329 -0
- package/starter/desert/render/sky/sky.ts +382 -0
- package/starter/desert/render/texturePreparation.ts +135 -0
- package/starter/desert/render/water/river.ts +1132 -0
- package/starter/desert/render/worldNames.ts +6 -0
- package/starter/desert/scene.ts +748 -0
- package/starter/desert/sceneProps.ts +562 -0
- package/starter/desert/sceneState.ts +33 -0
- package/starter/desert/world/terrainAssets.ts +162 -0
- package/starter/desert/world/walkBand.ts +47 -0
- package/starter/desert/world/water.ts +74 -0
- package/starter/desert/worlds.ts +13 -0
- package/starter/forest/README.md +59 -116
- package/starter/forest/assets.json +14 -14
- package/starter/forest/bake.mjs +26 -4
- package/starter/forest/playerRig.ts +89 -0
- package/starter/forest/recipe.json +233 -43
- package/starter/forest/render/bakedFile.ts +17 -0
- package/starter/forest/render/benchmark.ts +77 -0
- package/starter/forest/render/biomeData.ts +14 -0
- package/starter/forest/render/biomes.ts +637 -0
- package/starter/forest/render/ground/cover.ts +565 -0
- package/starter/forest/render/ground/horizon.ts +219 -0
- package/starter/forest/render/ground/palette.d.ts +1 -0
- package/starter/forest/render/ground/palette.js +11 -0
- package/starter/forest/render/ground/scatter.ts +104 -0
- package/starter/forest/render/ground/terrain.ts +1796 -0
- package/starter/forest/render/kitAssets.ts +28 -0
- package/starter/forest/render/loading.ts +354 -0
- package/starter/forest/render/lookKnobs.ts +37 -0
- package/starter/forest/render/orbitCamera.ts +155 -0
- package/starter/forest/render/props/farForest.ts +94 -0
- package/starter/forest/render/props/pack.ts +1078 -0
- package/starter/forest/render/props/prepared.ts +226 -0
- package/starter/forest/render/props/propMaterials.ts +1247 -0
- package/starter/forest/render/props/propProgress.ts +2 -0
- package/starter/forest/render/props/propWorld.ts +105 -0
- package/starter/forest/render/props/props.ts +624 -0
- package/starter/forest/render/props/spruce.ts +440 -0
- package/starter/forest/render/sky/atmosphere.ts +329 -0
- package/starter/forest/render/sky/sky.ts +382 -0
- package/starter/forest/render/texturePreparation.ts +135 -0
- package/starter/forest/render/water/river.ts +1132 -0
- package/starter/forest/render/worldNames.ts +6 -0
- package/starter/forest/scene.ts +715 -0
- package/starter/forest/sceneProps.ts +559 -0
- package/starter/forest/sceneState.ts +33 -0
- package/starter/forest/surface.json +2 -2
- package/starter/forest/world/terrainAssets.ts +158 -0
- package/starter/forest/world/walkBand.ts +47 -0
- package/starter/forest/world/water.ts +74 -0
- package/starter/forest/worlds.ts +13 -0
- package/starter/tundra/README.md +35 -14
- package/starter/tundra/bake.mjs +14 -1
- package/starter/tundra/biome.data.json +6 -6
- package/starter/tundra/playerRig.ts +89 -0
- package/starter/tundra/recipe.json +111 -110
- package/starter/tundra/render/bakedFile.ts +17 -0
- package/starter/tundra/render/benchmark.ts +79 -0
- package/starter/tundra/render/biomeData.ts +14 -0
- package/starter/tundra/render/biomes.ts +714 -0
- package/starter/tundra/render/ground/cover.ts +565 -0
- package/starter/tundra/render/ground/horizon.ts +219 -0
- package/starter/tundra/render/ground/palette.d.ts +1 -0
- package/starter/tundra/render/ground/palette.js +11 -0
- package/starter/tundra/render/ground/scatter.ts +104 -0
- package/starter/tundra/render/ground/terrain.ts +1874 -0
- package/starter/tundra/render/kitAssets.ts +28 -0
- package/starter/tundra/render/loading.ts +354 -0
- package/starter/tundra/render/lookKnobs.ts +37 -0
- package/starter/tundra/render/orbitCamera.ts +155 -0
- package/starter/tundra/render/props/farForest.ts +96 -0
- package/starter/tundra/render/props/pack.ts +1088 -0
- package/starter/tundra/render/props/prepared.ts +225 -0
- package/starter/tundra/render/props/propMaterials.ts +1247 -0
- package/starter/tundra/render/props/propProgress.ts +2 -0
- package/starter/tundra/render/props/propWorld.ts +105 -0
- package/starter/tundra/render/props/props.ts +624 -0
- package/starter/tundra/render/props/spruce.ts +440 -0
- package/starter/tundra/render/sky/atmosphere.ts +329 -0
- package/starter/tundra/render/sky/sky.ts +382 -0
- package/starter/tundra/render/texturePreparation.ts +135 -0
- package/starter/tundra/render/water/river.ts +1132 -0
- package/starter/tundra/render/worldNames.ts +6 -0
- package/starter/tundra/scene.ts +715 -0
- package/starter/tundra/sceneProps.ts +559 -0
- package/starter/tundra/sceneState.ts +33 -0
- package/starter/tundra/world/terrainAssets.ts +159 -0
- package/starter/tundra/world/walkBand.ts +47 -0
- package/starter/tundra/world/water.ts +74 -0
- package/starter/tundra/worlds.ts +13 -0
- package/starter-assets.json +4 -4
- package/starter-credits.json +901 -15
- package/AGENT_GUIDE.md +0 -209
- package/starter/forest/sky.ts +0 -38
- package/starter/forest/water.ts +0 -257
- package/starter/forest/world.ts +0 -182
package/dist/editor/worker.js
CHANGED
|
@@ -153,6 +153,104 @@ function splinePoints(points, step = 3, smooth = true) {
|
|
|
153
153
|
return out;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
// src/core/masks.ts
|
|
157
|
+
var MATERIAL_IDS = Object.freeze([
|
|
158
|
+
"grass",
|
|
159
|
+
"dirt",
|
|
160
|
+
"rock",
|
|
161
|
+
"snow",
|
|
162
|
+
"sand",
|
|
163
|
+
"mud",
|
|
164
|
+
"road",
|
|
165
|
+
"moss"
|
|
166
|
+
]);
|
|
167
|
+
var range = (v, min, max, fade = 0) => fade > 0 ? smoothstep(min - fade, min, v) * (1 - smoothstep(max, max + fade, v)) : Number(v >= min && v <= max);
|
|
168
|
+
function compileMask(mask, s) {
|
|
169
|
+
if (!mask || mask.type === "all") return () => 1;
|
|
170
|
+
switch (mask.type) {
|
|
171
|
+
case "none":
|
|
172
|
+
return () => 0;
|
|
173
|
+
case "circle": {
|
|
174
|
+
const centre = mask.at;
|
|
175
|
+
return (i, x, z) => falloff(
|
|
176
|
+
Math.hypot(x - centre[0], z - centre[1]),
|
|
177
|
+
mask.radius,
|
|
178
|
+
mask.falloff ?? 0.6
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
case "rectangle": {
|
|
182
|
+
const centre = mask.at;
|
|
183
|
+
const rad = (mask.rotation ?? 0) * Math.PI / 180;
|
|
184
|
+
const c = Math.cos(rad);
|
|
185
|
+
const sn = Math.sin(rad);
|
|
186
|
+
const size = Array.isArray(mask.size) ? mask.size : [mask.size, mask.size];
|
|
187
|
+
return (i, x, z) => {
|
|
188
|
+
const dx = x - centre[0];
|
|
189
|
+
const dz = z - centre[1];
|
|
190
|
+
return falloff(
|
|
191
|
+
Math.max(
|
|
192
|
+
Math.abs(dx * c + dz * sn) / (size[0] / 2),
|
|
193
|
+
Math.abs(-dx * sn + dz * c) / (size[1] / 2)
|
|
194
|
+
),
|
|
195
|
+
1,
|
|
196
|
+
mask.falloff ?? 0.2
|
|
197
|
+
);
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
case "height":
|
|
201
|
+
return (i) => range(s.height[i], mask.min ?? -1e9, mask.max ?? 1e9, mask.fade);
|
|
202
|
+
case "slope":
|
|
203
|
+
return (i) => range(slopeAtIndex(s, i), mask.min ?? 0, mask.max ?? 90, mask.fade);
|
|
204
|
+
case "noise":
|
|
205
|
+
return (i, x, z) => smoothstep(
|
|
206
|
+
(mask.threshold ?? 0.5) - (mask.fade ?? 0.15),
|
|
207
|
+
(mask.threshold ?? 0.5) + (mask.fade ?? 0.15),
|
|
208
|
+
noise2(x / mask.scale, z / mask.scale, mask.seed ?? s.seed) * 0.5 + 0.5
|
|
209
|
+
);
|
|
210
|
+
case "biome": {
|
|
211
|
+
const field = s.biomes[mask.name];
|
|
212
|
+
return (i) => field?.[i] ?? 0;
|
|
213
|
+
}
|
|
214
|
+
case "material": {
|
|
215
|
+
const channel = MATERIAL_IDS.indexOf(mask.name);
|
|
216
|
+
if (channel < 0) throw Error(`Unknown material: ${String(mask.name)}`);
|
|
217
|
+
return (i) => s.splat[i * 8 + channel];
|
|
218
|
+
}
|
|
219
|
+
case "not": {
|
|
220
|
+
const inner = compileMask(mask.mask, s);
|
|
221
|
+
return (i, x, z) => 1 - inner(i, x, z);
|
|
222
|
+
}
|
|
223
|
+
case "and": {
|
|
224
|
+
const inner = (mask.masks ?? []).map((entry) => compileMask(entry, s));
|
|
225
|
+
return (i, x, z) => inner.reduce((value, sample) => value * sample(i, x, z), 1);
|
|
226
|
+
}
|
|
227
|
+
case "or": {
|
|
228
|
+
const inner = (mask.masks ?? []).map((entry) => compileMask(entry, s));
|
|
229
|
+
return (i, x, z) => 1 - inner.reduce((value, sample) => value * (1 - sample(i, x, z)), 1);
|
|
230
|
+
}
|
|
231
|
+
default:
|
|
232
|
+
throw Error(`Unknown mask: ${String(mask.type)}`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function rasterMask(mask, s) {
|
|
236
|
+
if (!mask || mask.type === "all") return null;
|
|
237
|
+
const out = new Float32Array(s.height.length);
|
|
238
|
+
const sample = compileMask(mask, s);
|
|
239
|
+
for (let z = 0; z < s.resolution; z += 1) {
|
|
240
|
+
for (let x = 0; x < s.resolution; x += 1) {
|
|
241
|
+
const i = z * s.resolution + x;
|
|
242
|
+
out[i] = clamp(sample(i, world(s, x), world(s, z)));
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return out;
|
|
246
|
+
}
|
|
247
|
+
function paintWeights(s, i, channel, weight) {
|
|
248
|
+
const w = clamp(weight);
|
|
249
|
+
const base = i * 8;
|
|
250
|
+
for (let c = 0; c < 8; c += 1)
|
|
251
|
+
s.splat[base + c] = s.splat[base + c] * (1 - w) + (c === channel ? w : 0);
|
|
252
|
+
}
|
|
253
|
+
|
|
156
254
|
// src/core/erosion.ts
|
|
157
255
|
function thermal(height, n, size, { iterations = 20, talus = 32, rate = 0.22 } = {}, observations) {
|
|
158
256
|
if (!Number.isInteger(n) || n < 2)
|
|
@@ -779,104 +877,6 @@ function gully(height, n, size, { iterations = 200, capacity = 0.05, rain = 5e-4
|
|
|
779
877
|
return Float32Array.from(h, (surface, i) => surface + sediment[i]);
|
|
780
878
|
}
|
|
781
879
|
|
|
782
|
-
// src/core/masks.ts
|
|
783
|
-
var MATERIAL_IDS = Object.freeze([
|
|
784
|
-
"grass",
|
|
785
|
-
"dirt",
|
|
786
|
-
"rock",
|
|
787
|
-
"snow",
|
|
788
|
-
"sand",
|
|
789
|
-
"mud",
|
|
790
|
-
"road",
|
|
791
|
-
"moss"
|
|
792
|
-
]);
|
|
793
|
-
var range = (v, min, max, fade = 0) => fade > 0 ? smoothstep(min - fade, min, v) * (1 - smoothstep(max, max + fade, v)) : Number(v >= min && v <= max);
|
|
794
|
-
function compileMask(mask, s) {
|
|
795
|
-
if (!mask || mask.type === "all") return () => 1;
|
|
796
|
-
switch (mask.type) {
|
|
797
|
-
case "none":
|
|
798
|
-
return () => 0;
|
|
799
|
-
case "circle": {
|
|
800
|
-
const centre = mask.at;
|
|
801
|
-
return (i, x, z) => falloff(
|
|
802
|
-
Math.hypot(x - centre[0], z - centre[1]),
|
|
803
|
-
mask.radius,
|
|
804
|
-
mask.falloff ?? 0.6
|
|
805
|
-
);
|
|
806
|
-
}
|
|
807
|
-
case "rectangle": {
|
|
808
|
-
const centre = mask.at;
|
|
809
|
-
const rad = (mask.rotation ?? 0) * Math.PI / 180;
|
|
810
|
-
const c = Math.cos(rad);
|
|
811
|
-
const sn = Math.sin(rad);
|
|
812
|
-
const size = Array.isArray(mask.size) ? mask.size : [mask.size, mask.size];
|
|
813
|
-
return (i, x, z) => {
|
|
814
|
-
const dx = x - centre[0];
|
|
815
|
-
const dz = z - centre[1];
|
|
816
|
-
return falloff(
|
|
817
|
-
Math.max(
|
|
818
|
-
Math.abs(dx * c + dz * sn) / (size[0] / 2),
|
|
819
|
-
Math.abs(-dx * sn + dz * c) / (size[1] / 2)
|
|
820
|
-
),
|
|
821
|
-
1,
|
|
822
|
-
mask.falloff ?? 0.2
|
|
823
|
-
);
|
|
824
|
-
};
|
|
825
|
-
}
|
|
826
|
-
case "height":
|
|
827
|
-
return (i) => range(s.height[i], mask.min ?? -1e9, mask.max ?? 1e9, mask.fade);
|
|
828
|
-
case "slope":
|
|
829
|
-
return (i) => range(slopeAtIndex(s, i), mask.min ?? 0, mask.max ?? 90, mask.fade);
|
|
830
|
-
case "noise":
|
|
831
|
-
return (i, x, z) => smoothstep(
|
|
832
|
-
(mask.threshold ?? 0.5) - (mask.fade ?? 0.15),
|
|
833
|
-
(mask.threshold ?? 0.5) + (mask.fade ?? 0.15),
|
|
834
|
-
noise2(x / mask.scale, z / mask.scale, mask.seed ?? s.seed) * 0.5 + 0.5
|
|
835
|
-
);
|
|
836
|
-
case "biome": {
|
|
837
|
-
const field = s.biomes[mask.name];
|
|
838
|
-
return (i) => field?.[i] ?? 0;
|
|
839
|
-
}
|
|
840
|
-
case "material": {
|
|
841
|
-
const channel = MATERIAL_IDS.indexOf(mask.name);
|
|
842
|
-
if (channel < 0) throw Error(`Unknown material: ${String(mask.name)}`);
|
|
843
|
-
return (i) => s.splat[i * 8 + channel];
|
|
844
|
-
}
|
|
845
|
-
case "not": {
|
|
846
|
-
const inner = compileMask(mask.mask, s);
|
|
847
|
-
return (i, x, z) => 1 - inner(i, x, z);
|
|
848
|
-
}
|
|
849
|
-
case "and": {
|
|
850
|
-
const inner = (mask.masks ?? []).map((entry) => compileMask(entry, s));
|
|
851
|
-
return (i, x, z) => inner.reduce((value, sample) => value * sample(i, x, z), 1);
|
|
852
|
-
}
|
|
853
|
-
case "or": {
|
|
854
|
-
const inner = (mask.masks ?? []).map((entry) => compileMask(entry, s));
|
|
855
|
-
return (i, x, z) => 1 - inner.reduce((value, sample) => value * (1 - sample(i, x, z)), 1);
|
|
856
|
-
}
|
|
857
|
-
default:
|
|
858
|
-
throw Error(`Unknown mask: ${String(mask.type)}`);
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
function rasterMask(mask, s) {
|
|
862
|
-
if (!mask || mask.type === "all") return null;
|
|
863
|
-
const out = new Float32Array(s.height.length);
|
|
864
|
-
const sample = compileMask(mask, s);
|
|
865
|
-
for (let z = 0; z < s.resolution; z += 1) {
|
|
866
|
-
for (let x = 0; x < s.resolution; x += 1) {
|
|
867
|
-
const i = z * s.resolution + x;
|
|
868
|
-
out[i] = clamp(sample(i, world(s, x), world(s, z)));
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
return out;
|
|
872
|
-
}
|
|
873
|
-
function paintWeights(s, i, channel, weight) {
|
|
874
|
-
const w = clamp(weight);
|
|
875
|
-
const base = i * 8;
|
|
876
|
-
for (let c = 0; c < 8; c += 1)
|
|
877
|
-
s.splat[base + c] = s.splat[base + c] * (1 - w) + (c === channel ? w : 0);
|
|
878
|
-
}
|
|
879
|
-
|
|
880
880
|
// src/core/scree.ts
|
|
881
881
|
var NEIGHBOURS = [
|
|
882
882
|
[-1, -1],
|
|
@@ -2180,7 +2180,7 @@ var TerrainEvaluator = class {
|
|
|
2180
2180
|
}
|
|
2181
2181
|
};
|
|
2182
2182
|
|
|
2183
|
-
// src/
|
|
2183
|
+
// src/package/bake.ts
|
|
2184
2184
|
var toLinear = (color) => color <= 0.04045 ? color / 12.92 : ((color + 0.055) / 1.055) ** 2.4;
|
|
2185
2185
|
function bakeMesh(state, {
|
|
2186
2186
|
step = 1,
|
|
@@ -2491,7 +2491,7 @@ function encodeGLB(input) {
|
|
|
2491
2491
|
}
|
|
2492
2492
|
const binary = join(chunks);
|
|
2493
2493
|
const doc = {
|
|
2494
|
-
asset: { version: "2.0", generator: "@threenative/terrain 0.1.
|
|
2494
|
+
asset: { version: "2.0", generator: "@threenative/terrain 0.1.12" },
|
|
2495
2495
|
scene: 0,
|
|
2496
2496
|
scenes: [{ nodes: meshes.map((_, i) => i) }],
|
|
2497
2497
|
nodes: meshes.map((m, i) => ({ mesh: i, name: m.name ?? `Terrain ${i}` })),
|
|
@@ -2519,7 +2519,7 @@ function encodeGLB(input) {
|
|
|
2519
2519
|
return out;
|
|
2520
2520
|
}
|
|
2521
2521
|
|
|
2522
|
-
// src/
|
|
2522
|
+
// src/package/export.ts
|
|
2523
2523
|
var enc = new TextEncoder();
|
|
2524
2524
|
var table = Uint32Array.from({ length: 256 }, (_, initial) => {
|
|
2525
2525
|
let n = initial;
|
package/dist/export.d.ts
CHANGED