UNPKG

hytopia

Version:

The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.

660 lines (288 loc) 9.32 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [server](./server.md) &gt; [PlayerCamera](./server.playercamera.md) ## PlayerCamera class The camera for a Player. **Signature:** ```typescript export default class PlayerCamera extends EventRouter implements protocol.Serializable ``` **Extends:** [EventRouter](./server.eventrouter.md) **Implements:** protocol.Serializable ## Remarks The camera is used to render the player's view of the world. The player's camera exposes functionality to control the camera of a player. All player objects have a camera, accessible via [Player.camera](./server.player.camera.md)<!-- -->. <h2>Events</h2> This class is an EventRouter, and instances of it emit events with payloads listed under [PlayerCameraEventPayloads](./server.playercameraeventpayloads.md) The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `PlayerCamera` class. ## Example ```typescript player.camera.setMode(PlayerCameraMode.FIRST_PERSON); ``` ## Properties <table><thead><tr><th> Property </th><th> Modifiers </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> [attachedToEntity](./server.playercamera.attachedtoentity.md) </td><td> `readonly` </td><td> [Entity](./server.entity.md) \| undefined </td><td> The entity the camera is attached to. </td></tr> <tr><td> [attachedToPosition](./server.playercamera.attachedtoposition.md) </td><td> `readonly` </td><td> [Vector3Like](./server.vector3like.md) \| undefined </td><td> The position the camera is attached to. </td></tr> <tr><td> [facingDirection](./server.playercamera.facingdirection.md) </td><td> `readonly` </td><td> [Vector3Like](./server.vector3like.md) </td><td> The facing direction vector of the camera based on its current orientation. </td></tr> <tr><td> [facingQuaternion](./server.playercamera.facingquaternion.md) </td><td> `readonly` </td><td> [QuaternionLike](./server.quaternionlike.md) </td><td> The quaternion representing the camera's facing direction. </td></tr> <tr><td> [filmOffset](./server.playercamera.filmoffset.md) </td><td> `readonly` </td><td> number </td><td> The film offset of the camera. A positive value shifts the camera right, a negative value shifts it left. </td></tr> <tr><td> [forwardOffset](./server.playercamera.forwardoffset.md) </td><td> `readonly` </td><td> number </td><td> Only used in first-person mode. The forward offset of the camera. A positive number shifts the camera forward, a negative number shifts it backward. </td></tr> <tr><td> [fov](./server.playercamera.fov.md) </td><td> `readonly` </td><td> number </td><td> The field of view of the camera. </td></tr> <tr><td> [mode](./server.playercamera.mode.md) </td><td> `readonly` </td><td> [PlayerCameraMode](./server.playercameramode.md) </td><td> The mode of the camera. </td></tr> <tr><td> [modelHiddenNodes](./server.playercamera.modelhiddennodes.md) </td><td> `readonly` </td><td> Set&lt;string&gt; </td><td> The nodes of the model the camera is attached to that will not be rendered for the player. Uses case insensitive substring matching. </td></tr> <tr><td> [modelShownNodes](./server.playercamera.modelshownnodes.md) </td><td> `readonly` </td><td> Set&lt;string&gt; </td><td> The nodes of the model the camera is attached to that will be rendered for the player, overriding hidden nodes. Uses case insensitive substring matching. </td></tr> <tr><td> [offset](./server.playercamera.offset.md) </td><td> `readonly` </td><td> [Vector3Like](./server.vector3like.md) </td><td> The relative offset of the camera from the entity or position it is attached to. </td></tr> <tr><td> [orientation](./server.playercamera.orientation.md) </td><td> `readonly` </td><td> [PlayerCameraOrientation](./server.playercameraorientation.md) </td><td> The current orientation of the camera. </td></tr> <tr><td> [player](./server.playercamera.player.md) </td><td> `readonly` </td><td> [Player](./server.player.md) </td><td> The player that the camera belongs to. </td></tr> <tr><td> [shoulderAngle](./server.playercamera.shoulderangle.md) </td><td> `readonly` </td><td> number </td><td> The shoulder angle of the camera in degrees. </td></tr> <tr><td> [trackedEntity](./server.playercamera.trackedentity.md) </td><td> `readonly` </td><td> [Entity](./server.entity.md) \| undefined </td><td> The entity the camera will constantly look at, even if the camera attached or tracked entity moves. </td></tr> <tr><td> [trackedPosition](./server.playercamera.trackedposition.md) </td><td> `readonly` </td><td> [Vector3Like](./server.vector3like.md) \| undefined </td><td> The position the camera will constantly look at, even if the camera attached entity moves. </td></tr> <tr><td> [zoom](./server.playercamera.zoom.md) </td><td> `readonly` </td><td> number </td><td> The zoom of the camera. </td></tr> </tbody></table> ## Methods <table><thead><tr><th> Method </th><th> Modifiers </th><th> Description </th></tr></thead> <tbody><tr><td> [lookAtEntity(entity)](./server.playercamera.lookatentity.md) </td><td> </td><td> Makes the camera look at an entity. If the camera was previously tracking an entity or position, it will stop tracking. </td></tr> <tr><td> [lookAtPosition(position)](./server.playercamera.lookatposition.md) </td><td> </td><td> Makes the camera look at a position. If the camera was previously tracking an entity or position, it will stop tracking. </td></tr> <tr><td> [reset()](./server.playercamera.reset.md) </td><td> </td><td> Resets the camera to its default, unattached, spectator mode state. </td></tr> <tr><td> [setAttachedToEntity(entity)](./server.playercamera.setattachedtoentity.md) </td><td> </td><td> Sets the entity the camera is attached to. </td></tr> <tr><td> [setAttachedToPosition(position)](./server.playercamera.setattachedtoposition.md) </td><td> </td><td> Sets the position the camera is attached to. </td></tr> <tr><td> [setFilmOffset(filmOffset)](./server.playercamera.setfilmoffset.md) </td><td> </td><td> Sets the film offset of the camera. A positive value shifts the camera right, a negative value shifts it left. </td></tr> <tr><td> [setForwardOffset(forwardOffset)](./server.playercamera.setforwardoffset.md) </td><td> </td><td> Only used in first-person mode. Sets the forward offset of the camera. A positive value shifts the camera forward, a negative value shifts it backward. </td></tr> <tr><td> [setFov(fov)](./server.playercamera.setfov.md) </td><td> </td><td> Sets the field of view of the camera. </td></tr> <tr><td> [setMode(mode)](./server.playercamera.setmode.md) </td><td> </td><td> Sets the mode of the camera. </td></tr> <tr><td> [setModelHiddenNodes(modelHiddenNodes)](./server.playercamera.setmodelhiddennodes.md) </td><td> </td><td> Sets the nodes of the model the camera is attached to that will not be rendered for the player. Uses case insensitive substring matching. </td></tr> <tr><td> [setModelShownNodes(modelShownNodes)](./server.playercamera.setmodelshownnodes.md) </td><td> </td><td> Sets the nodes of the model the camera is attached to that will be rendered for the player, overriding hidden nodes. Uses case insensitive substring matching. </td></tr> <tr><td> [setOffset(offset)](./server.playercamera.setoffset.md) </td><td> </td><td> Sets the relative offset of the camera from the entity or position it is attached to. </td></tr> <tr><td> [setShoulderAngle(shoulderAngle)](./server.playercamera.setshoulderangle.md) </td><td> </td><td> Only used in third-person mode. Sets the shoulder angle of the camera in degrees. A positive value shifts the camera to the right, a negative value shifts it to the left. </td></tr> <tr><td> [setTrackedEntity(entity)](./server.playercamera.settrackedentity.md) </td><td> </td><td> Sets the entity the camera will constantly look at, even if the camera attached or tracked entity moves. </td></tr> <tr><td> [setTrackedPosition(position)](./server.playercamera.settrackedposition.md) </td><td> </td><td> Sets the position the camera will constantly look at, even if the camera attached entity moves. </td></tr> <tr><td> [setZoom(zoom)](./server.playercamera.setzoom.md) </td><td> </td><td> Sets the zoom of the camera. </td></tr> </tbody></table>