bg2e-js 2.3.2 → 2.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bg2e-js.js CHANGED
@@ -5414,7 +5414,7 @@ async function uo(t) {
5414
5414
  }
5415
5415
  class fe {
5416
5416
  constructor(e = "") {
5417
- this._sceneChanged = !1, this._name = e, this._enabled = !0, this._steady = !1, this._components = new dr(this), this._parent = null, this._children = [];
5417
+ this._sceneChanged = !1, this._postRedisplayFrames = 0, this._name = e, this._enabled = !0, this._steady = !1, this._components = new dr(this), this._parent = null, this._children = [];
5418
5418
  }
5419
5419
  get name() {
5420
5420
  return this._name;
@@ -5519,6 +5519,16 @@ class fe {
5519
5519
  await this._children[r].asyncAccept(e);
5520
5520
  }
5521
5521
  }
5522
+ // Used by components to require a redraw of the scene for a certain number of frames.
5523
+ // This is needed, for example, when a component changes the material of a drawable,
5524
+ // so the change is reflected inmediately in the screen, or when a component generates
5525
+ // an animation that needs to be updated for a certain number of frames.
5526
+ get postRedisplayFrames() {
5527
+ return this._postRedisplayFrames;
5528
+ }
5529
+ set postRedisplayFrames(e) {
5530
+ this._postRedisplayFrames = e;
5531
+ }
5522
5532
  // Most usual components
5523
5533
  get transform() {
5524
5534
  return this.component("Transform");
@@ -7942,22 +7952,25 @@ class St {
7942
7952
  }
7943
7953
  class Rt extends ce {
7944
7954
  constructor(e) {
7945
- super(), this._renderQueue = e, this._delta = 0, this._modelMatrix = w.MakeIdentity(), this._matrixStack = [];
7955
+ super(), this._postRedisplayFrames = 0, this._renderQueue = e, this._delta = 0, this._modelMatrix = w.MakeIdentity(), this._matrixStack = [];
7946
7956
  }
7947
7957
  get delta() {
7948
7958
  return this._delta;
7949
7959
  }
7950
- set delta(e) {
7951
- this._delta = e;
7952
- }
7953
7960
  get modelMatrix() {
7954
7961
  return this._modelMatrix;
7955
7962
  }
7963
+ get postRedisplayFrames() {
7964
+ return this._postRedisplayFrames;
7965
+ }
7966
+ beginFrame(e) {
7967
+ this._delta = e, this._postRedisplayFrames = 0;
7968
+ }
7956
7969
  visit(e) {
7957
7970
  this._matrixStack.push(new w(this._modelMatrix)), e.frame(this._delta, this._modelMatrix, this._renderQueue);
7958
7971
  }
7959
7972
  didVisit(e) {
7960
- this._modelMatrix = this._matrixStack[this._matrixStack.length - 1] || w.MakeIdentity(), this._matrixStack.pop();
7973
+ this._modelMatrix = this._matrixStack[this._matrixStack.length - 1] || w.MakeIdentity(), this._matrixStack.pop(), this._postRedisplayFrames = Math.max(this._postRedisplayFrames, e.postRedisplayFrames), e.postRedisplayFrames = 0;
7961
7974
  }
7962
7975
  }
7963
7976
  class cn extends ce {
@@ -8011,6 +8024,9 @@ class un {
8011
8024
  get renderQueue() {
8012
8025
  return this._renderQueue;
8013
8026
  }
8027
+ get postRedisplayFrames() {
8028
+ return this._frameVisitor ? this._frameVisitor.postRedisplayFrames : 0;
8029
+ }
8014
8030
  async init({ shadowMapSize: e = new h(1024, 1024) } = {}) {
8015
8031
  typeof e == "number" && (e = new h(e, e)), this._shadowMapSize = e, this._mainDirectionalLight = null, this._opaquePipeline = this.renderer.factory.pipeline(), this._opaquePipeline?.setBlendState({ enabled: !1 }), this._opaquePipeline?.create(), this._transparentPipeline = this.renderer.factory.pipeline(), this._transparentPipeline?.setBlendState({
8016
8032
  enabled: !0,
@@ -8055,7 +8071,7 @@ class un {
8055
8071
  async frame(e, r) {
8056
8072
  if (!this._frameVisitor || !this._renderQueue || !this._initVisitor)
8057
8073
  throw new Error("SceneRenderer.frame(): SceneRenderer not initialized. Call SceneRenderer.init() first.");
8058
- e.sceneChanged && await e.asyncAccept(this._initVisitor), this._sceneRoot = e, this._renderQueue?.newFrame(), this._frameVisitor.delta = r, this._frameVisitor.modelMatrix.identity();
8074
+ e.sceneChanged && await e.asyncAccept(this._initVisitor), this._sceneRoot = e, this._renderQueue?.newFrame(), this._frameVisitor.beginFrame(r), this._frameVisitor.modelMatrix.identity();
8059
8075
  const i = j.GetMain(e);
8060
8076
  let n = this.defaultViewMatrix, s = this.defaultProjectionMatrix;
8061
8077
  i && (s = i.projectionMatrix, n = w.GetInverted(oe.GetWorldMatrix(i.node))), this._renderQueue.viewMatrix = n, this._renderQueue.projectionMatrix = s, e.accept(this._frameVisitor), this._skyCube?.updateRenderState({
@@ -9018,7 +9034,7 @@ class m0 extends en {
9018
9034
  !this.sceneRoot || !this.sceneRenderer || (this.sceneRenderer.resize(this.sceneRoot, e, r), this.selectionManager?.setViewportSize(e, r), this.selectionHighlight?.setViewportSize(e, r), this._debugRenderer?.setViewportSize(e, r));
9019
9035
  }
9020
9036
  async frame(e) {
9021
- !this.sceneRoot || !this.sceneRenderer || (this._debugRenderer?.beginFrame(), await this.sceneRenderer?.frame(this.sceneRoot, e));
9037
+ !this.sceneRoot || !this.sceneRenderer || (this._debugRenderer?.beginFrame(), await this.sceneRenderer?.frame(this.sceneRoot, e), this.sceneRenderer.postRedisplayFrames > 0 && this.mainLoop.postRedisplay({ frames: this.sceneRenderer.postRedisplayFrames }));
9022
9038
  }
9023
9039
  display() {
9024
9040
  if (!this.sceneRoot || !this.sceneRenderer)