Skip to content

Really Fun Camera Positions

FabiKogWi edited this page Jul 7, 2024 · 2 revisions

Really Fun Camera Positions (RFCP)

Overview

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.

Teleport Controls

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.

UI

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.

Clone this wiki locally