roamwright 0.61.14 → 0.61.16

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 CHANGED
@@ -30,29 +30,30 @@ npm resolves the Three.js peer in a new project. Roamwright targets Three.js **0
30
30
 
31
31
  ## Examples
32
32
 
33
- Browse all nineteen examples on the [live showcase](https://enestaylan.github.io/roamwright/).
34
-
35
- | Live example | What the example shows | Source |
36
- | -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------- |
37
- | [A small world](https://enestaylan.github.io/roamwright/examples/small-world.html?seed=42) | A coastal valley with a walled harbour town, lamps, market crowd, pasture herds, ships and a passing day/night sky. | [small-world.js](examples/small-world.js) |
38
- | [Towns](https://enestaylan.github.io/roamwright/examples/towns.html?seed=7) | A village streaming in block by block along a winding valley road, with street lamps and windows lit after dark. | [towns.js](examples/towns.js) |
39
- | [Fortification](https://enestaylan.github.io/roamwright/examples/fortification.html?seed=11) | Walled coastal or inland town with towers, battlements, vaulted gatehouses, wall-walk and portal in three styles. | [fortification.js](examples/fortification.js) |
40
- | [Harbour of ships](https://enestaylan.github.io/roamwright/examples/ships.html?seed=42) | Every preset of the ship kit moored stern-on to a stone harbour quay while a cog and rowing boat tack offshore. | [ships.js](examples/ships.js) |
41
- | [Alpine viaduct](https://enestaylan.github.io/roamwright/examples/viaduct.html?seed=42) | Watch an electric train cross eight stone arches above a forested alpine river from valley, trackside or riverbank. | [viaduct.js](examples/viaduct.js) |
42
- | [Crowds and herds](https://enestaylan.github.io/roamwright/examples/crowds.html?seed=17) | Instanced market crowd, patrolling camp walkers, street dogs, grazing cattle and poultry with crowd alarms. | [crowds.js](examples/crowds.js) |
43
- | [Animal kit](https://enestaylan.github.io/roamwright/examples/animals.html?seed=42) | Horses, cattle, sheep, a pack camel, dogs and a cat animated on procedural quadruped skeletons in a fenced paddock. | [animals.js](examples/animals.js) |
44
- | [Figure motion](https://enestaylan.github.io/roamwright/examples/figure-motion.html?seed=11) | Full-body procedural locomotion on uneven ground: walk, run, sit, bow, draw and sheathe a blade, and mount a horse. | [figure-motion.js](examples/figure-motion.js) |
45
- | [Fliers](https://enestaylan.github.io/roamwright/examples/fliers.html?seed=7) | Moths around a lantern, animated and perched corvids on a crag, wheeling bird flocks and four-winged gliders aloft. | [fliers.js](examples/fliers.js) |
46
- | [Rooms](https://enestaylan.github.io/roamwright/examples/rooms.html?seed=42) | A furnished beamed room and a domed arcaded hall with baked window, lamp and hearth light by day or night. | [rooms.js](examples/rooms.js) |
47
- | [House kit](https://enestaylan.github.io/roamwright/examples/house-kit.html?seed=42) | Every built-in architectural form — gable, hip, flat, tower, round, dome and courtyard — arranged round a town square. | [house-kit.js](examples/house-kit.js) |
48
- | [Props and plants](https://enestaylan.github.io/roamwright/examples/props-and-plants.html?seed=42) | Camp, market, farm and road props beside every tree, shrub, grass tussock and waterside reed in the plant kit. | [props-and-plants.js](examples/props-and-plants.js) |
49
- | [Effects by day and night](https://enestaylan.github.io/roamwright/examples/effects.html?seed=3) | Budgeted campfires and light pools, drifting smoke shadows, hollow mist and particle bursts that scorch the ground. | [effects.js](examples/effects.js) |
50
- | [Soundscape](https://enestaylan.github.io/roamwright/examples/soundscape.html?seed=42) | Synthesised spatial audio and surface-aware stride foley across a lakeside shore of water, mud, sand, stone and earth. | [soundscape.js](examples/soundscape.js) |
51
- | [Figures](https://enestaylan.github.io/roamwright/examples/figure.html?seed=7) | Sculpted procedural characters from plain look specs — faces, hair, clothing, cloaks and custom weapons, near and far. | [figure.js](examples/figure.js) |
52
- | [A baked land](https://enestaylan.github.io/roamwright/examples/land.html?seed=7) | One height sheet baked row by row with erosion, coast, river ford, banked road, cliff-faced tel, quarry and upland mere. | [land.js](examples/land.js) |
53
- | [Island](https://enestaylan.github.io/roamwright/examples/island.html?seed=42) | Fractal terrain shapes a coastline, sandy coves, weathered boulders and coastal pines in turquoise shallows. | [island.js](examples/island.js) |
54
- | [Pacing and measuring](https://enestaylan.github.io/roamwright/examples/pacing.html?seed=42) | Device-aware presets, ground render order, frame-pacing watch and a live performance box over a coastal valley. | [pacing.js](examples/pacing.js) |
55
- | [Ruins, rocks & paved roads](https://enestaylan.github.io/roamwright/examples/ruins.html?seed=42) | Hilltop ruins, buried-town mounds, bedded outcrops, a paved arch highway with cedar avenue and a flagstone plaza. | [ruins.js](examples/ruins.js) |
33
+ Browse all twenty examples on the [live showcase](https://enestaylan.github.io/roamwright/).
34
+
35
+ | Live example | What the example shows | Source |
36
+ | -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
37
+ | [A small world](https://enestaylan.github.io/roamwright/examples/small-world.html?seed=42) | A coastal valley with a walled harbour town, lamps, market crowd, pasture herds, ships and a passing day/night sky. | [small-world.js](examples/small-world.js) |
38
+ | [Towns](https://enestaylan.github.io/roamwright/examples/towns.html?seed=7) | A village streaming in block by block along a winding valley road, with street lamps and windows lit after dark. | [towns.js](examples/towns.js) |
39
+ | [Town fittings](https://enestaylan.github.io/roamwright/examples/town-fittings.html?seed=42) | Walled courtyard gardens with instanced shrubs, harbour works and breakwater moles, street lamps and a desert storm wall. | [town-fittings.js](examples/town-fittings.js) |
40
+ | [Fortification](https://enestaylan.github.io/roamwright/examples/fortification.html?seed=11) | Walled coastal or inland town with towers, battlements, vaulted gatehouses, wall-walk and portal in three styles. | [fortification.js](examples/fortification.js) |
41
+ | [Harbour of ships](https://enestaylan.github.io/roamwright/examples/ships.html?seed=42) | Every preset of the ship kit moored stern-on to a stone harbour quay while a cog and rowing boat tack offshore. | [ships.js](examples/ships.js) |
42
+ | [Alpine viaduct](https://enestaylan.github.io/roamwright/examples/viaduct.html?seed=42) | Watch an electric train cross eight stone arches above a forested alpine river from valley, trackside or riverbank. | [viaduct.js](examples/viaduct.js) |
43
+ | [Crowds and herds](https://enestaylan.github.io/roamwright/examples/crowds.html?seed=17) | Instanced market crowd, patrolling camp walkers, street dogs, grazing cattle and poultry with crowd alarms. | [crowds.js](examples/crowds.js) |
44
+ | [Animal kit](https://enestaylan.github.io/roamwright/examples/animals.html?seed=42) | Horses, cattle, sheep, a pack camel, dogs and a cat animated on procedural quadruped skeletons in a fenced paddock. | [animals.js](examples/animals.js) |
45
+ | [Figure motion](https://enestaylan.github.io/roamwright/examples/figure-motion.html?seed=11) | Full-body procedural locomotion on uneven ground: walk, run, sit, bow, draw and sheathe a blade, and mount a horse. | [figure-motion.js](examples/figure-motion.js) |
46
+ | [Fliers](https://enestaylan.github.io/roamwright/examples/fliers.html?seed=7) | Moths around a lantern, animated and perched corvids on a crag, wheeling bird flocks and four-winged gliders aloft. | [fliers.js](examples/fliers.js) |
47
+ | [Rooms](https://enestaylan.github.io/roamwright/examples/rooms.html?seed=42) | A furnished beamed room and a domed arcaded hall with baked window, lamp and hearth light by day or night. | [rooms.js](examples/rooms.js) |
48
+ | [House kit](https://enestaylan.github.io/roamwright/examples/house-kit.html?seed=42) | Every built-in architectural form — gable, hip, flat, tower, round, dome and courtyard — arranged round a town square. | [house-kit.js](examples/house-kit.js) |
49
+ | [Props and plants](https://enestaylan.github.io/roamwright/examples/props-and-plants.html?seed=42) | Camp, market, farm and road props beside every tree, shrub, grass tussock and waterside reed in the plant kit. | [props-and-plants.js](examples/props-and-plants.js) |
50
+ | [Effects by day and night](https://enestaylan.github.io/roamwright/examples/effects.html?seed=3) | Budgeted campfires and light pools, drifting smoke shadows, hollow mist and particle bursts that scorch the ground. | [effects.js](examples/effects.js) |
51
+ | [Soundscape](https://enestaylan.github.io/roamwright/examples/soundscape.html?seed=42) | Synthesised spatial audio and surface-aware stride foley across a lakeside shore of water, mud, sand, stone and earth. | [soundscape.js](examples/soundscape.js) |
52
+ | [Figures](https://enestaylan.github.io/roamwright/examples/figure.html?seed=7) | Sculpted procedural characters from plain look specs — faces, hair, clothing, cloaks and custom weapons, near and far. | [figure.js](examples/figure.js) |
53
+ | [A baked land](https://enestaylan.github.io/roamwright/examples/land.html?seed=7) | One height sheet baked row by row with erosion, coast, river ford, banked road, cliff-faced tel, quarry and upland mere. | [land.js](examples/land.js) |
54
+ | [Island](https://enestaylan.github.io/roamwright/examples/island.html?seed=42) | Fractal terrain shapes a coastline, sandy coves, weathered boulders and coastal pines in turquoise shallows. | [island.js](examples/island.js) |
55
+ | [Pacing and measuring](https://enestaylan.github.io/roamwright/examples/pacing.html?seed=42) | Device-aware presets, ground render order, frame-pacing watch and a live performance box over a coastal valley. | [pacing.js](examples/pacing.js) |
56
+ | [Ruins, rocks & paved roads](https://enestaylan.github.io/roamwright/examples/ruins.html?seed=42) | Hilltop ruins, buried-town mounds, bedded outcrops, a paved arch highway with cedar avenue and a flagstone plaza. | [ruins.js](examples/ruins.js) |
56
57
 
57
58
  ### Run locally
58
59
 
@@ -9,11 +9,11 @@ import {
9
9
  createParticleSystem,
10
10
  createSiteSchedule,
11
11
  createSkyPanorama,
12
- GeometryBuilder,
12
+ scatterInstances,
13
13
  scatterTrees,
14
14
  } from 'roamwright';
15
15
  import { sstep } from 'roamwright/math/scalar.js';
16
- import { C, TRS } from 'roamwright/geometry/primitives.js';
16
+ import { C } from 'roamwright/geometry/primitives.js';
17
17
  import { createProps } from 'roamwright/geometry/props.js';
18
18
  import { createParticleEmitters, shakeCamera } from 'roamwright/rendering/particle-emitters.js';
19
19
  import { createParticleBursts } from 'roamwright/rendering/particle-bursts.js';
@@ -118,17 +118,23 @@ sites.push(
118
118
  createHouseKitMeshes({ materials: createHouseKitMaterials({ doubleSide: true }) }).kitStatic(propKit, worldGroup);
119
119
 
120
120
  // Boulders and pines ringing the hillside behind the camp and misty hollow.
121
- const rocks = new GeometryBuilder();
122
- for (let i = 0; i < 24; i++) {
123
- const a = random() * Math.PI * 2,
124
- r = 25 + random() * 24;
125
- const rx = campCenter.x + Math.cos(a) * r,
126
- rz = campCenter.z + Math.sin(a) * r;
127
- const s = 0.6 + random() * 1.3;
128
- rocks.add(shapes.rock, C(0x6e6a62, 0.15, random), TRS(rx, groundAt(rx, rz) - 0.1, rz, s * 1.4, s * 0.9, s, random() * Math.PI));
129
- }
130
- const rockMesh = rocks.mesh(new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.94, flatShading: true }), worldGroup);
131
- rockMesh.castShadow = rockMesh.receiveShadow = true;
121
+ scatterInstances({
122
+ geometries: [shapes.rock.clone().scale(1.4, 0.9, 1)],
123
+ parent: worldGroup,
124
+ material: new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.94, flatShading: true }),
125
+ attempts: 24,
126
+ maxPerBucket: 24,
127
+ random,
128
+ sample: () => {
129
+ const a = random() * Math.PI * 2,
130
+ r = 25 + random() * 24;
131
+ return [campCenter.x + Math.cos(a) * r, campCenter.z + Math.sin(a) * r];
132
+ },
133
+ groundAt,
134
+ sink: 0.1,
135
+ scaleRange: [0.6, 1.3],
136
+ colorAt: color => color.fromArray(C(0x6e6a62, 0.15, random)),
137
+ });
132
138
 
133
139
  scatterTrees({
134
140
  parent: worldGroup,
@@ -6,13 +6,13 @@ import {
6
6
  createRenderContext,
7
7
  createSimpleWater,
8
8
  createUnitShapes,
9
- GeometryBuilder,
9
+ scatterInstances,
10
10
  scatterTrees,
11
11
  mulberry32,
12
12
  } from 'roamwright';
13
13
  import { createHash } from 'roamwright/math/random.js';
14
14
  import { sstep } from 'roamwright/math/scalar.js';
15
- import { C, TRS } from 'roamwright/geometry/primitives.js';
15
+ import { C } from 'roamwright/geometry/primitives.js';
16
16
  import { createHeightfieldMesh } from 'roamwright/geometry/heightfield.js';
17
17
  import { readSeed } from './stage.js';
18
18
 
@@ -53,18 +53,25 @@ const island = createHeightfieldMesh({
53
53
  island.castShadow = true;
54
54
  worldGroup.add(island);
55
55
 
56
- // Sculpted weathered boulders along the rocky headland and coves.
57
- const stones = new GeometryBuilder();
58
- for (let i = 0; i < 140; i++) {
59
- const x = (random() - 0.5) * 82,
60
- z = (random() - 0.5) * 82;
61
- const y = height(x, z);
62
- if (y < -0.3 || y > 18) continue;
63
- const size = 0.45 + random() * 1.65;
64
- stones.add(shapes.rock, C(0x838076, 0.18, random), TRS(x, y - 0.25, z, size * 1.35, size * 0.82, size, random() * Math.PI));
65
- }
66
- const rockMesh = stones.mesh(new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.93, flatShading: true }), worldGroup);
67
- rockMesh.castShadow = rockMesh.receiveShadow = true;
56
+ // Sculpted weathered boulders along the rocky headland and coves, each tinted its own way.
57
+ scatterInstances({
58
+ geometries: [shapes.rock.clone().scale(1.35, 0.82, 1)],
59
+ parent: worldGroup,
60
+ material: new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.93, flatShading: true }),
61
+ attempts: 140,
62
+ maxPerBucket: 140,
63
+ random,
64
+ sample: () => {
65
+ const x = (random() - 0.5) * 82,
66
+ z = (random() - 0.5) * 82,
67
+ y = height(x, z);
68
+ return y < -0.3 || y > 18 ? null : [x, z];
69
+ },
70
+ groundAt: height,
71
+ sink: 0.25,
72
+ scaleRange: [0.45, 1.65],
73
+ colorAt: color => color.fromArray(C(0x838076, 0.18, random)),
74
+ });
68
75
 
69
76
  // Coastal pines and cedars clustered on the sheltered green slopes.
70
77
  scatterTrees({
package/examples/ruins.js CHANGED
@@ -16,7 +16,8 @@ import {
16
16
  import { instanceArrays, instancedMesh, putInstance } from 'roamwright/geometry/instances.js';
17
17
  import { C, TRS } from 'roamwright/geometry/primitives.js';
18
18
  import { sstep, TAU } from 'roamwright/math/scalar.js';
19
- import { initExample, makeRollingGround } from './stage.js';
19
+ import { createHeightfieldMesh } from 'roamwright/geometry/heightfield.js';
20
+ import { initExample } from './stage.js';
20
21
 
21
22
  const { canvas, renderer, camera, scene, worldGroup, seed, noise, hash, shapes } = initExample({
22
23
  fallbackSeed: 42,
@@ -48,7 +49,7 @@ const scrubTone = new THREE.Color(0x9a9168);
48
49
  const rockTone = new THREE.Color(0xb6a382);
49
50
  const hillTone = new THREE.Color(0xc2b296);
50
51
 
51
- const terrain = makeRollingGround({
52
+ const terrain = createHeightfieldMesh({
52
53
  size: 360,
53
54
  segs: 180,
54
55
  heightAt: height,
package/examples/stage.js CHANGED
@@ -27,9 +27,3 @@ export function initExample({ fallbackSeed = 42, fov = 42 } = {}) {
27
27
  const shapes = createUnitShapes(noise.fbm);
28
28
  return { canvas, ...ctx, seed, random, noise, hash, shapes };
29
29
  }
30
-
31
- /**
32
- * Vertex-colored rolling terrain mesh with natural variation.
33
- */
34
- // the examples' old name for the engine's rolling ground, kept for pages that still import it from here
35
- export { createHeightfieldMesh as makeRollingGround } from 'roamwright/geometry/heightfield.js';
@@ -0,0 +1,52 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <meta name="theme-color" content="#152c2c" />
7
+ <title>Town fittings · Roamwright</title>
8
+ <link rel="stylesheet" href="./showcase.css" />
9
+ <script type="importmap">
10
+ {
11
+ "imports": {
12
+ "three": "../node_modules/three/build/three.module.js",
13
+ "three/addons/": "../node_modules/three/examples/jsm/",
14
+ "roamwright": "../index.js",
15
+ "roamwright/": "../"
16
+ }
17
+ }
18
+ </script>
19
+ </head>
20
+ <body>
21
+ <canvas
22
+ tabindex="0"
23
+ aria-label="A walled courtyard garden beside a stone harbour with breakwater moles, moored warships, street lamps and a distant desert storm wall"
24
+ ></canvas>
25
+ <header>
26
+ <a class="back" href="../index.html"><span aria-hidden="true">←</span> Roamwright</a>
27
+ <div class="meta">
28
+ <a class="source" href="https://github.com/enestaylan/roamwright/blob/main/examples/town-fittings.js">Source</a>
29
+ <form method="get">
30
+ <label for="seed">Seed</label>
31
+ <input id="seed" name="seed" type="number" step="1" min="-2147483648" max="2147483647" value="42" required />
32
+ <button type="submit" title="Rebuild town fittings with this seed" aria-label="Rebuild town fittings with this seed">→</button>
33
+ </form>
34
+ </div>
35
+ </header>
36
+ <footer>
37
+ <div class="caption">
38
+ <h1>Town fittings</h1>
39
+ <p>Walled courtyard gardens with instanced shrubs, harbour works and breakwater moles, street lamps and a desert storm wall.</p>
40
+ </div>
41
+ <div class="tools">
42
+ <div class="views" role="group" aria-label="Camera viewpoint">
43
+ <button type="button" data-view="garden" aria-pressed="true">Garden</button>
44
+ <button type="button" data-view="harbour" aria-pressed="false">Harbour</button>
45
+ <button type="button" data-view="storm" aria-pressed="false">Storm wall</button>
46
+ </div>
47
+ <button type="button" class="action" id="hour" aria-pressed="false">Night</button>
48
+ </div>
49
+ </footer>
50
+ <script type="module" src="./town-fittings.js"></script>
51
+ </body>
52
+ </html>