roamwright 0.54.0 → 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 +11 -1
- package/motion/cast-actors.js +379 -0
- package/motion/cast-manager.js +321 -0
- package/motion/figure-mount.js +1 -0
- package/package.json +20 -1
- package/rendering/cast-stage.js +299 -0
- package/rendering/crowd-system.js +239 -0
- package/rendering/daylight-sky.js +212 -0
- package/rendering/house-kit-meshes.js +65 -16
- package/rendering/nameplate-groups.js +84 -0
- package/rendering/nameplates.js +386 -0
- package/rendering/orbit-camera.js +216 -0
- package/rendering/water-simple.js +112 -0
package/examples/animals.js
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
buildCamel,
|
|
4
|
+
buildCanine,
|
|
5
|
+
buildCattle,
|
|
6
|
+
caninePose,
|
|
7
|
+
createDaylightSky,
|
|
8
|
+
createHouseKit,
|
|
9
|
+
createHouseKitMaterials,
|
|
10
|
+
createHouseKitMeshes,
|
|
11
|
+
createOrbitCamera,
|
|
12
|
+
GeometryBuilder,
|
|
13
|
+
horsePose,
|
|
14
|
+
rigHorse,
|
|
15
|
+
} from 'roamwright';
|
|
3
16
|
import { sstep } from 'roamwright/math/scalar.js';
|
|
4
17
|
import { createProps } from 'roamwright/geometry/props.js';
|
|
5
|
-
import {
|
|
6
|
-
import { buildCircularFence,
|
|
18
|
+
import { initExample, makeRollingGround } from './stage.js';
|
|
19
|
+
import { buildCircularFence, scatterTrees, scatterTussocks } from './stage-kits.js';
|
|
7
20
|
|
|
8
21
|
const { canvas, renderer, camera, scene, worldGroup, seed, random, noise, hash, shapes } = initExample({
|
|
9
22
|
fallbackSeed: 42,
|
|
@@ -48,18 +61,13 @@ const props = createProps({ houseKit, shapes, vnoise: noise.vnoise, hash, horse:
|
|
|
48
61
|
const propKit = houseKit.kitNew();
|
|
49
62
|
houseKit.kitAt(propKit, -11, groundAt(-11, -7.5), -7.5, 0.3, false, props.propWell, random);
|
|
50
63
|
houseKit.kitAt(propKit, 11.5, groundAt(11.5, -7), -7, -0.4, false, (B, R) => props.propWoodpile(B, R), random);
|
|
51
|
-
const propGroup =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
materials: createShowcaseHouseMaterials(houseKit.KIT_KEYS, { doubleSide: true }),
|
|
55
|
-
parent: worldGroup,
|
|
56
|
-
});
|
|
64
|
+
const propGroup = new THREE.Group();
|
|
65
|
+
createHouseKitMeshes({ materials: createHouseKitMaterials({ doubleSide: true }) }).kitStatic(propKit, propGroup);
|
|
66
|
+
worldGroup.add(propGroup);
|
|
57
67
|
const hayBuilder = new GeometryBuilder();
|
|
58
68
|
props.haycock(hayBuilder, false);
|
|
59
69
|
const hayMesh = hayBuilder.mesh(new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.9 }), propGroup);
|
|
60
70
|
hayMesh.position.set(8.8, 0, -6.2);
|
|
61
|
-
hayMesh.updateMatrix();
|
|
62
|
-
hayMesh.castShadow = hayMesh.receiveShadow = true;
|
|
63
71
|
|
|
64
72
|
// Trees and meadow tussocks outside and along the fence line.
|
|
65
73
|
const { material: leafMat } = scatterTrees({
|
|
@@ -137,13 +145,17 @@ addCanine({ breed: 'wolf', h: 0.55, c1: 0x8a7a66, c2: 0x4a4038 }, -2.8, 5.4, 0.4
|
|
|
137
145
|
addCanine({ breed: 'cur', h: 0.42, c1: 0xc8b090, c2: 0x8a7050 }, 4.5, 5.2, -0.4, 9.6, 2.1);
|
|
138
146
|
addCanine({ breed: 'cat', h: 0.22, c1: 0xb8a68a, c2: 0x5a4636 }, 0.4, 5.2, -0.25);
|
|
139
147
|
|
|
140
|
-
|
|
141
|
-
scene
|
|
142
|
-
|
|
148
|
+
createDaylightSky({
|
|
149
|
+
scene,
|
|
150
|
+
renderer,
|
|
151
|
+
noise,
|
|
152
|
+
sky: { sunDir: [-0.68, 0.36, 0.64] },
|
|
143
153
|
sunPosition: [-22, 24, 18],
|
|
144
154
|
shadowRadius: 24,
|
|
145
155
|
shadowFar: 90,
|
|
146
156
|
normalBias: 0.03,
|
|
157
|
+
fogColor: 0xd3ded9,
|
|
158
|
+
fogDensity: 0.0042,
|
|
147
159
|
});
|
|
148
160
|
|
|
149
161
|
const views = {
|
|
@@ -153,7 +165,7 @@ const views = {
|
|
|
153
165
|
canines: { eye: [-1.4, 1.4, 9.4], target: [-0.8, 0.5, 5.2] },
|
|
154
166
|
};
|
|
155
167
|
|
|
156
|
-
const rig =
|
|
168
|
+
const rig = createOrbitCamera({
|
|
157
169
|
camera,
|
|
158
170
|
canvas,
|
|
159
171
|
renderer,
|
package/examples/crowds.js
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createCampGrid,
|
|
4
|
+
createCrowdSystem,
|
|
5
|
+
createDaylightSky,
|
|
6
|
+
createHouseKit,
|
|
7
|
+
createHouseKitMaterials,
|
|
8
|
+
createHouseKitMeshes,
|
|
9
|
+
createOrbitCamera,
|
|
10
|
+
createSpaces,
|
|
11
|
+
grazeRound,
|
|
12
|
+
planCampWalkers,
|
|
13
|
+
planTownsfolk,
|
|
14
|
+
} from 'roamwright';
|
|
3
15
|
import { sharedFields } from 'roamwright/motion/crowd-camp.js';
|
|
4
16
|
import { sstep } from 'roamwright/math/scalar.js';
|
|
5
17
|
import { C } from 'roamwright/geometry/primitives.js';
|
|
6
18
|
import { createProps } from 'roamwright/geometry/props.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
19
|
+
import { initExample, makeRollingGround } from './stage.js';
|
|
20
|
+
import { scatterTrees, scatterTussocks } from './stage-kits.js';
|
|
9
21
|
|
|
10
22
|
const {
|
|
11
23
|
canvas,
|
|
@@ -106,12 +118,7 @@ for (const [dx, dz] of [
|
|
|
106
118
|
houseKit.kitAt(propKit, fx, groundHeight(fx, fz), fz, rng() * Math.PI, false, (B, R) => props.propBrazier(B, R), rng);
|
|
107
119
|
}
|
|
108
120
|
|
|
109
|
-
|
|
110
|
-
kitKeys: houseKit.KIT_KEYS,
|
|
111
|
-
kit: propKit,
|
|
112
|
-
materials: createShowcaseHouseMaterials(houseKit.KIT_KEYS, { doubleSide: true }),
|
|
113
|
-
parent: worldGroup,
|
|
114
|
-
});
|
|
121
|
+
createHouseKitMeshes({ materials: createHouseKitMaterials({ doubleSide: true }) }).kitStatic(propKit, worldGroup);
|
|
115
122
|
|
|
116
123
|
// Trees and grass tussocks framing the meadow, market backdrop and pasture.
|
|
117
124
|
const { material: leafMat } = scatterTrees({
|
|
@@ -151,10 +158,10 @@ scatterTussocks({
|
|
|
151
158
|
},
|
|
152
159
|
});
|
|
153
160
|
|
|
154
|
-
// Wire up Roamwright's
|
|
161
|
+
// Wire up Roamwright's crowd system facade.
|
|
155
162
|
const spaceKit = createSpaces({ id: 'world', ground: groundHeight });
|
|
156
|
-
const crowdSystem =
|
|
157
|
-
const {
|
|
163
|
+
const crowdSystem = createCrowdSystem({ scene: worldGroup, groundAt: groundHeight, spaceKit, camera, renderer });
|
|
164
|
+
const { addCrowd, herdSkins, streetBeasts, beastsAbout, alarms } = crowdSystem;
|
|
158
165
|
|
|
159
166
|
// 1. Market crowd + street dogs
|
|
160
167
|
const marketFolk = planTownsfolk({
|
|
@@ -209,16 +216,19 @@ const cattle = Array.from({ length: 12 }, () => {
|
|
|
209
216
|
addCrowd(cattle, [0xffffff, 0xe8d9c5, 0xd4be9f], 44, 16, 260, 'herd', herdSkins.herdLook('cow'));
|
|
210
217
|
beastsAbout('hen', [[14, 11, 6, 4]], rng, 14, 11, 160, 'world');
|
|
211
218
|
|
|
212
|
-
|
|
219
|
+
crowdSystem.build();
|
|
213
220
|
|
|
214
|
-
|
|
215
|
-
scene
|
|
216
|
-
|
|
221
|
+
const { lightDir } = createDaylightSky({
|
|
222
|
+
scene,
|
|
223
|
+
renderer,
|
|
224
|
+
noise,
|
|
225
|
+
sky: { sunDir: [0.68, 0.34, 0.65] },
|
|
217
226
|
sunPosition: [62, 46, 58],
|
|
218
227
|
shadowRadius: 88,
|
|
219
228
|
shadowFar: 250,
|
|
229
|
+
fogColor: 0xd2ddd9,
|
|
230
|
+
fogDensity: 0.0022,
|
|
220
231
|
});
|
|
221
|
-
const lightDir = sun.position.clone().normalize();
|
|
222
232
|
|
|
223
233
|
let elapsed = 0,
|
|
224
234
|
frame = 0;
|
|
@@ -237,7 +247,7 @@ const views = {
|
|
|
237
247
|
overview: { eye: [8, 44, 82], target: [-6, 1, -6] },
|
|
238
248
|
};
|
|
239
249
|
|
|
240
|
-
const rig =
|
|
250
|
+
const rig = createOrbitCamera({
|
|
241
251
|
camera,
|
|
242
252
|
canvas,
|
|
243
253
|
renderer,
|
package/examples/effects.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createHouseKit,
|
|
4
|
+
createHouseKitMaterials,
|
|
5
|
+
createHouseKitMeshes,
|
|
6
|
+
createOrbitCamera,
|
|
7
|
+
createSkyPanorama,
|
|
8
|
+
GeometryBuilder,
|
|
9
|
+
} from 'roamwright';
|
|
3
10
|
import { sstep } from 'roamwright/math/scalar.js';
|
|
4
11
|
import { C, TRS } from 'roamwright/geometry/primitives.js';
|
|
5
12
|
import { createProps } from 'roamwright/geometry/props.js';
|
|
@@ -12,8 +19,8 @@ import { FLAME_KINDS, createFlameSources } from 'roamwright/rendering/flame-sour
|
|
|
12
19
|
import { createFireLightWatch } from 'roamwright/rendering/fire-light-watch.js';
|
|
13
20
|
import { perspectivePointScale } from 'roamwright/rendering/viewport.js';
|
|
14
21
|
import { createSiteSchedule } from 'roamwright/runtime/effect-sites.js';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
22
|
+
import { initExample } from './stage.js';
|
|
23
|
+
import { makeParticleNoiseTexture, scatterTrees } from './stage-kits.js';
|
|
17
24
|
|
|
18
25
|
const { canvas, renderer, camera, scene, worldGroup, fxScene, seed, random, noise, hash, shapes } = initExample({
|
|
19
26
|
fallbackSeed: 3,
|
|
@@ -107,12 +114,7 @@ sites.push(
|
|
|
107
114
|
{ type: 'mist', x: -26, z: 16, r: 15, size: 7.5, rate: 5 },
|
|
108
115
|
);
|
|
109
116
|
|
|
110
|
-
|
|
111
|
-
kitKeys: houseKit.KIT_KEYS,
|
|
112
|
-
kit: propKit,
|
|
113
|
-
materials: createShowcaseHouseMaterials(houseKit.KIT_KEYS, { doubleSide: true }),
|
|
114
|
-
parent: worldGroup,
|
|
115
|
-
});
|
|
117
|
+
createHouseKitMeshes({ materials: createHouseKitMaterials({ doubleSide: true }) }).kitStatic(propKit, worldGroup);
|
|
116
118
|
|
|
117
119
|
// Boulders and pines ringing the hillside behind the camp and misty hollow.
|
|
118
120
|
const rocks = new GeometryBuilder();
|
|
@@ -215,7 +217,7 @@ function fireBurst() {
|
|
|
215
217
|
}
|
|
216
218
|
}
|
|
217
219
|
|
|
218
|
-
const duskSky =
|
|
220
|
+
const duskSky = createSkyPanorama(noise, {
|
|
219
221
|
zenith: [0.09, 0.14, 0.27],
|
|
220
222
|
horizon: [0.58, 0.4, 0.31],
|
|
221
223
|
ground: [0.16, 0.14, 0.13],
|
|
@@ -245,7 +247,7 @@ const views = {
|
|
|
245
247
|
hollow: { eye: [-6, 8, 38], target: [-26, 0.5, 16] },
|
|
246
248
|
};
|
|
247
249
|
|
|
248
|
-
const rig =
|
|
250
|
+
const rig = createOrbitCamera({
|
|
249
251
|
camera,
|
|
250
252
|
canvas,
|
|
251
253
|
renderer,
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
createDaylightSky,
|
|
5
|
+
createFigureAssembler,
|
|
6
|
+
createFigureBuilder,
|
|
7
|
+
createFigurePose,
|
|
8
|
+
figureActor,
|
|
9
|
+
geometryOf,
|
|
10
|
+
rigHorse,
|
|
11
|
+
} from 'roamwright';
|
|
4
12
|
import { sstep } from 'roamwright/math/scalar.js';
|
|
5
13
|
import { createWind } from '../motion/wind.js';
|
|
6
|
-
import { initExample, makeRollingGround
|
|
14
|
+
import { initExample, makeRollingGround } from './stage.js';
|
|
7
15
|
import { buildCircularFence, scatterTrees, scatterTussocks } from './stage-kits.js';
|
|
8
16
|
|
|
9
17
|
const doing = document.getElementById('doing');
|
|
@@ -201,13 +209,17 @@ function describe() {
|
|
|
201
209
|
return (going ?? (a.mount ? 'In the saddle' : a.pose === 'sit' ? 'Sitting' : 'Standing')) + act;
|
|
202
210
|
}
|
|
203
211
|
|
|
204
|
-
|
|
205
|
-
scene
|
|
206
|
-
|
|
212
|
+
const { sun } = createDaylightSky({
|
|
213
|
+
scene,
|
|
214
|
+
renderer,
|
|
215
|
+
noise,
|
|
216
|
+
sky: { sunDir: [-0.7, 0.36, 0.62] },
|
|
207
217
|
sunPosition: [-8, 12, 8],
|
|
208
218
|
shadowRadius: 8,
|
|
209
219
|
shadowFar: 40,
|
|
210
220
|
normalBias: 0.025,
|
|
221
|
+
fogColor: 0xd4ded9,
|
|
222
|
+
fogDensity: 0.0048,
|
|
211
223
|
});
|
|
212
224
|
scene.add(sun.target);
|
|
213
225
|
|
package/examples/figure.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import {
|
|
3
|
+
createDaylightSky,
|
|
3
4
|
createFigureAssembler,
|
|
4
5
|
createFigureBuilder,
|
|
5
6
|
createNoise,
|
|
7
|
+
createOrbitCamera,
|
|
6
8
|
createRenderContext,
|
|
7
9
|
createUnitShapes,
|
|
8
10
|
GeometryBuilder,
|
|
@@ -13,10 +15,9 @@ import { createHash } from 'roamwright/math/random.js';
|
|
|
13
15
|
import { sstep } from 'roamwright/math/scalar.js';
|
|
14
16
|
import { C, TRS } from 'roamwright/geometry/primitives.js';
|
|
15
17
|
import { partsGeometry } from 'roamwright/geometry/foliage.js';
|
|
16
|
-
import { createBroadleaf } from 'roamwright/geometry/plant-broadleaf.js';
|
|
17
18
|
import { createPlantTints } from 'roamwright/geometry/plant-tints.js';
|
|
18
19
|
import { createTrees } from 'roamwright/geometry/plant-trees.js';
|
|
19
|
-
import {
|
|
20
|
+
import { makeRollingGround, readSeed } from './stage.js';
|
|
20
21
|
|
|
21
22
|
const canvas = document.querySelector('canvas');
|
|
22
23
|
const { renderer, camera, scene, worldGroup } = createRenderContext(canvas, { fov: 36 });
|
|
@@ -94,9 +95,8 @@ wallMesh.castShadow = wallMesh.receiveShadow = true;
|
|
|
94
95
|
// Broadleaf and cedar trees framing the hills behind the terrace.
|
|
95
96
|
const tints = createPlantTints({ fbm: noise.fbm, vnoise: noise.vnoise, hash });
|
|
96
97
|
const treeKit = createTrees({ hash, ...tints, seed });
|
|
97
|
-
const { broadleaf } = createBroadleaf(tints);
|
|
98
98
|
const leafMat = new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.88, side: THREE.DoubleSide });
|
|
99
|
-
const treeGeos = [broadleaf(), treeKit.cedar(0), treeKit.conifer()].map(t => partsGeometry(t.near
|
|
99
|
+
const treeGeos = [treeKit.broadleaf(), treeKit.cedar(0), treeKit.conifer()].map(t => partsGeometry(t.near));
|
|
100
100
|
const treePools = treeGeos.map(geo => {
|
|
101
101
|
const m = new THREE.InstancedMesh(geo, leafMat, 22);
|
|
102
102
|
m.castShadow = m.receiveShadow = true;
|
|
@@ -198,13 +198,17 @@ function applyLod() {
|
|
|
198
198
|
}
|
|
199
199
|
applyLod();
|
|
200
200
|
|
|
201
|
-
|
|
202
|
-
scene
|
|
203
|
-
|
|
201
|
+
createDaylightSky({
|
|
202
|
+
scene,
|
|
203
|
+
renderer,
|
|
204
|
+
noise,
|
|
205
|
+
sky: { sunDir: [-0.65, 0.34, 0.68] },
|
|
204
206
|
sunPosition: [-14, 16, 15],
|
|
205
207
|
shadowRadius: 12,
|
|
206
208
|
shadowFar: 65,
|
|
207
209
|
normalBias: 0.02,
|
|
210
|
+
fogColor: 0xd4ded9,
|
|
211
|
+
fogDensity: 0.0055,
|
|
208
212
|
});
|
|
209
213
|
camera.layers.enable(1);
|
|
210
214
|
|
|
@@ -214,7 +218,7 @@ const views = {
|
|
|
214
218
|
gear: { eye: [1.6, 1.65, -4.8], target: [0.2, 1.0, 0] },
|
|
215
219
|
};
|
|
216
220
|
|
|
217
|
-
const rig =
|
|
221
|
+
const rig = createOrbitCamera({
|
|
218
222
|
camera,
|
|
219
223
|
canvas,
|
|
220
224
|
renderer,
|
package/examples/fliers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import { createStreetLamps } from 'roamwright';
|
|
2
|
+
import { createDaylightSky, createOrbitCamera, createStreetLamps } 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';
|
|
@@ -13,7 +13,7 @@ import { createCorvidFigure } from 'roamwright/rendering/flier-corvid-figure.js'
|
|
|
13
13
|
import { createLongFlierCompany } from 'roamwright/rendering/flier-long-body-company.js';
|
|
14
14
|
import { createFlierShapes, createSwarm } from 'roamwright/rendering/flier-swarm.js';
|
|
15
15
|
import { createFlock } from 'roamwright/rendering/flocks.js';
|
|
16
|
-
import {
|
|
16
|
+
import { initExample, makeRollingGround } from './stage.js';
|
|
17
17
|
import { scatterTrees, scatterTussocks } from './stage-kits.js';
|
|
18
18
|
|
|
19
19
|
const { canvas, renderer, camera, scene, worldGroup, seed, random, noise, hash, shapes } = initExample({
|
|
@@ -218,20 +218,24 @@ const company = createLongFlierCompany({ count: 4, shapes: longFlierArrays(), ti
|
|
|
218
218
|
worldGroup.add(company.group);
|
|
219
219
|
const flier = { x: 0, y: 0, z: 0, ry: 0, rx: 0, rz: 0 };
|
|
220
220
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
221
|
+
createDaylightSky({
|
|
222
|
+
scene,
|
|
223
|
+
renderer,
|
|
224
|
+
noise,
|
|
225
|
+
sky: {
|
|
226
|
+
zenith: [0.22, 0.4, 0.64],
|
|
227
|
+
horizon: [0.88, 0.78, 0.67],
|
|
228
|
+
cloudColor: [0.98, 0.9, 0.79],
|
|
229
|
+
sunGlow: [1.0, 0.76, 0.46],
|
|
230
|
+
sunDir: [-0.74, 0.2, -0.64],
|
|
231
|
+
},
|
|
230
232
|
sunPosition: [-46, 22, -38],
|
|
231
233
|
sunColor: 0xffd5a2,
|
|
232
234
|
sunIntensity: 2.5,
|
|
233
235
|
shadowRadius: 36,
|
|
234
236
|
shadowFar: 140,
|
|
237
|
+
fogColor: 0xd3cfc6,
|
|
238
|
+
fogDensity: 0.0028,
|
|
235
239
|
});
|
|
236
240
|
|
|
237
241
|
const views = {
|
|
@@ -240,7 +244,7 @@ const views = {
|
|
|
240
244
|
skies: { eye: [6, 5.5, 18], target: [-4, 15, -24] },
|
|
241
245
|
};
|
|
242
246
|
|
|
243
|
-
const rig =
|
|
247
|
+
const rig = createOrbitCamera({
|
|
244
248
|
camera,
|
|
245
249
|
canvas,
|
|
246
250
|
renderer,
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
buildPortalGateway,
|
|
4
|
+
createDaylightSky,
|
|
5
|
+
createHouseKit,
|
|
6
|
+
createHouseKitMaterials,
|
|
7
|
+
createHouseKitMeshes,
|
|
8
|
+
createOrbitCamera,
|
|
9
|
+
createSimpleWater,
|
|
10
|
+
createSpaces,
|
|
11
|
+
mulberry32,
|
|
12
|
+
} from 'roamwright';
|
|
3
13
|
import { townFrame } from 'roamwright/geometry/land-town-ground.js';
|
|
4
14
|
import { C } from 'roamwright/geometry/primitives.js';
|
|
5
15
|
import { sstep } from 'roamwright/math/scalar.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
16
|
+
import { initExample, makeRollingGround } from './stage.js';
|
|
17
|
+
import { createShowcaseFortification, scatterTrees } from './stage-kits.js';
|
|
8
18
|
|
|
9
19
|
const { canvas, renderer, camera, scene, worldGroup, seed, noise, hash, shapes } = initExample({
|
|
10
20
|
fallbackSeed: 11,
|
|
@@ -169,11 +179,10 @@ wards.forEach(([hx, hz], i) => {
|
|
|
169
179
|
...(form === 'courtyard' ? { court: [4, 3.5] } : {}),
|
|
170
180
|
});
|
|
171
181
|
});
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
});
|
|
182
|
+
createHouseKitMeshes({ materials: createHouseKitMaterials({ roughness: 0.92 }) }).kitMeshes(
|
|
183
|
+
houseKit.housesFromSpecs(houseSpecs).kits,
|
|
184
|
+
worldGroup,
|
|
185
|
+
);
|
|
177
186
|
|
|
178
187
|
// Rolling warm coastal/Mediterranean terrain.
|
|
179
188
|
const earthCol = new THREE.Color(0xbca881),
|
|
@@ -200,7 +209,7 @@ worldGroup.add(terrain);
|
|
|
200
209
|
let waterTick = null;
|
|
201
210
|
if (coastal) {
|
|
202
211
|
// Wide sea sheet extending well into the coastal haze so the horizon fades seamlessly into the sky.
|
|
203
|
-
const { mesh, timeUniform } =
|
|
212
|
+
const { mesh, timeUniform } = createSimpleWater({
|
|
204
213
|
width: 4800,
|
|
205
214
|
depth: 3600,
|
|
206
215
|
segs: 112,
|
|
@@ -237,14 +246,16 @@ scatterTrees({
|
|
|
237
246
|
},
|
|
238
247
|
});
|
|
239
248
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
249
|
+
createDaylightSky({
|
|
250
|
+
scene,
|
|
251
|
+
renderer,
|
|
252
|
+
noise,
|
|
253
|
+
sky: {
|
|
254
|
+
zenith: [0.25, 0.48, 0.72],
|
|
255
|
+
horizon: [0.86, 0.85, 0.79],
|
|
256
|
+
sunGlow: [1.0, 0.86, 0.6],
|
|
257
|
+
sunDir: [0.7, 0.34, -0.62],
|
|
258
|
+
},
|
|
248
259
|
sunPosition: [145, 78, -110],
|
|
249
260
|
sunColor: 0xffe4bc,
|
|
250
261
|
sunIntensity: 2.75,
|
|
@@ -252,6 +263,8 @@ setupSun(scene, renderer, {
|
|
|
252
263
|
shadowFar: 460,
|
|
253
264
|
normalBias: 0.08,
|
|
254
265
|
staticShadows: !coastal,
|
|
266
|
+
fogColor: 0xdad8cc,
|
|
267
|
+
fogDensity: coastal ? 0.00145 : 0.00095,
|
|
255
268
|
});
|
|
256
269
|
|
|
257
270
|
const views = {
|
|
@@ -260,7 +273,7 @@ const views = {
|
|
|
260
273
|
citadel: { eye: [36, 20, -68], target: [0, 8, -22] },
|
|
261
274
|
};
|
|
262
275
|
|
|
263
|
-
const rig =
|
|
276
|
+
const rig = createOrbitCamera({
|
|
264
277
|
camera,
|
|
265
278
|
canvas,
|
|
266
279
|
renderer,
|
package/examples/house-kit.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import { createHouseKit } from 'roamwright';
|
|
2
|
+
import { createDaylightSky, createHouseKit, createHouseKitMaterials, createHouseKitMeshes, createOrbitCamera } from 'roamwright';
|
|
3
3
|
import { sstep } from 'roamwright/math/scalar.js';
|
|
4
4
|
import { createProps } from 'roamwright/geometry/props.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { initExample, makeRollingGround } from './stage.js';
|
|
6
|
+
import { scatterTrees } from './stage-kits.js';
|
|
7
7
|
|
|
8
8
|
const { canvas, renderer, camera, scene, worldGroup, seed, random, noise, hash, shapes } = initExample({
|
|
9
9
|
fallbackSeed: 42,
|
|
@@ -113,9 +113,12 @@ const specs = layout.map((item, i) => {
|
|
|
113
113
|
// Washing line strung between the two gable cottages on the north-west side.
|
|
114
114
|
specs.push({ x: -18, y: 0, z: -6, seed, build: 'washing', ax: -21, ay: 5.2, az: -4.2, bx: -14, by: 5.3, bz: -6.4 });
|
|
115
115
|
|
|
116
|
-
const materials =
|
|
116
|
+
const materials = createHouseKitMaterials({ roughness: 0.9 });
|
|
117
117
|
materials.glass = new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.2, emissive: 0x3b2612 });
|
|
118
|
-
const
|
|
118
|
+
const { kitMeshes, kitStatic } = createHouseKitMeshes({ materials });
|
|
119
|
+
const houses = new THREE.Group();
|
|
120
|
+
kitMeshes(houseKit.housesFromSpecs(specs).kits, houses);
|
|
121
|
+
worldGroup.add(houses);
|
|
119
122
|
|
|
120
123
|
// Small town-square props (well, crates, cart) to anchor the plaza scale.
|
|
121
124
|
const props = createProps({ houseKit, shapes, vnoise: noise.vnoise, hash, horse: () => {} });
|
|
@@ -123,7 +126,7 @@ const propKit = houseKit.kitNew();
|
|
|
123
126
|
houseKit.kitAt(propKit, 0.5, ground(0.5, 1.5), 1.5, 0.3, false, props.propWell, random);
|
|
124
127
|
houseKit.kitAt(propKit, -8.5, ground(-8.5, -2.5), -2.5, 0.4, false, props.propCrates, random);
|
|
125
128
|
houseKit.kitAt(propKit, 11.5, ground(11.5, -2.5), -2.5, -0.5, false, props.propCart, random);
|
|
126
|
-
|
|
129
|
+
kitStatic(propKit, houses);
|
|
127
130
|
|
|
128
131
|
// Trees framing the green hills behind the square.
|
|
129
132
|
scatterTrees({
|
|
@@ -146,13 +149,17 @@ scatterTrees({
|
|
|
146
149
|
},
|
|
147
150
|
});
|
|
148
151
|
|
|
149
|
-
|
|
150
|
-
scene
|
|
151
|
-
|
|
152
|
+
createDaylightSky({
|
|
153
|
+
scene,
|
|
154
|
+
renderer,
|
|
155
|
+
noise,
|
|
156
|
+
sky: { sunDir: [-0.74, 0.32, 0.58] },
|
|
152
157
|
sunPosition: [-58, 36, 46],
|
|
153
158
|
shadowRadius: 56,
|
|
154
159
|
shadowFar: 190,
|
|
155
160
|
staticShadows: true,
|
|
161
|
+
fogColor: 0xd4ded9,
|
|
162
|
+
fogDensity: 0.0022,
|
|
156
163
|
});
|
|
157
164
|
|
|
158
165
|
const views = {
|
|
@@ -161,7 +168,7 @@ const views = {
|
|
|
161
168
|
towers: { eye: [36, 13, 24], target: [18, 4.5, -1] },
|
|
162
169
|
};
|
|
163
170
|
|
|
164
|
-
|
|
171
|
+
createOrbitCamera({
|
|
165
172
|
camera,
|
|
166
173
|
canvas,
|
|
167
174
|
renderer,
|
package/examples/island.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createDaylightSky,
|
|
4
|
+
createNoise,
|
|
5
|
+
createOrbitCamera,
|
|
6
|
+
createRenderContext,
|
|
7
|
+
createSimpleWater,
|
|
8
|
+
createUnitShapes,
|
|
9
|
+
GeometryBuilder,
|
|
10
|
+
mulberry32,
|
|
11
|
+
} from 'roamwright';
|
|
3
12
|
import { createHash } from 'roamwright/math/random.js';
|
|
4
13
|
import { sstep } from 'roamwright/math/scalar.js';
|
|
5
14
|
import { C, TRS } from 'roamwright/geometry/primitives.js';
|
|
6
15
|
import { partsGeometry } from 'roamwright/geometry/foliage.js';
|
|
7
16
|
import { createPlantTints } from 'roamwright/geometry/plant-tints.js';
|
|
8
17
|
import { createTrees } from 'roamwright/geometry/plant-trees.js';
|
|
9
|
-
import {
|
|
18
|
+
import { makeRollingGround, readSeed } from './stage.js';
|
|
10
19
|
|
|
11
20
|
const canvas = document.querySelector('canvas');
|
|
12
21
|
const { renderer, camera, scene, worldGroup } = createRenderContext(canvas, { fov: 40 });
|
|
@@ -62,7 +71,7 @@ rockMesh.castShadow = rockMesh.receiveShadow = true;
|
|
|
62
71
|
const tints = createPlantTints({ fbm, vnoise, hash });
|
|
63
72
|
const treeKit = createTrees({ hash, ...tints, seed });
|
|
64
73
|
const leafMat = new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.88, side: THREE.DoubleSide });
|
|
65
|
-
const treeGeos = [treeKit.conifer(), treeKit.cedar(0)].map(t => partsGeometry(t.near
|
|
74
|
+
const treeGeos = [treeKit.conifer(), treeKit.cedar(0)].map(t => partsGeometry(t.near));
|
|
66
75
|
const treePools = treeGeos.map(geo => {
|
|
67
76
|
const m = new THREE.InstancedMesh(geo, leafMat, 60);
|
|
68
77
|
m.castShadow = m.receiveShadow = true;
|
|
@@ -87,7 +96,7 @@ for (let i = 0; i < 240; i++) {
|
|
|
87
96
|
for (const pool of treePools) pool.instanceMatrix.needsUpdate = true;
|
|
88
97
|
|
|
89
98
|
// Shimmering ocean water with shallow turquoise shoals grading into deep sea blue.
|
|
90
|
-
const { mesh: water, timeUniform: waterTime } =
|
|
99
|
+
const { mesh: water, timeUniform: waterTime } = createSimpleWater({
|
|
91
100
|
width: 1100,
|
|
92
101
|
depth: 1100,
|
|
93
102
|
segs: 140,
|
|
@@ -99,18 +108,22 @@ const { mesh: water, timeUniform: waterTime } = makeWaterMesh({
|
|
|
99
108
|
});
|
|
100
109
|
worldGroup.add(water);
|
|
101
110
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
111
|
+
createDaylightSky({
|
|
112
|
+
scene,
|
|
113
|
+
renderer,
|
|
114
|
+
noise,
|
|
115
|
+
sky: {
|
|
116
|
+
zenith: [0.22, 0.48, 0.74],
|
|
117
|
+
horizon: [0.84, 0.89, 0.88],
|
|
118
|
+
sunDir: [-0.7, 0.34, 0.62],
|
|
119
|
+
},
|
|
109
120
|
sunPosition: [-64, 38, 52],
|
|
110
121
|
shadowRadius: 56,
|
|
111
122
|
shadowFar: 185,
|
|
112
123
|
normalBias: 0.05,
|
|
113
124
|
staticShadows: true,
|
|
125
|
+
fogColor: 0xcbdce0,
|
|
126
|
+
fogDensity: 0.0022,
|
|
114
127
|
});
|
|
115
128
|
|
|
116
129
|
const views = {
|
|
@@ -119,7 +132,7 @@ const views = {
|
|
|
119
132
|
summit: { eye: [24, 34, -32], target: [0, 7, 4] },
|
|
120
133
|
};
|
|
121
134
|
|
|
122
|
-
const rig =
|
|
135
|
+
const rig = createOrbitCamera({
|
|
123
136
|
camera,
|
|
124
137
|
canvas,
|
|
125
138
|
renderer,
|