@base2datadesign/viewer-kit 0.2.2 → 0.2.4
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;
|
|
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;gBAEf,OAAO,EAAE,mBAAmB;IAkDxC,SAAS,IAAI,YAAY;IAkBzB,KAAK,IAAI,IAAI;IAgBb,IAAI,IAAI,IAAI;IAQZ,MAAM,IAAI,IAAI;IAYd,OAAO,IAAI,IAAI;IAef,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAIjC,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI;IAStD,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IAwBjC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI;IAe5C,cAAc,IAAI,WAAW;IAQvB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAmCjC,WAAW,IAAI,cAAc;IAe7B,OAAO,CAAC,YAAY;IAuCpB,OAAO,CAAC,WAAW;IAuBnB,OAAO,CAAC,aAAa;CAKtB"}
|
|
@@ -23,6 +23,8 @@ export class ViewerEngine {
|
|
|
23
23
|
presetId;
|
|
24
24
|
running = false;
|
|
25
25
|
animationFrame = null;
|
|
26
|
+
lastWidth;
|
|
27
|
+
lastHeight;
|
|
26
28
|
constructor(options) {
|
|
27
29
|
this.container = options.container;
|
|
28
30
|
const basePresets = options.presets ?? DEFAULT_PRESETS;
|
|
@@ -55,6 +57,8 @@ export class ViewerEngine {
|
|
|
55
57
|
this.postFxSystem = new PostFxSystem(this.renderer, this.scene, this.camera);
|
|
56
58
|
this.debugSystem = new DebugSystem(this.scene);
|
|
57
59
|
this.usePostprocessing = options.usePostprocessing ?? true;
|
|
60
|
+
this.lastWidth = width;
|
|
61
|
+
this.lastHeight = height;
|
|
58
62
|
this.postFxSystem.resize(width, height);
|
|
59
63
|
this.applyPreset(this.presetId);
|
|
60
64
|
}
|
|
@@ -103,10 +107,13 @@ export class ViewerEngine {
|
|
|
103
107
|
resize() {
|
|
104
108
|
const width = this.container.clientWidth || 1;
|
|
105
109
|
const height = this.container.clientHeight || 1;
|
|
110
|
+
this.lastWidth = width;
|
|
111
|
+
this.lastHeight = height;
|
|
106
112
|
this.camera.aspect = width / height;
|
|
107
113
|
this.camera.updateProjectionMatrix();
|
|
108
114
|
this.renderer.setSize(width, height);
|
|
109
115
|
this.postFxSystem.resize(width, height);
|
|
116
|
+
this.postFxSystem.invalidate();
|
|
110
117
|
}
|
|
111
118
|
dispose() {
|
|
112
119
|
this.stop();
|
|
@@ -271,6 +278,9 @@ export class ViewerEngine {
|
|
|
271
278
|
? { ...preset.renderer, toneMappingExposure: exposureOverride }
|
|
272
279
|
: preset.renderer;
|
|
273
280
|
applyRendererConfig(this.renderer, rendererConfig);
|
|
281
|
+
// applyRendererConfig can change pixel ratio; keep drawing buffer in sync.
|
|
282
|
+
this.renderer.setSize(this.lastWidth, this.lastHeight);
|
|
283
|
+
this.postFxSystem.resize(this.lastWidth, this.lastHeight);
|
|
274
284
|
void this.environmentSystem.apply(preset);
|
|
275
285
|
this.lightingSystem.apply(preset);
|
|
276
286
|
this.postFxSystem.apply(this.usePostprocessing ? preset.postfx : undefined);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postfxSystem.d.ts","sourceRoot":"","sources":["../../src/systems/postfxSystem.ts"],"names":[],"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,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,SAAS,CAAK;IACtB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,aAAa,CAA6B;gBAEtC,QAAQ,EAAE,KAAK,CAAC,aAAa,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,iBAAiB;IAM9F,KAAK,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI;IA2GlC,MAAM,IAAI,IAAI;IAUd,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAY3C,OAAO,IAAI,IAAI;IAaf,UAAU,IAAI,IAAI;IAqBlB,QAAQ,IAAI;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,YAAY,EAAE,OAAO,CAAC;QAAC,eAAe,EAAE,OAAO,CAAA;KAAE;CAOpF"}
|
|
@@ -159,6 +159,21 @@ export class PostFxSystem {
|
|
|
159
159
|
invalidate() {
|
|
160
160
|
if (this.aoPass) {
|
|
161
161
|
this.aoPass.firstFrame?.();
|
|
162
|
+
const aoPassAny = this.aoPass;
|
|
163
|
+
if (aoPassAny.accumulationRenderTarget) {
|
|
164
|
+
const prevTarget = this.renderer.getRenderTarget();
|
|
165
|
+
this.renderer.setRenderTarget(aoPassAny.accumulationRenderTarget);
|
|
166
|
+
this.renderer.clear(true, true, true);
|
|
167
|
+
this.renderer.setRenderTarget(prevTarget);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (this.composer) {
|
|
171
|
+
const prevTarget = this.renderer.getRenderTarget();
|
|
172
|
+
this.renderer.setRenderTarget(this.composer.inputBuffer);
|
|
173
|
+
this.renderer.clear(true, true, true);
|
|
174
|
+
this.renderer.setRenderTarget(this.composer.outputBuffer);
|
|
175
|
+
this.renderer.clear(true, true, true);
|
|
176
|
+
this.renderer.setRenderTarget(prevTarget);
|
|
162
177
|
}
|
|
163
178
|
}
|
|
164
179
|
getState() {
|