Script stuff
This commit is contained in:
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
/**
|
||||
* Built-in primitive meshes, usable with Renderable.setMesh(). Opaque
|
||||
* engine-owned handles -- do not inspect or mutate.
|
||||
*/
|
||||
declare const MESH_CUBE: object;
|
||||
declare const MESH_PLANE: object;
|
||||
declare const MESH_SPHERE: object;
|
||||
declare const MESH_CAPSULE: object;
|
||||
declare const MESH_TRIPRISM: object;
|
||||
declare const MESH_QUAD: object;
|
||||
+7
-5
@@ -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. */
|
||||
|
||||
Vendored
+54
@@ -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;
|
||||
}
|
||||
Vendored
+34
@@ -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
@@ -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;
|
||||
}
|
||||
Vendored
+6
@@ -3,6 +3,12 @@
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
/// <reference path="require.d.ts" />
|
||||
/// <reference path="entity/entity.d.ts" />
|
||||
/// <reference path="entity/component/component.d.ts" />
|
||||
/// <reference path="entity/component/position.d.ts" />
|
||||
/// <reference path="entity/component/physics.d.ts" />
|
||||
/// <reference path="entity/component/renderable.d.ts" />
|
||||
/// <reference path="scene/scene.d.ts" />
|
||||
/// <reference path="display/mesh.d.ts" />
|
||||
/// <reference path="time/time.d.ts" />
|
||||
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
/**
|
||||
* Loads and executes another script file (relative to the asset root,
|
||||
* or to the requiring file's own directory if path starts with "./" or
|
||||
* "../"), returning its `module.exports`. Each resolved path is only
|
||||
* executed once - subsequent require() calls for the same file return
|
||||
* the cached exports.
|
||||
*/
|
||||
declare function require(path: string): any;
|
||||
|
||||
/**
|
||||
* Only defined inside a file loaded via require() - not present in a
|
||||
* top-level script executed directly. Set `module.exports` to whatever
|
||||
* value require() of this file should return.
|
||||
*/
|
||||
declare const module: { exports: any };
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// Copyright (c) 2026 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
/**
|
||||
* Live view over the engine's fixed-timestep clock (see time/time.h).
|
||||
* `delta`/`time` always reflect the most recent timeUpdate() call.
|
||||
*/
|
||||
declare const Time: {
|
||||
/** Fixed simulation timestep, in seconds (always DUSK_TIME_STEP). */
|
||||
readonly delta: number;
|
||||
/** Total elapsed fixed-simulation time, in seconds. */
|
||||
readonly time: number;
|
||||
};
|
||||
Reference in New Issue
Block a user