summaryrefslogtreecommitdiff
path: root/src/SomhairlesDream.Frontend/Bindings.fs
diff options
context:
space:
mode:
authorSomhairle H. Marisol <[email protected]>2026-09-21 02:03:45 +0800
committerSomhairle H. Marisol <[email protected]>2026-09-21 02:07:13 +0800
commitdd75aaf6e82799ce88d8e66b01a3d53ba05301c9 (patch)
treeef1601be2954f7c995f5fd47544241b457a7791e /src/SomhairlesDream.Frontend/Bindings.fs
parent7e7166e9a7dfe6d619dbb2d3baa54ee97dfce1b9 (diff)
downloadsomhairles-dream-fsharp-dd75aaf6e82799ce88d8e66b01a3d53ba05301c9.tar.gz
feat(viewer): fit camera to loaded model and add checked-in browser acceptance driver
- add three.js Box3/Camera bindings and bbox-driven camera framing (fov-fit with margin, recenters the model so group rotation orbits in place); refit on canvas resize instead of reverting to replay placeholder geometry - expose window.SOMHAIRLES_VIEWER debug handle for numeric verification - add tools/acceptance/e2e_acceptance.py: self-provisioning playwright driver (isolated port/artifact root, unique run ids) asserting framing, frozen-screenshot determinism, GLB hash equality, failure surfacing - gitignore scratch/ and tools/acceptance/deps/; document the clean-checkout verification sequence (fable before build)
Diffstat (limited to 'src/SomhairlesDream.Frontend/Bindings.fs')
-rw-r--r--src/SomhairlesDream.Frontend/Bindings.fs28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/SomhairlesDream.Frontend/Bindings.fs b/src/SomhairlesDream.Frontend/Bindings.fs
index 9dbfa00..a0276cc 100644
--- a/src/SomhairlesDream.Frontend/Bindings.fs
+++ b/src/SomhairlesDream.Frontend/Bindings.fs
@@ -8,6 +8,7 @@ type ThreeVector =
abstract x: float with get, set
abstract y: float with get, set
abstract z: float with get, set
+ abstract length: unit -> float
[<Erase>]
type ThreeNode =
@@ -19,6 +20,22 @@ type ThreeNode =
abstract background: obj with get, set
[<Erase>]
+type ThreeBox3 =
+ abstract setFromObject: node: ThreeNode -> ThreeBox3
+ abstract isEmpty: unit -> bool
+ abstract getCenter: target: ThreeVector -> ThreeVector
+ abstract getSize: target: ThreeVector -> ThreeVector
+
+[<Erase>]
+type ThreeCamera =
+ inherit ThreeNode
+ abstract fov: float with get, set
+ abstract aspect: float with get, set
+ abstract near: float with get, set
+ abstract far: float with get, set
+ abstract updateProjectionMatrix: unit -> unit
+
+[<Erase>]
type ThreeRenderer =
abstract setPixelRatio: ratio: float -> unit
abstract setSize: width: float * height: float * updateStyle: bool -> unit
@@ -71,7 +88,16 @@ let createScene () : ThreeNode = jsNative
let createGroup () : ThreeNode = jsNative
[<Emit("new THREE.PerspectiveCamera($0, $1, $2, $3)")>]
-let createPerspectiveCamera (fieldOfView: float, aspect: float, nearPlane: float, farPlane: float) : ThreeNode = jsNative
+let createPerspectiveCamera (fieldOfView: float, aspect: float, nearPlane: float, farPlane: float) : ThreeCamera = jsNative
+
+[<Emit("new THREE.Box3()")>]
+let createBox3 () : ThreeBox3 = jsNative
+
+[<Emit("new THREE.Vector3()")>]
+let createVector3 () : ThreeVector = jsNative
+
+[<Emit("window.SOMHAIRLES_VIEWER = { camera: $0, scene: $1, group: $2, canvas: $3 }")>]
+let exposeViewerDebug (camera: ThreeCamera) (scene: ThreeNode) (group: ThreeNode) (canvas: obj) : unit = jsNative
[<Emit("new THREE.WebGLRenderer($0)")>]
let createRenderer (options: obj) : ThreeRenderer = jsNative