@lightningjs/renderer 2.9.0-beta3 → 2.9.0-beta4
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/dist/src/core/CoreNode.d.ts +28 -6
- package/dist/src/core/CoreNode.js +99 -71
- package/dist/src/core/CoreNode.js.map +1 -1
- package/dist/src/core/CoreTextNode.d.ts +2 -2
- package/dist/src/core/CoreTextNode.js +7 -4
- package/dist/src/core/CoreTextNode.js.map +1 -1
- package/dist/src/core/Stage.js +1 -0
- package/dist/src/core/Stage.js.map +1 -1
- package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.js +2 -2
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.js +6 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.js.map +1 -1
- package/dist/src/core/textures/Texture.d.ts +1 -1
- package/dist/src/core/textures/Texture.js +13 -5
- package/dist/src/core/textures/Texture.js.map +1 -1
- package/dist/tsconfig.dist.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core/CoreNode.test.ts +146 -42
- package/src/core/CoreNode.ts +116 -85
- package/src/core/CoreTextNode.ts +9 -4
- package/src/core/Stage.ts +1 -0
- package/src/core/renderers/webgl/internal/RendererUtils.ts +155 -155
- package/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.ts +2 -2
- package/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.ts +7 -0
- package/src/core/textures/Texture.ts +22 -6
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
-
* following copyright and licenses apply:
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
-
* you may not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import type { WebGlContextWrapper } from '../../../lib/WebGlContextWrapper.js';
|
|
21
|
-
|
|
22
|
-
export interface CoreWebGlParameters {
|
|
23
|
-
MAX_RENDERBUFFER_SIZE: number;
|
|
24
|
-
MAX_TEXTURE_SIZE: number;
|
|
25
|
-
MAX_VIEWPORT_DIMS: Int32Array;
|
|
26
|
-
MAX_VERTEX_TEXTURE_IMAGE_UNITS: number;
|
|
27
|
-
MAX_TEXTURE_IMAGE_UNITS: number;
|
|
28
|
-
MAX_COMBINED_TEXTURE_IMAGE_UNITS: number;
|
|
29
|
-
MAX_VERTEX_ATTRIBS: number;
|
|
30
|
-
MAX_VARYING_VECTORS: number;
|
|
31
|
-
MAX_VERTEX_UNIFORM_VECTORS: number;
|
|
32
|
-
MAX_FRAGMENT_UNIFORM_VECTORS: number;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Get device specific webgl parameters
|
|
37
|
-
* @param glw
|
|
38
|
-
*/
|
|
39
|
-
export function getWebGlParameters(
|
|
40
|
-
glw: WebGlContextWrapper,
|
|
41
|
-
): CoreWebGlParameters {
|
|
42
|
-
const params: CoreWebGlParameters = {
|
|
43
|
-
MAX_RENDERBUFFER_SIZE: 0,
|
|
44
|
-
MAX_TEXTURE_SIZE: 0,
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
|
|
46
|
-
MAX_VIEWPORT_DIMS: 0 as any, // Code below will replace this with an Int32Array
|
|
47
|
-
MAX_VERTEX_TEXTURE_IMAGE_UNITS: 0,
|
|
48
|
-
MAX_TEXTURE_IMAGE_UNITS: 0,
|
|
49
|
-
MAX_COMBINED_TEXTURE_IMAGE_UNITS: 0,
|
|
50
|
-
MAX_VERTEX_ATTRIBS: 0,
|
|
51
|
-
MAX_VARYING_VECTORS: 0,
|
|
52
|
-
MAX_VERTEX_UNIFORM_VECTORS: 0,
|
|
53
|
-
MAX_FRAGMENT_UNIFORM_VECTORS: 0,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// Map over all parameters and get them
|
|
57
|
-
const keys = Object.keys(params) as Array<keyof CoreWebGlParameters>;
|
|
58
|
-
keys.forEach((key) => {
|
|
59
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
60
|
-
params[key] = glw.getParameter(glw[key]);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
return params;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface CoreWebGlExtensions {
|
|
67
|
-
ANGLE_instanced_arrays: ANGLE_instanced_arrays | null;
|
|
68
|
-
WEBGL_compressed_texture_s3tc: WEBGL_compressed_texture_s3tc | null;
|
|
69
|
-
WEBGL_compressed_texture_astc: WEBGL_compressed_texture_astc | null;
|
|
70
|
-
WEBGL_compressed_texture_etc: WEBGL_compressed_texture_etc | null;
|
|
71
|
-
WEBGL_compressed_texture_etc1: WEBGL_compressed_texture_etc1 | null;
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
|
-
WEBGL_compressed_texture_pvrtc: any | null;
|
|
74
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
|
-
WEBKIT_WEBGL_compressed_texture_pvrtc: any | null;
|
|
76
|
-
WEBGL_compressed_texture_s3tc_srgb: WEBGL_compressed_texture_s3tc_srgb | null;
|
|
77
|
-
OES_vertex_array_object: OES_vertex_array_object | null;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Get device webgl extensions
|
|
82
|
-
* @param glw
|
|
83
|
-
*/
|
|
84
|
-
export function getWebGlExtensions(
|
|
85
|
-
glw: WebGlContextWrapper,
|
|
86
|
-
): CoreWebGlExtensions {
|
|
87
|
-
const extensions: CoreWebGlExtensions = {
|
|
88
|
-
ANGLE_instanced_arrays: null,
|
|
89
|
-
WEBGL_compressed_texture_s3tc: null,
|
|
90
|
-
WEBGL_compressed_texture_astc: null,
|
|
91
|
-
WEBGL_compressed_texture_etc: null,
|
|
92
|
-
WEBGL_compressed_texture_etc1: null,
|
|
93
|
-
WEBGL_compressed_texture_pvrtc: null,
|
|
94
|
-
WEBKIT_WEBGL_compressed_texture_pvrtc: null,
|
|
95
|
-
WEBGL_compressed_texture_s3tc_srgb: null,
|
|
96
|
-
OES_vertex_array_object: null,
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// Map over all extensions and get them
|
|
100
|
-
const keys = Object.keys(extensions) as Array<keyof CoreWebGlExtensions>;
|
|
101
|
-
keys.forEach((key) => {
|
|
102
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
103
|
-
extensions[key] = glw.getExtension(key);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
return extensions;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Allocate big memory chunk that we
|
|
111
|
-
* can re-use to draw quads
|
|
112
|
-
*
|
|
113
|
-
* @param glw
|
|
114
|
-
* @param size
|
|
115
|
-
*/
|
|
116
|
-
export function createIndexBuffer(glw: WebGlContextWrapper, size: number) {
|
|
117
|
-
const maxQuads = ~~(size / 80);
|
|
118
|
-
const indices = new Uint16Array(maxQuads * 6);
|
|
119
|
-
|
|
120
|
-
for (let i = 0, j = 0; i < maxQuads; i += 6, j += 4) {
|
|
121
|
-
indices[i] = j;
|
|
122
|
-
indices[i + 1] = j + 1;
|
|
123
|
-
indices[i + 2] = j + 2;
|
|
124
|
-
indices[i + 3] = j + 2;
|
|
125
|
-
indices[i + 4] = j + 1;
|
|
126
|
-
indices[i + 5] = j + 3;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const buffer = glw.createBuffer();
|
|
130
|
-
glw.elementArrayBufferData(buffer, indices, glw.STATIC_DRAW);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Checks if an object is of type HTMLImageElement.
|
|
135
|
-
* This is used because we cant check for HTMLImageElement directly when the
|
|
136
|
-
* renderer is running in a seperate web worker context.
|
|
137
|
-
*
|
|
138
|
-
* @param obj
|
|
139
|
-
* @returns
|
|
140
|
-
*/
|
|
141
|
-
export function isHTMLImageElement(obj: unknown): obj is HTMLImageElement {
|
|
142
|
-
return (
|
|
143
|
-
obj !== null &&
|
|
144
|
-
((typeof obj === 'object' &&
|
|
145
|
-
obj.constructor &&
|
|
146
|
-
obj.constructor.name === 'HTMLImageElement') ||
|
|
147
|
-
(typeof HTMLImageElement !== 'undefined' &&
|
|
148
|
-
obj instanceof HTMLImageElement))
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export interface WebGlColor {
|
|
153
|
-
raw: number;
|
|
154
|
-
normalized: [number, number, number, number];
|
|
155
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
+
* following copyright and licenses apply:
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2023 Comcast Cable Communications Management, LLC.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { WebGlContextWrapper } from '../../../lib/WebGlContextWrapper.js';
|
|
21
|
+
|
|
22
|
+
export interface CoreWebGlParameters {
|
|
23
|
+
MAX_RENDERBUFFER_SIZE: number;
|
|
24
|
+
MAX_TEXTURE_SIZE: number;
|
|
25
|
+
MAX_VIEWPORT_DIMS: Int32Array;
|
|
26
|
+
MAX_VERTEX_TEXTURE_IMAGE_UNITS: number;
|
|
27
|
+
MAX_TEXTURE_IMAGE_UNITS: number;
|
|
28
|
+
MAX_COMBINED_TEXTURE_IMAGE_UNITS: number;
|
|
29
|
+
MAX_VERTEX_ATTRIBS: number;
|
|
30
|
+
MAX_VARYING_VECTORS: number;
|
|
31
|
+
MAX_VERTEX_UNIFORM_VECTORS: number;
|
|
32
|
+
MAX_FRAGMENT_UNIFORM_VECTORS: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get device specific webgl parameters
|
|
37
|
+
* @param glw
|
|
38
|
+
*/
|
|
39
|
+
export function getWebGlParameters(
|
|
40
|
+
glw: WebGlContextWrapper,
|
|
41
|
+
): CoreWebGlParameters {
|
|
42
|
+
const params: CoreWebGlParameters = {
|
|
43
|
+
MAX_RENDERBUFFER_SIZE: 0,
|
|
44
|
+
MAX_TEXTURE_SIZE: 0,
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
|
|
46
|
+
MAX_VIEWPORT_DIMS: 0 as any, // Code below will replace this with an Int32Array
|
|
47
|
+
MAX_VERTEX_TEXTURE_IMAGE_UNITS: 0,
|
|
48
|
+
MAX_TEXTURE_IMAGE_UNITS: 0,
|
|
49
|
+
MAX_COMBINED_TEXTURE_IMAGE_UNITS: 0,
|
|
50
|
+
MAX_VERTEX_ATTRIBS: 0,
|
|
51
|
+
MAX_VARYING_VECTORS: 0,
|
|
52
|
+
MAX_VERTEX_UNIFORM_VECTORS: 0,
|
|
53
|
+
MAX_FRAGMENT_UNIFORM_VECTORS: 0,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Map over all parameters and get them
|
|
57
|
+
const keys = Object.keys(params) as Array<keyof CoreWebGlParameters>;
|
|
58
|
+
keys.forEach((key) => {
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
60
|
+
params[key] = glw.getParameter(glw[key]);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return params;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface CoreWebGlExtensions {
|
|
67
|
+
ANGLE_instanced_arrays: ANGLE_instanced_arrays | null;
|
|
68
|
+
WEBGL_compressed_texture_s3tc: WEBGL_compressed_texture_s3tc | null;
|
|
69
|
+
WEBGL_compressed_texture_astc: WEBGL_compressed_texture_astc | null;
|
|
70
|
+
WEBGL_compressed_texture_etc: WEBGL_compressed_texture_etc | null;
|
|
71
|
+
WEBGL_compressed_texture_etc1: WEBGL_compressed_texture_etc1 | null;
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
|
+
WEBGL_compressed_texture_pvrtc: any | null;
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
|
+
WEBKIT_WEBGL_compressed_texture_pvrtc: any | null;
|
|
76
|
+
WEBGL_compressed_texture_s3tc_srgb: WEBGL_compressed_texture_s3tc_srgb | null;
|
|
77
|
+
OES_vertex_array_object: OES_vertex_array_object | null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Get device webgl extensions
|
|
82
|
+
* @param glw
|
|
83
|
+
*/
|
|
84
|
+
export function getWebGlExtensions(
|
|
85
|
+
glw: WebGlContextWrapper,
|
|
86
|
+
): CoreWebGlExtensions {
|
|
87
|
+
const extensions: CoreWebGlExtensions = {
|
|
88
|
+
ANGLE_instanced_arrays: null,
|
|
89
|
+
WEBGL_compressed_texture_s3tc: null,
|
|
90
|
+
WEBGL_compressed_texture_astc: null,
|
|
91
|
+
WEBGL_compressed_texture_etc: null,
|
|
92
|
+
WEBGL_compressed_texture_etc1: null,
|
|
93
|
+
WEBGL_compressed_texture_pvrtc: null,
|
|
94
|
+
WEBKIT_WEBGL_compressed_texture_pvrtc: null,
|
|
95
|
+
WEBGL_compressed_texture_s3tc_srgb: null,
|
|
96
|
+
OES_vertex_array_object: null,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// Map over all extensions and get them
|
|
100
|
+
const keys = Object.keys(extensions) as Array<keyof CoreWebGlExtensions>;
|
|
101
|
+
keys.forEach((key) => {
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
103
|
+
extensions[key] = glw.getExtension(key);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
return extensions;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Allocate big memory chunk that we
|
|
111
|
+
* can re-use to draw quads
|
|
112
|
+
*
|
|
113
|
+
* @param glw
|
|
114
|
+
* @param size
|
|
115
|
+
*/
|
|
116
|
+
export function createIndexBuffer(glw: WebGlContextWrapper, size: number) {
|
|
117
|
+
const maxQuads = ~~(size / 80);
|
|
118
|
+
const indices = new Uint16Array(maxQuads * 6);
|
|
119
|
+
|
|
120
|
+
for (let i = 0, j = 0; i < maxQuads; i += 6, j += 4) {
|
|
121
|
+
indices[i] = j;
|
|
122
|
+
indices[i + 1] = j + 1;
|
|
123
|
+
indices[i + 2] = j + 2;
|
|
124
|
+
indices[i + 3] = j + 2;
|
|
125
|
+
indices[i + 4] = j + 1;
|
|
126
|
+
indices[i + 5] = j + 3;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const buffer = glw.createBuffer();
|
|
130
|
+
glw.elementArrayBufferData(buffer, indices, glw.STATIC_DRAW);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Checks if an object is of type HTMLImageElement.
|
|
135
|
+
* This is used because we cant check for HTMLImageElement directly when the
|
|
136
|
+
* renderer is running in a seperate web worker context.
|
|
137
|
+
*
|
|
138
|
+
* @param obj
|
|
139
|
+
* @returns
|
|
140
|
+
*/
|
|
141
|
+
export function isHTMLImageElement(obj: unknown): obj is HTMLImageElement {
|
|
142
|
+
return (
|
|
143
|
+
obj !== null &&
|
|
144
|
+
((typeof obj === 'object' &&
|
|
145
|
+
obj.constructor &&
|
|
146
|
+
obj.constructor.name === 'HTMLImageElement') ||
|
|
147
|
+
(typeof HTMLImageElement !== 'undefined' &&
|
|
148
|
+
obj instanceof HTMLImageElement))
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface WebGlColor {
|
|
153
|
+
raw: number;
|
|
154
|
+
normalized: [number, number, number, number];
|
|
155
|
+
}
|
|
@@ -64,12 +64,12 @@ export class RadialGradientEffect extends ShaderEffect {
|
|
|
64
64
|
|
|
65
65
|
static override getEffectKey(props: RadialGradientEffectProps): string {
|
|
66
66
|
if ((props.colors as unknown as ShaderEffectValueMap).value as number[]) {
|
|
67
|
-
return `
|
|
67
|
+
return `radialGradient${
|
|
68
68
|
((props.colors as unknown as ShaderEffectValueMap).value as number[])
|
|
69
69
|
.length
|
|
70
70
|
}`;
|
|
71
71
|
}
|
|
72
|
-
return `
|
|
72
|
+
return `radialGradient${props.colors!.length}`;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
static override resolveDefaults(
|
|
@@ -89,6 +89,13 @@ export class SdfTrFontFace<
|
|
|
89
89
|
// Load the texture
|
|
90
90
|
stage.txManager.loadTexture(this.texture, true);
|
|
91
91
|
|
|
92
|
+
// FIXME This is a stop-gap solution to avoid Font Face textures to be cleaned up
|
|
93
|
+
// Ideally we do want to clean up the textures if they're not being used to save as much memory as possible
|
|
94
|
+
// However, we need to make sure that the font face is reloaded if the texture is cleaned up and needed again
|
|
95
|
+
// and make sure the SdfFontRenderer is properly guarded against textures being reloaded
|
|
96
|
+
// for now this will do the trick and the increase on memory is not that big
|
|
97
|
+
this.texture.preventCleanup = true;
|
|
98
|
+
|
|
92
99
|
this.texture.on('loaded', () => {
|
|
93
100
|
this.checkLoaded();
|
|
94
101
|
// Make sure we mark the stage for a re-render (in case the font's texture was freed and reloaded)
|
|
@@ -101,7 +101,12 @@ export interface TextureData {
|
|
|
101
101
|
premultiplyAlpha?: boolean | null;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
export type TextureState =
|
|
104
|
+
export type TextureState =
|
|
105
|
+
| 'initial'
|
|
106
|
+
| 'freed'
|
|
107
|
+
| 'loading'
|
|
108
|
+
| 'loaded'
|
|
109
|
+
| 'failed';
|
|
105
110
|
|
|
106
111
|
export enum TextureType {
|
|
107
112
|
'generic' = 0,
|
|
@@ -155,11 +160,11 @@ export abstract class Texture extends EventEmitter {
|
|
|
155
160
|
readonly error: Error | null = null;
|
|
156
161
|
|
|
157
162
|
// aggregate state
|
|
158
|
-
public state: TextureState = '
|
|
163
|
+
public state: TextureState = 'initial';
|
|
159
164
|
// texture source state
|
|
160
|
-
private sourceState: TextureState = '
|
|
165
|
+
private sourceState: TextureState = 'initial';
|
|
161
166
|
// texture (gpu) state
|
|
162
|
-
private coreCtxState: TextureState = '
|
|
167
|
+
private coreCtxState: TextureState = 'initial';
|
|
163
168
|
|
|
164
169
|
readonly renderableOwners = new Set<unknown>();
|
|
165
170
|
|
|
@@ -195,13 +200,23 @@ export abstract class Texture extends EventEmitter {
|
|
|
195
200
|
*/
|
|
196
201
|
setRenderableOwner(owner: unknown, renderable: boolean): void {
|
|
197
202
|
const oldSize = this.renderableOwners.size;
|
|
198
|
-
|
|
199
|
-
|
|
203
|
+
|
|
204
|
+
if (renderable === true) {
|
|
205
|
+
if (this.renderableOwners.has(owner) === false) {
|
|
206
|
+
// Add the owner to the set
|
|
207
|
+
this.renderableOwners.add(owner);
|
|
208
|
+
}
|
|
209
|
+
|
|
200
210
|
const newSize = this.renderableOwners.size;
|
|
201
211
|
if (newSize > oldSize && newSize === 1) {
|
|
202
212
|
(this.renderable as boolean) = true;
|
|
203
213
|
(this.lastRenderableChangeTime as number) = this.txManager.frameTime;
|
|
204
214
|
this.onChangeIsRenderable?.(true);
|
|
215
|
+
|
|
216
|
+
// Check if the texture needs to be added to the loading queue
|
|
217
|
+
if (this.state === 'freed' || this.state === 'initial') {
|
|
218
|
+
this.txManager.loadTexture(this);
|
|
219
|
+
}
|
|
205
220
|
}
|
|
206
221
|
} else {
|
|
207
222
|
this.renderableOwners.delete(owner);
|
|
@@ -249,6 +264,7 @@ export abstract class Texture extends EventEmitter {
|
|
|
249
264
|
this.ctxTexture?.free();
|
|
250
265
|
if (this.textureData !== null) {
|
|
251
266
|
this.textureData = null;
|
|
267
|
+
this.setSourceState('freed');
|
|
252
268
|
}
|
|
253
269
|
}
|
|
254
270
|
|