Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/components/editors/Nodes.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2293,7 +2293,7 @@
<!-- 78 F7: what each node is doing right now, under its card -->
{#each liveChips as chip (chip.id)}
<ViewportPortal target="front">
<div class="flow-live-state" data-node-id={chip.id} style="transform: translate({chip.x}px, {chip.y}px); max-width: {chip.w}px">{chip.text}</div>
<div class="flow-live-state" class:flow-live-warn={chip.text === INERT_LINE} data-node-id={chip.id} style="transform: translate({chip.x}px, {chip.y}px); max-width: {chip.w}px">{chip.text}</div>
</ViewportPortal>
{/each}
<!-- 78 F24: a chip on every wire the lint flags (tooltip = what is wrong; press = the fix) -->
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions src/components/editors/nodes/EffectNode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@

<NodeWrapper type={data.type} label={data.label}>
<Socket kind="target" nodeType={data.type} position={Position.Left} id={handleId} style="top: 30px" />
{#if data.type === 'setuniform'}
<!-- 102b-papercuts: a colour or a vector reaches a vec3/vec2/vec4 uniform; the number
still drives a float one (and fills every component of a vector one) -->
<Socket kind="target" nodeType={data.type} position={Position.Left} id="color" style="top: 88px" />
<Socket kind="target" nodeType={data.type} position={Position.Left} id="vector" style="top: 108px" />
{/if}
<Socket kind="source" nodeType={data.type} position={Position.Right} />
<div class="flex w-full flex-col gap-1">
{#if data.type === 'lookat'}
Expand All @@ -42,6 +48,8 @@
<p class="text-[9px] leading-tight text-text-faint">
the name shown beside that param in the Shader editor
</p>
<span class="text-[9px] text-text-muted" title="Wire a colour here to drive a colour uniform">color</span>
<span class="text-[9px] text-text-muted" title="Wire a Vector3 here to drive a vector uniform">vector</span>
{:else if data.type === 'visibility'}
<label class="flex items-center gap-2">
<input class="nodrag nopan" type="checkbox" checked={data.on !== false}
Expand Down
45 changes: 35 additions & 10 deletions src/components/menu/Inspector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import LoadStatePanel from './LoadStatePanel.svelte';
import WaterPanel from '../water/WaterPanel.svelte';
import SliderRow from '../ui/SliderRow.svelte';
import { fogKindOf } from '$lib/fogModes.js';
import SceneLodSection from './SceneLodSection.svelte'; // 46 P2
import PropRow from '../ui/PropRow.svelte';
import Chips from '../ui/Chips.svelte';
Expand Down Expand Up @@ -104,6 +105,7 @@
} from '$lib/meshEdit';
import { bottomInset } from '$lib/bottomDock';
import { geometryParamsOf, applyGeometry } from '$lib/geometryEdit';
import { roundedBoxOffer } from '$lib/roundedBoxGate.js'; // 102b-papercuts
import { nameOf } from '$lib/lockControl';
import { geometrySpec } from '$lib/geometryParams';
import { LIGHT_PARAMS, SHADOW_TYPES, SHADOW_SIZES, setShadowMapSize, cappedShadowSize } from '$lib/lightParams';
Expand Down Expand Up @@ -906,6 +908,12 @@
return !isLight && !isGroup && $selectedObject ? geometryParamsOf($selectedObject) : null;
});
const geoSpec = $derived(geoParams ? geometrySpec(geoParams.gtype) : null);
// 102b-papercuts: a baked rounded box the Geometry section can offer to convert (never converts by itself)
const roundOffer = $derived.by(() => {
geoTick;
$objectsGroup;
return !geoParams && !isLight && !isGroup && $selectedObject ? roundedBoxOffer($selectedObject) : null;
});

