summaryrefslogtreecommitdiff
path: root/public/App.js
diff options
context:
space:
mode:
authorSomhairle H. Marisol <[email protected]>2026-09-21 23:47:42 +0800
committerSomhairle H. Marisol <[email protected]>2026-09-21 23:47:42 +0800
commit5d73943e584b1c0c0753dda85fbda34d27726986 (patch)
tree5126127692f3cd399345aae8ade5ec66dd247668 /public/App.js
parent7c3a0728570f84f5c7d5f396c5a5d5c11f5fb661 (diff)
downloadsomhairles-dream-fsharp-5d73943e584b1c0c0753dda85fbda34d27726986.tar.gz
feat(ship): HNX-02 Copernicus rework — continuous hull, few-large-element scale, Draco pipeline, side-on framing
Diffstat (limited to 'public/App.js')
-rw-r--r--public/App.js31
1 files changed, 19 insertions, 12 deletions
diff --git a/public/App.js b/public/App.js
index a91f298..7e73305 100644
--- a/public/App.js
+++ b/public/App.js
@@ -1,8 +1,8 @@
import { Union, Record } from "./fable_modules/fable-library-js.4.24.0/Types.js";
import { union_type, obj_type, class_type, record_type, bool_type, string_type } from "./fable_modules/fable-library-js.4.24.0/Reflection.js";
-import { comparePrimitives, defaultOf, equals, createAtom } from "./fable_modules/fable-library-js.4.24.0/Util.js";
+import { defaultOf, equals, comparePrimitives, createAtom } from "./fable_modules/fable-library-js.4.24.0/Util.js";
import { Replay_frames } from "./SomhairlesDream.Shared/Replay.js";
-import { sortBy, map, equalsWith, tryFind, iterateIndexed, item } from "./fable_modules/fable-library-js.4.24.0/Array.js";
+import { sortBy, map, equalsWith, tryFind, iterateIndexed, sort, item } from "./fable_modules/fable-library-js.4.24.0/Array.js";
import { join, isNullOrWhiteSpace, printf, toText } from "./fable_modules/fable-library-js.4.24.0/String.js";
import { MeshData_triangleIndices, MeshData_positionData } from "./SomhairlesDream.Shared/Domain.js";
import { min, max } from "./fable_modules/fable-library-js.4.24.0/Double.js";
@@ -253,19 +253,23 @@ export function frameObject(view, node) {
const size = new THREE.Vector3();
box.getCenter(center);
box.getSize(size);
- const radius = 0.5 * size.length();
- if (radius > 1E-06) {
+ const axes = sort(new Float64Array([size.x, size.y, size.z]), {
+ Compare: comparePrimitives,
+ });
+ const longest = item(2, axes);
+ const smallest = item(0, axes);
+ if (longest > 1E-06) {
node.position.set(-center.x, -center.y, -center.z);
const camera = view.Camera;
- const aspect = max(1, view.Canvas.clientWidth) / max(1, view.Canvas.clientHeight);
+ const aspect = max(0.3, max(1, view.Canvas.clientWidth) / max(1, view.Canvas.clientHeight));
camera.aspect = aspect;
const fovY = (camera.fov * 3.141592653589793) / 180;
- const limitingFov = min(fovY, 2 * Math.atan(Math.tan(fovY / 2) * aspect));
- const distance = (1.28 * radius) / Math.sin(limitingFov / 2);
- const norm = Math.sqrt(((0.62 * 0.62) + (0.45 * 0.45)) + (0.7 * 0.7));
- camera.position.set((0.62 / norm) * distance, (0.45 / norm) * distance, (0.7 / norm) * distance);
- camera.near = max(distance * 0.01, distance - (radius * 2.5));
- camera.far = (distance + (radius * 4));
+ const tanHalf = Math.tan(fovY / 2);
+ const distance = 1.25 * max((0.5 * longest) / (tanHalf * aspect), (0.5 * smallest) / tanHalf);
+ const norm = Math.sqrt(((0.3 * 0.3) + (0.44 * 0.44)) + (0.85 * 0.85));
+ camera.position.set((0.3 / norm) * distance, (0.44 / norm) * distance, (0.85 / norm) * distance);
+ camera.near = max(1, distance * 0.05);
+ camera.far = (distance + (longest * 3));
camera.lookAt(0, 0, 0);
camera.updateProjectionMatrix();
const matchValue_3 = view.Controls;
@@ -438,6 +442,9 @@ export function startStepLoad(view, owner, historical) {
loadedStep(undefined);
document.getElementById("viewport-loading").classList.toggle('is-hidden', false);
const loader = new GLTFLoader();
+ const draco = new DRACOLoader();
+ draco.setDecoderPath("/vendor/addons/libs/draco/");
+ loader.setDRACOLoader(draco);
const projectId = encodeURIComponent(owner.ProjectId);
const runId = encodeURIComponent(owner.RunId);
const stamp = ~~(Date.now() % 100000000) | 0;
@@ -884,7 +891,7 @@ export function inputValue(id) {
export const probeSelection = new RunSelection("probe-001", "run-probe-real-2", "probe-base-000", "probe-target-007", false);
-export const shipSelection = new RunSelection("ship-001", "run-ship-001", "ship-base-000", "ship-target-007", false);
+export const shipSelection = new RunSelection("ship-001", "run-ship-002", "ship-base-000", "ship-target-007", false);
export let activeModel = createAtom(probeSelection);