@litfamily/litgrok 1.0.26 → 1.0.27
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.
- package/.grok/hooks/lit-mark.mjs +42 -0
- package/.grok/hooks/lit-status-line.mjs +142 -19
- package/.grok/hooks/record-passive-event.mjs +21 -2
- package/.grok/hooks/session-start.mjs +17 -0
- package/.grok/hooks/workflow-stage.mjs +5 -2
- package/.grok/rules/00-litgrok.md +13 -0
- package/.grok/skills/frontend-ui-ux/ATTRIBUTION.md +23 -0
- package/.grok/skills/frontend-ui-ux/SKILL.md +4 -1
- package/.grok/skills/frontend-ui-ux/examples/phase-3-readme-ab/README.md +9 -0
- package/.grok/skills/frontend-ui-ux/kit/components.css +414 -0
- package/.grok/skills/frontend-ui-ux/kit/fonts.json +22 -0
- package/.grok/skills/frontend-ui-ux/kit/layouts/landing.html +164 -0
- package/.grok/skills/frontend-ui-ux/kit/layouts/settings.html +114 -0
- package/.grok/skills/frontend-ui-ux/kit/layouts/workspace.html +115 -0
- package/.grok/skills/frontend-ui-ux/kit/styles/computational-brutalism.json +227 -0
- package/.grok/skills/frontend-ui-ux/kit/styles/field-notes.json +205 -0
- package/.grok/skills/frontend-ui-ux/kit/styles/graphite.json +200 -0
- package/.grok/skills/frontend-ui-ux/kit/styles/meadow.json +199 -0
- package/.grok/skills/frontend-ui-ux/kit/styles/neo-brutalism.json +222 -0
- package/.grok/skills/frontend-ui-ux/kit/ui.js +226 -0
- package/.grok/skills/frontend-ui-ux/references/adaptive-layout.md +10 -4
- package/.grok/skills/frontend-ui-ux/references/brand-and-imagery.md +11 -7
- package/.grok/skills/frontend-ui-ux/references/complete-contract.md +21 -0
- package/.grok/skills/frontend-ui-ux/references/composition.md +10 -6
- package/.grok/skills/frontend-ui-ux/references/craft-floor.md +256 -93
- package/.grok/skills/frontend-ui-ux/references/creative-directions.md +9 -6
- package/.grok/skills/frontend-ui-ux/references/default-editorial-pixel.json +28 -0
- package/.grok/skills/frontend-ui-ux/references/house-styles.md +234 -0
- package/.grok/skills/frontend-ui-ux/references/implementation-platforms.md +10 -6
- package/.grok/skills/frontend-ui-ux/references/inclusive-interface.md +11 -5
- package/.grok/skills/frontend-ui-ux/references/interaction-motion.md +34 -78
- package/.grok/skills/frontend-ui-ux/references/motion-guide.md +10 -7
- package/.grok/skills/frontend-ui-ux/references/performance-delivery.md +11 -8
- package/.grok/skills/frontend-ui-ux/references/probe-loop.md +1 -1
- package/.grok/skills/frontend-ui-ux/references/product-direction.md +9 -4
- package/.grok/skills/frontend-ui-ux/references/production-interview.md +17 -0
- package/.grok/skills/frontend-ui-ux/references/redesign-playbook.md +10 -6
- package/.grok/skills/frontend-ui-ux/references/slop-register.md +148 -73
- package/.grok/skills/frontend-ui-ux/references/system-foundations.md +10 -4
- package/.grok/skills/frontend-ui-ux/references/visual-language.md +10 -4
- package/.grok/skills/frontend-ui-ux/references/visual-reconstruction.md +39 -72
- package/.grok/skills/frontend-ui-ux/scripts/design-lock.mjs +400 -0
- package/.grok/skills/frontend-ui-ux/scripts/interface-probe-driver.mjs +33 -0
- package/.grok/skills/frontend-ui-ux/scripts/interface-probe-lock.mjs +196 -0
- package/.grok/skills/frontend-ui-ux/scripts/interface-probe-page.mjs +1555 -0
- package/.grok/skills/frontend-ui-ux/scripts/interface-probe-rules.mjs +153 -0
- package/.grok/skills/frontend-ui-ux/scripts/interface-probe-server.mjs +57 -0
- package/.grok/skills/frontend-ui-ux/scripts/interface-probe-static.mjs +139 -0
- package/.grok/skills/frontend-ui-ux/scripts/interface-probe.mjs +363 -0
- package/.grok/skills/frontend-ui-ux/scripts/pixel-art.mjs +60 -0
- package/.grok/skills/lit-adhd/SKILL.md +151 -0
- package/.grok/skills/lit-adhd/references/card-examples.md +118 -0
- package/.grok/skills/lit-adhd/references/status-taxonomy.md +36 -0
- package/.grok/skills/lit-adhd/scripts/lib/brief.mjs +370 -0
- package/.grok/skills/lit-adhd/scripts/lib/collect.mjs +327 -0
- package/.grok/skills/lit-adhd/scripts/lib/gauge.mjs +87 -0
- package/.grok/skills/lit-adhd/scripts/lib/next-step.mjs +18 -0
- package/.grok/skills/lit-adhd/scripts/lib/plan-task-rows.mjs +32 -0
- package/.grok/skills/lit-adhd/scripts/lib/project-state-root.mjs +55 -0
- package/.grok/skills/lit-adhd/scripts/lib/redact.mjs +64 -0
- package/.grok/skills/lit-adhd/scripts/lib/suggest.mjs +140 -0
- package/.grok/skills/lit-adhd/scripts/lib/transcripts.mjs +232 -0
- package/.grok/skills/lit-adhd/scripts/rewind.mjs +6 -0
- package/.grok/skills/lit-diagram-drawer/SKILL.md +17 -5
- package/.grok/skills/lit-diagram-drawer/references/output-spec.md +2 -2
- package/.grok/skills/lit-diagram-drawer/references/style-guide.md +20 -11
- package/.grok/skills/lit-diagram-drawer/references/type-architecture.md +3 -3
- package/.grok/skills/lit-diagram-drawer/references/type-dependency.md +1 -1
- package/.grok/skills/lit-diagram-drawer/references/type-tree.md +3 -3
- package/.grok/skills/lit-diagram-drawer/references/type-wardley.md +1 -1
- package/.grok/skills/lit-diagram-drawer/references/verifier-guide.md +4 -0
- package/.grok/skills/lit-diagram-drawer/scripts/visual-quality.mjs +2 -2
- package/.grok/skills/lit-handoff/SKILL.md +2 -0
- package/.grok/skills/lit-hijack/SKILL.md +459 -0
- package/.grok/skills/lit-hijack/references/capture-and-provenance.md +124 -0
- package/.grok/skills/lit-hijack/references/clean-room-build.md +130 -0
- package/.grok/skills/lit-hijack/references/distil-and-licence.md +128 -0
- package/.grok/skills/lit-hijack/references/gap-and-port-design.md +150 -0
- package/.grok/skills/lit-hijack/references/parity-and-report.md +130 -0
- package/.grok/skills/lit-hijack/scripts/hijack.mjs +890 -0
- package/.grok/skills/lit-hijack/scripts/lib/safe-fetch.mjs +213 -0
- package/.grok/skills/lit-plan/SKILL.md +1 -1
- package/.grok/skills/lit-pptx/SKILL.md +10 -5
- package/.grok/skills/lit-pptx/examples/13-engineering-review-computational-brutalism-ko.md +173 -0
- package/.grok/skills/lit-pptx/examples/14-launch-pitch-neo-brutalism-ko.md +154 -0
- package/.grok/skills/lit-pptx/examples/15-design-lecture-bauhaus-ko.md +139 -0
- package/.grok/skills/lit-pptx/examples/16-community-programme-riso-ko.md +158 -0
- package/.grok/skills/lit-pptx/examples/17-public-data-briefing-newsroom-ko.md +179 -0
- package/.grok/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Bold.ttf +0 -0
- package/.grok/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Regular.ttf +0 -0
- package/.grok/skills/lit-pptx/fonts/jetbrains-mono/OFL.txt +93 -0
- package/.grok/skills/lit-pptx/fonts/jetbrains-mono/provenance.json +1 -0
- package/.grok/skills/lit-pptx/references/direction-step.md +34 -8
- package/.grok/skills/lit-pptx/references/tonalities/bauhaus.md +140 -0
- package/.grok/skills/lit-pptx/references/tonalities/computational-brutalism.md +150 -0
- package/.grok/skills/lit-pptx/references/tonalities/neo-brutalism.md +161 -0
- package/.grok/skills/lit-pptx/references/tonalities/newsroom.md +144 -0
- package/.grok/skills/lit-pptx/references/tonalities/riso.md +137 -0
- package/.grok/skills/lit-pptx/scripts/compile-deck.js +1 -1
- package/.grok/skills/lit-pptx/scripts/craft_extras.py +61 -3
- package/.grok/skills/lit-pptx/scripts/deck_output.py +76 -62
- package/.grok/skills/lit-pptx/scripts/embed_fonts.py +14 -1
- package/.grok/skills/lit-pptx/scripts/lib/grid-resolver.js +101 -110
- package/.grok/skills/lit-pptx/scripts/lib/layout-resolver.js +9 -15
- package/.grok/skills/lit-pptx/scripts/lib/render-pack.js +389 -582
- package/.grok/skills/lit-pptx/scripts/lib/slide-grid.js +104 -0
- package/.grok/skills/lit-pptx/scripts/lib/template-registry.js +60 -8
- package/.grok/skills/lit-pptx/scripts/qa_deck.py +4 -4
- package/.grok/skills/lit-pptx/templates/tonalities/atlas/pack.yaml +2 -0
- package/.grok/skills/lit-pptx/templates/tonalities/bauhaus/pack.yaml +98 -0
- package/.grok/skills/lit-pptx/templates/tonalities/chalk/pack.yaml +2 -0
- package/.grok/skills/lit-pptx/templates/tonalities/computational-brutalism/pack.yaml +99 -0
- package/.grok/skills/lit-pptx/templates/tonalities/gazette/pack.yaml +2 -0
- package/.grok/skills/lit-pptx/templates/tonalities/ledger/pack.yaml +2 -0
- package/.grok/skills/lit-pptx/templates/tonalities/neo-brutalism/pack.yaml +107 -0
- package/.grok/skills/lit-pptx/templates/tonalities/newsroom/pack.yaml +99 -0
- package/.grok/skills/lit-pptx/templates/tonalities/night/pack.yaml +2 -0
- package/.grok/skills/lit-pptx/templates/tonalities/paper/pack.yaml +2 -0
- package/.grok/skills/lit-pptx/templates/tonalities/riso/pack.yaml +99 -0
- package/.grok/skills/lit-pptx/templates/tonalities/signal/pack.yaml +3 -0
- package/.grok/skills/lit-pptx/templates/tonalities/studio/pack.yaml +2 -0
- package/.grok/skills/lit-recap/SKILL.md +1 -1
- package/.grok/skills/lit-schematic/SKILL.md +140 -0
- package/.grok/skills/lit-schematic/examples/iso-heat-exchanger/build.mjs +38 -0
- package/.grok/skills/lit-schematic/examples/iso-heat-exchanger/scene.mjs +133 -0
- package/.grok/skills/lit-schematic/examples/journal-adsorption-rig/build.mjs +87 -0
- package/.grok/skills/lit-schematic/examples/pid-dosing-skid/build.mjs +85 -0
- package/.grok/skills/lit-schematic/references/cutaway-outputs.md +70 -0
- package/.grok/skills/lit-schematic/references/isometric-craft.md +101 -0
- package/.grok/skills/lit-schematic/references/journal-figures.md +72 -0
- package/.grok/skills/lit-schematic/references/kit-api.md +134 -0
- package/.grok/skills/lit-schematic/references/pfd-and-layout.md +53 -0
- package/.grok/skills/lit-schematic/references/pid-drafting.md +103 -0
- package/.grok/skills/lit-schematic/references/pid-symbols.md +163 -0
- package/.grok/skills/lit-schematic/references/verification.md +100 -0
- package/.grok/skills/lit-schematic/scripts/doctor.mjs +57 -0
- package/.grok/skills/lit-schematic/scripts/lib/figure.mjs +81 -0
- package/.grok/skills/lit-schematic/scripts/lib/fonts.mjs +27 -0
- package/.grok/skills/lit-schematic/scripts/lib/geom.mjs +113 -0
- package/.grok/skills/lit-schematic/scripts/lib/interactive.mjs +292 -0
- package/.grok/skills/lit-schematic/scripts/lib/isa.mjs +115 -0
- package/.grok/skills/lit-schematic/scripts/lib/iso.mjs +719 -0
- package/.grok/skills/lit-schematic/scripts/lib/legend-sheet.mjs +162 -0
- package/.grok/skills/lit-schematic/scripts/lib/pid.mjs +937 -0
- package/.grok/skills/lit-schematic/scripts/lib/png.mjs +132 -0
- package/.grok/skills/lit-schematic/scripts/lib/qa-core.mjs +658 -0
- package/.grok/skills/lit-schematic/scripts/lib/route.mjs +218 -0
- package/.grok/skills/lit-schematic/scripts/lib/sheet.mjs +890 -0
- package/.grok/skills/lit-schematic/scripts/lib/svg.mjs +82 -0
- package/.grok/skills/lit-schematic/scripts/lib/theme.mjs +115 -0
- package/.grok/skills/lit-schematic/scripts/motion.mjs +129 -0
- package/.grok/skills/lit-schematic/scripts/qa.mjs +92 -0
- package/.grok/skills/lit-schematic/scripts/render.mjs +233 -0
- package/.grok/skills/lit-schematic/scripts/scaffold.mjs +60 -0
- package/.grok/skills/lit-scientific-visualization/SKILL.md +36 -12
- package/.grok/skills/lit-typographic-motion/SKILL.md +7 -4
- package/.grok/skills/lit-typographic-motion/THIRD_PARTY_NOTICES +11 -0
- package/.grok/skills/lit-typographic-motion/recipes/hero-3d/expected.json +62 -0
- package/.grok/skills/lit-typographic-motion/recipes/hero-3d/index.html +82 -0
- package/.grok/skills/lit-typographic-motion/references/choice-first.md +30 -0
- package/.grok/skills/lit-typographic-motion/references/cover.md +10 -1
- package/.grok/skills/lit-typographic-motion/references/depth.md +119 -0
- package/.grok/skills/lit-typographic-motion/references/treatment.md +9 -1
- package/.grok/skills/lit-typographic-motion/scripts/blender/runner.py +218 -0
- package/.grok/skills/lit-typographic-motion/scripts/lib/assets.mjs +230 -0
- package/.grok/skills/lit-typographic-motion/scripts/lib/blender.mjs +136 -0
- package/.grok/skills/lit-typographic-motion/scripts/lib/board.mjs +153 -0
- package/.grok/skills/lit-typographic-motion/scripts/lib/chrome.mjs +61 -32
- package/.grok/skills/lit-typographic-motion/scripts/lib/constants.mjs +4 -2
- package/.grok/skills/lit-typographic-motion/scripts/lib/cover-capture.mjs +20 -11
- package/.grok/skills/lit-typographic-motion/scripts/lib/cover-treatment.mjs +26 -2
- package/.grok/skills/lit-typographic-motion/scripts/lib/cover.mjs +12 -5
- package/.grok/skills/lit-typographic-motion/scripts/lib/frame-pool.mjs +78 -1
- package/.grok/skills/lit-typographic-motion/scripts/lib/gallery.mjs +160 -0
- package/.grok/skills/lit-typographic-motion/scripts/lib/house.mjs +43 -0
- package/.grok/skills/lit-typographic-motion/scripts/lib/look.mjs +39 -1
- package/.grok/skills/lit-typographic-motion/scripts/lib/scaffold.mjs +174 -0
- package/.grok/skills/lit-typographic-motion/scripts/lib/score.mjs +640 -0
- package/.grok/skills/lit-typographic-motion/scripts/lib/sound.mjs +143 -0
- package/.grok/skills/lit-typographic-motion/scripts/lib/soundtrack.mjs +12 -3
- package/.grok/skills/lit-typographic-motion/scripts/lib/stage-gate.mjs +44 -0
- package/.grok/skills/lit-typographic-motion/scripts/lib/stage-qa.mjs +132 -3
- package/.grok/skills/lit-typographic-motion/scripts/lib/stage-session.mjs +51 -3
- package/.grok/skills/lit-typographic-motion/scripts/lib/stage.mjs +74 -9
- package/.grok/skills/lit-typographic-motion/scripts/lib/styles.mjs +224 -0
- package/.grok/skills/lit-typographic-motion/scripts/lib/treatment.mjs +198 -4
- package/.grok/skills/lit-typographic-motion/scripts/lib/vendor/three/LICENSE +21 -0
- package/.grok/skills/lit-typographic-motion/scripts/lib/vendor/three/addons/environments/RoomEnvironment.js +144 -0
- package/.grok/skills/lit-typographic-motion/scripts/lib/vendor/three/addons/geometries/RoundedBoxGeometry.js +155 -0
- package/.grok/skills/lit-typographic-motion/scripts/lib/vendor/three/three.module.js +54571 -0
- package/.grok/skills/lit-typographic-motion/scripts/motion.mjs +56 -6
- package/.grok/skills/lit-typographic-motion/scripts/stage/cover-init.js +20 -8
- package/.grok/skills/lit-typographic-motion/scripts/stage/loop-kit.js +2 -2
- package/.grok/skills/lit-typographic-motion/scripts/stage/stage-kit.js +25 -0
- package/.grok/skills/lit-typographic-motion/styles/paper.json +1 -0
- package/.grok/skills/lit-typographic-motion/styles/swiss-signal.json +1 -0
- package/.grok/skills/lit-typographic-motion/styles/terminalcore.json +1 -0
- package/.grok/skills/lit-typographic-motion/styles/tidal.json +1 -0
- package/.grok/skills/litgrok/SKILL.md +1 -1
- package/.grok/skills/litresearch/SKILL.md +2 -0
- package/.grok/skills/readme-studio/SKILL.md +14 -12
- package/.grok/skills/readme-studio/references/choice-first.md +24 -0
- package/.grok/skills/start-work/SKILL.md +1 -1
- package/.grok-plugin/plugin.json +4 -1
- package/CHANGELOG.md +10 -0
- package/README.md +11 -11
- package/README_ko-KR.md +11 -11
- package/docs/assets/readme/badge-version.svg +1 -1
- package/docs/assets/showcase/brief.webp +0 -0
- package/docs/assets/showcase/deck.webp +0 -0
- package/docs/assets/showcase/page.webp +0 -0
- package/docs/assets/showcase/pid.webp +0 -0
- package/docs/assets/skills/lit-adhd.webp +0 -0
- package/docs/assets/skills/lit-hijack.webp +0 -0
- package/docs/assets/skills/lit-schematic.webp +0 -0
- package/docs/reference.md +5 -5
- package/docs/reference_ko-KR.md +5 -5
- package/package.json +5 -1
- package/plugin.json +1 -1
- package/.grok/skills/frontend-ui-ux/scripts/page-probe.mjs +0 -105
- package/.grok/skills/frontend-ui-ux/scripts/probe.mjs +0 -91
- package/.grok/skills/frontend-ui-ux/scripts/rule-data.mjs +0 -56
- package/.grok/skills/frontend-ui-ux/scripts/static-probe.mjs +0 -27
- package/.grok/skills/frontend-ui-ux/scripts/static-server.mjs +0 -19
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// `motion.mjs styles --out <dir> [--format 16:9|9:16]`: the style gallery. One short demo film, the
|
|
2
|
+
// same treatment and the same drawings, rendered as a board round in every house style, so a person
|
|
3
|
+
// can see what each style looks like before asking for a film. Each style's board lands in
|
|
4
|
+
// `<dir>/<style>/stills/board.png`, and `<dir>/styles.png` puts them side by side. The demo also
|
|
5
|
+
// proves the styles and the scaffold pass the board check as shipped.
|
|
6
|
+
import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { EXIT } from './constants.mjs';
|
|
9
|
+
import { decodePng, encodePng } from './png.mjs';
|
|
10
|
+
import { scaffoldHtml } from './scaffold.mjs';
|
|
11
|
+
import { renderStage } from './stage.mjs';
|
|
12
|
+
import { STYLE_IDS, readStyle, zonesPx } from './styles.mjs';
|
|
13
|
+
|
|
14
|
+
const COPY = ['작게 시작해서 끝까지', 'One clock for every frame', '한 화면에 한 가지 생각', 'Same house, every film'];
|
|
15
|
+
|
|
16
|
+
/** The demo treatment for one style: four shots, one of each text layout, 12 s. */
|
|
17
|
+
export function demoTreatment(styleId, format = '16:9') {
|
|
18
|
+
const style = readStyle(styleId);
|
|
19
|
+
// The demo renders: the port synth plays the glass bed, so every style demos its glass variant.
|
|
20
|
+
const bed = style.beds.find((b) => b.timbre === 'glass') ?? style.beds[0];
|
|
21
|
+
const hand = (i) => style.transitions[i % style.transitions.length];
|
|
22
|
+
const vertical = format === '9:16' ? ' vertical' : '';
|
|
23
|
+
const beats = [
|
|
24
|
+
{ t0: 0, t1: 3, layout: 'title', hero: 'The opening line lands while a ring draws itself behind it.', purpose: 'Open on the promise.', onScreen: 'A ring drawing on behind the opening line.', motion: 'The ring draws on; the line rises in.', sound: 'Pad opens with a hit on the first word.' },
|
|
25
|
+
{ t0: 3, t1: 6, layout: 'split', hero: 'Five bars rise in turn beside the line.', purpose: 'Show the system.', onScreen: 'Five bars rising beside one line.', motion: 'Bars rise in stagger.', sound: 'Hit on the cut.' },
|
|
26
|
+
{ t0: 6, t1: 9, layout: 'split-alt', hero: 'A dot travels a path from left to right.', purpose: 'Show one idea per screen.', onScreen: 'A dot crossing a drawn path.', motion: 'The dot travels the path.', sound: 'A rise into the close.' },
|
|
27
|
+
{ t0: 9, t1: 12, layout: 'stage', hero: 'A grid of squares settles above the closing line.', purpose: 'Close on the house.', onScreen: 'A settling grid of squares over a closing caption.', motion: 'Squares settle in stagger.', sound: 'Closing cadence.' },
|
|
28
|
+
].map((b, i, all) => ({ ...b, lines: [i], transition: i === all.length - 1 ? 'end' : hand(i) }));
|
|
29
|
+
return {
|
|
30
|
+
// A calibration sheet, not a film: the same simple demo in every style, so the styles compare.
|
|
31
|
+
// Minimal register: four plain shapes are negative space by design, and the board still judges
|
|
32
|
+
// every text rule on them.
|
|
33
|
+
request: `render a 12 s${vertical} simple demo film in the ${styleId} style`,
|
|
34
|
+
register: 'minimal',
|
|
35
|
+
genre: 'other', path: 'stage', pathReason: 'The demo draws shapes beside its type, which the type engine cannot draw.',
|
|
36
|
+
style: styleId,
|
|
37
|
+
idea: 'Four screens, one per layout, so the house style can be judged before a film is made.',
|
|
38
|
+
audience: 'Someone choosing a house style for their films.', channel: 'A gallery sheet viewed before a film is made, played with sound.',
|
|
39
|
+
format, formatReason: format === '9:16' ? 'The gallery shows the vertical layouts.' : 'The gallery shows the landscape layouts.',
|
|
40
|
+
durationSec: 12, beats,
|
|
41
|
+
story: { expect: 'Four screens that each show a new shape.', turn: 'The bars of the second screen become the path the dot travels on the third.', beat: 2, payoff: 'Everything settles into one grid above the closing line.' },
|
|
42
|
+
protagonist: { name: 'the signal mark', kind: 'object', look: "The style's signal colour as a ring, bars, a dot and one accent square.", acts: [{ beat: 0, action: 'Draws itself as a ring.' }, { beat: 1, action: 'Rises as five bars.' }, { beat: 2, action: 'Travels the path as a dot.' }, { beat: 3, action: 'Lands as the accent square of the grid.' }] },
|
|
43
|
+
subject: { name: 'the style demo', source: 'invented', specifics: ['Four screens with a ring, bars, a travelling dot and a grid.', 'Each screen uses one layout of the house grid.'] },
|
|
44
|
+
visualDevices: [{ kind: 'shape', role: 'subject', beats: [0, 1, 2, 3] }, { kind: 'path', role: 'support', beats: [2] }],
|
|
45
|
+
palette: [{ hex: style.palette.ground, role: 'ground' }, { hex: style.palette.ink, role: 'ink' }, { hex: style.palette.signal, role: 'signal' }],
|
|
46
|
+
typePlan: { faces: [style.faces.headline.family, style.faces.body.family], hierarchy: 'One line per screen in the style\u2019s headline or display size.', maxWordsOnScreen: 6 },
|
|
47
|
+
sound: { mode: 'generated', plan: 'The style\u2019s glass bed with a hit on the cuts and a closing cadence.', palette: { ...bed }, events: [{ t: 1.5, on: 'the ring draws itself behind the opening line', kind: 'tap' }, { t: 7.5, on: 'the dot travels the path', kind: 'whoosh' }] },
|
|
48
|
+
copy: { source: 'invented', lines: COPY },
|
|
49
|
+
inventions: ['the style demo (its four screens)', 'all four copy lines'],
|
|
50
|
+
ambition: 'Each screen shows one layout cleanly so the style\u2019s type, colour and motion read at a glance.',
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// The demo's drawings: generic shapes in the style's own colours, one per shot, posed by the shot's
|
|
55
|
+
// own progress so every replay draws the same pixels. Each shot's DRAW also shows its own copy line
|
|
56
|
+
// in the type zone and hides the other three, so the board reads one line per shot.
|
|
57
|
+
function demoDraw(treatment, style) {
|
|
58
|
+
const zones = zonesPx(treatment.format);
|
|
59
|
+
const pal = style.palette;
|
|
60
|
+
const line = (i) => {
|
|
61
|
+
const z = zones[treatment.beats[i].layout].type;
|
|
62
|
+
return `<p class="lit-headline lit-ink" id="dl${i}" style="position:absolute;left:${z.x}px;top:${z.y}px;width:${z.w}px;opacity:0">${treatment.copy.lines[i]}</p>`;
|
|
63
|
+
};
|
|
64
|
+
const shapes = treatment.beats.map((b, i) => {
|
|
65
|
+
const z = zones[b.layout].subject;
|
|
66
|
+
const cx = z.x + z.w / 2, cy = z.y + z.h / 2;
|
|
67
|
+
if (i === 0) {
|
|
68
|
+
const r = Math.round(Math.min(z.w, z.h) * 0.3);
|
|
69
|
+
return `<div id="dg0" style="position:absolute;left:${cx - r}px;top:${cy - r}px;width:${2 * r}px;height:${2 * r}px;border:10px solid ${pal.signal};border-radius:50%;box-sizing:border-box;opacity:0"></div>`;
|
|
70
|
+
}
|
|
71
|
+
if (i === 1) {
|
|
72
|
+
const w = Math.round(z.w / 9);
|
|
73
|
+
let bars = '';
|
|
74
|
+
for (let k = 0; k < 5; k++) bars += `<div style="position:absolute;left:${k * 2 * w}px;bottom:0;width:${w}px;height:${Math.round(z.h * (0.3 + 0.14 * k))}px;background:${k === 4 ? pal.signal : pal.line}"></div>`;
|
|
75
|
+
return `<div id="dg1" style="position:absolute;left:${z.x}px;top:${z.y}px;width:${z.w}px;height:${z.h}px;opacity:0">${bars}</div>`;
|
|
76
|
+
}
|
|
77
|
+
if (i === 2) {
|
|
78
|
+
const y = cy, w = Math.round(z.w * 0.8), x0 = Math.round(cx - w / 2);
|
|
79
|
+
return `<div id="dg2" style="position:absolute;left:${z.x}px;top:${z.y}px;width:${z.w}px;height:${z.h}px;opacity:0"><div style="position:absolute;left:${x0}px;top:${y}px;width:${w}px;height:6px;background:${pal.line}"></div><div id="dg2dot" style="position:absolute;left:${x0}px;top:${y - 17}px;width:40px;height:40px;border-radius:50%;background:${pal.signal}"></div></div>`;
|
|
80
|
+
}
|
|
81
|
+
const n = 3, gap = 18, cell = Math.min(Math.round((z.w - gap * (n - 1)) / n), Math.round((z.h - gap * (n - 1)) / n));
|
|
82
|
+
let cells = '';
|
|
83
|
+
for (let ky = 0; ky < n; ky++) for (let kx = 0; kx < n; kx++) cells += `<div style="position:absolute;left:${kx * (cell + gap)}px;top:${ky * (cell + gap)}px;width:${cell}px;height:${cell}px;background:${kx === 2 && ky === 2 ? pal.signal : pal.surface};border:2px solid ${pal.line};box-sizing:border-box"></div>`;
|
|
84
|
+
const gw = n * cell + (n - 1) * gap;
|
|
85
|
+
return `<div id="dg3" style="position:absolute;left:${Math.round(cx - gw / 2)}px;top:${Math.round(cy - gw / 2)}px;width:${gw}px;height:${gw}px;opacity:0">${cells}</div>`;
|
|
86
|
+
});
|
|
87
|
+
const fns = treatment.beats.map((b, i) => ` // shot ${i + 1} (${b.layout}): ${b.hero.replace(/\*\//gu, '* /')}
|
|
88
|
+
(s, t) => {
|
|
89
|
+
for (let k = 0; k < ${treatment.beats.length}; k++) {
|
|
90
|
+
document.getElementById('dl' + k).style.opacity = k === ${i} ? '1' : '0';
|
|
91
|
+
document.getElementById('dg' + k).style.opacity = k === ${i} ? '1' : '0';
|
|
92
|
+
}${i === 2 ? "\n document.getElementById('dg2dot').style.left = (s.p * 100).toFixed(2) + '%';" : ''}
|
|
93
|
+
},`);
|
|
94
|
+
return { lines: treatment.beats.map((_, i) => line(i)).join('\n'), shapes: shapes.join('\n'), fns };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The demo page: the scaffold with its DRAW stubs replaced by the demo's drawings and copy lines. */
|
|
98
|
+
export function demoPage(treatment) {
|
|
99
|
+
const style = readStyle(treatment.style);
|
|
100
|
+
const { lines, shapes, fns } = demoDraw(treatment, style);
|
|
101
|
+
let n = 0;
|
|
102
|
+
return scaffoldHtml(treatment)
|
|
103
|
+
.replace('<body>\n', `<body>\n${lines}\n${shapes}\n`)
|
|
104
|
+
.replace(/ \/\/ shot \d+( \([a-z-]+\))?: [^\n]*\n \(s, t\) => \{\},/gu, () => fns[n++] ?? '');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Render the gallery: a board round per style, then one sheet of the boards. */
|
|
108
|
+
export async function stylesCommand({ out, format = '16:9', env = process.env, log = () => {} }) {
|
|
109
|
+
if (!['16:9', '9:16'].includes(format)) return { code: EXIT.USAGE, message: '--format is 16:9 or 9:16' };
|
|
110
|
+
mkdirSync(out, { recursive: true });
|
|
111
|
+
const boards = [];
|
|
112
|
+
const verdicts = [];
|
|
113
|
+
for (const id of STYLE_IDS) {
|
|
114
|
+
const dir = path.join(out, id);
|
|
115
|
+
rmSync(dir, { recursive: true, force: true });
|
|
116
|
+
mkdirSync(path.join(dir, 'stage'), { recursive: true });
|
|
117
|
+
const treatment = demoTreatment(id, format);
|
|
118
|
+
writeFileSync(path.join(dir, 'treatment.json'), `${JSON.stringify(treatment, null, 2)}\n`);
|
|
119
|
+
writeFileSync(path.join(dir, 'stage', 'index.html'), demoPage(treatment));
|
|
120
|
+
log(`styles: rendering the ${id} board`);
|
|
121
|
+
const r = await renderStage({ out: dir, treatment, round: 1, stillsOnly: true, env, log });
|
|
122
|
+
verdicts.push(`${id}: ${r.exitCode === EXIT.OK ? 'board check PASS' : r.message.split(';')[0]}`);
|
|
123
|
+
boards.push(readFileSync(path.join(dir, 'stills', 'board.png')));
|
|
124
|
+
}
|
|
125
|
+
const file = path.join(out, 'styles.png');
|
|
126
|
+
writeFileSync(file, composeBoards(boards));
|
|
127
|
+
const failed = verdicts.filter((v) => !/PASS$/u.test(v));
|
|
128
|
+
return { code: failed.length ? EXIT.GATE_FAIL_QA : EXIT.OK, message: `STYLES: ${file}\n${verdicts.join('\n')}` };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** One sheet of board stills, two columns, at the boards' own size. */
|
|
132
|
+
export function composeBoards(pngs) {
|
|
133
|
+
const decoded = pngs.map((buf) => decodePng(buf));
|
|
134
|
+
const w = decoded[0].width, h = decoded[0].height;
|
|
135
|
+
const cols = 2, rows = Math.ceil(decoded.length / cols);
|
|
136
|
+
const sheet = Buffer.alloc(cols * w * rows * h * 4, 0);
|
|
137
|
+
decoded.forEach((b, i) => {
|
|
138
|
+
const dx = (i % cols) * w, dy = Math.floor(i / cols) * h;
|
|
139
|
+
const src = b.channels === 4 ? b.pixels : toRgba(b.pixels, b.channels);
|
|
140
|
+
for (let y = 0; y < Math.min(h, b.height); y++) {
|
|
141
|
+
for (let x = 0; x < Math.min(w, b.width); x++) {
|
|
142
|
+
const from = (y * b.width + x) * 4, to = ((dy + y) * cols * w + dx + x) * 4;
|
|
143
|
+
sheet[to] = src[from]; sheet[to + 1] = src[from + 1]; sheet[to + 2] = src[from + 2]; sheet[to + 3] = src[from + 3];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
return encodePng(sheet, cols * w, rows * h);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function toRgba(pixels, channels) {
|
|
151
|
+
const n = pixels.length / channels;
|
|
152
|
+
const out = Buffer.alloc(n * 4);
|
|
153
|
+
for (let i = 0; i < n; i++) {
|
|
154
|
+
out[i * 4] = pixels[i * channels];
|
|
155
|
+
out[i * 4 + 1] = pixels[i * channels + (channels >= 3 ? 1 : 0)];
|
|
156
|
+
out[i * 4 + 2] = pixels[i * channels + (channels >= 3 ? 2 : 0)];
|
|
157
|
+
out[i * 4 + 3] = 255;
|
|
158
|
+
}
|
|
159
|
+
return out;
|
|
160
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// The house file: `motion-house.json` beside a film's output folder (the working directory).
|
|
2
|
+
// A passed full render writes it, or appends the film to it; while one exists, the treatment
|
|
3
|
+
// validator holds every new film in that folder to its style unless the request names another.
|
|
4
|
+
// Data the validator reads, so the second film starts from the first one's style unasked.
|
|
5
|
+
import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { STYLE_IDS } from "./styles.mjs";
|
|
8
|
+
|
|
9
|
+
export const HOUSE_FILE = "motion-house.json";
|
|
10
|
+
export const HOUSE_SCHEMA = "litgrok.motion-house/v1";
|
|
11
|
+
const MAX_FILMS = 50;
|
|
12
|
+
|
|
13
|
+
export const houseFileFor = (out) => path.join(path.dirname(path.resolve(out)), HOUSE_FILE);
|
|
14
|
+
|
|
15
|
+
/** The house record for an output folder, or null when missing or unusable. */
|
|
16
|
+
export function readHouse(out) {
|
|
17
|
+
const file = houseFileFor(out);
|
|
18
|
+
if (!existsSync(file)) return null;
|
|
19
|
+
try {
|
|
20
|
+
const house = JSON.parse(readFileSync(file, "utf8"));
|
|
21
|
+
if (house?.schema !== HOUSE_SCHEMA || !STYLE_IDS.includes(house.style)) return null;
|
|
22
|
+
return house;
|
|
23
|
+
} catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Record a passed film. The first film sets the house style; later films are appended. A film in
|
|
30
|
+
* a style the request named outright is appended without moving the house style.
|
|
31
|
+
*/
|
|
32
|
+
export function recordHouse(out, { style, path: renderPath, format, durationSec, now = new Date() }) {
|
|
33
|
+
const file = houseFileFor(out);
|
|
34
|
+
const house = readHouse(out) ?? { schema: HOUSE_SCHEMA, style, createdAt: now.toISOString(), films: [] };
|
|
35
|
+
const dir = path.basename(path.resolve(out));
|
|
36
|
+
const films = (Array.isArray(house.films) ? house.films : []).filter((f) => f?.dir !== dir);
|
|
37
|
+
films.push({ dir, style, path: renderPath, format, durationSec, at: now.toISOString() });
|
|
38
|
+
const next = { ...house, films: films.slice(-MAX_FILMS) };
|
|
39
|
+
const tmp = `${file}.tmp`;
|
|
40
|
+
writeFileSync(tmp, `${JSON.stringify(next, null, 2)}\n`);
|
|
41
|
+
renameSync(tmp, file);
|
|
42
|
+
return next;
|
|
43
|
+
}
|
|
@@ -170,6 +170,7 @@ export function doneState(out) {
|
|
|
170
170
|
let raw = null;
|
|
171
171
|
try { raw = readJson(treatmentFile); } catch { return notDone('treatment.json is not valid JSON'); }
|
|
172
172
|
if (raw?.mode === 'cover') return coverDoneState(out, raw);
|
|
173
|
+
if (raw?.preview === true) return previewDoneState(out, raw);
|
|
173
174
|
}
|
|
174
175
|
const render = completionState(out);
|
|
175
176
|
if (!render.done) return notDone(render.reason);
|
|
@@ -198,7 +199,7 @@ export function doneState(out) {
|
|
|
198
199
|
const indexNow = existsSync(join(out, 'stills', 'index.json')) ? sha(readFileSync(join(out, 'stills', 'index.json'))) : null;
|
|
199
200
|
if (indexNow !== manifest.stillsIndexSha256) return notDone('the stills on disk are not the final render\'s; render again', { downgraded });
|
|
200
201
|
const index = readJson(join(out, 'stills', 'index.json'));
|
|
201
|
-
const required = index.stills.filter((s) => ['poster', 'contact-sheet', 'beat-mid', 'transition'].includes(s.kind)).map((s) => s.file);
|
|
202
|
+
const required = index.stills.filter((s) => ['poster', 'contact-sheet', 'beat-mid', 'transition', 'board'].includes(s.kind)).map((s) => s.file);
|
|
202
203
|
const unviewed = required.filter((file) => !last.viewed.includes(file));
|
|
203
204
|
if (unviewed.length) return notDone(`the last look did not view ${unviewed.join(', ')}`, { downgraded });
|
|
204
205
|
const open = last.openItems ?? [];
|
|
@@ -212,6 +213,43 @@ export function lookSummary(out) {
|
|
|
212
213
|
return { rounds: look.rounds.length, viewed: viewed.size, blocked: look.rounds.some((r) => r.blocked) };
|
|
213
214
|
}
|
|
214
215
|
|
|
216
|
+
// A preview film (treatment preview: true) is done at its board: a stills-only render whose layout
|
|
217
|
+
// check passed, looked at, storyboard included. The full render waits for the user.
|
|
218
|
+
export function previewDoneState(out, raw) {
|
|
219
|
+
const labels = [`this is the storyboard preview (${join(out, 'stills', 'board.png')}); the film is not rendered yet, and the user can say go to render it`];
|
|
220
|
+
const notDone = (reason, extra = {}) => ({ status: 'NOT DONE', done: false, reason, downgraded: [], open: [], preview: true, labels, ...extra });
|
|
221
|
+
const valid = validateTreatment(raw);
|
|
222
|
+
if (!valid.ok) return notDone(`the treatment is invalid (${valid.field})`);
|
|
223
|
+
const indexFile = join(out, 'stills', 'index.json');
|
|
224
|
+
if (!existsSync(indexFile)) return notDone('no board yet: render with --stills-only');
|
|
225
|
+
const indexSha = sha(readFileSync(indexFile));
|
|
226
|
+
const index = readJson(indexFile);
|
|
227
|
+
if (!index.stills.some((s) => s.file === 'stills/board.png')) return notDone('the stills set has no storyboard (stills/board.png); render with --stills-only again');
|
|
228
|
+
try {
|
|
229
|
+
const check = readJson(join(out, 'stage', 'check.json'));
|
|
230
|
+
const failed = (check.rules ?? []).filter((x) => x.status === 'FAIL').map((x) => x.id);
|
|
231
|
+
if (failed.length) return notDone(`the board check failed (${failed.join(', ')}); fix the page and render the board again`);
|
|
232
|
+
} catch {
|
|
233
|
+
return notDone('the board check result is missing; render with --stills-only again');
|
|
234
|
+
}
|
|
235
|
+
let rounds;
|
|
236
|
+
try {
|
|
237
|
+
rounds = readLook(out).rounds;
|
|
238
|
+
} catch {
|
|
239
|
+
return notDone('look.json is unreadable', {});
|
|
240
|
+
}
|
|
241
|
+
const last = rounds.at(-1);
|
|
242
|
+
if (!last) return notDone('no look round on the board: open the storyboard and the stills with Read and record round 1');
|
|
243
|
+
if (last.stamp?.stillsIndexSha256 !== indexSha) return notDone('the look round was recorded before the latest board; look again and record it');
|
|
244
|
+
const required = index.stills.filter((s) => ['board', 'contact-sheet', 'beat-mid'].includes(s.kind)).map((s) => s.file);
|
|
245
|
+
const missing = required.filter((file) => !last.viewed?.includes(file));
|
|
246
|
+
if (missing.length) return notDone(`the look round did not view ${missing.slice(0, 4).join(', ')}`);
|
|
247
|
+
const open = last.openItems ?? [];
|
|
248
|
+
if (open.length && last.round < 3) return notDone(`the last look asks for another round (${open.join('; ')}); fix it and record round ${last.round + 1}`, { open });
|
|
249
|
+
if (last.blocked) return { status: 'DONE_UNVIEWED', done: true, reason: 'the board was looked at without a vision tool: say so in the reply', downgraded: [], open, preview: true, labels };
|
|
250
|
+
return { status: 'DONE', done: true, reason: 'the board passed its check and was looked at', downgraded: [], open, preview: true, labels };
|
|
251
|
+
}
|
|
252
|
+
|
|
215
253
|
// The cover done-check (references/cover.md, Rounds and done): a valid cover treatment unchanged
|
|
216
254
|
// since the last cover render; that render's report reading PASS+TARGET on the decoded file; at
|
|
217
255
|
// least two look rounds, the first naming its change; the last stamped with the final render's
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
// `motion.mjs scaffold --out <dir>`: the starting stage page, written from the treatment, so every
|
|
2
|
+
// film shares one architecture: the COPY block, one DRAW function per beat where the drawing goes,
|
|
3
|
+
// entrances on the house style's tokens. It never overwrites an existing page.
|
|
4
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { EXIT } from "./constants.mjs";
|
|
7
|
+
import { BlockedError } from "./constants.mjs";
|
|
8
|
+
import { readHouse } from "./house.mjs";
|
|
9
|
+
import { loadTreatment } from "./treatment.mjs";
|
|
10
|
+
|
|
11
|
+
const HANGUL = /[ㄱ-ㆎ가-힣]/u;
|
|
12
|
+
|
|
13
|
+
// A high-quality, cinematic or photoreal request earns the offline Cycles rung when Blender exists.
|
|
14
|
+
const PATH_TRACED = /(고퀄리티|고품질|시네마틱|실사|cinematic|photoreal|high-quality|\bblender\b)/iu;
|
|
15
|
+
export function asksPathTraced(request) { return PATH_TRACED.test(String(request ?? '')); }
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Where Blender is: an explicit LITGROK_BLENDER path (used only if it exists), the macOS app,
|
|
19
|
+
* then `blender` on PATH. `{ env, exists }` are injectable for tests.
|
|
20
|
+
*/
|
|
21
|
+
export function findBlender({ env = process.env, exists = existsSync } = {}) {
|
|
22
|
+
if (env.LITGROK_BLENDER) return exists(env.LITGROK_BLENDER) ? { path: env.LITGROK_BLENDER, source: 'LITGROK_BLENDER' } : null;
|
|
23
|
+
if (exists('/Applications/Blender.app/Contents/MacOS/Blender')) return { path: '/Applications/Blender.app/Contents/MacOS/Blender', source: 'macOS app' };
|
|
24
|
+
for (const dir of String(env.PATH ?? '').split(':')) {
|
|
25
|
+
if (dir && exists(path.join(dir, 'blender'))) return { path: path.join(dir, 'blender'), source: 'PATH' };
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Which copy lines each beat shows: the beat's own `lines` when given; otherwise spread in order
|
|
32
|
+
* over the beats, the first line on the first and the last line on the last.
|
|
33
|
+
*/
|
|
34
|
+
export function linesPerShot(treatment) {
|
|
35
|
+
const beats = treatment.beats;
|
|
36
|
+
if (beats.some((b) => Array.isArray(b.lines))) return beats.map((b) => (Array.isArray(b.lines) ? b.lines : []));
|
|
37
|
+
const lines = treatment.copy.lines.map((_, i) => i);
|
|
38
|
+
const textShots = beats.map((b, i) => (b.layout === "full" ? null : i)).filter((i) => i !== null);
|
|
39
|
+
const out = beats.map(() => []);
|
|
40
|
+
if (!textShots.length) return out;
|
|
41
|
+
lines.forEach((line, k) => {
|
|
42
|
+
const at = lines.length > 1 ? Math.round((k * (textShots.length - 1)) / (lines.length - 1)) : 0;
|
|
43
|
+
out[textShots[at]].push(line);
|
|
44
|
+
});
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The scaffold page for a stage treatment, in the renderer's page contract. */
|
|
49
|
+
export function scaffoldHtml(treatment) {
|
|
50
|
+
const format = treatment.format === "9:16" ? "9:16" : "16:9";
|
|
51
|
+
const [width, height] = format === "9:16" ? [1080, 1920] : [1920, 1080];
|
|
52
|
+
const perShot = linesPerShot(treatment);
|
|
53
|
+
const lang = treatment.copy.lines.some((l) => HANGUL.test(l)) ? "ko" : "en";
|
|
54
|
+
const draws = treatment.beats.map((b, i) => ` // shot ${i + 1}${b.layout ? ` (${b.layout})` : ""}: ${String(b.hero ?? b.onScreen ?? "").replace(/\*\//gu, "* /")}\n (s, t) => {},`).join("\n");
|
|
55
|
+
// A 3D film also gets the three.js world: an import map onto the vendored build, a full-frame
|
|
56
|
+
// canvas behind the shots, one protagonist group for the whole film, and one WORLD function per
|
|
57
|
+
// shot that poses it. Copy stays DOM text over the canvas so the QA can read it.
|
|
58
|
+
const solid = treatment.depth === "3d";
|
|
59
|
+
const worlds = treatment.beats.map((b, i) => ` // shot ${i + 1}${b.layout ? ` (${b.layout})` : ""}\n (s, hero, cam, t) => {},`).join("\n");
|
|
60
|
+
const head3d = solid ? `\n<script type="importmap">{ "imports": { "three": "/lit/three/three.module.js", "three/addons/": "/lit/three/addons/" } }</script>` : "";
|
|
61
|
+
const canvas3d = solid ? `<canvas id="world" width="${width}" height="${height}"></canvas>\n` : "";
|
|
62
|
+
const style3d = solid ? `\n #world { position: absolute; left: 0; top: 0; width: ${width}px; height: ${height}px; }` : "";
|
|
63
|
+
const world3d = solid ? `
|
|
64
|
+
// The world: one scene for the whole film, drawn on the GPU rung (software when it is missing).
|
|
65
|
+
// Build the protagonist once, in HERO, and only pose it per shot: that is what makes it the same
|
|
66
|
+
// object across the film. Tint the lights to the style; keep the type in DOM text, never in 3D.
|
|
67
|
+
// More parts of the vendored build: three/addons/geometries/RoundedBoxGeometry.js.
|
|
68
|
+
const renderer = new THREE.WebGLRenderer({ canvas: document.getElementById("world"), antialias: true, alpha: true, preserveDrawingBuffer: true });
|
|
69
|
+
renderer.setPixelRatio(1);
|
|
70
|
+
renderer.setSize(${width}, ${height}, false);
|
|
71
|
+
renderer.setClearColor(0x000000, 0);
|
|
72
|
+
renderer.outputColorSpace = THREE.SRGBColorSpace;
|
|
73
|
+
renderer.toneMapping = THREE.ACESFilmicToneMapping;
|
|
74
|
+
renderer.shadowMap.enabled = true;
|
|
75
|
+
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
|
76
|
+
const scene = new THREE.Scene();
|
|
77
|
+
scene.environment = new THREE.PMREMGenerator(renderer).fromScene(new RoomEnvironment(), 0.04).texture;
|
|
78
|
+
const cam = new THREE.PerspectiveCamera(32, ${width} / ${height}, 0.1, 100);
|
|
79
|
+
const key = new THREE.DirectionalLight(0xffffff, 2.2);
|
|
80
|
+
key.position.set(3, 6, 4);
|
|
81
|
+
key.castShadow = true;
|
|
82
|
+
key.shadow.mapSize.set(2048, 2048);
|
|
83
|
+
key.shadow.radius = 4;
|
|
84
|
+
key.shadow.bias = -0.0004;
|
|
85
|
+
key.shadow.normalBias = 0.03;
|
|
86
|
+
scene.add(key, new THREE.HemisphereLight(0xf4f1ea, 0x101418, 0.6));
|
|
87
|
+
const floor = new THREE.Mesh(new THREE.PlaneGeometry(40, 40), new THREE.ShadowMaterial({ opacity: 0.18 }));
|
|
88
|
+
floor.rotation.x = -Math.PI / 2;
|
|
89
|
+
floor.receiveShadow = true;
|
|
90
|
+
scene.add(floor);
|
|
91
|
+
const HERO = new THREE.Group();
|
|
92
|
+
scene.add(HERO);
|
|
93
|
+
|
|
94
|
+
const WORLD = [
|
|
95
|
+
${worlds}
|
|
96
|
+
];
|
|
97
|
+
|
|
98
|
+
function drawWorld(s, t) {
|
|
99
|
+
cam.position.set(0, 1.6, 7);
|
|
100
|
+
cam.lookAt(0, 0.6, 0);
|
|
101
|
+
WORLD[s.index](s, HERO, cam, t);
|
|
102
|
+
renderer.render(scene, cam);
|
|
103
|
+
}
|
|
104
|
+
` : "";
|
|
105
|
+
const scriptOpen = solid ? `<script type="module">
|
|
106
|
+
import * as THREE from "three";
|
|
107
|
+
import { RoomEnvironment } from "three/addons/environments/RoomEnvironment.js";
|
|
108
|
+
` : "<script>\n";
|
|
109
|
+
const script = `${scriptOpen} // The film's words: every copy line of treatment.json, verbatim. Edit them here.
|
|
110
|
+
const COPY = ${JSON.stringify(treatment.copy.lines, null, 2).replace(/\n/gu, "\n ")};
|
|
111
|
+
|
|
112
|
+
const { define, text } = LitStage;
|
|
113
|
+
|
|
114
|
+
// One function per shot: draw the subject as a function of the shot's progress.
|
|
115
|
+
// s carries the shot index, p (0..1 within the shot) and local seconds.
|
|
116
|
+
const SHOTS = ${JSON.stringify(treatment.beats.map((b) => [b.t0, b.t1]))};
|
|
117
|
+
function shotOf(t) {
|
|
118
|
+
let index = SHOTS.findIndex(([t0, t1]) => t >= t0 && t < t1);
|
|
119
|
+
if (index < 0) index = t < SHOTS[0][0] ? 0 : SHOTS.length - 1;
|
|
120
|
+
const [t0, t1] = SHOTS[index];
|
|
121
|
+
return { index, p: t1 > t0 ? Math.min(1, Math.max(0, (t - t0) / (t1 - t0))) : 0, t: Math.min(Math.max(0, t - t0), t1 - t0), duration: t1 - t0 };
|
|
122
|
+
}
|
|
123
|
+
const DRAW = [
|
|
124
|
+
${draws}
|
|
125
|
+
];
|
|
126
|
+
|
|
127
|
+
function paint(i, s, t) {
|
|
128
|
+
DRAW[i](s, t);
|
|
129
|
+
}
|
|
130
|
+
${world3d}
|
|
131
|
+
define({ width: ${width}, height: ${height}, fps: ${treatment.fps ?? 60}, duration: ${treatment.durationSec}, render(t) {
|
|
132
|
+
const s = shotOf(t);
|
|
133
|
+
paint(s.index, s, t);${solid ? "\n drawWorld(s, t);" : ""}
|
|
134
|
+
} });
|
|
135
|
+
</script>`;
|
|
136
|
+
return `<!doctype html>
|
|
137
|
+
<html lang="${lang}">
|
|
138
|
+
<head>
|
|
139
|
+
<meta charset="utf-8">
|
|
140
|
+
<link rel="stylesheet" href="/lit/fonts.css">
|
|
141
|
+
<link rel="stylesheet" href="/lit/style.css">
|
|
142
|
+
<script src="/lit/stage-kit.js"></script>
|
|
143
|
+
<script src="/lit/style.js"></script>${head3d}
|
|
144
|
+
<style>
|
|
145
|
+
html, body { width: ${width}px; height: ${height}px; }${style3d}
|
|
146
|
+
</style>
|
|
147
|
+
</head>
|
|
148
|
+
<body>
|
|
149
|
+
${canvas3d}${script}
|
|
150
|
+
</body>
|
|
151
|
+
</html>
|
|
152
|
+
`;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Write `<out>/stage/index.html` from the treatment; refuses to replace a page. */
|
|
156
|
+
export function scaffoldCommand({ out }) {
|
|
157
|
+
const treatment = loadTreatment(out, { house: readHouse(out) });
|
|
158
|
+
if (treatment.path !== "stage") throw new BlockedError(EXIT.TREATMENT_INVALID, `BLOCKED_TREATMENT_INVALID field=path: scaffold writes the stage page, but this treatment's path is ${treatment.path}; render it with make --out ${out}`);
|
|
159
|
+
const file = path.join(out, "stage", "index.html");
|
|
160
|
+
if (existsSync(file)) throw new BlockedError(EXIT.USAGE, `${file} exists; scaffold never overwrites a page (move it away to start again)`);
|
|
161
|
+
mkdirSync(path.dirname(file), { recursive: true });
|
|
162
|
+
writeFileSync(file, scaffoldHtml(treatment));
|
|
163
|
+
// The scaffold's word on the 3D renderer: a Blender film draws its world in stage/scene.py; a film that
|
|
164
|
+
// the request wants path-traced takes the Blender rung when Blender is installed, three.js otherwise.
|
|
165
|
+
let advice = "";
|
|
166
|
+
if (treatment.depth === "3d") {
|
|
167
|
+
if (treatment.render3d === "blender") advice = ` This is a Blender film: write the world in ${path.join(out, "stage", "scene.py")}, look at the preview stills (blender --out ${out}), render the plate (--final), and show it under the type with LitStage.plate() in place of the three.js world (references/depth.md, The Blender rung).`;
|
|
168
|
+
else {
|
|
169
|
+
const found = asksPathTraced(treatment.request) ? findBlender() : null;
|
|
170
|
+
if (found) advice = `\nBLENDER: ${found.path} is installed and the request asks for high-quality 3D. Take the Blender rung: set render3d "blender" in the treatment, write stage/scene.py, and keep this page for the type, labels and panels over the plate (references/depth.md, The Blender rung).`;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return { code: EXIT.OK, message: `SCAFFOLD: ${file} (style ${treatment.style ?? "default"}, ${treatment.beats.length} shots). Draw each shot's subject in its DRAW function, then render the board: stage --out ${out} --round 1 --stills-only${advice}` };
|
|
174
|
+
}
|