Support diegetic Norn and TeX surfaces
This commit is contained in:
parent
c7d067caba
commit
d22370cfe2
6 changed files with 271 additions and 23 deletions
|
|
@ -107,7 +107,8 @@ Open `http://127.0.0.1:8891/`. The page can spawn:
|
|||
- `Fensalir Direct2D`, a fixture surface for the planned
|
||||
CultMesh-to-`AquariumUiDocument` lowering.
|
||||
- `Sai VN Surface`, a fixture for visual-novel scenes exported as
|
||||
`gamecult.eve.surface.v1`.
|
||||
`gamecult.eve.surface.v1`, including embedded Norn and TeX surfaces placed
|
||||
diegetically inside the scene.
|
||||
|
||||
## VoidBot CEF Stream
|
||||
|
||||
|
|
|
|||
|
|
@ -48,8 +48,9 @@ device better latency, touch, media, or sensor access.
|
|||
|
||||
Sai visual novels are now a first pressure test for this contract. Sai needs
|
||||
backgrounds, dialogue panels, choices, sprite layers, provider-owned cards,
|
||||
Norn graph navigation, and synchronized style controls. If a renderer can lower
|
||||
that tree, it can handle more than a dashboard pretending to be a list.
|
||||
embedded Norn graph navigation, embedded TeX surfaces, diegetic placement on
|
||||
scene props, and synchronized style controls. If a renderer can lower that
|
||||
tree, it can handle more than a dashboard pretending to be a list.
|
||||
|
||||
## Sensor Model
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ Kinds are semantic, not HTML tags. Renderers lower them to native controls:
|
|||
- `surface`, `stack`, `grid`, `dock`, `panel`, `card`
|
||||
- `text`, `text.dialogue`, `avatar`
|
||||
- `image.background`, `image.sprite`, `media.stream`
|
||||
- `embed.norn`, `embed.tex`, `layer.embedded-surfaces`
|
||||
- `graph`, `tree`, `inspector.kv`
|
||||
- `rail.actions`, `control.button`, `control.toggle`, `control.slider`,
|
||||
`control.segmented`, `control.color`, `control.select`
|
||||
|
|
@ -63,6 +64,87 @@ If a renderer does not know a specialized kind, it should fall back through the
|
|||
kind path: `panel.dialogue` may render as `panel`; `image.sprite` may render as
|
||||
`image`.
|
||||
|
||||
## Embedded Knowledge Surfaces
|
||||
|
||||
Eve must be able to place rich interactive surfaces inside another surface. For
|
||||
Sai, this means the VN scene can host Norn and TeX as diegetic scene elements:
|
||||
whiteboards, handheld tablets, hologram panes, cockpit screens, chalkboards, or
|
||||
chromakey regions baked into sprite assets.
|
||||
|
||||
### `embed.norn`
|
||||
|
||||
`embed.norn` means "run Norn here." It is not a request to draw a static graph
|
||||
with whatever local widget happens to be nearby.
|
||||
|
||||
Minimum props:
|
||||
|
||||
- `engine.id`: `norn`
|
||||
- `engine.contract`: Norn surface contract id, currently
|
||||
`gamecult.norn.surface.v1`.
|
||||
- `engine.web.wasm`: optional WASM asset for browser clients.
|
||||
- `engine.native.rustCrate`: native solver crate, usually `norn-rs`.
|
||||
- `layout`: layout mode and solver knobs.
|
||||
- `graph.nodes` and `graph.edges`: provider graph state.
|
||||
- `interaction.nodeAction`: command emitted when a node is activated.
|
||||
- `placement`: scene placement instructions.
|
||||
|
||||
Each target renderer embeds Norn by using the strongest local path available:
|
||||
|
||||
- Web: Norn WASM / `@gamecult/norn-viewer`.
|
||||
- iOS: native graph view using the Norn layout output, eventually Rust FFI.
|
||||
- Android: native graph view using the same Norn contract, eventually Rust FFI.
|
||||
- Windows Direct2D: Norn layout lowered to Direct2D/DirectWrite primitives.
|
||||
|
||||
If a client cannot run Norn, it must report a capability gap. It may show a
|
||||
read-only fallback, but it must not silently pretend the fallback is full Norn.
|
||||
|
||||
### `embed.tex`
|
||||
|
||||
`embed.tex` is a portable TeX/LaTeX surface. It carries source, macros, display
|
||||
mode, renderer hints, and placement. Web clients may lower through KaTeX,
|
||||
MathJax, Typst-assisted renderers, or a TeX WASM path. Native clients should
|
||||
lower to vector/text primitives or cached images while preserving source,
|
||||
baseline, scale, and command provenance.
|
||||
|
||||
Minimum props:
|
||||
|
||||
- `source` or `sourceUri`
|
||||
- `format`: `latex`, `tex`, or a stricter future dialect.
|
||||
- `display`: `inline`, `block`, or `page`.
|
||||
- `macros`
|
||||
- `renderer`
|
||||
- `placement`
|
||||
|
||||
## Scene Placement
|
||||
|
||||
Any component can carry `props.placement` when it needs to live in scene space.
|
||||
|
||||
```json
|
||||
{
|
||||
"space": "scene",
|
||||
"anchor": "whiteboard",
|
||||
"mode": "keystone",
|
||||
"quad": [[0.16, 0.18], [0.58, 0.13], [0.62, 0.50], [0.14, 0.56]],
|
||||
"zIndex": 4,
|
||||
"opacity": 0.94,
|
||||
"chromaKey": { "color": "#00ff00", "tolerance": 0.12 },
|
||||
"occlusion": "sprite-mask:whiteboard-hand",
|
||||
"lighting": "scene"
|
||||
}
|
||||
```
|
||||
|
||||
Placement modes:
|
||||
|
||||
- `overlay`: normal 2D scene overlay.
|
||||
- `billboard`: scene-space panel facing the viewer.
|
||||
- `skew`: affine skew.
|
||||
- `keystone`: four-corner perspective fit.
|
||||
- `sprite-chromakey`: render into a keyed region of a sprite or prop.
|
||||
|
||||
Coordinates are normalized to the stage unless an explicit coordinate space is
|
||||
named. Renderers that cannot do true perspective must preserve hit-testing and
|
||||
report the degradation.
|
||||
|
||||
## Commands
|
||||
|
||||
Commands use `gamecult.eve.command.v1`:
|
||||
|
|
@ -132,7 +214,10 @@ Sai requires Eve/CultUI to carry:
|
|||
- speaker, avatar, dialogue, and choices;
|
||||
- sprite layers with position, scale, and offsets;
|
||||
- external provider-owned cards/fragments;
|
||||
- Norn-style graph components with clickable node targets;
|
||||
- embedded Norn graph/map surfaces with clickable node targets;
|
||||
- embedded TeX surfaces for equations, whitepapers, ledgers, and proofs;
|
||||
- diegetic placement with perspective, skew, keystone, chromakey, and occlusion
|
||||
metadata;
|
||||
- synchronized style tokens;
|
||||
- story commands for continue, choice, jump, and style patch.
|
||||
|
||||
|
|
|
|||
|
|
@ -56,22 +56,82 @@
|
|||
},
|
||||
{
|
||||
"id": "sai.graph",
|
||||
"kind": "graph",
|
||||
"kind": "embed.norn",
|
||||
"props": {
|
||||
"label": "GameCult Ink Knot Graph",
|
||||
"layout": "norn.2d",
|
||||
"nodes": [
|
||||
{ "id": "hub", "label": "Hub", "target": "hub", "x": 0.2, "y": 0.2, "current": true },
|
||||
{ "id": "eve", "label": "Eve", "target": "eve", "x": 0.72, "y": 0.24 },
|
||||
{ "id": "sai", "label": "Sai", "target": "sai", "x": 0.48, "y": 0.55 }
|
||||
],
|
||||
"edges": [
|
||||
{ "source": "hub", "target": "eve" },
|
||||
{ "source": "hub", "target": "sai" },
|
||||
{ "source": "sai", "target": "eve" }
|
||||
]
|
||||
"engine": {
|
||||
"id": "norn",
|
||||
"contract": "gamecult.norn.surface.v1",
|
||||
"web": {
|
||||
"wasm": "/static/interactive/norn/norn-rs.wasm",
|
||||
"package": "@gamecult/norn-viewer"
|
||||
},
|
||||
"native": {
|
||||
"rustCrate": "norn-rs",
|
||||
"direct2dAdapter": "fensalir.norn.direct2d"
|
||||
}
|
||||
},
|
||||
"layout": {
|
||||
"mode": "norn.2d",
|
||||
"iterations": 220,
|
||||
"rankGap": 150,
|
||||
"nodeGap": 88,
|
||||
"edgeLength": 132
|
||||
},
|
||||
"graph": {
|
||||
"nodes": [
|
||||
{ "id": "hub", "label": "Hub", "target": "hub", "x": 0.2, "y": 0.2, "current": true },
|
||||
{ "id": "eve", "label": "Eve", "target": "eve", "x": 0.72, "y": 0.24 },
|
||||
{ "id": "sai", "label": "Sai", "target": "sai", "x": 0.48, "y": 0.55 }
|
||||
],
|
||||
"edges": [
|
||||
{ "source": "hub", "target": "eve" },
|
||||
{ "source": "hub", "target": "sai" },
|
||||
{ "source": "sai", "target": "eve" }
|
||||
]
|
||||
},
|
||||
"interaction": {
|
||||
"nodeAction": "story.jump",
|
||||
"focusFollowsStory": true,
|
||||
"rendererMustUseNorn": true
|
||||
},
|
||||
"placement": {
|
||||
"space": "scene",
|
||||
"anchor": "whiteboard",
|
||||
"mode": "keystone",
|
||||
"quad": [[0.08, 0.10], [0.55, 0.06], [0.59, 0.52], [0.07, 0.58]],
|
||||
"zIndex": 4
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "sai.embeds",
|
||||
"kind": "layer.embedded-surfaces",
|
||||
"children": [
|
||||
{
|
||||
"id": "sai.tex.log-power",
|
||||
"kind": "embed.tex",
|
||||
"props": {
|
||||
"label": "Bifrost voting weight",
|
||||
"source": "\\\\mathrm{votes}(p)=1+\\\\lfloor\\\\log_b(1+p)\\\\rfloor",
|
||||
"format": "latex",
|
||||
"display": "block",
|
||||
"renderer": {
|
||||
"web": "katex",
|
||||
"native": "tex-renderer",
|
||||
"direct2d": "tex-to-directwrite"
|
||||
},
|
||||
"placement": {
|
||||
"space": "scene",
|
||||
"anchor": "whiteboard-equation",
|
||||
"mode": "keystone",
|
||||
"quad": [[0.16, 0.60], [0.54, 0.57], [0.56, 0.70], [0.15, 0.73]],
|
||||
"zIndex": 5
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "sai.cards",
|
||||
"kind": "layer.cards",
|
||||
|
|
|
|||
|
|
@ -252,6 +252,21 @@ p {
|
|||
z-index: 4;
|
||||
}
|
||||
|
||||
.cultui-placed {
|
||||
position: absolute;
|
||||
transform-origin: center;
|
||||
}
|
||||
|
||||
.cultui-placed[data-placement-mode="keystone"],
|
||||
.cultui-placed[data-placement-mode="skew"],
|
||||
.cultui-placed[data-placement-mode="sprite-chromakey"] {
|
||||
box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28);
|
||||
}
|
||||
|
||||
.cultui-placed[data-chroma-key] {
|
||||
outline: 1px dashed rgba(0, 255, 120, 0.45);
|
||||
}
|
||||
|
||||
.cultui-node {
|
||||
position: absolute;
|
||||
transform: translate(-50%, -50%);
|
||||
|
|
@ -282,6 +297,39 @@ p {
|
|||
stroke-linecap: round;
|
||||
}
|
||||
|
||||
.cultui-layer-embedded-surfaces {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 5;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.cultui-layer-embedded-surfaces > * {
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.cultui-tex {
|
||||
min-width: 12rem;
|
||||
min-height: 3.2rem;
|
||||
border: 1px solid rgba(142, 252, 255, 0.34);
|
||||
border-radius: 6px;
|
||||
background: rgba(7, 17, 26, 0.78);
|
||||
color: var(--text);
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
.cultui-tex-label {
|
||||
color: var(--accent);
|
||||
font: 700 10px "Cascadia Mono", Consolas, monospace;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.cultui-tex-source {
|
||||
margin-top: 4px;
|
||||
font: 700 15px "Cambria Math", "STIX Two Math", Georgia, serif;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.cultui-layer-cards {
|
||||
position: absolute;
|
||||
top: 18px;
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ function renderCultComponent(node) {
|
|||
const kind = node.kind || "panel";
|
||||
const props = node.props || {};
|
||||
const children = node.children || [];
|
||||
let rendered;
|
||||
|
||||
if (kind === "vn.stage") {
|
||||
const stage = el("section", "cultui-vn-stage");
|
||||
|
|
@ -113,14 +114,23 @@ function renderCultComponent(node) {
|
|||
const view = el("div", "cultui-background");
|
||||
if (props.src) view.style.backgroundImage = `url("${props.src}")`;
|
||||
view.setAttribute("aria-label", props.label || "background");
|
||||
return view;
|
||||
return placeComponent(view, props.placement);
|
||||
}
|
||||
|
||||
if (kind === "graph") {
|
||||
return renderCultGraph(props);
|
||||
if (kind === "graph" || kind === "embed.norn") {
|
||||
return placeComponent(renderCultGraph(props), props.placement);
|
||||
}
|
||||
|
||||
if (kind === "layer.sprites" || kind === "layer.cards" || kind === "rail.actions") {
|
||||
if (kind === "embed.tex") {
|
||||
return placeComponent(renderCultTex(props), props.placement);
|
||||
}
|
||||
|
||||
if (
|
||||
kind === "layer.sprites" ||
|
||||
kind === "layer.cards" ||
|
||||
kind === "layer.embedded-surfaces" ||
|
||||
kind === "rail.actions"
|
||||
) {
|
||||
const layer = el("div", `cultui-${kind.replace(".", "-")}`);
|
||||
for (const child of children) layer.append(renderCultComponent(child));
|
||||
return layer;
|
||||
|
|
@ -186,16 +196,51 @@ function renderCultComponent(node) {
|
|||
const fallback = el("section", "pane");
|
||||
fallback.append(el("h2", "", kind));
|
||||
for (const child of children) fallback.append(renderCultComponent(child));
|
||||
return fallback;
|
||||
rendered = fallback;
|
||||
return placeComponent(rendered, props.placement);
|
||||
}
|
||||
|
||||
function placeComponent(element, placement) {
|
||||
if (!placement || placement.space !== "scene") return element;
|
||||
element.classList.add("cultui-placed");
|
||||
element.dataset.placementMode = placement.mode || "overlay";
|
||||
element.dataset.placementAnchor = placement.anchor || "";
|
||||
if (placement.zIndex !== undefined) element.style.zIndex = placement.zIndex;
|
||||
if (placement.opacity !== undefined) element.style.opacity = placement.opacity;
|
||||
|
||||
const quad = placement.quad;
|
||||
if (Array.isArray(quad) && quad.length >= 4) {
|
||||
const xs = quad.map(point => point[0]);
|
||||
const ys = quad.map(point => point[1]);
|
||||
const minX = Math.min(...xs);
|
||||
const maxX = Math.max(...xs);
|
||||
const minY = Math.min(...ys);
|
||||
const maxY = Math.max(...ys);
|
||||
element.style.left = `${minX * 100}%`;
|
||||
element.style.top = `${minY * 100}%`;
|
||||
element.style.width = `${Math.max(0.02, maxX - minX) * 100}%`;
|
||||
element.style.height = `${Math.max(0.02, maxY - minY) * 100}%`;
|
||||
const skewX = ((quad[1][1] - quad[0][1]) + (quad[2][1] - quad[3][1])) * 18;
|
||||
const skewY = ((quad[3][0] - quad[0][0]) + (quad[2][0] - quad[1][0])) * -18;
|
||||
element.style.transform = `skew(${skewX}deg, ${skewY}deg)`;
|
||||
}
|
||||
|
||||
if (placement.chromaKey) {
|
||||
element.dataset.chromaKey = placement.chromaKey.color || "enabled";
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
function renderCultGraph(props) {
|
||||
const graph = el("section", "cultui-graph");
|
||||
graph.dataset.engine = props.engine?.id || "graph";
|
||||
graph.dataset.contract = props.engine?.contract || "";
|
||||
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
||||
svg.setAttribute("viewBox", "0 0 1 1");
|
||||
svg.setAttribute("preserveAspectRatio", "none");
|
||||
const nodes = props.nodes || [];
|
||||
for (const edge of props.edges || []) {
|
||||
const graphState = props.graph || props;
|
||||
const nodes = graphState.nodes || [];
|
||||
for (const edge of graphState.edges || []) {
|
||||
const source = nodes.find(node => node.id === edge.source);
|
||||
const target = nodes.find(node => node.id === edge.target);
|
||||
if (!source || !target) continue;
|
||||
|
|
@ -220,6 +265,14 @@ function renderCultGraph(props) {
|
|||
return graph;
|
||||
}
|
||||
|
||||
function renderCultTex(props) {
|
||||
const panel = el("section", "cultui-tex");
|
||||
panel.dataset.renderer = props.renderer?.web || "tex";
|
||||
if (props.label) panel.append(el("div", "cultui-tex-label", props.label));
|
||||
panel.append(el("div", "cultui-tex-source", props.source || props.sourceUri || ""));
|
||||
return panel;
|
||||
}
|
||||
|
||||
function renderVoidBot(state) {
|
||||
const nodes = state.nodes || [];
|
||||
const ctb = nodes.filter(n => n.kind === "ctb-turn");
|
||||
|
|
|
|||
Loading…
Reference in a new issue