diff --git a/src/components/editors/Nodes.svelte b/src/components/editors/Nodes.svelte
index b896f13fb..4dc31ac89 100644
--- a/src/components/editors/Nodes.svelte
+++ b/src/components/editors/Nodes.svelte
@@ -110,7 +110,7 @@
import { lintFlowGraph, type FlowLintFinding } from '$lib/flowLint.js'; // 78 F24
import { fittingNodes, wireMenuRows, candidateOutputs, type WireEnd } from '$lib/wireSearch.js'; // 78 F1
import { animateInEditor, toggleAnimateInEditor } from '$lib/editorMotion'; // 78 F6
- import { liveStateGraph, nodeLiveStates, clearLiveStates } from '$lib/nodeLiveState'; // 78 F7
+ import { liveStateGraph, nodeLiveStates, clearLiveStates, INERT_LINE } from '$lib/nodeLiveState'; // 78 F7
import { variadicSocketExists, switcherItems, MAX_SWITCHER_ITEMS, SWITCHER_TYPES, switcherVType } from '$lib/variadicNodes.js'; // 37 (R6)
import { removeVariadicSocket, setSwitcherType, addSwitcherItem } from '$lib/variadicEdit.js'; // 37 (R6)
import KitButton from '../ui/Button.svelte'; // 37: the Switcher ⓘ rows on the redesign kit
@@ -2293,7 +2293,7 @@
{#each liveChips as chip (chip.id)}
-
{chip.text}
+
{chip.text}
{/each}
@@ -2527,6 +2527,10 @@
overflow: hidden;
text-overflow: ellipsis;
}
+ /* 102b-papercuts: an effect that acts on nothing (the words say it too: not colour alone) */
+ .flow-live-state.flow-live-warn {
+ color: var(--warn-text);
+ }
/* 78 F6: the motion switch reads as OFF at a glance (not by colour alone: the glyph is a pause) */
:global(.svelte-flow__controls-button.flow-motion-off) {
color: var(--accent);
diff --git a/src/components/editors/nodes/EffectNode.svelte b/src/components/editors/nodes/EffectNode.svelte
index 71459c4ac..7b0e3e474 100644
--- a/src/components/editors/nodes/EffectNode.svelte
+++ b/src/components/editors/nodes/EffectNode.svelte
@@ -22,6 +22,12 @@
+ {#if data.type === 'setuniform'}
+
+
+
+ {/if}
{#if data.type === 'lookat'}
@@ -42,6 +48,8 @@
the name shown beside that param in the Shader editor
+ color
+ vector
{:else if data.type === 'visibility'}
+ This mesh is a rounded box ({offer.width} x {offer.height} x {offer.depth} m, corner {offer.radius} m).
+
+ {
+ void import('$lib/roundedBoxConvert.js').then((m) => {
+ if (m.convertToRoundedBox(uuid)) onconverted();
+ });
+ }}>Convert to a rounded Box
+
diff --git a/src/components/menu/scene/FogKindRows.svelte b/src/components/menu/scene/FogKindRows.svelte
new file mode 100644
index 000000000..646b55a2a
--- /dev/null
+++ b/src/components/menu/scene/FogKindRows.svelte
@@ -0,0 +1,45 @@
+
+
+
+ {#snippet control()}
+ editEnvSky({ fog: fogKindPatch(fog, v) })}
+ />
+ {/snippet}
+
+{#if kind !== 'linear'}
+ editEnvSky({ fog: { density: v } })} />
+{/if}
+{#if layer}
+ editEnvSky({ fog: { base: v } })} />
+ editEnvSky({ fog: { thickness: v } })} />
+{/if}
diff --git a/src/components/menu/scene/HdriSection.svelte b/src/components/menu/scene/HdriSection.svelte
index be56500b1..e68f01409 100644
--- a/src/components/menu/scene/HdriSection.svelte
+++ b/src/components/menu/scene/HdriSection.svelte
@@ -41,20 +41,25 @@
}
/** @param {any} event */
async function onUpload(event) {
- const file = event.currentTarget.files?.[0];
+ const picked = [...(event.currentTarget.files ?? [])];
event.currentTarget.value = '';
- if (!file) return;
- if (!/\.(hdr|exr)$/i.test(file.name)) {
- showToast('Pick a .hdr or .exr file');
+ if (!picked.length) return;
+ // 102b-papercuts: a cube map (a cross, a strip, or six face files) or a plain image is converted to an
+ // equirectangular .hdr first; a 2:1 .hdr / .exr goes in untouched, as before
+ const { prepareSky } = await import('$lib/hdri/cubeImport.js');
+ const ready = await prepareSky(await Promise.all(picked.map(async (f) => ({ name: f.name, buffer: await f.arrayBuffer() }))));
+ if ('error' in ready) {
+ showToast(ready.error);
return;
}
- if (file.size > MAX_UPLOAD) {
+ if (ready.bytes.byteLength > MAX_UPLOAD) {
showToast('That HDRI is over 25 MB — peers could not receive it. A 1k or 2k file is plenty.');
return;
}
try {
- const item = await addItemFromBytes(await file.arrayBuffer(), file.name, null, { imported: true, kind: 'hdri' });
+ const item = await addItemFromBytes(/** @type {ArrayBuffer} */ (ready.bytes.buffer), ready.name, null, { imported: true, kind: 'hdri' });
if (item?.hash) pickCustom(item);
+ if (ready.converted && ready.converted !== 'image') showToast('Cube map converted to a sky image: ' + ready.name);
} catch (err) {
showToast('Could not add that HDRI');
console.warn('[hdri] upload failed', err);
@@ -77,7 +82,7 @@
);
-
+
Sky image
{#if hdri}
target.input. End at a "' + cat.outputNodeFor(domain) + '" node.',
- uniforms: 'a param marked uniform compiles to u__; a float one can be driven by a flow "setuniform" node (data.uniform = that name) on the same object.'
+ uniforms: 'a param marked uniform compiles to u__; a flow "setuniform" node (data.uniform = that name) on the same object drives it: data.value for a float, data.color ("#rrggbb") or data.vector ([x, y, z]) for a vec3/vec2/vec4.'
};
}
@@ -1474,7 +1474,7 @@ export const LOOK_AI_TOOLS = [
function: {
name: 'create_shader',
description:
- 'Give objects a node shader, written as text like flow graphs: one line per node (id = type {param: value}), one per edge (source[.output] -> target.input), ending at a "surface" node. Example: c = color {value: "#ff8800"}\\nout = surface\\nc -> out.emissive. Call describe_shader_nodes for the types. Each object gets its own copy. Compiler errors come back in the result and nothing is written. Returns the graph key and its uniforms: a float one (u__) can be driven by a flow "setuniform" node on that object. scene: true makes the default for every object, which asks the host first.',
+ 'Give objects a node shader, written as text like flow graphs: one line per node (id = type {param: value}), one per edge (source[.output] -> target.input), ending at a "surface" node. Example: c = color {value: "#ff8800"}\\nout = surface\\nc -> out.emissive. Call describe_shader_nodes for the types. Each object gets its own copy. Compiler errors come back in the result and nothing is written. Returns the graph key and its uniforms (u__): a flow "setuniform" node on that object drives a float, colour or vector one. scene: true makes the default for every object, which asks the host first.',
parameters: {
type: 'object',
properties: {
diff --git a/src/lib/ai/runtimeCore.js b/src/lib/ai/runtimeCore.js
index 9929cd6f6..5340ece07 100644
--- a/src/lib/ai/runtimeCore.js
+++ b/src/lib/ai/runtimeCore.js
@@ -39,6 +39,7 @@ const r1 = (n) => Math.round(n * 10) / 10;
* behaviours?: {name: string, issues: {line?: number, message: string}[]}[],
* isSource: (type: string) => boolean,
* isAction: (type: string) => boolean,
+ * isObjectEffect?: (type: string) => boolean,
* inputsOf: (type: string) => {name: string, type: string}[],
* edgeTypeProblem?: (source: any, target: any, sourceHandle?: string, targetHandle?: string) => ({refuse?: string, warn?: string} | null),
* edgeHandleProblems?: (source: any, target: any, sourceHandle?: string, targetHandle?: string) => string[]
@@ -175,6 +176,25 @@ export function validateScene(w) {
if (n.type === 'onclick' && w.play?.interaction === 'off')
add({ code: 'clicks-off', level: 'warning', node: n.id, message: name + ': clicking is switched off in Play (scene physics ▸ play interaction "off"), so a player cannot click it.', fix: 'Set the play interaction to click or grab.' });
}
+ // 102b-papercuts (scout row 18): a per-frame EFFECT in the scene graph that reaches no object (no Object
+ // Selector picking one, no target of its own) does nothing — the node editor card says so too
+ if (
+ w.isObjectEffect?.(n.type) &&
+ !(n.type === 'script' && Array.isArray(n.data?.outputs) && n.data.outputs.length) &&
+ (!n.__graph || n.__graph === 'scene') &&
+ !(typeof n.data?.target === 'string' && n.data.target && n.data.target !== '-None-') &&
+ !ix.out(n.id).some((/** @type {any} */ e) => {
+ const t = ix.byId.get(e.target);
+ return t?.type === 'objectselector' && t.data?.selected && t.data.selected !== '-None-';
+ })
+ )
+ add({
+ code: 'effect-no-object',
+ level: 'warning',
+ node: n.id,
+ message: name + ' is in the scene graph and is not wired into an Object Selector that picks an object, so it acts on nothing.',
+ fix: 'Wire it into an Object Selector naming the object, or move it into that object\'s own graph.'
+ });
// an ACTION with no source upstream never runs (kit actions, setgamestate, travel, spawn …)
if (w.isAction(n.type) && !w.isSource(n.type)) {
const triggerWired = ix.into(n.id).length > 0;
diff --git a/src/lib/ai/runtimeTools.js b/src/lib/ai/runtimeTools.js
index bb0328088..be5a4574f 100644
--- a/src/lib/ai/runtimeTools.js
+++ b/src/lib/ai/runtimeTools.js
@@ -52,10 +52,10 @@ const triggerNow = () => (sessionNow() % 86400000) / 1000;
const objectOf = (uuid) => /** @type {any} */ (get(objectsGroup))?.getObjectByProperty?.('uuid', uuid);
/** the socket tables, loaded once (flowSockets is a leaf; the kit's action set needs the kit catalog) */
-/** @type {Promise<{isSource: (t: string) => boolean, isAction: (t: string) => boolean, inputsOf: (t: string) => {name: string, type: string}[]}> | null} */
+/** @type {Promise<{isSource: (t: string) => boolean, isAction: (t: string) => boolean, isObjectEffect: (t: string) => boolean, inputsOf: (t: string) => {name: string, type: string}[]}> | null} */
let typeInfoP = null;
function typeInfo() {
- typeInfoP ??= Promise.all([import('$lib/flowSockets'), import('$lib/kit/nodes.js').catch(() => null), import('./edgeHandles.js')]).then(([s, kit, eh]) => {
+ typeInfoP ??= Promise.all([import('$lib/flowSockets'), import('$lib/kit/nodes.js').catch(() => null), import('./edgeHandles.js'), import('$lib/nodeCatalog'), import('$lib/moduleSDK')]).then(([s, kit, eh, cat, sdk]) => {
/** @param {string} t */
const inputsOf = (t) => s.inputHandles(t).map((name) => ({ name, type: s.inputType(t, name) }));
/** @param {string} t */
@@ -64,7 +64,10 @@ function typeInfo() {
/** @param {string} t */
const isAction = (t) => TRIGGERED_ACTIONS.has(t) || kitActions.has(t);
// 2.0-n3b step 2: the same edge checks create_flow_nodes runs, over the graph as it stands
- return { isSource, isAction, inputsOf, edgeTypeProblem: eh.edgeTypeProblem, edgeHandleProblems: eh.edgeHandleProblems };
+ // 102b-papercuts: the per-frame effects that act only through an Object Selector (or their own graph's object)
+ /** @param {string} t */
+ const isObjectEffect = (t) => cat.animationTypes.includes(t) || !!sdk.moduleEffects[t] || t === 'script' || t === 'customnode';
+ return { isSource, isAction, inputsOf, isObjectEffect, edgeTypeProblem: eh.edgeTypeProblem, edgeHandleProblems: eh.edgeHandleProblems };
});
return typeInfoP;
}
@@ -478,7 +481,7 @@ export const RUNTIME_AI_TOOLS = [
function: {
name: 'validate_scene',
description:
- 'Check the scene for what would not work when someone presses Play: actions nothing fires, an Object Selector wired the wrong way round, a scene-graph On Click that reaches no object, Game Start wired as an event, HUD nodes pointing at elements that do not exist, walk mode with no spawn, a scene with no light, behaviour code problems. Each issue says what to fix. Run it after building a game, then playtest.',
+ 'Check the scene for what would not work when someone presses Play: actions nothing fires, effects that act on no object, an Object Selector wired the wrong way round, a scene-graph On Click that reaches no object, Game Start wired as an event, HUD nodes pointing at elements that do not exist, walk mode with no spawn, a scene with no light, behaviour code problems. Each issue says what to fix. Run it after building a game, then playtest.',
parameters: { type: 'object', properties: {} }
}
},
diff --git a/src/lib/ai/sceneSetupCore.js b/src/lib/ai/sceneSetupCore.js
index 4f5392f51..97fcb1f34 100644
--- a/src/lib/ai/sceneSetupCore.js
+++ b/src/lib/ai/sceneSetupCore.js
@@ -157,22 +157,47 @@ export function planSky(args, now) {
if (!c) return { error: 'fog.color: a colour' };
fog.color = c;
}
+ // 102b-papercuts: a density is REAL exponential fog now (kind distance), or the ground layer (kind height);
+ // near / far are still written, as the linear fog an older build falls back to
+ if (f.kind !== undefined && !['linear', 'distance', 'height'].includes(f.kind)) return { error: 'fog.kind: linear (near / far), distance (density) or height (density, base, thickness)' };
if (f.density !== undefined) {
if (!finite(f.density) || f.density <= 0) return { error: 'fog.density: a number above 0 (0.01 thin, 0.1 thick)' };
+ fog.density = r3(clamp(f.density, 0.0005, 1)) || 0.001;
fog.near = 0;
fog.far = r3(clamp(DENSITY_FAR / f.density, 1, 20000));
fog.fit = false;
- warnings.push('density ' + f.density + ' became linear fog from 0 to ' + fog.far + ' m (the scene renders linear fog)');
+ if (f.kind === undefined && fog.kind !== 'height') fog.kind = 'distance';
+ }
+ if (f.kind !== undefined) {
+ fog.kind = f.kind;
+ if (f.kind !== 'linear' && !(fog.density > 0)) fog.density = 0.02;
+ }
+ for (const k of ['base', 'thickness']) {
+ if (f[k] === undefined) continue;
+ if (!finite(f[k]) || (k === 'thickness' && f[k] <= 0)) return { error: 'fog.' + k + (k === 'base' ? ' is the ground height in metres' : ' is metres above 0') };
+ fog[k] = r3(clamp(f[k], k === 'base' ? -10000 : 0.1, 10000));
+ if (f.kind === undefined) fog.kind = 'height';
+ }
+ if (fog.kind === 'height') {
+ if (!finite(fog.base)) fog.base = 0;
+ if (!(fog.thickness > 0)) fog.thickness = 6;
}
for (const k of ['near', 'far']) {
if (f[k] === undefined) continue;
+ if (f.kind === undefined && f.density === undefined) fog.kind = 'linear';
if (!finite(f[k]) || f[k] < 0) return { error: 'fog.' + k + ' is metres (0 or more)' };
fog[k] = r3(clamp(f[k], 0, 20000));
fog.fit = false;
}
if (fog.far <= fog.near) return { error: 'fog: far must be beyond near' };
payload.fog = fog;
- words.push('fog ' + fog.color + ' ' + fog.near + '-' + fog.far + ' m');
+ words.push(
+ fog.kind === 'height'
+ ? 'ground fog ' + fog.color + ' density ' + fog.density + ', ' + fog.thickness + ' m thick from ' + fog.base + ' m'
+ : fog.kind === 'distance'
+ ? 'fog ' + fog.color + ' density ' + fog.density
+ : 'fog ' + fog.color + ' ' + fog.near + '-' + fog.far + ' m'
+ );
}
custom = true;
}
diff --git a/src/lib/ai/sceneSetupTools.js b/src/lib/ai/sceneSetupTools.js
index 78836e6c2..fda2d04cb 100644
--- a/src/lib/ai/sceneSetupTools.js
+++ b/src/lib/ai/sceneSetupTools.js
@@ -138,7 +138,13 @@ function describeEnvironment() {
minQuality: hdri.minQuality
}
: null,
- fog: p.fog ? { color: p.fog.color, near: p.fog.near, far: p.fog.far } : null,
+ fog: p.fog
+ ? p.fog.kind === 'height'
+ ? { kind: 'height', color: p.fog.color, density: p.fog.density, base: p.fog.base, thickness: p.fog.thickness }
+ : p.fog.kind === 'distance'
+ ? { kind: 'distance', color: p.fog.color, density: p.fog.density }
+ : { color: p.fog.color, near: p.fog.near, far: p.fog.far }
+ : null,
sun: p.sun ? { color: p.sun.color, intensity: p.sun.intensity, position: p.sun.position } : null,
ambient: p.hemi ? { sky: p.hemi.sky, ground: p.hemi.ground, intensity: p.hemi.intensity } : null,
envLights: (s.lights ?? []).map((/** @type {any} */ l) => ({ id: l.id, kind: l.kind, color: l.color, intensity: l.intensity, position: l.position, ...(l.groundColor ? { groundColor: l.groundColor } : {}) }))
@@ -315,7 +321,7 @@ export const SCENE_SETUP_AI_TOOLS = [
PRESET_NAMES +
'), a sky image by name (' +
SKY_NAMES +
- '; a search_assets HDRI id "cc0:polyhaven/" (fetched into the library once) or "lib:"; or {hash} of an HDR in the library — upload your own .hdr / .exr with assets upload; never a URL) with rotation, intensity, blur and Sky quality (auto / standard / high / max, plus a minimum), a background colour or {top, bottom} gradient, fog ({color, near, far} in metres, or {color, density}; null = none) and exposure. "Make it night": preset night or hdri starlight + a dark fog. Changes the whole scene\'s look, so the host is asked first: it answers needsConfirm, then repeat with confirmId. One undo step.',
+ '; a search_assets HDRI id "cc0:polyhaven/" (fetched into the library once) or "lib:"; or {hash} of an HDR in the library — upload your own .hdr / .exr with assets upload; never a URL) with rotation, intensity, blur and Sky quality (auto / standard / high / max, plus a minimum), a background colour or {top, bottom} gradient, fog ({color, near, far} in metres; {color, density} for distance fog; {color, density, base, thickness} for ground fog lying from base up over thickness metres; null = none) and exposure. "Make it night": preset night or hdri starlight + a dark fog. Changes the whole scene\'s look, so the host is asked first: it answers needsConfirm, then repeat with confirmId. One undo step.',
parameters: {
type: 'object',
properties: {
@@ -338,7 +344,15 @@ export const SCENE_SETUP_AI_TOOLS = [
gradient: { type: ['object', 'null'], properties: { top: { type: 'string' }, bottom: { type: 'string' } } },
fog: {
type: ['object', 'null'],
- properties: { color: { type: 'string' }, near: { type: 'number', minimum: 0 }, far: { type: 'number', minimum: 0 }, density: { type: 'number', exclusiveMinimum: 0 } }
+ properties: {
+ kind: { type: 'string', enum: ['linear', 'distance', 'height'], description: 'linear = near to far; distance = thickens with distance (density); height = ground fog (density, base, thickness)' },
+ color: { type: 'string' },
+ near: { type: 'number', minimum: 0 },
+ far: { type: 'number', minimum: 0 },
+ density: { type: 'number', exclusiveMinimum: 0 },
+ base: { type: 'number', description: 'ground fog: the height (m) where it is thickest' },
+ thickness: { type: 'number', exclusiveMinimum: 0, description: 'ground fog: how far up (m) it thins out' }
+ }
},
exposure: { type: 'number', minimum: 0.1, maximum: 4 },
...CONFIRM
diff --git a/src/lib/ai/tools.js b/src/lib/ai/tools.js
index 52093134d..2d67ec345 100644
--- a/src/lib/ai/tools.js
+++ b/src/lib/ai/tools.js
@@ -1457,7 +1457,7 @@ export const AI_TOOLS = [
type: 'array',
items: { type: 'number' },
description:
- 'up to 4 constructor args. Box=[w,h,d], Sphere=[radius], Cylinder=[rTop,rBottom,height], Cone=[radius,height], Plane=[w,h], Torus=[radius,tube]. Omit for sensible defaults. Sizes go down to 0.001 m.'
+ 'up to 4 constructor args. Box=[w,h,d], Sphere=[radius], Cylinder=[rTop,rBottom,height], Cone=[radius,height], Plane=[w,h], Torus=[radius,tube]. Omit for sensible defaults. For a rounded box, create a Box and then set_geometry {radius}. Sizes go down to 0.001 m.'
},
name: { type: 'string' },
position: { type: 'array', items: { type: 'number' }, description: '[x,y,z]' },
diff --git a/src/lib/ai/uploadAsset.js b/src/lib/ai/uploadAsset.js
index a22f2385b..beea98172 100644
--- a/src/lib/ai/uploadAsset.js
+++ b/src/lib/ai/uploadAsset.js
@@ -52,7 +52,19 @@ export async function uploadAssetTool(args) {
}
}
}
- const name = uploadName(args.name, type.kind === 'sound' ? 'sound' : 'sky', type.ext);
+ let name = uploadName(args.name, type.kind === 'sound' ? 'sound' : 'sky', type.ext);
+ // 102b-papercuts: a sky in a cube layout (a cross or a strip of six faces) becomes an equirectangular .hdr
+ /** @type {string | null} */ let converted = null;
+ if (type.kind === 'hdri') {
+ const { prepareSky } = await import('../hdri/cubeImport.js');
+ const ready = await prepareSky([{ name, buffer: /** @type {ArrayBuffer} */ (bytes.slice().buffer) }]);
+ // anything else (a 2:1 sky, a file it cannot read) is filed exactly as before
+ if (!('error' in ready) && ready.converted) {
+ bytes = ready.bytes;
+ name = ready.name;
+ converted = ready.converted;
+ }
+ }
const { fileIntoLibrary } = await import('./importFile.js');
try {
const filed = await fileIntoLibrary(bytes, name, args.folder ?? (type.kind === 'sound' ? 'Sounds' : 'Skies'));
@@ -63,6 +75,7 @@ export async function uploadAssetTool(args) {
bytes: bytes.length,
folder: filed.folder,
...(filed.created ? {} : { note: 'the library already had this file' }),
+ ...(converted ? { converted: 'cube map (' + converted + ') -> equirectangular .hdr' } : {}),
use: uploadUse(type.kind)
};
} catch (e) {
@@ -75,7 +88,7 @@ export const UPLOAD_ASSET_TOOL = {
function: {
name: 'upload_asset',
description:
- 'Put a SOUND or an HDR SKY you hold as bytes into the library and get its hash: your own generated music or ambience, or a file you fetched yourself (any site — the bytes come from you, so nothing needs the site to allow cross-origin reads). data = base64; a big file goes as chunk: {id, index, total} parts (each a multiple of 4 base64 characters). Sounds: WAV, OGG, MP3, FLAC, M4A or WebM up to 16 MB (decoded once to prove it is audio) → place it with effects sound {asset: hash} or music {asset: hash}. Skies: Radiance .hdr or OpenEXR up to 25 MB → set_look sky {hdri: {hash}}. The type comes from the bytes, never the name. Images go through image instead. Everyone in the session can pull it by hash.',
+ 'Put a SOUND or an HDR SKY you hold as bytes into the library and get its hash: your own generated music or ambience, or a file you fetched yourself (any site — the bytes come from you, so nothing needs the site to allow cross-origin reads). data = base64; a big file goes as chunk: {id, index, total} parts (each a multiple of 4 base64 characters). Sounds: WAV, OGG, MP3, FLAC, M4A or WebM up to 16 MB (decoded once to prove it is audio) → place it with effects sound {asset: hash} or music {asset: hash}. Skies: Radiance .hdr or OpenEXR up to 25 MB, equirectangular (2:1) or a cube map as a cross (4:3, 3:4) or a strip of six faces (6:1, 1:6), which is converted → set_look sky {hdri: {hash}}. The type comes from the bytes, never the name. Images go through image instead. Everyone in the session can pull it by hash.',
parameters: {
type: 'object',
properties: {
diff --git a/src/lib/cinematic/cinematicCore.js b/src/lib/cinematic/cinematicCore.js
index c200d5215..7889e2666 100644
--- a/src/lib/cinematic/cinematicCore.js
+++ b/src/lib/cinematic/cinematicCore.js
@@ -117,7 +117,8 @@ export const STAND_IN_LABELS = Object.freeze({
shader: 'Shader graph and code materials',
terrain: 'Terrain paint layers',
deform: 'Jiggle and sway',
- custom: 'Custom materials'
+ custom: 'Custom materials',
+ heightfog: 'Height fog' // 102b-papercuts: the WebGPU view draws distance fog, not the ground layer
});
/** @typedef {keyof typeof STAND_IN_LABELS} StandInKind */
diff --git a/src/lib/cinematic/cinematicView.js b/src/lib/cinematic/cinematicView.js
index 878e9b2c3..674125d2e 100644
--- a/src/lib/cinematic/cinematicView.js
+++ b/src/lib/cinematic/cinematicView.js
@@ -25,6 +25,10 @@ import { compileAsync } from '../render/compile.js';
import { captureEnvironment, useCopies, restoreEnvironment } from './envHandover.js';
import { buildPipeline } from './pipeline.js';
import { classifyMaterial, notShownText, effectiveQuality, createDropWatch, quantile } from './cinematicCore.js';
+import { HEIGHT_FOG } from '../fogModes.js';
+
+/** 102b-papercuts: what the chip names — the stand-ins, plus a height fog (WebGL-only shader chunk) @param {any} swap */
+const shownKinds = (swap) => (HEIGHT_FOG[2] > 0.5 ? [...swap.kinds, 'heightfog'] : swap.kinds);
// the STORE leaf, never ./cinematicState.js (that one reaches the app's stores: this chunk's preload list)
import { cinematicState, cinematicPrefs, disableCinematic, cinematicDisabled } from './cinematicStore.js';
import { deformersOf } from '../vertexDeform.js';
@@ -359,7 +363,7 @@ async function enterSteps() {
live.labels.tick();
live.swap = createSwapper(W, scene);
live.swap.scan();
- patchState({ notShown: notShownText(live.swap.kinds) });
+ patchState({ notShown: notShownText(shownKinds(live.swap)) });
try {
live.built = await build(targetQuality());
await compileAsync(r, scene, cam);
@@ -468,10 +472,10 @@ function draw(_delta) {
/** @param {any} g */
function rescan(g) {
- const before = notShownText(g.swap.kinds);
+ const before = notShownText(shownKinds(g.swap));
g.swap.scan();
g.labels?.scan(g.scene);
- const after = notShownText(g.swap.kinds);
+ const after = notShownText(shownKinds(g.swap));
if (after !== before) patchState({ notShown: after });
}
diff --git a/src/lib/environment.js b/src/lib/environment.js
index 6c2050831..c8a080c7d 100644
--- a/src/lib/environment.js
+++ b/src/lib/environment.js
@@ -8,6 +8,19 @@ import { globalScene, globalRenderer, objectsGroup, backgroundColor, TControls,
import { peers } from '../stores/appStore';
import { sceneRadius } from './sceneBounds';
import { fogFarFor, mergeFogPatch } from './fogReach';
+// 102b-papercuts: distance + height fog (the height layer's chunk patch, fogShader.js, loads with the first height fog)
+import { fogKindOf, fogDensityOf, heightFogParams, setHeightFog } from './fogModes.js';
+
+/** 102b: the height-fog chunk patch is a lazy chunk; the first height fog installs it and recompiles what is live
+ * @param {any} scene */
+function ensureHeightFogShader(scene) {
+ void import('./fogShader.js').then((m) => {
+ if (!m.installHeightFog()) return;
+ scene?.traverse?.((/** @type {any} */ o) => {
+ for (const mat of Array.isArray(o.material) ? o.material : o.material ? [o.material] : []) mat.needsUpdate = true;
+ });
+ });
+}
import { registerSystemGroup } from './moduleSDK';
import { createLight } from './geometries.svelte';
import { cappedShadowSize, shadowsDisabled } from './lightParams';
@@ -458,6 +471,7 @@ export function applyEnvironment() {
// compositor blends the camera feed under); 'room' leaves nothing (three clears to clear)
scene.background = get(roomLook) === 'dim' ? dimBackdrop() : null;
scene.fog = null;
+ setHeightFog([0, 0, 0, 0]);
} else {
// 30 author-kit: a gradient sky when the payload carries one, else the flat colour
const gradient = skyGradientOf(preset);
@@ -469,9 +483,17 @@ export function applyEnvironment() {
}
// fog never swallows a big scene: a PRESET's reach grows with the scene bounds; a fog the
// user set by hand (`fit: false`) keeps its own (36 A5, fogReach.js)
- scene.fog = preset.fog
- ? new THREE.Fog(preset.fog.color, preset.fog.near, fogFarFor(preset.fog, sceneRadius()))
- : null;
+ // 102b-papercuts: `kind` distance / height = exponential fog (height adds the ground layer, fogShader.js);
+ // absent = the linear fog every older document and build has
+ const kind = preset.fog ? fogKindOf(preset.fog) : 'linear';
+ scene.fog = !preset.fog
+ ? null
+ : kind === 'linear'
+ ? new THREE.Fog(preset.fog.color, preset.fog.near, fogFarFor(preset.fog, sceneRadius()))
+ : new THREE.FogExp2(preset.fog.color, fogDensityOf(preset.fog));
+ const layer = heightFogParams(preset.fog);
+ setHeightFog(layer);
+ if (layer[2] > 0.5) ensureHeightFogShader(scene);
}
backgroundColor.set(preset.background);
@@ -630,7 +652,7 @@ function detachedPayload() {
* 37-hdri: `hdri` is the third sky field — a partial patch merged into the payload's hdri
* (hdriCore.mergeHdriPatch), `null` removes it. It rides the same commit, so an HDRI pick,
* rotation or exposure drag persists and replicates like a background colour does.
- * @param {{background?: string, fog?: {color?: string, near?: number, far?: number} | null, hdri?: any}} patch
+ * @param {{background?: string, fog?: {color?: string, near?: number, far?: number, kind?: string, density?: number, base?: number, thickness?: number} | null, hdri?: any}} patch
* @param {{replicate?: boolean}} [opts]
*/
export function editEnvSky(patch, opts = {}) {
diff --git a/src/lib/flowRuntime.js b/src/lib/flowRuntime.js
index 9fc60386d..f16748210 100644
--- a/src/lib/flowRuntime.js
+++ b/src/lib/flowRuntime.js
@@ -1,3 +1,4 @@
+import { writeUniformSlot } from './uniformWrite.js';
import * as THREE from 'three';
// `{v}` labels for the HUD — 'Gems: {v}' needs no string node and no string socket type
import { hudFormat } from './hudFormat.js';
@@ -2527,6 +2528,8 @@ function stampOfSource(edge, ctx, seen) {
// 36 (U10): a NAMED event output keeps its own log entry, `#