roamwright 0.61.27 → 0.61.28

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.
@@ -86,22 +86,32 @@ export function addLightPool(group, x, y, z, radius, options = {}) {
86
86
  }
87
87
 
88
88
  /**
89
- * Add a dark, glossy oval or circular pool of still water lying in a courtyard basin or hollow.
89
+ * Add a glossy oval or circular pool of still water (or liquid decal) lying flat in a basin, spring
90
+ * or hollow. Pass `material` to share an existing water/liquid material, or omit it to create a
91
+ * `MeshStandardMaterial` from `color`, `roughness`, `metalness`, `transparent` and `opacity`.
92
+ * Pass `radius` (with optional `scaleX`/`scaleZ`) to size the `CircleGeometry` directly, or omit it
93
+ * to scale a unit-diameter disc by `(width, depth)`.
90
94
  *
91
- * @param {THREE.Object3D} group - Destination scene or group.
92
- * @param {object} options
95
+ * @param {THREE.Object3D | null} group - Destination scene or group.
96
+ * @param {object} [options]
93
97
  * @param {{ x: number, z: number }} [options.origin={ x: 0, z: 0 }] - Local frame world origin.
94
98
  * @param {number} [options.x=0] - Local X position in metres.
95
- * @param {number} [options.y=0] - Water surface elevation in metres.
99
+ * @param {number} [options.y=0] - Surface elevation in metres.
96
100
  * @param {number} [options.z=0] - Local Z position in metres.
97
- * @param {number} [options.width=2] - Pool width in metres.
98
- * @param {number} [options.depth=2] - Pool depth in metres.
101
+ * @param {number} [options.width=2] - Pool width in metres (when `radius` is omitted).
102
+ * @param {number} [options.depth=2] - Pool depth in metres (when `radius` is omitted).
103
+ * @param {number | null} [options.radius=null] - Explicit `CircleGeometry` radius in metres.
104
+ * @param {number} [options.scaleX=1] - X scale multiplier when `radius` is set.
105
+ * @param {number} [options.scaleZ=1] - Z scale multiplier when `radius` is set.
99
106
  * @param {number} [options.yaw=0] - Rotation around Y in radians.
100
- * @param {number} [options.color=0x1c2a2a] - Water base sRGB colour.
101
- * @param {number} [options.roughness=0.05] - Surface roughness.
102
- * @param {number} [options.metalness=0.4] - Surface reflectivity factor.
103
- * @param {number} [options.opacity=0.88] - Water opacity.
107
+ * @param {number} [options.color=0x1c2a2a] - Base sRGB colour when `material` is omitted.
108
+ * @param {number} [options.roughness=0.05] - Surface roughness when `material` is omitted.
109
+ * @param {number} [options.metalness=0.4] - Surface reflectivity factor when `material` is omitted.
110
+ * @param {boolean} [options.transparent=true] - Whether the default material is transparent.
111
+ * @param {number} [options.opacity=0.88] - Opacity when `material` is omitted and `transparent` is true.
112
+ * @param {THREE.Material | null} [options.material=null] - Optional shared material to reuse.
104
113
  * @param {number} [options.segments=20] - Perimeter circle segments.
114
+ * @param {number | null} [options.renderOrder=null] - Optional Three.js `renderOrder`.
105
115
  * @returns {THREE.Mesh}
106
116
  */
