@base2datadesign/viewer-kit 0.1.3 → 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.
@@ -0,0 +1,217 @@
1
+ import { findMaterial } from "./catalogue";
2
+ export const BASELINE_MATERIAL_PRESET_ID = "calenv-baseline";
3
+ const materialSlot = (catalogId, overrides) => ({
4
+ catalogId,
5
+ overrides,
6
+ });
7
+ export const MATERIAL_PRESET_DATA = {
8
+ [BASELINE_MATERIAL_PRESET_ID]: {
9
+ id: BASELINE_MATERIAL_PRESET_ID,
10
+ label: "calenv baseline surfaces",
11
+ materials: {
12
+ walls: materialSlot("white_wall", { reflectance: 0.7, roughness: 0.3 }),
13
+ floor: materialSlot("stone_light", {
14
+ color: { r: 232, g: 234, b: 240 },
15
+ reflectance: 0.52,
16
+ roughness: 0.4,
17
+ }),
18
+ ceiling: materialSlot("acoustic_ceiling_white", { reflectance: 0.7, roughness: 0.3 }),
19
+ },
20
+ },
21
+ studio: {
22
+ id: "studio",
23
+ label: "studio high-contrast surfaces",
24
+ materials: {
25
+ walls: materialSlot("concrete_charcoal", {
26
+ color: { r: 48, g: 52, b: 58 },
27
+ reflectance: 0.22,
28
+ roughness: 0.45,
29
+ }),
30
+ floor: materialSlot("stone_dark", {
31
+ color: { r: 28, g: 30, b: 34 },
32
+ reflectance: 0.18,
33
+ roughness: 0.4,
34
+ }),
35
+ ceiling: materialSlot("white_wall", {
36
+ color: { r: 220, g: 222, b: 228 },
37
+ reflectance: 0.58,
38
+ roughness: 0.25,
39
+ }),
40
+ },
41
+ },
42
+ daylight: {
43
+ id: "daylight",
44
+ label: "daylight pavilion surfaces",
45
+ materials: {
46
+ walls: materialSlot("white_wall", {
47
+ color: { r: 240, g: 242, b: 248 },
48
+ reflectance: 0.68,
49
+ roughness: 0.35,
50
+ }),
51
+ floor: materialSlot("stone_light", {
52
+ color: { r: 214, g: 206, b: 190 },
53
+ reflectance: 0.45,
54
+ roughness: 0.5,
55
+ }),
56
+ ceiling: materialSlot("acoustic_ceiling_white", {
57
+ color: { r: 252, g: 252, b: 248 },
58
+ reflectance: 0.78,
59
+ roughness: 0.22,
60
+ }),
61
+ },
62
+ },
63
+ "gallery-spot": {
64
+ id: "gallery-spot",
65
+ label: "immersive gallery surfaces",
66
+ materials: {
67
+ walls: materialSlot("white_wall", {
68
+ color: { r: 246, g: 237, b: 225 },
69
+ reflectance: 0.6,
70
+ roughness: 0.25,
71
+ }),
72
+ floor: materialSlot("stone_dark", {
73
+ color: { r: 90, g: 88, b: 83 },
74
+ reflectance: 0.32,
75
+ roughness: 0.6,
76
+ pattern: "grid",
77
+ patternScale: 0.4,
78
+ }),
79
+ ceiling: materialSlot("acoustic_ceiling_white", {
80
+ color: { r: 255, g: 250, b: 245 },
81
+ reflectance: 0.75,
82
+ roughness: 0.2,
83
+ }),
84
+ },
85
+ },
86
+ "lab-neutral": {
87
+ id: "lab-neutral",
88
+ label: "neutral lab surfaces",
89
+ materials: {
90
+ walls: materialSlot("white_wall", {
91
+ color: { r: 240, g: 240, b: 246 },
92
+ reflectance: 0.82,
93
+ roughness: 0.3,
94
+ }),
95
+ floor: materialSlot("timber_floor_warm", {
96
+ color: { r: 172, g: 168, b: 160 },
97
+ reflectance: 0.35,
98
+ roughness: 0.55,
99
+ }),
100
+ ceiling: materialSlot("acoustic_ceiling_white", {
101
+ color: { r: 233, g: 235, b: 239 },
102
+ reflectance: 0.88,
103
+ roughness: 0.25,
104
+ }),
105
+ },
106
+ },
107
+ "atrium-suntrack": {
108
+ id: "atrium-suntrack",
109
+ label: "atrium daylight surfaces",
110
+ materials: {
111
+ walls: materialSlot("stone_light", {
112
+ color: { r: 210, g: 210, b: 205 },
113
+ reflectance: 0.55,
114
+ roughness: 0.4,
115
+ }),
116
+ floor: materialSlot("stone_light", {
117
+ color: { r: 190, g: 190, b: 183 },
118
+ reflectance: 0.4,
119
+ roughness: 0.6,
120
+ pattern: "grid",
121
+ patternScale: 0.5,
122
+ }),
123
+ ceiling: materialSlot("glass_structural_clear", {
124
+ color: { r: 230, g: 238, b: 245 },
125
+ reflectance: 0.65,
126
+ roughness: 0.15,
127
+ }),
128
+ },
129
+ },
130
+ "flow-horizon": {
131
+ id: "flow-horizon",
132
+ label: "flow horizon surfaces",
133
+ materials: {
134
+ walls: materialSlot("glass_structural_clear", {
135
+ color: { r: 210, g: 225, b: 235 },
136
+ reflectance: 0.4,
137
+ roughness: 0.2,
138
+ }),
139
+ floor: materialSlot("timber_floor_warm", {
140
+ color: { r: 140, g: 110, b: 85 },
141
+ reflectance: 0.28,
142
+ roughness: 0.6,
143
+ pattern: "herringbone",
144
+ patternScale: 0.4,
145
+ }),
146
+ ceiling: materialSlot("timber_floor_warm", {
147
+ color: { r: 210, g: 200, b: 185 },
148
+ reflectance: 0.5,
149
+ roughness: 0.35,
150
+ }),
151
+ },
152
+ },
153
+ "biophilic-soft": {
154
+ id: "biophilic-soft",
155
+ label: "biophilic loft surfaces",
156
+ materials: {
157
+ walls: materialSlot("white_wall", {
158
+ color: { r: 214, g: 224, b: 214 },
159
+ reflectance: 0.58,
160
+ roughness: 0.35,
161
+ }),
162
+ floor: materialSlot("timber_floor_warm", {
163
+ color: { r: 170, g: 142, b: 110 },
164
+ reflectance: 0.32,
165
+ roughness: 0.55,
166
+ }),
167
+ ceiling: materialSlot("acoustic_ceiling_white", {
168
+ color: { r: 250, g: 248, b: 240 },
169
+ reflectance: 0.78,
170
+ roughness: 0.25,
171
+ }),
172
+ },
173
+ },
174
+ };
175
+ const DEFAULT_REFLECTANCE = 0.5;
176
+ const hexToRgb = (hex) => {
177
+ const normalized = hex.replace("#", "");
178
+ const value = parseInt(normalized, 16);
179
+ return {
180
+ r: (value >> 16) & 0xff,
181
+ g: (value >> 8) & 0xff,
182
+ b: value & 0xff,
183
+ };
184
+ };
185
+ const resolveMaterialConfig = (definition, catalogId, overrides) => {
186
+ const baselineColor = definition?.baseline?.color ?? "#ffffff";
187
+ const baseColor = overrides?.color ?? hexToRgb(baselineColor);
188
+ return {
189
+ type: catalogId,
190
+ color: baseColor,
191
+ reflectance: overrides?.reflectance ?? DEFAULT_REFLECTANCE,
192
+ roughness: overrides?.roughness ?? definition?.pbr?.roughness ?? 0.6,
193
+ pattern: overrides?.pattern ?? "none",
194
+ patternScale: overrides?.patternScale ?? 0.5,
195
+ };
196
+ };
197
+ export function resolveMaterialSlot(slot) {
198
+ const definition = findMaterial(slot.catalogId);
199
+ return resolveMaterialConfig(definition, slot.catalogId, slot.overrides);
200
+ }
201
+ export function resolveMaterialPresetMaterials(preset) {
202
+ return {
203
+ walls: resolveMaterialSlot(preset.materials.walls),
204
+ floor: resolveMaterialSlot(preset.materials.floor),
205
+ ceiling: resolveMaterialSlot(preset.materials.ceiling),
206
+ };
207
+ }
208
+ export function listMaterialPresets() {
209
+ return Object.values(MATERIAL_PRESET_DATA);
210
+ }
211
+ export function getMaterialPreset(id) {
212
+ const preset = MATERIAL_PRESET_DATA[id];
213
+ if (!preset) {
214
+ throw new Error(`Material preset '${id}' not found.`);
215
+ }
216
+ return preset;
217
+ }
@@ -0,0 +1,15 @@
1
+ import type { MaterialId } from "./types";
2
+ export type TextureMap = {
3
+ albedo?: string;
4
+ normal?: string;
5
+ roughness?: string;
6
+ ao?: string;
7
+ scale?: [number, number];
8
+ };
9
+ export type RenderMaterialMetadata = {
10
+ materialId: MaterialId;
11
+ doubleSided?: boolean;
12
+ textures?: TextureMap;
13
+ };
14
+ export declare function getRenderMaterialMetadata(materialId: MaterialId): RenderMaterialMetadata | undefined;
15
+ //# sourceMappingURL=renderMetadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderMetadata.d.ts","sourceRoot":"","sources":["../../src/materials/renderMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB,CAAC;AAgEF,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,UAAU,GAAG,sBAAsB,GAAG,SAAS,CAEpG"}
@@ -0,0 +1,64 @@
1
+ const RENDER_MATERIAL_METADATA = {
2
+ white_wall: {
3
+ materialId: "white_wall",
4
+ doubleSided: true,
5
+ textures: {
6
+ normal: "/textures/plaster/normal.png",
7
+ ao: "/textures/stone/roughness.png",
8
+ scale: [4, 4],
9
+ },
10
+ },
11
+ acoustic_ceiling_white: {
12
+ materialId: "acoustic_ceiling_white",
13
+ doubleSided: true,
14
+ textures: {
15
+ normal: "/textures/plaster/normal.png",
16
+ ao: "/textures/stone/roughness.png",
17
+ scale: [2, 2],
18
+ },
19
+ },
20
+ timber_floor_warm: {
21
+ materialId: "timber_floor_warm",
22
+ doubleSided: false,
23
+ textures: {
24
+ albedo: "/textures/wood/albedo.png",
25
+ normal: "/textures/wood/normal.png",
26
+ roughness: "/textures/stone/roughness.png",
27
+ scale: [6, 6],
28
+ },
29
+ },
30
+ stone_dark: {
31
+ materialId: "stone_dark",
32
+ doubleSided: false,
33
+ textures: {
34
+ roughness: "/textures/stone/roughness.png",
35
+ ao: "/textures/stone/roughness.png",
36
+ scale: [3, 3],
37
+ },
38
+ },
39
+ stone_light: {
40
+ materialId: "stone_light",
41
+ doubleSided: false,
42
+ textures: {
43
+ roughness: "/textures/stone/roughness.png",
44
+ ao: "/textures/stone/roughness.png",
45
+ scale: [3, 3],
46
+ },
47
+ },
48
+ concrete_charcoal: {
49
+ materialId: "concrete_charcoal",
50
+ doubleSided: true,
51
+ textures: {
52
+ normal: "/textures/plaster/normal.png",
53
+ roughness: "/textures/stone/roughness.png",
54
+ scale: [2, 2],
55
+ },
56
+ },
57
+ glass_structural_clear: {
58
+ materialId: "glass_structural_clear",
59
+ doubleSided: false,
60
+ },
61
+ };
62
+ export function getRenderMaterialMetadata(materialId) {
63
+ return RENDER_MATERIAL_METADATA[materialId];
64
+ }
@@ -0,0 +1,50 @@
1
+ export type MaterialTextureConfig = {
2
+ type: string;
3
+ scale?: number;
4
+ };
5
+ export type MaterialPbrConfig = {
6
+ baseColor: string;
7
+ roughness: number;
8
+ metalness: number;
9
+ emissive: string;
10
+ emissiveIntensity: number;
11
+ texture?: MaterialTextureConfig;
12
+ transparent?: boolean;
13
+ opacity?: number;
14
+ ior?: number;
15
+ };
16
+ export type MaterialBaselineConfig = {
17
+ color: string;
18
+ finish: string;
19
+ };
20
+ export type MaterialDefinition = {
21
+ materialId: string;
22
+ label: string;
23
+ category: string;
24
+ baseline: MaterialBaselineConfig;
25
+ pbr: MaterialPbrConfig;
26
+ };
27
+ export type MaterialCatalogue = {
28
+ version: number;
29
+ materials: ReadonlyArray<MaterialDefinition>;
30
+ };
31
+ export type MaterialId = MaterialDefinition["materialId"];
32
+ export type MaterialColor = {
33
+ r: number;
34
+ g: number;
35
+ b: number;
36
+ };
37
+ export type SurfaceMaterialConfig = {
38
+ type: MaterialId | "custom";
39
+ color: MaterialColor;
40
+ reflectance: number;
41
+ roughness: number;
42
+ pattern?: string;
43
+ patternScale?: number;
44
+ };
45
+ export type MaterialsConfig = {
46
+ walls: SurfaceMaterialConfig;
47
+ floor: SurfaceMaterialConfig;
48
+ ceiling: SurfaceMaterialConfig;
49
+ };
50
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/materials/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC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C,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,qBAAqB,CAAC;IAC7B,KAAK,EAAE,qBAAqB,CAAC;IAC7B,OAAO,EAAE,qBAAqB,CAAC;CAChC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { PresetCatalog } from "../engine/types";
2
+ export declare const SCIENCE_PRESET_SUMMARIES: Record<string, string>;
3
+ export declare const SCIENCE_DEFAULT_PRESET_ID = "architectural";
4
+ export declare function buildViewerPresets(): PresetCatalog;
5
+ export declare const buildSciencePresets: typeof buildViewerPresets;
6
+ export declare const SCIENCE_PRESETS: PresetCatalog;
7
+ //# sourceMappingURL=sciencePresets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sciencePresets.d.ts","sourceRoot":"","sources":["../../src/presets/sciencePresets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAOd,MAAM,iBAAiB,CAAC;AA4fzB,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAE3D,CAAC;AAEF,eAAO,MAAM,yBAAyB,kBAA6B,CAAC;AAEpE,wBAAgB,kBAAkB,IAAI,aAAa,CA6BlD;AAGD,eAAO,MAAM,mBAAmB,2BAAqB,CAAC;AAEtD,eAAO,MAAM,eAAe,eAAuB,CAAC"}