@base2datadesign/viewer-kit 0.2.9 → 0.2.11
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;IAC3B,OAAO,CAAC,aAAa,CAAS;gBAElB,OAAO,EAAE,mBAAmB;IAwDxC,SAAS,IAAI,YAAY;IAkBzB,KAAK,IAAI,IAAI;
|
|
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,Y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aAAa;CAKtB"}
|
|
@@ -39,7 +39,7 @@ export class ViewerEngine {
|
|
|
39
39
|
this.camera.position.set(...camPos);
|
|
40
40
|
const rendererOptions = {
|
|
41
41
|
antialias: options.renderer?.antialias ?? true,
|
|
42
|
-
alpha: options.renderer?.alpha ??
|
|
42
|
+
alpha: options.renderer?.alpha ?? false,
|
|
43
43
|
preserveDrawingBuffer: options.renderer?.preserveDrawingBuffer ?? false,
|
|
44
44
|
};
|
|
45
45
|
this.renderer = new THREE.WebGLRenderer(rendererOptions);
|
|
@@ -93,9 +93,6 @@ export class ViewerEngine {
|
|
|
93
93
|
const loop = () => {
|
|
94
94
|
if (!this.running)
|
|
95
95
|
return;
|
|
96
|
-
if (this.container.clientWidth !== this.lastWidth || this.container.clientHeight !== this.lastHeight) {
|
|
97
|
-
this.resize();
|
|
98
|
-
}
|
|
99
96
|
this.controls.update();
|
|
100
97
|
if (this.usePostprocessing) {
|
|
101
98
|
this.postFxSystem.render();
|
|
@@ -14,6 +14,7 @@ export declare class PostFxSystem {
|
|
|
14
14
|
private lastWidth;
|
|
15
15
|
private lastHeight;
|
|
16
16
|
private pendingConfig;
|
|
17
|
+
private currentConfig;
|
|
17
18
|
constructor(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.PerspectiveCamera);
|
|
18
19
|
apply(config?: PostFxConfig): void;
|
|
19
20
|
render(): void;
|
|
@@ -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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C,EAAE,YAAY,GAAG,IAAI;IA+GlC,MAAM,IAAI,IAAI;IAWd,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAwB3C,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"}
|
|
@@ -15,6 +15,7 @@ export class PostFxSystem {
|
|
|
15
15
|
lastWidth = 0;
|
|
16
16
|
lastHeight = 0;
|
|
17
17
|
pendingConfig = null;
|
|
18
|
+
currentConfig = null;
|
|
18
19
|
constructor(renderer, scene, camera) {
|
|
19
20
|
this.renderer = renderer;
|
|
20
21
|
this.scene = scene;
|
|
@@ -25,6 +26,7 @@ export class PostFxSystem {
|
|
|
25
26
|
const bloom = config?.bloom;
|
|
26
27
|
const vignette = config?.vignette;
|
|
27
28
|
const shouldEnable = Boolean(ao?.enabled || bloom?.enabled || vignette?.enabled);
|
|
29
|
+
this.currentConfig = config ?? null;
|
|
28
30
|
if (!shouldEnable) {
|
|
29
31
|
this.enabled = false;
|
|
30
32
|
this.pendingConfig = null;
|
|
@@ -42,6 +44,7 @@ export class PostFxSystem {
|
|
|
42
44
|
if (!this.composer) {
|
|
43
45
|
this.composer = new EffectComposer(this.renderer);
|
|
44
46
|
this.renderPass = new RenderPass(this.scene, this.camera);
|
|
47
|
+
this.renderPass.clearPass && (this.renderPass.clearPass.overrideClearAlpha = 1);
|
|
45
48
|
this.composer.addPass(this.renderPass);
|
|
46
49
|
this.composer.setSize(this.lastWidth, this.lastHeight);
|
|
47
50
|
}
|
|
@@ -136,11 +139,20 @@ export class PostFxSystem {
|
|
|
136
139
|
resize(width, height) {
|
|
137
140
|
this.lastWidth = width;
|
|
138
141
|
this.lastHeight = height;
|
|
139
|
-
if (this.composer)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
this.
|
|
143
|
-
|
|
142
|
+
if (this.composer) {
|
|
143
|
+
// Full rebuild to avoid stale postprocessing buffers after resize.
|
|
144
|
+
this.composer.dispose();
|
|
145
|
+
this.composer = null;
|
|
146
|
+
this.renderPass = null;
|
|
147
|
+
this.aoPass = null;
|
|
148
|
+
this.effectPass = null;
|
|
149
|
+
this.enabled = false;
|
|
150
|
+
}
|
|
151
|
+
if (this.currentConfig) {
|
|
152
|
+
const config = this.currentConfig;
|
|
153
|
+
this.currentConfig = null;
|
|
154
|
+
this.apply(config);
|
|
155
|
+
}
|
|
144
156
|
if (this.pendingConfig) {
|
|
145
157
|
const pending = this.pendingConfig;
|
|
146
158
|
this.pendingConfig = null;
|