roamwright 0.61.5 → 0.61.7
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/examples/animals.js +6 -4
- package/examples/crowds.js +4 -3
- package/examples/effects.js +7 -6
- package/examples/figure-motion.js +7 -5
- package/examples/fliers.js +3 -4
- package/examples/fortification.js +4 -3
- package/examples/house-kit.js +9 -3
- package/examples/land-features.js +102 -0
- package/examples/land.html +2 -2
- package/examples/land.js +3 -73
- package/examples/pacing.js +2 -2
- package/examples/rooms.js +13 -8
- package/examples/ships.js +2 -2
- package/examples/small-world-land.js +5 -6
- package/examples/small-world-town.js +9 -3
- package/examples/soundscape.js +6 -6
- package/examples/towns.js +2 -2
- package/geometry/farm-crops.js +142 -0
- package/geometry/farm-props.js +107 -0
- package/geometry/fort-city-walls.js +10 -8
- package/geometry/land-trails.js +110 -0
- package/geometry/scatter-instances.js +103 -0
- package/geometry/stream-springs.js +236 -0
- package/geometry/timber-fence.js +117 -0
- package/index.js +10 -1
- package/package.json +1 -1
- package/rendering/land-trail-surface.js +91 -0
- package/rendering/particles.js +78 -1
- package/rendering/scatter-instances.js +246 -0
- package/rendering/stream-springs.js +66 -0
- package/examples/stage-kits.js +0 -172
package/examples/animals.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
buildCamel,
|
|
4
4
|
buildCanine,
|
|
5
5
|
buildCattle,
|
|
6
|
+
buildFenceRing,
|
|
6
7
|
caninePose,
|
|
7
8
|
createDaylightSky,
|
|
8
9
|
createHouseKit,
|
|
@@ -12,11 +13,12 @@ import {
|
|
|
12
13
|
GeometryBuilder,
|
|
13
14
|
horsePose,
|
|
14
15
|
rigHorse,
|
|
16
|
+
scatterTrees,
|
|
17
|
+
scatterTussocks,
|
|
15
18
|
} from 'roamwright';
|
|
16
19
|
import { sstep } from 'roamwright/math/scalar.js';
|
|
17
20
|
import { createProps } from 'roamwright/geometry/props.js';
|
|
18
21
|
import { initExample, makeRollingGround } from './stage.js';
|
|
19
|
-
import { buildCircularFence, scatterTrees, scatterTussocks } from './stage-kits.js';
|
|
20
22
|
|
|
21
23
|
const { canvas, renderer, camera, scene, worldGroup, seed, random, noise, hash, shapes } = initExample({
|
|
22
24
|
fallbackSeed: 42,
|
|
@@ -53,7 +55,7 @@ const ground = makeRollingGround({
|
|
|
53
55
|
worldGroup.add(ground);
|
|
54
56
|
|
|
55
57
|
// Timber post-and-rail paddock fence and watering trough.
|
|
56
|
-
|
|
58
|
+
buildFenceRing({ parent: worldGroup, groundAt, radius: 16.5, posts: 28, random, postHeight: 1.28, railHeights: [0.48, 0.92] });
|
|
57
59
|
|
|
58
60
|
// Haycock and farm well beside the back fence.
|
|
59
61
|
const houseKit = createHouseKit({ shapes });
|
|
@@ -71,7 +73,7 @@ hayMesh.position.set(8.8, 0, -6.2);
|
|
|
71
73
|
|
|
72
74
|
// Trees and meadow tussocks outside and along the fence line.
|
|
73
75
|
const { material: leafMat } = scatterTrees({
|
|
74
|
-
worldGroup,
|
|
76
|
+
parent: worldGroup,
|
|
75
77
|
noise,
|
|
76
78
|
hash,
|
|
77
79
|
seed,
|
|
@@ -90,7 +92,7 @@ const { material: leafMat } = scatterTrees({
|
|
|
90
92
|
});
|
|
91
93
|
|
|
92
94
|
scatterTussocks({
|
|
93
|
-
worldGroup,
|
|
95
|
+
parent: worldGroup,
|
|
94
96
|
seed: seed * 11,
|
|
95
97
|
random,
|
|
96
98
|
groundAt,
|
package/examples/crowds.js
CHANGED
|
@@ -11,13 +11,14 @@ import {
|
|
|
11
11
|
grazeRound,
|
|
12
12
|
planCampWalkers,
|
|
13
13
|
planTownsfolk,
|
|
14
|
+
scatterTrees,
|
|
15
|
+
scatterTussocks,
|
|
14
16
|
} from 'roamwright';
|
|
15
17
|
import { sharedFields } from 'roamwright/motion/crowd-camp.js';
|
|
16
18
|
import { sstep } from 'roamwright/math/scalar.js';
|
|
17
19
|
import { C } from 'roamwright/geometry/primitives.js';
|
|
18
20
|
import { createProps } from 'roamwright/geometry/props.js';
|
|
19
21
|
import { initExample, makeRollingGround } from './stage.js';
|
|
20
|
-
import { scatterTrees, scatterTussocks } from './stage-kits.js';
|
|
21
22
|
|
|
22
23
|
const {
|
|
23
24
|
canvas,
|
|
@@ -122,7 +123,7 @@ createHouseKitMeshes({ materials: createHouseKitMaterials({ doubleSide: true })
|
|
|
122
123
|
|
|
123
124
|
// Trees and grass tussocks framing the meadow, market backdrop and pasture.
|
|
124
125
|
const { material: leafMat } = scatterTrees({
|
|
125
|
-
worldGroup,
|
|
126
|
+
parent: worldGroup,
|
|
126
127
|
noise,
|
|
127
128
|
hash,
|
|
128
129
|
seed,
|
|
@@ -143,7 +144,7 @@ const { material: leafMat } = scatterTrees({
|
|
|
143
144
|
});
|
|
144
145
|
|
|
145
146
|
scatterTussocks({
|
|
146
|
-
worldGroup,
|
|
147
|
+
parent: worldGroup,
|
|
147
148
|
seed: seed * 13,
|
|
148
149
|
random: rng,
|
|
149
150
|
groundAt: groundHeight,
|
package/examples/effects.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import {
|
|
3
|
+
createFireLightWatch,
|
|
3
4
|
createHouseKit,
|
|
4
5
|
createHouseKitMaterials,
|
|
5
6
|
createHouseKitMeshes,
|
|
6
7
|
createOrbitCamera,
|
|
8
|
+
createParticleNoiseTexture,
|
|
9
|
+
createParticleSystem,
|
|
10
|
+
createSiteSchedule,
|
|
7
11
|
createSkyPanorama,
|
|
8
12
|
GeometryBuilder,
|
|
13
|
+
scatterTrees,
|
|
9
14
|
} from 'roamwright';
|
|
10
15
|
import { sstep } from 'roamwright/math/scalar.js';
|
|
11
16
|
import { C, TRS } from 'roamwright/geometry/primitives.js';
|
|
12
17
|
import { createProps } from 'roamwright/geometry/props.js';
|
|
13
|
-
import { createParticleSystem } from 'roamwright/rendering/particles.js';
|
|
14
18
|
import { createParticleEmitters, shakeCamera } from 'roamwright/rendering/particle-emitters.js';
|
|
15
19
|
import { createParticleBursts } from 'roamwright/rendering/particle-bursts.js';
|
|
16
20
|
import { createGroundMarks } from 'roamwright/rendering/ground-marks.js';
|
|
17
21
|
import { createSmokeShadows } from 'roamwright/rendering/smoke-shadows.js';
|
|
18
22
|
import { FLAME_KINDS, createFlameSources } from 'roamwright/rendering/flame-sources.js';
|
|
19
|
-
import { createFireLightWatch } from 'roamwright/rendering/fire-light-watch.js';
|
|
20
23
|
import { perspectivePointScale } from 'roamwright/rendering/viewport.js';
|
|
21
|
-
import { createSiteSchedule } from 'roamwright/runtime/effect-sites.js';
|
|
22
24
|
import { initExample } from './stage.js';
|
|
23
|
-
import { makeParticleNoiseTexture, scatterTrees } from './stage-kits.js';
|
|
24
25
|
|
|
25
26
|
const { canvas, renderer, camera, scene, worldGroup, fxScene, seed, random, noise, hash, shapes } = initExample({
|
|
26
27
|
fallbackSeed: 3,
|
|
@@ -130,7 +131,7 @@ const rockMesh = rocks.mesh(new THREE.MeshStandardMaterial({ vertexColors: true,
|
|
|
130
131
|
rockMesh.castShadow = rockMesh.receiveShadow = true;
|
|
131
132
|
|
|
132
133
|
scatterTrees({
|
|
133
|
-
worldGroup,
|
|
134
|
+
parent: worldGroup,
|
|
134
135
|
noise,
|
|
135
136
|
hash,
|
|
136
137
|
seed,
|
|
@@ -152,7 +153,7 @@ scatterTrees({
|
|
|
152
153
|
});
|
|
153
154
|
|
|
154
155
|
// Particles, noise sheet, and effect systems.
|
|
155
|
-
const noiseTexture =
|
|
156
|
+
const noiseTexture = createParticleNoiseTexture({ noise, size: 128 });
|
|
156
157
|
|
|
157
158
|
const pointScale = { value: 600 },
|
|
158
159
|
particles = createParticleSystem({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
|
3
3
|
import {
|
|
4
|
+
buildFenceRing,
|
|
4
5
|
createDaylightSky,
|
|
5
6
|
createFigureAssembler,
|
|
6
7
|
createFigureBuilder,
|
|
@@ -8,11 +9,12 @@ import {
|
|
|
8
9
|
figureActor,
|
|
9
10
|
geometryOf,
|
|
10
11
|
rigHorse,
|
|
12
|
+
scatterTrees,
|
|
13
|
+
scatterTussocks,
|
|
11
14
|
} from 'roamwright';
|
|
12
15
|
import { sstep } from 'roamwright/math/scalar.js';
|
|
13
|
-
import { createWind } from '
|
|
16
|
+
import { createWind } from 'roamwright/motion/wind.js';
|
|
14
17
|
import { initExample, makeRollingGround } from './stage.js';
|
|
15
|
-
import { buildCircularFence, scatterTrees, scatterTussocks } from './stage-kits.js';
|
|
16
18
|
|
|
17
19
|
const doing = document.getElementById('doing');
|
|
18
20
|
const { canvas, renderer, camera, scene, worldGroup, seed, random, noise, hash } = initExample({
|
|
@@ -45,11 +47,11 @@ const meadow = makeRollingGround({
|
|
|
45
47
|
worldGroup.add(meadow);
|
|
46
48
|
|
|
47
49
|
// Timber post-and-rail paddock fence ringing the 20 m training ground.
|
|
48
|
-
|
|
50
|
+
buildFenceRing({ parent: worldGroup, groundAt, radius: 20.5, posts: 32, random, postHeight: 1.32, railHeights: [0.52, 0.96] });
|
|
49
51
|
|
|
50
52
|
// Trees and meadow tussocks framing the paddock.
|
|
51
53
|
const { material: leafMat } = scatterTrees({
|
|
52
|
-
worldGroup,
|
|
54
|
+
parent: worldGroup,
|
|
53
55
|
noise,
|
|
54
56
|
hash,
|
|
55
57
|
seed,
|
|
@@ -65,7 +67,7 @@ const { material: leafMat } = scatterTrees({
|
|
|
65
67
|
});
|
|
66
68
|
|
|
67
69
|
scatterTussocks({
|
|
68
|
-
worldGroup,
|
|
70
|
+
parent: worldGroup,
|
|
69
71
|
seed: seed * 17,
|
|
70
72
|
random,
|
|
71
73
|
groundAt,
|
package/examples/fliers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import { createDaylightSky, createOrbitCamera, createStreetLamps } from 'roamwright';
|
|
2
|
+
import { createDaylightSky, createOrbitCamera, createStreetLamps, scatterTrees, scatterTussocks } from 'roamwright';
|
|
3
3
|
import { sstep } from 'roamwright/math/scalar.js';
|
|
4
4
|
import { GB } from 'roamwright/geometry/builder.js';
|
|
5
5
|
import { C, TRS } from 'roamwright/geometry/primitives.js';
|
|
@@ -14,7 +14,6 @@ import { createLongFlierCompany } from 'roamwright/rendering/flier-long-body-com
|
|
|
14
14
|
import { createFlierShapes, createSwarm } from 'roamwright/rendering/flier-swarm.js';
|
|
15
15
|
import { createFlock } from 'roamwright/rendering/flocks.js';
|
|
16
16
|
import { initExample, makeRollingGround } from './stage.js';
|
|
17
|
-
import { scatterTrees, scatterTussocks } from './stage-kits.js';
|
|
18
17
|
|
|
19
18
|
const { canvas, renderer, camera, scene, worldGroup, seed, random, noise, hash, shapes } = initExample({
|
|
20
19
|
fallbackSeed: 7,
|
|
@@ -83,7 +82,7 @@ worldGroup.add(lampLight);
|
|
|
83
82
|
|
|
84
83
|
// Trees and meadow tussocks framing the crag and distant ridge.
|
|
85
84
|
const { material: leafMat } = scatterTrees({
|
|
86
|
-
worldGroup,
|
|
85
|
+
parent: worldGroup,
|
|
87
86
|
noise,
|
|
88
87
|
hash,
|
|
89
88
|
seed,
|
|
@@ -105,7 +104,7 @@ const { material: leafMat } = scatterTrees({
|
|
|
105
104
|
});
|
|
106
105
|
|
|
107
106
|
scatterTussocks({
|
|
108
|
-
worldGroup,
|
|
107
|
+
parent: worldGroup,
|
|
109
108
|
seed: seed * 19,
|
|
110
109
|
random,
|
|
111
110
|
groundAt,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import {
|
|
3
3
|
buildPortalGateway,
|
|
4
|
+
createCityFortification,
|
|
4
5
|
createDaylightSky,
|
|
5
6
|
createHouseKit,
|
|
6
7
|
createHouseKitMaterials,
|
|
@@ -9,12 +10,12 @@ import {
|
|
|
9
10
|
createSimpleWater,
|
|
10
11
|
createSpaces,
|
|
11
12
|
mulberry32,
|
|
13
|
+
scatterTrees,
|
|
12
14
|
} from 'roamwright';
|
|
13
15
|
import { townFrame } from 'roamwright/geometry/land-town-ground.js';
|
|
14
16
|
import { C } from 'roamwright/geometry/primitives.js';
|
|
15
17
|
import { sstep } from 'roamwright/math/scalar.js';
|
|
16
18
|
import { initExample, makeRollingGround } from './stage.js';
|
|
17
|
-
import { createShowcaseFortification, scatterTrees } from './stage-kits.js';
|
|
18
19
|
|
|
19
20
|
const { canvas, renderer, camera, scene, worldGroup, seed, noise, hash, shapes } = initExample({
|
|
20
21
|
fallbackSeed: 11,
|
|
@@ -70,7 +71,7 @@ function ground(x, z) {
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
const { addBox } = createSpaces({ ground });
|
|
73
|
-
const fort =
|
|
74
|
+
const fort = createCityFortification({ ground, addBox, shapes, houseKit });
|
|
74
75
|
|
|
75
76
|
const plan = {
|
|
76
77
|
yaw: 0,
|
|
@@ -226,7 +227,7 @@ if (coastal) {
|
|
|
226
227
|
|
|
227
228
|
// Sparse cypress/cedar trees dotting the slopes outside the walls.
|
|
228
229
|
scatterTrees({
|
|
229
|
-
worldGroup,
|
|
230
|
+
parent: worldGroup,
|
|
230
231
|
noise,
|
|
231
232
|
hash,
|
|
232
233
|
seed,
|
package/examples/house-kit.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createDaylightSky,
|
|
4
|
+
createHouseKit,
|
|
5
|
+
createHouseKitMaterials,
|
|
6
|
+
createHouseKitMeshes,
|
|
7
|
+
createOrbitCamera,
|
|
8
|
+
scatterTrees,
|
|
9
|
+
} from 'roamwright';
|
|
3
10
|
import { sstep } from 'roamwright/math/scalar.js';
|
|
4
11
|
import { createProps } from 'roamwright/geometry/props.js';
|
|
5
12
|
import { initExample, makeRollingGround } from './stage.js';
|
|
6
|
-
import { scatterTrees } from './stage-kits.js';
|
|
7
13
|
|
|
8
14
|
const { canvas, renderer, camera, scene, worldGroup, seed, random, noise, hash, shapes } = initExample({
|
|
9
15
|
fallbackSeed: 42,
|
|
@@ -130,7 +136,7 @@ kitStatic(propKit, houses);
|
|
|
130
136
|
|
|
131
137
|
// Trees framing the green hills behind the square.
|
|
132
138
|
scatterTrees({
|
|
133
|
-
worldGroup,
|
|
139
|
+
parent: worldGroup,
|
|
134
140
|
noise,
|
|
135
141
|
hash,
|
|
136
142
|
seed,
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import {
|
|
3
|
+
GeometryBuilder,
|
|
4
|
+
buildHaystacks,
|
|
5
|
+
buildStonePile,
|
|
6
|
+
createUnitShapes,
|
|
7
|
+
drystoneStone,
|
|
8
|
+
layRoads,
|
|
9
|
+
meshSprings,
|
|
10
|
+
meshStreamBanks,
|
|
11
|
+
mulberry32,
|
|
12
|
+
planDrystoneWall,
|
|
13
|
+
planSprings,
|
|
14
|
+
planStreamBanks,
|
|
15
|
+
} from 'roamwright';
|
|
16
|
+
import { instancedMesh } from 'roamwright/geometry/instances.js';
|
|
17
|
+
import { SRGB2LIN } from 'roamwright/math/color.js';
|
|
18
|
+
import { lerp } from 'roamwright/math/scalar.js';
|
|
19
|
+
|
|
20
|
+
// Roads, river springhead and stoned banks, drystone field enclosure, haystacks and stone pile for examples/land.js.
|
|
21
|
+
export function buildLandFeatures({ worldGroup, land, waters, groundExact, sea, shoreZ, tones, seed, fbm, vnoise }) {
|
|
22
|
+
const roadColor = (tone, mul) => ({ r: SRGB2LIN[tone[0]] * mul, g: SRGB2LIN[tone[1]] * mul, b: SRGB2LIN[tone[2]] * mul });
|
|
23
|
+
const roadSoil = roadColor(tones.debris, 0.72),
|
|
24
|
+
roadVerge = roadColor(tones.grass, 0.9);
|
|
25
|
+
layRoads({
|
|
26
|
+
roads: land.roads.map(r => ({ pts: r.pts, w: r.w, crown: 0.15, fadeStart: 20, fadeEnd: 20 })),
|
|
27
|
+
parent: worldGroup,
|
|
28
|
+
ground: groundExact,
|
|
29
|
+
soil: () => roadSoil,
|
|
30
|
+
verge: () => roadVerge,
|
|
31
|
+
material: () => new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.96, transparent: true }),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const shapes = createUnitShapes(fbm);
|
|
35
|
+
const [river] = waters.channels;
|
|
36
|
+
const riverPts = river.line.filter(([, z]) => z <= shoreZ + 10);
|
|
37
|
+
const bed = Float32Array.from(riverPts, ([x, z]) => groundExact(x, z) - 0.4);
|
|
38
|
+
const level = Float32Array.from(riverPts, (_, i) => Math.max(river.level(i / Math.max(1, river.n - 1)), sea + 0.06));
|
|
39
|
+
const plans = planStreamBanks({
|
|
40
|
+
rivers: [{ fine: riverPts, bed, level, w: river.width }],
|
|
41
|
+
waterLevel: sea,
|
|
42
|
+
ground: groundExact,
|
|
43
|
+
random: mulberry32(seed * 41),
|
|
44
|
+
});
|
|
45
|
+
meshStreamBanks({
|
|
46
|
+
plans,
|
|
47
|
+
stone: { geometry: shapes.rock, material: new THREE.MeshStandardMaterial({ roughness: 0.92 }) },
|
|
48
|
+
log: { geometry: shapes.cyl, material: new THREE.MeshStandardMaterial({ roughness: 0.95 }) },
|
|
49
|
+
parent: worldGroup,
|
|
50
|
+
});
|
|
51
|
+
meshSprings({
|
|
52
|
+
plans: planSprings({
|
|
53
|
+
rivers: [{ fine: riverPts, level, w: river.width }],
|
|
54
|
+
ground: groundExact,
|
|
55
|
+
noise: vnoise,
|
|
56
|
+
random: mulberry32(seed * 47),
|
|
57
|
+
}),
|
|
58
|
+
parent: worldGroup,
|
|
59
|
+
crag: () => shapes.rock,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const wallRng = mulberry32(seed * 53);
|
|
63
|
+
const wallCorners = [
|
|
64
|
+
[168, 62],
|
|
65
|
+
[224, 66],
|
|
66
|
+
[220, 118],
|
|
67
|
+
[164, 114],
|
|
68
|
+
];
|
|
69
|
+
const stones = [],
|
|
70
|
+
tintsOut = [];
|
|
71
|
+
for (let i = 0; i < wallCorners.length; i++) {
|
|
72
|
+
const a = wallCorners[i],
|
|
73
|
+
b = wallCorners[(i + 1) % wallCorners.length];
|
|
74
|
+
const segs = Math.max(1, Math.round(Math.hypot(b[0] - a[0], b[1] - a[1]) / 6));
|
|
75
|
+
for (let s = 0; s < segs; s++) {
|
|
76
|
+
if (i === 0 && s === Math.floor(segs / 2)) continue; // gateway facing the road
|
|
77
|
+
const p0 = [lerp(a[0], b[0], s / segs), lerp(a[1], b[1], s / segs)];
|
|
78
|
+
const p1 = [lerp(a[0], b[0], (s + 1) / segs), lerp(a[1], b[1], (s + 1) / segs)];
|
|
79
|
+
const planned = planDrystoneWall(p0, p1, 0.95, wallRng, { ground: groundExact });
|
|
80
|
+
stones.push(...planned.stones);
|
|
81
|
+
tintsOut.push(...planned.tints);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const wallMesh = instancedMesh(drystoneStone(vnoise), new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.94 }), {
|
|
85
|
+
matrices: new Float32Array(stones),
|
|
86
|
+
colours: new Float32Array(tintsOut),
|
|
87
|
+
});
|
|
88
|
+
wallMesh.castShadow = wallMesh.receiveShadow = true;
|
|
89
|
+
worldGroup.add(wallMesh);
|
|
90
|
+
|
|
91
|
+
const placeProp = (build, x, z, roughness) => {
|
|
92
|
+
const gb = new GeometryBuilder();
|
|
93
|
+
build(gb);
|
|
94
|
+
const mesh = gb.mesh(new THREE.MeshStandardMaterial({ vertexColors: true, roughness }), worldGroup);
|
|
95
|
+
if (mesh) {
|
|
96
|
+
mesh.position.set(x, groundExact(x, z), z);
|
|
97
|
+
mesh.updateMatrix();
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
placeProp(gb => buildHaystacks(gb, mulberry32(seed * 59), { noise: vnoise, box: shapes.box }), 186, 86, 0.96);
|
|
101
|
+
placeProp(gb => buildStonePile(gb, mulberry32(seed * 61), { rock: shapes.rock }), 196, 80, 0.92);
|
|
102
|
+
}
|
package/examples/land.html
CHANGED
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
<div class="caption">
|
|
38
38
|
<h1>A baked land</h1>
|
|
39
39
|
<p id="status">
|
|
40
|
-
One height sheet baked row by row: coast, eroded hills, river
|
|
41
|
-
cliff-faced tel, quarry and port pad.
|
|
40
|
+
One height sheet baked row by row: coast, eroded hills, river springhead and stoned banks, lake, draped earth road, drystone
|
|
41
|
+
enclosure with haystacks and stone pile, cliff-faced tel, quarry and port pad.
|
|
42
42
|
</p>
|
|
43
43
|
</div>
|
|
44
44
|
<div class="tools">
|
package/examples/land.js
CHANGED
|
@@ -12,17 +12,10 @@ import {
|
|
|
12
12
|
createRenderContext,
|
|
13
13
|
createSimpleWater,
|
|
14
14
|
createTownGround,
|
|
15
|
-
createUnitShapes,
|
|
16
|
-
drystoneStone,
|
|
17
15
|
landEdgeGrid,
|
|
18
|
-
layRoads,
|
|
19
|
-
meshStreamBanks,
|
|
20
16
|
mulberry32,
|
|
21
|
-
planDrystoneWall,
|
|
22
|
-
planStreamBanks,
|
|
23
17
|
} from 'roamwright';
|
|
24
18
|
import { erodeHeightfield } from 'roamwright/geometry/erosion.js';
|
|
25
|
-
import { instancedMesh } from 'roamwright/geometry/instances.js';
|
|
26
19
|
import { createClearings, createRainRule } from 'roamwright/geometry/land-clearings.js';
|
|
27
20
|
import { createSandRidges } from 'roamwright/geometry/land-dunes.js';
|
|
28
21
|
import { landEdgeArrays } from 'roamwright/geometry/land-edge.js';
|
|
@@ -34,6 +27,7 @@ import { lerp, sstep } from 'roamwright/math/scalar.js';
|
|
|
34
27
|
import { partsGeometry } from 'roamwright/geometry/foliage.js';
|
|
35
28
|
import { createPlantTints } from 'roamwright/geometry/plant-tints.js';
|
|
36
29
|
import { createTrees } from 'roamwright/geometry/plant-trees.js';
|
|
30
|
+
import { buildLandFeatures } from './land-features.js';
|
|
37
31
|
import { readSeed } from './stage.js';
|
|
38
32
|
|
|
39
33
|
const seed = readSeed(7);
|
|
@@ -369,71 +363,7 @@ const groundExact = (x, z) => {
|
|
|
369
363
|
return fx + fz <= 1 ? h00 + (h10 - h00) * fx + (h01 - h00) * fz : h11 + (h01 - h11) * (1 - fx) + (h10 - h11) * (1 - fz);
|
|
370
364
|
};
|
|
371
365
|
|
|
372
|
-
|
|
373
|
-
const roadColor = (tone, mul) => ({ r: SRGB2LIN[tone[0]] * mul, g: SRGB2LIN[tone[1]] * mul, b: SRGB2LIN[tone[2]] * mul });
|
|
374
|
-
const roadSoil = roadColor(TONE.debris, 0.72),
|
|
375
|
-
roadVerge = roadColor(TONE.grass, 0.9);
|
|
376
|
-
layRoads({
|
|
377
|
-
roads: land.roads.map(r => ({ pts: r.pts, w: r.w, crown: 0.15, fadeStart: 20, fadeEnd: 20 })),
|
|
378
|
-
parent: worldGroup,
|
|
379
|
-
ground: groundExact,
|
|
380
|
-
soil: () => roadSoil,
|
|
381
|
-
verge: () => roadVerge,
|
|
382
|
-
material: () => new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.96, transparent: true }),
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
// Stream bank boulders, shingle bars and driftwood along the river channel.
|
|
386
|
-
{
|
|
387
|
-
const [river] = waters.channels;
|
|
388
|
-
const riverPts = river.line.filter(([, z]) => z <= SHORE_Z + 10);
|
|
389
|
-
const bed = Float32Array.from(riverPts, ([x, z]) => groundExact(x, z) - 0.4);
|
|
390
|
-
const level = Float32Array.from(riverPts, (_, i) => Math.max(river.level(i / Math.max(1, river.n - 1)), SEA + 0.06));
|
|
391
|
-
const plans = planStreamBanks({
|
|
392
|
-
rivers: [{ fine: riverPts, bed, level, w: river.width }],
|
|
393
|
-
waterLevel: SEA,
|
|
394
|
-
ground: groundExact,
|
|
395
|
-
random: mulberry32(seed * 41),
|
|
396
|
-
});
|
|
397
|
-
const shapes = createUnitShapes(fbm);
|
|
398
|
-
meshStreamBanks({
|
|
399
|
-
plans,
|
|
400
|
-
stone: { geometry: shapes.rock, material: new THREE.MeshStandardMaterial({ roughness: 0.92 }) },
|
|
401
|
-
log: { geometry: shapes.cyl, material: new THREE.MeshStandardMaterial({ roughness: 0.95 }) },
|
|
402
|
-
parent: worldGroup,
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
// Drystone field enclosure beside the road east of the river ford.
|
|
407
|
-
{
|
|
408
|
-
const wallRng = mulberry32(seed * 53);
|
|
409
|
-
const wallCorners = [
|
|
410
|
-
[168, 62],
|
|
411
|
-
[224, 66],
|
|
412
|
-
[220, 118],
|
|
413
|
-
[164, 114],
|
|
414
|
-
];
|
|
415
|
-
const stones = [],
|
|
416
|
-
tintsOut = [];
|
|
417
|
-
for (let i = 0; i < wallCorners.length; i++) {
|
|
418
|
-
const a = wallCorners[i],
|
|
419
|
-
b = wallCorners[(i + 1) % wallCorners.length];
|
|
420
|
-
const segs = Math.max(1, Math.round(Math.hypot(b[0] - a[0], b[1] - a[1]) / 6));
|
|
421
|
-
for (let s = 0; s < segs; s++) {
|
|
422
|
-
if (i === 0 && s === Math.floor(segs / 2)) continue; // gateway facing the road
|
|
423
|
-
const p0 = [lerp(a[0], b[0], s / segs), lerp(a[1], b[1], s / segs)];
|
|
424
|
-
const p1 = [lerp(a[0], b[0], (s + 1) / segs), lerp(a[1], b[1], (s + 1) / segs)];
|
|
425
|
-
const planned = planDrystoneWall(p0, p1, 0.95, wallRng, { ground: groundExact });
|
|
426
|
-
stones.push(...planned.stones);
|
|
427
|
-
tintsOut.push(...planned.tints);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
const wallMesh = instancedMesh(drystoneStone(vnoise), new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.94 }), {
|
|
431
|
-
matrices: new Float32Array(stones),
|
|
432
|
-
colours: new Float32Array(tintsOut),
|
|
433
|
-
});
|
|
434
|
-
wallMesh.castShadow = wallMesh.receiveShadow = true;
|
|
435
|
-
worldGroup.add(wallMesh);
|
|
436
|
-
}
|
|
366
|
+
buildLandFeatures({ worldGroup, land, waters, groundExact, sea: SEA, shoreZ: SHORE_Z, tones: TONE, seed, fbm, vnoise });
|
|
437
367
|
|
|
438
368
|
createDaylightSky({
|
|
439
369
|
scene,
|
|
@@ -450,7 +380,7 @@ createDaylightSky({
|
|
|
450
380
|
});
|
|
451
381
|
|
|
452
382
|
const status = document.querySelector('#status');
|
|
453
|
-
status.textContent = `${STRIDE} × ${STRIDE} points (${sheet.spacing} m step): coast, eroded hills, river
|
|
383
|
+
status.textContent = `${STRIDE} × ${STRIDE} points (${sheet.spacing} m step): coast, eroded hills, river springhead and stoned banks, mere, draped earth road, drystone enclosure with haystacks and stone pile, cliff-faced tel, quarry and port pad.`;
|
|
454
384
|
|
|
455
385
|
const views = {
|
|
456
386
|
coast: { eye: [365, 138, 440], target: [35, 8, -35] },
|
package/examples/pacing.js
CHANGED
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
groundRenderOrder,
|
|
15
15
|
readDevice,
|
|
16
16
|
resolveDevicePresets,
|
|
17
|
+
scatterTrees,
|
|
17
18
|
} from 'roamwright';
|
|
18
19
|
import { sstep } from 'roamwright/math/scalar.js';
|
|
19
20
|
import { createDiagnosticLog } from 'roamwright/runtime/diagnostic-log.js';
|
|
20
21
|
import { estimateMemory } from 'roamwright/rendering/memory-estimate.js';
|
|
21
22
|
import { initExample, makeRollingGround } from './stage.js';
|
|
22
|
-
import { scatterTrees } from './stage-kits.js';
|
|
23
23
|
|
|
24
24
|
const { canvas, renderer, camera, scene, worldGroup, seed, random, noise, hash, shapes } = initExample({
|
|
25
25
|
fallbackSeed: 42,
|
|
@@ -141,7 +141,7 @@ createHouseKitMeshes({ materials: createHouseKitMaterials({ roughness: 0.9 }) })
|
|
|
141
141
|
const treeGroup = new THREE.Group();
|
|
142
142
|
worldGroup.add(treeGroup);
|
|
143
143
|
scatterTrees({
|
|
144
|
-
|
|
144
|
+
parent: treeGroup,
|
|
145
145
|
noise,
|
|
146
146
|
hash,
|
|
147
147
|
seed,
|
package/examples/rooms.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import {
|
|
4
|
+
bindKeyboardOrbit,
|
|
5
|
+
createParticleNoiseTexture,
|
|
6
|
+
createParticleSystem,
|
|
7
|
+
createRoomKit,
|
|
8
|
+
createRoomMaterials,
|
|
9
|
+
createSiteSchedule,
|
|
10
|
+
finishRoom,
|
|
11
|
+
} from 'roamwright';
|
|
12
|
+
import { createParticleEmitters } from 'roamwright/rendering/particle-emitters.js';
|
|
13
|
+
import { updateRoomLight } from 'roamwright/rendering/room-light.js';
|
|
14
|
+
import { perspectivePointScale } from 'roamwright/rendering/viewport.js';
|
|
9
15
|
import { initExample } from './stage.js';
|
|
10
|
-
import { makeParticleNoiseTexture } from './stage-kits.js';
|
|
11
16
|
|
|
12
17
|
const { canvas, renderer, camera, scene, worldGroup, seed, noise, hash, shapes } = initExample({
|
|
13
18
|
fallbackSeed: 42,
|
|
@@ -145,7 +150,7 @@ const finish = (R, def) =>
|
|
|
145
150
|
const rooms = { small: await smallRoom(), hall: await hall() };
|
|
146
151
|
|
|
147
152
|
// Real engine fire inside the small room's hearth, using the fire site emitted by kit.hearth().
|
|
148
|
-
const noiseTexture =
|
|
153
|
+
const noiseTexture = createParticleNoiseTexture({ noise, size: 128 });
|
|
149
154
|
const pointScale = { value: 520 };
|
|
150
155
|
let fireClock = 0;
|
|
151
156
|
const particles = createParticleSystem({
|
package/examples/ships.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
createShipMeshes,
|
|
10
10
|
createSimpleWater,
|
|
11
11
|
GeometryBuilder,
|
|
12
|
+
scatterTrees,
|
|
12
13
|
SHIP_PRESETS,
|
|
13
14
|
} from 'roamwright';
|
|
14
15
|
import { sstep } from 'roamwright/math/scalar.js';
|
|
@@ -18,7 +19,6 @@ import { YARD_STOWED } from 'roamwright/geometry/ship-rig.js';
|
|
|
18
19
|
import { createBoatSailing, openWaterCourse } from 'roamwright/motion/boat-sailing.js';
|
|
19
20
|
import { createProps } from 'roamwright/geometry/props.js';
|
|
20
21
|
import { initExample, makeRollingGround } from './stage.js';
|
|
21
|
-
import { scatterTrees } from './stage-kits.js';
|
|
22
22
|
|
|
23
23
|
const { canvas, renderer, camera, scene, worldGroup, seed, random, noise, hash, shapes } = initExample({
|
|
24
24
|
fallbackSeed: 42,
|
|
@@ -141,7 +141,7 @@ kitStatic(propKit, portGroup);
|
|
|
141
141
|
|
|
142
142
|
// Coastal pines and cedars along the headland behind the warehouses.
|
|
143
143
|
scatterTrees({
|
|
144
|
-
worldGroup,
|
|
144
|
+
parent: worldGroup,
|
|
145
145
|
noise,
|
|
146
146
|
hash,
|
|
147
147
|
seed,
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import { createSimpleWater, GeometryBuilder, mulberry32 } from 'roamwright';
|
|
2
|
+
import { buildFenceRing, createSimpleWater, GeometryBuilder, mulberry32, scatterTrees, scatterTussocks } from 'roamwright';
|
|
3
3
|
import { sstep } from 'roamwright/math/scalar.js';
|
|
4
4
|
import { C, TRS } from 'roamwright/geometry/primitives.js';
|
|
5
5
|
import { createReeds } from 'roamwright/rendering/plant-reeds.js';
|
|
6
6
|
import { makeRollingGround } from './stage.js';
|
|
7
|
-
import { buildCircularFence, scatterTrees, scatterTussocks } from './stage-kits.js';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Builds the coastal valley terrain, river mouth, bay water, stone harbour quay,
|
|
@@ -81,8 +80,8 @@ export function buildSmallWorldLand({ world, worldGroup, seed, rng, noise, hash,
|
|
|
81
80
|
quayMesh.castShadow = quayMesh.receiveShadow = true;
|
|
82
81
|
|
|
83
82
|
// Timber paddock fence enclosing the grazing pasture east of the town.
|
|
84
|
-
|
|
85
|
-
worldGroup,
|
|
83
|
+
buildFenceRing({
|
|
84
|
+
parent: worldGroup,
|
|
86
85
|
groundAt,
|
|
87
86
|
cx: world.pasture.x,
|
|
88
87
|
cz: world.pasture.z,
|
|
@@ -94,7 +93,7 @@ export function buildSmallWorldLand({ world, worldGroup, seed, rng, noise, hash,
|
|
|
94
93
|
|
|
95
94
|
// Woodland, meadow tussocks and swaying river reeds.
|
|
96
95
|
const { material: leafMat } = scatterTrees({
|
|
97
|
-
worldGroup,
|
|
96
|
+
parent: worldGroup,
|
|
98
97
|
noise,
|
|
99
98
|
hash,
|
|
100
99
|
seed,
|
|
@@ -117,7 +116,7 @@ export function buildSmallWorldLand({ world, worldGroup, seed, rng, noise, hash,
|
|
|
117
116
|
});
|
|
118
117
|
|
|
119
118
|
scatterTussocks({
|
|
120
|
-
worldGroup,
|
|
119
|
+
parent: worldGroup,
|
|
121
120
|
seed: seed * 13,
|
|
122
121
|
random: rng,
|
|
123
122
|
groundAt,
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createCityFortification,
|
|
4
|
+
createHouseKit,
|
|
5
|
+
createHouseKitMaterials,
|
|
6
|
+
createHouseKitMeshes,
|
|
7
|
+
createStreetLamps,
|
|
8
|
+
GeometryBuilder,
|
|
9
|
+
} from 'roamwright';
|
|
3
10
|
import { townFrame } from 'roamwright/geometry/land-town-ground.js';
|
|
4
11
|
import { createProps } from 'roamwright/geometry/props.js';
|
|
5
|
-
import { createShowcaseFortification } from './stage-kits.js';
|
|
6
12
|
|
|
7
13
|
const STYLES = {
|
|
8
14
|
town: {
|
|
@@ -43,7 +49,7 @@ const ROOF_PALETTE = [0x8c4c38, 0x674b3d, 0x9b5f3d, 0x5c686a];
|
|
|
43
49
|
*/
|
|
44
50
|
export function buildSmallWorldTown({ world, worldGroup, seed, rng, noise, hash, shapes, groundAt, spaceKit }) {
|
|
45
51
|
const houseKit = createHouseKit({ shapes, styles: STYLES });
|
|
46
|
-
const fort =
|
|
52
|
+
const fort = createCityFortification({ ground: groundAt, addBox: spaceKit.addBox, shapes, houseKit });
|
|
47
53
|
const frame = townFrame({ ...world.town, water: -1.5 });
|
|
48
54
|
const townSpace = { id: world.town.id, decks: [], grid: new Map(), ground: groundAt };
|
|
49
55
|
const K = fort.cityKit(townSpace, frame);
|