excalibur 0.32.0-alpha.1570 → 0.32.0-alpha.1572

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.
@@ -1,4 +1,4 @@
1
- /*! excalibur - 0.32.0-alpha.1570+3b683c5 - 2025-11-26
1
+ /*! excalibur - 0.32.0-alpha.1572+72a3430 - 2025-11-28
2
2
  https://github.com/excaliburjs/Excalibur
3
3
  Copyright (c) 2025 Excalibur.js <https://github.com/excaliburjs/Excalibur/graphs/contributors>
4
4
  Licensed BSD-2-Clause
@@ -6408,13 +6408,22 @@ Check your bundler settings to make sure this is not the case! Excalibur has ESM
6408
6408
  const intersect = this.intersect(bb);
6409
6409
  return _BoundingBox2.getSideFromIntersection(intersect);
6410
6410
  }
6411
+ /**
6412
+ * Draw a debug bounding box
6413
+ * @param ex
6414
+ * @param color
6415
+ * @deprecated
6416
+ */
6417
+ draw(ex, options = { color: Color.Yellow }) {
6418
+ ex.debug.drawRect(this.left, this.top, this.width, this.height, options);
6419
+ }
6411
6420
  /**
6412
6421
  * Draw a debug bounding box
6413
6422
  * @param ex
6414
6423
  * @param color
6415
6424
  */
6416
- draw(ex, color = Color.Yellow) {
6417
- ex.debug.drawRect(this.left, this.top, this.width, this.height, { color });
6425
+ debug(ex, options = { color: Color.Yellow }) {
6426
+ ex.debug.drawRect(this.left, this.top, this.width, this.height, options);
6418
6427
  }
6419
6428
  };
6420
6429
  _BoundingBox._SCRATCH_INTERSECT = [0, 0, 0, 0];
@@ -6862,9 +6871,9 @@ Check your bundler settings to make sure this is not the case! Excalibur has ESM
6862
6871
  const helper = (currentNode) => {
6863
6872
  if (currentNode) {
6864
6873
  if (currentNode.isLeaf()) {
6865
- currentNode.bounds.draw(ex, Color.Green);
6874
+ currentNode.bounds.debug(ex, { color: Color.Green });
6866
6875
  } else {
6867
- currentNode.bounds.draw(ex, Color.White);
6876
+ currentNode.bounds.debug(ex, { color: Color.White });
6868
6877
  }
6869
6878
  if (currentNode.left) {
6870
6879
  helper(currentNode.left);
@@ -7798,7 +7807,7 @@ Check your bundler settings to make sure this is not the case! Excalibur has ESM
7798
7807
  ex.translate(pos.x, pos.y);
7799
7808
  ex.rotate(rotation);
7800
7809
  ex.scale(scale.x, scale.y);
7801
- ex.drawCircle((_d = this.offset) != null ? _d : Vector.Zero, this._naturalRadius, Color.Transparent, color, lineWidth);
7810
+ ex.debug.drawCircle((_d = this.offset) != null ? _d : Vector.Zero, this._naturalRadius, Color.Transparent, color, lineWidth);
7802
7811
  ex.restore();
7803
7812
  }
7804
7813
  }
@@ -8564,9 +8573,9 @@ Check your bundler settings to make sure this is not the case! Excalibur has ESM
8564
8573
  debug(ex, color) {
8565
8574
  const begin = this._getTransformedBegin();
8566
8575
  const end = this._getTransformedEnd();
8567
- ex.drawLine(begin, end, color, 2);
8568
- ex.drawCircle(begin, 2, color);
8569
- ex.drawCircle(end, 2, color);
8576
+ ex.debug.drawLine(begin, end, { color, lineWidth: 2 });
8577
+ ex.debug.drawCircle(begin, 2, color);
8578
+ ex.debug.drawCircle(end, 2, color);
8570
8579
  }
8571
8580
  }
8572
8581
  class PolygonCollider extends Collider {
@@ -11300,11 +11309,118 @@ Read more here: https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL
11300
11309
  });
11301
11310
  }
11302
11311
  }
