@xviewer.js/core 1.0.0-alpha.46 → 1.0.0-alpha.47
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 +74 -74
- package/dist/main.js.map +1 -1
- package/dist/module.js +74 -74
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/types/components/index.d.ts +0 -1
- package/types/plugins/PerformanceMonitorPlugin.d.ts +48 -0
- package/types/plugins/index.d.ts +1 -0
package/dist/main.js
CHANGED
|
@@ -3146,79 +3146,6 @@ class Reflector extends Component {
|
|
|
3146
3146
|
}
|
|
3147
3147
|
}
|
|
3148
3148
|
|
|
3149
|
-
class PerformanceMonitor extends Component {
|
|
3150
|
-
subscribe(subscriber) {
|
|
3151
|
-
this.subscriptions.set(Symbol(), subscriber);
|
|
3152
|
-
}
|
|
3153
|
-
constructor({ iterations = 10, ms = 250, threshold = 0.75, step = 0.1, factor: _factor = 0.5, flipflops = Infinity, bounds = (refreshrate)=>refreshrate > 100 ? [
|
|
3154
|
-
60,
|
|
3155
|
-
100
|
|
3156
|
-
] : [
|
|
3157
|
-
40,
|
|
3158
|
-
60
|
|
3159
|
-
], onIncline, onDecline, onChange, onFallback }){
|
|
3160
|
-
super();
|
|
3161
|
-
this.fps = 0;
|
|
3162
|
-
this.index = 0;
|
|
3163
|
-
this.factor = 0.5;
|
|
3164
|
-
this.flipped = 0;
|
|
3165
|
-
this.refreshrate = 0;
|
|
3166
|
-
this.fallback = false;
|
|
3167
|
-
this.frames = [];
|
|
3168
|
-
this.averages = [];
|
|
3169
|
-
this.subscriptions = new Map();
|
|
3170
|
-
let lastFactor = 0;
|
|
3171
|
-
const decimalPlacesRatio = Math.pow(10, 0);
|
|
3172
|
-
this.update = (dt)=>{
|
|
3173
|
-
// If the fallback has been reached do not continue running samples
|
|
3174
|
-
if (this.fallback) return;
|
|
3175
|
-
const { frames, averages } = this;
|
|
3176
|
-
if (averages.length < iterations) {
|
|
3177
|
-
frames.push(performance.now());
|
|
3178
|
-
const msPassed = frames[frames.length - 1] - frames[0];
|
|
3179
|
-
if (msPassed >= ms) {
|
|
3180
|
-
this.fps = Math.round(frames.length / msPassed * 1000 * decimalPlacesRatio) / decimalPlacesRatio;
|
|
3181
|
-
this.refreshrate = Math.max(this.refreshrate, this.fps);
|
|
3182
|
-
averages[this.index++ % iterations] = this.fps;
|
|
3183
|
-
if (averages.length === iterations) {
|
|
3184
|
-
const [lower, upper] = bounds(this.refreshrate);
|
|
3185
|
-
const upperBounds = averages.filter((value)=>value >= upper);
|
|
3186
|
-
const lowerBounds = averages.filter((value)=>value < lower);
|
|
3187
|
-
// Trigger incline when more than -threshold- avgs exceed the upper bound
|
|
3188
|
-
if (upperBounds.length > iterations * threshold) {
|
|
3189
|
-
this.factor = Math.min(1, this.factor + step);
|
|
3190
|
-
this.flipped++;
|
|
3191
|
-
if (onIncline) onIncline(this);
|
|
3192
|
-
this.subscriptions.forEach((value)=>value.onIncline && value.onIncline(this));
|
|
3193
|
-
}
|
|
3194
|
-
// Trigger decline when more than -threshold- avgs are below the lower bound
|
|
3195
|
-
if (lowerBounds.length > iterations * threshold) {
|
|
3196
|
-
this.factor = Math.max(0, this.factor - step);
|
|
3197
|
-
this.flipped++;
|
|
3198
|
-
if (onDecline) onDecline(this);
|
|
3199
|
-
this.subscriptions.forEach((value)=>value.onDecline && value.onDecline(this));
|
|
3200
|
-
}
|
|
3201
|
-
if (lastFactor !== this.factor) {
|
|
3202
|
-
lastFactor = this.factor;
|
|
3203
|
-
if (onChange) onChange(this);
|
|
3204
|
-
this.subscriptions.forEach((value)=>value.onChange && value.onChange(this));
|
|
3205
|
-
}
|
|
3206
|
-
if (this.flipped > flipflops && !this.fallback) {
|
|
3207
|
-
this.fallback = true;
|
|
3208
|
-
if (onFallback) onFallback(this);
|
|
3209
|
-
this.subscriptions.forEach((value)=>value.onFallback && value.onFallback(this));
|
|
3210
|
-
}
|
|
3211
|
-
this.averages = [];
|
|
3212
|
-
// Resetting the refreshrate creates more problems than it solves atm
|
|
3213
|
-
// this.refreshrate = 0
|
|
3214
|
-
}
|
|
3215
|
-
this.frames = [];
|
|
3216
|
-
}
|
|
3217
|
-
}
|
|
3218
|
-
};
|
|
3219
|
-
}
|
|
3220
|
-
}
|
|
3221
|
-
|
|
3222
3149
|
const vert_fullscreen = /*glsl*/ `
|
|
3223
3150
|
varying vec2 vUv;
|
|
3224
3151
|
void main() {
|
|
@@ -5551,6 +5478,79 @@ __decorate([
|
|
|
5551
5478
|
property
|
|
5552
5479
|
], BoxProjectionPlugin.prototype, "boxMax", null);
|
|
5553
5480
|
|
|
5481
|
+
class PerformanceMonitorPlugin extends Plugin {
|
|
5482
|
+
subscribe(subscriber) {
|
|
5483
|
+
this.subscriptions.set(Symbol(), subscriber);
|
|
5484
|
+
}
|
|
5485
|
+
constructor({ iterations = 10, ms = 250, threshold = 0.75, step = 0.1, factor: _factor = 0.5, flipflops = Infinity, bounds = (refreshrate)=>refreshrate > 100 ? [
|
|
5486
|
+
60,
|
|
5487
|
+
100
|
|
5488
|
+
] : [
|
|
5489
|
+
40,
|
|
5490
|
+
60
|
|
5491
|
+
], onIncline, onDecline, onChange, onFallback }){
|
|
5492
|
+
super();
|
|
5493
|
+
this.fps = 0;
|
|
5494
|
+
this.index = 0;
|
|
5495
|
+
this.factor = 0.5;
|
|
5496
|
+
this.flipped = 0;
|
|
5497
|
+
this.refreshrate = 0;
|
|
5498
|
+
this.fallback = false;
|
|
5499
|
+
this.frames = [];
|
|
5500
|
+
this.averages = [];
|
|
5501
|
+
this.subscriptions = new Map();
|
|
5502
|
+
let lastFactor = 0;
|
|
5503
|
+
const decimalPlacesRatio = Math.pow(10, 0);
|
|
5504
|
+
this.onUpdate = (dt)=>{
|
|
5505
|
+
// If the fallback has been reached do not continue running samples
|
|
5506
|
+
if (this.fallback) return;
|
|
5507
|
+
const { frames, averages } = this;
|
|
5508
|
+
if (averages.length < iterations) {
|
|
5509
|
+
frames.push(performance.now());
|
|
5510
|
+
const msPassed = frames[frames.length - 1] - frames[0];
|
|
5511
|
+
if (msPassed >= ms) {
|
|
5512
|
+
this.fps = Math.round(frames.length / msPassed * 1000 * decimalPlacesRatio) / decimalPlacesRatio;
|
|
5513
|
+
this.refreshrate = Math.max(this.refreshrate, this.fps);
|
|
5514
|
+
averages[this.index++ % iterations] = this.fps;
|
|
5515
|
+
if (averages.length === iterations) {
|
|
5516
|
+
const [lower, upper] = bounds(this.refreshrate);
|
|
5517
|
+
const upperBounds = averages.filter((value)=>value >= upper);
|
|
5518
|
+
const lowerBounds = averages.filter((value)=>value < lower);
|
|
5519
|
+
// Trigger incline when more than -threshold- avgs exceed the upper bound
|
|
5520
|
+
if (upperBounds.length > iterations * threshold) {
|
|
5521
|
+
this.factor = Math.min(1, this.factor + step);
|
|
5522
|
+
this.flipped++;
|
|
5523
|
+
if (onIncline) onIncline(this);
|
|
5524
|
+
this.subscriptions.forEach((value)=>value.onIncline && value.onIncline(this));
|
|
5525
|
+
}
|
|
5526
|
+
// Trigger decline when more than -threshold- avgs are below the lower bound
|
|
5527
|
+
if (lowerBounds.length > iterations * threshold) {
|
|
5528
|
+
this.factor = Math.max(0, this.factor - step);
|
|
5529
|
+
this.flipped++;
|
|
5530
|
+
if (onDecline) onDecline(this);
|
|
5531
|
+
this.subscriptions.forEach((value)=>value.onDecline && value.onDecline(this));
|
|
5532
|
+
}
|
|
5533
|
+
if (lastFactor !== this.factor) {
|
|
5534
|
+
lastFactor = this.factor;
|
|
5535
|
+
if (onChange) onChange(this);
|
|
5536
|
+
this.subscriptions.forEach((value)=>value.onChange && value.onChange(this));
|
|
5537
|
+
}
|
|
5538
|
+
if (this.flipped > flipflops && !this.fallback) {
|
|
5539
|
+
this.fallback = true;
|
|
5540
|
+
if (onFallback) onFallback(this);
|
|
5541
|
+
this.subscriptions.forEach((value)=>value.onFallback && value.onFallback(this));
|
|
5542
|
+
}
|
|
5543
|
+
this.averages = [];
|
|
5544
|
+
// Resetting the refreshrate creates more problems than it solves atm
|
|
5545
|
+
// this.refreshrate = 0
|
|
5546
|
+
}
|
|
5547
|
+
this.frames = [];
|
|
5548
|
+
}
|
|
5549
|
+
}
|
|
5550
|
+
};
|
|
5551
|
+
}
|
|
5552
|
+
}
|
|
5553
|
+
|
|
5554
5554
|
exports.AnimationCurve = AnimationCurve;
|
|
5555
5555
|
exports.Box = Box;
|
|
5556
5556
|
exports.BoxProjectionPlugin = BoxProjectionPlugin;
|
|
@@ -5567,7 +5567,7 @@ exports.FInterpTo = FInterpTo;
|
|
|
5567
5567
|
exports.FreelookVirtualCamera = FreelookVirtualCamera;
|
|
5568
5568
|
exports.Logger = Logger;
|
|
5569
5569
|
exports.ObjectInstance = ObjectInstance;
|
|
5570
|
-
exports.
|
|
5570
|
+
exports.PerformanceMonitorPlugin = PerformanceMonitorPlugin;
|
|
5571
5571
|
exports.Perlin = Perlin;
|
|
5572
5572
|
exports.Plane = Plane;
|
|
5573
5573
|
exports.Plugin = Plugin;
|