modern-canvas 0.7.3 → 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.mjs CHANGED
@@ -2399,25 +2399,6 @@ class WebGLBatch2DModule extends WebGLModule {
2399
2399
  _drawCallUid = 0;
2400
2400
  _defaultModulate = 4294967295;
2401
2401
  _defaultBackgroundColor = 0;
2402
- _defaultColorMatrixOffset = [0, 0, 0, 0];
2403
- _defaultColorMatrix = [
2404
- 1,
2405
- 0,
2406
- 0,
2407
- 0,
2408
- 0,
2409
- 1,
2410
- 0,
2411
- 0,
2412
- 0,
2413
- 0,
2414
- 1,
2415
- 0,
2416
- 0,
2417
- 0,
2418
- 0,
2419
- 1
2420
- ];
2421
2402
  _batchables = [];
2422
2403
  _vertexCount = 0;
2423
2404
  _indexCount = 0;
@@ -2435,14 +2416,10 @@ class WebGLBatch2DModule extends WebGLModule {
2435
2416
  // 1
2436
2417
  aBackgroundColor: { size: 4, normalized: true, type: "unsigned_byte" },
2437
2418
  // 1
2438
- aDisableWrapMode: { size: 4, normalized: true, type: "float" },
2439
- // 4 只是为了凑4的整数倍
2440
- aColorMatrixOffset: { size: 4, normalized: false, type: "float" },
2441
- // 4 TODO bug
2442
- aColorMatrix: { size: 4, normalized: false, type: "float" }
2443
- // 16 TODO bug
2419
+ aDisableWrapMode: { size: 4, normalized: true, type: "unsigned_byte" }
2420
+ // 1
2444
2421
  };
2445
- _vertexSize = 1 + 2 + 2 + 1 + 1 + 4 + 4 + 16;
2422
+ _vertexSize = 1 + 2 + 2 + 1 + 1 + 1;
2446
2423
  _getShader(maxTextureUnits) {
2447
2424
  let shader = this._shaders.get(maxTextureUnits);
2448
2425
  if (!shader) {
@@ -2459,8 +2436,6 @@ attribute vec2 aPosition;
2459
2436
  attribute vec2 aUv;
2460
2437
  attribute vec4 aModulate;
2461
2438
  attribute vec4 aBackgroundColor;
2462
- attribute mat4 aColorMatrix;
2463
- attribute vec4 aColorMatrixOffset;
2464
2439
  attribute vec4 aDisableWrapMode;
2465
2440
 
2466
2441
  uniform mat3 projectionMatrix;
@@ -2471,8 +2446,6 @@ varying float vTextureId;
2471
2446
  varying vec2 vUv;
2472
2447
  varying vec4 vModulate;
2473
2448
  varying vec4 vBackgroundColor;
2474
- varying mat4 vColorMatrix;
2475
- varying vec4 vColorMatrixOffset;
2476
2449
  varying vec4 vDisableWrapMode;
2477
2450
 
2478
2451
  void main(void) {
@@ -2487,8 +2460,6 @@ void main(void) {
2487
2460
  vUv = aUv;
2488
2461
  vModulate = aModulate * modulate;
2489
2462
  vBackgroundColor = aBackgroundColor;
2490
- vColorMatrix = aColorMatrix;
2491
- vColorMatrixOffset = aColorMatrixOffset;
2492
2463
  vDisableWrapMode = aDisableWrapMode;
2493
2464
  }`,
2494
2465
  frag: `precision highp float;
@@ -2496,8 +2467,6 @@ varying float vTextureId;
2496
2467
  varying vec2 vUv;
2497
2468
  varying vec4 vModulate;
2498
2469
  varying vec4 vBackgroundColor;
2499
- varying mat4 vColorMatrix;
2500
- varying vec4 vColorMatrixOffset;
2501
2470
  varying vec4 vDisableWrapMode;
2502
2471
 
2503
2472
  uniform sampler2D samplers[${maxTextureUnits}];
@@ -2530,8 +2499,6 @@ void main(void) {
2530
2499
  color += (1.0 - color.a) * vBackgroundColor;
2531
2500
  if (color.a > 0.0) {
2532
2501
  color *= vModulate;
2533
- color = vColorMatrix * color;
2534
- color += vColorMatrixOffset;
2535
2502
  }
2536
2503
  gl_FragColor = color;
2537
2504
  }`
@@ -2634,12 +2601,9 @@ void main(void) {
2634
2601
  texture: texture2,
2635
2602
  modulate = this._defaultModulate,
2636
2603
  backgroundColor = this._defaultBackgroundColor,
2637
- colorMatrix = this._defaultColorMatrix,
2638
- colorMatrixOffset = this._defaultColorMatrixOffset,
2639
2604
  blendMode = WebGLBlendMode.NORMAL,
2640
2605
  disableWrapMode = false
2641
2606
  } = batchables[i];
2642
- const textureLocation = (texture2 ? textureLocationMap.get(texture2) : -1) ?? -1;
2643
2607
  if (start < i && drawCall.blendMode !== blendMode) {
2644
2608
  drawCall.count = iIndex - drawCall.first;
2645
2609
  drawCalls.push(drawCall);
@@ -2649,24 +2613,17 @@ void main(void) {
2649
2613
  drawCall.first = iIndex;
2650
2614
  }
2651
2615
  const iIndexStart = aIndex / this._vertexSize;
2616
+ const textureLocation = (texture2 ? textureLocationMap.get(texture2) : 255) ?? 255;
2617
+ const disableWrapModeInt = disableWrapMode ? 1 : 0;
2652
2618
  for (let len2 = vertices.length, i2 = 0; i2 < len2; i2 += 2) {
2653
2619
  float32View[aIndex++] = textureLocation;
2654
2620
  float32View[aIndex++] = vertices[i2];
2655
2621
  float32View[aIndex++] = vertices[i2 + 1];
2656
- float32View[aIndex++] = uvs[i2] ?? 0;
2657
- float32View[aIndex++] = uvs[i2 + 1] ?? 0;
2622
+ float32View[aIndex++] = uvs[i2];
2623
+ float32View[aIndex++] = uvs[i2 + 1];
2658
2624
  uint32View[aIndex++] = modulate;
2659
2625
  uint32View[aIndex++] = backgroundColor;
2660
- float32View[aIndex++] = disableWrapMode ? 1 : 0;
2661
- float32View[aIndex++] = 0;
2662
- float32View[aIndex++] = 0;
2663
- float32View[aIndex++] = 0;
2664
- for (let i3 = 0; i3 < 4; i3++) {
2665
- float32View[aIndex++] = colorMatrixOffset[i3] ?? 0;
2666
- }
2667
- for (let i3 = 0; i3 < 16; i3++) {
2668
- float32View[aIndex++] = colorMatrix[i3] ?? 0;
2669
- }
2626
+ uint32View[aIndex++] = disableWrapModeInt;
2670
2627
  }
2671
2628
  for (let len2 = indices.length, i2 = 0; i2 < len2; i2++) {
2672
2629
  indexBuffer[iIndex++] = iIndexStart + indices[i2];
@@ -7055,7 +7012,7 @@ class SceneTree extends MainLoop {
7055
7012
  }
7056
7013
  }
7057
7014
  __decorateClass$L([
7058
- property({ fallback: false })
7015
+ property({ protected: true, fallback: false })
7059
7016
  ], SceneTree.prototype, "processPaused");
7060
7017
  __decorateClass$L([
7061
7018
  property()
@@ -9984,12 +9941,11 @@ let BaseElement2D = class extends Node2D {
9984
9941
  _drawContent() {
9985
9942
  }
9986
9943
  _repaint(batchables) {
9987
- const colorMatrix = parseCSSFilter(this.style.filter);
9988
9944
  return super._repaint(batchables).map((batchable) => {
9989
9945
  return {
9990
- ...batchable,
9991
- colorMatrix: colorMatrix.toMatrix4().toArray(true),
9992
- colorMatrixOffset: colorMatrix.toVector4().toArray()
9946
+ ...batchable
9947
+ // colorMatrix: colorMatrix.toMatrix4().toArray(true),
9948
+ // colorMatrixOffset: colorMatrix.toVector4().toArray(),
9993
9949
  };
9994
9950
  });
9995
9951
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-canvas",
3
3
  "type": "module",
4
- "version": "0.7.3",
4
+ "version": "0.7.4",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "A JavaScript WebGL rendering engine.",
7
7
  "author": "wxm",