11303
- const debugFont = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAABACAYAAAD1Xam+AAAAAXNSR0IArs4c6QAABlFJREFUeJztndmy4yoMRcWt/v9fdr8EWoDAaDD4JntVpeqcxBrMIGQDNhEAAAAAAAAAAAAAAOCrSbMfr+u6yoEpTY+906GV57YtPkjyXj9WZZ+wHWHfo2N3/bU6Tte9Rv6ptruqRyMvKvvIX/zY3I/vjLeqsg6l/CWdp0KHKO/1Y1H2EdsR9j06Ntdfp+N03SvkH2u7i3pu5XkQ+DNTkgNJSok+/183xpcdWZHjgUzpQ2pGD67vaf//KRAGAq3tdhCy2tcMQKPyXyz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ZAAA/DAIAADMMU3fOuS2ggAAwBjrorKoxWiPBxHMAgAg490Ts0VeePdA+ZfJDKcCh7sBqY88mmjklZeOt9iXPrvx2I2QPRnN2/qzyJ84h4gNcbtfasq5mM1rZr+bBWh2A+bIIX13Z9wqL+nQvFno7v3oq4tJItCed7isUT6C/I7BUn9KP95wDicYBYpcjncrO2c/dmW4tBtw4RiRld1IDxDyYsoXMHxF1w3dyz0Nne8033AOFsT6VgRCafl89fenTZUfbm8CGhrgdDcS7anAsvnkkP0IeCfQ+JzYunky6jhNYj5bl7++4fJvN9WDSKS/292A0wyANyKDI91bfkm3kcH7ckaP/SKW/VHKRZAcI14pP3beu0fPyn/DuZQbWMogNnsc16sziE96f7H/iai7uTf0/3N8lwFz/e13T00Djt4OrInCnkeChXT+qOcKOLA21tJpsv/G8/COnGnw97J9QwbTvd6djYSv7fxEVTuV/LzNhj7nOawv6bfbAGCYEpQ6HxFtuxs6sq9tzOYHobQ6Nje+6vo5BwFrPZ4OgMayS4PPt1NlzdLfbRCYBoBc+NaO4JWPwLEf33oN3unY3InKPQBW6Z7nEZzEmrl4iZjC804lqgePPEOguQcwWghUphxm343wyt/pWpWR0OrR+jvyxavHajfb9pTjbt9bH07Z5/expM4TLWfwb7QQqMoC+UDWXZo/4RgA38LOgUvLJAAQ1Td9y9//0ylxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB+g79apuVUsS5ZmwAAAABJRU5ErkJggg==";
11312
+ const debugFont2 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3GwHAAAAAXNSR0IB2cksfwAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB+kLGhIwLEfXSw4AAAaVSURBVHja7d3BduQoDIVhas68/ytn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A79NyFLOe3UV8pCgAKAJx6hlfWzr9cIAAAAAAAAAAv5R8sG/KSRHx9UQAAAABJRU5ErkJggg==";
11313
+ const _Debug = class _Debug2 {
11314
+ static registerDebugConfig(config) {
11315
+ _Debug2.config = config;
11316
+ }
11317
+ static draw(debugDrawCall) {
11318
+ this._drawCalls.push(debugDrawCall);
11319
+ }
11320
+ static drawPoint(point2, options) {
11321
+ _Debug2.draw((ctx) => {
11322
+ ctx.debug.drawPoint(point2, options);
11323
+ });
11324
+ }
11325
+ static drawLine(start, end, options) {
11326
+ _Debug2.draw((ctx) => {
11327
+ ctx.debug.drawLine(start, end, options);
11328
+ });
11329
+ }
11330
+ static drawLines(points, options) {
11331
+ if (points.length > 1) {
11332
+ _Debug2.draw((ctx) => {
11333
+ for (let i = 0; i < points.length - 1; i++) {
11334
+ ctx.debug.drawLine(points[i], points[i + 1], options);
11335
+ }
11336
+ });
11337
+ }
11338
+ }
11339
+ static drawText(text, pos) {
11340
+ _Debug2.draw((ctx) => {
11341
+ ctx.debug.drawText(text, pos);
11342
+ });
11343
+ }
11344
+ static drawPolygon(points, options) {
11345
+ if (points.length > 1) {
11346
+ _Debug2.draw((ctx) => {
11347
+ const firstPoint = points[0];
11348
+ const polygon = [...points, firstPoint];
11349
+ for (let i = 0; i < polygon.length - 1; i++) {
11350
+ ctx.debug.drawLine(polygon[i], polygon[i + 1], options);
11351
+ }
11352
+ });
11353
+ }
11354
+ }
11355
+ static drawCircle(center, radius, options) {
11356
+ const { color, strokeColor, width } = {
11357
+ color: Color.Black,
11358
+ strokeColor: void 0,
11359
+ width: void 0,
11360
+ ...options
11361
+ };
11362
+ _Debug2.draw((ctx) => {
11363
+ ctx.debug.drawCircle(center, radius, color, strokeColor, width);
11364
+ });
11365
+ }
11366
+ static drawBounds(boundingBox, options) {
11367
+ _Debug2.draw((ctx) => {
11368
+ ctx.debug.drawRect(boundingBox.left, boundingBox.top, boundingBox.width, boundingBox.height, options);
11369
+ });
11370
+ }
11371
+ static drawRay(ray, options) {
11372
+ const { distance, color } = {
11373
+ color: Color.Blue,
11374
+ distance: 10,
11375
+ ...options
11376
+ };
11377
+ _Debug2.draw((ctx) => {
11378
+ ctx.z = _Debug2.config.settings.z.ray;
11379
+ const start = ray.pos;
11380
+ const end = ray.pos.add(ray.dir.scale(distance));
11381
+ ctx.debug.drawLine(start, end, { color });
11382
+ });
11383
+ }
11384
+ static flush(ctx) {
11385
+ ctx.save();
11386
+ ctx.z = _Debug2.z;
11387
+ for (const drawCall of _Debug2._drawCalls) {
11388
+ drawCall(ctx);
11389
+ }
11390
+ ctx.restore();
11391
+ _Debug2.clear();
11392
+ }
11393
+ static clear() {
11394
+ _Debug2._drawCalls.length = 0;
11395
+ }
11396
+ };
11397
+ _Debug._drawCalls = [];
11398
+ _Debug.z = Infinity;
11399
+ _Debug.config = {
11400
+ // add some defaults
11401
+ settings: {
11402
+ text: {
11403
+ foreground: Color.Black,
11404
+ background: Color.Transparent,
11405
+ border: Color.Transparent
11406
+ },
11407
+ z: {
11408
+ text: Number.POSITIVE_INFINITY,
11409
+ point: Number.MAX_SAFE_INTEGER - 1,
11410
+ ray: Number.MAX_SAFE_INTEGER - 1,
11411
+ dashed: Number.MAX_SAFE_INTEGER - 2,
11412
+ solid: Number.MAX_SAFE_INTEGER - 3
11413
+ }
11414
+ }
11415
+ };
11416
+ let Debug = _Debug;
11304
11417
  class DebugText {
11305
11418
  constructor() {
11306
- this.fontSheet = debugFont;
11419
+ this.fontSheet = debugFont2;
11307
11420
  this.size = 16;
11421
+ this.foregroundColor = Debug.config.settings.text.foreground;
11422
+ this.backgroundColor = Debug.config.settings.text.background;
11423
+ this.borderColor = Debug.config.settings.text.border;
11308
11424
  this.load();
11309
11425
  }
11310
11426
  load() {
@@ -11313,17 +11429,23 @@ Read more here: https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL
11313
11429
  this._spriteSheet = SpriteSheet.fromImageSource({
11314
11430
  image: this._imageSource,
11315
11431
  grid: {
11316
- rows: 4,
11432
+ rows: 8,
11317
11433
  columns: 16,
11318
- spriteWidth: 16,
11319
- spriteHeight: 16
11434
+ spriteWidth: 6 * 2 - 2,
11435
+ // hack to avoid sample bleed
11436
+ spriteHeight: 12 * 2
11437
+ },
11438
+ spacing: {
11439
+ // hack to avoid sample bleed
11440
+ originOffset: { x: 2, y: 0 },
11441
+ margin: { x: 2, y: 0 }
11320
11442
  }
11321
11443
  });
11322
11444
  this._spriteFont = new SpriteFont({
11323
- alphabet: `0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ,!'&."?-()+# `,
11324
- caseInsensitive: true,
11445
+ alphabet: " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~?",
11446
+ caseInsensitive: false,
11325
11447
  spriteSheet: this._spriteSheet,
11326
- spacing: -6
11448
+ spacing: 2
11327
11449
  });
11328
11450
  });
11329
11451
  }
@@ -11333,9 +11455,23 @@ Read more here: https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL
11333
11455
  * @param text
11334
11456
  * @param pos
11335
11457
  */
11336
- write(ctx, text, pos) {
11458
+ write(ctx, text, pos, foreground, background) {
11337
11459
  if (this._imageSource.isLoaded()) {
11460
+ const pos1 = ctx.getTransform().getPosition();
11461
+ ctx.save();
11462
+ ctx.resetTransform();
11463
+ ctx.z = Debug.config.settings.z.text;
11464
+ ctx.translate(pos1.x, pos1.y);
11465
+ const bounds = this._spriteFont.measureText(text);
11466
+ const color = foreground != null ? foreground : this.foregroundColor;
11467
+ const bg = background != null ? background : this.backgroundColor;
11468
+ ctx.save();
11469
+ ctx.z = Debug.config.settings.z.solid;
11470
+ ctx.drawRectangle(pos, bounds.width, bounds.height, bg, this.borderColor, 1);
11471
+ ctx.restore();
11472
+ ctx.tint = color;
11338
11473
  this._spriteFont.render(ctx, text, null, pos.x, pos.y);
11474
+ ctx.restore();
11339
11475
  }
11340
11476
  }
11341
11477
  }
@@ -11499,8 +11635,8 @@ Read more here: https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL
11499
11635
  gl.bindTexture(gl.TEXTURE_2D, null);
11500
11636
  }
11501
11637
  }
