Modules

Docs / API / Modules / math

Math

Platform

@s2script/sdk/math

Vector and QAngle value types plus helpers like forwardVector.

3 exports

Import

import { Vector } from "@s2script/sdk/math";

Author-time types ship in the npm package; the engine injects the runtime at plugin load. Add @s2script/sdk to your plugin's dependencies.

API reference

Generated from the shipped type definitions.

class
Vector

A 3-component vector value (a copied snapshot; never a live pointer).

import { Vector } from "@s2script/sdk/math";
const start = new Vector(0, 0, 100);
console.log(start.length());
x: number
The X component.
y: number
The Y component.
z: number
The Z component.
length(): number
Euclidean magnitude — e.g. speed from a velocity vector.
toString(): string
Format as "Vector(x, y, z)" (for logging).
class
QAngle

A Source 2 Euler angle value (x=pitch, y=yaw, z=roll), a copied snapshot.

x: number
Pitch, in degrees.
y: number
Yaw, in degrees.
z: number
Roll, in degrees.
toString(): string
Format as "QAngle(x, y, z)" (for logging).
fn
forwardVector(a: QAngle): Vector

The unit forward-direction vector for a Euler angle (pitch=a.x, yaw=a.y; ignores roll).

Back to modules All packages

s2script — Source 2 plugin framework

GitHub