@plasius/gpu-shared 0.1.11 → 0.1.14
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/CHANGELOG.md +58 -3
- package/README.md +110 -4
- package/assets/brigantine.gltf +549 -24
- package/assets/cutter.gltf +538 -0
- package/assets/harbor-dock.gltf +680 -0
- package/assets/lighthouse.gltf +604 -0
- package/dist/chunk-2GM64LB6.js +9 -0
- package/dist/chunk-2GM64LB6.js.map +1 -0
- package/dist/chunk-3ARPGHCQ.js +119 -0
- package/dist/chunk-3ARPGHCQ.js.map +1 -0
- package/dist/chunk-4ZJ24VRS.js +402 -0
- package/dist/chunk-4ZJ24VRS.js.map +1 -0
- package/dist/chunk-W5GA3VA6.js +442 -0
- package/dist/chunk-W5GA3VA6.js.map +1 -0
- package/dist/gltf-loader-YDPLZS5Q.js +8 -0
- package/dist/index.cjs +2432 -6424
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +45 -6
- package/dist/index.js.map +1 -1
- package/dist/product-studio-runtime-HDAUDWYO.js +11 -0
- package/dist/showcase-inline-assets-WT4PSNKI.js +7 -0
- package/dist/showcase-inline-assets-WT4PSNKI.js.map +1 -0
- package/dist/showcase-runtime-SNCUFSSC.js +3785 -0
- package/dist/showcase-runtime-SNCUFSSC.js.map +1 -0
- package/package.json +20 -8
- package/src/asset-url.js +62 -11
- package/src/feature-flags.js +2 -0
- package/src/gltf-loader.js +330 -32
- package/src/i18n.js +71 -0
- package/src/index.d.ts +187 -2
- package/src/index.js +42 -1
- package/src/product-studio-runtime.js +465 -0
- package/src/showcase-inline-assets.js +3 -0
- package/src/showcase-runtime.js +1779 -252
- package/src/translations/en-GB.js +55 -0
- package/dist/chunk-DGUM43GV.js +0 -11
- package/dist/chunk-OTCJ3VOK.js +0 -35
- package/dist/chunk-OTCJ3VOK.js.map +0 -1
- package/dist/chunk-QBMXJ3V2.js +0 -142
- package/dist/chunk-QBMXJ3V2.js.map +0 -1
- package/dist/gltf-loader-LKALCZAV.js +0 -8
- package/dist/showcase-runtime-2ZNPKD7D.js +0 -8593
- package/dist/showcase-runtime-2ZNPKD7D.js.map +0 -1
- /package/dist/{chunk-DGUM43GV.js.map → gltf-loader-YDPLZS5Q.js.map} +0 -0
- /package/dist/{gltf-loader-LKALCZAV.js.map → product-studio-runtime-HDAUDWYO.js.map} +0 -0
package/src/index.d.ts
CHANGED
|
@@ -10,6 +10,28 @@ export interface GltfModelBounds {
|
|
|
10
10
|
readonly max: readonly [number, number, number];
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
export interface GltfModelMaterial {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly color: GltfModelColor;
|
|
16
|
+
readonly roughness: number;
|
|
17
|
+
readonly metallic: number;
|
|
18
|
+
readonly emissive: Readonly<{
|
|
19
|
+
r: number;
|
|
20
|
+
g: number;
|
|
21
|
+
b: number;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface GltfModelPrimitive {
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly positions: readonly number[];
|
|
28
|
+
readonly indices: readonly number[];
|
|
29
|
+
readonly normals: readonly number[] | null;
|
|
30
|
+
readonly colors: readonly number[] | null;
|
|
31
|
+
readonly material: GltfModelMaterial;
|
|
32
|
+
readonly bounds: GltfModelBounds;
|
|
33
|
+
}
|
|
34
|
+
|
|
13
35
|
export interface GltfModel {
|
|
14
36
|
readonly name: string;
|
|
15
37
|
readonly positions: readonly number[];
|
|
@@ -17,8 +39,15 @@ export interface GltfModel {
|
|
|
17
39
|
readonly bounds: GltfModelBounds;
|
|
18
40
|
readonly color: GltfModelColor;
|
|
19
41
|
readonly physics: Readonly<Record<string, unknown>>;
|
|
42
|
+
readonly primitives: readonly GltfModelPrimitive[];
|
|
20
43
|
}
|
|
21
44
|
|
|
45
|
+
export type ShowcaseAssetName =
|
|
46
|
+
| "brigantine"
|
|
47
|
+
| "cutter"
|
|
48
|
+
| "lighthouse"
|
|
49
|
+
| "harbor-dock";
|
|
50
|
+
|
|
22
51
|
export type ShowcaseFocusMode =
|
|
23
52
|
| "integrated"
|
|
24
53
|
| "lighting"
|
|
@@ -28,12 +57,131 @@ export type ShowcaseFocusMode =
|
|
|
28
57
|
| "performance"
|
|
29
58
|
| "debug";
|
|
30
59
|
|
|
60
|
+
export type ShowcaseDemoMode = "harbor" | "product-studio" | "product" | "studio" | "eames";
|
|
61
|
+
|
|
62
|
+
export interface ProductStudioMesh {
|
|
63
|
+
readonly id: number;
|
|
64
|
+
readonly positions: readonly number[];
|
|
65
|
+
readonly indices: readonly number[];
|
|
66
|
+
readonly normals?: readonly number[] | null;
|
|
67
|
+
readonly uvs?: readonly number[] | null;
|
|
68
|
+
readonly color: readonly number[];
|
|
69
|
+
readonly emission?: readonly number[];
|
|
70
|
+
readonly materialKind: string | number;
|
|
71
|
+
readonly materialRefId?: number;
|
|
72
|
+
readonly roughness?: number;
|
|
73
|
+
readonly metallic?: number;
|
|
74
|
+
readonly opacity?: number;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type GpuSharedTranslationValue =
|
|
78
|
+
| string
|
|
79
|
+
| number
|
|
80
|
+
| boolean
|
|
81
|
+
| null
|
|
82
|
+
| undefined;
|
|
83
|
+
|
|
84
|
+
export type GpuSharedTranslationArgs = Readonly<
|
|
85
|
+
Record<string, GpuSharedTranslationValue>
|
|
86
|
+
>;
|
|
87
|
+
|
|
88
|
+
export interface GpuSharedTranslate {
|
|
89
|
+
(
|
|
90
|
+
key: GpuSharedTranslationKey,
|
|
91
|
+
args?: GpuSharedTranslationArgs
|
|
92
|
+
): string | undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const gpuSharedTranslationKeys: Readonly<{
|
|
96
|
+
showcaseTitle: "gpuShared.showcase.title";
|
|
97
|
+
showcaseSubtitle: "gpuShared.showcase.subtitle";
|
|
98
|
+
statusBooting: "gpuShared.showcase.status.booting";
|
|
99
|
+
statusLive: "gpuShared.showcase.status.live";
|
|
100
|
+
detailsBooting: "gpuShared.showcase.details.booting";
|
|
101
|
+
detailsPhysics: "gpuShared.showcase.details.physics";
|
|
102
|
+
detailsRealistic: "gpuShared.showcase.details.realistic";
|
|
103
|
+
detailsLegacy: "gpuShared.showcase.details.legacy";
|
|
104
|
+
pause: "gpuShared.showcase.action.pause";
|
|
105
|
+
resume: "gpuShared.showcase.action.resume";
|
|
106
|
+
stressMode: "gpuShared.showcase.control.stressMode";
|
|
107
|
+
focus: "gpuShared.showcase.control.focus";
|
|
108
|
+
focusIntegrated: "gpuShared.showcase.focus.integrated";
|
|
109
|
+
focusLighting: "gpuShared.showcase.focus.lighting";
|
|
110
|
+
focusCloth: "gpuShared.showcase.focus.cloth";
|
|
111
|
+
focusFluid: "gpuShared.showcase.focus.fluid";
|
|
112
|
+
focusPhysics: "gpuShared.showcase.focus.physics";
|
|
113
|
+
focusPerformance: "gpuShared.showcase.focus.performance";
|
|
114
|
+
focusDebug: "gpuShared.showcase.focus.debug";
|
|
115
|
+
legendTitle: "gpuShared.showcase.legend.title";
|
|
116
|
+
legendShipMetadata: "gpuShared.showcase.legend.shipMetadata";
|
|
117
|
+
legendLighting: "gpuShared.showcase.legend.lighting";
|
|
118
|
+
legendCollisions: "gpuShared.showcase.legend.collisions";
|
|
119
|
+
sceneState: "gpuShared.showcase.section.sceneState";
|
|
120
|
+
qualityBudgets: "gpuShared.showcase.section.qualityBudgets";
|
|
121
|
+
debugTelemetry: "gpuShared.showcase.section.debugTelemetry";
|
|
122
|
+
notes: "gpuShared.showcase.section.notes";
|
|
123
|
+
noteAssetLoading: "gpuShared.showcase.note.assetLoading";
|
|
124
|
+
noteMoonlight: "gpuShared.showcase.note.moonlight";
|
|
125
|
+
noteContinuity: "gpuShared.showcase.note.continuity";
|
|
126
|
+
notePerformance: "gpuShared.showcase.note.performance";
|
|
127
|
+
notePhysicsSnapshots: "gpuShared.showcase.note.physicsSnapshots";
|
|
128
|
+
notePhysicsCollisions: "gpuShared.showcase.note.physicsCollisions";
|
|
129
|
+
notePhysicsLighting: "gpuShared.showcase.note.physicsLighting";
|
|
130
|
+
debugAdapterShowcase: "gpuShared.debug.adapter.showcase";
|
|
131
|
+
debugMainColorBuffer: "gpuShared.debug.allocation.mainColorBuffer";
|
|
132
|
+
debugShadowImpressionAtlas: "gpuShared.debug.allocation.shadowImpressionAtlas";
|
|
133
|
+
}>;
|
|
134
|
+
|
|
135
|
+
export type GpuSharedTranslationKey =
|
|
136
|
+
(typeof gpuSharedTranslationKeys)[keyof typeof gpuSharedTranslationKeys];
|
|
137
|
+
|
|
138
|
+
export const gpuSharedEnGbTranslations: Readonly<
|
|
139
|
+
Record<GpuSharedTranslationKey, string>
|
|
140
|
+
>;
|
|
141
|
+
|
|
142
|
+
export const gpuSharedTranslations: Readonly<{
|
|
143
|
+
"en-GB": typeof gpuSharedEnGbTranslations;
|
|
144
|
+
}>;
|
|
145
|
+
|
|
146
|
+
export function translateGpuSharedText(
|
|
147
|
+
key: GpuSharedTranslationKey,
|
|
148
|
+
args?: GpuSharedTranslationArgs,
|
|
149
|
+
translate?: GpuSharedTranslate
|
|
150
|
+
): string;
|
|
151
|
+
|
|
152
|
+
export function createGpuSharedTranslator(
|
|
153
|
+
translate?: GpuSharedTranslate
|
|
154
|
+
): (key: GpuSharedTranslationKey, args?: GpuSharedTranslationArgs) => string;
|
|
155
|
+
|
|
31
156
|
export interface MountGpuShowcaseOptions {
|
|
157
|
+
__showcaseFeatureLoaders?: {
|
|
158
|
+
cloth?: () => Promise<unknown>;
|
|
159
|
+
fluid?: () => Promise<unknown>;
|
|
160
|
+
lighting?: () => Promise<unknown>;
|
|
161
|
+
performance?: () => Promise<unknown>;
|
|
162
|
+
debug?: () => Promise<unknown>;
|
|
163
|
+
physics?: () => Promise<unknown>;
|
|
164
|
+
};
|
|
32
165
|
root?: HTMLElement;
|
|
166
|
+
demoMode?: ShowcaseDemoMode;
|
|
167
|
+
mode?: ShowcaseDemoMode;
|
|
33
168
|
focus?: ShowcaseFocusMode | string;
|
|
34
169
|
packageName?: string;
|
|
35
170
|
title?: string;
|
|
36
171
|
subtitle?: string;
|
|
172
|
+
translate?: GpuSharedTranslate;
|
|
173
|
+
captureMode?: boolean;
|
|
174
|
+
renderScale?: number;
|
|
175
|
+
productAssetUrl?: string | URL;
|
|
176
|
+
assetUrl?: string | URL;
|
|
177
|
+
width?: number;
|
|
178
|
+
height?: number;
|
|
179
|
+
maxDepth?: number;
|
|
180
|
+
tileSize?: number;
|
|
181
|
+
samplesPerPixel?: number;
|
|
182
|
+
denoise?: boolean;
|
|
183
|
+
lightingPreset?: string;
|
|
184
|
+
lightingIntensity?: number;
|
|
37
185
|
createState?: () => unknown;
|
|
38
186
|
updateState?: (state: unknown, scene: Record<string, unknown>, dt: number) => unknown;
|
|
39
187
|
describeState?: (state: unknown, scene: Record<string, unknown>) => Record<string, unknown> | null;
|
|
@@ -47,12 +195,49 @@ export interface MountGpuShowcaseResult {
|
|
|
47
195
|
destroy(): void;
|
|
48
196
|
}
|
|
49
197
|
|
|
198
|
+
export interface MountGpuProductStudioResult {
|
|
199
|
+
readonly state: Readonly<{
|
|
200
|
+
featureFlags: unknown;
|
|
201
|
+
modelName: string;
|
|
202
|
+
sourceTriangleCount: number;
|
|
203
|
+
meshCount: number;
|
|
204
|
+
geometryMode: string;
|
|
205
|
+
requiresTriangleMeshRenderer: boolean;
|
|
206
|
+
displayQuality: boolean;
|
|
207
|
+
requiresMeshBvhForDisplayQuality: boolean;
|
|
208
|
+
rendererStats: Record<string, unknown>;
|
|
209
|
+
}>;
|
|
210
|
+
readonly model: GltfModel;
|
|
211
|
+
readonly canvas: HTMLCanvasElement;
|
|
212
|
+
readonly renderer: unknown;
|
|
213
|
+
readonly meshes: readonly ProductStudioMesh[];
|
|
214
|
+
destroy(): void;
|
|
215
|
+
}
|
|
216
|
+
|
|
50
217
|
export const showcaseFocusModes: readonly ShowcaseFocusMode[];
|
|
218
|
+
export const showcaseDemoModes: readonly ShowcaseDemoMode[];
|
|
219
|
+
export const GPU_SHOWCASE_REALISTIC_MODELS_FEATURE: "gpu_showcase_realistic_models_v1";
|
|
220
|
+
export const GPU_SHOWCASE_PRODUCT_STUDIO_FEATURE: "gpu_showcase_product_studio_wavefront_v1";
|
|
51
221
|
|
|
52
|
-
export function resolveShowcaseAssetUrl(
|
|
222
|
+
export function resolveShowcaseAssetUrl(
|
|
223
|
+
baseUrlOrAssetName?: string | URL | ShowcaseAssetName,
|
|
224
|
+
assetName?: ShowcaseAssetName
|
|
225
|
+
): URL;
|
|
53
226
|
|
|
54
227
|
export function loadGltfModel(url: string | URL): Promise<GltfModel>;
|
|
55
228
|
|
|
229
|
+
export function createProductStudioMeshes(
|
|
230
|
+
model: GltfModel,
|
|
231
|
+
options?: {
|
|
232
|
+
targetCenter?: readonly number[];
|
|
233
|
+
targetSize?: number;
|
|
234
|
+
}
|
|
235
|
+
): readonly ProductStudioMesh[];
|
|
236
|
+
|
|
237
|
+
export function mountGpuProductStudio(
|
|
238
|
+
options?: MountGpuShowcaseOptions
|
|
239
|
+
): Promise<MountGpuProductStudioResult>;
|
|
240
|
+
|
|
56
241
|
export function mountGpuShowcase(
|
|
57
242
|
options?: MountGpuShowcaseOptions
|
|
58
|
-
): Promise<MountGpuShowcaseResult>;
|
|
243
|
+
): Promise<MountGpuShowcaseResult | MountGpuProductStudioResult>;
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
export { resolveShowcaseAssetUrl } from "./asset-url.js";
|
|
2
|
+
export {
|
|
3
|
+
createGpuSharedTranslator,
|
|
4
|
+
gpuSharedTranslationKeys,
|
|
5
|
+
gpuSharedTranslations,
|
|
6
|
+
translateGpuSharedText,
|
|
7
|
+
} from "./i18n.js";
|
|
8
|
+
export { gpuSharedEnGbTranslations } from "./translations/en-GB.js";
|
|
9
|
+
export {
|
|
10
|
+
GPU_SHOWCASE_PRODUCT_STUDIO_FEATURE,
|
|
11
|
+
GPU_SHOWCASE_REALISTIC_MODELS_FEATURE,
|
|
12
|
+
} from "./feature-flags.js";
|
|
13
|
+
export {
|
|
14
|
+
createProductStudioMeshes,
|
|
15
|
+
mountGpuProductStudio,
|
|
16
|
+
} from "./product-studio-runtime.js";
|
|
2
17
|
|
|
3
18
|
export const showcaseFocusModes = Object.freeze([
|
|
4
19
|
"integrated",
|
|
@@ -9,6 +24,7 @@ export const showcaseFocusModes = Object.freeze([
|
|
|
9
24
|
"performance",
|
|
10
25
|
"debug",
|
|
11
26
|
]);
|
|
27
|
+
export const showcaseDemoModes = Object.freeze(["harbor", "product-studio"]);
|
|
12
28
|
|
|
13
29
|
export async function loadGltfModel(url) {
|
|
14
30
|
const module = await import("./gltf-loader.js");
|
|
@@ -16,6 +32,29 @@ export async function loadGltfModel(url) {
|
|
|
16
32
|
}
|
|
17
33
|
|
|
18
34
|
export async function mountGpuShowcase(options = {}) {
|
|
35
|
+
const demoMode = options.demoMode ?? options.mode;
|
|
36
|
+
if (
|
|
37
|
+
demoMode === "product-studio" ||
|
|
38
|
+
demoMode === "product" ||
|
|
39
|
+
demoMode === "studio" ||
|
|
40
|
+
demoMode === "eames"
|
|
41
|
+
) {
|
|
42
|
+
const productRuntimeLoader =
|
|
43
|
+
typeof options.__productRuntimeLoader === "function"
|
|
44
|
+
? options.__productRuntimeLoader
|
|
45
|
+
: () => import("./product-studio-runtime.js");
|
|
46
|
+
const productModule = await productRuntimeLoader();
|
|
47
|
+
if (typeof productModule.mountGpuProductStudio !== "function") {
|
|
48
|
+
throw new Error("product runtime loader must provide mountGpuProductStudio.");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const productOptions = { ...options, demoMode };
|
|
52
|
+
delete productOptions.__runtimeLoader;
|
|
53
|
+
delete productOptions.__productRuntimeLoader;
|
|
54
|
+
delete productOptions.__featureFlags;
|
|
55
|
+
return productModule.mountGpuProductStudio(productOptions, options.__featureFlags);
|
|
56
|
+
}
|
|
57
|
+
|
|
19
58
|
const runtimeLoader =
|
|
20
59
|
typeof options.__runtimeLoader === "function"
|
|
21
60
|
? options.__runtimeLoader
|
|
@@ -27,5 +66,7 @@ export async function mountGpuShowcase(options = {}) {
|
|
|
27
66
|
|
|
28
67
|
const publicOptions = { ...options };
|
|
29
68
|
delete publicOptions.__runtimeLoader;
|
|
30
|
-
|
|
69
|
+
delete publicOptions.__productRuntimeLoader;
|
|
70
|
+
delete publicOptions.__featureFlags;
|
|
71
|
+
return module.mountGpuShowcase(publicOptions, options.__featureFlags);
|
|
31
72
|
}
|