@hiber3d/hdk-core
Table of contents
Type Aliases
Functions
- eulerToQuaternion
- getAvatarDirection
- getAvatarPosition
- printAssets
- quaternionToEuler
- setAvatar
- setAvatarUrl
- setMovementMode
Type Aliases
EulerRotation
Euler rotation angles.
See
https://en.wikipedia.org/wiki/Euler_angles (opens in a new tab)
LiteralUnion
LiteralUnion<T
, U
>: T
| U
& Record
<never
, never
>
Type that allows a literal (i.e. string) but keeps autosuggest https://github.com/Microsoft/TypeScript/issues/29729 (opens in a new tab)
Type parameters
Name |
---|
T |
U |
QuaternionRotation
QuaternionRotation: [X
, Y
, Z
, W
]
Quaternion rotation.
See
- https://en.wikipedia.org/wiki/Quaternion (opens in a new tab)
- https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation (opens in a new tab)
Skeleton
Skeleton: AvatarSkeleton
Deprecated
Use AvatarSkeleton instead.
Vec3
Vec3: [number
, number
, number
]
A three-dimensional vector.
Vec4
Vec4: [number
, number
, number
, number
]
A four-dimensional vector.
W
W: number
Represents a rotation on the W axis.
X
X: number
Represents a rotation or distance on the X axis to the right of the origin.
Y
Y: number
Represents a rotation or distance on the Y axis, upwards from the origin.
Z
Z: number
Represents a rotation or distance on the Z axis, inwards from the origin.
Functions
eulerToQuaternion
eulerToQuaternion(euler
, quad?
): QuaternionRotation
Converts a rotation represented in Euler angles to a rotation represented as a Quaternion GlMatrix quaternion (opens in a new tab)
Parameters
Name | Type | Description |
---|---|---|
euler | EulerRotation | Input Euler angles - [x, y, z] Vec3 |
quad? | QuaternionRotation | optional Quaternion representation to be used as target - [x, y, z, w] Vec4 |
Returns
Quaternion representation - [x, y, z, w] Vec4
getAvatarDirection
getAvatarDirection(): Vec3
Returns
the current direction of the avatar on the level
getAvatarPosition
getAvatarPosition(): Vec3
Returns
the current position of the avatar on the level
printAssets
printAssets(): void
Outputting blockJSON
yarn build && node -e 'import("./dist/index.js").then(module => {module.printAssets(); process.exit(0);})' > src/generated/assets.json
Returns
void
quaternionToEuler
quaternionToEuler(quat
, euler?
): Vec3
Returns an euler angle representation (pitch-yaw-roll) of a quaternion
Parameters
Name | Type | Description |
---|---|---|
quat | Vec4 | Quaternion representation - [x, y, z, w] Vec4 |
euler? | Vec3 | optional euler to be used as target - [x, y, z] Vec3 |
Returns
Euler angles representation - [x, y, z] EulerRotation
setAvatar
setAvatar(id
): void
This sets the avatar for the player using one of Hiber's own avatars
Parameters
Name | Type | Description |
---|---|---|
id | AvatarId | id for a Hiber avatar to be equipped |
Returns
void
setAvatarUrl
setAvatarUrl(url
, provider
): void
This sets the player avatar from an external provider
Parameters
Name | Type | Description |
---|---|---|
url | string | url to the .glb file |
provider | string | provider of the avatar |
Returns
void
setMovementMode
setMovementMode(mode
): void
This sets the player movement mode
Parameters
Name | Type | Description |
---|---|---|
mode | MovementType | the mode of the player movement to, i.e. 'fly' or 'walk' |
Returns
void