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.
- package/dist/browser/index.d.mts +20 -20
- package/dist/browser/index.d.ts +20 -20
- package/dist/browser/index.js +36 -30
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +37 -31
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +31 -26
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +20 -20
- package/dist/node/index.d.ts +20 -20
- package/dist/node/index.js +38 -31
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +39 -32
- package/dist/node/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/browser/index.mjs
CHANGED
|
@@ -477,6 +477,7 @@ import { CanvasTexture, Texture as Texture2 } from "three";
|
|
|
477
477
|
|
|
478
478
|
// src/texture/TextureLoader.ts
|
|
479
479
|
import { RGBAFormat, Texture } from "three";
|
|
480
|
+
import * as THREE from "three";
|
|
480
481
|
|
|
481
482
|
// src/canvas/CanvasCompat.ts
|
|
482
483
|
function createImage(width, height) {
|
|
@@ -865,6 +866,7 @@ var TextureLoader = class {
|
|
|
865
866
|
}
|
|
866
867
|
static loadInBackground(src, format = RGBAFormat, rotation = 0) {
|
|
867
868
|
const texture = this.createTexture();
|
|
869
|
+
texture.colorSpace = THREE.SRGBColorSpace;
|
|
868
870
|
const image = ImageLoader.loadElement(src);
|
|
869
871
|
image.onload = function() {
|
|
870
872
|
texture.needsUpdate = true;
|
|
@@ -876,6 +878,7 @@ var TextureLoader = class {
|
|
|
876
878
|
}
|
|
877
879
|
static load(src, format = RGBAFormat, rotation = 0) {
|
|
878
880
|
const texture = new Texture();
|
|
881
|
+
texture.colorSpace = THREE.SRGBColorSpace;
|
|
879
882
|
ImageLoader.getData(src).then((image) => {
|
|
880
883
|
texture.needsUpdate = true;
|
|
881
884
|
texture.image = image;
|
|
@@ -887,11 +890,11 @@ var TextureLoader = class {
|
|
|
887
890
|
};
|
|
888
891
|
|
|
889
892
|
// src/texture/Textures.ts
|
|
890
|
-
import * as
|
|
893
|
+
import * as THREE2 from "three";
|
|
891
894
|
var Textures = class _Textures {
|
|
892
895
|
static initTextureProps(texture) {
|
|
893
|
-
texture.magFilter =
|
|
894
|
-
texture.minFilter =
|
|
896
|
+
texture.magFilter = THREE2.NearestFilter;
|
|
897
|
+
texture.minFilter = THREE2.NearestFilter;
|
|
895
898
|
texture.anisotropy = 0;
|
|
896
899
|
return texture;
|
|
897
900
|
}
|
|
@@ -902,7 +905,9 @@ var Textures = class _Textures {
|
|
|
902
905
|
return new Texture2();
|
|
903
906
|
}
|
|
904
907
|
static createCanvasTexture(canvas) {
|
|
905
|
-
|
|
908
|
+
const texture = new CanvasTexture(canvas);
|
|
909
|
+
texture.colorSpace = THREE2.SRGBColorSpace;
|
|
910
|
+
return this.initTextureProps(texture);
|
|
906
911
|
}
|
|
907
912
|
static getImage(key) {
|
|
908
913
|
const keyStr = serializeTextureKey(key);
|
|
@@ -1019,6 +1024,9 @@ var _Materials = class _Materials {
|
|
|
1019
1024
|
gl_FragColor = vec4(lift + color.rgb * light2, 1.0);
|
|
1020
1025
|
|
|
1021
1026
|
}
|
|
1027
|
+
|
|
1028
|
+
#include <tonemapping_fragment>
|
|
1029
|
+
#include <colorspace_fragment>
|
|
1022
1030
|
}
|
|
1023
1031
|
`;
|
|
1024
1032
|
try {
|
|
@@ -2893,7 +2901,7 @@ function isSceneObject(obj) {
|
|
|
2893
2901
|
// src/entity/scene/EntityObject.ts
|
|
2894
2902
|
var import_ts_deepmerge5 = __toESM(require_dist());
|
|
2895
2903
|
import { Object3D as Object3D3 } from "three";
|
|
2896
|
-
import * as
|
|
2904
|
+
import * as THREE3 from "three";
|
|
2897
2905
|
var EntityObject = class extends SceneObject {
|
|
2898
2906
|
constructor(entity, options) {
|
|
2899
2907
|
super();
|
|
@@ -2937,8 +2945,8 @@ var EntityObject = class extends SceneObject {
|
|
|
2937
2945
|
const l = cube.maxZ - cube.minZ;
|
|
2938
2946
|
const uv = texture.toUvArray(w, h, l);
|
|
2939
2947
|
const cubeGeo = this._getBoxGeometryForDimensionsAndUv(w, h, l, uv).clone();
|
|
2940
|
-
cubeGeo.applyMatrix4(new
|
|
2941
|
-
cubeGeo.applyMatrix4(new
|
|
2948
|
+
cubeGeo.applyMatrix4(new THREE3.Matrix4().makeTranslation(w / 2, h / 2, l / 2));
|
|
2949
|
+
cubeGeo.applyMatrix4(new THREE3.Matrix4().makeTranslation(cube.minX, cube.minY, cube.minZ));
|
|
2942
2950
|
applyModelPartRotation(part, cubeGeo);
|
|
2943
2951
|
const mesh = this.createMesh(partName, cubeGeo, mat);
|
|
2944
2952
|
partAnchor.add(mesh);
|
|
@@ -5395,7 +5403,7 @@ function isMineRenderScene(obj) {
|
|
|
5395
5403
|
}
|
|
5396
5404
|
|
|
5397
5405
|
// src/renderer/Renderer.ts
|
|
5398
|
-
import { AxesHelper as AxesHelper3, GridHelper,
|
|
5406
|
+
import { AxesHelper as AxesHelper3, GridHelper, OrthographicCamera, PCFSoftShadowMap, PerspectiveCamera, SRGBColorSpace as SRGBColorSpace3, Vector3 as Vector38, WebGLRenderer } from "three";
|
|
5399
5407
|
var import_ts_deepmerge10 = __toESM(require_dist());
|
|
5400
5408
|
import Stats from "stats.js";
|
|
5401
5409
|
import { EffectComposer, RenderPass } from "postprocessing";
|
|
@@ -6054,8 +6062,6 @@ var MapControls = class extends OrbitControls {
|
|
|
6054
6062
|
var _Renderer = class _Renderer {
|
|
6055
6063
|
constructor(options) {
|
|
6056
6064
|
this._dirty = true;
|
|
6057
|
-
this._animationTimer = void 0;
|
|
6058
|
-
this._animationFrame = void 0;
|
|
6059
6065
|
this._resizeListener = void 0;
|
|
6060
6066
|
this._disposed = false;
|
|
6061
6067
|
this._debugHelpers = [];
|
|
@@ -6065,7 +6071,7 @@ var _Renderer = class _Renderer {
|
|
|
6065
6071
|
};
|
|
6066
6072
|
this.options = (0, import_ts_deepmerge10.default)({}, _Renderer.DEFAULT_OPTIONS, options ?? {});
|
|
6067
6073
|
this._animationLoop = this.animate.bind(this);
|
|
6068
|
-
this.
|
|
6074
|
+
this._frameInterval = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
|
|
6069
6075
|
this._scene = this.createScene();
|
|
6070
6076
|
this._camera = this.createCamera();
|
|
6071
6077
|
this._renderer = this.createRenderer();
|
|
@@ -6112,13 +6118,13 @@ var _Renderer = class _Renderer {
|
|
|
6112
6118
|
renderer.setClearColor(0, 0);
|
|
6113
6119
|
renderer.shadowMap.enabled = true;
|
|
6114
6120
|
renderer.shadowMap.type = PCFSoftShadowMap;
|
|
6115
|
-
renderer.
|
|
6121
|
+
renderer.outputColorSpace = SRGBColorSpace3;
|
|
6116
6122
|
renderer.setSize(this.viewWidth, this.viewHeight);
|
|
6117
6123
|
return renderer;
|
|
6118
6124
|
}
|
|
6119
6125
|
createComposer() {
|
|
6126
|
+
if (!this.options.composer.enabled) return void 0;
|
|
6120
6127
|
const composer = new EffectComposer(this.renderer);
|
|
6121
|
-
if (!this.options.composer.enabled) return composer;
|
|
6122
6128
|
composer.setSize(this.viewWidth, this.viewHeight);
|
|
6123
6129
|
composer.addPass(new RenderPass(this.scene, this.camera));
|
|
6124
6130
|
return composer;
|
|
@@ -6227,7 +6233,7 @@ var _Renderer = class _Renderer {
|
|
|
6227
6233
|
this.camera.updateProjectionMatrix();
|
|
6228
6234
|
}
|
|
6229
6235
|
this.renderer.setSize(width, height);
|
|
6230
|
-
this.composer
|
|
6236
|
+
this.composer?.setSize(width, height);
|
|
6231
6237
|
this._dirty = true;
|
|
6232
6238
|
}
|
|
6233
6239
|
//<editor-fold desc="RENDER">
|
|
@@ -6246,12 +6252,7 @@ var _Renderer = class _Renderer {
|
|
|
6246
6252
|
stop() {
|
|
6247
6253
|
if (this._disposed) return;
|
|
6248
6254
|
this.renderer.setAnimationLoop(null);
|
|
6249
|
-
|
|
6250
|
-
clearTimeout(this._animationTimer);
|
|
6251
|
-
this._animationTimer = void 0;
|
|
6252
|
-
if (this._animationFrame)
|
|
6253
|
-
cancelAnimationFrame(this._animationFrame);
|
|
6254
|
-
this._animationFrame = void 0;
|
|
6255
|
+
this._nextFrameTime = void 0;
|
|
6255
6256
|
}
|
|
6256
6257
|
/**
|
|
6257
6258
|
* Stops rendering and releases owned resources. Repeated calls have no effect, and a disposed
|
|
@@ -6291,25 +6292,30 @@ var _Renderer = class _Renderer {
|
|
|
6291
6292
|
}
|
|
6292
6293
|
}
|
|
6293
6294
|
this._debugHelpers.length = 0;
|
|
6294
|
-
this.composer
|
|
6295
|
+
this.composer?.dispose();
|
|
6295
6296
|
this.renderer.dispose();
|
|
6296
6297
|
this.renderer.forceContextLoss();
|
|
6297
6298
|
}
|
|
6298
|
-
animate(t) {
|
|
6299
|
+
animate(t = performance.now()) {
|
|
6299
6300
|
if (this._disposed) return;
|
|
6300
|
-
if (this._stats) {
|
|
6301
|
-
this._stats.begin();
|
|
6302
|
-
}
|
|
6303
6301
|
if (this._controls?.enabled) {
|
|
6304
6302
|
this._controls.update();
|
|
6305
6303
|
}
|
|
6306
6304
|
if (this._disposed) return;
|
|
6307
|
-
if (this.dirty
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6305
|
+
if (!this.dirty && !this.options.render.renderAlways) return;
|
|
6306
|
+
const interval = this._frameInterval;
|
|
6307
|
+
if (interval) {
|
|
6308
|
+
const next = this._nextFrameTime;
|
|
6309
|
+
if (next !== void 0 && t + 0.1 < next) return;
|
|
6310
|
+
this._nextFrameTime = next !== void 0 && t - next < interval ? next + interval : t + interval;
|
|
6311
|
+
}
|
|
6312
|
+
if (this._stats) {
|
|
6313
|
+
this._stats.begin();
|
|
6314
|
+
}
|
|
6315
|
+
if (this.options.composer.enabled && this.composer) {
|
|
6316
|
+
this.composer.render();
|
|
6317
|
+
} else {
|
|
6318
|
+
this.renderer.render(this.scene, this.camera);
|
|
6313
6319
|
}
|
|
6314
6320
|
this.dirty = false;
|
|
6315
6321
|
if (this._stats) {
|