-
Notifications
You must be signed in to change notification settings - Fork 1
Really Fun Camera Positions
RFCPs are positions in the splat that are especially interesting and are thus saved for direct access. The user can "teleport" to them. The code for the teleportation is in TeleportControls.tsx and UI in CanvasLayer.tsx.
File: TeleportControls.tsx
The code enables changing the position and heading of the camera. For this the function teleport()
is defined with the useImperativeHandle
Method. The parameters of teleport()
are the target coordinates (x, y, z)
and the direction of view (lookAtX, lookAtY, lookAtZ)
. From these parameters the corresponding vectors are created and saved in teleportData
.
The useFrame
Hook tests in every frame if teleportData != null
and if this evaluates to true the position and heading of the camera are set according to teleportData
. Afterwards teleportData
is reset to null
so that new changes can be recognized.
File: CanvasLayer.tsx
A reference for TeleportControls
is created together with a test button. If the test button is clicked, the teleport()
function is called together with the test coordinates.