@xviewer.js/core 1.0.0-alpha.47 → 1.0.0-alpha.49
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/main.js +46 -24
- package/dist/main.js.map +1 -1
- package/dist/module.js +46 -24
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/types/Viewer.d.ts +3 -0
- package/types/passes/cubeuv/MergeInfo.d.ts +1 -1
- package/types/passes/cubeuv/utils.d.ts +4 -3
- package/types/plugins/EnvironmentPlugin.d.ts +7 -4
package/dist/module.js
CHANGED
|
@@ -3602,10 +3602,11 @@ const _axisDirections = [
|
|
|
3602
3602
|
/*@__PURE__*/ new Vector3(PHI, INV_PHI, 0),
|
|
3603
3603
|
/*@__PURE__*/ new Vector3(-PHI, INV_PHI, 0)
|
|
3604
3604
|
];
|
|
3605
|
-
const
|
|
3606
|
-
|
|
3605
|
+
const _Quality = {
|
|
3606
|
+
LOW: 0,
|
|
3607
3607
|
MEDIUM: 1,
|
|
3608
|
-
|
|
3608
|
+
HIGH: 2,
|
|
3609
|
+
ULTRA: 3
|
|
3609
3610
|
};
|
|
3610
3611
|
function _setViewport(target, x, y, width, height) {
|
|
3611
3612
|
target.viewport.set(x, y, width, height);
|
|
@@ -4602,6 +4603,12 @@ class Viewer extends EventEmitter {
|
|
|
4602
4603
|
get input() {
|
|
4603
4604
|
return this._input;
|
|
4604
4605
|
}
|
|
4606
|
+
get targetFrameRate() {
|
|
4607
|
+
return this._targetFrameRate;
|
|
4608
|
+
}
|
|
4609
|
+
set targetFrameRate(v) {
|
|
4610
|
+
this._targetFrameRate = Math.max(0.001, v);
|
|
4611
|
+
}
|
|
4605
4612
|
destroy() {
|
|
4606
4613
|
this._renderer.dispose();
|
|
4607
4614
|
this._taskManager.destroy();
|
|
@@ -4621,14 +4628,15 @@ class Viewer extends EventEmitter {
|
|
|
4621
4628
|
this._time = time;
|
|
4622
4629
|
if (this._targetFrameRate > -1) {
|
|
4623
4630
|
const interval = 1 / this._targetFrameRate;
|
|
4624
|
-
const delta =
|
|
4631
|
+
const delta = this._time - this._lastFrameTime;
|
|
4625
4632
|
if (delta >= interval) {
|
|
4626
|
-
this.loop(
|
|
4627
|
-
this._lastTime =
|
|
4633
|
+
this.loop(this._time - this._lastTime);
|
|
4634
|
+
this._lastTime = this._time;
|
|
4635
|
+
this._lastFrameTime = this._time - delta % interval;
|
|
4628
4636
|
}
|
|
4629
4637
|
} else {
|
|
4630
|
-
this.loop(
|
|
4631
|
-
this._lastTime =
|
|
4638
|
+
this.loop(this._time - this._lastTime);
|
|
4639
|
+
this._lastTime = this._time;
|
|
4632
4640
|
}
|
|
4633
4641
|
}
|
|
4634
4642
|
loop(dt) {
|
|
@@ -4932,6 +4940,7 @@ class Viewer extends EventEmitter {
|
|
|
4932
4940
|
this._rootRotated = false;
|
|
4933
4941
|
this._time = 0;
|
|
4934
4942
|
this._lastTime = 0;
|
|
4943
|
+
this._lastFrameTime = 0;
|
|
4935
4944
|
this._targetFrameRate = -1;
|
|
4936
4945
|
this._autoResize = true;
|
|
4937
4946
|
const el = canvas || document.getElementById("canvas");
|
|
@@ -5003,7 +5012,7 @@ class MergeRefectPass {
|
|
|
5003
5012
|
}
|
|
5004
5013
|
mergeReflect(info) {
|
|
5005
5014
|
this._pmremGenerator._copyTexture(this._envMapTarget, this._sourceTarget.texture, info.envMapIntensity);
|
|
5006
|
-
this._pmremGenerator._mergeReflect(this._envMapTarget, this._reflectMap, info.
|
|
5015
|
+
this._pmremGenerator._mergeReflect(this._envMapTarget, this._reflectMap, info.quality);
|
|
5007
5016
|
info.envMapTarget = this._envMapTarget;
|
|
5008
5017
|
info.lodMax = this._pmremGenerator._lodMeshes.length - 1;
|
|
5009
5018
|
}
|
|
@@ -5037,19 +5046,19 @@ class MergeRefectPass {
|
|
|
5037
5046
|
pmremGenerator._clearTexture = function(targetOut, intensity) {
|
|
5038
5047
|
this._copyTexture(targetOut, this._sourceTarget.texture, intensity);
|
|
5039
5048
|
};
|
|
5040
|
-
pmremGenerator._mergeReflect = function(sourceTarget, reflectMap,
|
|
5049
|
+
pmremGenerator._mergeReflect = function(sourceTarget, reflectMap, quality) {
|
|
5041
5050
|
const renderer = this._renderer;
|
|
5042
5051
|
const autoClear = renderer.autoClear;
|
|
5043
5052
|
const cubeMapMaterial = this._cubeMapMaterial;
|
|
5044
5053
|
const uniforms = this._cubeMapMaterial.uniforms;
|
|
5045
5054
|
uniforms.envMap.value = reflectMap;
|
|
5046
5055
|
renderer.autoClear = false;
|
|
5047
|
-
if (
|
|
5056
|
+
if (quality === _Quality.HIGH) {
|
|
5048
5057
|
for(let i = 0; i < this._lodMeshes.length - 1; i++){
|
|
5049
5058
|
uniforms.lod.value = i < 5 ? 0 : i;
|
|
5050
5059
|
this._blit(sourceTarget, i, cubeMapMaterial);
|
|
5051
5060
|
}
|
|
5052
|
-
} else if (
|
|
5061
|
+
} else if (quality === _Quality.MEDIUM) {
|
|
5053
5062
|
for(let i = 0; i < this._lodMeshes.length; i++){
|
|
5054
5063
|
if (i < 4) {
|
|
5055
5064
|
uniforms.lod.value = 0;
|
|
@@ -5058,7 +5067,7 @@ class MergeRefectPass {
|
|
|
5058
5067
|
this._pmremblur(sourceTarget, i - 1, i);
|
|
5059
5068
|
}
|
|
5060
5069
|
}
|
|
5061
|
-
} else {
|
|
5070
|
+
} else if (quality === _Quality.ULTRA) {
|
|
5062
5071
|
uniforms.lod.value = 0;
|
|
5063
5072
|
this._blit(sourceTarget, 0, cubeMapMaterial);
|
|
5064
5073
|
for(let i = 1; i < this._lodMeshes.length; i++){
|
|
@@ -5244,11 +5253,18 @@ class EnvironmentPlugin extends Plugin {
|
|
|
5244
5253
|
}
|
|
5245
5254
|
}
|
|
5246
5255
|
onRender(dt) {
|
|
5247
|
-
if (this.
|
|
5248
|
-
this._elapsed
|
|
5256
|
+
if (!this.manual) {
|
|
5257
|
+
if (this._elapsed >= this.interval || this._elapsed === 0) {
|
|
5258
|
+
this._elapsed = 0;
|
|
5259
|
+
this._renderFrame();
|
|
5260
|
+
}
|
|
5261
|
+
this._elapsed += dt;
|
|
5262
|
+
}
|
|
5263
|
+
}
|
|
5264
|
+
manualFrame() {
|
|
5265
|
+
if (this.manual) {
|
|
5249
5266
|
this._renderFrame();
|
|
5250
5267
|
}
|
|
5251
|
-
this._elapsed += dt;
|
|
5252
5268
|
}
|
|
5253
5269
|
_renderFrame() {
|
|
5254
5270
|
const { renderer } = this.viewer;
|
|
@@ -5257,13 +5273,15 @@ class EnvironmentPlugin extends Plugin {
|
|
|
5257
5273
|
const oldActiveCubeFace = renderer.getActiveCubeFace();
|
|
5258
5274
|
const oldActiveMipmapLevel = renderer.getActiveMipmapLevel();
|
|
5259
5275
|
renderer.autoClear = true;
|
|
5260
|
-
this.
|
|
5261
|
-
this._mergeInfo.performance = this.performance;
|
|
5276
|
+
this._mergeInfo.quality = this.quality;
|
|
5262
5277
|
this._mergeInfo.exposure = this.reflectExposure;
|
|
5263
5278
|
this._mergeInfo.envMapIntensity = this.envMapIntensity;
|
|
5264
5279
|
this._mergeInfo.blurIntensity = this.reflectBlurIntensity;
|
|
5280
|
+
if (this.quality !== _Quality.LOW) {
|
|
5281
|
+
this._cubeCamera.update(renderer, this._scene);
|
|
5282
|
+
}
|
|
5265
5283
|
this._reflectPass.mergeReflect(this._mergeInfo);
|
|
5266
|
-
if (this.
|
|
5284
|
+
if (this.quality === _Quality.HIGH) {
|
|
5267
5285
|
if (this._mipBlurPass === undefined) {
|
|
5268
5286
|
this._mipBlurPass = new MergeMipBlurPass({
|
|
5269
5287
|
viewer: this.viewer,
|
|
@@ -5278,7 +5296,7 @@ class EnvironmentPlugin extends Plugin {
|
|
|
5278
5296
|
constructor({ envMap, scene, near, far, layer = 0, resolution = 256, floatType = HalfFloatType, position = new Vector3(0, 1, 0) } = {}){
|
|
5279
5297
|
super();
|
|
5280
5298
|
this._mergeInfo = {
|
|
5281
|
-
|
|
5299
|
+
quality: _Quality.HIGH,
|
|
5282
5300
|
envMapTarget: null,
|
|
5283
5301
|
envMapIntensity: 1,
|
|
5284
5302
|
blurIntensity: 1,
|
|
@@ -5288,11 +5306,12 @@ class EnvironmentPlugin extends Plugin {
|
|
|
5288
5306
|
this._debug = false;
|
|
5289
5307
|
this._debugNode = null;
|
|
5290
5308
|
this._elapsed = 0;
|
|
5291
|
-
this.
|
|
5309
|
+
this.quality = _Quality.HIGH;
|
|
5292
5310
|
this.envMapIntensity = 1;
|
|
5293
5311
|
this.reflectExposure = 1;
|
|
5294
5312
|
this.reflectBlurIntensity = 5;
|
|
5295
5313
|
this.interval = 0;
|
|
5314
|
+
this.manual = false;
|
|
5296
5315
|
this.install = ()=>{
|
|
5297
5316
|
const viewer = this.viewer;
|
|
5298
5317
|
this._scene = scene || viewer.scene;
|
|
@@ -5315,15 +5334,15 @@ class EnvironmentPlugin extends Plugin {
|
|
|
5315
5334
|
};
|
|
5316
5335
|
}
|
|
5317
5336
|
}
|
|
5318
|
-
EnvironmentPlugin.
|
|
5337
|
+
EnvironmentPlugin.Quality = _Quality;
|
|
5319
5338
|
__decorate([
|
|
5320
5339
|
property
|
|
5321
5340
|
], EnvironmentPlugin.prototype, "debug", null);
|
|
5322
5341
|
__decorate([
|
|
5323
5342
|
property({
|
|
5324
|
-
value:
|
|
5343
|
+
value: _Quality
|
|
5325
5344
|
})
|
|
5326
|
-
], EnvironmentPlugin.prototype, "
|
|
5345
|
+
], EnvironmentPlugin.prototype, "quality", void 0);
|
|
5327
5346
|
__decorate([
|
|
5328
5347
|
property({
|
|
5329
5348
|
min: 0,
|
|
@@ -5348,6 +5367,9 @@ __decorate([
|
|
|
5348
5367
|
__decorate([
|
|
5349
5368
|
property
|
|
5350
5369
|
], EnvironmentPlugin.prototype, "interval", void 0);
|
|
5370
|
+
__decorate([
|
|
5371
|
+
property
|
|
5372
|
+
], EnvironmentPlugin.prototype, "manual", void 0);
|
|
5351
5373
|
|
|
5352
5374
|
class BoxProjectionPlugin extends Plugin {
|
|
5353
5375
|
get debug() {
|