Enhance image encoder to manage timeline clocks and local time updates
Updated the image encoder to track entities with timeline clocks, ensuring that local time is consistently updated for both the main stage and clock entities. This change improves synchronization during playback and enhances the overall functionality of the image encoding process.
This commit is contained in:
parent
c1a28375b1
commit
68117d5b04
@ -106,10 +106,21 @@ export async function createImageEncoder(sourceWorld: EngineWorld, config: Image
|
||||
// computed start is 0 unless it carries a Trim, whose start offsets it.
|
||||
const startFrame = c.Computed.start[rootEid] ?? 0;
|
||||
|
||||
// Entities in the clone that own a timeline clock
|
||||
const clockEids = clonedEids.filter(eid => hasComponent(world, eid, c.Playback));
|
||||
|
||||
const seek = (frame: number) => {
|
||||
const stageFrame = startFrame + frame;
|
||||
const stageSeconds = framesToSeconds(stageFrame, world.frameRate);
|
||||
c.Computed.localTime[stageEid] = stageFrame;
|
||||
c.Computed.localTimeInSeconds[stageEid] = framesToSeconds(stageFrame, world.frameRate);
|
||||
c.Computed.localTimeInSeconds[stageEid] = stageSeconds;
|
||||
|
||||
for (const eid of clockEids) {
|
||||
c.Computed.localTime[eid] = stageFrame;
|
||||
c.Computed.localTimeInSeconds[eid] = stageSeconds;
|
||||
c.Playback.playing[eid] = 1;
|
||||
}
|
||||
|
||||
world.timestamp.delta = 1000 / world.frameRate;
|
||||
world.timestamp.now += world.timestamp.delta;
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
An element whose children are **real HTML**: the browser lays them out at the element's box size and the result is drawn into the box via the [html-in-canvas](https://github.com/WICG/html-in-canvas) API. `dapi` always drives the Diffusion Studio Electron app, which ships with this API enabled, so `<html>` is always available — reach for it liberally. It is the recommended way to build motion graphics, overlays, and any UI-heavy content: styled cards, tables, code blocks, flex/grid layouts — anything painful to assemble from `<rect>` and `<text>`.
|
||||
|
||||
```tsx
|
||||
<html x={40} y={40} width={800} height={120} cornerRadius={24}>
|
||||
<html x={40} y={40} width={800} height={120} cornerRadius={24} end={32}>
|
||||
<div style="display:flex;align-items:center;gap:16px;height:100%;
|
||||
background:#111;color:#fff;font:500 40px Inter;padding:0 32px;">
|
||||
<span style="color:#7c9cff;">01</span> Introduction
|
||||
@ -21,14 +21,6 @@ An element whose children are **real HTML**: the browser lays them out at the el
|
||||
</rect>
|
||||
```
|
||||
|
||||
A [`<scene>`](./scene.md) is a filled visual element too, so an `<htmlPaint>` can sit directly on it: the paint fills the whole composition box and the scene becomes a **pure HTML scene**, laid out entirely with real HTML and CSS:
|
||||
|
||||
```tsx
|
||||
<scene key="dashboard" name="Dashboard" width={1920} height={1080}>
|
||||
<htmlPaint />
|
||||
</scene>
|
||||
```
|
||||
|
||||
|
||||
## Reactivity
|
||||
|
||||
@ -65,3 +57,4 @@ The compiled module is persisted with the document: on reload, export, and `dapi
|
||||
- Cross-origin subresources (e.g. remote images) are excluded from the painted output by the browser's read-back rules; use local assets.
|
||||
- `<audio>` and `<video>` tags are rejected: media doesn't play under a paint host. Use the [`<audio>`](./audio.md) and [`<video>`](./video.md) composition elements, which own playback and the timeline.
|
||||
- A DOM `<canvas>` is likewise unavailable: its pixels don't survive the html-in-canvas rasterization. Use [`<surface>`](./surface-paint.md) for hand-drawn graphics.
|
||||
- **`<html>` is sourceless, so with no `end` it defaults to a 16-second duration and disappears after 16 s** — a silent cutoff with no error. A ticker-driven motion-graphics `<html>` that must span the whole composition needs an explicit `end` (`<html start={0} end={TOTAL}>…`). See [timing.md](./timing.md#semantics).
|
||||
|
||||
@ -14,9 +14,10 @@ Timing splits the two independent questions a clip answers: **where it sits on t
|
||||
- `start` / `end` place the clip on the parent timeline. `sourceIn` / `sourceOut` select which part of the source plays. On-timeline duration always equals the played source length, so `end - start == sourceOut - sourceIn`.
|
||||
- **Trimming the source is not the same as moving the clip.** To drop part of the source you must move `sourceIn` / `sourceOut`; changing `start` alone only slides the clip along the timeline while the full source keeps playing. If the source is meant to stay aligned with something else in the scene (synced audio, a transcript, another track), advance `start` and `sourceIn` **together** — moving one without the other offsets the content instead of trimming it.
|
||||
- **`end` and `sourceOut` are two spellings of the same out edge** — the clip's end in timeline time (`end`) versus source time (`sourceOut`). Set one; the last one set wins.
|
||||
- Sourceless nodes (`<rect>`, `<group>`, `<text>`) have no footage to trim, so you place them with `start` / `end` alone.
|
||||
- Sourceless nodes (`<rect>`, `<group>`, `<text>`, `<html>`, `<surface>`) have no footage to trim, so you place them with `start` / `end` alone.
|
||||
- Instead of setting `start`, a media node can derive its placement from another node's audio with `syncTo` (see [audio-sync.md](./audio-sync.md)).
|
||||
- If timing is omitted, a media node fits its natural duration at `start` 0, and a group auto-fits its children. A [`<sequence>`](./sequences.md) does not position its children for you: give each an explicit `start` (the next clip's `start` is the previous clip's end).
|
||||
- **A sourceless _leaf_ node with no `end` defaults to a fixed 16-second duration**
|
||||
|
||||
> Examples:
|
||||
> - `<rect start={2} end={5} width={200} height={120} fill="red" />` — a rectangle on screen from timeline second 2 to 5.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user