@base2datadesign/viewer-kit 0.1.2 → 0.2.0
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/engine/types.d.ts +64 -0
- package/dist/engine/types.d.ts.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/materials/architectural.d.ts +6 -0
- package/dist/materials/architectural.d.ts.map +1 -0
- package/dist/materials/architectural.js +169 -0
- package/dist/materials/catalogue-data.d.ts +149 -0
- package/dist/materials/catalogue-data.d.ts.map +1 -0
- package/dist/materials/catalogue-data.js +158 -0
- package/dist/materials/catalogue.d.ts +5 -0
- package/dist/materials/catalogue.d.ts.map +1 -0
- package/dist/materials/catalogue.js +23 -0
- package/dist/materials/presets.d.ts +21 -0
- package/dist/materials/presets.d.ts.map +1 -0
- package/dist/materials/presets.js +217 -0
- package/dist/materials/renderMetadata.d.ts +15 -0
- package/dist/materials/renderMetadata.d.ts.map +1 -0
- package/dist/materials/renderMetadata.js +64 -0
- package/dist/materials/types.d.ts +50 -0
- package/dist/materials/types.d.ts.map +1 -0
- package/dist/materials/types.js +1 -0
- package/dist/presets/sciencePresets.d.ts +7 -0
- package/dist/presets/sciencePresets.d.ts.map +1 -0
- package/dist/presets/sciencePresets.js +473 -0
- package/dist/sky/scienceSky.d.ts +10 -0
- package/dist/sky/scienceSky.d.ts.map +1 -0
- package/dist/sky/scienceSky.js +68 -0
- package/dist/systems/debugSystem.d.ts.map +1 -1
- package/dist/systems/debugSystem.js +32 -9
- package/dist/systems/environmentSystem.d.ts +1 -0
- package/dist/systems/environmentSystem.d.ts.map +1 -1
- package/dist/systems/environmentSystem.js +19 -0
- package/dist/systems/lightingSystem.d.ts +1 -0
- package/dist/systems/lightingSystem.d.ts.map +1 -1
- package/dist/systems/lightingSystem.js +27 -0
- package/dist/systems/postfxSystem.d.ts +5 -0
- package/dist/systems/postfxSystem.d.ts.map +1 -1
- package/dist/systems/postfxSystem.js +57 -4
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lightingSystem.d.ts","sourceRoot":"","sources":["../../src/systems/lightingSystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAqB,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAUjF,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,MAAM,CAAqB;gBAEvB,KAAK,EAAE,KAAK,CAAC,KAAK;IAI9B,KAAK,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"lightingSystem.d.ts","sourceRoot":"","sources":["../../src/systems/lightingSystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAqB,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAUjF,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,MAAM,CAAqB;gBAEvB,KAAK,EAAE,KAAK,CAAC,KAAK;IAI9B,KAAK,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI;IAkD3C,OAAO,IAAI,IAAI;IAIf,OAAO,CAAC,GAAG;IAKX,OAAO,CAAC,KAAK;IAOb,OAAO,CAAC,eAAe;CAcxB"}
|
|
@@ -32,6 +32,9 @@ export class LightingSystem {
|
|
|
32
32
|
const light = new THREE.DirectionalLight(new THREE.Color(key.color), key.intensity);
|
|
33
33
|
light.position.set(...key.position);
|
|
34
34
|
light.castShadow = key.castShadow ?? false;
|
|
35
|
+
if (light.castShadow) {
|
|
36
|
+
this.configureShadow(light, config.shadow);
|
|
37
|
+
}
|
|
35
38
|
this.add(light);
|
|
36
39
|
}
|
|
37
40
|
const fill = config.fill ?? DEFAULT_LIGHTING.fill;
|
|
@@ -40,6 +43,15 @@ export class LightingSystem {
|
|
|
40
43
|
light.position.set(...fill.position);
|
|
41
44
|
this.add(light);
|
|
42
45
|
}
|
|
46
|
+
if (preset.interiorLights?.length) {
|
|
47
|
+
preset.interiorLights.forEach((interior) => {
|
|
48
|
+
const color = interior.color ? new THREE.Color(interior.color) : new THREE.Color("#ffffff");
|
|
49
|
+
const distance = typeof interior.distance === "number" ? interior.distance : 40;
|
|
50
|
+
const point = new THREE.PointLight(color, interior.intensity, distance);
|
|
51
|
+
point.position.set(...interior.position);
|
|
52
|
+
this.add(point);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
43
55
|
}
|
|
44
56
|
dispose() {
|
|
45
57
|
this.clear();
|
|
@@ -55,4 +67,19 @@ export class LightingSystem {
|
|
|
55
67
|
});
|
|
56
68
|
this.lights = [];
|
|
57
69
|
}
|
|
70
|
+
configureShadow(light, config) {
|
|
71
|
+
if (!light.shadow)
|
|
72
|
+
return;
|
|
73
|
+
const cameraSize = config?.cameraSize ?? 25;
|
|
74
|
+
light.shadow.camera.left = -cameraSize;
|
|
75
|
+
light.shadow.camera.right = cameraSize;
|
|
76
|
+
light.shadow.camera.top = cameraSize;
|
|
77
|
+
light.shadow.camera.bottom = -cameraSize;
|
|
78
|
+
light.shadow.camera.near = config?.near ?? 0.1;
|
|
79
|
+
light.shadow.camera.far = config?.far ?? 60;
|
|
80
|
+
const mapSize = config?.mapSize ?? 2048;
|
|
81
|
+
light.shadow.mapSize.set(mapSize, mapSize);
|
|
82
|
+
light.shadow.bias = config?.bias ?? -0.0001;
|
|
83
|
+
light.shadow.radius = config?.radius ?? 3;
|
|
84
|
+
}
|
|
58
85
|
}
|
|
@@ -7,6 +7,9 @@ export declare class PostFxSystem {
|
|
|
7
7
|
private composer;
|
|
8
8
|
private renderPass;
|
|
9
9
|
private aoPass;
|
|
10
|
+
private effectPass;
|
|
11
|
+
private bloomEffect;
|
|
12
|
+
private vignetteEffect;
|
|
10
13
|
private enabled;
|
|
11
14
|
constructor(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.PerspectiveCamera);
|
|
12
15
|
apply(config?: PostFxConfig): void;
|
|
@@ -15,6 +18,8 @@ export declare class PostFxSystem {
|
|
|
15
18
|
dispose(): void;
|
|
16
19
|
getState(): {
|
|
17
20
|
aoEnabled: boolean;
|
|
21
|
+
bloomEnabled: boolean;
|
|
22
|
+
vignetteEnabled: boolean;
|
|
18
23
|
};
|
|
19
24
|
}
|
|
20
25
|
//# sourceMappingURL=postfxSystem.d.ts.map
|
|
@@ -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,OAAO,CAAS;gBAEZ,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;
|
|
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;gBAEZ,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;IA6ElC,MAAM,IAAI,IAAI;IAQd,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAS3C,OAAO,IAAI,IAAI;IAaf,QAAQ,IAAI;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,YAAY,EAAE,OAAO,CAAC;QAAC,eAAe,EAAE,OAAO,CAAA;KAAE;CAOpF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EffectComposer, RenderPass } from "postprocessing";
|
|
1
|
+
import { BloomEffect, EffectComposer, EffectPass, RenderPass, VignetteEffect } from "postprocessing";
|
|
2
2
|
import { N8AOPostPass } from "n8ao";
|
|
3
3
|
export class PostFxSystem {
|
|
4
4
|
renderer;
|
|
@@ -7,6 +7,9 @@ export class PostFxSystem {
|
|
|
7
7
|
composer = null;
|
|
8
8
|
renderPass = null;
|
|
9
9
|
aoPass = null;
|
|
10
|
+
effectPass = null;
|
|
11
|
+
bloomEffect = null;
|
|
12
|
+
vignetteEffect = null;
|
|
10
13
|
enabled = false;
|
|
11
14
|
constructor(renderer, scene, camera) {
|
|
12
15
|
this.renderer = renderer;
|
|
@@ -15,23 +18,47 @@ export class PostFxSystem {
|
|
|
15
18
|
}
|
|
16
19
|
apply(config) {
|
|
17
20
|
const ao = config?.ao;
|
|
18
|
-
const
|
|
21
|
+
const bloom = config?.bloom;
|
|
22
|
+
const vignette = config?.vignette;
|
|
23
|
+
const shouldEnable = Boolean(ao?.enabled || bloom?.enabled || vignette?.enabled);
|
|
19
24
|
if (!shouldEnable) {
|
|
20
25
|
this.enabled = false;
|
|
21
26
|
if (this.aoPass)
|
|
22
27
|
this.aoPass.enabled = false;
|
|
28
|
+
if (this.effectPass)
|
|
29
|
+
this.effectPass.enabled = false;
|
|
23
30
|
return;
|
|
24
31
|
}
|
|
25
32
|
if (!this.composer) {
|
|
26
33
|
this.composer = new EffectComposer(this.renderer);
|
|
27
34
|
this.renderPass = new RenderPass(this.scene, this.camera);
|
|
28
35
|
this.composer.addPass(this.renderPass);
|
|
36
|
+
}
|
|
37
|
+
if (!this.aoPass) {
|
|
29
38
|
this.aoPass = new N8AOPostPass(this.scene, this.camera, this.renderer.domElement.width, this.renderer.domElement.height);
|
|
30
39
|
this.composer.addPass(this.aoPass);
|
|
31
40
|
}
|
|
41
|
+
if (!this.bloomEffect) {
|
|
42
|
+
this.bloomEffect = new BloomEffect({
|
|
43
|
+
intensity: bloom?.intensity ?? 0.0,
|
|
44
|
+
radius: bloom?.radius ?? 0.85,
|
|
45
|
+
luminanceThreshold: bloom?.threshold ?? 1.0,
|
|
46
|
+
luminanceSmoothing: bloom?.smoothing ?? 0.03,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (!this.vignetteEffect) {
|
|
50
|
+
this.vignetteEffect = new VignetteEffect({
|
|
51
|
+
offset: vignette?.offset ?? 0.5,
|
|
52
|
+
darkness: vignette?.darkness ?? 0.5,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (!this.effectPass) {
|
|
56
|
+
this.effectPass = new EffectPass(this.camera, this.bloomEffect, this.vignetteEffect);
|
|
57
|
+
this.composer.addPass(this.effectPass);
|
|
58
|
+
}
|
|
32
59
|
this.enabled = true;
|
|
33
60
|
if (this.aoPass) {
|
|
34
|
-
this.aoPass.enabled =
|
|
61
|
+
this.aoPass.enabled = Boolean(ao?.enabled);
|
|
35
62
|
if (ao?.intensity !== undefined)
|
|
36
63
|
this.aoPass.configuration.intensity = ao.intensity;
|
|
37
64
|
if (ao?.radius !== undefined)
|
|
@@ -42,6 +69,25 @@ export class PostFxSystem {
|
|
|
42
69
|
this.aoPass.configuration.halfRes = ao.halfRes;
|
|
43
70
|
this.aoPass.firstFrame?.();
|
|
44
71
|
}
|
|
72
|
+
if (this.bloomEffect) {
|
|
73
|
+
this.bloomEffect.intensity = bloom?.enabled ? bloom?.intensity ?? 1.0 : 0.0;
|
|
74
|
+
if (bloom?.radius !== undefined) {
|
|
75
|
+
this.bloomEffect.mipmapBlurPass.radius = bloom.radius;
|
|
76
|
+
}
|
|
77
|
+
if (bloom?.threshold !== undefined)
|
|
78
|
+
this.bloomEffect.luminanceMaterial.threshold = bloom.threshold;
|
|
79
|
+
if (bloom?.smoothing !== undefined)
|
|
80
|
+
this.bloomEffect.luminanceMaterial.smoothing = bloom.smoothing;
|
|
81
|
+
}
|
|
82
|
+
if (this.vignetteEffect) {
|
|
83
|
+
const offset = vignette?.offset ?? 0.5;
|
|
84
|
+
const darkness = vignette?.enabled ? vignette.darkness ?? 0.5 : 0.0;
|
|
85
|
+
this.vignetteEffect.offset = offset;
|
|
86
|
+
this.vignetteEffect.darkness = darkness;
|
|
87
|
+
}
|
|
88
|
+
if (this.effectPass) {
|
|
89
|
+
this.effectPass.enabled = Boolean(bloom?.enabled || vignette?.enabled);
|
|
90
|
+
}
|
|
45
91
|
}
|
|
46
92
|
render() {
|
|
47
93
|
if (this.enabled && this.composer) {
|
|
@@ -64,10 +110,17 @@ export class PostFxSystem {
|
|
|
64
110
|
}
|
|
65
111
|
this.renderPass = null;
|
|
66
112
|
this.aoPass = null;
|
|
113
|
+
this.effectPass = null;
|
|
114
|
+
this.bloomEffect = null;
|
|
115
|
+
this.vignetteEffect = null;
|
|
67
116
|
this.composer = null;
|
|
68
117
|
this.enabled = false;
|
|
69
118
|
}
|
|
70
119
|
getState() {
|
|
71
|
-
return {
|
|
120
|
+
return {
|
|
121
|
+
aoEnabled: Boolean(this.aoPass?.enabled),
|
|
122
|
+
bloomEnabled: Boolean(this.effectPass?.enabled && this.bloomEffect && this.bloomEffect.intensity > 0),
|
|
123
|
+
vignetteEnabled: Boolean(this.effectPass?.enabled && this.vignetteEffect && this.vignetteEffect.darkness > 0),
|
|
124
|
+
};
|
|
72
125
|
}
|
|
73
126
|
}
|