@nayan-ui/engine 0.0.0-stage → 1.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NayanEngine.podspec +28 -0
- package/README.md +308 -2
- package/lib/module/assets/AssetBytesCache.js +76 -0
- package/lib/module/assets/AssetCache.js +19 -0
- package/lib/module/assets/AssetLoader.js +52 -0
- package/lib/module/assets/CacheGeneration.js +7 -0
- package/lib/module/assets/IndexedDbCache.web.js +149 -0
- package/lib/module/assets/ProceduralCache.js +249 -0
- package/lib/module/assets/font.js +139 -0
- package/lib/module/assets/loft.js +142 -0
- package/lib/module/assets/model.js +96 -0
- package/lib/module/assets/modelling.js +254 -0
- package/lib/module/assets/shape.js +926 -0
- package/lib/module/assets/source.js +58 -0
- package/lib/module/assets/source.web.js +22 -0
- package/lib/module/assets/storage.js +4 -0
- package/lib/module/assets/storage.shared.js +38 -0
- package/lib/module/assets/storage.web.js +38 -0
- package/lib/module/assets/surface.js +47 -0
- package/lib/module/assets/texture.js +69 -0
- package/lib/module/drawing/DrawingCanvas.js +38 -0
- package/lib/module/drawing/DrawingCanvas.web.js +206 -0
- package/lib/module/drawing/DrawingDocument.js +256 -0
- package/lib/module/drawing/types.js +4 -0
- package/lib/module/globals.d.ts +12 -0
- package/lib/module/index.js +39 -0
- package/lib/module/input/Joystick.js +84 -0
- package/lib/module/input/Joystick.web.js +93 -0
- package/lib/module/input/keyboard.js +250 -0
- package/lib/module/media/audio-worklet.js +34 -0
- package/lib/module/media/audio.js +97 -0
- package/lib/module/media/haptics.js +82 -0
- package/lib/module/media/output.web.js +66 -0
- package/lib/module/native/BrowserEngine.js +568 -0
- package/lib/module/native/EngineBridge.js +4 -0
- package/lib/module/native/NativeNayanEngine.js +7 -0
- package/lib/module/native/NativeNayanEngine.web.js +62 -0
- package/lib/module/native/prepare.js +7 -0
- package/lib/module/native/prepare.web.js +17 -0
- package/lib/module/native/spec/NativeNayanEngine.js +17 -0
- package/lib/module/package.json +1 -0
- package/lib/module/render/GameView.js +317 -0
- package/lib/module/render/camera.js +34 -0
- package/lib/module/render/host.js +39 -0
- package/lib/module/render/host.web.js +104 -0
- package/lib/module/render/light.js +24 -0
- package/lib/module/render/meshes.js +159 -0
- package/lib/module/render/quality.js +119 -0
- package/lib/module/render/responder.js +4 -0
- package/lib/module/render/responder.web.js +97 -0
- package/lib/module/render/touch.js +185 -0
- package/lib/module/render/useWorld.js +72 -0
- package/lib/module/types.js +30 -0
- package/lib/module/world/Scoreboard.js +161 -0
- package/lib/module/world/TransformBatch.js +128 -0
- package/lib/module/world/World.js +704 -0
- package/lib/module/world/color.js +80 -0
- package/lib/module/world/desc.js +187 -0
- package/lib/module/world/effects.js +463 -0
- package/lib/module/world/quat.js +86 -0
- package/lib/module/world/types.js +4 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/assets/AssetBytesCache.d.ts +7 -0
- package/lib/typescript/src/assets/AssetCache.d.ts +9 -0
- package/lib/typescript/src/assets/AssetLoader.d.ts +11 -0
- package/lib/typescript/src/assets/CacheGeneration.d.ts +3 -0
- package/lib/typescript/src/assets/IndexedDbCache.web.d.ts +20 -0
- package/lib/typescript/src/assets/ProceduralCache.d.ts +45 -0
- package/lib/typescript/src/assets/font.d.ts +53 -0
- package/lib/typescript/src/assets/loft.d.ts +31 -0
- package/lib/typescript/src/assets/model.d.ts +58 -0
- package/lib/typescript/src/assets/modelling.d.ts +157 -0
- package/lib/typescript/src/assets/shape.d.ts +203 -0
- package/lib/typescript/src/assets/source.d.ts +10 -0
- package/lib/typescript/src/assets/source.web.d.ts +8 -0
- package/lib/typescript/src/assets/storage.d.ts +2 -0
- package/lib/typescript/src/assets/storage.shared.d.ts +7 -0
- package/lib/typescript/src/assets/storage.web.d.ts +7 -0
- package/lib/typescript/src/assets/surface.d.ts +17 -0
- package/lib/typescript/src/assets/texture.d.ts +30 -0
- package/lib/typescript/src/drawing/DrawingCanvas.d.ts +5 -0
- package/lib/typescript/src/drawing/DrawingCanvas.web.d.ts +4 -0
- package/lib/typescript/src/drawing/DrawingDocument.d.ts +210 -0
- package/lib/typescript/src/drawing/types.d.ts +12 -0
- package/lib/typescript/src/index.d.ts +45 -0
- package/lib/typescript/src/input/Joystick.d.ts +20 -0
- package/lib/typescript/src/input/Joystick.web.d.ts +13 -0
- package/lib/typescript/src/input/keyboard.d.ts +17 -0
- package/lib/typescript/src/media/audio.d.ts +46 -0
- package/lib/typescript/src/media/haptics.d.ts +22 -0
- package/lib/typescript/src/media/output.web.d.ts +4 -0
- package/lib/typescript/src/native/BrowserEngine.d.ts +8 -0
- package/lib/typescript/src/native/EngineBridge.d.ts +26 -0
- package/lib/typescript/src/native/NativeNayanEngine.d.ts +5 -0
- package/lib/typescript/src/native/NativeNayanEngine.web.d.ts +10 -0
- package/lib/typescript/src/native/prepare.d.ts +3 -0
- package/lib/typescript/src/native/prepare.web.d.ts +2 -0
- package/lib/typescript/src/native/spec/NativeNayanEngine.d.ts +211 -0
- package/lib/typescript/src/render/GameView.d.ts +107 -0
- package/lib/typescript/src/render/camera.d.ts +6 -0
- package/lib/typescript/src/render/host.d.ts +29 -0
- package/lib/typescript/src/render/host.web.d.ts +16 -0
- package/lib/typescript/src/render/light.d.ts +12 -0
- package/lib/typescript/src/render/meshes.d.ts +45 -0
- package/lib/typescript/src/render/quality.d.ts +48 -0
- package/lib/typescript/src/render/responder.d.ts +2 -0
- package/lib/typescript/src/render/responder.web.d.ts +40 -0
- package/lib/typescript/src/render/touch.d.ts +26 -0
- package/lib/typescript/src/render/useWorld.d.ts +20 -0
- package/lib/typescript/src/types.d.ts +81 -0
- package/lib/typescript/src/world/Scoreboard.d.ts +75 -0
- package/lib/typescript/src/world/TransformBatch.d.ts +39 -0
- package/lib/typescript/src/world/World.d.ts +207 -0
- package/lib/typescript/src/world/color.d.ts +18 -0
- package/lib/typescript/src/world/desc.d.ts +17 -0
- package/lib/typescript/src/world/effects.d.ts +157 -0
- package/lib/typescript/src/world/quat.d.ts +31 -0
- package/lib/typescript/src/world/types.d.ts +238 -0
- package/lib/web/audio-worklet.js +29 -0
- package/lib/web/engine_core_bg.wasm +0 -0
- package/lib/web/index.js +8240 -0
- package/lib/web/types/src/assets/AssetBytesCache.d.ts +6 -0
- package/lib/web/types/src/assets/AssetCache.d.ts +8 -0
- package/lib/web/types/src/assets/AssetLoader.d.ts +10 -0
- package/lib/web/types/src/assets/CacheGeneration.d.ts +2 -0
- package/lib/web/types/src/assets/IndexedDbCache.d.ts +19 -0
- package/lib/web/types/src/assets/ProceduralCache.d.ts +44 -0
- package/lib/web/types/src/assets/font.d.ts +52 -0
- package/lib/web/types/src/assets/loft.d.ts +30 -0
- package/lib/web/types/src/assets/model.d.ts +57 -0
- package/lib/web/types/src/assets/modelling.d.ts +156 -0
- package/lib/web/types/src/assets/shape.d.ts +202 -0
- package/lib/web/types/src/assets/source.d.ts +7 -0
- package/lib/web/types/src/assets/storage.d.ts +6 -0
- package/lib/web/types/src/assets/storage.shared.d.ts +6 -0
- package/lib/web/types/src/assets/surface.d.ts +16 -0
- package/lib/web/types/src/assets/texture.d.ts +29 -0
- package/lib/web/types/src/drawing/DrawingCanvas.d.ts +3 -0
- package/lib/web/types/src/drawing/DrawingDocument.d.ts +209 -0
- package/lib/web/types/src/drawing/types.d.ts +11 -0
- package/lib/web/types/src/index.d.ts +44 -0
- package/lib/web/types/src/input/Joystick.d.ts +12 -0
- package/lib/web/types/src/input/keyboard.d.ts +16 -0
- package/lib/web/types/src/media/audio.d.ts +45 -0
- package/lib/web/types/src/media/haptics.d.ts +21 -0
- package/lib/web/types/src/media/output.d.ts +3 -0
- package/lib/web/types/src/native/BrowserEngine.d.ts +7 -0
- package/lib/web/types/src/native/EngineBridge.d.ts +25 -0
- package/lib/web/types/src/native/NativeNayanEngine.d.ts +9 -0
- package/lib/web/types/src/native/prepare.d.ts +1 -0
- package/lib/web/types/src/native/spec/NativeNayanEngine.d.ts +210 -0
- package/lib/web/types/src/render/GameView.d.ts +106 -0
- package/lib/web/types/src/render/camera.d.ts +5 -0
- package/lib/web/types/src/render/host.d.ts +15 -0
- package/lib/web/types/src/render/light.d.ts +11 -0
- package/lib/web/types/src/render/meshes.d.ts +44 -0
- package/lib/web/types/src/render/quality.d.ts +47 -0
- package/lib/web/types/src/render/responder.d.ts +39 -0
- package/lib/web/types/src/render/touch.d.ts +25 -0
- package/lib/web/types/src/render/useWorld.d.ts +19 -0
- package/lib/web/types/src/types.d.ts +80 -0
- package/lib/web/types/src/world/Scoreboard.d.ts +74 -0
- package/lib/web/types/src/world/TransformBatch.d.ts +38 -0
- package/lib/web/types/src/world/World.d.ts +206 -0
- package/lib/web/types/src/world/color.d.ts +17 -0
- package/lib/web/types/src/world/desc.d.ts +16 -0
- package/lib/web/types/src/world/effects.d.ts +156 -0
- package/lib/web/types/src/world/quat.d.ts +30 -0
- package/lib/web/types/src/world/types.d.ts +237 -0
- package/native/android/CMakeLists.txt +34 -0
- package/native/android/NayanEngineSpec.h +15 -0
- package/native/android/build.gradle +26 -0
- package/native/android/codegen/CMakeLists.txt +3 -0
- package/native/android/proguard-rules.pro +2 -0
- package/native/android/src/main/java/com/nayanui/engine/EngineSurfaceView.java +295 -0
- package/native/android/src/main/java/com/nayanui/engine/EngineSurfaceViewManager.java +45 -0
- package/native/android/src/main/java/com/nayanui/engine/NayanEnginePackage.java +24 -0
- package/native/core/build/EngineCore.xcframework/Info.plist +43 -0
- package/native/core/build/EngineCore.xcframework/ios-arm64/libengine_core.a +0 -0
- package/native/core/build/EngineCore.xcframework/ios-arm64-simulator/libengine_core.a +0 -0
- package/native/core/build/android/arm64-v8a/libengine_core.a +0 -0
- package/native/core/build/android/armeabi-v7a/libengine_core.a +0 -0
- package/native/core/build/android/x86/libengine_core.a +0 -0
- package/native/core/build/android/x86_64/libengine_core.a +0 -0
- package/native/core/include/drawing-licenses.txt +58 -0
- package/native/core/include/engine_core.h +331 -0
- package/native/cpp/NayanEngineModule.cpp +998 -0
- package/native/cpp/NayanEngineModule.h +174 -0
- package/native/cpp/generated/NayanEngineSpecJSI.cpp +2 -0
- package/native/cpp/generated/NayanEngineSpecJSI.h +1026 -0
- package/native/ios/NayanEngineProvider.h +5 -0
- package/native/ios/NayanEngineProvider.mm +21 -0
- package/native/ios/NayanEngineSurface.mm +252 -0
- package/native/scripts/check-package.mjs +39 -0
- package/package.json +162 -4
- package/react-native.config.js +18 -0
- package/src/native/spec/NativeNayanEngine.ts +265 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export type ScoreboardHandlers = {
|
|
2
|
+
/** The score changed (points, time-based points, reset). */
|
|
3
|
+
onScore?: (score: number) => void;
|
|
4
|
+
onLives?: (lives: number) => void;
|
|
5
|
+
/** The whole seconds shown changed: time left for a countdown, elapsed otherwise. */
|
|
6
|
+
onSecond?: (seconds: number) => void;
|
|
7
|
+
/** A countdown reached 0 (the clock stops). */
|
|
8
|
+
onTimeUp?: () => void;
|
|
9
|
+
/** Lives went from above 0 to 0. */
|
|
10
|
+
onLivesOut?: () => void;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Score, lives and the game clock, kept and advanced in Rust by `world.update`: countdowns, elapsed
|
|
14
|
+
* time and time-based points (survival, distance) cost no JS per frame. Handlers run from `update`
|
|
15
|
+
* only when something they show changed. Set `handlers` for the game's own rules, and `listen` for
|
|
16
|
+
* anything else that follows along (a UI showing the score), so neither replaces the other.
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* world.scoreboard.handlers = { onTimeUp: () => end(true) };
|
|
20
|
+
* const stop = world.scoreboard.listen({ onScore: setScore, onSecond: setTime });
|
|
21
|
+
* world.scoreboard.reset(3);
|
|
22
|
+
* world.scoreboard.startCountdown(60);
|
|
23
|
+
* world.scoreboard.add(10);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class Scoreboard {
|
|
27
|
+
private readonly world;
|
|
28
|
+
/** The game's own handlers. `listen` adds more without replacing these. */
|
|
29
|
+
handlers: ScoreboardHandlers;
|
|
30
|
+
private readonly listeners;
|
|
31
|
+
private readonly state;
|
|
32
|
+
/** @internal */
|
|
33
|
+
constructor(world: number);
|
|
34
|
+
private op;
|
|
35
|
+
get score(): number;
|
|
36
|
+
get best(): number;
|
|
37
|
+
get lives(): number;
|
|
38
|
+
/** Seconds left (countdown) or elapsed, fractional. */
|
|
39
|
+
get seconds(): number;
|
|
40
|
+
/** Whole seconds as shown: rounded up while counting down, down while counting up. */
|
|
41
|
+
get shownSeconds(): number;
|
|
42
|
+
get running(): boolean;
|
|
43
|
+
/** Adds points (negative to take away). Returns the score. */
|
|
44
|
+
add(points: number): number;
|
|
45
|
+
set(score: number): number;
|
|
46
|
+
addLives(n: number): number;
|
|
47
|
+
setLives(n: number): void;
|
|
48
|
+
/** Counts `seconds` down to 0 (then `onTimeUp`), earning `pointsPerSecond` meanwhile. */
|
|
49
|
+
startCountdown(seconds: number, pointsPerSecond?: number): void;
|
|
50
|
+
/** Counts up from 0, earning `pointsPerSecond` (survival and distance scores). */
|
|
51
|
+
startClock(pointsPerSecond?: number): void;
|
|
52
|
+
stop(): void;
|
|
53
|
+
resume(): void;
|
|
54
|
+
/** Time bonus (or penalty) on the clock. */
|
|
55
|
+
addTime(seconds: number): void;
|
|
56
|
+
/**
|
|
57
|
+
* Adds `pointsPerSecond` for each whole second saved: the seconds left on a countdown, or
|
|
58
|
+
* `expectedSeconds` minus the seconds elapsed on a clock counting up. Returns the score.
|
|
59
|
+
*/
|
|
60
|
+
awardTimeBonus(pointsPerSecond: number, expectedSeconds?: number): number;
|
|
61
|
+
/**
|
|
62
|
+
* A new run: score 0, `lives`, clock stopped at 0. With `countdownSeconds`, the stopped clock shows
|
|
63
|
+
* that countdown in full (a ready screen); `resume()` starts it.
|
|
64
|
+
*/
|
|
65
|
+
reset(lives?: number, countdownSeconds?: number): void;
|
|
66
|
+
/**
|
|
67
|
+
* Adds handlers alongside `handlers` (and other listeners); they run after them, in order of
|
|
68
|
+
* listening. Returns a function that removes them.
|
|
69
|
+
*/
|
|
70
|
+
listen(handlers: ScoreboardHandlers): () => void;
|
|
71
|
+
/** @internal Runs handlers for what changed since the last call. */
|
|
72
|
+
dispatch(): void;
|
|
73
|
+
private run;
|
|
74
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Entity, EntityOptions } from './types';
|
|
2
|
+
export type TransformOptions = Pick<EntityOptions, 'position' | 'rotation' | 'scale' | 'color'>;
|
|
3
|
+
export declare const TRANSFORM_STRIDE = 16;
|
|
4
|
+
/**
|
|
5
|
+
* Explicit draw-only updates, applied in one native call by `flush()`. `world.update` flushes
|
|
6
|
+
* `world.transforms` before stepping; flush yourself before reading positions or animating. Records and scratch storage are reused; values are
|
|
7
|
+
* copied when queued, never retained by reference. The scalar methods (`position`, `rotation`,
|
|
8
|
+
* `scale`, `color`, `transform`) allocate nothing; consecutive calls for the same entity share one
|
|
9
|
+
* record.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const batch = world.transforms;
|
|
13
|
+
* for (const p of pieces) batch.transform(p.entity, p.x, 0, p.z, 0, p.qy, 0, p.qw);
|
|
14
|
+
* batch.flush();
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare class TransformBatch {
|
|
18
|
+
private readonly commit;
|
|
19
|
+
private data;
|
|
20
|
+
private count;
|
|
21
|
+
constructor(commit: (data: Float64Array, count: number) => number);
|
|
22
|
+
private record;
|
|
23
|
+
position(entity: Entity, x: number, y: number, z: number): void;
|
|
24
|
+
/** Rotation quaternion [x, y, z, w]. */
|
|
25
|
+
rotation(entity: Entity, x: number, y: number, z: number, w: number): void;
|
|
26
|
+
/** Uniform scale, or per axis. */
|
|
27
|
+
scale(entity: Entity, x: number, y?: number, z?: number): void;
|
|
28
|
+
/** RGBA color; alpha defaults to 1. */
|
|
29
|
+
color(entity: Entity, r: number, g: number, b: number, a?: number): void;
|
|
30
|
+
/** Position and rotation together (the common per-frame update for a moving piece). */
|
|
31
|
+
transform(entity: Entity, x: number, y: number, z: number, qx: number, qy: number, qz: number, qw: number): void;
|
|
32
|
+
/** Queued records (merged per entity). */
|
|
33
|
+
get size(): number;
|
|
34
|
+
set(entity: Entity, options: TransformOptions): void;
|
|
35
|
+
private writeColor;
|
|
36
|
+
flush(): number;
|
|
37
|
+
clear(): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { type RenderSource, type Vec3 } from '../types';
|
|
2
|
+
import { Scoreboard } from './Scoreboard';
|
|
3
|
+
import { TransformBatch } from './TransformBatch';
|
|
4
|
+
import type { AnimateOptions, AnimateTarget, Bounds, BurstOptions, ClipOptions, CollisionInfo, Entity, EntityOptions, Keyframe, PickHit, RaycastHit, ScreenPlane } from './types';
|
|
5
|
+
/** True when the engine's native code is linked into this build (it is not in Expo Go). */
|
|
6
|
+
export declare const isEngineAvailable: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* A game world, simulated by the Rust core: entities, motion, Rapier physics, collisions,
|
|
9
|
+
* animations and raycasts at a fixed 60 Hz, with rendering smoothed between steps. Pass it to `<GameView>`.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const world = new World(500);
|
|
13
|
+
* const ball = world.spawn({ mesh: "sphere", position: [0, 5, 0], physics: "dynamic" });
|
|
14
|
+
* world.set(ball, { color: [1, 0, 0] });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare class World implements RenderSource {
|
|
18
|
+
readonly capacity: number;
|
|
19
|
+
readonly matrices: Float32Array;
|
|
20
|
+
readonly colors: Float32Array;
|
|
21
|
+
readonly regions: Float32Array;
|
|
22
|
+
readonly ranges: Uint32Array;
|
|
23
|
+
private readonly events;
|
|
24
|
+
private readonly eventFloats;
|
|
25
|
+
private readonly finished;
|
|
26
|
+
private readonly scratch;
|
|
27
|
+
private readonly desc;
|
|
28
|
+
private anim;
|
|
29
|
+
private readonly burstDesc;
|
|
30
|
+
private readonly info;
|
|
31
|
+
/** Promise resolvers of running animations, by animation id. */
|
|
32
|
+
private readonly pending;
|
|
33
|
+
/** Callbacks of pending `after` timers, by timer id (the core counts the time). */
|
|
34
|
+
private readonly timers;
|
|
35
|
+
/** Timers for a native core built before `after` existed: [fire time, callback], on `clock`. */
|
|
36
|
+
private fallbackTimers;
|
|
37
|
+
private fallbackTimerId;
|
|
38
|
+
private transformsValue;
|
|
39
|
+
private clock;
|
|
40
|
+
private scoreboardValue;
|
|
41
|
+
private readonly texts;
|
|
42
|
+
private readonly id;
|
|
43
|
+
private disposed;
|
|
44
|
+
private gravityValue;
|
|
45
|
+
private boundsValue;
|
|
46
|
+
private listenerValue;
|
|
47
|
+
private updates;
|
|
48
|
+
constructor(capacity: number);
|
|
49
|
+
private get native();
|
|
50
|
+
/** True once `dispose()` has run. Cleanup calls (despawn, set, has, queries, stopping animations
|
|
51
|
+
* and timers) are safe no-ops afterwards, so late animation promises and timers need no guard.
|
|
52
|
+
*/
|
|
53
|
+
get isDisposed(): boolean;
|
|
54
|
+
/** Live entities (text letters count too). */
|
|
55
|
+
get count(): number;
|
|
56
|
+
/** Adds an entity (one native call; text adds one per letter). Throws if the world is full or an option is invalid. */
|
|
57
|
+
spawn(options?: EntityOptions): Entity;
|
|
58
|
+
/**
|
|
59
|
+
* Changes an entity (one native call). Only the options you pass change; `null` removes.
|
|
60
|
+
* Returns false if the entity is gone, the world is disposed, or an option was rejected (the others still apply).
|
|
61
|
+
*/
|
|
62
|
+
set(e: Entity, options: EntityOptions): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* This world's shared draw-only transform batch (created on first use). Queue per-frame moves with
|
|
65
|
+
* its allocation-free methods; the next `update()` applies them first (or `flush()` them yourself
|
|
66
|
+
* before reading positions or animating).
|
|
67
|
+
*/
|
|
68
|
+
get transforms(): TransformBatch;
|
|
69
|
+
/** Reusable draw-only transforms; use set() for text entities and flush before animations/queries. */
|
|
70
|
+
createTransformBatch(): TransformBatch;
|
|
71
|
+
/** Removes an entity and anything attached to it. Returns false if it was already gone. */
|
|
72
|
+
despawn(e: Entity): boolean;
|
|
73
|
+
/** A one-off push: jump, explosion, knockback (dynamic bodies only). */
|
|
74
|
+
impulse(e: Entity, impulse: Vec3): void;
|
|
75
|
+
private resolveMesh;
|
|
76
|
+
private encodeColor;
|
|
77
|
+
/** Updates a text entity's letters in place, growing or shrinking only when needed. */
|
|
78
|
+
private buildText;
|
|
79
|
+
/** Native world backing this render source; bone palettes stay in Rust. */
|
|
80
|
+
get nativeWorld(): number;
|
|
81
|
+
/** Play a named GLB clip. Re-selecting it changes speed without restarting; `time` explicitly seeks.
|
|
82
|
+
* `fade` crossfades from the current pose (seconds). A speed of zero holds a pose for a ready screen.
|
|
83
|
+
*/
|
|
84
|
+
playClip(entity: Entity, clip: string, options?: ClipOptions): boolean;
|
|
85
|
+
/** Hold the current GLB pose, or return to its bind pose with `reset`. */
|
|
86
|
+
stopClip(entity: Entity, reset?: boolean): boolean;
|
|
87
|
+
/** Sample selected animated vertices in model space for foot contact and attachments.
|
|
88
|
+
* Reuse both arrays. `after` previews the interpolated pose following the next update.
|
|
89
|
+
*/
|
|
90
|
+
sampleSkinnedVertices(entity: Entity, vertices: Uint32Array, output: Float32Array, after?: number): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Animates in Rust, with no per-frame JS: from where things are to `to`, or through keyframes.
|
|
93
|
+
* Each property (position, rotation, scale, color, shake) runs on its own, so a piece can move
|
|
94
|
+
* while it pulses; animating a property again replaces only that property. Pass several entities
|
|
95
|
+
* to animate them together (with `stagger` for waves). Resolves when every part has finished, been
|
|
96
|
+
* replaced or stopped, or its entity was despawned.
|
|
97
|
+
*
|
|
98
|
+
* ```ts
|
|
99
|
+
* await world.animate(piece, { position: [2, 0, 3] }, { duration: 0.25, easing: "back" });
|
|
100
|
+
* world.animate(coin, { scale: 1.2 }, { repeat: "forever", yoyo: true }); // pulse
|
|
101
|
+
* world.animate(piece, [{ moveBy: [1, 1.5, 0] }, { moveBy: [2, 0, 0] }], { path: "smooth" }); // hop
|
|
102
|
+
* world.animate(card, { turn: [0, Math.PI, 0] }); // flip
|
|
103
|
+
* world.animate(tiles, { scale: 1 }, { stagger: 0.03, easing: "back" }); // reveal a board
|
|
104
|
+
* world.animate(cursor, { position: [x, 0, z] }, { spring: true }); // follows the finger smoothly
|
|
105
|
+
* world.animate(wrongTile, { shake: 0.15 }, { duration: 0.4 });
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
animate(targets: Entity | readonly Entity[], to: AnimateTarget | readonly Keyframe[], options?: AnimateOptions): Promise<void>;
|
|
109
|
+
private encodeKeyframe;
|
|
110
|
+
/** Stops every animation on the entity where it is (their promises resolve). */
|
|
111
|
+
stopAnimation(e: Entity): void;
|
|
112
|
+
/**
|
|
113
|
+
* Particles: many small, short-lived pieces flying out of a point (explosions, sparks, dust,
|
|
114
|
+
* confetti). One native call; they fall, spin, shrink away and clean themselves up. `endSize` and
|
|
115
|
+
* `endColor` grow / shrink and recolor them over their life (fire cooling, smoke thinning out).
|
|
116
|
+
* Returns how many were spawned (fewer if the world is nearly full).
|
|
117
|
+
*/
|
|
118
|
+
burst(options: BurstOptions): number;
|
|
119
|
+
/**
|
|
120
|
+
* Runs `fn` after `seconds` of `update` time (game time: it pauses when updates stop). The clock is
|
|
121
|
+
* kept in Rust, so there's no JS timer list to scan every frame. Due callbacks run inside `update`,
|
|
122
|
+
* earliest first. Returns the timer's id for `cancelTimer`; `cancelTimers()` drops every pending one.
|
|
123
|
+
* After `dispose()` it does nothing and returns 0.
|
|
124
|
+
*
|
|
125
|
+
* ```ts
|
|
126
|
+
* world.after(0.3, () => checkMatches());
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
after(seconds: number, fn: () => void): number;
|
|
130
|
+
/** Drops one pending `after` timer so its callback never runs. Returns false if it already ran or was dropped. */
|
|
131
|
+
cancelTimer(id: number): boolean;
|
|
132
|
+
/** Drops every pending `after` timer: their callbacks never run (a new round, a reset). */
|
|
133
|
+
cancelTimers(): void;
|
|
134
|
+
/** Score, lives and the game clock, kept in Rust (created on first use). */
|
|
135
|
+
get scoreboard(): Scoreboard;
|
|
136
|
+
/** How many times `update` has run. GameView reads it to step the world only when `onUpdate` didn't. */
|
|
137
|
+
get updateCount(): number;
|
|
138
|
+
/** Timers waiting to fire. */
|
|
139
|
+
get timerCount(): number;
|
|
140
|
+
/** Resolves the promises of animations the core reports as ended, then runs due timers. */
|
|
141
|
+
private resolveFinished;
|
|
142
|
+
private runFallbackTimers;
|
|
143
|
+
/**
|
|
144
|
+
* Current simulated position (relative to the parent when attached), or null if the entity is gone.
|
|
145
|
+
* Pass `out` to avoid allocating every frame.
|
|
146
|
+
*/
|
|
147
|
+
position(e: Entity, out?: [number, number, number]): [number, number, number] | null;
|
|
148
|
+
/** Where the entity was last drawn, in world space (parents and smoothing included), or null if it's gone. */
|
|
149
|
+
worldPosition(e: Entity, out?: [number, number, number]): [number, number, number] | null;
|
|
150
|
+
/** Current velocity, or null if the entity is gone. Pass `out` to avoid allocating every frame. */
|
|
151
|
+
velocity(e: Entity, out?: [number, number, number]): [number, number, number] | null;
|
|
152
|
+
/** True while the entity exists (false after `dispose()`). */
|
|
153
|
+
has(e: Entity): boolean;
|
|
154
|
+
/**
|
|
155
|
+
* First solid (non-sensor) collider along the ray whose layer is in `mask`, as of the last update.
|
|
156
|
+
* Pass `out` to reuse a hit object every frame.
|
|
157
|
+
*/
|
|
158
|
+
raycast(origin: Vec3, direction: Vec3, maxDistance: number, mask?: number, out?: RaycastHit): RaycastHit | null;
|
|
159
|
+
/**
|
|
160
|
+
* The entity under a point of the GameView (e.g. a tap's `x, y`), tested against what was last
|
|
161
|
+
* drawn. Needs no physics. Returns null if nothing pickable is there. Pass `out` to reuse a hit object.
|
|
162
|
+
*/
|
|
163
|
+
pick(x: number, y: number, out?: PickHit): PickHit | null;
|
|
164
|
+
/**
|
|
165
|
+
* Where a world position appears in the GameView, in points from its top-left, or null if it's behind
|
|
166
|
+
* the camera (or nothing has been drawn yet). Place React Native views over 3D objects with it.
|
|
167
|
+
* Pass `out` to avoid allocating every frame.
|
|
168
|
+
*/
|
|
169
|
+
toScreen(position: Vec3, out?: [number, number]): [number, number] | null;
|
|
170
|
+
/**
|
|
171
|
+
* Where a GameView point (a finger's `x, y`) lands on a plane, or null if the plane is behind the
|
|
172
|
+
* camera or edge-on. Defaults to the ground (y = 0). Drag a piece across a board with it:
|
|
173
|
+
* `world.screenToWorld(x, y, { point: [0, pieceHeight, 0] })`. 2D games looking down -z use
|
|
174
|
+
* `{ normal: [0, 0, 1] }`. Like `toScreen`, it needs a drawn frame (null before the first one).
|
|
175
|
+
* Pass `out` to avoid allocating every frame.
|
|
176
|
+
*/
|
|
177
|
+
screenToWorld(x: number, y: number, plane?: ScreenPlane, out?: [number, number, number]): [number, number, number] | null;
|
|
178
|
+
/** Called by GameView after drawing a frame, with the camera matrix and the view size in points. */
|
|
179
|
+
setView(viewProj: Float32Array, width: number, height: number): void;
|
|
180
|
+
private copyScratch;
|
|
181
|
+
/** Default [0, -9.81, 0]. */
|
|
182
|
+
get gravity(): Vec3;
|
|
183
|
+
set gravity(g: Vec3);
|
|
184
|
+
/** Keeps moving non-physics entities inside [minX, minZ, maxX, maxZ]. Physics bodies need walls. */
|
|
185
|
+
get bounds(): Bounds | null;
|
|
186
|
+
set bounds(b: Bounds | null);
|
|
187
|
+
/** Impact sounds pan and fade relative to this entity (usually the player). */
|
|
188
|
+
get listener(): Entity | null;
|
|
189
|
+
set listener(e: Entity | null);
|
|
190
|
+
/**
|
|
191
|
+
* Advances the simulation (fixed 60 Hz steps), resolves finished animations, runs due timers and
|
|
192
|
+
* scoreboard handlers, and refreshes what GameView draws. `GameView` calls it for you each frame;
|
|
193
|
+
* call it yourself from `onUpdate` only to step with a different `dt` (it is then not stepped twice).
|
|
194
|
+
*/
|
|
195
|
+
update(dt: number): void;
|
|
196
|
+
/**
|
|
197
|
+
* Calls `fn` for each touch that started or ended during the last `update`. `info` is reused:
|
|
198
|
+
* copy what you need. Either entity may already be despawned by an earlier callback.
|
|
199
|
+
*/
|
|
200
|
+
forEachCollision(fn: (a: Entity, b: Entity, info: CollisionInfo) => void): void;
|
|
201
|
+
/**
|
|
202
|
+
* Frees the native world. Pending animation promises resolve and timers are dropped. Later cleanup
|
|
203
|
+
* calls and queries are no-ops (see `isDisposed`); `spawn` and `update` throw.
|
|
204
|
+
*/
|
|
205
|
+
dispose(): void;
|
|
206
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Color } from './types';
|
|
2
|
+
/** A color as an option takes it: `[r, g, b]` / `[r, g, b, a]` (0..1, channels above 1 glow) or a CSS string. */
|
|
3
|
+
export type ColorInput = Color | string;
|
|
4
|
+
/**
|
|
5
|
+
* Any color input as an `[r, g, b, a]` tuple (0..1), with its alpha multiplied by `alpha`. Use it when
|
|
6
|
+
* you need the numbers (to brighten, mix or fade a theme color); options take strings directly.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* toColor('#FF4757'); // [1, 0.278, 0.341, 1]
|
|
10
|
+
* toColor('#FF4757', 0.5); // half see-through
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function toColor(color: ColorInput, alpha?: number): [number, number, number, number];
|
|
14
|
+
/** A color input as a tuple, without copying tuples (the hot path of `spawn`, `set` and `animate`). */
|
|
15
|
+
export declare function resolveColor(color: ColorInput): Color;
|
|
16
|
+
/** One color input, or a list to pick from, as tuples. */
|
|
17
|
+
export declare function resolveColors(colors: ColorInput | readonly ColorInput[]): readonly Color[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { EntityOptions } from './types';
|
|
2
|
+
export declare const DESC_LEN = 64;
|
|
3
|
+
/** Writes `options` into `d`, with the mesh id already resolved. Only the fields present are flagged. */
|
|
4
|
+
export declare function encode(d: Float64Array, o: EntityOptions, mesh: number | undefined): void;
|
|
5
|
+
export declare const ANIM_HEADER = 12;
|
|
6
|
+
export declare const ANIM_KEY_LEN = 23;
|
|
7
|
+
export declare const BURST_LEN = 36;
|
|
8
|
+
export declare const EASING: {
|
|
9
|
+
readonly linear: 0;
|
|
10
|
+
readonly easeIn: 1;
|
|
11
|
+
readonly easeOut: 2;
|
|
12
|
+
readonly easeInOut: 3;
|
|
13
|
+
readonly back: 4;
|
|
14
|
+
readonly bounce: 5;
|
|
15
|
+
readonly elastic: 6;
|
|
16
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import type { Vec3 } from '../types';
|
|
2
|
+
import { type ColorInput } from './color';
|
|
3
|
+
import type { BurstOptions, Entity } from './types';
|
|
4
|
+
import type { World } from './World';
|
|
5
|
+
/** Shared options of the layered effects (confetti, sparkle, shatter, splash, sparks, explosion). */
|
|
6
|
+
export type EffectOptions = {
|
|
7
|
+
position: Vec3;
|
|
8
|
+
/** One color (CSS string or tuple), or several to pick from at random. */
|
|
9
|
+
colors: ColorInput | readonly ColorInput[];
|
|
10
|
+
/** Typical particle size. */
|
|
11
|
+
size: number;
|
|
12
|
+
/** Top speed. */
|
|
13
|
+
speed: number;
|
|
14
|
+
/** About how many particles (a few extra go to the flash and puffs). */
|
|
15
|
+
count: number;
|
|
16
|
+
/** Seconds. */
|
|
17
|
+
lifetime: number;
|
|
18
|
+
/** Vertical acceleration (negative falls). Default 0. */
|
|
19
|
+
gravity?: number;
|
|
20
|
+
/** Main direction. Default up. */
|
|
21
|
+
direction?: Vec3;
|
|
22
|
+
/** Half-angle of the cone around `direction`. Default π (every direction). */
|
|
23
|
+
spread?: number;
|
|
24
|
+
/** A brief glow at the source. Default true. */
|
|
25
|
+
flash?: boolean;
|
|
26
|
+
};
|
|
27
|
+
/** A soft cloud of puffs that swell and fade: landing dust, kicked-up sand, sawdust, steam, muzzle smoke. */
|
|
28
|
+
export type DustOptions = {
|
|
29
|
+
position: Vec3;
|
|
30
|
+
/** Start color (alpha is how thick it looks), or several to pick from. */
|
|
31
|
+
color: ColorInput | readonly ColorInput[];
|
|
32
|
+
/** Puff size at the start. */
|
|
33
|
+
size: number;
|
|
34
|
+
/** Top speed. */
|
|
35
|
+
speed: number;
|
|
36
|
+
count: number;
|
|
37
|
+
/** Seconds. */
|
|
38
|
+
lifetime: number;
|
|
39
|
+
/** Default up. */
|
|
40
|
+
direction?: Vec3;
|
|
41
|
+
/** Half-angle around `direction`. Default π. */
|
|
42
|
+
spread?: number;
|
|
43
|
+
/** Default 0 (dust hangs; positive rises like smoke). */
|
|
44
|
+
gravity?: number;
|
|
45
|
+
/** How much each puff grows by the end. Default 2. */
|
|
46
|
+
endSize?: number;
|
|
47
|
+
/** Color at the end. Default: a single `color` faded to transparent; several colors keep theirs. */
|
|
48
|
+
endColor?: ColorInput;
|
|
49
|
+
/** Default "puff" (blended); "flame" adds light instead. */
|
|
50
|
+
mesh?: BurstOptions['mesh'];
|
|
51
|
+
};
|
|
52
|
+
/** One glow that swells and fades at a point: a hit, a strike, a muzzle flash. */
|
|
53
|
+
export type FlashOptions = {
|
|
54
|
+
position: Vec3;
|
|
55
|
+
/** Use channels above 1 to glow (see `effects.hot`). */
|
|
56
|
+
color: ColorInput;
|
|
57
|
+
size: number;
|
|
58
|
+
/** Seconds. Default 0.22. */
|
|
59
|
+
lifetime?: number;
|
|
60
|
+
/** How much it grows by the end. Default 2.2. */
|
|
61
|
+
endSize?: number;
|
|
62
|
+
/** Default: `color` faded to transparent. */
|
|
63
|
+
endColor?: ColorInput;
|
|
64
|
+
/** Default "flame" (adds light); "sphere" or "puff" for a solid or soft flash. */
|
|
65
|
+
mesh?: BurstOptions['mesh'];
|
|
66
|
+
/** Glows drawn at once (slightly scattered when `speed` > 0). Default 1. */
|
|
67
|
+
count?: number;
|
|
68
|
+
/** Default 0. */
|
|
69
|
+
speed?: number;
|
|
70
|
+
};
|
|
71
|
+
/** The cleared-piece pop: swell, flash white, settle, shrink away. */
|
|
72
|
+
export type PopOptions = {
|
|
73
|
+
/** Its scale at rest (what it has now): one number, or per axis. */
|
|
74
|
+
scale: number | Vec3;
|
|
75
|
+
/** Its color at rest, to return to after the white flash. Omit to flash `flash` only (or nothing). */
|
|
76
|
+
color?: ColorInput;
|
|
77
|
+
/** Parts to flash white as well (a group's visible children, whose rest color is white). */
|
|
78
|
+
flash?: readonly Entity[];
|
|
79
|
+
/** Seconds before it starts. Default 0. */
|
|
80
|
+
delay?: number;
|
|
81
|
+
/** Seconds it takes. Default `effects.POP_TIME`. */
|
|
82
|
+
duration?: number;
|
|
83
|
+
};
|
|
84
|
+
type Rgba = [number, number, number, number];
|
|
85
|
+
/** The same hue, self-lit: its brightest channel lifted to `peak` (above 1 glows, through light, shadow and fog). */
|
|
86
|
+
declare function hot(input: ColorInput, peak?: number, alpha?: number): Rgba;
|
|
87
|
+
/** Part way (`t`, 0..1) to white, with `alpha`. */
|
|
88
|
+
declare function pale(input: ColorInput, t: number, alpha?: number): Rgba;
|
|
89
|
+
declare function flash(world: World, o: FlashOptions): number;
|
|
90
|
+
declare function dust(world: World, o: DustOptions): number;
|
|
91
|
+
/** Celebration confetti: tumbling paper in two layers, a few glinting sparkles, and a pop of light. */
|
|
92
|
+
declare function confetti(world: World, e: EffectOptions): void;
|
|
93
|
+
/** Glitter for a reward: solid bright beads (seen on any background) with additive glints around them. */
|
|
94
|
+
declare function sparkle(world: World, e: EffectOptions): void;
|
|
95
|
+
/**
|
|
96
|
+
* Something breaking apart: big slow chunks, small fast crumbs, a glow at the break and a puff of
|
|
97
|
+
* its dust. `mesh` is the chunks' shape.
|
|
98
|
+
*/
|
|
99
|
+
declare function shatter(world: World, e: EffectOptions & {
|
|
100
|
+
mesh?: BurstOptions['mesh'];
|
|
101
|
+
dust?: boolean;
|
|
102
|
+
}): void;
|
|
103
|
+
/** Liquid: droplets in two sizes thrown out of a fine mist of the same color. */
|
|
104
|
+
declare function splash(world: World, e: EffectOptions): void;
|
|
105
|
+
/** Hot metal sparks: additive streaks that burn out, with a few solid beads and a flash where they strike. */
|
|
106
|
+
declare function sparks(world: World, e: EffectOptions): void;
|
|
107
|
+
/**
|
|
108
|
+
* A fiery blast: a white-hot flash, a fireball that cools into smoke, embers thrown out and, given
|
|
109
|
+
* `debris` colors, chunks of whatever blew up. `size` is the fireball's puff size; `colors` its fire.
|
|
110
|
+
* The fire and smoke swell every way; `direction`, `spread` and `gravity` aim the embers and debris.
|
|
111
|
+
*/
|
|
112
|
+
declare function explosion(world: World, e: Omit<EffectOptions, 'colors'> & {
|
|
113
|
+
colors?: EffectOptions['colors'];
|
|
114
|
+
debris?: readonly ColorInput[];
|
|
115
|
+
smoke?: ColorInput;
|
|
116
|
+
}): void;
|
|
117
|
+
/** The piece swells, flashes white, settles and shrinks away. Resolves when it's gone (despawning it is the caller's). */
|
|
118
|
+
declare function pop(world: World, entity: Entity, o: PopOptions): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Ready-made effects. Each is one call; particles then live, fall, shrink and recolor in Rust.
|
|
121
|
+
*
|
|
122
|
+
* ```ts
|
|
123
|
+
* effects.confetti(world, { position, colors: [RED, GOLD], size: 0.12, speed: 6, count: 40, lifetime: 1.2, gravity: -6 });
|
|
124
|
+
* effects.dust(world, { position: feet, color: [0.8, 0.75, 0.65, 0.6], size: 0.3, speed: 1.5, count: 6, lifetime: 0.5 });
|
|
125
|
+
* effects.flash(world, { position: hit, color: effects.hot(ORANGE), size: 0.8 });
|
|
126
|
+
* await effects.pop(world, candy, { scale: 1, color: RED });
|
|
127
|
+
* world.despawn(candy);
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export declare const effects: {
|
|
131
|
+
/** Celebration: tumbling paper, glints and a pop of light (wins, level-ups). */
|
|
132
|
+
confetti: typeof confetti;
|
|
133
|
+
/** Reward glitter: bright beads and glints (pickups, perfect moves). */
|
|
134
|
+
sparkle: typeof sparkle;
|
|
135
|
+
/** Breaking apart: chunks, crumbs, a glow and dust (bricks, crates, glass). `mesh` shapes the chunks. */
|
|
136
|
+
shatter: typeof shatter;
|
|
137
|
+
/** Liquid: droplets and mist (water, juice, paint). */
|
|
138
|
+
splash: typeof splash;
|
|
139
|
+
/** Hot metal: additive streaks and beads (scrapes, strikes, electricity). */
|
|
140
|
+
sparks: typeof sparks;
|
|
141
|
+
/** Fiery blast: flash, fireball cooling to smoke, embers and optional debris. */
|
|
142
|
+
explosion: typeof explosion;
|
|
143
|
+
/** Soft swelling puffs: dust, sand, sawdust, steam, smoke. */
|
|
144
|
+
dust: typeof dust;
|
|
145
|
+
/** One swelling glow: hits, strikes, muzzle flashes. */
|
|
146
|
+
flash: typeof flash;
|
|
147
|
+
/** The cleared-piece animation: swell, flash white, settle, shrink to nothing. */
|
|
148
|
+
pop: typeof pop;
|
|
149
|
+
/** Default `pop` duration in seconds. */
|
|
150
|
+
POP_TIME: number;
|
|
151
|
+
/** The same hue made self-lit (brightest channel lifted to `peak`), for glows. */
|
|
152
|
+
hot: typeof hot;
|
|
153
|
+
/** Part way (`t`, 0..1) to white. */
|
|
154
|
+
pale: typeof pale;
|
|
155
|
+
};
|
|
156
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Quat } from './types';
|
|
2
|
+
/** A writable quaternion; pass one as `out` to reuse it instead of allocating. */
|
|
3
|
+
export type MutableQuat = [number, number, number, number];
|
|
4
|
+
/**
|
|
5
|
+
* Quaternion helpers for `rotation` options, keyframes and geometry parts ([x, y, z, w]). Every
|
|
6
|
+
* function takes an optional `out` so per-frame code can reuse one array instead of allocating.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* world.set(car, { rotation: quat.y(heading) });
|
|
10
|
+
* const spin = quat.multiply(quat.y(yaw), quat.x(pitch), scratch); // pitch first, then yaw
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const quat: {
|
|
14
|
+
/** No rotation. */
|
|
15
|
+
identity: Quat;
|
|
16
|
+
/** Rotation by `angle` radians around the unit axis (x, y, z). */
|
|
17
|
+
axisAngle(x: number, y: number, z: number, angle: number, out?: MutableQuat): MutableQuat;
|
|
18
|
+
/** Rotation around the x axis (pitch). */
|
|
19
|
+
x(angle: number, out?: MutableQuat): MutableQuat;
|
|
20
|
+
/** Rotation around the y axis (yaw, heading). */
|
|
21
|
+
y(angle: number, out?: MutableQuat): MutableQuat;
|
|
22
|
+
/** Rotation around the z axis (roll; spin for 2D games looking down -z). */
|
|
23
|
+
z(angle: number, out?: MutableQuat): MutableQuat;
|
|
24
|
+
/** `a` after `b`: `b` turns first. `out` may be `a` or `b`. */
|
|
25
|
+
multiply(a: Quat, b: Quat, out?: MutableQuat): MutableQuat;
|
|
26
|
+
/** Turns around x, then y, then z (radians): the same as `multiply(z(z), multiply(y(y), x(x)))`. */
|
|
27
|
+
fromEuler(x: number, y: number, z: number, out?: MutableQuat): MutableQuat;
|
|
28
|
+
/** Shortest-path interpolation from `a` (t = 0) to `b` (t = 1). */
|
|
29
|
+
slerp(a: Quat, b: Quat, t: number, out?: MutableQuat): MutableQuat;
|
|
30
|
+
};
|