melonjs 20.10.0 → 20.10.1

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 +1 @@
1
- {"version":3,"file":"camera2d.d.ts","sourceRoot":"","sources":["../../src/camera/camera2d.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAgB,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAc,MAAM,wBAAwB,CAAC;AAE5D,OAAO,UAAU,MAAM,+BAA+B,CAAC;AAcvD,OAAO,KAAK,YAAY,MAAM,4BAA4B,CAAC;AAK3D;;;;GAIG;AAEH,UAAU,QAAQ;IACjB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACjB,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;CACjB;AAID;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,UAAU;IAC/C;;;;;;;OAOG;IACH,MAAM,CAAC,aAAa,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,OAAO,CAAO;IAEtD;;;;;;OAMG;IACH,IAAI,EAAE,QAAQ,CAAC;IAEf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,YAAY,EAAE,OAAO,CAAC;IAEtB;;;;;;;;;;;;;;;OAeG;IACH,OAAO,EAAE,MAAM,CAA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;;;;;OAKG;IACH,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,GAAE,OAAsB,GAAG,OAAO;IA0BrE;;;;;;OAMG;IACH,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ;IAS1D;;;;;;OAMG;IACH,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ;CAyU1D"}
package/build/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - 20.10.0
2
+ * melonJS Game Engine - 20.10.1
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -16940,6 +16940,29 @@ var Camera2d = class extends Renderable {
16940
16940
  fx.draw(renderer, this.width, this.height);
16941
16941
  }
16942
16942
  }
16943
+ /**
16944
+ * The built-in {@link Camera2d#colorMatrix} as the effect that applies it,
16945
+ * made on first need and kept, and set to the current matrix.
16946
+ *
16947
+ * `draw` appends it last in the camera's chain for the frame. The
16948
+ * renderer's warm-up calls this too, once a stage has been built, so the
16949
+ * effect exists, and is warmed where `draw` will run it, before the frame
16950
+ * that first needs it rather than inside that frame.
16951
+ * @param renderer - the renderer the camera draws with
16952
+ * @returns the effect, or null while the matrix is identity
16953
+ * @ignore
16954
+ * @internal
16955
+ */
16956
+ _syncColorMatrixEffect(renderer) {
16957
+ if (this.colorMatrix.isIdentity()) {
16958
+ return null;
16959
+ }
16960
+ if (!this._colorMatrixEffect) {
16961
+ this._colorMatrixEffect = new ColorMatrixEffect(renderer);
16962
+ }
16963
+ this._colorMatrixEffect.reset().multiply(this.colorMatrix);
16964
+ return this._colorMatrixEffect;
16965
+ }
16943
16966
  /**
16944
16967
  * draw all objects visible in this viewport
16945
16968
  * @ignore
@@ -16955,12 +16978,9 @@ var Camera2d = class extends Renderable {
16955
16978
  const containerOffsetY = isNonDefault ? container.pos.y : 0;
16956
16979
  const translateX = this.pos.x + this.offset.x + containerOffsetX;
16957
16980
  const translateY = this.pos.y + this.offset.y + containerOffsetY;
16958
- if (!this.colorMatrix.isIdentity()) {
16959
- if (!this._colorMatrixEffect) {
16960
- this._colorMatrixEffect = new ColorMatrixEffect(renderer);
16961
- }
16962
- this._colorMatrixEffect.reset().multiply(this.colorMatrix);
16963
- this.postEffects.push(this._colorMatrixEffect);
16981
+ const colorMatrixEffect = this._syncColorMatrixEffect(renderer);
16982
+ if (colorMatrixEffect !== null) {
16983
+ this.postEffects.push(colorMatrixEffect);
16964
16984
  }
16965
16985
  const usePostEffect = r.beginPostEffect(this);
16966
16986
  this._applyContainerViewTransform(container, translateX, translateY);
@@ -23341,19 +23361,157 @@ var Renderer = class _Renderer {
23341
23361
  }
23342
23362
  /**
23343
23363
  * Run the warm-ups queued by {@link Renderer#_queueWarm}.
23364
+ * @param {boolean} [stage=false] - true when a stage is being entered,
23365
+ * which warms its cameras' grading as well
23366
+ * @returns {Promise<void>[]} what they started that is still being built
23367
+ * @ignore
23368
+ * @internal
23369
+ */
23370
+ _flushWarm(stage = false) {
23371
+ const hosts = this._warmHosts === void 0 ? [] : [...this._warmHosts];
23372
+ if (hosts.length === 0 && !stage) {
23373
+ return [];
23374
+ }
23375
+ this._warmHosts?.clear();
23376
+ const cameras = stage || hosts.some((host) => {
23377
+ return host?._postEffectManaged === true;
23378
+ });
23379
+ this._warmFog = this._warmFogStates();
23380
+ try {
23381
+ return this._collectWarms(() => {
23382
+ for (const host of hosts) {
23383
+ try {
23384
+ this._warmRenderable(host);
23385
+ } catch {
23386
+ }
23387
+ }
23388
+ if (cameras) {
23389
+ try {
23390
+ this._warmCameraColorMatrices();
23391
+ } catch {
23392
+ }
23393
+ }
23394
+ });
23395
+ } finally {
23396
+ this._warmFog = void 0;
23397
+ }
23398
+ }
23399
+ /**
23400
+ * Run `warm` and hand back what it started that is still being built,
23401
+ * as one promise each. Every warm-up on this base is done by the time it
23402
+ * returns, so nothing.
23403
+ * @param {Function} warm - issues the warm-ups
23404
+ * @returns {Promise<void>[]} the warm-ups still on their way
23344
23405
  * @ignore
23345
23406
  * @internal
23346
23407
  */
