visualfries 0.1.104 → 0.1.106
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.
|
@@ -24,6 +24,7 @@ export class AnimationHook {
|
|
|
24
24
|
#currentId = undefined;
|
|
25
25
|
#componentTimeline = undefined;
|
|
26
26
|
#animationsBuilt = false;
|
|
27
|
+
#lastAnimationDataHash = undefined; // Track animationData changes
|
|
27
28
|
timeline;
|
|
28
29
|
splitTextCache;
|
|
29
30
|
types = Object.keys(this.#handlers);
|
|
@@ -142,6 +143,18 @@ export class AnimationHook {
|
|
|
142
143
|
if (this.#context.isActive && this.#currentId !== this.#context.contextData.id) {
|
|
143
144
|
await this.#handleRefresh();
|
|
144
145
|
}
|
|
146
|
+
// Check if animationData has changed (e.g., SubtitlesHook just set wordStartTimes)
|
|
147
|
+
// This fixes the issue where animations are built before animationData is available
|
|
148
|
+
if (this.#context.isActive && this.#animationsBuilt) {
|
|
149
|
+
const animationData = this.#context.resources.get('animationData');
|
|
150
|
+
const currentHash = animationData?.wordStartTimes?.length?.toString() ?? '';
|
|
151
|
+
if (currentHash !== this.#lastAnimationDataHash && currentHash !== '') {
|
|
152
|
+
// animationData changed (became available) - need to rebuild animations
|
|
153
|
+
this.#lastAnimationDataHash = currentHash;
|
|
154
|
+
await this.#handleRefresh();
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
145
158
|
// Setup if component becomes active and animations aren't set up
|
|
146
159
|
if (this.#context.isActive) {
|
|
147
160
|
// && !this.#controls
|
|
@@ -187,15 +187,28 @@ export class PixiSplitScreenDisplayObjectHook {
|
|
|
187
187
|
this.#context.setResource('pixiRenderObject', this.#displayObject);
|
|
188
188
|
}
|
|
189
189
|
async #handleRefresh() {
|
|
190
|
-
|
|
191
|
-
//
|
|
192
|
-
this.#pixiTexture
|
|
193
|
-
|
|
190
|
+
const currentTexture = this.#context.getResource('pixiTexture');
|
|
191
|
+
// Check if texture has changed (e.g., video source change)
|
|
192
|
+
if (currentTexture && currentTexture !== this.#pixiTexture) {
|
|
193
|
+
// Texture changed - need to recreate everything
|
|
194
|
+
await this.#handleDestroy();
|
|
195
|
+
this.#pixiTexture = currentTexture;
|
|
196
|
+
if (this.#displayObject) {
|
|
197
|
+
this.#displayObject.removeChildren();
|
|
198
|
+
this.#initDisplayObject();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
else if (this.#displayObject?.children?.length > 0) {
|
|
202
|
+
// Same texture - just update sprite properties (position, size, etc.)
|
|
203
|
+
// For split screen, we may need to rebuild if effects changed
|
|
204
|
+
// For now, trigger a full rebuild on refresh
|
|
194
205
|
this.#displayObject.removeChildren();
|
|
206
|
+
if (currentTexture) {
|
|
207
|
+
this.#pixiTexture = currentTexture;
|
|
208
|
+
this.#initDisplayObject();
|
|
209
|
+
}
|
|
195
210
|
}
|
|
196
|
-
//
|
|
197
|
-
// after resources are ready
|
|
198
|
-
await this.#handleUpdate();
|
|
211
|
+
// If no texture yet, #handleUpdate will handle initial creation
|
|
199
212
|
}
|
|
200
213
|
async #handleDestroy() {
|
|
201
214
|
// remove event listeners from video
|