modern-canvas 0.7.2 → 0.7.4

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/index.cjs CHANGED
@@ -2405,25 +2405,6 @@ class WebGLBatch2DModule extends WebGLModule {
2405
2405
  _drawCallUid = 0;
2406
2406
  _defaultModulate = 4294967295;
2407
2407
  _defaultBackgroundColor = 0;
2408
- _defaultColorMatrixOffset = [0, 0, 0, 0];
2409
- _defaultColorMatrix = [
2410
- 1,
2411
- 0,
2412
- 0,
2413
- 0,
2414
- 0,
2415
- 1,
2416
- 0,
2417
- 0,
2418
- 0,
2419
- 0,
2420
- 1,
2421
- 0,
2422
- 0,
2423
- 0,
2424
- 0,
2425
- 1
2426
- ];
2427
2408
  _batchables = [];
2428
2409
  _vertexCount = 0;
2429
2410
  _indexCount = 0;
@@ -2441,14 +2422,10 @@ class WebGLBatch2DModule extends WebGLModule {
2441
2422
  // 1
2442
2423
  aBackgroundColor: { size: 4, normalized: true, type: "unsigned_byte" },
2443
2424
  // 1
2444
- aDisableWrapMode: { size: 4, normalized: true, type: "float" },
2445
- // 4 只是为了凑4的整数倍
2446
- aColorMatrixOffset: { size: 4, normalized: false, type: "float" },
2447
- // 4 TODO bug
2448
- aColorMatrix: { size: 4, normalized: false, type: "float" }
2449
- // 16 TODO bug
2425
+ aDisableWrapMode: { size: 4, normalized: true, type: "unsigned_byte" }
2426
+ // 1
2450
2427
  };
2451
- _vertexSize = 1 + 2 + 2 + 1 + 1 + 4 + 4 + 16;
2428
+ _vertexSize = 1 + 2 + 2 + 1 + 1 + 1;
2452
2429
  _getShader(maxTextureUnits) {
2453
2430
  let shader = this._shaders.get(maxTextureUnits);
2454
2431
  if (!shader) {
@@ -2465,8 +2442,6 @@ attribute vec2 aPosition;
2465
2442
  attribute vec2 aUv;
2466
2443
  attribute vec4 aModulate;
2467
2444
  attribute vec4 aBackgroundColor;
2468
- attribute mat4 aColorMatrix;
2469
- attribute vec4 aColorMatrixOffset;
2470
2445
  attribute vec4 aDisableWrapMode;
2471
2446
 
2472
2447
  uniform mat3 projectionMatrix;
@@ -2477,8 +2452,6 @@ varying float vTextureId;
2477
2452
  varying vec2 vUv;
2478
2453
  varying vec4 vModulate;
2479
2454
  varying vec4 vBackgroundColor;
2480
- varying mat4 vColorMatrix;
2481
- varying vec4 vColorMatrixOffset;
2482
2455
  varying vec4 vDisableWrapMode;
2483
2456
 
2484
2457
  void main(void) {
@@ -2493,8 +2466,6 @@ void main(void) {
2493
2466
  vUv = aUv;
2494
2467
  vModulate = aModulate * modulate;
2495
2468
  vBackgroundColor = aBackgroundColor;
2496
- vColorMatrix = aColorMatrix;
2497
- vColorMatrixOffset = aColorMatrixOffset;
2498
2469
  vDisableWrapMode = aDisableWrapMode;
2499
2470
  }`,
2500
2471
  frag: `precision highp float;
@@ -2502,8 +2473,6 @@ varying float vTextureId;
2502
2473
  varying vec2 vUv;
2503
2474
  varying vec4 vModulate;
2504
2475
  varying vec4 vBackgroundColor;
2505
- varying mat4 vColorMatrix;
2506
- varying vec4 vColorMatrixOffset;
2507
2476
  varying vec4 vDisableWrapMode;
2508
2477
 
2509
2478
  uniform sampler2D samplers[${maxTextureUnits}];
@@ -2536,8 +2505,6 @@ void main(void) {
2536
2505
  color += (1.0 - color.a) * vBackgroundColor;
2537
2506
  if (color.a > 0.0) {
2538
2507
  color *= vModulate;
2539
- color = vColorMatrix * color;
2540
- color += vColorMatrixOffset;
2541
2508
  }
2542
2509
  gl_FragColor = color;
2543
2510
  }`
@@ -2640,12 +2607,9 @@ void main(void) {
2640
2607
  texture: texture2,
2641
2608
  modulate = this._defaultModulate,
2642
2609
  backgroundColor = this._defaultBackgroundColor,
2643
- colorMatrix = this._defaultColorMatrix,
2644
- colorMatrixOffset = this._defaultColorMatrixOffset,
2645
2610
  blendMode = WebGLBlendMode.NORMAL,
2646
2611
  disableWrapMode = false
2647
2612
  } = batchables[i];
2648
- const textureLocation = (texture2 ? textureLocationMap.get(texture2) : -1) ?? -1;
2649
2613
  if (start < i && drawCall.blendMode !== blendMode) {
2650
2614
  drawCall.count = iIndex - drawCall.first;
2651
2615
  drawCalls.push(drawCall);
@@ -2655,24 +2619,17 @@ void main(void) {
2655
2619
  drawCall.first = iIndex;
2656
2620
  }
2657
2621
  const iIndexStart = aIndex / this._vertexSize;
2622
+ const textureLocation = (texture2 ? textureLocationMap.get(texture2) : 255) ?? 255;
2623
+ const disableWrapModeInt = disableWrapMode ? 1 : 0;
2658
2624
  for (let len2 = vertices.length, i2 = 0; i2 < len2; i2 += 2) {
2659
2625
  float32View[aIndex++] = textureLocation;
2660
2626
  float32View[aIndex++] = vertices[i2];
2661
2627
  float32View[aIndex++] = vertices[i2 + 1];
2662
- float32View[aIndex++] = uvs[i2] ?? 0;
2663
- float32View[aIndex++] = uvs[i2 + 1] ?? 0;
2628
+ float32View[aIndex++] = uvs[i2];
2629
+ float32View[aIndex++] = uvs[i2 + 1];
2664
2630
  uint32View[aIndex++] = modulate;
2665
2631
  uint32View[aIndex++] = backgroundColor;
2666
- float32View[aIndex++] = disableWrapMode ? 1 : 0;
2667
- float32View[aIndex++] = 0;
2668
- float32View[aIndex++] = 0;
2669
- float32View[aIndex++] = 0;
2670
- for (let i3 = 0; i3 < 4; i3++) {
2671
- float32View[aIndex++] = colorMatrixOffset[i3] ?? 0;
2672
- }
2673
- for (let i3 = 0; i3 < 16; i3++) {
2674
- float32View[aIndex++] = colorMatrix[i3] ?? 0;
2675
- }
2632
+ uint32View[aIndex++] = disableWrapModeInt;
2676
2633
  }
2677
2634
  for (let len2 = indices.length, i2 = 0; i2 < len2; i2++) {
2678
2635
  indexBuffer[iIndex++] = iIndexStart + indices[i2];
@@ -6165,20 +6122,20 @@ __decorateClass$S([
6165
6122
  modernIdoc.property({ fallback: modernIdoc.idGenerator() })
6166
6123
  ], exports.Node.prototype, "name", 2);
6167
6124
  __decorateClass$S([
6168
- modernIdoc.property({ fallback: "inherit" })
6125
+ modernIdoc.property({ default: () => ({}) })
6126
+ ], exports.Node.prototype, "meta", 2);
6127
+ __decorateClass$S([
6128
+ modernIdoc.property({ protected: true, fallback: "inherit" })
6169
6129
  ], exports.Node.prototype, "processMode", 2);
6170
6130
  __decorateClass$S([
6171
- modernIdoc.property({ fallback: "default" })
6131
+ modernIdoc.property({ protected: true, fallback: "default" })
6172
6132
  ], exports.Node.prototype, "processSortMode", 2);
6173
6133
  __decorateClass$S([
6174
- modernIdoc.property({ fallback: "inherit" })
6134
+ modernIdoc.property({ protected: true, fallback: "inherit" })
6175
6135
  ], exports.Node.prototype, "renderMode", 2);
6176
6136
  __decorateClass$S([
6177
- modernIdoc.property({ fallback: "default" })
6137
+ modernIdoc.property({ protected: true, fallback: "default" })
6178
6138
  ], exports.Node.prototype, "internalMode", 2);
6179
- __decorateClass$S([
6180
- modernIdoc.property({ default: () => ({}) })
6181
- ], exports.Node.prototype, "meta", 2);
6182
6139
  __decorateClass$S([
6183
6140
  modernIdoc.property({ protected: true })
6184
6141
  ], exports.Node.prototype, "mask", 2);
@@ -7061,7 +7018,7 @@ class SceneTree extends MainLoop {
7061
7018
  }
7062
7019
  }
7063
7020
  __decorateClass$L([
7064
- modernIdoc.property({ fallback: false })
7021
+ modernIdoc.property({ protected: true, fallback: false })
7065
7022
  ], SceneTree.prototype, "processPaused");
7066
7023
  __decorateClass$L([
7067
7024
  modernIdoc.property()
@@ -9990,12 +9947,11 @@ exports.BaseElement2D = class BaseElement2D extends exports.Node2D {
9990
9947
  _drawContent() {
9991
9948
  }
9992
9949
  _repaint(batchables) {
9993
- const colorMatrix = parseCSSFilter(this.style.filter);
9994
9950
  return super._repaint(batchables).map((batchable) => {
9995
9951
  return {
9996
- ...batchable,
9997
- colorMatrix: colorMatrix.toMatrix4().toArray(true),
9998
- colorMatrixOffset: colorMatrix.toVector4().toArray()
9952
+ ...batchable
9953
+ // colorMatrix: colorMatrix.toMatrix4().toArray(true),
9954
+ // colorMatrixOffset: colorMatrix.toVector4().toArray(),
9999
9955
  };
10000
9956
  });
10001
9957
  }
package/dist/index.d.cts CHANGED
@@ -922,8 +922,6 @@ interface Batchable2D {
922
922
  texture?: WebGLTexture;
923
923
  backgroundColor?: number;
924
924
  modulate?: number;
925
- colorMatrix?: ArrayLike<number>;
926
- colorMatrixOffset?: ArrayLike<number>;
927
925
  blendMode?: WebGLBlendMode;
928
926
  disableWrapMode?: boolean;
929
927
  }
@@ -938,8 +936,6 @@ declare class WebGLBatch2DModule extends WebGLModule {
938
936
  protected _drawCallUid: number;
939
937
  protected _defaultModulate: number;
940
938
  protected _defaultBackgroundColor: number;
941
- protected _defaultColorMatrixOffset: number[];
942
- protected _defaultColorMatrix: number[];
943
939
  protected _batchables: Batchable2D[];
944
940
  protected _vertexCount: number;
945
941
  protected _indexCount: number;
@@ -1634,11 +1630,11 @@ declare class Node extends CoreObject {
1634
1630
  readonly is: string;
1635
1631
  id: string;
1636
1632
  name: string;
1633
+ meta: Record<string, any>;
1637
1634
  processMode: ProcessMode;
1638
1635
  processSortMode: ProcessSortMode;
1639
1636
  renderMode: RenderMode;
1640
1637
  internalMode: InternalMode;
1641
- meta: Record<string, any>;
1642
1638
  mask?: Maskable;
1643
1639
  protected _readyed: boolean;
1644
1640
  constructor(properties?: Partial<NodeProperties>, nodes?: Node[]);
package/dist/index.d.mts CHANGED
@@ -922,8 +922,6 @@ interface Batchable2D {
922
922
  texture?: WebGLTexture;
923
923
  backgroundColor?: number;
924
924
  modulate?: number;
925
- colorMatrix?: ArrayLike<number>;
926
- colorMatrixOffset?: ArrayLike<number>;
927
925
  blendMode?: WebGLBlendMode;
928
926
  disableWrapMode?: boolean;
929
927
  }
@@ -938,8 +936,6 @@ declare class WebGLBatch2DModule extends WebGLModule {
938
936
  protected _drawCallUid: number;
939
937
  protected _defaultModulate: number;
940
938
  protected _defaultBackgroundColor: number;
941
- protected _defaultColorMatrixOffset: number[];
942
- protected _defaultColorMatrix: number[];
943
939
  protected _batchables: Batchable2D[];
944
940
  protected _vertexCount: number;
945
941
  protected _indexCount: number;
@@ -1634,11 +1630,11 @@ declare class Node extends CoreObject {
1634
1630
  readonly is: string;
1635
1631
  id: string;
1636
1632
  name: string;
1633
+ meta: Record<string, any>;
1637
1634
  processMode: ProcessMode;
1638
1635
  processSortMode: ProcessSortMode;
1639
1636
  renderMode: RenderMode;
1640
1637
  internalMode: InternalMode;
1641
- meta: Record<string, any>;
1642
1638
  mask?: Maskable;
1643
1639
  protected _readyed: boolean;
1644
1640
  constructor(properties?: Partial<NodeProperties>, nodes?: Node[]);
package/dist/index.d.ts CHANGED
@@ -922,8 +922,6 @@ interface Batchable2D {
922
922
  texture?: WebGLTexture;
923
923
  backgroundColor?: number;
924
924
  modulate?: number;
925
- colorMatrix?: ArrayLike<number>;
926
- colorMatrixOffset?: ArrayLike<number>;
927
925
  blendMode?: WebGLBlendMode;
928
926
  disableWrapMode?: boolean;
929
927
  }
@@ -938,8 +936,6 @@ declare class WebGLBatch2DModule extends WebGLModule {
938
936
  protected _drawCallUid: number;
939
937
  protected _defaultModulate: number;
940
938
  protected _defaultBackgroundColor: number;
941
- protected _defaultColorMatrixOffset: number[];
942
- protected _defaultColorMatrix: number[];
943
939
  protected _batchables: Batchable2D[];
944
940
  protected _vertexCount: number;
945
941
  protected _indexCount: number;
@@ -1634,11 +1630,11 @@ declare class Node extends CoreObject {
1634
1630
  readonly is: string;
1635
1631
  id: string;
1636
1632
  name: string;
1633
+ meta: Record<string, any>;
1637
1634
  processMode: ProcessMode;
1638
1635
  processSortMode: ProcessSortMode;
1639
1636
  renderMode: RenderMode;
1640
1637
  internalMode: InternalMode;
1641
- meta: Record<string, any>;
1642
1638
  mask?: Maskable;
1643
1639
  protected _readyed: boolean;
1644
1640
  constructor(properties?: Partial<NodeProperties>, nodes?: Node[]);