visualfries 0.1.106 → 0.1.107
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.
|
@@ -2,7 +2,7 @@ import { MediaManager } from '../../managers/MediaManager.js';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { StateManager } from '../../managers/StateManager.svelte.js';
|
|
4
4
|
export class MediaHook {
|
|
5
|
-
types = ['setup', 'update', 'destroy'
|
|
5
|
+
types = ['setup', 'update', 'destroy'];
|
|
6
6
|
priority = 1;
|
|
7
7
|
#context;
|
|
8
8
|
#mediaElement;
|
|
@@ -53,6 +53,8 @@ export class PixiDisplayObjectHook {
|
|
|
53
53
|
async #handleUpdate() {
|
|
54
54
|
const isActive = this.#context.isActive;
|
|
55
55
|
if (this.#displayObject) {
|
|
56
|
+
// Always re-assert the resource in case the context was cleared or updated
|
|
57
|
+
this.#context.setResource('pixiRenderObject', this.#displayObject);
|
|
56
58
|
// Only mark dirty if visibility actually changed
|
|
57
59
|
if (this.#displayObject.visible !== isActive) {
|
|
58
60
|
this.#displayObject.visible = isActive;
|
|
@@ -172,6 +172,8 @@ export class PixiSplitScreenDisplayObjectHook {
|
|
|
172
172
|
this.#drawBlurredBackground();
|
|
173
173
|
}
|
|
174
174
|
if (this.#displayObject) {
|
|
175
|
+
// Always re-assert the resource in case the context was cleared or updated
|
|
176
|
+
this.#context.setResource('pixiRenderObject', this.#displayObject);
|
|
175
177
|
if (this.#displayObject.visible != isActive) {
|
|
176
178
|
this.#displayObject.visible = isActive;
|
|
177
179
|
}
|
|
@@ -9,6 +9,7 @@ export class PixiVideoTextureHook {
|
|
|
9
9
|
priority = 1;
|
|
10
10
|
#context;
|
|
11
11
|
#videoTexture;
|
|
12
|
+
#videoElement;
|
|
12
13
|
componentElement;
|
|
13
14
|
#handlers = {
|
|
14
15
|
update: this.#handleUpdate.bind(this),
|
|
@@ -16,27 +17,29 @@ export class PixiVideoTextureHook {
|
|
|
16
17
|
'refresh:content': this.#handleRefreshContent.bind(this)
|
|
17
18
|
};
|
|
18
19
|
async #handleUpdate() {
|
|
19
|
-
if (this.#videoTexture) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
20
|
const media = this.#context.getResource('videoElement');
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
// If element changed or texture is missing, recreate it
|
|
22
|
+
if (media && (media !== this.#videoElement || !this.#videoTexture)) {
|
|
23
|
+
await this.#handleDestroy();
|
|
24
|
+
const res = new PIXI.VideoResource(media, {
|
|
25
|
+
autoPlay: false,
|
|
26
|
+
updateFPS: 30
|
|
27
|
+
});
|
|
28
|
+
const baseTexture = new PIXI.BaseTexture(res);
|
|
29
|
+
this.#videoTexture = new PIXI.Texture(baseTexture);
|
|
30
|
+
this.#videoElement = media;
|
|
31
|
+
}
|
|
32
|
+
// Always re-assert the resource in case the context was cleared or updated
|
|
33
|
+
if (this.#videoTexture) {
|
|
34
|
+
this.#context.setResource('pixiTexture', this.#videoTexture);
|
|
26
35
|
}
|
|
27
|
-
const res = new PIXI.VideoResource(media, {
|
|
28
|
-
autoPlay: false,
|
|
29
|
-
updateFPS: 30
|
|
30
|
-
});
|
|
31
|
-
const baseTexture = new PIXI.BaseTexture(res);
|
|
32
|
-
this.#videoTexture = new PIXI.Texture(baseTexture);
|
|
33
|
-
this.#context.setResource('pixiTexture', this.#videoTexture);
|
|
34
36
|
}
|
|
35
37
|
async #handleDestroy() {
|
|
36
38
|
if (this.#videoTexture) {
|
|
37
39
|
// Destroy the texture and its base texture to free GPU memory
|
|
38
40
|
this.#videoTexture.destroy(true);
|
|
39
41
|
this.#videoTexture = undefined;
|
|
42
|
+
this.#videoElement = undefined;
|
|
40
43
|
this.#context.removeResource('pixiTexture');
|
|
41
44
|
}
|
|
42
45
|
}
|