@lightningjs/renderer 0.6.0 → 0.6.1
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/README.md +1 -1
- package/dist/src/core/CoreNode.d.ts +63 -15
- package/dist/src/core/CoreNode.js +238 -118
- package/dist/src/core/CoreNode.js.map +1 -1
- package/dist/src/core/CoreTextNode.d.ts +1 -0
- package/dist/src/core/CoreTextNode.js +13 -0
- package/dist/src/core/CoreTextNode.js.map +1 -1
- package/dist/src/core/Stage.d.ts +6 -2
- package/dist/src/core/Stage.js +24 -21
- package/dist/src/core/Stage.js.map +1 -1
- package/dist/src/core/animations/CoreAnimation.js +11 -2
- package/dist/src/core/animations/CoreAnimation.js.map +1 -1
- package/dist/src/core/lib/ContextSpy.d.ts +12 -0
- package/dist/src/core/lib/ContextSpy.js +38 -0
- package/dist/src/core/lib/ContextSpy.js.map +1 -0
- package/dist/src/core/lib/WebGlContext.d.ts +414 -0
- package/dist/src/core/lib/WebGlContext.js +640 -0
- package/dist/src/core/lib/WebGlContext.js.map +1 -0
- package/dist/src/core/lib/WebGlContextWrapper.d.ts +496 -0
- package/dist/src/core/lib/WebGlContextWrapper.js +779 -0
- package/dist/src/core/lib/WebGlContextWrapper.js.map +1 -0
- package/dist/src/core/platform.js +4 -0
- package/dist/src/core/platform.js.map +1 -1
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js +9 -8
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js.map +1 -1
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.js +4 -5
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.js.map +1 -1
- package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.js +15 -13
- package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.js.map +1 -1
- package/dist/tsconfig.dist.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/core/CoreNode.ts +293 -149
- package/src/core/CoreTextNode.ts +16 -0
- package/src/core/Stage.ts +28 -31
- package/src/core/animations/CoreAnimation.ts +11 -2
- package/src/core/platform.ts +5 -0
- package/src/core/renderers/webgl/WebGlCoreRenderer.ts +9 -40
- package/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.ts +4 -5
- package/src/core/text-rendering/renderers/CanvasTextRenderer.ts +19 -15
- package/src/core/scene/Scene.ts +0 -120
package/src/core/CoreTextNode.ts
CHANGED
|
@@ -102,6 +102,9 @@ export class CoreTextNode extends CoreNode implements ICoreTextNode {
|
|
|
102
102
|
}
|
|
103
103
|
this.updateLocalTransform();
|
|
104
104
|
|
|
105
|
+
// Incase the RAF loop has been stopped already before text was loaded,
|
|
106
|
+
// we request a render so it can be drawn.
|
|
107
|
+
this.stage.requestRender();
|
|
105
108
|
this.emit('loaded', {
|
|
106
109
|
type: 'text',
|
|
107
110
|
dimensions: {
|
|
@@ -148,6 +151,7 @@ export class CoreTextNode extends CoreNode implements ICoreTextNode {
|
|
|
148
151
|
|
|
149
152
|
set text(value: string) {
|
|
150
153
|
this.textRenderer.set.text(this.trState, value);
|
|
154
|
+
this.checkIsRenderable();
|
|
151
155
|
}
|
|
152
156
|
|
|
153
157
|
get textRendererOverride(): CoreTextNodeProps['textRendererOverride'] {
|
|
@@ -269,6 +273,18 @@ export class CoreTextNode extends CoreNode implements ICoreTextNode {
|
|
|
269
273
|
this.textRenderer.set.y(this.trState, this.globalTransform.ty);
|
|
270
274
|
}
|
|
271
275
|
|
|
276
|
+
override checkIsRenderable(): boolean {
|
|
277
|
+
if (super.checkIsRenderable()) {
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (this.trState.props.text !== '') {
|
|
282
|
+
return (this.isRenderable = true);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return (this.isRenderable = false);
|
|
286
|
+
}
|
|
287
|
+
|
|
272
288
|
override renderQuads(renderer: CoreRenderer) {
|
|
273
289
|
assertTruthy(this.globalTransform);
|
|
274
290
|
this.textRenderer.renderQuads(
|
package/src/core/Stage.ts
CHANGED
|
@@ -16,11 +16,7 @@
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
import { Scene } from './scene/Scene.js';
|
|
21
|
-
|
|
22
19
|
import { startLoop, getTimeStamp } from './platform.js';
|
|
23
|
-
|
|
24
20
|
import { WebGlCoreRenderer } from './renderers/webgl/WebGlCoreRenderer.js';
|
|
25
21
|
import { assertTruthy } from '../utils.js';
|
|
26
22
|
import { AnimationManager } from './animations/AnimationManager.js';
|
|
@@ -62,7 +58,7 @@ export class Stage extends EventEmitter {
|
|
|
62
58
|
public readonly textRenderers: Partial<TextRendererMap>;
|
|
63
59
|
public readonly shManager: CoreShaderManager;
|
|
64
60
|
public readonly renderer: WebGlCoreRenderer;
|
|
65
|
-
|
|
61
|
+
public readonly root: CoreNode;
|
|
66
62
|
|
|
67
63
|
/// State
|
|
68
64
|
deltaTime = 0;
|
|
@@ -70,6 +66,7 @@ export class Stage extends EventEmitter {
|
|
|
70
66
|
currentFrameTime = 0;
|
|
71
67
|
private fpsNumFrames = 0;
|
|
72
68
|
private fpsElapsedTime = 0;
|
|
69
|
+
private renderRequested = false;
|
|
73
70
|
|
|
74
71
|
/**
|
|
75
72
|
* Stage constructor
|
|
@@ -146,7 +143,7 @@ export class Stage extends EventEmitter {
|
|
|
146
143
|
shaderProps: null,
|
|
147
144
|
});
|
|
148
145
|
|
|
149
|
-
this.
|
|
146
|
+
this.root = rootNode;
|
|
150
147
|
|
|
151
148
|
// execute platform start loop
|
|
152
149
|
if (autoStart) {
|
|
@@ -158,8 +155,8 @@ export class Stage extends EventEmitter {
|
|
|
158
155
|
* Update animations
|
|
159
156
|
*/
|
|
160
157
|
updateAnimations() {
|
|
161
|
-
const {
|
|
162
|
-
if (!
|
|
158
|
+
const { animationManager } = this;
|
|
159
|
+
if (!this.root) {
|
|
163
160
|
return;
|
|
164
161
|
}
|
|
165
162
|
this.lastFrameTime = this.currentFrameTime;
|
|
@@ -177,34 +174,32 @@ export class Stage extends EventEmitter {
|
|
|
177
174
|
* Check if the scene has updates
|
|
178
175
|
*/
|
|
179
176
|
hasSceneUpdates() {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (!scene?.root) {
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return scene?.root?.hasUpdates;
|
|
177
|
+
return !!this.root.updateType || this.renderRequested;
|
|
187
178
|
}
|
|
188
179
|
|
|
189
180
|
/**
|
|
190
181
|
* Start a new frame draw
|
|
191
182
|
*/
|
|
192
183
|
drawFrame() {
|
|
193
|
-
const { renderer,
|
|
194
|
-
if (!scene?.root) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
184
|
+
const { renderer, renderRequested } = this;
|
|
197
185
|
|
|
198
|
-
//
|
|
199
|
-
|
|
186
|
+
// Update tree if needed
|
|
187
|
+
if (this.root.updateType !== 0) {
|
|
188
|
+
this.root.update(this.deltaTime);
|
|
189
|
+
}
|
|
200
190
|
|
|
201
191
|
// test if we need to update the scene
|
|
202
192
|
renderer?.reset();
|
|
203
193
|
|
|
204
|
-
this.addQuads(
|
|
194
|
+
this.addQuads(this.root);
|
|
205
195
|
|
|
206
196
|
renderer?.render();
|
|
207
197
|
|
|
198
|
+
// Reset renderRequested flag if it was set
|
|
199
|
+
if (renderRequested) {
|
|
200
|
+
this.renderRequested = false;
|
|
201
|
+
}
|
|
202
|
+
|
|
208
203
|
// If there's an FPS update interval, emit the FPS update event
|
|
209
204
|
// when the specified interval has elapsed.
|
|
210
205
|
const { fpsUpdateInterval } = this.options;
|
|
@@ -225,7 +220,10 @@ export class Stage extends EventEmitter {
|
|
|
225
220
|
addQuads(node: CoreNode) {
|
|
226
221
|
assertTruthy(this.renderer && node.globalTransform);
|
|
227
222
|
|
|
228
|
-
node.
|
|
223
|
+
if (node.isRenderable) {
|
|
224
|
+
node.renderQuads(this.renderer);
|
|
225
|
+
}
|
|
226
|
+
|
|
229
227
|
for (let i = 0; i < node.children.length; i++) {
|
|
230
228
|
const child = node.children[i];
|
|
231
229
|
|
|
@@ -241,6 +239,13 @@ export class Stage extends EventEmitter {
|
|
|
241
239
|
}
|
|
242
240
|
}
|
|
243
241
|
|
|
242
|
+
/**
|
|
243
|
+
* Request a render pass without forcing an update
|
|
244
|
+
*/
|
|
245
|
+
requestRender() {
|
|
246
|
+
this.renderRequested = true;
|
|
247
|
+
}
|
|
248
|
+
|
|
244
249
|
/**
|
|
245
250
|
* Given a font name, and possible renderer override, return the best compatible text renderer.
|
|
246
251
|
*
|
|
@@ -305,12 +310,4 @@ export class Stage extends EventEmitter {
|
|
|
305
310
|
// the covariant state argument in the setter method map
|
|
306
311
|
return resolvedTextRenderer as unknown as TextRenderer;
|
|
307
312
|
}
|
|
308
|
-
|
|
309
|
-
//#region Properties
|
|
310
|
-
|
|
311
|
-
get root() {
|
|
312
|
-
return this.scene?.root || null;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
//#endregion Properties
|
|
316
313
|
}
|
|
@@ -98,7 +98,7 @@ export class CoreAnimation extends EventEmitter {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
update(dt: number) {
|
|
101
|
-
const { duration, loop, easing } = this.settings;
|
|
101
|
+
const { duration, loop, easing, stopMethod } = this.settings;
|
|
102
102
|
if (!duration) {
|
|
103
103
|
this.emit('finished', {});
|
|
104
104
|
return;
|
|
@@ -108,7 +108,13 @@ export class CoreAnimation extends EventEmitter {
|
|
|
108
108
|
|
|
109
109
|
if (this.progress > 1) {
|
|
110
110
|
this.progress = loop ? 0 : 1;
|
|
111
|
-
|
|
111
|
+
if (stopMethod) {
|
|
112
|
+
// If there's a stop method emit finished so the stop method can be applied.
|
|
113
|
+
// TODO: We should probably reevaluate how stopMethod is implemented as currently
|
|
114
|
+
// stop method 'reset' does not work when looping.
|
|
115
|
+
this.emit('finished', {});
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
112
118
|
}
|
|
113
119
|
|
|
114
120
|
for (let i = 0; i < this.propsList.length; i++) {
|
|
@@ -156,5 +162,8 @@ export class CoreAnimation extends EventEmitter {
|
|
|
156
162
|
this.node[propName] =
|
|
157
163
|
startValue + (endValue - startValue) * this.progress;
|
|
158
164
|
}
|
|
165
|
+
if (this.progress === 1) {
|
|
166
|
+
this.emit('finished', {});
|
|
167
|
+
}
|
|
159
168
|
}
|
|
160
169
|
}
|
package/src/core/platform.ts
CHANGED
|
@@ -26,6 +26,11 @@ export const startLoop = (stage: Stage) => {
|
|
|
26
26
|
const runLoop = () => {
|
|
27
27
|
stage.updateAnimations();
|
|
28
28
|
|
|
29
|
+
if (!stage.hasSceneUpdates()) {
|
|
30
|
+
setTimeout(runLoop, 16.666666666666668);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
29
34
|
stage.drawFrame();
|
|
30
35
|
requestAnimationFrame(runLoop);
|
|
31
36
|
};
|
|
@@ -179,6 +179,7 @@ export class WebGlCoreRenderer extends CoreRenderer {
|
|
|
179
179
|
this.curBufferIdx = 0;
|
|
180
180
|
this.curRenderOp = null;
|
|
181
181
|
this.renderOps.length = 0;
|
|
182
|
+
this.gl.disable(this.gl.SCISSOR_TEST);
|
|
182
183
|
this.gl.clear(this.gl.COLOR_BUFFER_BIT);
|
|
183
184
|
}
|
|
184
185
|
|
|
@@ -325,11 +326,7 @@ export class WebGlCoreRenderer extends CoreRenderer {
|
|
|
325
326
|
fQuadBuffer[bufferIdx++] = ty; // vertexY
|
|
326
327
|
fQuadBuffer[bufferIdx++] = texCoordX1; // texCoordX
|
|
327
328
|
fQuadBuffer[bufferIdx++] = texCoordY1; // texCoordY
|
|
328
|
-
uiQuadBuffer[bufferIdx++] =
|
|
329
|
-
colorTl,
|
|
330
|
-
alpha,
|
|
331
|
-
true,
|
|
332
|
-
); // color
|
|
329
|
+
uiQuadBuffer[bufferIdx++] = colorTl; // color
|
|
333
330
|
fQuadBuffer[bufferIdx++] = textureIdx; // texIndex
|
|
334
331
|
|
|
335
332
|
// Upper-Right
|
|
@@ -337,11 +334,7 @@ export class WebGlCoreRenderer extends CoreRenderer {
|
|
|
337
334
|
fQuadBuffer[bufferIdx++] = ty + width * tc;
|
|
338
335
|
fQuadBuffer[bufferIdx++] = texCoordX2;
|
|
339
336
|
fQuadBuffer[bufferIdx++] = texCoordY1;
|
|
340
|
-
uiQuadBuffer[bufferIdx++] =
|
|
341
|
-
colorTr,
|
|
342
|
-
alpha,
|
|
343
|
-
true,
|
|
344
|
-
);
|
|
337
|
+
uiQuadBuffer[bufferIdx++] = colorTr;
|
|
345
338
|
fQuadBuffer[bufferIdx++] = textureIdx;
|
|
346
339
|
|
|
347
340
|
// Lower-Left
|
|
@@ -349,11 +342,7 @@ export class WebGlCoreRenderer extends CoreRenderer {
|
|
|
349
342
|
fQuadBuffer[bufferIdx++] = ty + height * td;
|
|
350
343
|
fQuadBuffer[bufferIdx++] = texCoordX1;
|
|
351
344
|
fQuadBuffer[bufferIdx++] = texCoordY2;
|
|
352
|
-
uiQuadBuffer[bufferIdx++] =
|
|
353
|
-
colorBl,
|
|
354
|
-
alpha,
|
|
355
|
-
true,
|
|
356
|
-
);
|
|
345
|
+
uiQuadBuffer[bufferIdx++] = colorBl;
|
|
357
346
|
fQuadBuffer[bufferIdx++] = textureIdx;
|
|
358
347
|
|
|
359
348
|
// Lower-Right
|
|
@@ -361,11 +350,7 @@ export class WebGlCoreRenderer extends CoreRenderer {
|
|
|
361
350
|
fQuadBuffer[bufferIdx++] = ty + width * tc + height * td;
|
|
362
351
|
fQuadBuffer[bufferIdx++] = texCoordX2;
|
|
363
352
|
fQuadBuffer[bufferIdx++] = texCoordY2;
|
|
364
|
-
uiQuadBuffer[bufferIdx++] =
|
|
365
|
-
colorBr,
|
|
366
|
-
alpha,
|
|
367
|
-
true,
|
|
368
|
-
);
|
|
353
|
+
uiQuadBuffer[bufferIdx++] = colorBr;
|
|
369
354
|
fQuadBuffer[bufferIdx++] = textureIdx;
|
|
370
355
|
} else {
|
|
371
356
|
// Calculate the right corner of the quad
|
|
@@ -378,11 +363,7 @@ export class WebGlCoreRenderer extends CoreRenderer {
|
|
|
378
363
|
fQuadBuffer[bufferIdx++] = ty; // vertexY
|
|
379
364
|
fQuadBuffer[bufferIdx++] = texCoordX1; // texCoordX
|
|
380
365
|
fQuadBuffer[bufferIdx++] = texCoordY1; // texCoordY
|
|
381
|
-
uiQuadBuffer[bufferIdx++] =
|
|
382
|
-
colorTl,
|
|
383
|
-
alpha,
|
|
384
|
-
true,
|
|
385
|
-
); // color
|
|
366
|
+
uiQuadBuffer[bufferIdx++] = colorTl; // color
|
|
386
367
|
fQuadBuffer[bufferIdx++] = textureIdx; // texIndex
|
|
387
368
|
|
|
388
369
|
// Upper-Right
|
|
@@ -390,11 +371,7 @@ export class WebGlCoreRenderer extends CoreRenderer {
|
|
|
390
371
|
fQuadBuffer[bufferIdx++] = ty;
|
|
391
372
|
fQuadBuffer[bufferIdx++] = texCoordX2;
|
|
392
373
|
fQuadBuffer[bufferIdx++] = texCoordY1;
|
|
393
|
-
uiQuadBuffer[bufferIdx++] =
|
|
394
|
-
colorTr,
|
|
395
|
-
alpha,
|
|
396
|
-
true,
|
|
397
|
-
);
|
|
374
|
+
uiQuadBuffer[bufferIdx++] = colorTr;
|
|
398
375
|
fQuadBuffer[bufferIdx++] = textureIdx;
|
|
399
376
|
|
|
400
377
|
// Lower-Left
|
|
@@ -402,11 +379,7 @@ export class WebGlCoreRenderer extends CoreRenderer {
|
|
|
402
379
|
fQuadBuffer[bufferIdx++] = rightCornerY;
|
|
403
380
|
fQuadBuffer[bufferIdx++] = texCoordX1;
|
|
404
381
|
fQuadBuffer[bufferIdx++] = texCoordY2;
|
|
405
|
-
uiQuadBuffer[bufferIdx++] =
|
|
406
|
-
colorBl,
|
|
407
|
-
alpha,
|
|
408
|
-
true,
|
|
409
|
-
);
|
|
382
|
+
uiQuadBuffer[bufferIdx++] = colorBl;
|
|
410
383
|
fQuadBuffer[bufferIdx++] = textureIdx;
|
|
411
384
|
|
|
412
385
|
// Lower-Right
|
|
@@ -414,11 +387,7 @@ export class WebGlCoreRenderer extends CoreRenderer {
|
|
|
414
387
|
fQuadBuffer[bufferIdx++] = rightCornerY;
|
|
415
388
|
fQuadBuffer[bufferIdx++] = texCoordX2;
|
|
416
389
|
fQuadBuffer[bufferIdx++] = texCoordY2;
|
|
417
|
-
uiQuadBuffer[bufferIdx++] =
|
|
418
|
-
colorBr,
|
|
419
|
-
alpha,
|
|
420
|
-
true,
|
|
421
|
-
);
|
|
390
|
+
uiQuadBuffer[bufferIdx++] = colorBr;
|
|
422
391
|
fQuadBuffer[bufferIdx++] = textureIdx;
|
|
423
392
|
}
|
|
424
393
|
|
|
@@ -82,10 +82,9 @@ export class SdfTrFontFace<
|
|
|
82
82
|
},
|
|
83
83
|
);
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
// });
|
|
85
|
+
this.texture.on('loaded', () => {
|
|
86
|
+
this.checkLoaded();
|
|
87
|
+
});
|
|
89
88
|
|
|
90
89
|
// Set this.data to the fetched data from dataUrl
|
|
91
90
|
fetch(atlasDataUrl)
|
|
@@ -120,7 +119,7 @@ export class SdfTrFontFace<
|
|
|
120
119
|
|
|
121
120
|
private checkLoaded(): void {
|
|
122
121
|
if (this.loaded) return;
|
|
123
|
-
if (
|
|
122
|
+
if (this.texture.state === 'loaded' && this.data) {
|
|
124
123
|
(this.loaded as boolean) = true;
|
|
125
124
|
this.emit('loaded');
|
|
126
125
|
}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import { EventEmitter } from '../../../common/EventEmitter.js';
|
|
21
|
-
import { assertTruthy } from '../../../utils.js';
|
|
21
|
+
import { assertTruthy, mergeColorAlphaPremultiplied } from '../../../utils.js';
|
|
22
22
|
import type { Stage } from '../../Stage.js';
|
|
23
23
|
import type { Matrix3d } from '../../lib/Matrix3d.js';
|
|
24
24
|
import {
|
|
@@ -114,7 +114,11 @@ export class CanvasTextRenderer extends TextRenderer<CanvasTextRendererState> {
|
|
|
114
114
|
} else {
|
|
115
115
|
this.canvas = document.createElement('canvas');
|
|
116
116
|
}
|
|
117
|
-
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
118
|
+
let context = this.canvas.getContext('2d') as
|
|
119
|
+
| OffscreenCanvasRenderingContext2D
|
|
120
|
+
| CanvasRenderingContext2D
|
|
121
|
+
| null;
|
|
118
122
|
if (!context) {
|
|
119
123
|
// A browser may appear to support OffscreenCanvas but not actually support the Canvas '2d' context
|
|
120
124
|
// Here we try getting the context again after falling back to an HTMLCanvasElement.
|
|
@@ -543,15 +547,15 @@ export class CanvasTextRenderer extends TextRenderer<CanvasTextRendererState> {
|
|
|
543
547
|
// Color alpha of text is not properly rendered to the Canvas texture, so we
|
|
544
548
|
// need to apply it here.
|
|
545
549
|
const combinedAlpha = alpha * getNormalizedAlphaComponent(color);
|
|
546
|
-
|
|
550
|
+
const quadColor = mergeColorAlphaPremultiplied(0xffffffff, combinedAlpha);
|
|
547
551
|
if (canvasPages[0].valid) {
|
|
548
552
|
this.stage.renderer.addQuad({
|
|
549
553
|
alpha: combinedAlpha,
|
|
550
554
|
clippingRect,
|
|
551
|
-
colorBl:
|
|
552
|
-
colorBr:
|
|
553
|
-
colorTl:
|
|
554
|
-
colorTr:
|
|
555
|
+
colorBl: quadColor,
|
|
556
|
+
colorBr: quadColor,
|
|
557
|
+
colorTl: quadColor,
|
|
558
|
+
colorTr: quadColor,
|
|
555
559
|
width: canvasPages[0].texture?.dimensions?.width || 0,
|
|
556
560
|
height: canvasPages[0].texture?.dimensions?.height || 0,
|
|
557
561
|
texture: canvasPages[0].texture!,
|
|
@@ -571,10 +575,10 @@ export class CanvasTextRenderer extends TextRenderer<CanvasTextRendererState> {
|
|
|
571
575
|
this.stage.renderer.addQuad({
|
|
572
576
|
alpha: combinedAlpha,
|
|
573
577
|
clippingRect,
|
|
574
|
-
colorBl:
|
|
575
|
-
colorBr:
|
|
576
|
-
colorTl:
|
|
577
|
-
colorTr:
|
|
578
|
+
colorBl: quadColor,
|
|
579
|
+
colorBr: quadColor,
|
|
580
|
+
colorTl: quadColor,
|
|
581
|
+
colorTr: quadColor,
|
|
578
582
|
width: canvasPages[1].texture?.dimensions?.width || 0,
|
|
579
583
|
height: canvasPages[1].texture?.dimensions?.height || 0,
|
|
580
584
|
texture: canvasPages[1].texture!,
|
|
@@ -594,10 +598,10 @@ export class CanvasTextRenderer extends TextRenderer<CanvasTextRendererState> {
|
|
|
594
598
|
this.stage.renderer.addQuad({
|
|
595
599
|
alpha: combinedAlpha,
|
|
596
600
|
clippingRect,
|
|
597
|
-
colorBl:
|
|
598
|
-
colorBr:
|
|
599
|
-
colorTl:
|
|
600
|
-
colorTr:
|
|
601
|
+
colorBl: quadColor,
|
|
602
|
+
colorBr: quadColor,
|
|
603
|
+
colorTl: quadColor,
|
|
604
|
+
colorTr: quadColor,
|
|
601
605
|
width: canvasPages[2].texture?.dimensions?.width || 0,
|
|
602
606
|
height: canvasPages[2].texture?.dimensions?.height || 0,
|
|
603
607
|
texture: canvasPages[2].texture!,
|
package/src/core/scene/Scene.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
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 { CoreNode } from '../CoreNode.js';
|
|
21
|
-
|
|
22
|
-
export type NodeTypes = Node;
|
|
23
|
-
|
|
24
|
-
export class Scene {
|
|
25
|
-
/**
|
|
26
|
-
* Root node of the scene
|
|
27
|
-
*
|
|
28
|
-
* @type {Node}
|
|
29
|
-
* @memberof Scene
|
|
30
|
-
*/
|
|
31
|
-
public root: CoreNode;
|
|
32
|
-
|
|
33
|
-
constructor(root: CoreNode) {
|
|
34
|
-
this.root = root;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Get all nodes of a specific type
|
|
39
|
-
* @param type
|
|
40
|
-
* @returns
|
|
41
|
-
*/
|
|
42
|
-
public getNodeByType(type: string): Node[] {
|
|
43
|
-
return [];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Find a node by id
|
|
48
|
-
* @param id
|
|
49
|
-
* @returns
|
|
50
|
-
*/
|
|
51
|
-
public getNodeById(id: string): Node | null {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Create a new node
|
|
57
|
-
* @param parent
|
|
58
|
-
* @returns
|
|
59
|
-
*/
|
|
60
|
-
// public createNode(settings: Partial<INodeWritableProps> = {}): NodeTypes {
|
|
61
|
-
// return createNode(settings);
|
|
62
|
-
// }
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* create a new RectangleNode
|
|
66
|
-
* @param w
|
|
67
|
-
* @param h
|
|
68
|
-
* @param parent
|
|
69
|
-
* @returns
|
|
70
|
-
*/
|
|
71
|
-
// public rectangle(w: number, h: number, parent: NodeTypes | null = null) {
|
|
72
|
-
// // TODO: Fix this
|
|
73
|
-
// // return this.create(new RectangleNode(w, h), parent);
|
|
74
|
-
// }
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Create a new CircleNode
|
|
78
|
-
* @param r
|
|
79
|
-
* @param parent
|
|
80
|
-
* @returns
|
|
81
|
-
*/
|
|
82
|
-
// public circle(r: number, parent: NodeTypes | null = null) {
|
|
83
|
-
// // TODO: Fix this
|
|
84
|
-
// // return this.create(new CircleNode(r), parent);
|
|
85
|
-
// }
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Create a new TextNode
|
|
89
|
-
* @param text
|
|
90
|
-
* @param parent
|
|
91
|
-
* @returns
|
|
92
|
-
*/
|
|
93
|
-
// public text(text = '', parent: NodeTypes | null = null) {
|
|
94
|
-
// // TODO: Fix this
|
|
95
|
-
// // return this.create(new TextNode(text), parent);
|
|
96
|
-
// }
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Setup and attaching Node
|
|
100
|
-
* @param node
|
|
101
|
-
* @param parent
|
|
102
|
-
* @returns
|
|
103
|
-
*/
|
|
104
|
-
// private create(node: NodeTypes, parent: NodeTypes | null = null): NodeTypes {
|
|
105
|
-
// if (!parent) {
|
|
106
|
-
// parent = this.root;
|
|
107
|
-
// }
|
|
108
|
-
|
|
109
|
-
// node.parent = parent;
|
|
110
|
-
// return node;
|
|
111
|
-
// }
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Update the scene
|
|
115
|
-
* @param delta
|
|
116
|
-
*/
|
|
117
|
-
public update(delta: number) {
|
|
118
|
-
this.root.update(delta);
|
|
119
|
-
}
|
|
120
|
-
}
|