@omnimedia/omnitool 1.1.0-19 → 1.1.0-21
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/package.json +1 -1
- package/s/timeline/parts/compositor/parts/schedulers.ts +8 -8
- package/s/timeline/parts/compositor/playback.ts +5 -5
- package/s/timeline/parts/item.ts +8 -1
- package/s/timeline/sugar/o.ts +23 -2
- package/x/demo/demo.bundle.min.js +18 -18
- package/x/demo/demo.bundle.min.js.map +3 -3
- package/x/index.html +2 -2
- package/x/timeline/parts/compositor/parts/schedulers.js +8 -8
- package/x/timeline/parts/compositor/parts/schedulers.js.map +1 -1
- package/x/timeline/parts/compositor/playback.js +5 -5
- package/x/timeline/parts/compositor/playback.js.map +1 -1
- package/x/timeline/parts/item.d.ts +8 -2
- package/x/timeline/parts/item.js +1 -0
- package/x/timeline/parts/item.js.map +1 -1
- package/x/timeline/sugar/o.d.ts +3 -0
- package/x/timeline/sugar/o.js +20 -2
- package/x/timeline/sugar/o.js.map +1 -1
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@ export const realtime = (
|
|
|
17
17
|
let fps = 60
|
|
18
18
|
|
|
19
19
|
let frameDuration = 1000 / fps
|
|
20
|
-
let
|
|
20
|
+
let composeTime = 0
|
|
21
21
|
let lastTime = 0
|
|
22
22
|
let accumulator = 0
|
|
23
23
|
let currentTime = 0
|
|
@@ -29,12 +29,12 @@ export const realtime = (
|
|
|
29
29
|
lastTime = now
|
|
30
30
|
|
|
31
31
|
accumulator += deltaTime
|
|
32
|
-
currentTime += deltaTime
|
|
32
|
+
currentTime += deltaTime
|
|
33
33
|
onUpdate(currentTime)
|
|
34
34
|
|
|
35
35
|
while (accumulator >= frameDuration) {
|
|
36
|
-
onTick(
|
|
37
|
-
|
|
36
|
+
onTick(composeTime)
|
|
37
|
+
composeTime += frameDuration
|
|
38
38
|
accumulator -= frameDuration
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -54,11 +54,11 @@ export const realtime = (
|
|
|
54
54
|
if (rafId !== null) cancelAnimationFrame(rafId)
|
|
55
55
|
rafId = null
|
|
56
56
|
},
|
|
57
|
-
seek(
|
|
58
|
-
|
|
57
|
+
seek(ms) {
|
|
58
|
+
composeTime = ms
|
|
59
59
|
accumulator = 0
|
|
60
|
-
currentTime =
|
|
61
|
-
onUpdate(
|
|
60
|
+
currentTime = ms
|
|
61
|
+
onUpdate(ms)
|
|
62
62
|
},
|
|
63
63
|
dispose() {
|
|
64
64
|
this.pause()
|
|
@@ -13,7 +13,7 @@ type ResolveMedia = (hash: string) => DecoderSource
|
|
|
13
13
|
export class VideoPlayer {
|
|
14
14
|
readonly currentTime = signal(0)
|
|
15
15
|
#controller = realtime(
|
|
16
|
-
|
|
16
|
+
compositeTime => this.#tick(compositeTime),
|
|
17
17
|
currentTime => this.currentTime(currentTime)
|
|
18
18
|
)
|
|
19
19
|
|
|
@@ -42,15 +42,15 @@ export class VideoPlayer {
|
|
|
42
42
|
return new this(driver, canvas, root, sampler)
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
async #tick(
|
|
46
|
-
const
|
|
47
|
-
const tt =
|
|
45
|
+
async #tick(ms: number) {
|
|
46
|
+
const duration = this.root.duration
|
|
47
|
+
const tt = ms > duration ? duration : ms
|
|
48
48
|
this.root.audio?.onTimeUpdate(tt)
|
|
49
49
|
const layers = await this.root.visuals?.sampleAt(tt) ?? []
|
|
50
50
|
const frame = await this.driver.composite(layers)
|
|
51
51
|
this.context.drawImage(frame, 0, 0)
|
|
52
52
|
frame.close()
|
|
53
|
-
if (
|
|
53
|
+
if (ms >= duration) this.pause()
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
async play() {
|
package/s/timeline/parts/item.ts
CHANGED
|
@@ -12,6 +12,7 @@ export enum Kind {
|
|
|
12
12
|
Gap,
|
|
13
13
|
Spatial,
|
|
14
14
|
Transition,
|
|
15
|
+
TextStyle
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export enum Effect {
|
|
@@ -19,6 +20,12 @@ export enum Effect {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export namespace Item {
|
|
23
|
+
export type TextStyle = {
|
|
24
|
+
id: Id
|
|
25
|
+
kind: Kind.TextStyle
|
|
26
|
+
style: TextStyleOptions
|
|
27
|
+
}
|
|
28
|
+
|
|
22
29
|
export type Spatial = {
|
|
23
30
|
id: Id
|
|
24
31
|
kind: Kind.Spatial
|
|
@@ -68,7 +75,7 @@ export namespace Item {
|
|
|
68
75
|
content: string
|
|
69
76
|
duration: number
|
|
70
77
|
spatialId?: Id
|
|
71
|
-
|
|
78
|
+
styleId?: Id
|
|
72
79
|
}
|
|
73
80
|
|
|
74
81
|
export type Transition = {
|
package/s/timeline/sugar/o.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {TextStyleOptions} from "pixi.js"
|
|
1
2
|
|
|
2
3
|
import {Media} from "../parts/media.js"
|
|
3
4
|
import {Id, TimelineFile} from "../parts/basics.js"
|
|
@@ -22,6 +23,12 @@ export class O {
|
|
|
22
23
|
this.state.project = fn(this.state.project)
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
textStyle = (style: TextStyleOptions): Item.TextStyle => ({
|
|
27
|
+
id: this.#getId(),
|
|
28
|
+
kind: Kind.TextStyle,
|
|
29
|
+
style
|
|
30
|
+
})
|
|
31
|
+
|
|
25
32
|
spatial = (transform: Transform): Item.Spatial => {
|
|
26
33
|
const item: Item.Spatial = {
|
|
27
34
|
id: this.#getId(),
|
|
@@ -107,8 +114,7 @@ export class O {
|
|
|
107
114
|
id: this.#getId(),
|
|
108
115
|
content,
|
|
109
116
|
kind: Kind.Text,
|
|
110
|
-
duration: 2000
|
|
111
|
-
style: {}
|
|
117
|
+
duration: 2000
|
|
112
118
|
})
|
|
113
119
|
|
|
114
120
|
gap = (duration: number): Item.Gap => ({
|
|
@@ -147,5 +153,20 @@ export class O {
|
|
|
147
153
|
return state
|
|
148
154
|
})
|
|
149
155
|
}
|
|
156
|
+
|
|
157
|
+
update = <K extends keyof Item.Any>(itemId: Id, key: K, value: Item.Any[K]) => {
|
|
158
|
+
this.#mutate(project => {
|
|
159
|
+
const newItems = project.items.map(item => {
|
|
160
|
+
if (item.id === itemId) {
|
|
161
|
+
return {
|
|
162
|
+
...item,
|
|
163
|
+
[key]: value,
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return item
|
|
167
|
+
})
|
|
168
|
+
return {...project, items: newItems}
|
|
169
|
+
})
|
|
170
|
+
}
|
|
150
171
|
}
|
|
151
172
|
|