Skip to content

Commit

Permalink
Add env map coordinate frame comments
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Nov 14, 2024
1 parent 34f8c9a commit e5c5278
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/viser/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,14 @@ function DefaultLights() {
);
const environmentMap = viewer.useSceneTree((state) => state.environmentMap);

// Environment map frames:
// - We want the `background_wxyz` and `environment_wxyz` to be in the Viser
// world frame. This is different from the threejs world frame, which should
// not be exposed to the user.
// - `backgroundRotation` and `environmentRotation` for the `Environment` component
// are in the threejs world frame.
const [R_threeworld_world, setR_threeworld_world] = React.useState(
// In Python, this will be set by `set_up_direction()`.
viewer.nodeAttributesFromName.current![""]!.wxyz!,
);
useFrame(() => {
Expand All @@ -512,8 +519,8 @@ function DefaultLights() {
environmentMap.background_wxyz[3],
environmentMap.background_wxyz[0],
)
.multiply(Rquat_world_threeworld)
.premultiply(Rquat_threeworld_world),
.premultiply(Rquat_threeworld_world)
.multiply(Rquat_world_threeworld),
);
const environmentRotation = new THREE.Euler().setFromQuaternion(
new THREE.Quaternion(
Expand All @@ -522,8 +529,8 @@ function DefaultLights() {
environmentMap.environment_wxyz[3],
environmentMap.environment_wxyz[0],
)
.multiply(Rquat_world_threeworld)
.premultiply(Rquat_threeworld_world),
.premultiply(Rquat_threeworld_world)
.multiply(Rquat_world_threeworld),
);

let envMapNode;
Expand Down

0 comments on commit e5c5278

Please sign in to comment.