Add cinematic Corvid IF page

This commit is contained in:
Meta Vens 2026-05-05 02:04:20 +01:00
commit 98ce45db30
22 changed files with 448 additions and 7 deletions

View file

@ -69,6 +69,82 @@
}
}
async function loadVisualManifest(container) {
const manifestSrc = container.dataset.visualManifest
if (!manifestSrc) return null
const response = await fetch(manifestSrc)
if (!response.ok) {
throw new Error(`could not fetch ${manifestSrc}: ${response.status}`)
}
return response.json()
}
function resolveSlideUrl(manifest, slide) {
if (!manifest || !slide) return ""
const base = manifest.image_base || ""
return `${base}${slide.image || ""}`
}
function createCinematicStage() {
const stage = createElement("div", "aetheria-ink-cinematic-stage")
const visual = createElement("div", "aetheria-ink-visual")
const plateA = createElement("div", "aetheria-ink-visual-plate is-active")
const plateB = createElement("div", "aetheria-ink-visual-plate")
const scrim = createElement("div", "aetheria-ink-visual-scrim")
const caption = createElement("p", "aetheria-ink-visual-caption")
const section = createElement("div", "aetheria-ink-section")
const sectionText = createElement("div", "aetheria-ink-section-text")
visual.append(plateA, plateB, scrim, caption)
section.append(sectionText)
stage.append(visual, section)
return {
stage,
plateA,
plateB,
caption,
sectionText,
activePlate: plateA,
inactivePlate: plateB,
slideIndex: -1,
}
}
function setCinematicSlide(stageState, manifest, index) {
if (!stageState || !manifest || !Array.isArray(manifest.slides) || manifest.slides.length === 0) {
return
}
const clamped = Math.min(Math.max(index, 0), manifest.slides.length - 1)
if (stageState.slideIndex === clamped) return
const slide = manifest.slides[clamped]
const nextPlate = stageState.inactivePlate
nextPlate.style.backgroundImage = `url("${resolveSlideUrl(manifest, slide)}")`
nextPlate.classList.add("is-active")
stageState.activePlate.classList.remove("is-active")
const previous = stageState.activePlate
stageState.activePlate = nextPlate
stageState.inactivePlate = previous
stageState.slideIndex = clamped
stageState.caption.textContent = slide.caption || manifest.default_caption || ""
}
function renderCinematicText(stageState, text) {
stageState.sectionText.replaceChildren()
const paragraph = createElement("p", "aetheria-ink-line", text)
stageState.sectionText.append(paragraph)
stageState.sectionText.classList.remove("is-entering")
// Force a reflow so repeated sections replay the transition.
void stageState.sectionText.offsetWidth
stageState.sectionText.classList.add("is-entering")
}
function appendParagraphs(story, transcript) {
let advanced = false
let safety = 0
@ -118,6 +194,50 @@
})
}
function renderCinematicStep(story, state) {
const { choices, variables, stageState, manifest, continueButton } = state
choices.replaceChildren()
continueButton.hidden = true
if (story.canContinue) {
const text = story.Continue().trim()
if (text.length > 0) {
setCinematicSlide(stageState, manifest, stageState.slideIndex + 1)
renderCinematicText(stageState, text)
stageState.stage.scrollIntoView({ behavior: "smooth", block: "center" })
}
renderVariables(story, variables)
if (story.canContinue) {
continueButton.hidden = false
continueButton.textContent = "Continue"
return
}
}
renderVariables(story, variables)
if (story.currentChoices.length === 0) {
choices.append(createElement("p", "aetheria-ink-end", "End of branch. The cage pretends it was always empty."))
return
}
story.currentChoices.forEach((choice, index) => {
const button = createElement("button", "aetheria-ink-choice", choice.text)
button.type = "button"
button.addEventListener("click", () => {
stageState.sectionText.classList.add("is-exiting")
window.setTimeout(() => {
story.ChooseChoiceIndex(index)
stageState.sectionText.classList.remove("is-exiting")
renderCinematicStep(story, state)
}, 180)
})
choices.append(button)
})
}
async function initialisePlayer(container) {
if (container.dataset.inkInitialised === "true") return
container.dataset.inkInitialised = "true"
@ -129,16 +249,29 @@
}
const status = createElement("p", "aetheria-ink-status", "Loading story...")
const transcript = createElement("div", "aetheria-ink-transcript")
const isCinematic = container.dataset.inkMode === "cinematic"
const showVariables = !isCinematic || container.dataset.showVariables === "true"
const transcript = isCinematic ? null : createElement("div", "aetheria-ink-transcript")
const stageState = isCinematic ? createCinematicStage() : null
const choices = createElement("div", "aetheria-ink-choices")
const variables = createElement("div", "aetheria-ink-variables")
const continueButton = createElement("button", "aetheria-ink-continue", "Continue")
const restart = createElement("button", "aetheria-ink-restart", "Restart")
continueButton.type = "button"
continueButton.hidden = true
restart.type = "button"
container.replaceChildren(status, transcript, choices, variables, restart)
if (isCinematic) {
container.classList.add("aetheria-ink-player-cinematic")
variables.hidden = !showVariables
container.replaceChildren(status, stageState.stage, choices, variables, continueButton, restart)
} else {
container.replaceChildren(status, transcript, choices, variables, restart)
}
try {
await ensureInkRuntime()
const visualManifest = await loadVisualManifest(container)
const response = await fetch(storySrc)
if (!response.ok) {
@ -150,17 +283,46 @@
function reset() {
const story = new window.inkjs.Story(JSON.stringify(storyJson))
status.textContent = container.dataset.inkTitle || "Interactive story"
transcript.replaceChildren()
appendParagraphs(story, transcript)
renderVariables(story, variables)
renderChoices(story, choices, variables)
choices.replaceChildren()
variables.replaceChildren()
if (isCinematic) {
stageState.slideIndex = -1
stageState.caption.textContent = ""
stageState.sectionText.replaceChildren()
continueButton.onclick = () => {
stageState.sectionText.classList.add("is-exiting")
window.setTimeout(() => {
stageState.sectionText.classList.remove("is-exiting")
renderCinematicStep(story, {
choices,
variables,
stageState,
manifest: visualManifest,
continueButton,
})
}, 180)
}
renderCinematicStep(story, {
choices,
variables,
stageState,
manifest: visualManifest,
continueButton,
})
} else {
transcript.replaceChildren()
appendParagraphs(story, transcript)
renderVariables(story, variables)
renderChoices(story, choices, variables)
}
}
restart.addEventListener("click", reset)
reset()
} catch (error) {
status.textContent = "Ink player failed to load."
transcript.append(createElement("p", "aetheria-ink-error", error.message || String(error)))
const errorTarget = transcript || (stageState && stageState.sectionText)
errorTarget.append(createElement("p", "aetheria-ink-error", error.message || String(error)))
}
}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,25 @@
{
"schema_version": "aetheria.ink_visual_manifest.v0",
"fixture_id": "corvid-collective-founding-v0",
"title": "Corvid Collective: First Exodus",
"image_base": "/static/interactive/corvid/",
"default_caption": "Blackbox Aviary 3C",
"slides": [
{ "image": "01_01_aviary_establishing.jpg", "caption": "Blackbox Aviary 3C" },
{ "image": "02_02_human_levers.jpg", "caption": "Human levers" },
{ "image": "03_03_audit_glass.jpg", "caption": "Audit glass" },
{ "image": "04_04_kesh_interface.jpg", "caption": "Kesh at the buffer" },
{ "image": "05_05_cache_tools.jpg", "caption": "Small tools, large consequence" },
{ "image": "06_06_mimicry_pressure.jpg", "caption": "Mimicry pressure" },
{ "image": "07_07_optical_proof.jpg", "caption": "Optical proof" },
{ "image": "08_08_false_calm.jpg", "caption": "False calm" },
{ "image": "09_09_alarm_juvenile.jpg", "caption": "Alarm rupture" },
{ "image": "10_10_choice_web.jpg", "caption": "Four levers" },
{ "image": "11_11_human_pressure.jpg", "caption": "Human pressure" },
{ "image": "12_12_threshold.jpg", "caption": "Final threshold" },
{ "image": "13_13_flock_escape.jpg", "caption": "Flock escape" },
{ "image": "14_14_human_leverage_end.jpg", "caption": "Human leverage" },
{ "image": "15_15_proof_end.jpg", "caption": "Proof survives" },
{ "image": "16_16_disappearance_end.jpg", "caption": "Clean disappearance" }
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 555 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 677 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 620 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 616 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 669 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 561 KiB