Skip to content

Instantly share code, notes, and snippets.

@maluoi
Last active September 14, 2023 07:22
Show Gist options
  • Save maluoi/fea5500f05037e1e70b4a1b077775c62 to your computer and use it in GitHub Desktop.
Save maluoi/fea5500f05037e1e70b4a1b077775c62 to your computer and use it in GitHub Desktop.
StereoKit "Reset to center"
using StereoKit;
SK.Initialize("SKRecenter");
SK.Run(() => {
Mesh.Sphere.Draw(Material.Default, Matrix.TS(0, 0, -0.5f, 0.1f));
if (Input.Key(Key.Space).IsJustActive()) {
// Get the head pose, and flatten the rotation to just the Y axis.
Pose head = Input.Head;
head.orientation.x = 0;
head.orientation.z = 0;
head.orientation.Normalize();
Pose root = Renderer.CameraRoot.Pose;
Renderer.CameraRoot = Matrix.TR(
head.orientation.Inverse * (root.position-head.position),
root.orientation * head.orientation.Inverse
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment