summaryrefslogtreecommitdiff
path: root/public/App.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/App.js')
-rw-r--r--public/App.js63
1 files changed, 59 insertions, 4 deletions
diff --git a/public/App.js b/public/App.js
index 262025a..c5a5418 100644
--- a/public/App.js
+++ b/public/App.js
@@ -1,7 +1,7 @@
import { Record } from "./fable_modules/fable-library-js.4.24.0/Types.js";
import { class_type, record_type, bool_type, string_type } from "./fable_modules/fable-library-js.4.24.0/Reflection.js";
import { Replay_frames } from "./SomhairlesDream.Shared/Replay.js";
-import { createAtom } from "./fable_modules/fable-library-js.4.24.0/Util.js";
+import { equals, createAtom } from "./fable_modules/fable-library-js.4.24.0/Util.js";
import { tryFind, item } from "./fable_modules/fable-library-js.4.24.0/Array.js";
import { isNullOrWhiteSpace, printf, toText } from "./fable_modules/fable-library-js.4.24.0/String.js";
import { MeshData_triangleIndices, MeshData_positionData } from "./SomhairlesDream.Shared/Domain.js";
@@ -52,6 +52,14 @@ export let replayIndex = createAtom(0);
export let eventSource = createAtom(undefined);
+export let currentProjectId = createAtom("");
+
+export let currentRunId = createAtom("");
+
+export let loadedStepPath = createAtom(undefined);
+
+export let freezeRotation = createAtom(false);
+
export function element(id) {
return document.getElementById(id);
}
@@ -204,12 +212,15 @@ export function initializeView() {
scene.add(keyLight);
const view = new ViewState(renderer, scene, camera, group, canvas);
viewState(view);
+ freezeRotation((new URLSearchParams(window.location.search).get("freeze")) === "1");
renderFrame(selectedFrame());
window.addEventListener("resize", (_arg) => {
resizeView(view);
});
const animate = (_arg_1) => {
- group.rotation.y = (group.rotation.y + 0.003);
+ if (!freezeRotation()) {
+ group.rotation.y = (group.rotation.y + 0.003);
+ }
renderer.render(scene, camera);
requestAnimationFrame(animate);
};
@@ -239,6 +250,24 @@ export function setManifestLink(payload) {
}
}
+export function loadStepArtifact(view, stepPath) {
+ loadedStepPath(stepPath);
+ const loader = new GLTFLoader();
+ const projectId = encodeURIComponent(currentProjectId());
+ const runId = encodeURIComponent(currentRunId());
+ let url;
+ const arg_2 = encodeURIComponent(stepPath);
+ url = toText(printf("/api/artifacts/steps?projectId=%s&runId=%s&path=%s"))(projectId)(runId)(arg_2);
+ setText("viewport-note", toText(printf("管线几何加载中 · %s"))(stepPath));
+ loader.load(url, ((gltf) => {
+ view.Group.clear();
+ view.Group.add(gltf.scene);
+ setText("viewport-note", toText(printf("管线几何 · %s"))(stepPath));
+ }), null, ((_arg) => {
+ setText("viewport-note", toText(printf("管线几何加载失败 · %s"))(stepPath));
+ }));
+}
+
export function updateState(payload) {
let arg, arg_3;
setStatusClass(statusName(payload));
@@ -246,6 +275,8 @@ export function updateState(payload) {
setText("run-message", ((payload.status === "failed") && !isNullOrWhiteSpace(payload.error)) ? payload.error : payload.message);
setText("project-id", payload.projectId);
setText("run-id", payload.runId);
+ currentProjectId(payload.projectId);
+ currentRunId(payload.runId);
const currentVersion = max(0, payload.currentStepIndex + 1) | 0;
setText("target-version", (arg = (payload.totalSteps | 0), toText(printf("V%02d"))(arg)));
setText("current-version", toText(printf("V%02d"))(currentVersion));
@@ -255,8 +286,32 @@ export function updateState(payload) {
setWidth("progress-fill", toText(printf("%.0f%%"))(progress));
const frame = defaultArg(tryFind((candidate) => (candidate.Version === currentVersion), frames), selectedFrame());
setManifestLink(payload);
- showFrameMetadata(frame);
- renderFrame(frame);
+ const completedSteps = (payload.completedSteps == null) ? [] : payload.completedSteps;
+ const matchValue = viewState();
+ if (matchValue == null) {
+ const steps_1 = completedSteps;
+ if (steps_1.length > 0) {
+ setText("mesh-label", item(steps_1.length - 1, steps_1));
+ }
+ else {
+ showFrameMetadata(frame);
+ }
+ }
+ else {
+ const view = matchValue;
+ const steps = completedSteps;
+ if (steps.length === 0) {
+ showFrameMetadata(frame);
+ renderFrame(frame);
+ }
+ else {
+ const latest = item(steps.length - 1, steps);
+ if (!equals(loadedStepPath(), latest)) {
+ loadStepArtifact(view, latest);
+ }
+ setText("mesh-label", latest);
+ }
+ }
}
export function updateStreamState(message) {