@nayan-ui/engine 1.0.0-beta.3 → 1.0.0-beta.5
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/README.md +229 -113
- package/lib/module/assets/AssetLoader.js +1 -1
- package/lib/module/assets/ProceduralCache.js +31 -4
- package/lib/module/assets/font.js +10 -7
- package/lib/module/assets/model.js +41 -19
- package/lib/module/assets/storage.shared.js +2 -0
- package/lib/module/assets/storage.web.js +1 -0
- package/lib/module/assets/texture.js +14 -11
- package/lib/module/index.js +4 -1
- package/lib/module/media/audio.js +6 -3
- package/lib/module/native/BrowserEngine.js +17 -0
- package/lib/module/render/GameView.js +86 -18
- package/lib/module/render/light.js +24 -0
- package/lib/module/render/quality.js +12 -5
- package/lib/module/render/useWorld.js +72 -0
- package/lib/module/world/Scoreboard.js +21 -3
- package/lib/module/world/TransformBatch.js +5 -3
- package/lib/module/world/World.js +27 -13
- package/lib/module/world/color.js +80 -0
- package/lib/module/world/desc.js +6 -5
- package/lib/module/world/effects.js +20 -8
- package/lib/typescript/src/assets/AssetLoader.d.ts +1 -1
- package/lib/typescript/src/assets/ProceduralCache.d.ts +12 -0
- package/lib/typescript/src/assets/model.d.ts +10 -0
- package/lib/typescript/src/index.d.ts +4 -1
- package/lib/typescript/src/native/EngineBridge.d.ts +6 -2
- package/lib/typescript/src/native/spec/NativeNayanEngine.d.ts +29 -0
- package/lib/typescript/src/render/GameView.d.ts +19 -7
- package/lib/typescript/src/render/light.d.ts +12 -0
- package/lib/typescript/src/render/quality.d.ts +4 -2
- package/lib/typescript/src/render/useWorld.d.ts +20 -0
- package/lib/typescript/src/types.d.ts +13 -4
- package/lib/typescript/src/world/Scoreboard.d.ts +12 -2
- package/lib/typescript/src/world/TransformBatch.d.ts +2 -2
- package/lib/typescript/src/world/World.d.ts +10 -2
- package/lib/typescript/src/world/color.d.ts +18 -0
- package/lib/typescript/src/world/effects.d.ts +13 -12
- package/lib/typescript/src/world/types.d.ts +11 -6
- package/lib/web/engine_core_bg.wasm +0 -0
- package/lib/web/index.js +521 -255
- package/lib/web/types/src/assets/AssetLoader.d.ts +1 -1
- package/lib/web/types/src/assets/ProceduralCache.d.ts +12 -0
- package/lib/web/types/src/assets/model.d.ts +10 -0
- package/lib/web/types/src/index.d.ts +4 -1
- package/lib/web/types/src/native/EngineBridge.d.ts +6 -2
- package/lib/web/types/src/native/spec/NativeNayanEngine.d.ts +29 -0
- package/lib/web/types/src/render/GameView.d.ts +19 -7
- package/lib/web/types/src/render/light.d.ts +11 -0
- package/lib/web/types/src/render/quality.d.ts +4 -2
- package/lib/web/types/src/render/useWorld.d.ts +19 -0
- package/lib/web/types/src/types.d.ts +13 -4
- package/lib/web/types/src/world/Scoreboard.d.ts +12 -2
- package/lib/web/types/src/world/TransformBatch.d.ts +2 -2
- package/lib/web/types/src/world/World.d.ts +10 -2
- package/lib/web/types/src/world/color.d.ts +17 -0
- package/lib/web/types/src/world/effects.d.ts +13 -12
- package/lib/web/types/src/world/types.d.ts +11 -6
- package/native/android/src/main/java/com/nayanui/engine/EngineSurfaceView.java +87 -26
- 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/engine_core.h +9 -0
- package/native/cpp/NayanEngineModule.cpp +171 -0
- package/native/cpp/NayanEngineModule.h +30 -0
- package/native/cpp/generated/NayanEngineSpecJSI.h +105 -0
- package/native/ios/NayanEngineSurface.mm +30 -1
- package/package.json +2 -2
- package/src/native/spec/NativeNayanEngine.ts +39 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Vec3 } from '../types.js';
|
|
2
|
-
import
|
|
2
|
+
import { type ColorInput } from './color.js';
|
|
3
|
+
import type { BurstOptions, Entity } from './types.js';
|
|
3
4
|
import type { World } from './World.js';
|
|
4
5
|
/** Shared options of the layered effects (confetti, sparkle, shatter, splash, sparks, explosion). */
|
|
5
6
|
export type EffectOptions = {
|
|
6
7
|
position: Vec3;
|
|
7
|
-
/** One color, or several to pick from at random. */
|
|
8
|
-
colors:
|
|
8
|
+
/** One color (CSS string or tuple), or several to pick from at random. */
|
|
9
|
+
colors: ColorInput | readonly ColorInput[];
|
|
9
10
|
/** Typical particle size. */
|
|
10
11
|
size: number;
|
|
11
12
|
/** Top speed. */
|
|
@@ -27,7 +28,7 @@ export type EffectOptions = {
|
|
|
27
28
|
export type DustOptions = {
|
|
28
29
|
position: Vec3;
|
|
29
30
|
/** Start color (alpha is how thick it looks), or several to pick from. */
|
|
30
|
-
color:
|
|
31
|
+
color: ColorInput | readonly ColorInput[];
|
|
31
32
|
/** Puff size at the start. */
|
|
32
33
|
size: number;
|
|
33
34
|
/** Top speed. */
|
|
@@ -44,7 +45,7 @@ export type DustOptions = {
|
|
|
44
45
|
/** How much each puff grows by the end. Default 2. */
|
|
45
46
|
endSize?: number;
|
|
46
47
|
/** Color at the end. Default: a single `color` faded to transparent; several colors keep theirs. */
|
|
47
|
-
endColor?:
|
|
48
|
+
endColor?: ColorInput;
|
|
48
49
|
/** Default "puff" (blended); "flame" adds light instead. */
|
|
49
50
|
mesh?: BurstOptions['mesh'];
|
|
50
51
|
};
|
|
@@ -52,14 +53,14 @@ export type DustOptions = {
|
|
|
52
53
|
export type FlashOptions = {
|
|
53
54
|
position: Vec3;
|
|
54
55
|
/** Use channels above 1 to glow (see `effects.hot`). */
|
|
55
|
-
color:
|
|
56
|
+
color: ColorInput;
|
|
56
57
|
size: number;
|
|
57
58
|
/** Seconds. Default 0.22. */
|
|
58
59
|
lifetime?: number;
|
|
59
60
|
/** How much it grows by the end. Default 2.2. */
|
|
60
61
|
endSize?: number;
|
|
61
62
|
/** Default: `color` faded to transparent. */
|
|
62
|
-
endColor?:
|
|
63
|
+
endColor?: ColorInput;
|
|
63
64
|
/** Default "flame" (adds light); "sphere" or "puff" for a solid or soft flash. */
|
|
64
65
|
mesh?: BurstOptions['mesh'];
|
|
65
66
|
/** Glows drawn at once (slightly scattered when `speed` > 0). Default 1. */
|
|
@@ -72,7 +73,7 @@ export type PopOptions = {
|
|
|
72
73
|
/** Its scale at rest (what it has now): one number, or per axis. */
|
|
73
74
|
scale: number | Vec3;
|
|
74
75
|
/** Its color at rest, to return to after the white flash. Omit to flash `flash` only (or nothing). */
|
|
75
|
-
color?:
|
|
76
|
+
color?: ColorInput;
|
|
76
77
|
/** Parts to flash white as well (a group's visible children, whose rest color is white). */
|
|
77
78
|
flash?: readonly Entity[];
|
|
78
79
|
/** Seconds before it starts. Default 0. */
|
|
@@ -82,9 +83,9 @@ export type PopOptions = {
|
|
|
82
83
|
};
|
|
83
84
|
type Rgba = [number, number, number, number];
|
|
84
85
|
/** The same hue, self-lit: its brightest channel lifted to `peak` (above 1 glows, through light, shadow and fog). */
|
|
85
|
-
declare function hot(
|
|
86
|
+
declare function hot(input: ColorInput, peak?: number, alpha?: number): Rgba;
|
|
86
87
|
/** Part way (`t`, 0..1) to white, with `alpha`. */
|
|
87
|
-
declare function pale(
|
|
88
|
+
declare function pale(input: ColorInput, t: number, alpha?: number): Rgba;
|
|
88
89
|
declare function flash(world: World, o: FlashOptions): number;
|
|
89
90
|
declare function dust(world: World, o: DustOptions): number;
|
|
90
91
|
/** Celebration confetti: tumbling paper in two layers, a few glinting sparkles, and a pop of light. */
|
|
@@ -110,8 +111,8 @@ declare function sparks(world: World, e: EffectOptions): void;
|
|
|
110
111
|
*/
|
|
111
112
|
declare function explosion(world: World, e: Omit<EffectOptions, 'colors'> & {
|
|
112
113
|
colors?: EffectOptions['colors'];
|
|
113
|
-
debris?: readonly
|
|
114
|
-
smoke?:
|
|
114
|
+
debris?: readonly ColorInput[];
|
|
115
|
+
smoke?: ColorInput;
|
|
115
116
|
}): void;
|
|
116
117
|
/** The piece swells, flashes white, settles and shrinks away. Resolves when it's gone (despawning it is the caller's). */
|
|
117
118
|
declare function pop(world: World, entity: Entity, o: PopOptions): Promise<void>;
|
|
@@ -3,6 +3,7 @@ import type { Model } from '../assets/model.js';
|
|
|
3
3
|
import type { Texture } from '../assets/texture.js';
|
|
4
4
|
import type { Sound } from '../media/audio.js';
|
|
5
5
|
import type { Vec3 } from '../types.js';
|
|
6
|
+
import type { ColorInput } from './color.js';
|
|
6
7
|
/** Opaque entity handle. Handles of despawned entities are safely ignored. */
|
|
7
8
|
export type Entity = number & {
|
|
8
9
|
readonly __entity: unique symbol;
|
|
@@ -105,8 +106,11 @@ export type EntityOptions = {
|
|
|
105
106
|
rotation?: Quat;
|
|
106
107
|
/** A number scales uniformly. Children scale with their parent. Visual only after the body exists. */
|
|
107
108
|
scale?: Vec3 | number;
|
|
108
|
-
/**
|
|
109
|
-
|
|
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;
|
|
110
114
|
/** Units per second. */
|
|
111
115
|
velocity?: Vec3;
|
|
112
116
|
/** Sets horizontal speed [x, z] and keeps the vertical one: steer a body and it still falls. */
|
|
@@ -141,7 +145,8 @@ export type AnimateTarget = {
|
|
|
141
145
|
position?: Vec3;
|
|
142
146
|
rotation?: Quat;
|
|
143
147
|
scale?: Vec3 | number;
|
|
144
|
-
color
|
|
148
|
+
/** A CSS color or a 0..1 tuple. */
|
|
149
|
+
color?: ColorInput;
|
|
145
150
|
/** Move by this offset from where the animation starts (instead of to a `position`). */
|
|
146
151
|
moveBy?: Vec3;
|
|
147
152
|
/** Turn by these angles (radians around x, y, z) from the starting rotation. 2π spins once; more spins more. */
|
|
@@ -200,12 +205,12 @@ export type BurstOptions = {
|
|
|
200
205
|
lifetime?: number;
|
|
201
206
|
/** Vertical acceleration. Default -9.81 (falls); 0 floats. */
|
|
202
207
|
gravity?: number;
|
|
203
|
-
/** One color, or up to 4 to pick from at random. Default white. */
|
|
204
|
-
color?:
|
|
208
|
+
/** One color (CSS string or tuple), or up to 4 to pick from at random. Default white. */
|
|
209
|
+
color?: ColorInput | readonly ColorInput[];
|
|
205
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. */
|
|
206
211
|
endSize?: number;
|
|
207
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. */
|
|
208
|
-
endColor?:
|
|
213
|
+
endColor?: ColorInput;
|
|
209
214
|
};
|
|
210
215
|
export type CollisionInfo = {
|
|
211
216
|
/** True when the touch started; false when it ended. */
|
|
Binary file
|