107
117
  export function addStillPool(group, options = {}) {
@@ -112,24 +122,107 @@ export function addStillPool(group, options = {}) {
112
122
  z = 0,
113
123
  width = 2,
114
124
  depth = 2,
125
+ radius = null,
126
+ scaleX = 1,
127
+ scaleZ = 1,
115
128
  yaw = 0,
116
129
  color = 0x1c2a2a,
117
130
  roughness = 0.05,
118
131
  metalness = 0.4,
132
+ transparent = true,
119
133
  opacity = 0.88,
134
+ material = null,
120
135
  segments = 20,
136
+ renderOrder = null,
121
137
  } = options;
122
- const water = new THREE.Mesh(
123
- new THREE.CircleGeometry(0.5, segments).rotateX(-Math.PI / 2),
124
- new THREE.MeshStandardMaterial({ color, roughness, metalness, transparent: true, opacity }),
125
- );
138
+ const mat =
139
+ material ??
140
+ new THREE.MeshStandardMaterial(
141
+ transparent ? { color, roughness, metalness, transparent: true, opacity } : { color, roughness, metalness },
142
+ );
143
+ const geo = new THREE.CircleGeometry(radius ?? 0.5, segments).rotateX(-Math.PI / 2);
144
+ const water = new THREE.Mesh(geo, mat);
126
145
  water.position.set(origin.x + x, y, origin.z + z);
127
- water.scale.set(width, 1, depth);
128
- water.rotation.y = yaw;
129
- group.add(water);
146
+ if (radius === null) water.scale.set(width, 1, depth);
147
+ else if (scaleX !== 1 || scaleZ !== 1) water.scale.set(scaleX, 1, scaleZ);
148
+ if (yaw) water.rotation.y = yaw;
149
+ if (renderOrder !== null) water.renderOrder = renderOrder;
150
+ if (group) group.add(water);
130
151
  return water;
131
152
  }
132
153
 
