@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,238 @@
|
|
|
1
|
+
import type { Font, TextAlign } from '../assets/font.js';
|
|
2
|
+
import type { Model } from '../assets/model.js';
|
|
3
|
+
import type { Texture } from '../assets/texture.js';
|
|
4
|
+
import type { Sound } from '../media/audio.js';
|
|
5
|
+
import type { Vec3 } from '../types.js';
|
|
6
|
+
import type { ColorInput } from './color.js';
|
|
7
|
+
/** Opaque entity handle. Handles of despawned entities are safely ignored. */
|
|
8
|
+
export type Entity = number & {
|
|
9
|
+
readonly __entity: unique symbol;
|
|
10
|
+
};
|
|
11
|
+
export type Color = readonly [number, number, number] | readonly [number, number, number, number];
|
|
12
|
+
export type Quat = readonly [number, number, number, number];
|
|
13
|
+
/** Playback for one entity using a skeletal animation embedded in a loaded model. */
|
|
14
|
+
export interface ClipOptions {
|
|
15
|
+
/** Repeat the clip. Default true. */
|
|
16
|
+
loop?: boolean;
|
|
17
|
+
/** Playback rate; zero holds a pose. Default 1. */
|
|
18
|
+
speed?: number;
|
|
19
|
+
/** Crossfade from the current pose, in seconds. Default 0.15. */
|
|
20
|
+
fade?: number;
|
|
21
|
+
/** Seek to this time in seconds. Omit to retain playback when reselecting a clip. */
|
|
22
|
+
time?: number;
|
|
23
|
+
}
|
|
24
|
+
/** Plane used by screenToWorld; defaults to the ground through the origin. */
|
|
25
|
+
export interface ScreenPlane {
|
|
26
|
+
point?: Vec3;
|
|
27
|
+
normal?: Vec3;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* - `dynamic`: moved by physics (gravity, collisions, impulses).
|
|
31
|
+
* - `kinematic`: moved by you; pushes dynamic bodies out of the way.
|
|
32
|
+
* - `fixed`: never moves (floors, walls).
|
|
33
|
+
*/
|
|
34
|
+
export type BodyType = 'dynamic' | 'kinematic' | 'fixed';
|
|
35
|
+
export type PhysicsOptions = {
|
|
36
|
+
type: BodyType;
|
|
37
|
+
/** Default: matches the mesh (spheres get a ball, cylinders a cylinder, ...; anything else a box). */
|
|
38
|
+
shape?: 'ball' | 'box' | 'cylinder' | 'capsule' | 'cone';
|
|
39
|
+
/** Ball, cylinder, capsule or cone radius. Default: from the entity's size. */
|
|
40
|
+
radius?: number;
|
|
41
|
+
/** Cylinder, capsule or cone height (total). Default: from the entity's size. */
|
|
42
|
+
height?: number;
|
|
43
|
+
/** Box size (full width, height, depth). Default: the entity's size. */
|
|
44
|
+
size?: Vec3;
|
|
45
|
+
/** Layer bits this collider is on. Default 1. */
|
|
46
|
+
layer?: number;
|
|
47
|
+
/** Layers it interacts with. Either side's mask is enough. Default: all. */
|
|
48
|
+
mask?: number;
|
|
49
|
+
/** Reports touches but doesn't push: pickups, trigger zones. */
|
|
50
|
+
sensor?: boolean;
|
|
51
|
+
/** How grippy, default 0.5. */
|
|
52
|
+
friction?: number;
|
|
53
|
+
/** Bounciness 0..1, default 0. */
|
|
54
|
+
bounce?: number;
|
|
55
|
+
/** Mass per volume, default 1. */
|
|
56
|
+
density?: number;
|
|
57
|
+
/** Slows movement over time (air resistance), default 0. */
|
|
58
|
+
drag?: number;
|
|
59
|
+
/** Slows spinning over time, default 0.05. */
|
|
60
|
+
angularDrag?: number;
|
|
61
|
+
/** Multiplier on world gravity, default 1. */
|
|
62
|
+
gravityScale?: number;
|
|
63
|
+
/** Stays upright: never tumbles. */
|
|
64
|
+
upright?: boolean;
|
|
65
|
+
/** Stops fast, small bodies passing through walls. */
|
|
66
|
+
ccd?: boolean;
|
|
67
|
+
/** 2D games: stays in its XY plane (moves in x/y, spins only around z). Keep the camera looking down -z. */
|
|
68
|
+
planar?: boolean;
|
|
69
|
+
};
|
|
70
|
+
/** Sound/haptic the core plays by itself when the entity hits something solid. */
|
|
71
|
+
export type ImpactFeedback = {
|
|
72
|
+
/** A loaded sound, e.g. `sfx.get("bump")`. Omit for haptics only. */
|
|
73
|
+
sound?: Sound;
|
|
74
|
+
/** Slower impacts are silent. Default 1. */
|
|
75
|
+
minSpeed?: number;
|
|
76
|
+
/** Full volume and strength at this speed. Default 10. */
|
|
77
|
+
maxSpeed?: number;
|
|
78
|
+
/** Volume at full strength, 0..2. Default 1. */
|
|
79
|
+
volume?: number;
|
|
80
|
+
/** Vibration at full strength, 0..1. Default 0 (none). */
|
|
81
|
+
haptic?: number;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Everything about an entity. `spawn` and `set` take the same options; in `set`, only what you
|
|
85
|
+
* pass changes, and `null` removes something (physics, parent, follow, bob, lifetime, impact).
|
|
86
|
+
*/
|
|
87
|
+
export type EntityOptions = {
|
|
88
|
+
/** A built-in shape or a model from `loadModel`. Default "cube". */
|
|
89
|
+
mesh?: Shape | Model;
|
|
90
|
+
/** An image from `loadTexture`, drawn on the mesh (`null` = none). In `set`, pass `mesh` with it. */
|
|
91
|
+
texture?: Texture | null;
|
|
92
|
+
/** Part of the texture to show, [u0, v0, u1, v1] from 0..1 (sprite sheets, card atlases). */
|
|
93
|
+
textureRegion?: readonly [number, number, number, number];
|
|
94
|
+
/** 3D text instead of a mesh (needs `font`). Letters are 1 unit tall at scale 1. */
|
|
95
|
+
text?: string;
|
|
96
|
+
/** A font from `loadFont`, for `text`. */
|
|
97
|
+
font?: Font;
|
|
98
|
+
/** Text alignment around `position`. Default "center". */
|
|
99
|
+
align?: TextAlign;
|
|
100
|
+
/** Extra space between letters, in ems. Default 0. */
|
|
101
|
+
letterSpacing?: number;
|
|
102
|
+
/** Digits all as wide as the widest, so changing scores and timers don't shift. Default false. */
|
|
103
|
+
tabular?: boolean;
|
|
104
|
+
/** Relative to the parent when attached. */
|
|
105
|
+
position?: Vec3;
|
|
106
|
+
rotation?: Quat;
|
|
107
|
+
/** A number scales uniformly. Children scale with their parent. Visual only after the body exists. */
|
|
108
|
+
scale?: Vec3 | number;
|
|
109
|
+
/**
|
|
110
|
+
* A CSS color (`'#FF4757'`, `'rgba(…)'`) or a 0..1 tuple. Alpha below 1 makes it see-through. Tuple
|
|
111
|
+
* channels above 1 glow: at 2 it's self-lit, ignoring light and shadow (fire, lamps).
|
|
112
|
+
*/
|
|
113
|
+
color?: ColorInput;
|
|
114
|
+
/** Units per second. */
|
|
115
|
+
velocity?: Vec3;
|
|
116
|
+
/** Sets horizontal speed [x, z] and keeps the vertical one: steer a body and it still falls. */
|
|
117
|
+
groundVelocity?: readonly [number, number];
|
|
118
|
+
/** Units per second², for entities without a dynamic body (falling debris, thrown items). */
|
|
119
|
+
acceleration?: Vec3;
|
|
120
|
+
/** Radians per second around each axis. */
|
|
121
|
+
spin?: Vec3;
|
|
122
|
+
/** Visual bob: the drawn position moves by amplitude * sin(phase), phase advancing at `speed`. */
|
|
123
|
+
bob?: {
|
|
124
|
+
amplitude: Vec3;
|
|
125
|
+
speed: number;
|
|
126
|
+
phase?: number;
|
|
127
|
+
} | null;
|
|
128
|
+
/** Chase `target` along the ground at `speed`. */
|
|
129
|
+
follow?: {
|
|
130
|
+
target: Entity;
|
|
131
|
+
speed: number;
|
|
132
|
+
} | null;
|
|
133
|
+
/** Seconds until it shrinks away and is despawned. */
|
|
134
|
+
lifetime?: number | null;
|
|
135
|
+
/** Attach to another entity: it moves, turns and scales with the parent and is despawned with it. Visual only. */
|
|
136
|
+
parent?: Entity | null;
|
|
137
|
+
physics?: BodyType | PhysicsOptions | null;
|
|
138
|
+
impact?: ImpactFeedback | null;
|
|
139
|
+
/** Whether `pick` can hit it. Default true. */
|
|
140
|
+
pickable?: boolean;
|
|
141
|
+
};
|
|
142
|
+
export type Easing = 'linear' | 'easeIn' | 'easeOut' | 'easeInOut' | 'back' | 'bounce' | 'elastic';
|
|
143
|
+
/** What `animate` changes. Anything left out stays as it is (and keeps any animation it already has). */
|
|
144
|
+
export type AnimateTarget = {
|
|
145
|
+
position?: Vec3;
|
|
146
|
+
rotation?: Quat;
|
|
147
|
+
scale?: Vec3 | number;
|
|
148
|
+
/** A CSS color or a 0..1 tuple. */
|
|
149
|
+
color?: ColorInput;
|
|
150
|
+
/** Move by this offset from where the animation starts (instead of to a `position`). */
|
|
151
|
+
moveBy?: Vec3;
|
|
152
|
+
/** Turn by these angles (radians around x, y, z) from the starting rotation. 2π spins once; more spins more. */
|
|
153
|
+
turn?: Vec3;
|
|
154
|
+
/** Shake by up to this distance, fading out. Only the drawn position shakes (hits, wrong moves). */
|
|
155
|
+
shake?: number;
|
|
156
|
+
};
|
|
157
|
+
/** A step of a keyframed animation: values to pass through, and when (0..1 of the duration; default evenly spaced). */
|
|
158
|
+
export type Keyframe = AnimateTarget & {
|
|
159
|
+
at?: number;
|
|
160
|
+
};
|
|
161
|
+
export type SpringOptions = {
|
|
162
|
+
/** How strongly it pulls toward the target. Default 170. */
|
|
163
|
+
stiffness?: number;
|
|
164
|
+
/** How quickly it calms down. Lower bounces more. Default 26 (no overshoot). */
|
|
165
|
+
damping?: number;
|
|
166
|
+
/** Heavier moves slower and swings further. Default 1. */
|
|
167
|
+
mass?: number;
|
|
168
|
+
};
|
|
169
|
+
export type AnimateOptions = {
|
|
170
|
+
/** Seconds (ignored by springs). Default 0.3. */
|
|
171
|
+
duration?: number;
|
|
172
|
+
/** Seconds before it starts. Default 0. */
|
|
173
|
+
delay?: number;
|
|
174
|
+
/** Default "easeOut". "back" overshoots, "bounce" bounces, "elastic" springs. */
|
|
175
|
+
easing?: Easing;
|
|
176
|
+
/** Extra runs after the first, or "forever". Default 0. */
|
|
177
|
+
repeat?: number | 'forever';
|
|
178
|
+
/** Every other run plays backwards (pulses, ping-pong). */
|
|
179
|
+
yoyo?: boolean;
|
|
180
|
+
/** With several entities: extra delay for each next one, in seconds (waves, board reveals). */
|
|
181
|
+
stagger?: number;
|
|
182
|
+
/** "smooth" moves along a curve through the keyframes (arcs, hops) instead of straight lines. */
|
|
183
|
+
path?: 'linear' | 'smooth';
|
|
184
|
+
/**
|
|
185
|
+
* Physically simulated motion instead of a fixed duration: true (smooth), "bouncy", or your own
|
|
186
|
+
* settings. Interrupting a spring with another keeps its speed, so it never jerks.
|
|
187
|
+
*/
|
|
188
|
+
spring?: boolean | 'bouncy' | SpringOptions;
|
|
189
|
+
};
|
|
190
|
+
export type BurstOptions = {
|
|
191
|
+
position: Vec3;
|
|
192
|
+
/** How many particles. Default 16. */
|
|
193
|
+
count?: number;
|
|
194
|
+
/** Main direction. Default up. */
|
|
195
|
+
direction?: Vec3;
|
|
196
|
+
/** Half-angle of the cone around `direction`, in radians. Default π (every direction). */
|
|
197
|
+
spread?: number;
|
|
198
|
+
/** Default "cube". */
|
|
199
|
+
mesh?: Shape | Model;
|
|
200
|
+
/** Particle size. Default 0.15. */
|
|
201
|
+
size?: number;
|
|
202
|
+
/** Top speed. Default 5. */
|
|
203
|
+
speed?: number;
|
|
204
|
+
/** Seconds. Default 0.8. */
|
|
205
|
+
lifetime?: number;
|
|
206
|
+
/** Vertical acceleration. Default -9.81 (falls); 0 floats. */
|
|
207
|
+
gravity?: number;
|
|
208
|
+
/** One color (CSS string or tuple), or up to 4 to pick from at random. Default white. */
|
|
209
|
+
color?: ColorInput | readonly ColorInput[];
|
|
210
|
+
/** Size at the end of each particle's life, as a multiple of its start size: above 1 grows (smoke), below shrinks (embers). Default 1. */
|
|
211
|
+
endSize?: number;
|
|
212
|
+
/** Color every particle shifts to over its life, e.g. flame to dark red; an alpha below 1 fades it out. Default: keeps its color. */
|
|
213
|
+
endColor?: ColorInput;
|
|
214
|
+
};
|
|
215
|
+
export type CollisionInfo = {
|
|
216
|
+
/** True when the touch started; false when it ended. */
|
|
217
|
+
started: boolean;
|
|
218
|
+
/** A sensor was involved. */
|
|
219
|
+
sensor: boolean;
|
|
220
|
+
/** Impact speed (0 when a touch ends). */
|
|
221
|
+
speed: number;
|
|
222
|
+
};
|
|
223
|
+
export type RaycastHit = {
|
|
224
|
+
entity: Entity;
|
|
225
|
+
distance: number;
|
|
226
|
+
normal: [number, number, number];
|
|
227
|
+
point: [number, number, number];
|
|
228
|
+
};
|
|
229
|
+
export type PickHit = {
|
|
230
|
+
entity: Entity;
|
|
231
|
+
/** Where the tap ray hit the entity's bounding box, in world space. */
|
|
232
|
+
point: [number, number, number];
|
|
233
|
+
distance: number;
|
|
234
|
+
};
|
|
235
|
+
export type Bounds = readonly [minX: number, minZ: number, maxX: number, maxZ: number];
|
|
236
|
+
import type { Shape } from '../types.js';
|
|
237
|
+
export type { Shape };
|
|
238
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Runs on the audio rendering thread. PCM is produced by the shared Rust mixer on the main thread.
|
|
2
|
+
class NayanMixer extends AudioWorkletProcessor {
|
|
3
|
+
constructor() {
|
|
4
|
+
super();
|
|
5
|
+
this.blocks = [];
|
|
6
|
+
this.offset = 0;
|
|
7
|
+
this.port.onmessage = ({ data }) => {
|
|
8
|
+
if (this.blocks.length < 8) this.blocks.push(data);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
process(_inputs, outputs) {
|
|
12
|
+
const channels = outputs[0];
|
|
13
|
+
for (let i = 0; i < channels[0].length; i++) {
|
|
14
|
+
const block = this.blocks[0];
|
|
15
|
+
channels[0][i] = block ? block[this.offset] : 0;
|
|
16
|
+
channels[1][i] = block ? block[this.offset + 1] : 0;
|
|
17
|
+
if (block) {
|
|
18
|
+
this.offset += 2;
|
|
19
|
+
if (this.offset >= block.length) {
|
|
20
|
+
this.blocks.shift();
|
|
21
|
+
this.offset = 0;
|
|
22
|
+
this.port.postMessage(null);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
registerProcessor('nayan-mixer', NayanMixer);
|
|
Binary file
|