11502
- const lineVertexSource = "#version 300 es\nin vec2 a_position;\nin vec4 a_color;\n\nout lowp vec4 v_color;\n\nuniform mat4 u_matrix;\n\nvoid main() {\n // Set the vertex position using the ortho transform matrix\n gl_Position = u_matrix * vec4(a_position, 0.0, 1.0);\n\n // Passthrough the color\n v_color = a_color;\n}";
11503
- const lineFragmentSource = "#version 300 es\nprecision mediump float;\n\n// Color\nin lowp vec4 v_color;\n\nout vec4 fragColor;\n\nvoid main() {\n fragColor = v_color;\n}";
11638
+ const lineVertexSource = "#version 300 es\nin vec2 a_position;\nin vec4 a_color;\nin float a_lengthSoFar;\n\nout lowp vec4 v_color;\nout float v_lengthSoFar;\n\nuniform mat4 u_matrix;\n\nvoid main() {\n // Set the vertex position using the ortho transform matrix\n gl_Position = u_matrix * vec4(a_position, 0.0, 1.0);\n\n // Passthrough the color\n v_color = a_color;\n\n // Passthrough the line length so far\n v_lengthSoFar = a_lengthSoFar;\n}\n";
11639
+ const lineFragmentSource = "#version 300 es\nprecision mediump float;\n\n// Color\nin lowp vec4 v_color;\nin float v_lengthSoFar;\n\nout vec4 fragColor;\n\nuniform bool u_dashed;\n\nvoid main() {\n fragColor = v_color;\n if (u_dashed) {\n fragColor.a = smoothstep(0.5, 0.55, fract(v_lengthSoFar / 10.0)); // 10 pixel dashes\n fragColor.rgb *= fragColor.a;\n }\n}\n";
11504
11640
  class Line extends Graphic {
11505
11641
  constructor(options) {
11506
11642
  super();
@@ -11795,6 +11931,7 @@ Read more here: https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL
11795
11931
  graphic.flipVertical = oldFlipVertical;
11796
11932
  }
11797
11933
  if (((_b = this._engine) == null ? void 0 : _b.isDebug) && this._engine.debug.graphics.showBounds) {
11934
+ this._graphicsContext.save();
11798
11935
  const offset2 = vec(offsetX, offsetY);
11799
11936
  if (graphic instanceof GraphicsGroup) {
11800
11937
  for (const member of graphic.members) {
@@ -11807,14 +11944,15 @@ Read more here: https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL
11807
11944
  pos = member.offset;
11808
11945
  }
11809
11946
  if (graphic.useAnchor) {
11810
- g == null ? void 0 : g.localBounds.translate(offset2.add(pos)).draw(this._graphicsContext, this._engine.debug.graphics.boundsColor);
11947
+ g == null ? void 0 : g.localBounds.translate(offset2.add(pos)).debug(this._graphicsContext, { color: this._engine.debug.graphics.boundsColor, dashed: true });
11811
11948
  } else {
11812
- g == null ? void 0 : g.localBounds.translate(pos).draw(this._graphicsContext, this._engine.debug.graphics.boundsColor);
11949
+ g == null ? void 0 : g.localBounds.translate(pos).debug(this._graphicsContext, { color: this._engine.debug.graphics.boundsColor, dashed: true });
11813
11950
  }
11814
11951
  }
11815
11952
  } else {
11816
- graphic == null ? void 0 : graphic.localBounds.translate(offset2).draw(this._graphicsContext, this._engine.debug.graphics.boundsColor);
11953
+ graphic == null ? void 0 : graphic.localBounds.translate(offset2).debug(this._graphicsContext, { color: this._engine.debug.graphics.boundsColor, dashed: true });
11817
11954
  }
11955
+ this._graphicsContext.restore();
11818
11956
  }
11819
11957
  }
11820
11958
  }
@@ -12640,6 +12778,30 @@ Read https://excaliburjs.com/docs/imagesource for more information.`
12640
12778
  this._ex.__ctx.closePath();
12641
12779
  this._ex.__ctx.restore();
12642
12780
  }
12781
+ drawCircle(pos, radius, color, stroke, thickness) {
12782
+ this._ex.__ctx.save();
12783
+ this._ex.__ctx.beginPath();
12784
+ if (stroke) {
12785
+ this._ex.__ctx.strokeStyle = stroke.toString();
12786
+ }
12787
+ if (thickness) {
12788
+ this._ex.__ctx.lineWidth = thickness;
12789
+ }
12790
+ this._ex.__ctx.fillStyle = color.toString();
12791
+ this._ex.__ctx.arc(
12792
+ this._ex.snapToPixel ? ~~(pos.x + pixelSnapEpsilon$1) : pos.x,
12793
+ this._ex.snapToPixel ? ~~(pos.y + pixelSnapEpsilon$1) : pos.y,
12794
+ radius,
12795
+ 0,
12796
+ Math.PI * 2
12797
+ );
12798
+ this._ex.__ctx.fill();
12799
+ if (stroke) {
12800
+ this._ex.__ctx.stroke();
12801
+ }
12802
+ this._ex.__ctx.closePath();
12803
+ this._ex.__ctx.restore();
12804
+ }
12643
12805
  drawText(text, pos) {
12644
12806
  this._debugText.write(this._ex, text, pos);
12645
12807
  }
@@ -12792,7 +12954,15 @@ Read https://excaliburjs.com/docs/imagesource for more information.`
12792
12954
  this.__ctx.scale(x, y);
12793
12955
  }
12794
12956
  getTransform() {
12795
- throw new Error("Not implemented");
12957
+ const domMatrix = this.__ctx.getTransform();
12958
+ const affine = new AffineMatrix();
12959
+ affine.data[0] = domMatrix.a;
12960
+ affine.data[1] = domMatrix.b;
12961
+ affine.data[2] = domMatrix.c;
12962
+ affine.data[3] = domMatrix.d;
12963
+ affine.data[4] = domMatrix.e;
12964
+ affine.data[5] = domMatrix.f;
12965
+ return affine;
12796
12966
  }
