visualfries 0.1.103 → 0.1.105
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.
|
@@ -32,9 +32,23 @@ export class PixiDisplayObjectHook {
|
|
|
32
32
|
this.initMainSprite();
|
|
33
33
|
}
|
|
34
34
|
async #handleRefresh() {
|
|
35
|
-
|
|
36
|
-
this.#
|
|
37
|
-
|
|
35
|
+
// Check if texture has changed (e.g., video source change)
|
|
36
|
+
const currentTexture = this.#context.getResource('pixiTexture');
|
|
37
|
+
if (currentTexture && currentTexture !== this.#pixiTexture) {
|
|
38
|
+
// Texture changed - need to recreate sprite with new texture
|
|
39
|
+
await this.#handleDestroy();
|
|
40
|
+
this.#pixiTexture = currentTexture;
|
|
41
|
+
this.#initDisplayObject();
|
|
42
|
+
}
|
|
43
|
+
else if (this.#displayObject?.children?.length > 0) {
|
|
44
|
+
// Same texture - just update sprite properties (position, size, opacity, etc.)
|
|
45
|
+
const sprite = this.#displayObject.children[0];
|
|
46
|
+
if (sprite) {
|
|
47
|
+
setPlacementAndOpacity(sprite, this.#context.data.appearance);
|
|
48
|
+
this.state.markDirty();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// If no texture yet, #handleUpdate will handle initial creation
|
|
38
52
|
}
|
|
39
53
|
async #handleUpdate() {
|
|
40
54
|
const isActive = this.#context.isActive;
|
|
@@ -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
|
|
@@ -2,7 +2,10 @@ import * as PIXI from 'pixi.js-legacy';
|
|
|
2
2
|
import { VideoComponentShape } from '../..';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
export class PixiVideoTextureHook {
|
|
5
|
-
|
|
5
|
+
// Note: 'refresh' is NOT included - timeline position changes don't need texture recreation.
|
|
6
|
+
// The video element persists and the same texture can continue to be used.
|
|
7
|
+
// Only 'refresh:content' (source change) should recreate the texture.
|
|
8
|
+
types = ['update', 'destroy', 'refresh:content'];
|
|
6
9
|
priority = 1;
|
|
7
10
|
#context;
|
|
8
11
|
#videoTexture;
|
|
@@ -10,8 +13,7 @@ export class PixiVideoTextureHook {
|
|
|
10
13
|
#handlers = {
|
|
11
14
|
update: this.#handleUpdate.bind(this),
|
|
12
15
|
destroy: this.#handleDestroy.bind(this),
|
|
13
|
-
refresh: this.#
|
|
14
|
-
'refresh:config': this.#handleRefresh.bind(this)
|
|
16
|
+
'refresh:content': this.#handleRefreshContent.bind(this)
|
|
15
17
|
};
|
|
16
18
|
async #handleUpdate() {
|
|
17
19
|
if (this.#videoTexture) {
|
|
@@ -38,9 +40,10 @@ export class PixiVideoTextureHook {
|
|
|
38
40
|
this.#context.removeResource('pixiTexture');
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
|
-
async #
|
|
43
|
+
async #handleRefreshContent() {
|
|
44
|
+
// Only recreate texture when video source changes
|
|
42
45
|
await this.#handleDestroy();
|
|
43
|
-
//
|
|
46
|
+
// Texture will be recreated on next update when videoElement is available
|
|
44
47
|
}
|
|
45
48
|
async handle(type, context) {
|
|
46
49
|
this.#context = context;
|