@xviewer.js/core 1.0.0-alpha.46 → 1.0.0-alpha.48
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 +113 -93
- package/dist/main.js.map +1 -1
- package/dist/module.js +113 -93
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/types/Viewer.d.ts +2 -0
- package/types/components/index.d.ts +0 -1
- 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/types/plugins/PerformanceMonitorPlugin.d.ts +48 -0
- package/types/plugins/index.d.ts +1 -0
package/dist/module.js
CHANGED
|
@@ -3144,79 +3144,6 @@ class Reflector extends Component {
|
|
|
3144
3144
|
}
|
|
3145
3145
|
}
|
|
3146
3146
|
|
|
3147
|
-
class PerformanceMonitor extends Component {
|
|
3148
|
-
subscribe(subscriber) {
|
|
3149
|
-
this.subscriptions.set(Symbol(), subscriber);
|
|
3150
|
-
}
|
|
3151
|
-
constructor({ iterations = 10, ms = 250, threshold = 0.75, step = 0.1, factor: _factor = 0.5, flipflops = Infinity, bounds = (refreshrate)=>refreshrate > 100 ? [
|
|
3152
|
-
60,
|
|
3153
|
-
100
|
|
3154
|
-
] : [
|
|
3155
|
-
40,
|
|
3156
|
-
60
|
|
3157
|
-
], onIncline, onDecline, onChange, onFallback }){
|
|
3158
|
-
super();
|
|
3159
|
-
this.fps = 0;
|
|
3160
|
-
this.index = 0;
|
|
3161
|
-
this.factor = 0.5;
|
|
3162
|
-
this.flipped = 0;
|
|
3163
|
-
this.refreshrate = 0;
|
|
3164
|
-
this.fallback = false;
|
|
3165
|
-
this.frames = [];
|
|
3166
|
-
this.averages = [];
|
|
3167
|
-
this.subscriptions = new Map();
|
|
3168
|
-
let lastFactor = 0;
|
|
3169
|
-
const decimalPlacesRatio = Math.pow(10, 0);
|
|
3170
|
-
this.update = (dt)=>{
|
|
3171
|
-
// If the fallback has been reached do not continue running samples
|
|
3172
|
-
if (this.fallback) return;
|
|
3173
|
-
const { frames, averages } = this;
|
|
3174
|
-
if (averages.length < iterations) {
|
|
3175
|
-
frames.push(performance.now());
|
|
3176
|
-
const msPassed = frames[frames.length - 1] - frames[0];
|
|
3177
|
-
if (msPassed >= ms) {
|
|
3178
|
-
this.fps = Math.round(frames.length / msPassed * 1000 * decimalPlacesRatio) / decimalPlacesRatio;
|
|
3179
|
-
this.refreshrate = Math.max(this.refreshrate, this.fps);
|
|
3180
|
-
averages[this.index++ % iterations] = this.fps;
|
|
3181
|
-
if (averages.length === iterations) {
|
|
3182
|
-
const [lower, upper] = bounds(this.refreshrate);
|
|
3183
|
-
const upperBounds = averages.filter((value)=>value >= upper);
|
|
3184
|
-
const lowerBounds = averages.filter((value)=>value < lower);
|
|
3185
|
-
// Trigger incline when more than -threshold- avgs exceed the upper bound
|
|
3186
|
-
if (upperBounds.length > iterations * threshold) {
|
|
3187
|
-
this.factor = Math.min(1, this.factor + step);
|
|
3188
|
-
this.flipped++;
|
|
3189
|
-
if (onIncline) onIncline(this);
|
|
3190
|
-
this.subscriptions.forEach((value)=>value.onIncline && value.onIncline(this));
|
|
3191
|
-
}
|
|
3192
|
-
// Trigger decline when more than -threshold- avgs are below the lower bound
|
|
3193
|
-
if (lowerBounds.length > iterations * threshold) {
|
|
3194
|
-
this.factor = Math.max(0, this.factor - step);
|
|
3195
|
-
this.flipped++;
|
|
3196
|
-
if (onDecline) onDecline(this);
|
|
3197
|
-
this.subscriptions.forEach((value)=>value.onDecline && value.onDecline(this));
|
|
3198
|
-
}
|
|
3199
|
-
if (lastFactor !== this.factor) {
|
|
3200
|
-
lastFactor = this.factor;
|
|
3201
|
-
if (onChange) onChange(this);
|
|
3202
|
-
this.subscriptions.forEach((value)=>value.onChange && value.onChange(this));
|
|
3203
|
-
}
|
|
3204
|
-
if (this.flipped > flipflops && !this.fallback) {
|
|
3205
|
-
this.fallback = true;
|
|
3206
|
-
if (onFallback) onFallback(this);
|
|
3207
|
-
this.subscriptions.forEach((value)=>value.onFallback && value.onFallback(this));
|
|
3208
|
-
}
|
|
3209
|
-
this.averages = [];
|
|
3210
|
-
// Resetting the refreshrate creates more problems than it solves atm
|
|
3211
|
-
// this.refreshrate = 0
|
|
3212
|
-
}
|
|
3213
|
-
this.frames = [];
|
|
3214
|
-
}
|
|
3215
|
-
}
|
|
3216
|
-
};
|
|
3217
|
-
}
|
|
3218
|
-
}
|
|
3219
|
-
|
|
3220
3147
|
const vert_fullscreen = /*glsl*/ `
|
|
3221
3148
|
varying vec2 vUv;
|
|
3222
3149
|
void main() {
|
|
@@ -3675,10 +3602,11 @@ const _axisDirections = [
|
|
|
3675
3602
|
/*@__PURE__*/ new Vector3(PHI, INV_PHI, 0),
|
|
3676
3603
|
/*@__PURE__*/ new Vector3(-PHI, INV_PHI, 0)
|
|
3677
3604
|
];
|
|
3678
|
-
const
|
|
3679
|
-
|
|
3605
|
+
const _Quality = {
|
|
3606
|
+
LOW: 0,
|
|
3680
3607
|
MEDIUM: 1,
|
|
3681
|
-
|
|
3608
|
+
HIGH: 2,
|
|
3609
|
+
ULTRA: 3
|
|
3682
3610
|
};
|
|
3683
3611
|
function _setViewport(target, x, y, width, height) {
|
|
3684
3612
|
target.viewport.set(x, y, width, height);
|
|
@@ -4675,6 +4603,12 @@ class Viewer extends EventEmitter {
|
|
|
4675
4603
|
get input() {
|
|
4676
4604
|
return this._input;
|
|
4677
4605
|
}
|
|
4606
|
+
get targetFrameRate() {
|
|
4607
|
+
return this._targetFrameRate;
|
|
4608
|
+
}
|
|
4609
|
+
set targetFrameRate(v) {
|
|
4610
|
+
this._targetFrameRate = Math.max(1, v);
|
|
4611
|
+
}
|
|
4678
4612
|
destroy() {
|
|
4679
4613
|
this._renderer.dispose();
|
|
4680
4614
|
this._taskManager.destroy();
|
|
@@ -5076,7 +5010,7 @@ class MergeRefectPass {
|
|
|
5076
5010
|
}
|
|
5077
5011
|
mergeReflect(info) {
|
|
5078
5012
|
this._pmremGenerator._copyTexture(this._envMapTarget, this._sourceTarget.texture, info.envMapIntensity);
|
|
5079
|
-
this._pmremGenerator._mergeReflect(this._envMapTarget, this._reflectMap, info.
|
|
5013
|
+
this._pmremGenerator._mergeReflect(this._envMapTarget, this._reflectMap, info.quality);
|
|
5080
5014
|
info.envMapTarget = this._envMapTarget;
|
|
5081
5015
|
info.lodMax = this._pmremGenerator._lodMeshes.length - 1;
|
|
5082
5016
|
}
|
|
@@ -5110,19 +5044,19 @@ class MergeRefectPass {
|
|
|
5110
5044
|
pmremGenerator._clearTexture = function(targetOut, intensity) {
|
|
5111
5045
|
this._copyTexture(targetOut, this._sourceTarget.texture, intensity);
|
|
5112
5046
|
};
|
|
5113
|
-
pmremGenerator._mergeReflect = function(sourceTarget, reflectMap,
|
|
5047
|
+
pmremGenerator._mergeReflect = function(sourceTarget, reflectMap, quality) {
|
|
5114
5048
|
const renderer = this._renderer;
|
|
5115
5049
|
const autoClear = renderer.autoClear;
|
|
5116
5050
|
const cubeMapMaterial = this._cubeMapMaterial;
|
|
5117
5051
|
const uniforms = this._cubeMapMaterial.uniforms;
|
|
5118
5052
|
uniforms.envMap.value = reflectMap;
|
|
5119
5053
|
renderer.autoClear = false;
|
|
5120
|
-
if (
|
|
5054
|
+
if (quality === _Quality.HIGH) {
|
|
5121
5055
|
for(let i = 0; i < this._lodMeshes.length - 1; i++){
|
|
5122
5056
|
uniforms.lod.value = i < 5 ? 0 : i;
|
|
5123
5057
|
this._blit(sourceTarget, i, cubeMapMaterial);
|
|
5124
5058
|
}
|
|
5125
|
-
} else if (
|
|
5059
|
+
} else if (quality === _Quality.MEDIUM) {
|
|
5126
5060
|
for(let i = 0; i < this._lodMeshes.length; i++){
|
|
5127
5061
|
if (i < 4) {
|
|
5128
5062
|
uniforms.lod.value = 0;
|
|
@@ -5131,7 +5065,7 @@ class MergeRefectPass {
|
|
|
5131
5065
|
this._pmremblur(sourceTarget, i - 1, i);
|
|
5132
5066
|
}
|
|
5133
5067
|
}
|
|
5134
|
-
} else {
|
|
5068
|
+
} else if (quality === _Quality.ULTRA) {
|
|
5135
5069
|
uniforms.lod.value = 0;
|
|
5136
5070
|
this._blit(sourceTarget, 0, cubeMapMaterial);
|
|
5137
5071
|
for(let i = 1; i < this._lodMeshes.length; i++){
|
|
@@ -5317,11 +5251,18 @@ class EnvironmentPlugin extends Plugin {
|
|
|
5317
5251
|
}
|
|
5318
5252
|
}
|
|
5319
5253
|
onRender(dt) {
|
|
5320
|
-
if (this.
|
|
5321
|
-
this._elapsed
|
|
5254
|
+
if (!this.manual) {
|
|
5255
|
+
if (this._elapsed >= this.interval || this._elapsed === 0) {
|
|
5256
|
+
this._elapsed = 0;
|
|
5257
|
+
this._renderFrame();
|
|
5258
|
+
}
|
|
5259
|
+
this._elapsed += dt;
|
|
5260
|
+
}
|
|
5261
|
+
}
|
|
5262
|
+
manualFrame() {
|
|
5263
|
+
if (this.manual) {
|
|
5322
5264
|
this._renderFrame();
|
|
5323
5265
|
}
|
|
5324
|
-
this._elapsed += dt;
|
|
5325
5266
|
}
|
|
5326
5267
|
_renderFrame() {
|
|
5327
5268
|
const { renderer } = this.viewer;
|
|
@@ -5330,13 +5271,15 @@ class EnvironmentPlugin extends Plugin {
|
|
|
5330
5271
|
const oldActiveCubeFace = renderer.getActiveCubeFace();
|
|
5331
5272
|
const oldActiveMipmapLevel = renderer.getActiveMipmapLevel();
|
|
5332
5273
|
renderer.autoClear = true;
|
|
5333
|
-
this.
|
|
5334
|
-
this._mergeInfo.performance = this.performance;
|
|
5274
|
+
this._mergeInfo.quality = this.quality;
|
|
5335
5275
|
this._mergeInfo.exposure = this.reflectExposure;
|
|
5336
5276
|
this._mergeInfo.envMapIntensity = this.envMapIntensity;
|
|
5337
5277
|
this._mergeInfo.blurIntensity = this.reflectBlurIntensity;
|
|
5278
|
+
if (this.quality !== _Quality.LOW) {
|
|
5279
|
+
this._cubeCamera.update(renderer, this._scene);
|
|
5280
|
+
}
|
|
5338
5281
|
this._reflectPass.mergeReflect(this._mergeInfo);
|
|
5339
|
-
if (this.
|
|
5282
|
+
if (this.quality === _Quality.HIGH) {
|
|
5340
5283
|
if (this._mipBlurPass === undefined) {
|
|
5341
5284
|
this._mipBlurPass = new MergeMipBlurPass({
|
|
5342
5285
|
viewer: this.viewer,
|
|
@@ -5351,7 +5294,7 @@ class EnvironmentPlugin extends Plugin {
|
|
|
5351
5294
|
constructor({ envMap, scene, near, far, layer = 0, resolution = 256, floatType = HalfFloatType, position = new Vector3(0, 1, 0) } = {}){
|
|
5352
5295
|
super();
|
|
5353
5296
|
this._mergeInfo = {
|
|
5354
|
-
|
|
5297
|
+
quality: _Quality.HIGH,
|
|
5355
5298
|
envMapTarget: null,
|
|
5356
5299
|
envMapIntensity: 1,
|
|
5357
5300
|
blurIntensity: 1,
|
|
@@ -5361,11 +5304,12 @@ class EnvironmentPlugin extends Plugin {
|
|
|
5361
5304
|
this._debug = false;
|
|
5362
5305
|
this._debugNode = null;
|
|
5363
5306
|
this._elapsed = 0;
|
|
5364
|
-
this.
|
|
5307
|
+
this.quality = _Quality.HIGH;
|
|
5365
5308
|
this.envMapIntensity = 1;
|
|
5366
5309
|
this.reflectExposure = 1;
|
|
5367
5310
|
this.reflectBlurIntensity = 5;
|
|
5368
5311
|
this.interval = 0;
|
|
5312
|
+
this.manual = false;
|
|
5369
5313
|
this.install = ()=>{
|
|
5370
5314
|
const viewer = this.viewer;
|
|
5371
5315
|
this._scene = scene || viewer.scene;
|
|
@@ -5388,15 +5332,15 @@ class EnvironmentPlugin extends Plugin {
|
|
|
5388
5332
|
};
|
|
5389
5333
|
}
|
|
5390
5334
|
}
|
|
5391
|
-
EnvironmentPlugin.
|
|
5335
|
+
EnvironmentPlugin.Quality = _Quality;
|
|
5392
5336
|
__decorate([
|
|
5393
5337
|
property
|
|
5394
5338
|
], EnvironmentPlugin.prototype, "debug", null);
|
|
5395
5339
|
__decorate([
|
|
5396
5340
|
property({
|
|
5397
|
-
value:
|
|
5341
|
+
value: _Quality
|
|
5398
5342
|
})
|
|
5399
|
-
], EnvironmentPlugin.prototype, "
|
|
5343
|
+
], EnvironmentPlugin.prototype, "quality", void 0);
|
|
5400
5344
|
__decorate([
|
|
5401
5345
|
property({
|
|
5402
5346
|
min: 0,
|
|
@@ -5421,6 +5365,9 @@ __decorate([
|
|
|
5421
5365
|
__decorate([
|
|
5422
5366
|
property
|
|
5423
5367
|
], EnvironmentPlugin.prototype, "interval", void 0);
|
|
5368
|
+
__decorate([
|
|
5369
|
+
property
|
|
5370
|
+
], EnvironmentPlugin.prototype, "manual", void 0);
|
|
5424
5371
|
|
|
5425
5372
|
class BoxProjectionPlugin extends Plugin {
|
|
5426
5373
|
get debug() {
|
|
@@ -5549,5 +5496,78 @@ __decorate([
|
|
|
5549
5496
|
property
|
|
5550
5497
|
], BoxProjectionPlugin.prototype, "boxMax", null);
|
|
5551
5498
|
|
|
5552
|
-
|
|
5499
|
+
class PerformanceMonitorPlugin extends Plugin {
|
|
5500
|
+
subscribe(subscriber) {
|
|
5501
|
+
this.subscriptions.set(Symbol(), subscriber);
|
|
5502
|
+
}
|
|
5503
|
+
constructor({ iterations = 10, ms = 250, threshold = 0.75, step = 0.1, factor: _factor = 0.5, flipflops = Infinity, bounds = (refreshrate)=>refreshrate > 100 ? [
|
|
5504
|
+
60,
|
|
5505
|
+
100
|
|
5506
|
+
] : [
|
|
5507
|
+
40,
|
|
5508
|
+
60
|
|
5509
|
+
], onIncline, onDecline, onChange, onFallback }){
|
|
5510
|
+
super();
|
|
5511
|
+
this.fps = 0;
|
|
5512
|
+
this.index = 0;
|
|
5513
|
+
this.factor = 0.5;
|
|
5514
|
+
this.flipped = 0;
|
|
5515
|
+
this.refreshrate = 0;
|
|
5516
|
+
this.fallback = false;
|
|
5517
|
+
this.frames = [];
|
|
5518
|
+
this.averages = [];
|
|
5519
|
+
this.subscriptions = new Map();
|
|
5520
|
+
let lastFactor = 0;
|
|
5521
|
+
const decimalPlacesRatio = Math.pow(10, 0);
|
|
5522
|
+
this.onUpdate = (dt)=>{
|
|
5523
|
+
// If the fallback has been reached do not continue running samples
|
|
5524
|
+
if (this.fallback) return;
|
|
5525
|
+
const { frames, averages } = this;
|
|
5526
|
+
if (averages.length < iterations) {
|
|
5527
|
+
frames.push(performance.now());
|
|
5528
|
+
const msPassed = frames[frames.length - 1] - frames[0];
|
|
5529
|
+
if (msPassed >= ms) {
|
|
5530
|
+
this.fps = Math.round(frames.length / msPassed * 1000 * decimalPlacesRatio) / decimalPlacesRatio;
|
|
5531
|
+
this.refreshrate = Math.max(this.refreshrate, this.fps);
|
|
5532
|
+
averages[this.index++ % iterations] = this.fps;
|
|
5533
|
+
if (averages.length === iterations) {
|
|
5534
|
+
const [lower, upper] = bounds(this.refreshrate);
|
|
5535
|
+
const upperBounds = averages.filter((value)=>value >= upper);
|
|
5536
|
+
const lowerBounds = averages.filter((value)=>value < lower);
|
|
5537
|
+
// Trigger incline when more than -threshold- avgs exceed the upper bound
|
|
5538
|
+
if (upperBounds.length > iterations * threshold) {
|
|
5539
|
+
this.factor = Math.min(1, this.factor + step);
|
|
5540
|
+
this.flipped++;
|
|
5541
|
+
if (onIncline) onIncline(this);
|
|
5542
|
+
this.subscriptions.forEach((value)=>value.onIncline && value.onIncline(this));
|
|
5543
|
+
}
|
|
5544
|
+
// Trigger decline when more than -threshold- avgs are below the lower bound
|
|
5545
|
+
if (lowerBounds.length > iterations * threshold) {
|
|
5546
|
+
this.factor = Math.max(0, this.factor - step);
|
|
5547
|
+
this.flipped++;
|
|
5548
|
+
if (onDecline) onDecline(this);
|
|
5549
|
+
this.subscriptions.forEach((value)=>value.onDecline && value.onDecline(this));
|
|
5550
|
+
}
|
|
5551
|
+
if (lastFactor !== this.factor) {
|
|
5552
|
+
lastFactor = this.factor;
|
|
5553
|
+
if (onChange) onChange(this);
|
|
5554
|
+
this.subscriptions.forEach((value)=>value.onChange && value.onChange(this));
|
|
5555
|
+
}
|
|
5556
|
+
if (this.flipped > flipflops && !this.fallback) {
|
|
5557
|
+
this.fallback = true;
|
|
5558
|
+
if (onFallback) onFallback(this);
|
|
5559
|
+
this.subscriptions.forEach((value)=>value.onFallback && value.onFallback(this));
|
|
5560
|
+
}
|
|
5561
|
+
this.averages = [];
|
|
5562
|
+
// Resetting the refreshrate creates more problems than it solves atm
|
|
5563
|
+
// this.refreshrate = 0
|
|
5564
|
+
}
|
|
5565
|
+
this.frames = [];
|
|
5566
|
+
}
|
|
5567
|
+
}
|
|
5568
|
+
};
|
|
5569
|
+
}
|
|
5570
|
+
}
|
|
5571
|
+
|
|
5572
|
+
export { AnimationCurve, Box, BoxProjectionPlugin, CinestationBlendDefinition, CinestationBrain, Component, DebugPlugin, DeviceInput, Easing, EnvironmentPlugin, EventEmitter, FInterpConstantTo, FInterpTo, FreelookVirtualCamera, Logger, ObjectInstance, Orientation, PerformanceMonitorPlugin, Perlin, Plane, Plugin, PropertyManager, QInterpConstantTo, QInterpTo, Quat_AngularDistance, Quat_Equals, Quat_exponentialDamp, Quat_quarticDamp, Quat_smoothDamp, Reflector, ReflectorMaterial, Sphere, SystemInfo, Tween, TweenChain, TweenManager, VInterpConstantTo, VInterpTo, Vec3_smoothDamp, Vector3_NEG_ONE, Vector3_ONE, Vector3_RIGHT, Vector3_UNIT_X, Vector3_UNIT_Y, Vector3_UNIT_Z, Vector3_UP, Vector3_ZERO, Viewer, VirtualCamera, aEXRLoader, aFBXLoader, aGLTFLoader, aHDRLoader, aJSONLoader, aLoader, aTextureLoader, exponentialDamp, frag_BoxfilterBlur, frag_cubeMapToPanorama, frag_panoramaToCubeMap, getClassInstance, getShaderMaterial, mixin, property, quarticDamp, smoothDamp, vert_fullscreen };
|
|
5553
5573
|
//# sourceMappingURL=module.js.map
|