12797
12967
  multiply(_m) {
12798
12968
  this.__ctx.setTransform(this.__ctx.getTransform().multiply(_m.toDOMMatrix()));
@@ -14486,101 +14656,17 @@ void main() {
14486
14656
  "u_screen_texture"
14487
14657
  ];
14488
14658
  let Material = _Material;
14489
- const _Debug = class _Debug2 {
14490
- static registerGraphicsContext(ctx) {
14491
- _Debug2._ctx = ctx;
14492
- }
14493
- static draw(debugDrawCall) {
14494
- this._drawCalls.push(debugDrawCall);
14495
- }
14496
- static drawPoint(point2, options) {
14497
- _Debug2.draw((ctx) => {
14498
- ctx.debug.drawPoint(point2, options);
14499
- });
14500
- }
14501
- static drawLine(start, end, options) {
14502
- _Debug2.draw((ctx) => {
14503
- ctx.debug.drawLine(start, end, options);
14504
- });
14505
- }
14506
- static drawLines(points, options) {
14507
- if (points.length > 1) {
14508
- _Debug2.draw((ctx) => {
14509
- for (let i = 0; i < points.length - 1; i++) {
14510
- ctx.debug.drawLine(points[i], points[i + 1], options);
14511
- }
14512
- });
14513
- }
14514
- }
14515
- static drawText(text, pos) {
14516
- _Debug2.draw((ctx) => {
14517
- ctx.debug.drawText(text, pos);
14518
- });
14519
- }
14520
- static drawPolygon(points, options) {
14521
- if (points.length > 1) {
14522
- _Debug2.draw((ctx) => {
14523
- const firstPoint = points[0];
14524
- const polygon = [...points, firstPoint];
14525
- for (let i = 0; i < polygon.length - 1; i++) {
14526
- ctx.debug.drawLine(polygon[i], polygon[i + 1], options);
14527
- }
14528
- });
14529
- }
14530
- }
14531
- static drawCircle(center, radius, options) {
14532
- const { color, strokeColor, width } = {
14533
- color: Color.Black,
14534
- strokeColor: void 0,
14535
- width: void 0,
14536
- ...options
14537
- };
14538
- _Debug2.draw((ctx) => {
14539
- ctx.drawCircle(center, radius, color, strokeColor, width);
14540
- });
14541
- }
14542
- static drawBounds(boundingBox, options) {
14543
- _Debug2.draw((ctx) => {
14544
- ctx.debug.drawRect(boundingBox.left, boundingBox.top, boundingBox.width, boundingBox.height, options);
14545
- });
14546
- }
14547
- static drawRay(ray, options) {
14548
- const { distance, color } = {
14549
- color: Color.Blue,
14550
- distance: 10,
14551
- ...options
14552
- };
14553
- _Debug2.draw((ctx) => {
14554
- const start = ray.pos;
14555
- const end = ray.pos.add(ray.dir.scale(distance));
14556
- ctx.debug.drawLine(start, end, { color });
14557
- });
14558
- }
14559
- static flush(ctx) {
14560
- ctx.save();
14561
- ctx.z = _Debug2.z;
14562
- for (const drawCall of _Debug2._drawCalls) {
14563
- drawCall(ctx);
14564
- }
14565
- ctx.restore();
14566
- _Debug2.clear();
14567
- }
14568
- static clear() {
14569
- _Debug2._drawCalls.length = 0;
14570
- }
14571
- };
14572
- _Debug._drawCalls = [];
14573
- _Debug.z = Infinity;
14574
- let Debug = _Debug;
14575
- class LineRenderer {
14659
+ class DebugLineRenderer {
14576
14660
  constructor() {
14577
- this.type = "ex.line";
14661
+ this.type = "ex.debug-line";
14578
14662
  this.priority = 0;
14579
14663
  this._maxLines = 10922;
14580
14664
  this._vertexIndex = 0;
14581
14665
  this._lineCount = 0;
14582
14666
  this._startScratch = vec(0, 0);
14583
14667
  this._endScratch = vec(0, 0);
14668
+ this._lengthSoFar = 0;
14669
+ this._currentlyDashed = false;
14584
14670
  }
14585
14671
  initialize(gl, context) {
14586
14672
  this._gl = gl;
@@ -14595,7 +14681,8 @@ void main() {
14595
14681
  this._shader.setUniformMatrix("u_matrix", this._context.ortho);
14596
14682
  this._vertexBuffer = new VertexBuffer({
14597
14683
  gl,
14598
- size: 6 * 2 * this._maxLines,
14684
+ size: 7 * 6 * this._maxLines,
14685
+ // 7 floats per vert, 6 verts per line
14599
14686
  type: "dynamic"
14600
14687
  });
14601
14688
  this._layout = new VertexLayout({
@@ -14604,7 +14691,8 @@ void main() {
14604
14691
  shader: this._shader,
14605
14692
  attributes: [
14606
14693
  ["a_position", 2],
14607
- ["a_color", 4]
14694
+ ["a_color", 4],
14695
+ ["a_lengthSoFar", 1]
14608
14696
  ]
14609
14697
  });
14610
14698
  }
@@ -14614,27 +14702,62 @@ void main() {
14614
14702
  this._context = null;
14615
14703
  this._gl = null;
14616
14704
  }
14617
- draw(start, end, color) {
14618
- if (this._isFull()) {
14705
+ draw(start, end, color, width = 2, dashed = false) {
14706
+ if (this._isFull() || this._currentlyDashed !== dashed) {
14707
+ this._currentlyDashed = dashed;
14619
14708
  this.flush();
14620
14709
  }
14621
14710
  this._lineCount++;
14622
14711
  const transform = this._context.getTransform();
14623
14712
  const finalStart = transform.multiply(start, this._startScratch);
14624
14713
  const finalEnd = transform.multiply(end, this._endScratch);
14714
+ const dir = finalEnd.sub(finalStart);
14715
+ const dist = finalStart.distance(finalEnd);
14716
+ const normal = dir.normal();
14717
+ const halfWidth = width / 2;
14625
14718
  const vertexBuffer = this._vertexBuffer.bufferData;
14626
- vertexBuffer[this._vertexIndex++] = finalStart.x;
14627
- vertexBuffer[this._vertexIndex++] = finalStart.y;
14719
+ vertexBuffer[this._vertexIndex++] = finalStart.x - normal.x * halfWidth;
14720
+ vertexBuffer[this._vertexIndex++] = finalStart.y - normal.y * halfWidth;
14628
14721
  vertexBuffer[this._vertexIndex++] = color.r / 255;
14629
14722
  vertexBuffer[this._vertexIndex++] = color.g / 255;
14630
14723
  vertexBuffer[this._vertexIndex++] = color.b / 255;
14631
14724
  vertexBuffer[this._vertexIndex++] = color.a;
14632
- vertexBuffer[this._vertexIndex++] = finalEnd.x;
14633
- vertexBuffer[this._vertexIndex++] = finalEnd.y;
14725
+ vertexBuffer[this._vertexIndex++] = this._lengthSoFar;
14726
+ vertexBuffer[this._vertexIndex++] = finalStart.x + normal.x * halfWidth;
14727
+ vertexBuffer[this._vertexIndex++] = finalStart.y + normal.y * halfWidth;
14634
14728
  vertexBuffer[this._vertexIndex++] = color.r / 255;
14635
14729
  vertexBuffer[this._vertexIndex++] = color.g / 255;
14636
14730
  vertexBuffer[this._vertexIndex++] = color.b / 255;
14637
14731
  vertexBuffer[this._vertexIndex++] = color.a;
14732
+ vertexBuffer[this._vertexIndex++] = this._lengthSoFar;
14733
+ vertexBuffer[this._vertexIndex++] = finalEnd.x - normal.x * halfWidth;
14734
+ vertexBuffer[this._vertexIndex++] = finalEnd.y - normal.y * halfWidth;
14735
+ vertexBuffer[this._vertexIndex++] = color.r / 255;
14736
+ vertexBuffer[this._vertexIndex++] = color.g / 255;
14737
+ vertexBuffer[this._vertexIndex++] = color.b / 255;
14738
+ vertexBuffer[this._vertexIndex++] = color.a;
14739
+ vertexBuffer[this._vertexIndex++] = this._lengthSoFar + dist;
14740
+ vertexBuffer[this._vertexIndex++] = finalEnd.x - normal.x * halfWidth;
14741
+ vertexBuffer[this._vertexIndex++] = finalEnd.y - normal.y * halfWidth;
14742
+ vertexBuffer[this._vertexIndex++] = color.r / 255;
14743
+ vertexBuffer[this._vertexIndex++] = color.g / 255;
14744
+ vertexBuffer[this._vertexIndex++] = color.b / 255;
14745
+ vertexBuffer[this._vertexIndex++] = color.a;
14746
+ vertexBuffer[this._vertexIndex++] = this._lengthSoFar + dist;
14747
+ vertexBuffer[this._vertexIndex++] = finalStart.x + normal.x * halfWidth;
14748
+ vertexBuffer[this._vertexIndex++] = finalStart.y + normal.y * halfWidth;
14749
+ vertexBuffer[this._vertexIndex++] = color.r / 255;
14750
+ vertexBuffer[this._vertexIndex++] = color.g / 255;
14751
+ vertexBuffer[this._vertexIndex++] = color.b / 255;
14752
+ vertexBuffer[this._vertexIndex++] = color.a;
14753
+ vertexBuffer[this._vertexIndex++] = this._lengthSoFar;
14754
+ vertexBuffer[this._vertexIndex++] = finalEnd.x + normal.x * halfWidth;
14755
+ vertexBuffer[this._vertexIndex++] = finalEnd.y + normal.y * halfWidth;
14756
+ vertexBuffer[this._vertexIndex++] = color.r / 255;
14757
+ vertexBuffer[this._vertexIndex++] = color.g / 255;
14758
+ vertexBuffer[this._vertexIndex++] = color.b / 255;
14759
+ vertexBuffer[this._vertexIndex++] = color.a;
14760
+ vertexBuffer[this._vertexIndex++] = this._lengthSoFar + dist;
14638
14761
  }
14639
14762
  _isFull() {
14640
14763
  if (this._lineCount >= this._maxLines) {
@@ -14653,18 +14776,20 @@ void main() {
14653
14776
  this._shader.use();
14654
14777
  this._layout.use(true);
14655
14778
  this._shader.setUniformMatrix("u_matrix", this._context.ortho);
14656
- gl.drawArrays(gl.LINES, 0, this._lineCount * 2);
14779
+ this._shader.setUniformBoolean("u_dashed", this._currentlyDashed);
14780
+ gl.drawArrays(gl.TRIANGLES, 0, this._lineCount * 6);
14657
14781
  GraphicsDiagnostics.DrawnImagesCount += this._lineCount;
14658
14782
  GraphicsDiagnostics.DrawCallCount++;
14659
14783
  this._vertexIndex = 0;
14660
14784
  this._lineCount = 0;
14785
+ this._lengthSoFar = 0;
14661
14786
  }
14662
14787
  }
14663
14788
  const pointVertexSource = "#version 300 es\nin vec2 a_position;\nin vec4 a_color;\nin float a_size;\nout lowp vec4 v_color;\nuniform mat4 u_matrix;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_position, 0.0, 1.0);\n gl_PointSize = a_size * 2.0;\n v_color = a_color;\n}";
14664
14789
  const pointFragmentSource = '#version 300 es\n\nprecision mediump float;\nin lowp vec4 v_color;\n\nout vec4 fragColor;\n\nvoid main() {\n float r = 0.0, delta = 0.0, alpha = 1.0;\n vec2 cxy = 2.0 * gl_PointCoord - 1.0;\n r = dot(cxy, cxy);\n\n delta = fwidth(r);\n alpha = 1.0 - smoothstep(1.0 - delta, 1.0 + delta, r);\n // "premultiply" the color by alpha\n vec4 color = v_color;\n color.a = color.a * alpha;\n color.rgb = color.rgb * color.a;\n fragColor = color;\n}';
14665
- class PointRenderer {
14790
+ class DebugPointRenderer {
14666
14791
  constructor() {
14667
- this.type = "ex.point";
14792
+ this.type = "ex.debug-point";
14668
14793
  this.priority = 0;
14669
14794
  this._maxPoints = 10922;
14670
14795
  this._pointCount = 0;
@@ -14723,7 +14848,7 @@ void main() {
14723
14848
  vertexBuffer[this._vertexIndex++] = color.g / 255;
14724
14849
  vertexBuffer[this._vertexIndex++] = color.b / 255;
14725
14850
  vertexBuffer[this._vertexIndex++] = color.a * opacity;
14726
- vertexBuffer[this._vertexIndex++] = size * Math.max(transform.getScaleX(), transform.getScaleY());
14851
+ vertexBuffer[this._vertexIndex++] = size;
14727
14852
  }
14728
14853
  _isFull() {
14729
14854
  if (this._pointCount >= this._maxPoints) {
@@ -14749,6 +14874,169 @@ void main() {
14749
14874
  this._vertexIndex = 0;
14750
14875
  }
14751
14876
  }
14877
+ const frag$4 = "#version 300 es\nprecision highp float;\n\n// UV coord\nin vec2 v_uv;\n\n// Color coord to blend with image\nin lowp vec4 v_color;\n\n// Stroke color if used\nin lowp vec4 v_strokeColor;\n\n// Stroke thickness if used\nin lowp float v_strokeThickness;\n\nin float v_radius;\n\n// Opacity\nin float v_opacity;\n\nout vec4 fragColor;\n\nvoid main() {\n // make (0, 0) the center the uv \n vec2 uv = v_uv * 2.0 - 1.0;\n\n vec4 color = v_color;\n vec4 strokeColor = v_strokeColor;\n\n float dist = 1.0 - length(uv);\n float radius = dist * v_radius; // 0 is the edge\n\n // Fade based on fwidth\n float fade = fwidth(dot(uv, uv)) / 2.0;\n\n float fill = smoothstep(-fade, fade, radius);\n\n float stroke = \n smoothstep(0.0, fade, radius) -\n smoothstep(v_strokeThickness, v_strokeThickness + fade, radius);\n\n strokeColor.a = stroke;\n strokeColor.rgb *= strokeColor.a;\n\n // vec4 finalColor = strokeColor;\n\n color.a *= fill * (1.0 - stroke);\n color.rgb *= color.a;\n\n vec4 finalColor = mix(vec4(0.0), (color + strokeColor), fill);\n finalColor.rgb = finalColor.rgb * v_opacity;\n finalColor.a = finalColor.a * v_opacity;\n\n fragColor = finalColor;\n}\n";
14878
+ const vert$4 = "#version 300 es\nin vec2 a_position;\n\n// UV coordinate\nin vec2 a_uv;\nout vec2 v_uv;\n\n// Opacity \nin float a_opacity;\nout float v_opacity;\n\nin vec4 a_color;\nout vec4 v_color;\n\nin vec4 a_strokeColor;\nout vec4 v_strokeColor;\n\nin float a_strokeThickness;\nout float v_strokeThickness;\n\nin float a_radius;\nout float v_radius;\n\nuniform mat4 u_matrix;\n\n\nvoid main() {\n // Set the vertex position using the ortho transform matrix\n gl_Position = u_matrix * vec4(a_position, 0.0, 1.0);\n\n // Pass through UV coords\n v_uv = a_uv;\n // Pass through the Opacity to the fragment shader\n v_opacity = a_opacity;\n // Pass through the color to the fragment shader\n v_color = a_color;\n // Pass through the stroke color to the fragment shader\n v_strokeColor = a_strokeColor;\n // Pass through the stroke thickenss to the fragment shader\n v_strokeThickness = a_strokeThickness;\n v_radius = a_radius;\n}\n";
14879
+ class DebugCircleRenderer {
14880
+ constructor() {
14881
+ this.type = "ex.debug-circle";
14882
+ this.priority = 0;
14883
+ this._maxCircles = 10922;
14884
+ this._circleCount = 0;
14885
+ this._vertexIndex = 0;
14886
+ }
14887
+ initialize(gl, context) {
14888
+ this._gl = gl;
14889
+ this._context = context;
14890
+ this._shader = new Shader({
14891
+ graphicsContext: context,
14892
+ fragmentSource: frag$4,
14893
+ vertexSource: vert$4
14894
+ });
14895
+ this._shader.compile();
14896
+ this._shader.use();
14897
+ this._shader.setUniformMatrix("u_matrix", context.ortho);
14898
+ this._buffer = new VertexBuffer({
14899
+ gl,
14900
+ size: 15 * 4 * this._maxCircles,
14901
+ type: "dynamic"
14902
+ });
14903
+ this._layout = new VertexLayout({
14904
+ gl,
14905
+ shader: this._shader,
14906
+ vertexBuffer: this._buffer,
14907
+ attributes: [
14908
+ ["a_position", 2],
14909
+ ["a_uv", 2],
14910
+ ["a_opacity", 1],
14911
+ ["a_color", 4],
14912
+ ["a_strokeColor", 4],
14913
+ ["a_strokeThickness", 1],
14914
+ ["a_radius", 1]
14915
+ ]
14916
+ });
14917
+ this._quads = new QuadIndexBuffer(gl, this._maxCircles, true);
14918
+ }
14919
+ dispose() {
14920
+ this._buffer.dispose();
14921
+ this._quads.dispose();
14922
+ this._shader.dispose();
14923
+ this._context = null;
14924
+ this._gl = null;
14925
+ }
14926
+ _isFull() {
14927
+ if (this._circleCount >= this._maxCircles) {
14928
+ return true;
14929
+ }
14930
+ return false;
14931
+ }
14932
+ draw(pos, radius, color, stroke = Color.Transparent, strokeThickness = 0) {
14933
+ if (this._isFull()) {
14934
+ this.flush();
14935
+ }
14936
+ this._circleCount++;
14937
+ const transform = this._context.getTransform();
14938
+ const scale = transform.getScaleX();
14939
+ const opacity = this._context.opacity;
14940
+ const snapToPixel = this._context.snapToPixel;
14941
+ const topLeft = transform.multiply(pos.add(vec(-radius, -radius)));
14942
+ const topRight = transform.multiply(pos.add(vec(radius, -radius)));
14943
+ const bottomRight = transform.multiply(pos.add(vec(radius, radius)));
14944
+ const bottomLeft = transform.multiply(pos.add(vec(-radius, radius)));
14945
+ if (snapToPixel) {
14946
+ topLeft.x = ~~(topLeft.x + pixelSnapEpsilon);
14947
+ topLeft.y = ~~(topLeft.y + pixelSnapEpsilon);
14948
+ topRight.x = ~~(topRight.x + pixelSnapEpsilon);
14949
+ topRight.y = ~~(topRight.y + pixelSnapEpsilon);
14950
+ bottomLeft.x = ~~(bottomLeft.x + pixelSnapEpsilon);
14951
+ bottomLeft.y = ~~(bottomLeft.y + pixelSnapEpsilon);
14952
+ bottomRight.x = ~~(bottomRight.x + pixelSnapEpsilon);
14953
+ bottomRight.y = ~~(bottomRight.y + pixelSnapEpsilon);
14954
+ }
14955
+ const uvx0 = 0;
14956
+ const uvy0 = 0;
14957
+ const uvx1 = 1;
14958
+ const uvy1 = 1;
14959
+ const vertexBuffer = this._layout.vertexBuffer.bufferData;
14960
+ vertexBuffer[this._vertexIndex++] = topLeft.x;
14961
+ vertexBuffer[this._vertexIndex++] = topLeft.y;
14962
+ vertexBuffer[this._vertexIndex++] = uvx0;
14963
+ vertexBuffer[this._vertexIndex++] = uvy0;
14964
+ vertexBuffer[this._vertexIndex++] = opacity;
14965
+ vertexBuffer[this._vertexIndex++] = color.r / 255;
14966
+ vertexBuffer[this._vertexIndex++] = color.g / 255;
14967
+ vertexBuffer[this._vertexIndex++] = color.b / 255;
14968
+ vertexBuffer[this._vertexIndex++] = color.a;
14969
+ vertexBuffer[this._vertexIndex++] = stroke.r / 255;
14970
+ vertexBuffer[this._vertexIndex++] = stroke.g / 255;
14971
+ vertexBuffer[this._vertexIndex++] = stroke.b / 255;
14972
+ vertexBuffer[this._vertexIndex++] = stroke.a;
14973
+ vertexBuffer[this._vertexIndex++] = strokeThickness;
14974
+ vertexBuffer[this._vertexIndex++] = radius * scale;
14975
+ vertexBuffer[this._vertexIndex++] = bottomLeft.x;
14976
+ vertexBuffer[this._vertexIndex++] = bottomLeft.y;
14977
+ vertexBuffer[this._vertexIndex++] = uvx0;
14978
+ vertexBuffer[this._vertexIndex++] = uvy1;
14979
+ vertexBuffer[this._vertexIndex++] = opacity;
14980
+ vertexBuffer[this._vertexIndex++] = color.r / 255;
14981
+ vertexBuffer[this._vertexIndex++] = color.g / 255;
14982
+ vertexBuffer[this._vertexIndex++] = color.b / 255;
14983
+ vertexBuffer[this._vertexIndex++] = color.a;
14984
+ vertexBuffer[this._vertexIndex++] = stroke.r / 255;
14985
+ vertexBuffer[this._vertexIndex++] = stroke.g / 255;
14986
+ vertexBuffer[this._vertexIndex++] = stroke.b / 255;
14987
+ vertexBuffer[this._vertexIndex++] = stroke.a;
14988
+ vertexBuffer[this._vertexIndex++] = strokeThickness;
14989
+ vertexBuffer[this._vertexIndex++] = radius * scale;
14990
+ vertexBuffer[this._vertexIndex++] = topRight.x;
14991
+ vertexBuffer[this._vertexIndex++] = topRight.y;
14992
+ vertexBuffer[this._vertexIndex++] = uvx1;
14993
+ vertexBuffer[this._vertexIndex++] = uvy0;
14994
+ vertexBuffer[this._vertexIndex++] = opacity;
14995
+ vertexBuffer[this._vertexIndex++] = color.r / 255;
14996
+ vertexBuffer[this._vertexIndex++] = color.g / 255;
14997
+ vertexBuffer[this._vertexIndex++] = color.b / 255;
14998
+ vertexBuffer[this._vertexIndex++] = color.a;
14999
+ vertexBuffer[this._vertexIndex++] = stroke.r / 255;
15000
+ vertexBuffer[this._vertexIndex++] = stroke.g / 255;
15001
+ vertexBuffer[this._vertexIndex++] = stroke.b / 255;
15002
+ vertexBuffer[this._vertexIndex++] = stroke.a;
15003
+ vertexBuffer[this._vertexIndex++] = strokeThickness;
15004
+ vertexBuffer[this._vertexIndex++] = radius * scale;
15005
+ vertexBuffer[this._vertexIndex++] = bottomRight.x;
15006
+ vertexBuffer[this._vertexIndex++] = bottomRight.y;
15007
+ vertexBuffer[this._vertexIndex++] = uvx1;
15008
+ vertexBuffer[this._vertexIndex++] = uvy1;
15009
+ vertexBuffer[this._vertexIndex++] = opacity;
15010
+ vertexBuffer[this._vertexIndex++] = color.r / 255;
15011
+ vertexBuffer[this._vertexIndex++] = color.g / 255;
15012
+ vertexBuffer[this._vertexIndex++] = color.b / 255;
15013
+ vertexBuffer[this._vertexIndex++] = color.a;
15014
+ vertexBuffer[this._vertexIndex++] = stroke.r / 255;
15015
+ vertexBuffer[this._vertexIndex++] = stroke.g / 255;
15016
+ vertexBuffer[this._vertexIndex++] = stroke.b / 255;
15017
+ vertexBuffer[this._vertexIndex++] = stroke.a;
15018
+ vertexBuffer[this._vertexIndex++] = strokeThickness;
15019
+ vertexBuffer[this._vertexIndex++] = radius * scale;
15020
+ }
15021
+ hasPendingDraws() {
15022
+ return this._circleCount !== 0;
15023
+ }
15024
+ flush() {
15025
+ if (this._circleCount === 0) {
15026
+ return;
15027
+ }
15028
+ const gl = this._gl;
15029
+ this._shader.use();
15030
+ this._layout.use(true);
15031
+ this._shader.setUniformMatrix("u_matrix", this._context.ortho);
15032
+ this._quads.bind();
15033
+ gl.drawElements(gl.TRIANGLES, this._circleCount * 6, this._quads.bufferGlType, 0);
15034
+ GraphicsDiagnostics.DrawnImagesCount += this._circleCount;
15035
+ GraphicsDiagnostics.DrawCallCount++;
15036
+ this._circleCount = 0;
15037
+ this._vertexIndex = 0;
15038
+ }
15039
+ }
14752
15040
  const screenVertex = "#version 300 es\nin vec2 a_position;\n\nin vec2 a_texcoord;\nout vec2 v_texcoord;\n\nvoid main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n\n // Pass the texcoord to the fragment shader.\n v_texcoord = a_texcoord;\n}";
14753
15041
  const screenFragment = "#version 300 es\nprecision mediump float;\n\n// Passed in from the vertex shader.\nin vec2 v_texcoord;\n\n// The texture.\nuniform sampler2D u_texture;\n\nout vec4 fragColor;\n\nvoid main() {\n fragColor = texture(u_texture, v_texcoord);\n}";
14754
15042
  class ScreenPassPainter {
@@ -16060,7 +16348,9 @@ void main() {
16060
16348
  this._debugText = new DebugText();
16061
16349
  }
16062
16350
  /**
16063
- * Draw a debugging rectangle to the context
16351
+ * Draw a debugging rectangle to the graphics context
16352
+ *
16353
+ * Debugging draws are independent of scale/zoom
16064
16354
  * @param x
16065
16355
  * @param y
16066
16356
  * @param width
@@ -16073,25 +16363,61 @@ void main() {
16073
16363
  this.drawLine(vec(x, y + height), vec(x, y), { ...rectOptions });
16074
16364
  }
16075
16365
  /**
16076
- * Draw a debugging line to the context
16366
+ * Draw a debugging line to the graphics context
16367
+ *
16368
+ * Debugging draws are independent of scale/zoom
16077
16369
  * @param start
16078
16370
  * @param end
16079
16371
  * @param lineOptions
16080
16372
  */
16081
16373
  drawLine(start, end, lineOptions) {
16082
16374
  var _a;
16083
- this._webglCtx.draw("ex.line", start, end, (_a = lineOptions == null ? void 0 : lineOptions.color) != null ? _a : Color.Black);
16375
+ this._webglCtx.save();
16376
+ this._webglCtx.z = (lineOptions == null ? void 0 : lineOptions.dashed) ? Debug.config.settings.z.dashed : Debug.config.settings.z.solid;
16377
+ this._webglCtx.draw(
16378
+ "ex.debug-line",
16379
+ start,
16380
+ end,
16381
+ (_a = lineOptions == null ? void 0 : lineOptions.color) != null ? _a : Color.Black,
16382
+ lineOptions == null ? void 0 : lineOptions.lineWidth,
16383
+ lineOptions == null ? void 0 : lineOptions.dashed
16384
+ );
16385
+ this._webglCtx.restore();
16084
16386
  }
16085
16387
  /**
16086
- * Draw a debugging point to the context
16388
+ * Draw a debugging point to the graphics context
16389
+ *
16390
+ * Debugging draws are independent of scale/zoom
16087
16391
  * @param point
16088
16392
  * @param pointOptions
16089
16393
  */
16090
16394
  drawPoint(point2, pointOptions = { color: Color.Black, size: 5 }) {
16091
- this._webglCtx.draw("ex.point", point2, pointOptions.color, pointOptions.size);
16395
+ this._webglCtx.save();
16396
+ this._webglCtx.z = Debug.config.settings.z.point;
16397
+ this._webglCtx.draw("ex.debug-point", point2, pointOptions.color, pointOptions.size);
16398
+ this._webglCtx.restore();
16399
+ }
16400
+ /**
16401
+ * Draw a debugging circle to the graphics context
16402
+ *
16403
+ * Debugging draws are independent of scale/zoom
16404
+ */
16405
+ drawCircle(pos, radius, color, stroke, thickness) {
16406
+ this._webglCtx.save();
16407
+ this._webglCtx.z = Debug.config.settings.z.solid;
16408
+ this._webglCtx.draw("ex.debug-circle", pos, radius, color, stroke, thickness);
16409
+ this._webglCtx.restore();
16092
16410
  }
16411
+ /**
16412
+ * Draw some debugging text to the graphics context
16413
+ *
16414
+ * Debugging draws are independent of scale/zoom
16415
+ */
16093
16416
  drawText(text, pos) {
16417
+ this._webglCtx.save();
16418
+ this._webglCtx.z = Debug.config.settings.z.text;
16094
16419
  this._debugText.write(this._webglCtx, text, pos);
16420
+ this._webglCtx.restore();
16095
16421
  }
16096
16422
  }
16097
16423
  class ExcaliburGraphicsContextWebGL {
@@ -16120,7 +16446,6 @@ void main() {
16120
16446
  this._disposed = false;
16121
16447
  this._imageToWidth = /* @__PURE__ */ new Map();
16122
16448
  this._imageToHeight = /* @__PURE__ */ new Map();
16123
- this.debug = new ExcaliburGraphicsContextWebGLDebug(this);
16124
16449
  this._totalPostProcessorTime = 0;
16125
16450
  const {
16126
16451
  canvasElement,
@@ -16246,8 +16571,9 @@ void main() {
16246
16571
  this.register(new MaterialRenderer());
16247
16572
  this.register(new RectangleRenderer());
16248
16573
  this.register(new CircleRenderer());
16249
- this.register(new PointRenderer());
16250
- this.register(new LineRenderer());
16574
+ this.lazyRegister("ex.debug-circle", () => new DebugCircleRenderer());
16575
+ this.lazyRegister("ex.debug-point", () => new DebugPointRenderer());
16576
+ this.lazyRegister("ex.debug-line", () => new DebugLineRenderer());
16251
16577
  this.lazyRegister("ex.particle", () => new ParticleRenderer());
16252
16578
  this.register(
16253
16579
  new ImageRendererV2({
@@ -16295,6 +16621,7 @@ void main() {
16295
16621
  antialias: this.multiSampleAntialiasing,
16296
16622
  samples: this.samples
16297
16623
  });
16624
+ this.debug = new ExcaliburGraphicsContextWebGLDebug(this);
16298
16625
  }
16299
16626
  register(renderer) {
16300
16627
  this._renderers.set(renderer.type, renderer);
@@ -21362,12 +21689,12 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
21362
21689
  return 1 + Math.max(this.topLeft.getTreeDepth(), this.topRight.getTreeDepth(), this.bottomLeft.getTreeDepth(), this.bottomRight.getTreeDepth());
21363
21690
  }
21364
21691
  debug(ctx) {
21365
- this.bounds.draw(ctx, Color.Yellow);
21692
+ this.bounds.debug(ctx, { color: Color.Yellow });
21366
21693
  if (this._isDivided) {
21367
- this.topLeft.bounds.draw(ctx, Color.Yellow);
21368
- this.topRight.bounds.draw(ctx, Color.Yellow);
21369
- this.bottomLeft.bounds.draw(ctx, Color.Yellow);
21370
- this.bottomRight.bounds.draw(ctx, Color.Yellow);
21694
+ this.topLeft.bounds.debug(ctx, { color: Color.Yellow });
21695
+ this.topRight.bounds.debug(ctx, { color: Color.Yellow });
21696
+ this.bottomLeft.bounds.debug(ctx, { color: Color.Yellow });
21697
+ this.bottomRight.bounds.debug(ctx, { color: Color.Yellow });
21371
21698
  }
21372
21699
  }
21373
21700
  }
@@ -25260,7 +25587,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
25260
25587
  gfx.z = 999;
25261
25588
  if (showColliderBounds) {
25262
25589
  for (let i = 0; i < this.tiles.length; i++) {
25263
- this.tiles[i].bounds.draw(gfx);
25590
+ this.tiles[i].bounds.debug(gfx);
25264
25591
  }
25265
25592
  }
25266
25593
  gfx.restore();
@@ -25797,17 +26124,17 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
25797
26124
  for (let y = 0; y < this.rows + 1; y++) {
25798
26125
  const left = this.tileToWorld(vec(0, y));
25799
26126
  const right = this.tileToWorld(vec(this.columns, y));
25800
- gfx.drawLine(left, right, gridColor, gridWidth);
26127
+ gfx.debug.drawLine(left, right, { color: gridColor, lineWidth: gridWidth });
25801
26128
  }
25802
26129
  for (let x = 0; x < this.columns + 1; x++) {
25803
26130
  const top = this.tileToWorld(vec(x, 0));
25804
26131
  const bottom = this.tileToWorld(vec(x, this.rows));
25805
- gfx.drawLine(top, bottom, gridColor, gridWidth);
26132
+ gfx.debug.drawLine(top, bottom, { color: gridColor, lineWidth: gridWidth });
25806
26133
  }
25807
26134
  }
25808
26135
  if (showAll || showPosition) {
25809
26136
  for (const tile of this.tiles) {
25810
- gfx.drawCircle(this.tileToWorld(vec(tile.x, tile.y)), positionSize, positionColor);
26137
+ gfx.debug.drawCircle(this.tileToWorld(vec(tile.x, tile.y)), positionSize, positionColor);
25811
26138
  }
25812
26139
  }
25813
26140
  if (showAll || showColliderGeometry) {
@@ -26552,8 +26879,6 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
26552
26879
  let colliderComp;
26553
26880
  const colliderSettings = this._engine.debug.collider;
26554
26881
  const physicsSettings = this._engine.debug.physics;
26555
- let graphics;
26556
- const graphicsSettings = this._engine.debug.graphics;
26557
26882
  let debugDraw;
26558
26883
  let body;
26559
26884
  const bodySettings = this._engine.debug.body;
@@ -26588,7 +26913,6 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
26588
26913
  if (tx.coordPlane === CoordPlane.Screen) {
26589
26914
  this._graphicsContext.translate(this._engine.screen.contentArea.left, this._engine.screen.contentArea.top);
26590
26915
  }
26591
- this._graphicsContext.z = txSettings.debugZIndex;
26592
26916
  this._applyTransform(entity);
26593
26917
  if (tx) {
26594
26918
  if (txSettings.showAll || txSettings.showPosition) {
@@ -26624,13 +26948,6 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
26624
26948
  this._graphicsContext.drawLine(Vector.Zero, tx.scale.add(Vector.Zero), txSettings.scaleColor, 2);
26625
26949
  }
26626
26950
  }
26627
- graphics = entity.get(GraphicsComponent);
26628
- if (graphics) {
26629
- if (graphicsSettings.showAll || graphicsSettings.showBounds) {
26630
- const bounds = graphics.localBounds;
26631
- bounds.draw(this._graphicsContext, graphicsSettings.boundsColor);
26632
- }
26633
- }
26634
26951
  debugDraw = entity.get(DebugGraphicsComponent);
26635
26952
  if (debugDraw) {
26636
26953
  if (!debugDraw.useTransform) {
@@ -26670,7 +26987,6 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
26670
26987
  if (tx.coordPlane === CoordPlane.Screen) {
26671
26988
  this._graphicsContext.translate(this._engine.screen.contentArea.left, this._engine.screen.contentArea.top);
26672
26989
  }
26673
- this._graphicsContext.z = txSettings.debugZIndex;
26674
26990
  motion = entity.get(MotionComponent);
26675
26991
  if (motion) {
26676
26992
  if (motionSettings.showAll || motionSettings.showVelocity) {
@@ -26697,16 +27013,25 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
26697
27013
  for (const collider2 of colliders) {
26698
27014
  const bounds = collider2.bounds;
26699
27015
  const pos = vec(bounds.left, bounds.top);
26700
- this._graphicsContext.debug.drawRect(pos.x, pos.y, bounds.width, bounds.height, { color: colliderSettings.boundsColor });
27016
+ this._graphicsContext.debug.drawRect(pos.x, pos.y, bounds.width, bounds.height, {
27017
+ color: colliderSettings.boundsColor,
27018
+ dashed: true
27019
+ });
26701
27020
  if (colliderSettings.showAll || colliderSettings.showOwner) {
26702
27021
  this._graphicsContext.debug.drawText(`owner id(${collider2.owner.id})`, pos);
26703
27022
  }
26704
27023
  }
26705
- colliderComp.bounds.draw(this._graphicsContext, colliderSettings.boundsColor);
27024
+ colliderComp.bounds.debug(this._graphicsContext, {
27025
+ color: colliderSettings.boundsColor,
27026
+ dashed: true
27027
+ });
26706
27028
  } else if (collider) {
26707
27029
  const bounds = colliderComp.bounds;
26708
27030
  const pos = vec(bounds.left, bounds.top);
26709
- this._graphicsContext.debug.drawRect(pos.x, pos.y, bounds.width, bounds.height, { color: colliderSettings.boundsColor });
27031
+ this._graphicsContext.debug.drawRect(pos.x, pos.y, bounds.width, bounds.height, {
27032
+ color: colliderSettings.boundsColor,
27033
+ dashed: true
27034
+ });
26710
27035
  if (colliderSettings.showAll || colliderSettings.showOwner) {
26711
27036
  this._graphicsContext.debug.drawText(`owner id(${colliderComp.owner.id})`, pos);
26712
27037
  }
@@ -26745,14 +27070,13 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
26745
27070
  this._graphicsContext.save();
26746
27071
  this._camera.draw(this._graphicsContext);
26747
27072
  if (cameraSettings.showAll || cameraSettings.showFocus) {
26748
- this._graphicsContext.drawCircle(this._camera.pos, 4, cameraSettings.focusColor);
27073
+ this._graphicsContext.debug.drawCircle(this._camera.pos, 4, cameraSettings.focusColor);
26749
27074
  }
26750
27075
  if (cameraSettings.showAll || cameraSettings.showZoom) {
26751
27076
  this._graphicsContext.debug.drawText(`zoom(${this._camera.zoom})`, this._camera.pos);
26752
27077
  }
26753
27078
  this._graphicsContext.restore();
26754
27079
  }
26755
- this._graphicsContext.flush();
26756
27080
  }
26757
27081
  postupdate(engine, elapsed) {
26758
27082
  if (this._engine.isDebug) {
@@ -26891,7 +27215,9 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
26891
27215
  const collider = colliders[i];
26892
27216
  const maybePointer = this._entityToPointer.get(collider.owner);
26893
27217
  if (maybePointer && (maybePointer.useColliderShape || this.overrideUseColliderShape)) {
26894
- this._pointerEventDispatcher.addPointerToObject(collider.owner, pointerId);
27218
+ if (collider.contains(pos.worldPos)) {
27219
+ this._pointerEventDispatcher.addPointerToObject(collider.owner, pointerId);
27220
+ }
26895
27221
  }
26896
27222
  }
26897
27223
  const graphics = this._graphicsHashGrid.query(pos.worldPos);
@@ -28771,6 +29097,20 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
28771
29097
  */
28772
29098
  prevFrame: new FrameStats()
28773
29099
  };
29100
+ this.settings = {
29101
+ text: {
29102
+ foreground: Color.Black,
29103
+ background: Color.Transparent,
29104
+ border: Color.Transparent
29105
+ },
29106
+ z: {
29107
+ text: Number.POSITIVE_INFINITY,
29108
+ point: Number.MAX_SAFE_INTEGER - 1,
29109
+ ray: Number.MAX_SAFE_INTEGER - 1,
29110
+ dashed: Number.MAX_SAFE_INTEGER - 2,
29111
+ solid: Number.MAX_SAFE_INTEGER - 3
29112
+ }
29113
+ };
28774
29114
  this.filter = {
28775
29115
  /**
28776
29116
  * Toggle filter on or off (default off) must be on for DebugDraw to use filters
@@ -28792,7 +29132,6 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
28792
29132
  };
28793
29133
  this.transform = {
28794
29134
  showAll: false,
28795
- debugZIndex: 1e7,
28796
29135
  showPosition: false,
28797
29136
  showPositionLabel: false,
28798
29137
  positionColor: Color.Yellow,
@@ -28814,8 +29153,8 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
28814
29153
  showOwner: false,
28815
29154
  showGeometry: true,
28816
29155
  geometryColor: Color.Green,
28817
- geometryLineWidth: 1,
28818
- geometryPointSize: 0.5
29156
+ geometryLineWidth: 2,
29157
+ geometryPointSize: 2
28819
29158
  };
28820
29159
  this.physics = {
28821
29160
  showAll: false,
@@ -28823,7 +29162,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
28823
29162
  showCollisionNormals: false,
28824
29163
  collisionNormalColor: Color.Cyan,
28825
29164
  showCollisionContacts: true,
28826
- contactSize: 2,
29165
+ contactSize: 10,
28827
29166
  collisionContactColor: Color.Red
28828
29167
  };
28829
29168
  this.motion = {
@@ -28869,6 +29208,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
28869
29208
  };
28870
29209
  this._engine = engine;
28871
29210
  this.colorBlindMode = new ColorBlindFlags(this._engine);
29211
+ Debug.registerDebugConfig(this);
28872
29212
  }
28873
29213
  /**
28874
29214
  * Switch the current excalibur clock with the {@apilink TestClock} and return
@@ -30193,6 +30533,7 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
30193
30533
  this._suppressPlayButton = true;
30194
30534
  }
30195
30535
  this._logger = Logger.getInstance();
30536
+ this.debug = new DebugConfig(this);
30196
30537
  if (this._logger.defaultLevel === LogLevel.Debug) {
30197
30538
  detector.logBrowserFeatures();
30198
30539
  }
@@ -30356,7 +30697,6 @@ Read more about this issue at https://excaliburjs.com/docs/performance`
30356
30697
  };
30357
30698
  mergeDeep(this.physics, options.physics);
30358
30699
  }
30359
- this.debug = new DebugConfig(this);
30360
30700
  this.director = new Director(this, options.scenes);
30361
30701
  this.director.events.pipe(this.events);
30362
30702
  this._initialize(options);
@@ -33102,7 +33442,7 @@ Read more about this issue at https://excaliburjs.com/docs/performance`
33102
33442
  this._count += count;
33103
33443
  }
33104
33444
  }
33105
- const EX_VERSION = "0.32.0-alpha.1570+3b683c5";
33445
+ const EX_VERSION = "0.32.0-alpha.1572+72a3430";
33106
33446
  polyfill();
33107
33447
  exports2.ActionCompleteEvent = ActionCompleteEvent;
33108
33448
  exports2.ActionContext = ActionContext;