@lightningjs/renderer 2.12.0 → 2.12.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.
@@ -49,7 +49,7 @@ import type { Dimensions } from '../../../common/CommonTypes.js';
49
49
  import { WebGlCoreShader } from './WebGlCoreShader.js';
50
50
  import { WebGlContextWrapper } from '../../lib/WebGlContextWrapper.js';
51
51
  import { RenderTexture } from '../../textures/RenderTexture.js';
52
- import type { CoreNode } from '../../CoreNode.js';
52
+ import { CoreNodeRenderState, type CoreNode } from '../../CoreNode.js';
53
53
  import { WebGlCoreCtxRenderTexture } from './WebGlCoreCtxRenderTexture.js';
54
54
  import type { BaseShaderController } from '../../../main-api/ShaderController.js';
55
55
 
@@ -544,25 +544,25 @@ export class WebGlCoreRenderer extends CoreRenderer {
544
544
  }
545
545
 
546
546
  // Switching clipping rect will require a new render operation
547
- if (!compareRect(this.curRenderOp.clippingRect, clippingRect)) {
547
+ if (compareRect(this.curRenderOp.clippingRect, clippingRect) === false) {
548
548
  return false;
549
549
  }
550
550
 
551
551
  // Force new render operation if rendering to texture
552
552
  // @todo: This needs to be improved, render operations could also be reused
553
553
  // for rendering to texture
554
- if (parentHasRenderTexture || rtt) {
554
+ if (parentHasRenderTexture !== undefined || rtt !== undefined) {
555
555
  return false;
556
556
  }
557
557
 
558
558
  // Check if the shader can batch the shader properties
559
559
  if (
560
560
  this.curRenderOp.shader !== this.defaultShader &&
561
- (!shaderProps ||
562
- !this.curRenderOp.shader.canBatchShaderProps(
561
+ (shaderProps === null ||
562
+ this.curRenderOp.shader.canBatchShaderProps(
563
563
  this.curRenderOp.shaderProps,
564
564
  shaderProps,
565
- ))
565
+ ) === false)
566
566
  ) {
567
567
  return false;
568
568
  }
@@ -591,20 +591,12 @@ export class WebGlCoreRenderer extends CoreRenderer {
591
591
 
592
592
  const arr = new Float32Array(quadBuffer, 0, this.curBufferIdx);
593
593
 
594
- const buffer = this.quadBufferCollection.getBuffer('a_position') ?? null;
594
+ const buffer = this.quadBufferCollection.getBuffer('a_position') || null;
595
595
  glw.arrayBufferData(buffer, arr, glw.STATIC_DRAW);
596
596
 
597
- const doLog = false; // idx++ % 100 === 0;
598
- if (doLog) {
599
- console.log('renderOps', this.renderOps.length);
600
- }
601
-
602
597
  for (let i = 0, length = this.renderOps.length; i < length; i++) {
603
- const renderOp = this.renderOps[i] as WebGlCoreRenderOp;
604
- if (doLog) {
605
- console.log('Quads per operation', renderOp.numQuads);
606
- }
607
- renderOp.draw();
598
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
599
+ this.renderOps[i]!.draw();
608
600
  }
609
601
  this.quadBufferUsage = this.curBufferIdx * arr.BYTES_PER_ELEMENT;
610
602
 
@@ -711,12 +703,21 @@ export class WebGlCoreRenderer extends CoreRenderer {
711
703
  const node = this.rttNodes[i];
712
704
 
713
705
  // Skip nodes that don't have RTT updates
714
- if (!node || !node.hasRTTupdates) {
706
+ if (node === undefined || node.hasRTTupdates === false) {
707
+ continue;
708
+ }
709
+
710
+ // Skip nodes that are not visible
711
+ if (
712
+ node.worldAlpha === 0 ||
713
+ (node.strictBounds === true &&
714
+ node.renderState === CoreNodeRenderState.OutOfBounds)
715
+ ) {
715
716
  continue;
716
717
  }
717
718
 
718
- if (!node.texture || !node.texture.ctxTexture) {
719
- console.warn('Texture not loaded for RTT node', node);
719
+ // Skip nodes that do not have a loaded texture
720
+ if (node.texture === null || node.texture.state !== 'loaded') {
720
721
  continue;
721
722
  }
722
723
 
@@ -741,7 +742,7 @@ export class WebGlCoreRenderer extends CoreRenderer {
741
742
  for (let i = 0; i < node.children.length; i++) {
742
743
  const child = node.children[i];
743
744
 
744
- if (!child) {
745
+ if (child === undefined) {
745
746
  continue;
746
747
  }
747
748