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