@base2datadesign/viewer-kit 0.2.7 → 0.2.8
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewerEngine.d.ts","sourceRoot":"","sources":["../../src/engine/ViewerEngine.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAiB,WAAW,EAAiB,sBAAsB,EAAE,mBAAmB,EAAmB,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAQrK,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAiB;IAE1D,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,SAAS,CAAc;IAE/B,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,iBAAiB,CAAU;IAEnC,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAS;
|
|
1
|
+
{"version":3,"file":"ViewerEngine.d.ts","sourceRoot":"","sources":["../../src/engine/ViewerEngine.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAiB,WAAW,EAAiB,sBAAsB,EAAE,mBAAmB,EAAmB,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAQrK,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB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astHeight;
|
|
28
|
+
maxPixelRatio;
|
|
28
29
|
constructor(options) {
|
|
29
30
|
this.container = options.container;
|
|
30
31
|
const basePresets = options.presets ?? DEFAULT_PRESETS;
|
|
@@ -47,6 +48,11 @@ export class ViewerEngine {
|
|
|
47
48
|
this.controls = new OrbitControls(this.camera, this.renderer.domElement);
|
|
48
49
|
this.controls.enableDamping = true;
|
|
49
50
|
this.controls.dampingFactor = 0.05;
|
|
51
|
+
this.controls.addEventListener("change", () => {
|
|
52
|
+
if (this.usePostprocessing) {
|
|
53
|
+
this.postFxSystem.invalidate();
|
|
54
|
+
}
|
|
55
|
+
});
|
|
50
56
|
const target = options.camera?.target ?? [0, 1.5, 0];
|
|
51
57
|
this.controls.target.set(...target);
|
|
52
58
|
this.controls.update();
|
|
@@ -59,6 +65,7 @@ export class ViewerEngine {
|
|
|
59
65
|
this.usePostprocessing = options.usePostprocessing ?? true;
|
|
60
66
|
this.lastWidth = width;
|
|
61
67
|
this.lastHeight = height;
|
|
68
|
+
this.maxPixelRatio = 1.75;
|
|
62
69
|
this.postFxSystem.resize(width, height);
|
|
63
70
|
this.applyPreset(this.presetId);
|
|
64
71
|
}
|
|
@@ -86,6 +93,9 @@ export class ViewerEngine {
|
|
|
86
93
|
const loop = () => {
|
|
87
94
|
if (!this.running)
|
|
88
95
|
return;
|
|
96
|
+
if (this.container.clientWidth !== this.lastWidth || this.container.clientHeight !== this.lastHeight) {
|
|
97
|
+
this.resize();
|
|
98
|
+
}
|
|
89
99
|
this.controls.update();
|
|
90
100
|
if (this.usePostprocessing) {
|
|
91
101
|
this.postFxSystem.render();
|
|
@@ -109,6 +119,8 @@ export class ViewerEngine {
|
|
|
109
119
|
const height = this.container.clientHeight || 1;
|
|
110
120
|
this.lastWidth = width;
|
|
111
121
|
this.lastHeight = height;
|
|
122
|
+
const deviceRatio = typeof window !== "undefined" ? window.devicePixelRatio : 1;
|
|
123
|
+
this.renderer.setPixelRatio(Math.min(deviceRatio, this.maxPixelRatio));
|
|
112
124
|
this.camera.aspect = width / height;
|
|
113
125
|
this.camera.updateProjectionMatrix();
|
|
114
126
|
this.renderer.setSize(width, height);
|
|
@@ -278,12 +290,14 @@ export class ViewerEngine {
|
|
|
278
290
|
? { ...preset.renderer, toneMappingExposure: exposureOverride }
|
|
279
291
|
: preset.renderer;
|
|
280
292
|
applyRendererConfig(this.renderer, rendererConfig);
|
|
293
|
+
this.maxPixelRatio = rendererConfig?.maxPixelRatio ?? this.maxPixelRatio;
|
|
281
294
|
// applyRendererConfig can change pixel ratio; keep drawing buffer in sync.
|
|
282
295
|
this.renderer.setSize(this.lastWidth, this.lastHeight);
|
|
283
296
|
this.postFxSystem.resize(this.lastWidth, this.lastHeight);
|
|
284
297
|
void this.environmentSystem.apply(preset);
|
|
285
298
|
this.lightingSystem.apply(preset);
|
|
286
299
|
this.postFxSystem.apply(this.usePostprocessing ? preset.postfx : undefined);
|
|
300
|
+
this.postFxSystem.invalidate();
|
|
287
301
|
this.debugSystem.apply(preset);
|
|
288
302
|
}
|
|
289
303
|
resolvePreset(presetId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postfxSystem.d.ts","sourceRoot":"","sources":["../../src/systems/postfxSystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,cAAc,CAA+B;IACrD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,S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;QAAC,YAAY,EAAE,OAAO,CAAC;QAAC,eAAe,EAAE,OAAO,CAAA;KAAE;CAOpF"}
|
|
@@ -121,6 +121,7 @@ export class PostFxSystem {
|
|
|
121
121
|
if (lastPass) {
|
|
122
122
|
lastPass.renderToScreen = true;
|
|
123
123
|
}
|
|
124
|
+
this.invalidate();
|
|
124
125
|
}
|
|
125
126
|
render() {
|
|
126
127
|
if (this.enabled && this.composer) {
|
|
@@ -138,6 +139,7 @@ export class PostFxSystem {
|
|
|
138
139
|
this.composer.setSize(width, height);
|
|
139
140
|
if (this.aoPass)
|
|
140
141
|
this.aoPass.setSize(width, height);
|
|
142
|
+
this.invalidate();
|
|
141
143
|
if (this.pendingConfig) {
|
|
142
144
|
const pending = this.pendingConfig;
|
|
143
145
|
this.pendingConfig = null;
|