Script stuff

This commit is contained in:
2026-07-31 09:40:53 -05:00
parent d49194fc4d
commit 07f98c119a
45 changed files with 2094 additions and 201 deletions
+7 -5
View File
@@ -4,11 +4,13 @@
// https://opensource.org/licenses/MIT
/**
* A component attached to an Entity. Generic across every component
* type for now -- there are no typed per-type properties yet (e.g. no
* `.position` on a POSITION component), just the operations every
* component supports regardless of type. Only ever obtained via
* Entity.add()/Entity.getComponent(), never constructed directly.
* A component attached to an Entity: the operations every component
* supports regardless of type. Entity.add()/Entity.getComponent() return
* a typed subclass for component types that have one -- see position.d.ts
* (POSITION), physics.d.ts (PHYSICS), and renderable.d.ts (RENDERABLE).
* Every other component type (CAMERA, TRIGGER, ANIMATION, PLAYER,
* INTERACTABLE) still only returns this generic Component. Never
* constructed directly.
*/
declare class Component {
/** The componenttype_t this component was added as, e.g. POSITION. */
+54
View File
@@ -0,0 +1,54 @@
// Copyright (c) 2026 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
/// <reference path="component.d.ts" />
/** Physics body type constants, usable with Physics.setBodyType(). */
declare const PHYSICS_BODY_STATIC: number;
declare const PHYSICS_BODY_DYNAMIC: number;
declare const PHYSICS_BODY_KINEMATIC: number;
/**
* Physics shape type constants, usable with Physics.setShape(). Argument
* shape per type:
* - PHYSICS_SHAPE_CUBE: (type, halfExtentX, halfExtentY, halfExtentZ)
* - PHYSICS_SHAPE_SPHERE: (type, radius)
* - PHYSICS_SHAPE_CAPSULE: (type, radius, halfHeight)
* - PHYSICS_SHAPE_PLANE: (type, normalX, normalY, normalZ, distance)
*/
declare const PHYSICS_SHAPE_CUBE: number;
declare const PHYSICS_SHAPE_SPHERE: number;
declare const PHYSICS_SHAPE_CAPSULE: number;
declare const PHYSICS_SHAPE_PLANE: number;
/**
* Typed wrapper for a PHYSICS component. Returned by Entity.add(PHYSICS)
* / Entity.getComponent(PHYSICS) instead of the generic Component.
*/
declare class Physics extends Component {
/** Sets the body type (see PHYSICS_BODY_* constants). */
setBodyType(type: number): void;
/** Gets the body type. */
getBodyType(): number;
/**
* Sets the collision shape. See PHYSICS_SHAPE_* constants for the
* expected trailing arguments per shape type.
*/
setShape(type: number, ...args: number[]): void;
/** Sets the body's velocity (not an impulse -- affected by mass/drag). */
setVelocity(x: number, y: number, z: number): void;
/** Gets the body's velocity. */
getVelocity(): { x: number; y: number; z: number };
/** Applies an immediate velocity change, unaffected by mass/drag. */
applyImpulse(x: number, y: number, z: number): void;
/** True if the body rested on a surface during the last physics step. */
isOnGround(): boolean;
}
+34
View File
@@ -0,0 +1,34 @@
// Copyright (c) 2026 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
/// <reference path="component.d.ts" />
/**
* Typed wrapper for a POSITION component. Returned by Entity.add(POSITION)
* / Entity.getComponent(POSITION) instead of the generic Component.
*/
declare class Position extends Component {
/** Sets the local position (not world position -- see entityposition.h). */
setLocalPosition(x: number, y: number, z: number): void;
/** Gets the cached local position. */
getLocalPosition(): { x: number; y: number; z: number };
/** Sets the local scale. */
setLocalScale(x: number, y: number, z: number): void;
/** Gets the cached local scale. */
getLocalScale(): { x: number; y: number; z: number };
/**
* Positions and orients the entity at (ex, ey, ez), facing
* (tx, ty, tz), with (ux, uy, uz) as up.
*/
lookAt(
ex: number, ey: number, ez: number,
tx: number, ty: number, tz: number,
ux: number, uy: number, uz: number
): void;
}
+26
View File
@@ -0,0 +1,26 @@
// Copyright (c) 2026 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
/// <reference path="component.d.ts" />
/**
* Typed wrapper for a RENDERABLE component. Returned by
* Entity.add(RENDERABLE) / Entity.getComponent(RENDERABLE) instead of
* the generic Component. Only meaningful for the default shader-material
* renderable type.
*/
declare class Renderable extends Component {
/** Sets the unlit material color (each channel 0-255). */
setColor(r: number, g: number, b: number, a: number): void;
/**
* Sets one of the material's mesh slots. mesh must be one of the
* built-in MESH_* constants (see mesh.d.ts).
*/
setMesh(slot: number, mesh: object): void;
/** Sets the render priority. 0 = auto (derived from type/flags). */
setPriority(priority: number): void;
}