23347
- _flushWarm() {
23348
- const hosts = [...this._warmHosts];
23349
- this._warmHosts.clear();
23350
- for (const host of hosts) {
23408
+ _collectWarms(warm) {
23409
+ warm();
23410
+ return [];
23411
+ }
23412
+ /**
23413
+ * Run the queued warm-ups now, and say when they are built.
23414
+ *
23415
+ * What a state change waits on before drawing the stage it has just built
23416
+ * (see `state.change`). A warm-up on its own does not keep the first
23417
+ * frame from compiling: the frame comes some milliseconds after the stage
23418
+ * is built, and a pipeline still compiling then is compiled again, on the
23419
+ * spot, by the draw that needs it. Holding the frame until they land is
23420
+ * what lets them do their job.
23421
+ *
23422
+ * Only what this flush asked for is waited on, not every warm-up in
23423
+ * flight: one a game started for later (an effect attached ahead of
23424
+ * time, a level's own preload) is not this stage's to wait for.
23425
+ * @returns {Promise<void>|undefined} settles once they are built, or
23426
+ * `undefined` when nothing is being built and the frame can draw now
23427
+ * @ignore
23428
+ * @internal
23429
+ */
23430
+ _whenWarmed() {
23431
+ let waits;
23432
+ try {
23433
+ waits = this._flushWarm(true);
23434
+ } catch {
23435
+ return void 0;
23436
+ }
23437
+ if (waits.length === 0) {
23438
+ return void 0;
23439
+ }
23440
+ return Promise.all(waits).then(() => {
23441
+ });
23442
+ }
23443
+ /**
23444
+ * Warm each of the current stage's cameras for its built-in colour
23445
+ * matrix.
23446
+ *
23447
+ * A camera applies `colorMatrix` as one more effect at the end of its
23448
+ * chain, but it built that effect inside its own `draw`, on the first
23449
+ * frame the matrix was not identity, and appends it for that frame only.
23450
+ * Nothing ever attached it, so nothing warmed it: its program (WebGL) or
23451
+ * its pipelines (WebGPU) were built in the first frame of a stage that
23452
+ * grades its camera. Made here instead, once the stage has been built,
23453
+ * and warmed where `draw` runs it, last in the camera's chain.
23454
+ * @ignore
23455
+ * @internal
23456
+ */
23457
+ _warmCameraColorMatrices() {
23458
+ const cameras = state_default.current()?.cameras;
23459
+ if (cameras === void 0) {
23460
+ return;
23461
+ }
23462
+ for (const camera of cameras.values()) {
23463
+ const effect = camera._syncColorMatrixEffect?.(this);
23464
+ if (effect == null) {
23465
+ continue;
23466
+ }
23467
+ const effects = camera.postEffects;
23468
+ effects.push(effect);
23351
23469
  try {
23352
- this._warmRenderable(host);
23353
- } catch {
23470
+ this._warmPostEffects(camera);
23471
+ } finally {
23472
+ effects.splice(effects.indexOf(effect), 1);
23354
23473
  }
23355
23474
  }
23356
23475
  }
23476
+ /**
23477
+ * Whether the meshes being warmed will draw with fog, without it, or both.
23478
+ *
23479
+ * Fog is a pipeline variant, and which one a mesh draws with is decided by
23480
+ * the camera drawing it: each camera installs its own fog on the renderer
23481
+ * as it starts drawing ({@link Renderer#setFog}), and the frame clears it.
23482
+ * So the renderer's own value is no answer here. A warm-up runs between
23483
+ * frames, while the renderer still holds the fog of whichever camera drew
23484
+ * LAST, which after a state change is the previous screen's: a loading
23485
+ * screen has none, so every mesh of a fogged scene was warmed without it
23486
+ * and then compiled with it, synchronously, on its first frame.
23487
+ *
23488
+ * Asked of the current stage's cameras instead, through the same
23489
+ * `_fog3dState` the draw installs, so the warm-up and the draw cannot
23490
+ * disagree. A stage with a fogged camera and a clear one (a minimap, say)
23491
+ * warms both variants. Fog switched on in a later frame than the scene was
23492
+ * built in is not seen here, and is built on that frame as before.
23493
+ * @returns {boolean[]} the fog states to warm, each `true` for fogged
23494
+ * @ignore
23495
+ * @internal
23496
+ */
23497
+ _warmFogStates() {
23498
+ let fogged = false;
23499
+ let clear = false;
23500
+ const cameras = state_default.current()?.cameras;
23501
+ if (cameras !== void 0) {
23502
+ for (const camera of cameras.values()) {
23503
+ if (camera._fog3dState?.(this) != null) {
23504
+ fogged = true;
23505
+ } else {
23506
+ clear = true;
23507
+ }
23508
+ }
23509
+ }
23510
+ if (!fogged && !clear) {
23511
+ return [this._fog3d != null];
23512
+ }
23513
+ return clear && fogged ? [false, true] : [fogged];
23514
+ }
23357
23515
  /**
23358
23516
  * Warm one renderable, and everything under it when it is a container:
23359
23517
  * adding a container to the world brings its whole subtree in with it,
@@ -40204,6 +40362,8 @@ var _transitionConfig = {
40204
40362
  duration: 0
40205
40363
  };
40206
40364
  var _onSwitchComplete = null;
40365
+ var MAX_WARM_HOLD = 1500;
40366
+ var _heldSwitch = null;
40207
40367
  var _extraArgs = null;
40208
40368
  var _pauseTime = 0;
40209
40369
  var _freezeTimer = null;
@@ -40257,9 +40417,17 @@ function _renderFrame(time) {
40257
40417
  }
40258
40418
  }
40259
40419
  function _stopRunLoop() {
40420
+ _endHeldSwitches();
40260
40421
  globalThis.cancelAnimationFrame(_animFrameId);
40261
40422
  _animFrameId = -1;
40262
40423
  }
40424
+ function _endHeldSwitches() {
40425
+ while (_heldSwitch !== null) {
40426
+ const finish = _heldSwitch;
40427
+ _heldSwitch = null;
40428
+ finish();
40429
+ }
40430
+ }
40263
40431
  function _switchState(stateId) {
40264
40432
  _stopRunLoop();
40265
40433
  if (_stages[_state]) {
@@ -40267,17 +40435,45 @@ function _switchState(stateId) {
40267
40435
  }
40268
40436
  if (_stages[stateId]) {
40269
40437
  _state = stateId;
40438
+ const onSwitchComplete = _onSwitchComplete;
40439
+ _onSwitchComplete = null;
40440
+ const finish = () => {
40441
+ try {
40442
+ emit(STATE_CHANGE);
40443
+ } finally {
40444
+ onSwitchComplete?.();
40445
+ }
40446
+ };
40270
40447
  if (_extraArgs) {
40271
40448
  _stages[_state].stage.reset(_app2, ..._extraArgs);
40272
40449
  } else {
40273
40450
  _stages[_state].stage.reset(_app2);
40274
40451
  }
40275
- _startRunLoop();
40276
- emit(STATE_CHANGE);
40277
- if (_onSwitchComplete) {
40278
- _onSwitchComplete();
40279
- _onSwitchComplete = null;
40452
+ const renderer = _app2?.renderer;
40453
+ const warmed = renderer?._whenWarmed?.();
40454
+ _endHeldSwitches();
40455
+ if (warmed === void 0) {
40456
+ _startRunLoop();
40457
+ finish();
40458
+ return;
40280
40459
  }
40460
+ _heldSwitch = finish;
40461
+ let cap;
40462
+ const start = () => {
40463
+ clearTimeout(cap);
40464
+ if (_heldSwitch !== finish) {
40465
+ return;
40466
+ }
40467
+ _heldSwitch = null;
40468
+ _startRunLoop();
40469
+ finish();
40470
+ };
40471
+ void Promise.race([
40472
+ warmed,
40473
+ new Promise((resolve) => {
40474
+ cap = setTimeout(resolve, MAX_WARM_HOLD);
40475
+ })
40476
+ ]).then(start, start);
40281
40477
  }
40282
40478
  }
40283
40479
  var _app2;
@@ -40461,7 +40657,7 @@ var state3 = {
40461
40657
  * @returns true if a "process is running"
40462
40658
  */
40463
40659
  isRunning() {
40464
- return _animFrameId !== -1;
40660
+ return _animFrameId !== -1 || _heldSwitch !== null;
40465
40661
  },
40466
40662
  /**
40467
40663
  * Return the pause state of the state manager
@@ -48910,16 +49106,36 @@ var WebGLRenderer = class _WebGLRenderer extends Renderer {
48910
49106
  return;
48911
49107
  }
48912
49108
  this._meshEffectWarmQueue ??= [];
48913
- for (const fx of effects) {
48914
- this._meshEffectWarmQueue.push(batcher, fx);
49109
+ for (const fog of this._warmFog ?? [this._fog3d != null]) {
49110
+ const fogDefine = fog ? "#define FOG\n" : "";
49111
+ for (const fx of effects) {
49112
+ this._meshEffectWarmQueue.push(batcher, fx, fogDefine);
49113
+ }
48915
49114
  }
48916
49115
  if (this._meshEffectWarmScheduled !== true) {
48917
49116
  this._meshEffectWarmScheduled = true;
49117
+ this._meshEffectWarmDone = new Promise((resolve) => {
49118
+ this._meshEffectWarmSettle = resolve;
49119
+ });
48918
49120
  queueMicrotask(() => {
48919
49121
  this._linkQueuedMeshEffects();
48920
49122
  });
48921
49123
  }
48922
49124
  }
49125
+ /**
49126
+ * Run `warm` and hand back what is still to be built once it returns:
49127
+ * the spliced mesh programs it queued, which are linked over the next
49128
+ * tasks rather than all at once.
49129
+ * @param {Function} warm - issues the warm-ups
49130
+ * @returns {Promise<void>[]} the queued links, as one promise, or nothing
49131
+ * @override
49132
+ * @ignore
49133
+ * @internal
49134
+ */
49135
+ _collectWarms(warm) {
49136
+ warm();
49137
+ return this._meshEffectWarmScheduled === true ? [this._meshEffectWarmDone] : [];
49138
+ }
48923
49139
  /**
48924
49140
  * Link the spliced mesh programs queued by `_warmPostEffects`, a few
48925
49141
  * milliseconds' worth per task, so a pool's worth spreads over the next
@@ -48933,7 +49149,7 @@ var WebGLRenderer = class _WebGLRenderer extends Renderer {
48933
49149
  const gl = this.gl;
48934
49150
  if (gl === null || gl.isContextLost?.() === true) {
48935
49151
  queue.length = 0;
48936
- this._meshEffectWarmScheduled = false;
49152
+ this._settleMeshEffectWarm();
48937
49153
  return;
48938
49154
  }
48939
49155
  const start = globalThis.performance.now();
@@ -48942,15 +49158,16 @@ var WebGLRenderer = class _WebGLRenderer extends Renderer {
48942
49158
  while (queue.length > 0 && globalThis.performance.now() - start < MESH_EFFECT_LINK_BUDGET) {
48943
49159
  const batcher = queue.shift();
48944
49160
  const fx = queue.shift();
49161
+ const fogDefine = queue.shift();
48945
49162
  if (fx.destroyed !== true && batcher.canHostEffect?.(fx) === true) {
48946
- batcher.effectShaderFor(fx);
49163
+ batcher._effectShader(fx, fogDefine);
48947
49164
  }
48948
49165
  }
48949
49166
  } finally {
48950
49167
  this._restoreProgram(previous);
48951
49168
  }
48952
49169
  if (queue.length === 0) {
48953
- this._meshEffectWarmScheduled = false;
49170
+ this._settleMeshEffectWarm();
48954
49171
  } else if (globalThis.document?.hidden === true) {
48955
49172
  this._linkQueuedMeshEffects();
48956
49173
  } else {
@@ -48959,6 +49176,17 @@ var WebGLRenderer = class _WebGLRenderer extends Renderer {
48959
49176
  }, 0);
48960
49177
  }
48961
49178
  }
49179
+ /**
49180
+ * The link queue is empty: let the next warm-up schedule a new one, and
49181
+ * release whatever is waiting on this one.
49182
+ * @ignore
49183
+ * @internal
49184
+ */
49185
+ _settleMeshEffectWarm() {
49186
+ this._meshEffectWarmScheduled = false;
49187
+ this._meshEffectWarmSettle?.();
49188
+ this._meshEffectWarmSettle = void 0;
49189
+ }
48962
49190
  /**
48963
49191
  * Build the advanced blend shader and its offscreen target before the
48964
49192
  * first draw in one of those modes, which otherwise compiles the shader
@@ -50042,8 +50270,16 @@ var WebGLRenderer = class _WebGLRenderer extends Renderer {
50042
50270
  * @see WebGLRenderer#createPattern
50043
50271
  */
50044
50272
  drawPattern(pattern, x, y, width, height) {
50273
+ if (this.customShader?._screenTextureUniforms?.length > 0) {
50274
+ this.toFrameTexture();
50275
+ }
50045
50276
  const uvs = pattern.getUVs("0,0," + width + "," + height);
50046
50277
  this.setBatcher("quad");
50278
+ const shader = this.customShader;
50279
+ if (shader != null) {
50280
+ this.currentBatcher.useShader(shader);
50281
+ shader._prepareTextures?.(this.currentBatcher);
50282
+ }
50047
50283
  this.currentBatcher.addQuad(
50048
50284
  pattern,
50049
50285
  x,
@@ -56651,7 +56887,7 @@ var Trigger = class extends Renderable {
56651
56887
  };
56652
56888
 
56653
56889
  // src/version.ts
56654
- var version = "20.10.0";
56890
+ var version = "20.10.1";
56655
56891
 
56656
56892
  // src/system/bootstrap.ts
56657
56893
  var initialized = false;
@@ -59176,6 +59412,7 @@ var WebGPUPipelineCache = class _WebGPUPipelineCache {
59176
59412
  this.inFrameMisses = 0;
59177
59413
  this.inFrameMissKeys = [];
59178
59414
  this.pending = /* @__PURE__ */ new Map();
59415
+ this.collecting = void 0;
59179
59416
  this.warmQueue = [];
59180
59417
  this.warmInFlight = 0;
59181
59418
  this.touchQueue = /* @__PURE__ */ new Map();
@@ -59537,6 +59774,7 @@ var WebGPUPipelineCache = class _WebGPUPipelineCache {
59537
59774
  }
59538
59775
  const inFlight = this.pending.get(key);
59539
59776
  if (inFlight !== void 0) {
59777
+ this.collecting?.push(inFlight);
59540
59778
  return inFlight;
59541
59779
  }
59542
59780
  const descriptor = this._descriptor(
@@ -59554,6 +59792,9 @@ var WebGPUPipelineCache = class _WebGPUPipelineCache {
59554
59792
  const promise = new Promise((resolve) => {
59555
59793
  this.warmQueue.push({
59556
59794
  run: () => {
59795
+ if (this.pipelines.has(key)) {
59796
+ return void 0;
59797
+ }
59557
59798
  return typeof this.device.createRenderPipelineAsync === "function" ? this.device.createRenderPipelineAsync(descriptor) : this.device.createRenderPipeline(descriptor);
59558
59799
  },
59559
59800
  resolve: (pipeline) => {
@@ -59567,9 +59808,29 @@ var WebGPUPipelineCache = class _WebGPUPipelineCache {
59567
59808
  });
59568
59809
  });
59569
59810
  this.pending.set(key, promise);
59811
+ this.collecting?.push(promise);
59570
59812
  this._pumpWarmQueue();
59571
59813
  return promise;
59572
59814
  }
59815
+ /**
59816
+ * Run `ask` and hand back the warm-ups it asked for that are not built
59817
+ * yet: the ones it started, and the ones already compiling that it asked
59818
+ * for again. A pipeline already in the cache is not waited on, so a scene
59819
+ * entered a second time hands back nothing.
59820
+ * @param {Function} ask - asks for warm-ups, through {@link WebGPUPipelineCache#warm}
59821
+ * @returns {Promise<void>[]} one promise per pipeline still on its way
59822
+ */
59823
+ collect(ask) {
59824
+ const outer = this.collecting;
59825
+ const asked = [];
59826
+ this.collecting = asked;
59827
+ try {
59828
+ ask();
59829
+ } finally {
59830
+ this.collecting = outer;
59831
+ }
59832
+ return asked;
59833
+ }
59573
59834
  /**
59574
59835
  * Start queued warm-ups until {@link MAX_WARM_IN_FLIGHT} are compiling.
59575
59836
  * @ignore
@@ -62880,6 +63141,21 @@ var WebGPURenderer = class _WebGPURenderer extends Renderer {
62880
63141
  }
62881
63142
  return realization.gpu.key;
62882
63143
  }
63144
+ /**
63145
+ * Run `warm` and hand back the pipelines it asked for that are still
63146
+ * compiling, which on this backend is every one not already cached.
63147
+ * @param {Function} warm - issues the warm-ups
63148
+ * @returns {Promise<void>[]} one promise per pipeline on its way
63149
+ * @override
63150
+ * @ignore
63151
+ * @internal
63152
+ */
63153
+ _collectWarms(warm) {
63154
+ if (this.pipelineCache == null) {
63155
+ return super._collectWarms(warm);
63156
+ }
63157
+ return this.pipelineCache.collect(warm);
63158
+ }
62883
63159
  /**
62884
63160
  * Build, off the frame, every pipeline a renderable's post effects can
62885
63161
  * draw with, and the render targets its chain will composite through.
@@ -63052,6 +63328,20 @@ var WebGPURenderer = class _WebGPURenderer extends Renderer {
63052
63328
  * @internal
63053
63329
  */
63054
63330
  _warmMeshDraw(mesh, family, scene) {
63331
+ for (const fog of this._warmFog ?? [this._fog3d != null]) {
63332
+ this._warmMeshDrawFog(mesh, family, scene, fog);
63333
+ }
63334
+ }
63335
+ /**
63336
+ * {@link WebGPURenderer#_warmMeshDraw} for one fog state.
63337
+ * @param {object} mesh - the mesh
63338
+ * @param {string} family - the pipeline family it draws with
63339
+ * @param {Array<Array<string|number>>} scene - the targets it can land on
63340
+ * @param {boolean} fog - whether it draws fogged
63341
+ * @ignore
63342
+ * @internal
63343
+ */
63344
+ _warmMeshDrawFog(mesh, family, scene, fog) {
63055
63345
  const culling = mesh.cullBackFaces === true;
63056
63346
  const state4 = {
63057
63347
  cullMode: culling ? "back" : "none",
@@ -63059,7 +63349,9 @@ var WebGPURenderer = class _WebGPURenderer extends Renderer {
63059
63349
  frontFace: culling && this.supportsRetainedMesh === true && mesh.rightHanded !== true ? "cw" : "ccw",
63060
63350
  depthWrite: void 0,
63061
63351
  depthTest: mesh.depthTest === false ? false : void 0,
63062
- fog: this._fog3d != null ? true : void 0
63352
+ // `undefined` rather than `false`, as the draw sets it: the key only
63353
+ // grows a fog suffix for `true`
63354
+ fog: fog ? true : void 0
63063
63355
  };
63064
63356
  const blendedOnly = mesh.transparent === true || mesh._blendedDraw === true;
63065
63357
  const blended = mesh.transparent !== false || mesh._blendedDraw === true;
@@ -63113,6 +63405,7 @@ var WebGPURenderer = class _WebGPURenderer extends Renderer {
63113
63405
  return;
63114
63406
  }
63115
63407
  if (renderable.instanceLayout !== void 0) {
63408
+ this._warmInstancedDraw(renderable, scene);
63116
63409
  return;
63117
63410
  }
63118
63411
  const blendMode = renderable.blendMode ?? "normal";
@@ -63129,6 +63422,61 @@ var WebGPURenderer = class _WebGPURenderer extends Renderer {
63129
63422
  );
63130
63423
  }
63131
63424
  }
63425
+ /**
63426
+ * Warm what an `InstancedMesh` draws with: its instanced family, and the
63427
+ * instanced ground-shadow family when it casts one.
63428
+ *
63429
+ * Both families are registered per instance record layout, on first use,
63430
+ * which the warm-up used to leave to the first draw. Nothing about them
63431
+ * needs the draw, though: the layout is the mesh's own, so registering
63432
+ * them here builds the same module and vertex layout the draw would, and
63433
+ * the keys follow the same rules as an ordinary mesh's. A scatter of
63434
+ * props is one of these, and it is exactly the kind of thing a stage
63435
+ * builds when it starts and draws on its next frame.
63436
+ * @param {object} mesh - the instanced mesh
63437
+ * @param {Array<Array<string|number>>} scene - the targets it can land on
63438
+ * @ignore
63439
+ * @internal
63440
+ */
63441
+ _warmInstancedDraw(mesh, scene) {
63442
+ if (this.supportsInstancing !== true) {
63443
+ return;
63444
+ }
63445
+ const batcher = this._meshBatcherFor(mesh);
63446
+ if (typeof batcher?.instancedFamilyFor !== "function") {
63447
+ return;
63448
+ }
63449
+ this._warmMeshDraw(
63450
+ mesh,
63451
+ batcher.instancedFamilyFor(mesh.instanceLayout),
63452
+ scene
63453
+ );
63454
+ if (mesh._castsGroundShadow?.(this) !== true || typeof batcher.instancedShadowFamily !== "function") {
63455
+ return;
63456
+ }
63457
+ const family = batcher.instancedShadowFamily(mesh.instanceLayout);
63458
+ for (const fog of this._warmFog ?? [this._fog3d != null]) {
63459
+ const state4 = {
63460
+ cullMode: "none",
63461
+ frontFace: "ccw",
63462
+ depthWrite: false,
63463
+ depthTest: mesh.depthTest === false ? false : void 0,
63464
+ fog: fog ? true : void 0
63465
+ };
63466
+ for (const [format, sampleCount] of scene) {
63467
+ void this.pipelineCache.warm(
63468
+ family,
63469
+ "triangle-list",
63470
+ "normal",
63471
+ true,
63472
+ "none",
63473
+ state4,
63474
+ format,
63475
+ sampleCount
63476
+ );
63477
+ }
63478
+ }
63479
+ }
63132
63480
  /**
63133
63481
  * Build the advanced blend shader and its offscreen target before the
63134
63482
  * first draw in one of those modes, and warm the two pipelines a bracket
@@ -63516,20 +63864,25 @@ var WebGPURenderer = class _WebGPURenderer extends Renderer {
63516
63864
  if (this.getDefaultTextureFilter() === "linear") {
63517
63865
  this.textureStore.warmMipmaps();
63518
63866
  }
63867
+ const warms = [];
63519
63868
  if (this._canWarm()) {
63520
63869
  for (const [format, sampleCount] of this._sceneTargets()) {
63521
- void this.pipelineCache.warm(
63522
- "clear",
63523
- "triangle-list",
63524
- "none",
63525
- true,
63526
- "none",
63527
- void 0,
63528
- format,
63529
- sampleCount
63870
+ warms.push(
63871
+ this.pipelineCache.warm(
63872
+ "clear",
63873
+ "triangle-list",
63874
+ "none",
63875
+ true,
63876
+ "none",
63877
+ void 0,
63878
+ format,
63879
+ sampleCount
63880
+ )
63530
63881
  );
63531
63882
  }
63532
63883
  }
63884
+ return Promise.all(warms).then(() => {
63885
+ });
63533
63886
  });
63534
63887
  }
63535
63888
  /**