@xviewer.js/core 1.0.0-alpha.45 → 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 +92 -6
- package/dist/main.js.map +1 -1
- package/dist/module.js +92 -7
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/types/Viewer.d.ts +2 -2
- package/types/components/PerformanceMonitor.d.ts +48 -0
- package/types/plugins/EnvironmentPlugin.d.ts +4 -1
- package/types/plugins/PerformanceMonitorPlugin.d.ts +48 -0
- package/types/plugins/index.d.ts +1 -0
package/dist/module.js
CHANGED
|
@@ -4836,7 +4836,7 @@ class Viewer extends EventEmitter {
|
|
|
4836
4836
|
node.visible = active;
|
|
4837
4837
|
return node;
|
|
4838
4838
|
}
|
|
4839
|
-
createRenderTarget(width, height, nearest = false, floatType = false, msaa = 0, mipmap = false) {
|
|
4839
|
+
createRenderTarget(width, height, nearest = false, floatType = false, msaa = 0, mipmap = false, depth = false) {
|
|
4840
4840
|
return new WebGLRenderTarget(width, height, {
|
|
4841
4841
|
wrapS: ClampToEdgeWrapping,
|
|
4842
4842
|
wrapT: ClampToEdgeWrapping,
|
|
@@ -4845,13 +4845,13 @@ class Viewer extends EventEmitter {
|
|
|
4845
4845
|
type: typeof floatType === "boolean" ? floatType ? this.DATA_FLOAT_TYPE : UnsignedByteType : floatType,
|
|
4846
4846
|
anisotropy: 0,
|
|
4847
4847
|
colorSpace: LinearSRGBColorSpace,
|
|
4848
|
-
depthBuffer:
|
|
4848
|
+
depthBuffer: depth,
|
|
4849
4849
|
stencilBuffer: false,
|
|
4850
4850
|
samples: SystemInfo.isSupportMSAA ? msaa : 0,
|
|
4851
4851
|
generateMipmaps: mipmap
|
|
4852
4852
|
});
|
|
4853
4853
|
}
|
|
4854
|
-
createCubeRenderTarget(size, nearest = false, floatType = false, msaa = 0, mipmap = false) {
|
|
4854
|
+
createCubeRenderTarget(size, nearest = false, floatType = false, msaa = 0, mipmap = false, depth = false) {
|
|
4855
4855
|
return new WebGLCubeRenderTarget(size, {
|
|
4856
4856
|
wrapS: ClampToEdgeWrapping,
|
|
4857
4857
|
wrapT: ClampToEdgeWrapping,
|
|
@@ -4860,7 +4860,7 @@ class Viewer extends EventEmitter {
|
|
|
4860
4860
|
type: typeof floatType === "boolean" ? floatType ? this.DATA_FLOAT_TYPE : UnsignedByteType : floatType,
|
|
4861
4861
|
anisotropy: 0,
|
|
4862
4862
|
colorSpace: LinearSRGBColorSpace,
|
|
4863
|
-
depthBuffer:
|
|
4863
|
+
depthBuffer: depth,
|
|
4864
4864
|
stencilBuffer: false,
|
|
4865
4865
|
samples: SystemInfo.isSupportMSAA ? msaa : 0,
|
|
4866
4866
|
generateMipmaps: mipmap
|
|
@@ -5243,7 +5243,14 @@ class EnvironmentPlugin extends Plugin {
|
|
|
5243
5243
|
}
|
|
5244
5244
|
}
|
|
5245
5245
|
}
|
|
5246
|
-
onRender() {
|
|
5246
|
+
onRender(dt) {
|
|
5247
|
+
if (this._elapsed >= this.interval || this._elapsed === 0) {
|
|
5248
|
+
this._elapsed = 0;
|
|
5249
|
+
this._renderFrame();
|
|
5250
|
+
}
|
|
5251
|
+
this._elapsed += dt;
|
|
5252
|
+
}
|
|
5253
|
+
_renderFrame() {
|
|
5247
5254
|
const { renderer } = this.viewer;
|
|
5248
5255
|
const autoClear = renderer.autoClear;
|
|
5249
5256
|
const oldTarget = renderer.getRenderTarget();
|
|
@@ -5280,14 +5287,16 @@ class EnvironmentPlugin extends Plugin {
|
|
|
5280
5287
|
};
|
|
5281
5288
|
this._debug = false;
|
|
5282
5289
|
this._debugNode = null;
|
|
5290
|
+
this._elapsed = 0;
|
|
5283
5291
|
this.performance = _Performance.HIGH;
|
|
5284
5292
|
this.envMapIntensity = 1;
|
|
5285
5293
|
this.reflectExposure = 1;
|
|
5286
5294
|
this.reflectBlurIntensity = 5;
|
|
5295
|
+
this.interval = 0;
|
|
5287
5296
|
this.install = ()=>{
|
|
5288
5297
|
const viewer = this.viewer;
|
|
5289
5298
|
this._scene = scene || viewer.scene;
|
|
5290
|
-
const cubeRenderTarget = viewer.createCubeRenderTarget(resolution, false, floatType, 0, true);
|
|
5299
|
+
const cubeRenderTarget = viewer.createCubeRenderTarget(resolution, false, floatType, 0, true, true);
|
|
5291
5300
|
this._cubeCamera = new CubeCamera(near || viewer.camera.near, far || viewer.camera.far, cubeRenderTarget);
|
|
5292
5301
|
this._cubeCamera.position.copy(position);
|
|
5293
5302
|
this._cubeCamera.layers.mask = layer;
|
|
@@ -5336,6 +5345,9 @@ __decorate([
|
|
|
5336
5345
|
step: 0.1
|
|
5337
5346
|
})
|
|
5338
5347
|
], EnvironmentPlugin.prototype, "reflectBlurIntensity", void 0);
|
|
5348
|
+
__decorate([
|
|
5349
|
+
property
|
|
5350
|
+
], EnvironmentPlugin.prototype, "interval", void 0);
|
|
5339
5351
|
|
|
5340
5352
|
class BoxProjectionPlugin extends Plugin {
|
|
5341
5353
|
get debug() {
|
|
@@ -5464,5 +5476,78 @@ __decorate([
|
|
|
5464
5476
|
property
|
|
5465
5477
|
], BoxProjectionPlugin.prototype, "boxMax", null);
|
|
5466
5478
|
|
|
5467
|
-
|
|
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 };
|
|
5468
5553
|
//# sourceMappingURL=module.js.map
|