Asset
Library for reading assets of all types from the filesystem.
Functions
Asset.loadModel
Loads a 3D model at the given path from the virtual filesystem.
The given path should not contain a file extension, as this is determined automatically from a list of supported formats:
.glb- Binary glTF.gltf- Text glTF.mdl- Source Engine MDL
Asset.loadModel(path: string): Asset3d
Parameters
| Name | Type | Default Value | Description |
|---|---|---|---|
| path | string | Required | Path to the model in the VFS, minus an extension. |
Returns
| Name | Type | Description |
|---|---|---|
| asset | Asset3d | The loaded asset. |
Asset.loadMap
Loads a map at the given path from the virtual filesystem.
The given path should not contain a file extension, as this is determined automatically from a list of supported formats:
.bsp- Source Engine BSP
Asset.loadMap(path: string): Map
Parameters
| Name | Type | Default Value | Description |
|---|---|---|---|
| path | string | Required | Path to the map in the VFS, minus an extension. |
Returns
| Name | Type | Description |
|---|---|---|
| asset | Map | The loaded asset. |
Types
Asset3dRigidBody
Internal structure of Asset3d describing the physics motion of a node.
type Asset3dRigidBody = { isStatic: boolean }
Properties
| Field | Type | Description |
|---|---|---|
| isStatic | boolean | Whether this rigid-body is static (generates collisions but cannot move). |
Asset3dNode
Internal structure of Asset3d which can be considered 1:1 with TASBox entities.
type Asset3dNode = { isRoot: boolean, shouldPrune: boolean, name: string, children: number[], position: vector, orientation: Quaternion, scale: vector, rigidBody: Asset3dRigidBody?, colliderIndex: number?, meshIndex: number?, skeletonIndex: number? }
Properties
| Field | Type | Description |
|---|---|---|
| isRoot | boolean | Whether this node is at the root of the hierarchy (i.e. has no parent). |
| shouldPrune | boolean | Whether this node should be discarded when loading (i.e. should not create an entity). |
| name | string | Optional display name for the entity. |
| children | number[] | Indices of this node's children in the asset's nodes array. |
| position | vector | Position of this node relative to its parent. |
| orientation | Quaternion | Orientation of this node relative to its parent. |
| scale | vector | Scale of this node relative to its parent. |
| rigidBody | Asset3dRigidBody? | Optional rigid-body motion for this node. |
| colliderIndex | number? | Optional index of a physics collider to attach to this node. |
| meshIndex | number? | Optional index of a mesh to attach to this node. |
| skeletonIndex | number? | Optional index of a skeleton to attach to this node. |
Asset3dInverseBindPose
Internal structure of Asset3d describing the inverse bind pose of a bone.
type Asset3dInverseBindPose = { position: vector, orientation: Quaternion }
Properties
| Field | Type | Description |
|---|---|---|
| position | vector | No description |
| orientation | Quaternion | No description |
Asset3dBone
Internal structure of Asset3d describing the bone of a skeleton.
type Asset3dBone = { nodeIndex: number, inverseBindPose: Asset3dInverseBindPose }
Properties
| Field | Type | Description |
|---|---|---|
| nodeIndex | number | Index of the bone's node in the asset's node array. |
| inverseBindPose | Asset3dInverseBindPose | Inverse bind pose of the bone used for pre-transforming the mesh during skinning. |
Asset3dSkeleton
Internal structure of Asset3d listing nodes to use as bone positions for skinned meshes.
type Asset3dSkeleton = { bones: Asset3dBone }
Properties
| Field | Type | Description |
|---|---|---|
| bones | Asset3dBone | List of bones which skinned meshes that reference this skeleton index into. |
Asset3dArticulationLimit
Internal structure of Asset3d describing a limit on a single degree of freedom of an articulation link's constraint.
type Asset3dArticulationLimit = { min: number, max: number, isFixed: boolean }
Properties
| Field | Type | Description |
|---|---|---|
| min | number | Minimum rotation about this degree of freedom in radians. |
| max | number | Maximum rotation about this degree of freedom in radians. |
| isFixed | boolean | Whether the limit is fixed (min and max are within a small tolerance). |
Asset3dArticulationLimits
Internal structure of Asset3d describing the limits of an articulation link's constraint.
type Asset3dArticulationLimits = { angularX: Asset3dArticulationLimit, angularY: Asset3dArticulationLimit, angularZ: Asset3dArticulationLimit, jointType: JointType }
Properties
| Field | Type | Description |
|---|---|---|
| angularX | Asset3dArticulationLimit | Limit on rotation about the joint's local X axis (in radians). |
| angularY | Asset3dArticulationLimit | Limit on rotation about the joint's local Y axis (in radians). |
| angularZ | Asset3dArticulationLimit | Limit on rotation about the joint's local Z axis (in radians). |
| jointType | JointType | Joint type with the minimum number of degrees of freedom for these limits. |
Asset3dArticulationConstraint
Internal structure of Asset3d describing the constraint formed by an articulation link.
type Asset3dArticulationConstraint = { limits: Asset3dArticulationLimits }
Properties
| Field | Type | Description |
|---|---|---|
| limits | Asset3dArticulationLimits | Limits of the constraint about each degree of freedom. |
Asset3dArticulationLink
Internal structure of Asset3d describing a link between two nodes in an articulation.
type Asset3dArticulationLink = { parentNodeIndex: number, childNodeIndex: number, constraint: Asset3dArticulationConstraint }
Properties
| Field | Type | Description |
|---|---|---|
| parentNodeIndex | number | Index of the link's parent in the asset's node array. |
| childNodeIndex | number | Index of the link's child in the asset's node array. |
| constraint | Asset3dArticulationConstraint | Details about the constraint between the parent and child nodes. |
Asset3dArticulation
Internal structure of Asset3d describing a physics reduced coordinate articulation.
type Asset3dArticulation = { rootNodeIndex: number, links: Asset3dArticulationLink[] }
Properties
| Field | Type | Description |
|---|---|---|
| rootNodeIndex | number | Index of the articulation root in the asset's node array. |
| links | Asset3dArticulationLink[] | Links between nodes in the articulation. |
Asset3dCollider
Internal structure of Asset3d describing a geometry with mass properties.
type Asset3dCollider = { geometry: PhysicsGeometry, mass: number, centreOfMass: vector }
Properties
| Field | Type | Description |
|---|---|---|
| geometry | PhysicsGeometry | No description |
| mass | number | No description |
| centreOfMass | vector | No description |
Asset3d
A 3D model or prefab containing materials, meshes, physics objects and more. Roughly follows the glTF structure.
type Asset3d = { nodes: Asset3dNode[], skeletons: Asset3dSkeleton[], articulations: Asset3dArticulation[], colliders: Asset3dCollider[], meshes: Mesh[], materials: Material[] }
Properties
| Field | Type | Description |
|---|---|---|
| nodes | Asset3dNode[] | Primary structure of the asset, defining a hierarchy of nodes (which can be considered 1:1 with entities). |
| skeletons | Asset3dSkeleton[] | Visual skeletons referenced by skinned mesh nodes. |
| articulations | Asset3dArticulation[] | Physics articulations joining nodes together into a single reduced coordinate system for simulation stability. |
| colliders | Asset3dCollider[] | Physics colliders comprised of geometry and mass properties. |
| meshes | Mesh[] | Visual meshes referenced by nodes. |
| materials | Material[] | Visual materials referenced by meshes. |
MapEntity
Internal structure of Map representing properties of an entity to spawn.
type MapEntity = { position: vector, orientation: Quaternion, asset: Asset3d }
Properties
| Field | Type | Description |
|---|---|---|
| position | vector | Position of the entity in world space. |
| orientation | Quaternion | Orientation of the entity in world space. |
| asset | Asset3d | Optional asset to spawn at the entity's position and orientation. |
Map
A map containing many entities.
type Map = { entities: MapEntity[] }
Properties
| Field | Type | Description |
|---|---|---|
| entities | MapEntity[] | List of entities in the map. |