minerender 2.1.0-alpha.3 → 2.1.0-alpha.5

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.
@@ -441,6 +441,7 @@ import { CanvasTexture, Texture as Texture2 } from "three";
441
441
 
442
442
  // src/texture/TextureLoader.ts
443
443
  import { RGBAFormat, Texture } from "three";
444
+ import * as THREE from "three";
444
445
 
445
446
  // src/canvas/CanvasCompat.ts
446
447
  function createImage(width, height) {
@@ -829,6 +830,7 @@ var TextureLoader = class {
829
830
  }
830
831
  static loadInBackground(src, format = RGBAFormat, rotation = 0) {
831
832
  const texture = this.createTexture();
833
+ texture.colorSpace = THREE.SRGBColorSpace;
832
834
  const image = ImageLoader.loadElement(src);
833
835
  image.onload = function() {
834
836
  texture.needsUpdate = true;
@@ -840,6 +842,7 @@ var TextureLoader = class {
840
842
  }
841
843
  static load(src, format = RGBAFormat, rotation = 0) {
842
844
  const texture = new Texture();
845
+ texture.colorSpace = THREE.SRGBColorSpace;
843
846
  ImageLoader.getData(src).then((image) => {
844
847
  texture.needsUpdate = true;
845
848
  texture.image = image;
@@ -851,11 +854,11 @@ var TextureLoader = class {
851
854
  };
852
855
 
853
856
  // src/texture/Textures.ts
854
- import * as THREE from "three";
857
+ import * as THREE2 from "three";
855
858
  var Textures = class _Textures {
856
859
  static initTextureProps(texture) {
857
- texture.magFilter = THREE.NearestFilter;
858
- texture.minFilter = THREE.NearestFilter;
860
+ texture.magFilter = THREE2.NearestFilter;
861
+ texture.minFilter = THREE2.NearestFilter;
859
862
  texture.anisotropy = 0;
860
863
  return texture;
861
864
  }
@@ -866,7 +869,9 @@ var Textures = class _Textures {
866
869
  return new Texture2();
867
870
  }
868
871
  static createCanvasTexture(canvas) {
869
- return this.initTextureProps(new CanvasTexture(canvas));
872
+ const texture = new CanvasTexture(canvas);
873
+ texture.colorSpace = THREE2.SRGBColorSpace;
874
+ return this.initTextureProps(texture);
870
875
  }
871
876
  static getImage(key) {
872
877
  const keyStr = serializeTextureKey(key);
@@ -983,6 +988,9 @@ var _Materials = class _Materials {
983
988
  gl_FragColor = vec4(lift + color.rgb * light2, 1.0);
984
989
 
985
990
  }
991
+
992
+ #include <tonemapping_fragment>
993
+ #include <colorspace_fragment>
986
994
  }
987
995
  `;
988
996
  try {
@@ -2860,7 +2868,7 @@ function isSceneObject(obj) {
2860
2868
  // src/entity/scene/EntityObject.ts
2861
2869
  var import_ts_deepmerge5 = __toESM(require_dist());
2862
2870
  import { Object3D as Object3D3 } from "three";
2863
- import * as THREE2 from "three";
2871
+ import * as THREE3 from "three";
2864
2872
  var EntityObject = class extends SceneObject {
2865
2873
  constructor(entity, options) {
2866
2874
  super();
@@ -2905,8 +2913,8 @@ var EntityObject = class extends SceneObject {
2905
2913
  const l = cube.maxZ - cube.minZ;
2906
2914
  const uv = texture.toUvArray(w, h, l);
2907
2915
  const cubeGeo = this._getBoxGeometryForDimensionsAndUv(w, h, l, uv).clone();
2908
- cubeGeo.applyMatrix4(new THREE2.Matrix4().makeTranslation(w / 2, h / 2, l / 2));
2909
- cubeGeo.applyMatrix4(new THREE2.Matrix4().makeTranslation(cube.minX, cube.minY, cube.minZ));
2916
+ cubeGeo.applyMatrix4(new THREE3.Matrix4().makeTranslation(w / 2, h / 2, l / 2));
2917
+ cubeGeo.applyMatrix4(new THREE3.Matrix4().makeTranslation(cube.minX, cube.minY, cube.minZ));
2910
2918
  applyModelPartRotation(part, cubeGeo);
2911
2919
  const mesh = this.createMesh(partName, cubeGeo, mat);
2912
2920
  partAnchor.add(mesh);
@@ -5370,7 +5378,7 @@ function isMineRenderScene(obj) {
5370
5378
  }
5371
5379
 
5372
5380
  // src/renderer/Renderer.ts
5373
- import { AxesHelper as AxesHelper3, GridHelper, LinearEncoding, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera, Vector3 as Vector38, WebGLRenderer } from "three";
5381
+ import { AxesHelper as AxesHelper3, GridHelper, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera, SRGBColorSpace as SRGBColorSpace3, Vector3 as Vector38, WebGLRenderer } from "three";
5374
5382
  var import_ts_deepmerge10 = __toESM(require_dist());
5375
5383
  import Stats from "stats.js";
5376
5384
  import { EffectComposer, RenderPass } from "postprocessing";
@@ -6029,8 +6037,6 @@ var MapControls = class extends OrbitControls {
6029
6037
  var _Renderer = class _Renderer {
6030
6038
  constructor(options) {
6031
6039
  this._dirty = true;
6032
- this._animationTimer = void 0;
6033
- this._animationFrame = void 0;
6034
6040
  this._resizeListener = void 0;
6035
6041
  this._disposed = false;
6036
6042
  this._debugHelpers = [];
@@ -6040,7 +6046,7 @@ var _Renderer = class _Renderer {
6040
6046
  };
6041
6047
  this.options = (0, import_ts_deepmerge10.default)({}, _Renderer.DEFAULT_OPTIONS, options ?? {});
6042
6048
  this._animationLoop = this.animate.bind(this);
6043
- this._fpsTimer = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
6049
+ this._frameInterval = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
6044
6050
  this._scene = this.createScene();
6045
6051
  this._camera = this.createCamera();
6046
6052
  this._renderer = this.createRenderer();
@@ -6087,13 +6093,13 @@ var _Renderer = class _Renderer {
6087
6093
  renderer.setClearColor(0, 0);
6088
6094
  renderer.shadowMap.enabled = true;
6089
6095
  renderer.shadowMap.type = PCFSoftShadowMap;
6090
- renderer.outputEncoding = LinearEncoding;
6096
+ renderer.outputColorSpace = SRGBColorSpace3;
6091
6097
  renderer.setSize(this.viewWidth, this.viewHeight);
6092
6098
  return renderer;
6093
6099
  }
6094
6100
  createComposer() {
6101
+ if (!this.options.composer.enabled) return void 0;
6095
6102
  const composer = new EffectComposer(this.renderer);
6096
- if (!this.options.composer.enabled) return composer;
6097
6103
  composer.setSize(this.viewWidth, this.viewHeight);
6098
6104
  composer.addPass(new RenderPass(this.scene, this.camera));
6099
6105
  return composer;
@@ -6191,6 +6197,7 @@ var _Renderer = class _Renderer {
6191
6197
  dispatcher.addEventListener(changeEvent2, this._changeListener);
6192
6198
  }
6193
6199
  resize(width, height) {
6200
+ var _a;
6194
6201
  if (this._disposed) return;
6195
6202
  if (isPerspectiveCamera(this.camera)) {
6196
6203
  this.camera.aspect = width / height;
@@ -6203,7 +6210,7 @@ var _Renderer = class _Renderer {
6203
6210
  this.camera.updateProjectionMatrix();
6204
6211
  }
6205
6212
  this.renderer.setSize(width, height);
6206
- this.composer.setSize(width, height);
6213
+ (_a = this.composer) == null ? void 0 : _a.setSize(width, height);
6207
6214
  this._dirty = true;
6208
6215
  }
6209
6216
  //<editor-fold desc="RENDER">
@@ -6222,12 +6229,7 @@ var _Renderer = class _Renderer {
6222
6229
  stop() {
6223
6230
  if (this._disposed) return;
6224
6231
  this.renderer.setAnimationLoop(null);
6225
- if (this._animationTimer)
6226
- clearTimeout(this._animationTimer);
6227
- this._animationTimer = void 0;
6228
- if (this._animationFrame)
6229
- cancelAnimationFrame(this._animationFrame);
6230
- this._animationFrame = void 0;
6232
+ this._nextFrameTime = void 0;
6231
6233
  }
6232
6234
  /**
6233
6235
  * Stops rendering and releases owned resources. Repeated calls have no effect, and a disposed
@@ -6235,7 +6237,7 @@ var _Renderer = class _Renderer {
6235
6237
  * controls must be managed by their owners.
6236
6238
  */
6237
6239
  dispose() {
6238
- var _a;
6240
+ var _a, _b;
6239
6241
  if (this._disposed) return;
6240
6242
  this.stop();
6241
6243
  this._disposed = true;
@@ -6268,26 +6270,31 @@ var _Renderer = class _Renderer {
6268
6270
  }
6269
6271
  }
6270
6272
  this._debugHelpers.length = 0;
6271
- this.composer.dispose();
6273
+ (_b = this.composer) == null ? void 0 : _b.dispose();
6272
6274
  this.renderer.dispose();
6273
6275
  this.renderer.forceContextLoss();
6274
6276
  }
6275
- animate(t) {
6277
+ animate(t = performance.now()) {
6276
6278
  var _a;
6277
6279
  if (this._disposed) return;
6278
- if (this._stats) {
6279
- this._stats.begin();
6280
- }
6281
6280
  if ((_a = this._controls) == null ? void 0 : _a.enabled) {
6282
6281
  this._controls.update();
6283
6282
  }
6284
6283
  if (this._disposed) return;
6285
- if (this.dirty || this.options.render.renderAlways) {
6286
- if (this.options.composer.enabled) {
6287
- this.composer.render();
6288
- } else {
6289
- this.renderer.render(this.scene, this.camera);
6290
- }
6284
+ if (!this.dirty && !this.options.render.renderAlways) return;
6285
+ const interval = this._frameInterval;
6286
+ if (interval) {
6287
+ const next = this._nextFrameTime;
6288
+ if (next !== void 0 && t + 0.1 < next) return;
6289
+ this._nextFrameTime = next !== void 0 && t - next < interval ? next + interval : t + interval;
6290
+ }
6291
+ if (this._stats) {
6292
+ this._stats.begin();
6293
+ }
6294
+ if (this.options.composer.enabled && this.composer) {
6295
+ this.composer.render();
6296
+ } else {
6297
+ this.renderer.render(this.scene, this.camera);
6291
6298
  }
6292
6299
  this.dirty = false;
6293
6300
  if (this._stats) {