@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/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() {
|
|
@@ -5549,5 +5476,78 @@ __decorate([
|
|
|
5549
5476
|
property
|
|
5550
5477
|
], BoxProjectionPlugin.prototype, "boxMax", null);
|
|
5551
5478
|
|
|
5552
|
-
|
|
5479
|
+
class PerformanceMonitorPlugin extends Plugin {
|
|
5480
|
+
subscribe(subscriber) {
|
|
5481
|
+
this.subscriptions.set(Symbol(), subscriber);
|
|
5482
|
+
}
|
|
5483
|
+
constructor({ iterations = 10, ms = 250, threshold = 0.75, step = 0.1, factor: _factor = 0.5, flipflops = Infinity, bounds = (refreshrate)=>refreshrate > 100 ? [
|
|
5484
|
+
60,
|
|
5485
|
+
100
|
|
5486
|
+
] : [
|
|
5487
|
+
40,
|
|
5488
|
+
60
|
|
5489
|
+
], onIncline, onDecline, onChange, onFallback }){
|
|
5490
|
+
super();
|
|
5491
|
+
this.fps = 0;
|
|
5492
|
+
this.index = 0;
|
|
5493
|
+
this.factor = 0.5;
|
|
5494
|
+
this.flipped = 0;
|
|
5495
|
+
this.refreshrate = 0;
|
|
5496
|
+
this.fallback = false;
|
|
5497
|
+
this.frames = [];
|
|
5498
|
+
this.averages = [];
|
|
5499
|
+
this.subscriptions = new Map();
|
|
5500
|
+
let lastFactor = 0;
|
|
5501
|
+
const decimalPlacesRatio = Math.pow(10, 0);
|
|
5502
|
+
this.onUpdate = (dt)=>{
|
|
5503
|
+
// If the fallback has been reached do not continue running samples
|
|
5504
|
+
if (this.fallback) return;
|
|
5505
|
+
const { frames, averages } = this;
|
|
5506
|
+
if (averages.length < iterations) {
|
|
5507
|
+
frames.push(performance.now());
|
|
5508
|
+
const msPassed = frames[frames.length - 1] - frames[0];
|
|
5509
|
+
if (msPassed >= ms) {
|
|
5510
|
+
this.fps = Math.round(frames.length / msPassed * 1000 * decimalPlacesRatio) / decimalPlacesRatio;
|
|
5511
|
+
this.refreshrate = Math.max(this.refreshrate, this.fps);
|
|
5512
|
+
averages[this.index++ % iterations] = this.fps;
|
|
5513
|
+
if (averages.length === iterations) {
|
|
5514
|
+
const [lower, upper] = bounds(this.refreshrate);
|
|
5515
|
+
const upperBounds = averages.filter((value)=>value >= upper);
|
|
5516
|
+
const lowerBounds = averages.filter((value)=>value < lower);
|
|
5517
|
+
// Trigger incline when more than -threshold- avgs exceed the upper bound
|
|
5518
|
+
if (upperBounds.length > iterations * threshold) {
|
|
5519
|
+
this.factor = Math.min(1, this.factor + step);
|
|
5520
|
+
this.flipped++;
|
|
5521
|
+
if (onIncline) onIncline(this);
|
|
5522
|
+
this.subscriptions.forEach((value)=>value.onIncline && value.onIncline(this));
|
|
5523
|
+
}
|
|
5524
|
+
// Trigger decline when more than -threshold- avgs are below the lower bound
|
|
5525
|
+
if (lowerBounds.length > iterations * threshold) {
|
|
5526
|
+
this.factor = Math.max(0, this.factor - step);
|
|
5527
|
+
this.flipped++;
|
|
5528
|
+
if (onDecline) onDecline(this);
|
|
5529
|
+
this.subscriptions.forEach((value)=>value.onDecline && value.onDecline(this));
|
|
5530
|
+
}
|
|
5531
|
+
if (lastFactor !== this.factor) {
|
|
5532
|
+
lastFactor = this.factor;
|
|
5533
|
+
if (onChange) onChange(this);
|
|
5534
|
+
this.subscriptions.forEach((value)=>value.onChange && value.onChange(this));
|
|
5535
|
+
}
|
|
5536
|
+
if (this.flipped > flipflops && !this.fallback) {
|
|
5537
|
+
this.fallback = true;
|
|
5538
|
+
if (onFallback) onFallback(this);
|
|
5539
|
+
this.subscriptions.forEach((value)=>value.onFallback && value.onFallback(this));
|
|
5540
|
+
}
|
|
5541
|
+
this.averages = [];
|
|
5542
|
+
// Resetting the refreshrate creates more problems than it solves atm
|
|
5543
|
+
// this.refreshrate = 0
|
|
5544
|
+
}
|
|
5545
|
+
this.frames = [];
|
|
5546
|
+
}
|
|
5547
|
+
}
|
|
5548
|
+
};
|
|
5549
|
+
}
|
|
5550
|
+
}
|
|
5551
|
+
|
|
5552
|
+
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
5553
|
//# sourceMappingURL=module.js.map
|