modern-canvas 0.7.3 → 0.7.5

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];
@@ -5604,9 +5561,9 @@ class CanvasContext extends modernPath2d.Path2D {
5604
5561
  }
5605
5562
  this.buildUvs(0, vertices, uvs, current.texture, current.uvTransform);
5606
5563
  batchables.push({
5607
- vertices,
5608
- indices,
5609
- uvs,
5564
+ vertices: new Float32Array(vertices),
5565
+ indices: new Float32Array(indices),
5566
+ uvs: new Float32Array(uvs),
5610
5567
  texture: current.texture,
5611
5568
  type: current.type,
5612
5569
  disableWrapMode: current.disableWrapMode,
@@ -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
@@ -916,14 +916,12 @@ declare class WebGLStateModule extends WebGLModule {
916
916
  }
917
917
 
918
918
  interface Batchable2D {
919
- vertices: number[];
920
- indices: number[];
921
- uvs?: number[];
919
+ vertices: Float32Array;
920
+ indices: Float32Array;
921
+ uvs?: Float32Array;
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;
@@ -1892,7 +1888,7 @@ declare class Node2D extends CanvasItem {
1892
1888
  getTransform(cb?: (transform: Transform2D) => void): Transform2D;
1893
1889
  updateTransform(): void;
1894
1890
  updateGlobalTransform(): void;
1895
- protected _transformVertices(vertices: number[], vertTransform?: VertTransform): number[];
1891
+ protected _transformVertices(vertices: Float32Array, vertTransform?: VertTransform): Float32Array;
1896
1892
  protected _relayout(batchables: CanvasBatchable[]): CanvasBatchable[];
1897
1893
  protected _process(delta: number): void;
1898
1894
  }
package/dist/index.d.mts CHANGED
@@ -916,14 +916,12 @@ declare class WebGLStateModule extends WebGLModule {
916
916
  }
917
917
 
918
918
  interface Batchable2D {
919
- vertices: number[];
920
- indices: number[];
921
- uvs?: number[];
919
+ vertices: Float32Array;
920
+ indices: Float32Array;
921
+ uvs?: Float32Array;
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;
@@ -1892,7 +1888,7 @@ declare class Node2D extends CanvasItem {
1892
1888
  getTransform(cb?: (transform: Transform2D) => void): Transform2D;
1893
1889
  updateTransform(): void;
1894
1890
  updateGlobalTransform(): void;
1895
- protected _transformVertices(vertices: number[], vertTransform?: VertTransform): number[];
1891
+ protected _transformVertices(vertices: Float32Array, vertTransform?: VertTransform): Float32Array;
1896
1892
  protected _relayout(batchables: CanvasBatchable[]): CanvasBatchable[];
1897
1893
  protected _process(delta: number): void;
1898
1894
  }
package/dist/index.d.ts CHANGED
@@ -916,14 +916,12 @@ declare class WebGLStateModule extends WebGLModule {
916
916
  }
917
917
 
918
918
  interface Batchable2D {
919
- vertices: number[];
920
- indices: number[];
921
- uvs?: number[];
919
+ vertices: Float32Array;
920
+ indices: Float32Array;
921
+ uvs?: Float32Array;
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;
@@ -1892,7 +1888,7 @@ declare class Node2D extends CanvasItem {
1892
1888
  getTransform(cb?: (transform: Transform2D) => void): Transform2D;
1893
1889
  updateTransform(): void;
1894
1890
  updateGlobalTransform(): void;
1895
- protected _transformVertices(vertices: number[], vertTransform?: VertTransform): number[];
1891
+ protected _transformVertices(vertices: Float32Array, vertTransform?: VertTransform): Float32Array;
1896
1892
  protected _relayout(batchables: CanvasBatchable[]): CanvasBatchable[];
1897
1893
  protected _process(delta: number): void;
1898
1894
  }