// 21-C1: the parametric LOCK has to notice a poke. Every meshgeo commit stamps
// userData.faceEdited (so every sculpt stroke does), and a THREE tree is not
Expand Down Expand Up @@ -2252,10 +2260,15 @@
}}
/>
</FieldClip>
<!-- 102b-papercuts: Linear / Distance / Height fog (Near and Far are the linear fog's rows) -->
<!-- 102b-papercuts: a lazy chunk (the boot carries no fog-kind rows) -->
{#await import('./scene/FogKindRows.svelte') then m}<m.default fog={envFog} />{/await}
{#if fogKindOf(envFog) === 'linear'}
<SliderRow id="fog-near" label="Near" min={0} max={Math.max(10, Math.ceil(envFog?.near ?? 0))} step={0.1} decimals={1} value={envFog?.near ?? 0}
onchange={(v) => editEnvSky({ fog: { near: v } })} />
<SliderRow id="fog-far" label="Far" min={0} max={Math.max(100, Math.ceil(envFog?.far ?? 0))} step={0.1} decimals={1} value={envFog?.far ?? 0}
onchange={(v) => editEnvSky({ fog: { far: v } })} />
{/if}
<UiButton
size="sm"
variant="outline"
Expand Down Expand Up @@ -3939,6 +3952,19 @@
>
{/if}
{:else}
{#snippet geoSlider(/** @type {any} */ spec, /** @type {string | undefined} */ rowId)}
<SliderRow
id={rowId}
label={spec.label}
min={spec.min ?? 0}
max={spec.max ?? 10}
step={spec.kind === 'int' ? 1 : spec.step ?? 0.05}
decimals={spec.kind === 'int' ? 0 : 2}
value={Number(geoParams.params[spec.key] ?? spec.def)}
mixed={geoMixed(spec.key, spec.def)}
onchange={(v) => editGeometry(spec.key, spec.kind === 'int' ? Math.round(v) : v)}
/>
{/snippet}
<div id="inspector-geometry" class="flex flex-col gap-1">
<!-- 37 R3: a row whose `show` says it does not apply (a door width on a wall
with no doors) is hidden, not disabled -->
Expand Down Expand Up @@ -3969,22 +3995,21 @@
{/each}
</div>
</div>
{:else if spec.optional}
<!-- 102b-papercuts: an optional row (a Box's corner radius) carries its own id and tooltip -->
<div title={spec.title ?? spec.label}>{@render geoSlider(spec, 'geo-' + spec.key)}</div>
{:else}
<SliderRow
label={spec.label}
min={spec.min ?? 0}
max={spec.max ?? 10}
step={spec.kind === 'int' ? 1 : spec.step ?? 0.05}
decimals={spec.kind === 'int' ? 0 : 2}
value={Number(geoParams.params[spec.key] ?? spec.def)}
mixed={geoMixed(spec.key, spec.def)}
onchange={(v) => editGeometry(spec.key, spec.kind === 'int' ? Math.round(v) : v)}
/>
{@render geoSlider(spec, undefined)}
{/if}
{/each}
</div>
{/if}
</Section>
{:else if roundOffer && !multiCount}
<!-- 102b-papercuts: a BAKED rounded box (a mesh of vertices that is exactly one) is OFFERED as a Box
with a corner radius. Never automatic: the shape stays the same, the file gets smaller and the
Geometry rows come back. One undo step. -->
{#await import('./RoundedBoxOffer.svelte') then m}<m.default offer={roundOffer} uuid={$selectedObject.uuid} onconverted={() => geoTick++} />{/await}
{/if}

{#if $selectedObject?.userData?.terrain && !multiCount}
Expand Down
26 changes: 26 additions & 0 deletions src/components/menu/RoundedBoxOffer.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<script>
// 102b-papercuts: the Geometry section's offer for a BAKED rounded box (a mesh that is exactly one). A lazy
// chunk: it only shows once the rounded-box chunk has recognised the mesh. Never converts by itself.
import Section from '../ui/Section.svelte';
import UiButton from '../ui/Button.svelte';

/** @type {{ offer: {width: number, height: number, depth: number, radius: number}, uuid: string, onconverted?: () => void }} */
let { offer, uuid, onconverted = () => {} } = $props();
</script>

<Section variant="panel" label="Geometry">
<p id="geometry-rounded-offer" class="px-1 text-[length:var(--fs-badge)] text-text-2">
This mesh is a rounded box ({offer.width} x {offer.height} x {offer.depth} m, corner {offer.radius} m).
</p>
<UiButton
id="geometry-convert-rounded"
size="sm"
variant="outline"
title="Make it a Box with a corner radius: it looks the same, saves as a few numbers instead of every vertex, and gets its Geometry rows back. Undo puts the mesh back."
onclick={() => {
void import('$lib/roundedBoxConvert.js').then((m) => {
if (m.convertToRoundedBox(uuid)) onconverted();
});
}}>Convert to a rounded Box</UiButton
>
</Section>
45 changes: 45 additions & 0 deletions src/components/menu/scene/FogKindRows.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<script>
// 102b-papercuts (scout row 18): which fog — Linear (Near / Far, the fog every older build draws),
// Distance (exponential: thickens with distance) or Height (lies on the ground, thinning upward).
// Rows only; every edit goes through editEnvSky like the rest of the Fog block, so it replicates,
// saves and undoes on the environment singleton. Near / Far stay shown for Linear only, and stay in
// the document for the other two (an older build falls back to them).
import PropRow from '../../ui/PropRow.svelte';
import SliderRow from '../../ui/SliderRow.svelte';
import ThemedSelect from '../../ui/ThemedSelect.svelte';
import { editEnvSky } from '$lib/environment';
import { fogKindOf, fogDensityOf, heightFogOf } from '$lib/fogModes.js';
import { fogKindPatch } from '$lib/fogEdit.js';

/** @type {{fog: any}} */
let { fog } = $props();
const kind = $derived(fogKindOf(fog));
const layer = $derived(heightFogOf(fog));
</script>

<PropRow label="Kind" valueBox={false}>
{#snippet control()}
<ThemedSelect
id="fog-kind"
class="flex-1"
value={kind}
title="Linear: fog from Near to Far. Distance: thickens with distance. Height: lies on the ground and thins upward"
items={[
{ value: 'linear', name: 'Linear (near to far)' },
{ value: 'distance', name: 'Distance' },
{ value: 'height', name: 'Height (ground fog)' }
]}
onchange={(/** @type {any} */ v) => editEnvSky({ fog: fogKindPatch(fog, v) })}
/>
{/snippet}
</PropRow>
{#if kind !== 'linear'}
<SliderRow id="fog-density" label="Density" min={0.001} max={0.3} step={0.001} decimals={3} value={fogDensityOf(fog)}
onchange={(v) => editEnvSky({ fog: { density: v } })} />
{/if}
{#if layer}
<SliderRow id="fog-base" label="Ground height" min={Math.min(-20, Math.floor(layer.base))} max={Math.max(50, Math.ceil(layer.base))} step={0.1} decimals={1} value={layer.base}
onchange={(v) => editEnvSky({ fog: { base: v } })} />
<SliderRow id="fog-thickness" label="Thickness" min={0.5} max={Math.max(60, Math.ceil(layer.thickness))} step={0.1} decimals={1} value={layer.thickness}
onchange={(v) => editEnvSky({ fog: { thickness: v } })} />
{/if}
23 changes: 14 additions & 9 deletions src/components/menu/scene/HdriSection.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -77,7 +82,7 @@
);
</script>

<div id="env-hdri" data-keywords="hdri hdr exr ultrahdr sky quality minimum resolution sky image skybox environment map ibl image based lighting reflections exposure tone mapping rotation">
<div id="env-hdri" data-keywords="hdri hdr exr cube map cubemap cross skybox faces ultrahdr sky quality minimum resolution sky image skybox environment map ibl image based lighting reflections exposure tone mapping rotation">
<p class="ui-section-label">Sky image</p>
<div class="hdri-row">
<button
Expand All @@ -100,11 +105,11 @@
{item.name}
</button>
{/each}
<button id="hdri-upload" class="hdri-chip" title="Use your own .hdr or .exr (equirectangular) — it is added to the Explorer and shared with peers"
<button id="hdri-upload" class="hdri-chip" title="Use your own sky: an equirectangular .hdr or .exr, a cube map (a cross, a strip or six face files) or an image — it is added to the Explorer and shared with peers"
onclick={() => document.getElementById('hdri-upload-file')?.click()}>
Upload HDRI…
</button>
<input type="file" id="hdri-upload-file" style="display: none" accept=".hdr,.exr" onchange={onUpload} />
<input type="file" id="hdri-upload-file" style="display: none" accept=".hdr,.exr,.png,.jpg,.jpeg,.webp" multiple onchange={onUpload} />
</div>
{#if hdri}
<SliderRow id="hdri-rotation" label="Rotation" min={0} max={360} step={1} decimals={0} value={hdri.rotation}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ai/geometryTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ export const GEOMETRY_AI_TOOLS = [
function: {
name: 'set_geometry',
description:
'Reshape existing objects in place (they keep uuid, transform, material and flows): change a primitive\'s params (the keys list_scene shows under geometry, e.g. {width, height, depth} for a Box, {radiusTop, radiusBottom, height, radialSegments} for a Cylinder, {segments, phiLength} for a Lathe, {depth, bevel} for an extrusion), or its TYPE (box → Cylinder) with params on top of the new type\'s defaults. A tube (create_tube) takes path, radius / radii, closed. A 3D text (create_text) takes its text fields as params (text, font, size, depth, bevel, align, maxWidth, anchor, color …). An object whose vertices were hand-edited refuses unless force: true (the rebuild replaces those edits). Up to ' +
'Reshape existing objects in place (they keep uuid, transform, material and flows): change a primitive\'s params (the keys list_scene shows under geometry, e.g. {width, height, depth} for a Box (plus {radius, radiusSegments} to round its edges and corners: a rounded box, saved as two numbers), {radiusTop, radiusBottom, height, radialSegments} for a Cylinder, {segments, phiLength} for a Lathe, {depth, bevel} for an extrusion), or its TYPE (box → Cylinder) with params on top of the new type\'s defaults. A tube (create_tube) takes path, radius / radii, closed. A 3D text (create_text) takes its text fields as params (text, font, size, depth, bevel, align, maxWidth, anchor, color …). An object whose vertices were hand-edited refuses unless force: true (the rebuild replaces those edits). Up to ' +
MAX_UPDATES +
' objects per call, one undo step.',
parameters: {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/ai/lookTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ async function describeShaderNodesTool(args) {
return {
nodes: rows,
format: 'one line per node: id = type {param: value}; one per edge: source[.output] -> target.input. End at a "' + cat.outputNodeFor(domain) + '" node.',
uniforms: 'a param marked uniform compiles to u_<nodeId>_<param>; 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_<nodeId>_<param>; 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.'
};
}

Expand Down Expand Up @@ -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_<nodeId>_<param>) 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_<nodeId>_<param>): 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: {
Expand Down
20 changes: 20 additions & 0 deletions src/lib/ai/runtimeCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down Expand Up @@ -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;
Expand Down
Loading
Loading