roamwright 0.55.1 → 0.56.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/examples/animals.js +27 -15
- package/examples/crowds.js +28 -18
- package/examples/effects.js +13 -11
- package/examples/figure-motion.js +17 -5
- package/examples/figure.js +12 -8
- package/examples/fliers.js +16 -12
- package/examples/fortification.js +31 -18
- package/examples/house-kit.js +17 -10
- package/examples/island.js +25 -12
- package/examples/land.js +14 -8
- package/examples/props-and-plants.js +21 -32
- package/examples/rooms.js +2 -2
- package/examples/ships.js +33 -15
- package/examples/small-world-land.js +3 -3
- package/examples/small-world-life.js +13 -5
- package/examples/small-world-town.js +8 -11
- package/examples/small-world.js +26 -19
- package/examples/soundscape.js +18 -18
- package/examples/stage-kits.js +5 -133
- package/examples/stage.js +1 -324
- package/examples/towns.js +25 -18
- package/examples/viaduct-landscape.js +1 -1
- package/examples/viaduct.js +3 -4
- package/geometry/builder.js +8 -18
- package/geometry/plant-broadleaf.js +10 -4
- package/geometry/plant-trees.js +15 -9
- package/geometry/still-mesh.js +35 -0
- package/index.js +6 -1
- package/motion/figure-mount.js +1 -0
- package/package.json +1 -1
- package/rendering/crowd-system.js +239 -0
- package/rendering/daylight-sky.js +212 -0
- package/rendering/house-kit-meshes.js +65 -16
- package/rendering/orbit-camera.js +216 -0
- package/rendering/water-simple.js +112 -0
package/examples/land.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import {
|
|
3
|
+
createDaylightSky,
|
|
3
4
|
createDitchedGround,
|
|
4
5
|
createEarthworks,
|
|
5
6
|
createLandBake,
|
|
@@ -7,7 +8,9 @@ import {
|
|
|
7
8
|
createLandWaters,
|
|
8
9
|
createMoundFaces,
|
|
9
10
|
createNoise,
|
|
11
|
+
createOrbitCamera,
|
|
10
12
|
createRenderContext,
|
|
13
|
+
createSimpleWater,
|
|
11
14
|
createTownGround,
|
|
12
15
|
landEdgeGrid,
|
|
13
16
|
mulberry32,
|
|
@@ -24,7 +27,7 @@ import { lerp, sstep } from 'roamwright/math/scalar.js';
|
|
|
24
27
|
import { partsGeometry } from 'roamwright/geometry/foliage.js';
|
|
25
28
|
import { createPlantTints } from 'roamwright/geometry/plant-tints.js';
|
|
26
29
|
import { createTrees } from 'roamwright/geometry/plant-trees.js';
|
|
27
|
-
import {
|
|
30
|
+
import { readSeed } from './stage.js';
|
|
28
31
|
|
|
29
32
|
const seed = readSeed(7);
|
|
30
33
|
const noise = createNoise(seed);
|
|
@@ -265,7 +268,7 @@ for (let i = 0; i < extArrays.position.length; i += 3) {
|
|
|
265
268
|
meshOf({ ...extArrays, color: extColor }, earth, false);
|
|
266
269
|
|
|
267
270
|
// Shimmering sea, upland lake, and river ribbon stopping cleanly at the sea mouth.
|
|
268
|
-
const { mesh: seaMesh, timeUniform: waterTime } =
|
|
271
|
+
const { mesh: seaMesh, timeUniform: waterTime } = createSimpleWater({
|
|
269
272
|
width: SIZE * 7,
|
|
270
273
|
depth: SIZE * 7,
|
|
271
274
|
segs: 120,
|
|
@@ -317,8 +320,7 @@ for (const lake of land.lakes) {
|
|
|
317
320
|
// Sparse groves of conifers on the inland slopes and along the riverbanks to convey the 1.5 km scale.
|
|
318
321
|
const tints = createPlantTints({ fbm, vnoise, hash: hash2 });
|
|
319
322
|
const treeKit = createTrees({ hash: hash2, ...tints, seed });
|
|
320
|
-
const
|
|
321
|
-
const treeGeo = partsGeometry(conifer.near ?? conifer);
|
|
323
|
+
const treeGeo = partsGeometry(treeKit.conifer().near);
|
|
322
324
|
const treeMat = new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.88, side: THREE.DoubleSide });
|
|
323
325
|
const trees = new THREE.InstancedMesh(treeGeo, treeMat, 220);
|
|
324
326
|
trees.castShadow = trees.receiveShadow = true;
|
|
@@ -343,14 +345,18 @@ trees.count = tc;
|
|
|
343
345
|
trees.instanceMatrix.needsUpdate = true;
|
|
344
346
|
worldGroup.add(trees);
|
|
345
347
|
|
|
346
|
-
|
|
347
|
-
scene
|
|
348
|
-
|
|
348
|
+
createDaylightSky({
|
|
349
|
+
scene,
|
|
350
|
+
renderer,
|
|
351
|
+
noise,
|
|
352
|
+
sky: { sunDir: [-0.72, 0.28, 0.63] },
|
|
349
353
|
sunPosition: [-460, 240, 360],
|
|
350
354
|
shadowRadius: 680,
|
|
351
355
|
shadowFar: 1850,
|
|
352
356
|
normalBias: 0.45,
|
|
353
357
|
staticShadows: true,
|
|
358
|
+
fogColor: 0xd0dcd9,
|
|
359
|
+
fogDensity: 0.00042,
|
|
354
360
|
});
|
|
355
361
|
|
|
356
362
|
const status = document.querySelector('#status');
|
|
@@ -363,7 +369,7 @@ const views = {
|
|
|
363
369
|
port: { eye: [-55, 78, 560], target: [-230, 5, 360] },
|
|
364
370
|
};
|
|
365
371
|
|
|
366
|
-
const rig =
|
|
372
|
+
const rig = createOrbitCamera({
|
|
367
373
|
camera,
|
|
368
374
|
canvas,
|
|
369
375
|
renderer,
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import {
|
|
3
|
+
createDaylightSky,
|
|
3
4
|
createHouseKit,
|
|
5
|
+
createHouseKitMaterials,
|
|
4
6
|
createHouseKitMeshes,
|
|
5
7
|
createNoise,
|
|
8
|
+
createOrbitCamera,
|
|
6
9
|
createRenderContext,
|
|
10
|
+
createSimpleWater,
|
|
7
11
|
createUnitShapes,
|
|
8
12
|
GeometryBuilder,
|
|
9
13
|
mulberry32,
|
|
@@ -15,11 +19,10 @@ import { partsGeometry } from 'roamwright/geometry/foliage.js';
|
|
|
15
19
|
import { createProps } from 'roamwright/geometry/props.js';
|
|
16
20
|
import { createPlantTints } from 'roamwright/geometry/plant-tints.js';
|
|
17
21
|
import { createShrubs } from 'roamwright/geometry/plant-shrub.js';
|
|
18
|
-
import { createBroadleaf } from 'roamwright/geometry/plant-broadleaf.js';
|
|
19
22
|
import { createTrees } from 'roamwright/geometry/plant-trees.js';
|
|
20
23
|
import { PLAIN_GRASS, tussockGeometry } from 'roamwright/geometry/plant-tussock.js';
|
|
21
24
|
import { createReeds } from 'roamwright/rendering/plant-reeds.js';
|
|
22
|
-
import {
|
|
25
|
+
import { makeRollingGround, readSeed } from './stage.js';
|
|
23
26
|
|
|
24
27
|
const canvas = document.querySelector('canvas');
|
|
25
28
|
const { renderer, camera, scene, worldGroup } = createRenderContext(canvas, { fov: 40 });
|
|
@@ -64,7 +67,7 @@ const terrain = makeRollingGround({
|
|
|
64
67
|
worldGroup.add(terrain);
|
|
65
68
|
|
|
66
69
|
// Shimmering pond filling the eastern basin.
|
|
67
|
-
const { mesh: pondMesh, timeUniform: waterTime } =
|
|
70
|
+
const { mesh: pondMesh, timeUniform: waterTime } = createSimpleWater({
|
|
68
71
|
width: 28,
|
|
69
72
|
depth: 24,
|
|
70
73
|
segs: 40,
|
|
@@ -109,33 +112,16 @@ const placements = [
|
|
|
109
112
|
for (const [x, z, yaw, build] of placements) {
|
|
110
113
|
houseKit.kitAt(kit, x, ground(x, z), z, yaw, false, build, random);
|
|
111
114
|
}
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
materials.stain = new THREE.MeshStandardMaterial({ vertexColors: true, transparent: true, opacity: 0.25, depthWrite: false });
|
|
115
|
-
const handOver = { paced: steps => Promise.resolve(steps), drain: steps => steps, heldBytes: () => 0 };
|
|
116
|
-
const { kitMeshes } = createHouseKitMeshes({ materials, PieceBatch: null, handOver });
|
|
117
|
-
const propsGroup = new THREE.Group();
|
|
118
|
-
kitMeshes(
|
|
119
|
-
houseKit.KIT_KEYS.map(k => kit[k].parts(true)),
|
|
120
|
-
propsGroup,
|
|
121
|
-
);
|
|
122
|
-
propsGroup.traverse(o => {
|
|
123
|
-
if (o.isMesh) {
|
|
124
|
-
o.castShadow = true;
|
|
125
|
-
o.receiveShadow = true;
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
worldGroup.add(propsGroup);
|
|
115
|
+
const { kitStatic } = createHouseKitMeshes({ materials: createHouseKitMaterials({ doubleSide: true, roughness: 0.9 }) });
|
|
116
|
+
kitStatic(kit, worldGroup);
|
|
129
117
|
|
|
130
118
|
// Harvest sheaves and a haycock beside the wagon.
|
|
131
|
-
const straw = new THREE.MeshStandardMaterial(
|
|
119
|
+
const straw = new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.9 });
|
|
132
120
|
const stook = (draw, x, z) => {
|
|
133
121
|
const builder = new GeometryBuilder();
|
|
134
122
|
draw(builder);
|
|
135
123
|
const mesh = builder.mesh(straw, worldGroup);
|
|
136
124
|
mesh.position.set(x, ground(x, z), z);
|
|
137
|
-
mesh.castShadow = mesh.receiveShadow = true;
|
|
138
|
-
mesh.updateMatrix();
|
|
139
125
|
};
|
|
140
126
|
for (let i = 0; i < 6; i++) {
|
|
141
127
|
const sx = -16.5 + (i % 3) * 1.45,
|
|
@@ -151,11 +137,10 @@ stook(builder => props.haycock(builder, false), -20.5, 11);
|
|
|
151
137
|
// The plant kit's trees arcing behind the clearing and beside the pond.
|
|
152
138
|
const tints = createPlantTints({ fbm, vnoise, hash });
|
|
153
139
|
const trees = createTrees({ hash, ...tints, seed });
|
|
154
|
-
const { broadleaf } = createBroadleaf(tints);
|
|
155
140
|
const { shrubParts } = createShrubs({ hash, ...tints });
|
|
156
141
|
const leafy = new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.86, side: THREE.DoubleSide });
|
|
157
|
-
const plant = (
|
|
158
|
-
const mesh = new THREE.Mesh(
|
|
142
|
+
const plant = (built, x, z, scale = 1) => {
|
|
143
|
+
const mesh = new THREE.Mesh(partsGeometry(built.near), leafy);
|
|
159
144
|
mesh.position.set(x, ground(x, z) - 0.08, z);
|
|
160
145
|
mesh.scale.setScalar(scale);
|
|
161
146
|
mesh.rotation.y = random() * Math.PI * 2;
|
|
@@ -164,12 +149,12 @@ const plant = (parts, x, z, scale = 1) => {
|
|
|
164
149
|
};
|
|
165
150
|
const grove = [
|
|
166
151
|
[trees.conifer(), -24, -14, 1.1],
|
|
167
|
-
[broadleaf(), -11, -15, 1.05],
|
|
152
|
+
[trees.broadleaf(), -11, -15, 1.05],
|
|
168
153
|
[trees.cedar(0), 2, -16, 0.88],
|
|
169
154
|
[trees.acacia(), 16, -13, 1.0],
|
|
170
155
|
[trees.thornTree(), 27, -6, 1.0],
|
|
171
156
|
[trees.burntTree(), 29, 12, 1.05],
|
|
172
|
-
[broadleaf(), 13, 16, 0.92],
|
|
157
|
+
[trees.broadleaf(), 13, 16, 0.92],
|
|
173
158
|
[trees.conifer(), -4, -22, 1.2],
|
|
174
159
|
[trees.cedar(0), -20, -21, 0.95],
|
|
175
160
|
];
|
|
@@ -233,13 +218,17 @@ for (let i = 0; i < 65; i++) {
|
|
|
233
218
|
}
|
|
234
219
|
meshReedBeds(worldGroup, [bed], reedModels(mulberry32(seed)));
|
|
235
220
|
|
|
236
|
-
|
|
237
|
-
scene
|
|
238
|
-
|
|
221
|
+
createDaylightSky({
|
|
222
|
+
scene,
|
|
223
|
+
renderer,
|
|
224
|
+
noise,
|
|
225
|
+
sky: { sunDir: [-0.72, 0.34, 0.6] },
|
|
239
226
|
sunPosition: [-52, 34, 44],
|
|
240
227
|
shadowRadius: 48,
|
|
241
228
|
shadowFar: 170,
|
|
242
229
|
staticShadows: true,
|
|
230
|
+
fogColor: 0xd3ddd7,
|
|
231
|
+
fogDensity: 0.0024,
|
|
243
232
|
});
|
|
244
233
|
|
|
245
234
|
const views = {
|
|
@@ -248,7 +237,7 @@ const views = {
|
|
|
248
237
|
grove: { eye: [10, 7.5, 21], target: [18, 2.4, -1] },
|
|
249
238
|
};
|
|
250
239
|
|
|
251
|
-
const rig =
|
|
240
|
+
const rig = createOrbitCamera({
|
|
252
241
|
camera,
|
|
253
242
|
canvas,
|
|
254
243
|
renderer,
|
package/examples/rooms.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
|
3
|
-
import { createRoomKit, createRoomMaterials, finishRoom } from 'roamwright';
|
|
3
|
+
import { bindKeyboardOrbit, createRoomKit, createRoomMaterials, finishRoom } from 'roamwright';
|
|
4
4
|
import { createParticleEmitters } from '../rendering/particle-emitters.js';
|
|
5
5
|
import { createParticleSystem } from '../rendering/particles.js';
|
|
6
6
|
import { updateRoomLight } from '../rendering/room-light.js';
|
|
7
7
|
import { perspectivePointScale } from '../rendering/viewport.js';
|
|
8
8
|
import { createSiteSchedule } from '../runtime/effect-sites.js';
|
|
9
|
-
import {
|
|
9
|
+
import { initExample } from './stage.js';
|
|
10
10
|
import { makeParticleNoiseTexture } from './stage-kits.js';
|
|
11
11
|
|
|
12
12
|
const { canvas, renderer, camera, scene, worldGroup, seed, noise, hash, shapes } = initExample({
|
package/examples/ships.js
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createDaylightSky,
|
|
4
|
+
createHouseKit,
|
|
5
|
+
createHouseKitMaterials,
|
|
6
|
+
createHouseKitMeshes,
|
|
7
|
+
createOrbitCamera,
|
|
8
|
+
createShipKit,
|
|
9
|
+
createShipMeshes,
|
|
10
|
+
createSimpleWater,
|
|
11
|
+
GeometryBuilder,
|
|
12
|
+
SHIP_PRESETS,
|
|
13
|
+
} from 'roamwright';
|
|
3
14
|
import { sstep } from 'roamwright/math/scalar.js';
|
|
4
15
|
import { C, TRS } from 'roamwright/geometry/primitives.js';
|
|
5
16
|
import { oneOf } from 'roamwright/geometry/ship-kit.js';
|
|
6
17
|
import { YARD_STOWED } from 'roamwright/geometry/ship-rig.js';
|
|
7
18
|
import { createBoatSailing, openWaterCourse } from 'roamwright/motion/boat-sailing.js';
|
|
8
19
|
import { createProps } from 'roamwright/geometry/props.js';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
20
|
+
import { initExample, makeRollingGround } from './stage.js';
|
|
21
|
+
import { scatterTrees } from './stage-kits.js';
|
|
11
22
|
|
|
12
23
|
const { canvas, renderer, camera, scene, worldGroup, seed, random, noise, hash, shapes } = initExample({
|
|
13
24
|
fallbackSeed: 42,
|
|
@@ -45,7 +56,7 @@ const coast = makeRollingGround({
|
|
|
45
56
|
worldGroup.add(coast);
|
|
46
57
|
|
|
47
58
|
// Shimmering harbour water grading from turquoise coastal shallows to deep sea blue.
|
|
48
|
-
const { mesh: water, timeUniform: waterTime } =
|
|
59
|
+
const { mesh: water, timeUniform: waterTime } = createSimpleWater({
|
|
49
60
|
width: 1600,
|
|
50
61
|
depth: 1600,
|
|
51
62
|
segs: 128,
|
|
@@ -111,8 +122,11 @@ const quayHouses = [
|
|
|
111
122
|
party: [0, 0, 0],
|
|
112
123
|
seed: seed * 19 + i,
|
|
113
124
|
}));
|
|
114
|
-
const houseMats =
|
|
115
|
-
const
|
|
125
|
+
const houseMats = createHouseKitMaterials({ doubleSide: true, roughness: 0.9 });
|
|
126
|
+
const { kitMeshes, kitStatic } = createHouseKitMeshes({ materials: houseMats });
|
|
127
|
+
const portGroup = new THREE.Group();
|
|
128
|
+
kitMeshes(houseKit.housesFromSpecs(quayHouses).kits, portGroup);
|
|
129
|
+
worldGroup.add(portGroup);
|
|
116
130
|
const propKit = houseKit.kitNew();
|
|
117
131
|
for (const [px, pz, ry, fn] of [
|
|
118
132
|
[-28, 25, 0.2, props.propCrates],
|
|
@@ -123,7 +137,7 @@ for (const [px, pz, ry, fn] of [
|
|
|
123
137
|
]) {
|
|
124
138
|
houseKit.kitAt(propKit, px, 1.65, pz, ry, false, fn, random);
|
|
125
139
|
}
|
|
126
|
-
|
|
140
|
+
kitStatic(propKit, portGroup);
|
|
127
141
|
|
|
128
142
|
// Coastal pines and cedars along the headland behind the warehouses.
|
|
129
143
|
scatterTrees({
|
|
@@ -185,17 +199,21 @@ for (const [i, spec, top] of [
|
|
|
185
199
|
sailing.add(Object.assign(boat, sailing.keeping(null, c, top, random)));
|
|
186
200
|
}
|
|
187
201
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
202
|
+
createDaylightSky({
|
|
203
|
+
scene,
|
|
204
|
+
renderer,
|
|
205
|
+
noise,
|
|
206
|
+
sky: {
|
|
207
|
+
zenith: [0.24, 0.48, 0.72],
|
|
208
|
+
horizon: [0.85, 0.88, 0.86],
|
|
209
|
+
sunDir: [-0.72, 0.34, -0.6],
|
|
210
|
+
},
|
|
195
211
|
sunPosition: [-75, 48, -62],
|
|
196
212
|
shadowRadius: 85,
|
|
197
213
|
shadowFar: 260,
|
|
198
214
|
normalBias: 0.05,
|
|
215
|
+
fogColor: 0xcfdcd9,
|
|
216
|
+
fogDensity: 0.0014,
|
|
199
217
|
});
|
|
200
218
|
|
|
201
219
|
const views = {
|
|
@@ -204,7 +222,7 @@ const views = {
|
|
|
204
222
|
sailing: { eye: [36, 12, -16], target: [-8, 4, -56] },
|
|
205
223
|
};
|
|
206
224
|
|
|
207
|
-
const rig =
|
|
225
|
+
const rig = createOrbitCamera({
|
|
208
226
|
camera,
|
|
209
227
|
canvas,
|
|
210
228
|
renderer,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import { GeometryBuilder, mulberry32 } from 'roamwright';
|
|
2
|
+
import { createSimpleWater, GeometryBuilder, mulberry32 } 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
|
-
import { makeRollingGround
|
|
6
|
+
import { makeRollingGround } from './stage.js';
|
|
7
7
|
import { buildCircularFence, scatterTrees, scatterTussocks } from './stage-kits.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -48,7 +48,7 @@ export function buildSmallWorldLand({ world, worldGroup, seed, rng, noise, hash,
|
|
|
48
48
|
});
|
|
49
49
|
worldGroup.add(terrain);
|
|
50
50
|
|
|
51
|
-
const { mesh: seaMesh, timeUniform: waterTime } =
|
|
51
|
+
const { mesh: seaMesh, timeUniform: waterTime } = createSimpleWater({
|
|
52
52
|
width: 1400,
|
|
53
53
|
depth: 1400,
|
|
54
54
|
segs: 140,
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createCrowdSystem,
|
|
4
|
+
createShipKit,
|
|
5
|
+
createShipMeshes,
|
|
6
|
+
grazeRound,
|
|
7
|
+
horsePose,
|
|
8
|
+
planTownsfolk,
|
|
9
|
+
rigHorse,
|
|
10
|
+
SHIP_PRESETS,
|
|
11
|
+
} from 'roamwright';
|
|
3
12
|
import { oneOf } from 'roamwright/geometry/ship-kit.js';
|
|
4
13
|
import { YARD_STOWED } from 'roamwright/geometry/ship-rig.js';
|
|
5
14
|
import { createBoatSailing, openWaterCourse } from 'roamwright/motion/boat-sailing.js';
|
|
6
15
|
import { BIRD_LOOKS } from 'roamwright/rendering/flier-bird-looks.js';
|
|
7
16
|
import { createFlock } from 'roamwright/rendering/flocks.js';
|
|
8
|
-
import { setupShowcaseCrowd } from './stage-kits.js';
|
|
9
17
|
|
|
10
18
|
/**
|
|
11
19
|
* Builds the living cast of the Small World showcase: walking market crowd,
|
|
@@ -13,8 +21,8 @@ import { setupShowcaseCrowd } from './stage-kits.js';
|
|
|
13
21
|
* and coastal gulls.
|
|
14
22
|
*/
|
|
15
23
|
export function buildSmallWorldLife({ world, worldGroup, rng, noise, hash, groundAt, spaceKit, camera, renderer }) {
|
|
16
|
-
const crowdSystem =
|
|
17
|
-
const {
|
|
24
|
+
const crowdSystem = createCrowdSystem({ scene: worldGroup, groundAt, spaceKit, camera, renderer });
|
|
25
|
+
const { addCrowd, herdSkins, streetBeasts } = crowdSystem;
|
|
18
26
|
|
|
19
27
|
const marketFolk = planTownsfolk({
|
|
20
28
|
rng,
|
|
@@ -64,7 +72,7 @@ export function buildSmallWorldLife({ world, worldGroup, rng, noise, hash, groun
|
|
|
64
72
|
return grazeRound(rng, world.pasture.x - 8 + Math.cos(a) * r, world.pasture.z + 7 + Math.sin(a) * r, 0.7, 0.12);
|
|
65
73
|
});
|
|
66
74
|
addCrowd(sheep, [0xf2ece0, 0xe6dfd0], world.pasture.x - 8, world.pasture.z + 7, 340, 'herd', herdSkins.herdLook('sheep'));
|
|
67
|
-
|
|
75
|
+
crowdSystem.build();
|
|
68
76
|
|
|
69
77
|
// Two rigged horses grazing in the pasture.
|
|
70
78
|
const horseSkin = new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.85 });
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import { createHouseKit, createStreetLamps, GeometryBuilder } from 'roamwright';
|
|
2
|
+
import { createHouseKit, createHouseKitMaterials, createHouseKitMeshes, createStreetLamps, GeometryBuilder } from 'roamwright';
|
|
3
3
|
import { townFrame } from 'roamwright/geometry/land-town-ground.js';
|
|
4
4
|
import { createProps } from 'roamwright/geometry/props.js';
|
|
5
|
-
import {
|
|
5
|
+
import { createShowcaseFortification } from './stage-kits.js';
|
|
6
6
|
|
|
7
7
|
const STYLES = {
|
|
8
8
|
town: {
|
|
@@ -81,15 +81,14 @@ export function buildSmallWorldTown({ world, worldGroup, seed, rng, noise, hash,
|
|
|
81
81
|
streetLit: true,
|
|
82
82
|
}));
|
|
83
83
|
|
|
84
|
-
const houseMats =
|
|
84
|
+
const houseMats = createHouseKitMaterials({ roughness: 0.9 });
|
|
85
85
|
const glass = new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.2, emissive: 0xffb25a, emissiveIntensity: 0 });
|
|
86
86
|
houseMats.glass = glass;
|
|
87
|
+
const { kitMeshes, kitStatic } = createHouseKitMeshes({ materials: houseMats });
|
|
87
88
|
|
|
88
|
-
const townGroup =
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
parent: worldGroup,
|
|
92
|
-
});
|
|
89
|
+
const townGroup = new THREE.Group();
|
|
90
|
+
kitMeshes(houseKit.housesFromSpecs(houseSpecs).kits, townGroup);
|
|
91
|
+
worldGroup.add(townGroup);
|
|
93
92
|
|
|
94
93
|
// Market stalls, well, cart, quay cargo and pasture haycock.
|
|
95
94
|
const props = createProps({ houseKit, shapes, vnoise: noise.vnoise, hash, horse: () => {} });
|
|
@@ -101,14 +100,12 @@ export function buildSmallWorldTown({ world, worldGroup, seed, rng, noise, hash,
|
|
|
101
100
|
houseKit.kitAt(propKit, 11, groundAt(11, -10), -10, -0.4, false, props.propCart, rng);
|
|
102
101
|
houseKit.kitAt(propKit, -16, 1.95, 22, 0.3, false, props.propCrates, rng);
|
|
103
102
|
houseKit.kitAt(propKit, 20, 1.95, 22, -0.2, false, props.propCrates, rng);
|
|
104
|
-
|
|
103
|
+
kitStatic(propKit, townGroup);
|
|
105
104
|
|
|
106
105
|
const hayBuilder = new GeometryBuilder();
|
|
107
106
|
props.haycock(hayBuilder, false);
|
|
108
107
|
const hayMesh = hayBuilder.mesh(new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.9 }), townGroup);
|
|
109
108
|
hayMesh.position.set(world.pasture.x + 14, groundAt(world.pasture.x + 14, world.pasture.z - 10), world.pasture.z - 10);
|
|
110
|
-
hayMesh.updateMatrix();
|
|
111
|
-
hayMesh.castShadow = hayMesh.receiveShadow = true;
|
|
112
109
|
|
|
113
110
|
// Street lamps along the quay and market square.
|
|
114
111
|
const lampUniforms = { night: { value: 0 }, time: { value: 0 }, sky: { value: new THREE.Color(0x223344) } };
|
package/examples/small-world.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import { createSpaces } from 'roamwright';
|
|
2
|
+
import { createDaylightSky, createOrbitCamera, createSkyPanorama, createSpaces } from 'roamwright';
|
|
3
3
|
import { litShare } from 'roamwright/math/lit-share.js';
|
|
4
4
|
import { createSunMoonCycle } from 'roamwright/rendering/daylight.js';
|
|
5
|
-
import {
|
|
5
|
+
import { initExample } from './stage.js';
|
|
6
6
|
import { buildSmallWorldLand } from './small-world-land.js';
|
|
7
7
|
import { buildSmallWorldTown } from './small-world-town.js';
|
|
8
8
|
import { buildSmallWorldLife } from './small-world-life.js';
|
|
@@ -94,14 +94,30 @@ const { glass, lampUniforms } = buildSmallWorldTown({ world: WORLD, worldGroup,
|
|
|
94
94
|
const life = buildSmallWorldLife({ world: WORLD, worldGroup, rng, noise, hash, groundAt, spaceKit, camera, renderer });
|
|
95
95
|
|
|
96
96
|
// Sky, daylight cycle, crowd updater and camera.
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
const {
|
|
98
|
+
sky: daySky,
|
|
99
|
+
sun,
|
|
100
|
+
hemi,
|
|
101
|
+
lightDir,
|
|
102
|
+
} = createDaylightSky({
|
|
103
|
+
scene,
|
|
104
|
+
renderer,
|
|
105
|
+
noise,
|
|
106
|
+
sky: {
|
|
107
|
+
zenith: [0.22, 0.46, 0.72],
|
|
108
|
+
horizon: [0.88, 0.84, 0.76],
|
|
109
|
+
cloudColor: [1.0, 0.94, 0.84],
|
|
110
|
+
sunGlow: [1.0, 0.8, 0.52],
|
|
111
|
+
sunDir: [-0.74, 0.26, 0.61],
|
|
112
|
+
},
|
|
113
|
+
sunPosition: [-120, 56, 95],
|
|
114
|
+
shadowRadius: 140,
|
|
115
|
+
shadowFar: 420,
|
|
116
|
+
normalBias: 0.07,
|
|
117
|
+
fogColor: 0xd8ddd6,
|
|
118
|
+
fogDensity: 0.0011,
|
|
103
119
|
});
|
|
104
|
-
const nightSky =
|
|
120
|
+
const nightSky = createSkyPanorama(noise, {
|
|
105
121
|
zenith: [0.03, 0.06, 0.14],
|
|
106
122
|
horizon: [0.09, 0.14, 0.24],
|
|
107
123
|
ground: [0.05, 0.07, 0.11],
|
|
@@ -111,15 +127,6 @@ const nightSky = makeSky(noise, {
|
|
|
111
127
|
cloudCover: 0.58,
|
|
112
128
|
stars: 0.9,
|
|
113
129
|
});
|
|
114
|
-
|
|
115
|
-
scene.fog = new THREE.FogExp2(0xd8ddd6, 0.0011);
|
|
116
|
-
const { sun, hemi } = setupSun(scene, renderer, {
|
|
117
|
-
sunPosition: [-120, 56, 95],
|
|
118
|
-
shadowRadius: 140,
|
|
119
|
-
shadowFar: 420,
|
|
120
|
-
normalBias: 0.07,
|
|
121
|
-
});
|
|
122
|
-
const lightDir = sun.position.clone().normalize();
|
|
123
130
|
const sunMoon = createSunMoonCycle({ sunRise: 0.85, sunOffset: 0.48, sunTilt: 0.22 });
|
|
124
131
|
const sunVec = new THREE.Vector3(),
|
|
125
132
|
moonVec = new THREE.Vector3();
|
|
@@ -186,7 +193,7 @@ const updater = life.createUpdater({
|
|
|
186
193
|
shadowFar: 420,
|
|
187
194
|
});
|
|
188
195
|
|
|
189
|
-
const rig =
|
|
196
|
+
const rig = createOrbitCamera({
|
|
190
197
|
camera,
|
|
191
198
|
canvas,
|
|
192
199
|
renderer,
|
package/examples/soundscape.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import {
|
|
3
|
+
createDaylightSky,
|
|
3
4
|
createFigureAssembler,
|
|
4
5
|
createFigureBuilder,
|
|
5
6
|
createFigurePose,
|
|
6
7
|
createHouseKit,
|
|
8
|
+
createHouseKitMaterials,
|
|
9
|
+
createHouseKitMeshes,
|
|
10
|
+
createOrbitCamera,
|
|
7
11
|
createShipKit,
|
|
8
12
|
createShipMeshes,
|
|
13
|
+
createSimpleWater,
|
|
9
14
|
figureActor,
|
|
10
15
|
GeometryBuilder,
|
|
11
16
|
geometryOf,
|
|
@@ -22,8 +27,8 @@ import { createWind } from '../motion/wind.js';
|
|
|
22
27
|
import { createScriptFoley } from '../runtime/foley-script.js';
|
|
23
28
|
import { createStrideFoley } from '../runtime/foley-strides.js';
|
|
24
29
|
import { createSoundscape } from '../runtime/soundscape.js';
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
30
|
+
import { initExample, makeRollingGround } from './stage.js';
|
|
31
|
+
import { scatterTrees } from './stage-kits.js';
|
|
27
32
|
|
|
28
33
|
const { canvas, renderer, camera, scene, worldGroup, seed, random, noise, hash, shapes } = initExample({
|
|
29
34
|
fallbackSeed: 42,
|
|
@@ -79,7 +84,7 @@ const terrain = makeRollingGround({
|
|
|
79
84
|
worldGroup.add(terrain);
|
|
80
85
|
|
|
81
86
|
// Shimmering lake water covering the western shore.
|
|
82
|
-
const { mesh: lakeMesh, timeUniform: waterTime } =
|
|
87
|
+
const { mesh: lakeMesh, timeUniform: waterTime } = createSimpleWater({
|
|
83
88
|
width: 240,
|
|
84
89
|
depth: 280,
|
|
85
90
|
segs: 80,
|
|
@@ -134,12 +139,7 @@ houseKit.kitAt(propKit, 7.5, groundAt(7.5, -5.5), -5.5, -0.45, false, (B, R) =>
|
|
|
134
139
|
houseKit.kitAt(propKit, 3.2, groundAt(3.2, -3.5), -3.5, 0.2, false, (B, R) => props.propBrazier(B, R), random);
|
|
135
140
|
houseKit.kitAt(propKit, 5.2, groundAt(5.2, -2.2), -2.2, 0.5, false, (B, R) => props.propWoodpile(B, R), random);
|
|
136
141
|
houseKit.kitAt(propKit, -6.5, groundAt(-6.5, -5.5), -5.5, 0.2, false, props.propCrates, random);
|
|
137
|
-
|
|
138
|
-
kitKeys: houseKit.KIT_KEYS,
|
|
139
|
-
kit: propKit,
|
|
140
|
-
materials: createShowcaseHouseMaterials(houseKit.KIT_KEYS, { doubleSide: true }),
|
|
141
|
-
parent: worldGroup,
|
|
142
|
-
});
|
|
142
|
+
createHouseKitMeshes({ materials: createHouseKitMaterials({ doubleSide: true }) }).kitStatic(propKit, worldGroup);
|
|
143
143
|
|
|
144
144
|
// Trees framing the lakeside meadow and swaying reeds along the water's edge.
|
|
145
145
|
scatterTrees({
|
|
@@ -211,8 +211,6 @@ const { wind, update: updateWind } = createWind({ speed: 2.0, direction: 0.5 });
|
|
|
211
211
|
let simTime = 0;
|
|
212
212
|
const motion = createFigurePose({ ground: groundAt, wind, clock: () => simTime });
|
|
213
213
|
motion.setAfoot(walker, 'beside');
|
|
214
|
-
// Keep the horse's world matrix current before the initial poseActor call so stepRig sees zero velocity.
|
|
215
|
-
worldGroup.updateMatrixWorld(true);
|
|
216
214
|
|
|
217
215
|
// Visual acoustic rings expanding where voices or footsteps fire.
|
|
218
216
|
const ringGeo = new THREE.RingGeometry(0.32, 0.42, 32).rotateX(-Math.PI / 2);
|
|
@@ -395,10 +393,8 @@ function crossShore(mounted) {
|
|
|
395
393
|
walker.x = -15.5;
|
|
396
394
|
walker.z = 1.5;
|
|
397
395
|
walker.yaw = Math.PI / 2;
|
|
398
|
-
if (mounted && !walker.mount) motion.
|
|
396
|
+
if (mounted && !walker.mount) motion.setAfoot(walker, false);
|
|
399
397
|
else if (!mounted && walker.mount) motion.setAfoot(walker, 'beside');
|
|
400
|
-
// Keep the horse's world matrix current before the initial poseActor call so stepRig sees zero velocity.
|
|
401
|
-
worldGroup.updateMatrixWorld(true);
|
|
402
398
|
const pace = mounted ? 6.5 : 1.9;
|
|
403
399
|
walker.move = motion.newMove(walker, 7.5, 1.5, 23 / pace);
|
|
404
400
|
foley.begin();
|
|
@@ -408,16 +404,20 @@ function crossShore(mounted) {
|
|
|
408
404
|
$('walk').addEventListener('click', () => crossShore(false));
|
|
409
405
|
$('ride').addEventListener('click', () => crossShore(true));
|
|
410
406
|
|
|
411
|
-
|
|
412
|
-
scene
|
|
413
|
-
|
|
407
|
+
createDaylightSky({
|
|
408
|
+
scene,
|
|
409
|
+
renderer,
|
|
410
|
+
noise,
|
|
411
|
+
sky: { sunDir: [-0.62, 0.42, -0.66] },
|
|
414
412
|
sunPosition: [-38, 38, -28],
|
|
415
413
|
shadowRadius: 48,
|
|
416
414
|
shadowFar: 160,
|
|
417
415
|
normalBias: 0.035,
|
|
416
|
+
fogColor: 0xd2ddd8,
|
|
417
|
+
fogDensity: 0.0028,
|
|
418
418
|
});
|
|
419
419
|
|
|
420
|
-
const rig =
|
|
420
|
+
const rig = createOrbitCamera({
|
|
421
421
|
camera,
|
|
422
422
|
canvas,
|
|
423
423
|
renderer,
|