@plasius/gpu-shared 0.1.2 → 0.1.4
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 +37 -0
- package/README.md +19 -1
- package/dist/chunk-S5NCFNKJ.js +14 -0
- package/dist/chunk-S5NCFNKJ.js.map +1 -0
- package/dist/index.cjs +67 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/{showcase-runtime-67CHJBNO.js → showcase-runtime-4BS7TWHS.js} +47 -14
- package/dist/{showcase-runtime-67CHJBNO.js.map → showcase-runtime-4BS7TWHS.js.map} +1 -1
- package/package.json +1 -1
- package/src/asset-url.js +10 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +2 -4
- package/src/showcase-runtime.js +49 -12
package/dist/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveShowcaseAssetUrl
|
|
3
|
+
} from "./chunk-S5NCFNKJ.js";
|
|
1
4
|
import "./chunk-DGUM43GV.js";
|
|
2
5
|
|
|
3
6
|
// src/index.js
|
|
@@ -10,15 +13,12 @@ var showcaseFocusModes = Object.freeze([
|
|
|
10
13
|
"performance",
|
|
11
14
|
"debug"
|
|
12
15
|
]);
|
|
13
|
-
function resolveShowcaseAssetUrl(baseUrl = import.meta.url) {
|
|
14
|
-
return new URL("../assets/brigantine.gltf", baseUrl);
|
|
15
|
-
}
|
|
16
16
|
async function loadGltfModel(url) {
|
|
17
17
|
const module = await import("./gltf-loader-4FNTT63R.js");
|
|
18
18
|
return module.loadGltfModel(url);
|
|
19
19
|
}
|
|
20
20
|
async function mountGpuShowcase(options = {}) {
|
|
21
|
-
const runtimeLoader = typeof options.__runtimeLoader === "function" ? options.__runtimeLoader : () => import("./showcase-runtime-
|
|
21
|
+
const runtimeLoader = typeof options.__runtimeLoader === "function" ? options.__runtimeLoader : () => import("./showcase-runtime-4BS7TWHS.js");
|
|
22
22
|
const module = await runtimeLoader();
|
|
23
23
|
if (typeof module.mountGpuShowcase !== "function") {
|
|
24
24
|
throw new Error("showcase runtime loader must provide mountGpuShowcase.");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"sourcesContent":["export const showcaseFocusModes = Object.freeze([\n \"integrated\",\n \"lighting\",\n \"cloth\",\n \"fluid\",\n \"physics\",\n \"performance\",\n \"debug\",\n]);\n\nexport
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"sourcesContent":["export { resolveShowcaseAssetUrl } from \"./asset-url.js\";\n\nexport const showcaseFocusModes = Object.freeze([\n \"integrated\",\n \"lighting\",\n \"cloth\",\n \"fluid\",\n \"physics\",\n \"performance\",\n \"debug\",\n]);\n\nexport async function loadGltfModel(url) {\n const module = await import(\"./gltf-loader.js\");\n return module.loadGltfModel(url);\n}\n\nexport async function mountGpuShowcase(options = {}) {\n const runtimeLoader =\n typeof options.__runtimeLoader === \"function\"\n ? options.__runtimeLoader\n : () => import(\"./showcase-runtime.js\");\n const module = await runtimeLoader();\n if (typeof module.mountGpuShowcase !== \"function\") {\n throw new Error(\"showcase runtime loader must provide mountGpuShowcase.\");\n }\n\n const publicOptions = { ...options };\n delete publicOptions.__runtimeLoader;\n return module.mountGpuShowcase(publicOptions);\n}\n"],"mappings":";;;;;;AAEO,IAAM,qBAAqB,OAAO,OAAO;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,eAAsB,cAAc,KAAK;AACvC,QAAM,SAAS,MAAM,OAAO,2BAAkB;AAC9C,SAAO,OAAO,cAAc,GAAG;AACjC;AAEA,eAAsB,iBAAiB,UAAU,CAAC,GAAG;AACnD,QAAM,gBACJ,OAAO,QAAQ,oBAAoB,aAC/B,QAAQ,kBACR,MAAM,OAAO,gCAAuB;AAC1C,QAAM,SAAS,MAAM,cAAc;AACnC,MAAI,OAAO,OAAO,qBAAqB,YAAY;AACjD,UAAM,IAAI,MAAM,wDAAwD;AAAA,EAC1E;AAEA,QAAM,gBAAgB,EAAE,GAAG,QAAQ;AACnC,SAAO,cAAc;AACrB,SAAO,OAAO,iBAAiB,aAAa;AAC9C;","names":[]}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resolveShowcaseAssetUrl
|
|
3
|
+
} from "./chunk-S5NCFNKJ.js";
|
|
1
4
|
import {
|
|
2
5
|
loadGltfModel
|
|
3
6
|
} from "./chunk-UUJLYYQS.js";
|
|
@@ -6187,9 +6190,6 @@ var UNIT_BOX_MESH = Object.freeze({
|
|
|
6187
6190
|
0
|
|
6188
6191
|
])
|
|
6189
6192
|
});
|
|
6190
|
-
function resolveShowcaseAssetUrl(baseUrl2 = import.meta.url) {
|
|
6191
|
-
return new URL("../assets/brigantine.gltf", baseUrl2);
|
|
6192
|
-
}
|
|
6193
6193
|
function injectStyles() {
|
|
6194
6194
|
if (document.getElementById(STYLE_ID)) {
|
|
6195
6195
|
return;
|
|
@@ -7710,6 +7710,9 @@ function syncTextState(state, shipModel) {
|
|
|
7710
7710
|
async function mountGpuShowcase(options = {}) {
|
|
7711
7711
|
injectStyles();
|
|
7712
7712
|
const root = options.root ?? document.body;
|
|
7713
|
+
const previousMarkup = root.innerHTML;
|
|
7714
|
+
const previousRenderGameToText = window.render_game_to_text;
|
|
7715
|
+
const previousAdvanceTime = window.advanceTime;
|
|
7713
7716
|
const focus = options.focus ?? new URLSearchParams(window.location.search).get("focus") ?? "integrated";
|
|
7714
7717
|
const dom = buildDemoDom(root, {
|
|
7715
7718
|
packageName: options.packageName ?? "@plasius/gpu-demo-viewer",
|
|
@@ -7726,7 +7729,12 @@ async function mountGpuShowcase(options = {}) {
|
|
|
7726
7729
|
state.demoDescription = resolveSceneDescription(state, options, shipModel).description;
|
|
7727
7730
|
syncTextState(state, shipModel);
|
|
7728
7731
|
const ctx = dom.canvas.getContext("2d");
|
|
7732
|
+
let destroyed = false;
|
|
7733
|
+
let frameHandle = null;
|
|
7729
7734
|
const renderFrame = (nowMs) => {
|
|
7735
|
+
if (destroyed) {
|
|
7736
|
+
return;
|
|
7737
|
+
}
|
|
7730
7738
|
if (!state.paused) {
|
|
7731
7739
|
if (state.lastTimeMs == null) {
|
|
7732
7740
|
state.lastTimeMs = nowMs;
|
|
@@ -7743,27 +7751,53 @@ async function mountGpuShowcase(options = {}) {
|
|
|
7743
7751
|
state.demoDescription = resolveSceneDescription(state, options, shipModel).description;
|
|
7744
7752
|
renderScene(ctx, dom.canvas, state, shipModel, dom);
|
|
7745
7753
|
syncTextState(state, shipModel);
|
|
7746
|
-
requestAnimationFrame(renderFrame);
|
|
7754
|
+
frameHandle = requestAnimationFrame(renderFrame);
|
|
7747
7755
|
};
|
|
7748
|
-
|
|
7756
|
+
const handlePauseClick = () => {
|
|
7749
7757
|
state.paused = !state.paused;
|
|
7750
7758
|
dom.pauseButton.textContent = state.paused ? "Resume" : "Pause";
|
|
7751
|
-
}
|
|
7752
|
-
|
|
7759
|
+
};
|
|
7760
|
+
const handleStressChange = () => {
|
|
7753
7761
|
state.stress = dom.stressToggle.checked;
|
|
7754
|
-
}
|
|
7755
|
-
|
|
7762
|
+
};
|
|
7763
|
+
const handleFocusChange = () => {
|
|
7756
7764
|
state.focus = dom.focusMode.value;
|
|
7757
7765
|
Object.assign(state.camera, {
|
|
7758
7766
|
...CAMERA_PRESETS[state.focus],
|
|
7759
7767
|
target: vec3(...CAMERA_PRESETS[state.focus].target)
|
|
7760
7768
|
});
|
|
7761
|
-
}
|
|
7762
|
-
|
|
7769
|
+
};
|
|
7770
|
+
dom.pauseButton.addEventListener("click", handlePauseClick);
|
|
7771
|
+
dom.stressToggle.addEventListener("change", handleStressChange);
|
|
7772
|
+
dom.focusMode.addEventListener("change", handleFocusChange);
|
|
7773
|
+
frameHandle = requestAnimationFrame(renderFrame);
|
|
7763
7774
|
return {
|
|
7764
7775
|
state,
|
|
7765
7776
|
shipModel,
|
|
7766
|
-
canvas: dom.canvas
|
|
7777
|
+
canvas: dom.canvas,
|
|
7778
|
+
destroy() {
|
|
7779
|
+
if (destroyed) {
|
|
7780
|
+
return;
|
|
7781
|
+
}
|
|
7782
|
+
destroyed = true;
|
|
7783
|
+
if (frameHandle != null) {
|
|
7784
|
+
cancelAnimationFrame(frameHandle);
|
|
7785
|
+
}
|
|
7786
|
+
dom.pauseButton.removeEventListener("click", handlePauseClick);
|
|
7787
|
+
dom.stressToggle.removeEventListener("change", handleStressChange);
|
|
7788
|
+
dom.focusMode.removeEventListener("change", handleFocusChange);
|
|
7789
|
+
root.innerHTML = previousMarkup;
|
|
7790
|
+
if (typeof previousRenderGameToText === "function") {
|
|
7791
|
+
window.render_game_to_text = previousRenderGameToText;
|
|
7792
|
+
} else {
|
|
7793
|
+
delete window.render_game_to_text;
|
|
7794
|
+
}
|
|
7795
|
+
if (typeof previousAdvanceTime === "function") {
|
|
7796
|
+
window.advanceTime = previousAdvanceTime;
|
|
7797
|
+
} else {
|
|
7798
|
+
delete window.advanceTime;
|
|
7799
|
+
}
|
|
7800
|
+
}
|
|
7767
7801
|
};
|
|
7768
7802
|
}
|
|
7769
7803
|
function updatePhysicsSnapshot(state, shipModel) {
|
|
@@ -7788,7 +7822,6 @@ function updatePhysicsSnapshot(state, shipModel) {
|
|
|
7788
7822
|
}
|
|
7789
7823
|
export {
|
|
7790
7824
|
mountGpuShowcase,
|
|
7791
|
-
resolveShowcaseAssetUrl,
|
|
7792
7825
|
showcaseFocusModes
|
|
7793
7826
|
};
|
|
7794
|
-
//# sourceMappingURL=showcase-runtime-
|
|
7827
|
+
//# sourceMappingURL=showcase-runtime-4BS7TWHS.js.map
|