excalibur 0.32.0-alpha.1563 → 0.32.0-alpha.1565

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/CHANGELOG.md CHANGED
@@ -15,6 +15,18 @@ This project adheres to [Semantic Versioning](http://semver.org/).
15
15
 
16
16
  ### Added
17
17
 
18
+ - Added a convenience parameter to set the initial graphics or material in an Actor
19
+ ```typescript
20
+ const cloudSprite = cloud.toSprite();
21
+ const swirlMaterial = game.graphicsContext.createMaterial({
22
+ name: 'swirl',
23
+ fragmentSource
24
+ });
25
+ const actor = new ex.Actor({
26
+ graphic: cloudSprite,
27
+ material: swirlMaterial
28
+ });
29
+ ```
18
30
  - Simpler easing functions of the form `(currentTime: number) => number` instead of the 4 parameter legacy ones
19
31
  - Support for disabling integration for all offscreen entities, or on a per entity basis
20
32
 
@@ -38,6 +50,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
38
50
 
39
51
  ### Fixed
40
52
 
53
+ - Fixed issue where overriding built in uniforms and graphics no longer worked as v0.30.x
41
54
  - Fixed issue where clearSchedule during a scheduled callback could cause a cb to be skipped
42
55
  - Fixed issue where the Loader could run twice even if already loaded when included in the scene loader.
43
56
  - Fixed issue where pixel ratio was accidentally doubled during load if the loader was included in the scene loader.
@@ -48,6 +61,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
48
61
 
49
62
  ### Updates
50
63
 
64
+ - When overriding a built-in uniform/graphic there is now a warning in dev excalibur builds
51
65
  - Camera zoom and move now support new easing functions form
52
66
  - MoveTo/MoveBy actions now support new easing function form
53
67
  - Transitions now support new easing functions form
@@ -24,6 +24,7 @@ import { ActionsComponent } from './Actions/ActionsComponent';
24
24
  import { CoordPlane } from './Math/coord-plane';
25
25
  import type { EventKey, Handler, Subscription } from './EventEmitter';
26
26
  import { EventEmitter } from './EventEmitter';
27
+ import type { Graphic, Material } from './Graphics';
27
28
  /**
28
29
  * Type guard for checking if something is an Actor
29
30
  * @param x
@@ -82,6 +83,14 @@ export type ActorArgs = ColliderArgs & {
82
83
  * If a width/height or a radius was set a default graphic will be added
83
84
  */
84
85
  color?: Color;
86
+ /**
87
+ * Optionally set the default graphic
88
+ */
89
+ graphic?: Graphic;
90
+ /**
91
+ * Optionally set the default material
92
+ */
93
+ material?: Material;
85
94
  /**
86
95
  * Optionally set the color of an actor, only used if no graphics are present
87
96
  * If a width/height or a radius was set a default graphic will be added
@@ -75,6 +75,7 @@ export interface MaterialImageOptions {
75
75
  filtering?: ImageFiltering;
76
76
  }
77
77
  export declare class Material {
78
+ static BuiltInUniforms: string[];
78
79
  private _logger;
79
80
  private _name;
80
81
  private _shader;
@@ -92,6 +93,7 @@ export declare class Material {
92
93
  set color(c: Color);
93
94
  get name(): string;
94
95
  get isUsingScreenTexture(): boolean;
96
+ get isOverridingGraphic(): boolean;
95
97
  update(callback: (shader: Shader) => any): void;
96
98
  getShader(): Shader | null;
97
99
  addImageSource(samplerName: string, image: ImageSource): void;
@@ -1,4 +1,4 @@
1
- /*! excalibur - 0.32.0-alpha.1563+eadef91 - 2025-11-24
1
+ /*! excalibur - 0.32.0-alpha.1565+76be137 - 2025-11-24
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
@@ -14358,7 +14358,7 @@ void main() {
14358
14358
  v_screenuv = a_screenuv;
14359
14359
  }
14360
14360
  `;
14361
- class Material {
14361
+ const _Material = class _Material2 {
14362
14362
  constructor(options) {
14363
14363
  this._logger = Logger.getInstance();
14364
14364
  this._color = Color.Transparent;
@@ -14380,6 +14380,25 @@ void main() {
14380
14380
  } else {
14381
14381
  this._logger.warn(`Material ${name} was created in 2D Canvas mode, currently only WebGL is supported`);
14382
14382
  }
14383
+ {
14384
+ if (this.images.u_graphic) {
14385
+ this._logger.warn(
14386
+ `Material named "${this.name}" is overriding built in image u_graphic, is this on purpose? If so ignore this warning.`
14387
+ );
14388
+ }
14389
+ if (this.images.u_screen_texture) {
14390
+ this._logger.warn(
14391
+ `Material named "${this.name}" is overriding built in image u_screen_texture, is this on purpose? If so ignore this warning.`
14392
+ );
14393
+ }
14394
+ for (const uniform of Object.keys(this._uniforms)) {
14395
+ if (_Material2.BuiltInUniforms.includes(uniform)) {
14396
+ this._logger.warn(
14397
+ `Material named "${this.name}" is overriding built in uniform ${uniform}, is this on purpose? If so ignore this warning.`
14398
+ );
14399
+ }
14400
+ }
14401
+ }
14383
14402
  }
14384
14403
  _initialize(graphicsContextWebGL) {
14385
14404
  if (this._initialized) {
@@ -14416,6 +14435,9 @@ void main() {
14416
14435
  get isUsingScreenTexture() {
14417
14436
  return this._fragmentSource.includes("u_screen_texture");
14418
14437
  }
14438
+ get isOverridingGraphic() {
14439
+ return !!this._images.u_graphic;
14440
+ }
14419
14441
  update(callback) {
14420
14442
  if (this._shader) {
14421
14443
  this._shader.use();
@@ -14427,6 +14449,18 @@ void main() {
14427
14449
  }
14428
14450
  addImageSource(samplerName, image) {
14429
14451
  this._shader.addImageSource(samplerName, image);
14452
+ {
14453
+ if (this.images.u_graphic) {
14454
+ this._logger.warn(
14455
+ `Material named "${this.name}" is overriding built in image u_graphic, is this on purpose? If so ignore this warning.`
14456
+ );
14457
+ }
14458
+ if (this.images.u_screen_texture) {
14459
+ this._logger.warn(
14460
+ `Material named "${this.name}" is overriding built in image u_screen_texture, is this on purpose? If so ignore this warning.`
14461
+ );
14462
+ }
14463
+ }
14430
14464
  }
14431
14465
  removeImageSource(samplerName) {
14432
14466
  this._shader.removeImageSource(samplerName);
@@ -14439,7 +14473,19 @@ void main() {
14439
14473
  throw Error(`Material ${this.name} not yet initialized, use the ExcaliburGraphicsContext.createMaterial() to work around this.`);
14440
14474
  }
14441
14475
  }
14442
- }
14476
+ };
14477
+ _Material.BuiltInUniforms = [
14478
+ "u_time_ms",
14479
+ "u_opacity",
14480
+ "u_resolution",
14481
+ "u_graphic_resolution",
14482
+ "u_size",
14483
+ "u_matrix",
14484
+ "u_transform",
14485
+ "u_graphic",
14486
+ "u_screen_texture"
14487
+ ];
14488
+ let Material = _Material;
14443
14489
  const _Debug = class _Debug2 {
14444
14490
  static registerGraphicsContext(ctx) {
14445
14491
  _Debug2._ctx = ctx;
@@ -15555,7 +15601,7 @@ void main() {
15555
15601
  this._gl = null;
15556
15602
  }
15557
15603
  draw(image, sx, sy, swidth, sheight, dx, dy, dwidth, dheight) {
15558
- var _a, _b, _c, _d;
15604
+ var _a, _b, _c, _d, _e;
15559
15605
  const gl = this._gl;
15560
15606
  const material = this._context.material;
15561
15607
  if (!material) {
@@ -15620,7 +15666,7 @@ void main() {
15620
15666
  vertexBuffer[vertexIndex++] = uvy1;
15621
15667
  vertexBuffer[vertexIndex++] = screenUVX1;
15622
15668
  vertexBuffer[vertexIndex++] = screenUVY1;
15623
- const texture = this._addImageAsTexture(image);
15669
+ let texture = this._addImageAsTexture(image);
15624
15670
  material.use();
15625
15671
  this._layout.shader = shader;
15626
15672
  this._layout.use(true);
@@ -15631,6 +15677,11 @@ void main() {
15631
15677
  shader.trySetUniformFloatVector("u_size", vec(sw, sh));
15632
15678
  shader.trySetUniformMatrix("u_matrix", this._context.ortho);
15633
15679
  shader.trySetUniformMatrix("u_transform", transform.to4x4());
15680
+ if (material.isOverridingGraphic) {
15681
+ if ((_e = material.images.u_graphic) == null ? void 0 : _e.image) {
15682
+ texture = this._addImageAsTexture(material.images.u_graphic.image);
15683
+ }
15684
+ }
15634
15685
  gl.activeTexture(gl.TEXTURE0 + 0);
15635
15686
  gl.bindTexture(gl.TEXTURE_2D, texture);
15636
15687
  shader.trySetUniformInt("u_graphic", 0);
@@ -19416,7 +19467,9 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
19416
19467
  anchor,
19417
19468
  offset,
19418
19469
  collisionType,
19419
- collisionGroup
19470
+ collisionGroup,
19471
+ graphic,
19472
+ material
19420
19473
  } = {
19421
19474
  ...config
19422
19475
  };
@@ -19487,6 +19540,12 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
19487
19540
  }
19488
19541
  }
19489
19542
  this.graphics.isVisible = visible != null ? visible : true;
19543
+ if (graphic) {
19544
+ this.graphics.use(graphic);
19545
+ }
19546
+ if (material) {
19547
+ this.graphics.material = material;
19548
+ }
19490
19549
  }
19491
19550
  /**
19492
19551
  * Gets the position vector of the actor in pixels
@@ -33043,7 +33102,7 @@ Read more about this issue at https://excaliburjs.com/docs/performance`
33043
33102
  this._count += count;
33044
33103
  }
33045
33104
  }
33046
- const EX_VERSION = "0.32.0-alpha.1563+eadef91";
33105
+ const EX_VERSION = "0.32.0-alpha.1565+76be137";
33047
33106
  polyfill();
33048
33107
  exports2.ActionCompleteEvent = ActionCompleteEvent;
33049
33108
  exports2.ActionContext = ActionContext;
@@ -1,4 +1,4 @@
1
- /*! excalibur - 0.32.0-alpha.1563+eadef91 - 2025-11-24
1
+ /*! excalibur - 0.32.0-alpha.1565+76be137 - 2025-11-24
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
@@ -14358,7 +14358,7 @@ void main() {
14358
14358
  v_screenuv = a_screenuv;
14359
14359
  }
14360
14360
  `;
14361
- class Material {
14361
+ const _Material = class _Material2 {
14362
14362
  constructor(options) {
14363
14363
  this._logger = Logger.getInstance();
14364
14364
  this._color = Color.Transparent;
@@ -14380,6 +14380,25 @@ void main() {
14380
14380
  } else {
14381
14381
  this._logger.warn(`Material ${name} was created in 2D Canvas mode, currently only WebGL is supported`);
14382
14382
  }
14383
+ {
14384
+ if (this.images.u_graphic) {
14385
+ this._logger.warn(
14386
+ `Material named "${this.name}" is overriding built in image u_graphic, is this on purpose? If so ignore this warning.`
14387
+ );
14388
+ }
14389
+ if (this.images.u_screen_texture) {
14390
+ this._logger.warn(
14391
+ `Material named "${this.name}" is overriding built in image u_screen_texture, is this on purpose? If so ignore this warning.`
14392
+ );
14393
+ }
14394
+ for (const uniform of Object.keys(this._uniforms)) {
14395
+ if (_Material2.BuiltInUniforms.includes(uniform)) {
14396
+ this._logger.warn(
14397
+ `Material named "${this.name}" is overriding built in uniform ${uniform}, is this on purpose? If so ignore this warning.`
14398
+ );
14399
+ }
14400
+ }
14401
+ }
14383
14402
  }
14384
14403
  _initialize(graphicsContextWebGL) {
14385
14404
  if (this._initialized) {
@@ -14416,6 +14435,9 @@ void main() {
14416
14435
  get isUsingScreenTexture() {
14417
14436
  return this._fragmentSource.includes("u_screen_texture");
14418
14437
  }
14438
+ get isOverridingGraphic() {
14439
+ return !!this._images.u_graphic;
14440
+ }
14419
14441
  update(callback) {
14420
14442
  if (this._shader) {
14421
14443
  this._shader.use();
@@ -14427,6 +14449,18 @@ void main() {
14427
14449
  }
14428
14450
  addImageSource(samplerName, image) {
14429
14451
  this._shader.addImageSource(samplerName, image);
14452
+ {
14453
+ if (this.images.u_graphic) {
14454
+ this._logger.warn(
14455
+ `Material named "${this.name}" is overriding built in image u_graphic, is this on purpose? If so ignore this warning.`
14456
+ );
14457
+ }
14458
+ if (this.images.u_screen_texture) {
14459
+ this._logger.warn(
14460
+ `Material named "${this.name}" is overriding built in image u_screen_texture, is this on purpose? If so ignore this warning.`
14461
+ );
14462
+ }
14463
+ }
14430
14464
  }
14431
14465
  removeImageSource(samplerName) {
14432
14466
  this._shader.removeImageSource(samplerName);
@@ -14439,7 +14473,19 @@ void main() {
14439
14473
  throw Error(`Material ${this.name} not yet initialized, use the ExcaliburGraphicsContext.createMaterial() to work around this.`);
14440
14474
  }
14441
14475
  }
14442
- }
14476
+ };
14477
+ _Material.BuiltInUniforms = [
14478
+ "u_time_ms",
14479
+ "u_opacity",
14480
+ "u_resolution",
14481
+ "u_graphic_resolution",
14482
+ "u_size",
14483
+ "u_matrix",
14484
+ "u_transform",
14485
+ "u_graphic",
14486
+ "u_screen_texture"
14487
+ ];
14488
+ let Material = _Material;
14443
14489
  const _Debug = class _Debug2 {
14444
14490
  static registerGraphicsContext(ctx) {
14445
14491
  _Debug2._ctx = ctx;
@@ -15555,7 +15601,7 @@ void main() {
15555
15601
  this._gl = null;
15556
15602
  }
15557
15603
  draw(image, sx, sy, swidth, sheight, dx, dy, dwidth, dheight) {
15558
- var _a, _b, _c, _d;
15604
+ var _a, _b, _c, _d, _e;
15559
15605
  const gl = this._gl;
15560
15606
  const material = this._context.material;
15561
15607
  if (!material) {
@@ -15620,7 +15666,7 @@ void main() {
15620
15666
  vertexBuffer[vertexIndex++] = uvy1;
15621
15667
  vertexBuffer[vertexIndex++] = screenUVX1;
15622
15668
  vertexBuffer[vertexIndex++] = screenUVY1;
15623
- const texture = this._addImageAsTexture(image);
15669
+ let texture = this._addImageAsTexture(image);
15624
15670
  material.use();
15625
15671
  this._layout.shader = shader;
15626
15672
  this._layout.use(true);
@@ -15631,6 +15677,11 @@ void main() {
15631
15677
  shader.trySetUniformFloatVector("u_size", vec(sw, sh));
15632
15678
  shader.trySetUniformMatrix("u_matrix", this._context.ortho);
15633
15679
  shader.trySetUniformMatrix("u_transform", transform.to4x4());
15680
+ if (material.isOverridingGraphic) {
15681
+ if ((_e = material.images.u_graphic) == null ? void 0 : _e.image) {
15682
+ texture = this._addImageAsTexture(material.images.u_graphic.image);
15683
+ }
15684
+ }
15634
15685
  gl.activeTexture(gl.TEXTURE0 + 0);
15635
15686
  gl.bindTexture(gl.TEXTURE_2D, texture);
15636
15687
  shader.trySetUniformInt("u_graphic", 0);
@@ -19416,7 +19467,9 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
19416
19467
  anchor,
19417
19468
  offset,
19418
19469
  collisionType,
19419
- collisionGroup
19470
+ collisionGroup,
19471
+ graphic,
19472
+ material
19420
19473
  } = {
19421
19474
  ...config
19422
19475
  };
@@ -19487,6 +19540,12 @@ If you want to do custom drawing, use Actor.graphics, or any onPreDraw or onPost
19487
19540
  }
19488
19541
  }
19489
19542
  this.graphics.isVisible = visible != null ? visible : true;
19543
+ if (graphic) {
19544
+ this.graphics.use(graphic);
19545
+ }
19546
+ if (material) {
19547
+ this.graphics.material = material;
19548
+ }
19490
19549
  }
19491
19550
  /**
19492
19551
  * Gets the position vector of the actor in pixels
@@ -33043,7 +33102,7 @@ Read more about this issue at https://excaliburjs.com/docs/performance`
33043
33102
  this._count += count;
33044
33103
  }
33045
33104
  }
33046
- const EX_VERSION = "0.32.0-alpha.1563+eadef91";
33105
+ const EX_VERSION = "0.32.0-alpha.1565+76be137";
33047
33106
  polyfill();
33048
33107
  exports2.ActionCompleteEvent = ActionCompleteEvent;
33049
33108
  exports2.ActionContext = ActionContext;