154
+ /** Default emissive core and lamp-threshold settings for {@link addFlame}. */
155
+ export const FLAME_DEFAULTS = Object.freeze({
156
+ color: 0xffb24a,
157
+ boost: 1.5,
158
+ lampSize: 0.2,
159
+ lampLight: Object.freeze({ lift: 0.25, light: 0.14 }),
160
+ });
161
+
162
+ /**
163
+ * Place a glowing flame core at `(x, y, z)` in local coordinates offset by `origin` and invoke an
164
+ * optional `onSite` callback with the fire-site parameters (attaching `lampLight` overrides when
165
+ * `size < lampSize` so small lamp wicks keep low, tight lighting).
166
+ *
167
+ * @param {THREE.Object3D | null} group - Destination group receiving the glowing flame core.
168
+ * @param {object} options
169
+ * @param {{ x: number, z: number }} [options.origin={ x: 0, z: 0 }] - Local frame world origin.
170
+ * @param {number} [options.x=0] - Local X in metres.
171
+ * @param {number} [options.y=0] - World Y in metres.
172
+ * @param {number} [options.z=0] - Local Z in metres.
173
+ * @param {number} [options.size=0.3] - Flame size in metres.
174
+ * @param {number} [options.color=FLAME_DEFAULTS.color] - Emissive core sRGB hex colour.
175
+ * @param {number} [options.boost=FLAME_DEFAULTS.boost] - Emissive intensity multiplier.
176
+ * @param {number} [options.lampSize=FLAME_DEFAULTS.lampSize] - Threshold below which `lampLight` is applied.
177
+ * @param {{ lift: number, light: number }} [options.lampLight=FLAME_DEFAULTS.lampLight] - Light override for small wicks.
178
+ * @param {object} [options.shapes] - Unit shapes containing `sph`.
179
+ * @param {((geo: THREE.BufferGeometry, hex: number, boost: number, group: THREE.Object3D | null) => THREE.Mesh) | null} [options.makeGlowMesh=null] - Custom emissive mesh factory.
180
+ * @param {((site: object) => void) | null} [options.onSite=null] - Optional callback receiving the fire effect-site record.
181
+ * @param {string} [options.space='world'] - Host space id stored on the emitted site record.
182
+ * @returns {{ core: THREE.Mesh, site: object }}
183
+ */
184
+ export function addFlame(group, options = {}) {
185
+ const {
186
+ origin = { x: 0, z: 0 },
187
+ x = 0,
188
+ y = 0,
189
+ z = 0,
190
+ size = 0.3,
191
+ color = FLAME_DEFAULTS.color,
192
+ boost = FLAME_DEFAULTS.boost,
193
+ lampSize = FLAME_DEFAULTS.lampSize,
194
+ lampLight = FLAME_DEFAULTS.lampLight,
195
+ shapes = defaultShapes(),
196
+ makeGlowMesh = null,
197
+ onSite = null,
198
+ space = 'world',
199
+ } = options;
200
+ const core = makeGlowMesh
201
+ ? makeGlowMesh(shapes.sph, color, boost, group)
202
+ : (() => {
203
+ const m = new THREE.Mesh(shapes.sph, new THREE.MeshBasicMaterial({ color: new THREE.Color(color).multiplyScalar(boost) }));
204
+ if (group) group.add(m);
205
+ return m;
206
+ })();
207
+ core.position.set(origin.x + x, y, origin.z + z);
208
+ core.scale.set(size * 0.5, size * 1.1, size * 0.5);
209
+ const lamp = size < lampSize;
210
+ const site = {
211
+ space,
212
+ type: 'fire',
213
+ x: origin.x + x,
214
+ y,
215
+ z: origin.z + z,
216
+ rate: 3 + size * 8,
217
+ size: size * 0.9,
218
+ hot: 1,
219
+ soot: 0.1,
220
+ ...(lamp && lampLight),
221
+ };
222
+ onSite?.(site);
223
+ return { core, site };
224
+ }
225
+
133
226
  /**
134
227
  * Build a tall brass oil-lamp stand and invoke an optional flame callback at its wick.
135
228
  *
package/runtime/index.js CHANGED
@@ -22,7 +22,7 @@ export { createSoundscape } from './soundscape.js';
22
22
  export { createStrideFoley } from './foley-strides.js';
23
23
  export { createScriptFoley } from './foley-script.js';
24
24
  export { createPool } from './pool.js';
25
- export { createBreather, createLazySets, createSetFrame } from './lazy-sets.js';
25
+ export { createBreather, createLazySets, createSetFrame, createSpotFrame } from './lazy-sets.js';
26
26
  export { describeDevice, readDevice } from './device.js';
27
27
  export { choosePostPipeline, createDeviceQuality, groundRenderOrder, resolveDevicePresets } from './device-quality.js';
28
28
  export { LEVELS, createQualityStore } from './quality-store.js';
@@ -172,3 +172,27 @@ export function createSetFrame({
172
172
  },
173
173
  };
174
174
  }
175
+
176
+ /**
177
+ * Create a lightweight local-coordinate spot frame anchored at `origin + offset`: returns the world
178
+ * origin `{ x0, z0 }`, a local ground sampler `Y(x, z)`, and a `make()` factory that allocates a
179
+ * geometry builder shifted to `(x0, z0)`. Worker-safe.
180
+ *
181
+ * @param {object} options
182
+ * @param {(x: number, z: number) => number} options.ground - World ground elevation sampler `(x, z) => y` in metres.
183
+ * @param {{ x: number, z: number }} options.origin - Reference place world origin `{ x, z }` in metres.
184
+ * @param {[number, number]} [options.offset=[0, 0]] - Local east/south offset `[dx, dz]` from `origin` in metres.
185
+ * @param {() => { ox: number, oz: number }} [options.createBuilder] - Builder factory called by `make()`.
186
+ * @returns {{ x0: number, z0: number, make: () => { ox: number, oz: number }, Y: (x: number, z: number) => number }}
187
+ */
188
+ export function createSpotFrame({ ground, origin, offset = [0, 0], createBuilder = () => ({ ox: 0, oz: 0 }) }) {
189
+ const x0 = origin.x + offset[0];
190
+ const z0 = origin.z + offset[1];
191
+ const make = () => {
192
+ const b = createBuilder();
193
+ b.ox = x0;
194
+ b.oz = z0;
195
+ return b;
196
+ };
197
+ return { x0, z0, make, Y: (x, z) => ground(x0 + x, z0 + z) };
198
+ }