@base2datadesign/viewer-kit 0.1.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/README.md +5 -0
- package/dist/engine/createViewer.d.ts +3 -0
- package/dist/engine/createViewer.d.ts.map +1 -0
- package/dist/engine/createViewer.js +57 -0
- package/dist/engine/types.d.ts +40 -0
- package/dist/engine/types.d.ts.map +1 -0
- package/dist/engine/types.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/package.json +24 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createViewer.d.ts","sourceRoot":"","sources":["../../src/engine/createViewer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAkB,MAAM,SAAS,CAAC;AAIjF,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CA0DvE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// NOTE: Stub engine: this exists to stabilize API and publishing early.
|
|
2
|
+
// Rendering systems (Three.js) will be implemented next without breaking the surface area.
|
|
3
|
+
export function createViewer(options) {
|
|
4
|
+
const { hooks } = options;
|
|
5
|
+
let running = false;
|
|
6
|
+
let presetId = options.presetId;
|
|
7
|
+
const snapshot = () => ({
|
|
8
|
+
capturedAt: new Date().toISOString(),
|
|
9
|
+
presetId,
|
|
10
|
+
renderer: {
|
|
11
|
+
toneMapping: "NeutralToneMapping",
|
|
12
|
+
toneMappingExposure: 1.0,
|
|
13
|
+
outputColorSpace: "SRGBColorSpace",
|
|
14
|
+
},
|
|
15
|
+
environment: {
|
|
16
|
+
mode: "none",
|
|
17
|
+
backgroundEnabled: false,
|
|
18
|
+
lightingEnabled: false,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
const handle = {
|
|
22
|
+
start() {
|
|
23
|
+
running = true;
|
|
24
|
+
},
|
|
25
|
+
stop() {
|
|
26
|
+
running = false;
|
|
27
|
+
},
|
|
28
|
+
resize() {
|
|
29
|
+
void running;
|
|
30
|
+
},
|
|
31
|
+
dispose() {
|
|
32
|
+
running = false;
|
|
33
|
+
},
|
|
34
|
+
setPreset(nextPresetId) {
|
|
35
|
+
presetId = nextPresetId;
|
|
36
|
+
},
|
|
37
|
+
setSceneRoot(_root) {
|
|
38
|
+
// placeholder
|
|
39
|
+
},
|
|
40
|
+
async capturePng() {
|
|
41
|
+
// placeholder blob (transparent 1x1 PNG)
|
|
42
|
+
const bytes = Uint8Array.from([
|
|
43
|
+
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48,
|
|
44
|
+
0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x06, 0x00, 0x00,
|
|
45
|
+
0x00, 0x1f, 0x15, 0xc4, 0x89, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44, 0x41, 0x54, 0x78,
|
|
46
|
+
0x9c, 0x63, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00, 0x01, 0x0d, 0x0a, 0x2d, 0xb4, 0x00,
|
|
47
|
+
0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
|
|
48
|
+
]);
|
|
49
|
+
return new Blob([bytes], { type: "image/png" });
|
|
50
|
+
},
|
|
51
|
+
getSnapshot() {
|
|
52
|
+
return snapshot();
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
queueMicrotask(() => hooks?.onReady?.(handle));
|
|
56
|
+
return handle;
|
|
57
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type AssetKind = "hdr" | "texture" | "cubeface";
|
|
2
|
+
export type AssetResolverResult = {
|
|
3
|
+
url: string;
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
};
|
|
6
|
+
export type AssetResolver = (src: string, kind: AssetKind) => Promise<AssetResolverResult>;
|
|
7
|
+
export type ViewerSnapshot = {
|
|
8
|
+
capturedAt: string;
|
|
9
|
+
presetId: string;
|
|
10
|
+
renderer: {
|
|
11
|
+
toneMapping: string;
|
|
12
|
+
toneMappingExposure: number;
|
|
13
|
+
outputColorSpace: string;
|
|
14
|
+
};
|
|
15
|
+
environment: {
|
|
16
|
+
mode: "none" | "gradient" | "hdr" | "cube";
|
|
17
|
+
backgroundEnabled: boolean;
|
|
18
|
+
lightingEnabled: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type ViewerCreateOptions = {
|
|
22
|
+
container: HTMLElement;
|
|
23
|
+
presetId: string;
|
|
24
|
+
assetResolver?: AssetResolver;
|
|
25
|
+
hooks?: {
|
|
26
|
+
onReady?: (handle: ViewerHandle) => void;
|
|
27
|
+
onError?: (error: unknown) => void;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type ViewerHandle = {
|
|
31
|
+
start(): void;
|
|
32
|
+
stop(): void;
|
|
33
|
+
resize(): void;
|
|
34
|
+
dispose(): void;
|
|
35
|
+
setPreset(presetId: string): void;
|
|
36
|
+
setSceneRoot(root: unknown): void;
|
|
37
|
+
capturePng(): Promise<Blob>;
|
|
38
|
+
getSnapshot(): ViewerSnapshot;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/engine/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,SAAS,GAAG,UAAU,CAAC;AAEvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,CAAC,GAA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":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,mBAAmB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createViewer } from "./engine/createViewer";
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@base2datadesign/viewer-kit",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc -b",
|
|
22
|
+
"typecheck": "tsc -b --pretty false --noEmit"
|
|
23
|
+
}
|
|
24
|
+
}
|