@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.
Files changed (198) hide show
  1. package/LICENSE +21 -0
  2. package/NayanEngine.podspec +28 -0
  3. package/README.md +308 -2
  4. package/lib/module/assets/AssetBytesCache.js +76 -0
  5. package/lib/module/assets/AssetCache.js +19 -0
  6. package/lib/module/assets/AssetLoader.js +52 -0
  7. package/lib/module/assets/CacheGeneration.js +7 -0
  8. package/lib/module/assets/IndexedDbCache.web.js +149 -0
  9. package/lib/module/assets/ProceduralCache.js +249 -0
  10. package/lib/module/assets/font.js +139 -0
  11. package/lib/module/assets/loft.js +142 -0
  12. package/lib/module/assets/model.js +96 -0
  13. package/lib/module/assets/modelling.js +254 -0
  14. package/lib/module/assets/shape.js +926 -0
  15. package/lib/module/assets/source.js +58 -0
  16. package/lib/module/assets/source.web.js +22 -0
  17. package/lib/module/assets/storage.js +4 -0
  18. package/lib/module/assets/storage.shared.js +38 -0
  19. package/lib/module/assets/storage.web.js +38 -0
  20. package/lib/module/assets/surface.js +47 -0
  21. package/lib/module/assets/texture.js +69 -0
  22. package/lib/module/drawing/DrawingCanvas.js +38 -0
  23. package/lib/module/drawing/DrawingCanvas.web.js +206 -0
  24. package/lib/module/drawing/DrawingDocument.js +256 -0
  25. package/lib/module/drawing/types.js +4 -0
  26. package/lib/module/globals.d.ts +12 -0
  27. package/lib/module/index.js +39 -0
  28. package/lib/module/input/Joystick.js +84 -0
  29. package/lib/module/input/Joystick.web.js +93 -0
  30. package/lib/module/input/keyboard.js +250 -0
  31. package/lib/module/media/audio-worklet.js +34 -0
  32. package/lib/module/media/audio.js +97 -0
  33. package/lib/module/media/haptics.js +82 -0
  34. package/lib/module/media/output.web.js +66 -0
  35. package/lib/module/native/BrowserEngine.js +568 -0
  36. package/lib/module/native/EngineBridge.js +4 -0
  37. package/lib/module/native/NativeNayanEngine.js +7 -0
  38. package/lib/module/native/NativeNayanEngine.web.js +62 -0
  39. package/lib/module/native/prepare.js +7 -0
  40. package/lib/module/native/prepare.web.js +17 -0
  41. package/lib/module/native/spec/NativeNayanEngine.js +17 -0
  42. package/lib/module/package.json +1 -0
  43. package/lib/module/render/GameView.js +317 -0
  44. package/lib/module/render/camera.js +34 -0
  45. package/lib/module/render/host.js +39 -0
  46. package/lib/module/render/host.web.js +104 -0
  47. package/lib/module/render/light.js +24 -0
  48. package/lib/module/render/meshes.js +159 -0
  49. package/lib/module/render/quality.js +119 -0
  50. package/lib/module/render/responder.js +4 -0
  51. package/lib/module/render/responder.web.js +97 -0
  52. package/lib/module/render/touch.js +185 -0
  53. package/lib/module/render/useWorld.js +72 -0
  54. package/lib/module/types.js +30 -0
  55. package/lib/module/world/Scoreboard.js +161 -0
  56. package/lib/module/world/TransformBatch.js +128 -0
  57. package/lib/module/world/World.js +704 -0
  58. package/lib/module/world/color.js +80 -0
  59. package/lib/module/world/desc.js +187 -0
  60. package/lib/module/world/effects.js +463 -0
  61. package/lib/module/world/quat.js +86 -0
  62. package/lib/module/world/types.js +4 -0
  63. package/lib/typescript/package.json +1 -0
  64. package/lib/typescript/src/assets/AssetBytesCache.d.ts +7 -0
  65. package/lib/typescript/src/assets/AssetCache.d.ts +9 -0
  66. package/lib/typescript/src/assets/AssetLoader.d.ts +11 -0
  67. package/lib/typescript/src/assets/CacheGeneration.d.ts +3 -0
  68. package/lib/typescript/src/assets/IndexedDbCache.web.d.ts +20 -0
  69. package/lib/typescript/src/assets/ProceduralCache.d.ts +45 -0
  70. package/lib/typescript/src/assets/font.d.ts +53 -0
  71. package/lib/typescript/src/assets/loft.d.ts +31 -0
  72. package/lib/typescript/src/assets/model.d.ts +58 -0
  73. package/lib/typescript/src/assets/modelling.d.ts +157 -0
  74. package/lib/typescript/src/assets/shape.d.ts +203 -0
  75. package/lib/typescript/src/assets/source.d.ts +10 -0
  76. package/lib/typescript/src/assets/source.web.d.ts +8 -0
  77. package/lib/typescript/src/assets/storage.d.ts +2 -0
  78. package/lib/typescript/src/assets/storage.shared.d.ts +7 -0
  79. package/lib/typescript/src/assets/storage.web.d.ts +7 -0
  80. package/lib/typescript/src/assets/surface.d.ts +17 -0
  81. package/lib/typescript/src/assets/texture.d.ts +30 -0
  82. package/lib/typescript/src/drawing/DrawingCanvas.d.ts +5 -0
  83. package/lib/typescript/src/drawing/DrawingCanvas.web.d.ts +4 -0
  84. package/lib/typescript/src/drawing/DrawingDocument.d.ts +210 -0
  85. package/lib/typescript/src/drawing/types.d.ts +12 -0
  86. package/lib/typescript/src/index.d.ts +45 -0
  87. package/lib/typescript/src/input/Joystick.d.ts +20 -0
  88. package/lib/typescript/src/input/Joystick.web.d.ts +13 -0
  89. package/lib/typescript/src/input/keyboard.d.ts +17 -0
  90. package/lib/typescript/src/media/audio.d.ts +46 -0
  91. package/lib/typescript/src/media/haptics.d.ts +22 -0
  92. package/lib/typescript/src/media/output.web.d.ts +4 -0
  93. package/lib/typescript/src/native/BrowserEngine.d.ts +8 -0
  94. package/lib/typescript/src/native/EngineBridge.d.ts +26 -0
  95. package/lib/typescript/src/native/NativeNayanEngine.d.ts +5 -0
  96. package/lib/typescript/src/native/NativeNayanEngine.web.d.ts +10 -0
  97. package/lib/typescript/src/native/prepare.d.ts +3 -0
  98. package/lib/typescript/src/native/prepare.web.d.ts +2 -0
  99. package/lib/typescript/src/native/spec/NativeNayanEngine.d.ts +211 -0
  100. package/lib/typescript/src/render/GameView.d.ts +107 -0
  101. package/lib/typescript/src/render/camera.d.ts +6 -0
  102. package/lib/typescript/src/render/host.d.ts +29 -0
  103. package/lib/typescript/src/render/host.web.d.ts +16 -0
  104. package/lib/typescript/src/render/light.d.ts +12 -0
  105. package/lib/typescript/src/render/meshes.d.ts +45 -0
  106. package/lib/typescript/src/render/quality.d.ts +48 -0
  107. package/lib/typescript/src/render/responder.d.ts +2 -0
  108. package/lib/typescript/src/render/responder.web.d.ts +40 -0
  109. package/lib/typescript/src/render/touch.d.ts +26 -0
  110. package/lib/typescript/src/render/useWorld.d.ts +20 -0
  111. package/lib/typescript/src/types.d.ts +81 -0
  112. package/lib/typescript/src/world/Scoreboard.d.ts +75 -0
  113. package/lib/typescript/src/world/TransformBatch.d.ts +39 -0
  114. package/lib/typescript/src/world/World.d.ts +207 -0
  115. package/lib/typescript/src/world/color.d.ts +18 -0
  116. package/lib/typescript/src/world/desc.d.ts +17 -0
  117. package/lib/typescript/src/world/effects.d.ts +157 -0
  118. package/lib/typescript/src/world/quat.d.ts +31 -0
  119. package/lib/typescript/src/world/types.d.ts +238 -0
  120. package/lib/web/audio-worklet.js +29 -0
  121. package/lib/web/engine_core_bg.wasm +0 -0
  122. package/lib/web/index.js +8240 -0
  123. package/lib/web/types/src/assets/AssetBytesCache.d.ts +6 -0
  124. package/lib/web/types/src/assets/AssetCache.d.ts +8 -0
  125. package/lib/web/types/src/assets/AssetLoader.d.ts +10 -0
  126. package/lib/web/types/src/assets/CacheGeneration.d.ts +2 -0
  127. package/lib/web/types/src/assets/IndexedDbCache.d.ts +19 -0
  128. package/lib/web/types/src/assets/ProceduralCache.d.ts +44 -0
  129. package/lib/web/types/src/assets/font.d.ts +52 -0
  130. package/lib/web/types/src/assets/loft.d.ts +30 -0
  131. package/lib/web/types/src/assets/model.d.ts +57 -0
  132. package/lib/web/types/src/assets/modelling.d.ts +156 -0
  133. package/lib/web/types/src/assets/shape.d.ts +202 -0
  134. package/lib/web/types/src/assets/source.d.ts +7 -0
  135. package/lib/web/types/src/assets/storage.d.ts +6 -0
  136. package/lib/web/types/src/assets/storage.shared.d.ts +6 -0
  137. package/lib/web/types/src/assets/surface.d.ts +16 -0
  138. package/lib/web/types/src/assets/texture.d.ts +29 -0
  139. package/lib/web/types/src/drawing/DrawingCanvas.d.ts +3 -0
  140. package/lib/web/types/src/drawing/DrawingDocument.d.ts +209 -0
  141. package/lib/web/types/src/drawing/types.d.ts +11 -0
  142. package/lib/web/types/src/index.d.ts +44 -0
  143. package/lib/web/types/src/input/Joystick.d.ts +12 -0
  144. package/lib/web/types/src/input/keyboard.d.ts +16 -0
  145. package/lib/web/types/src/media/audio.d.ts +45 -0
  146. package/lib/web/types/src/media/haptics.d.ts +21 -0
  147. package/lib/web/types/src/media/output.d.ts +3 -0
  148. package/lib/web/types/src/native/BrowserEngine.d.ts +7 -0
  149. package/lib/web/types/src/native/EngineBridge.d.ts +25 -0
  150. package/lib/web/types/src/native/NativeNayanEngine.d.ts +9 -0
  151. package/lib/web/types/src/native/prepare.d.ts +1 -0
  152. package/lib/web/types/src/native/spec/NativeNayanEngine.d.ts +210 -0
  153. package/lib/web/types/src/render/GameView.d.ts +106 -0
  154. package/lib/web/types/src/render/camera.d.ts +5 -0
  155. package/lib/web/types/src/render/host.d.ts +15 -0
  156. package/lib/web/types/src/render/light.d.ts +11 -0
  157. package/lib/web/types/src/render/meshes.d.ts +44 -0
  158. package/lib/web/types/src/render/quality.d.ts +47 -0
  159. package/lib/web/types/src/render/responder.d.ts +39 -0
  160. package/lib/web/types/src/render/touch.d.ts +25 -0
  161. package/lib/web/types/src/render/useWorld.d.ts +19 -0
  162. package/lib/web/types/src/types.d.ts +80 -0
  163. package/lib/web/types/src/world/Scoreboard.d.ts +74 -0
  164. package/lib/web/types/src/world/TransformBatch.d.ts +38 -0
  165. package/lib/web/types/src/world/World.d.ts +206 -0
  166. package/lib/web/types/src/world/color.d.ts +17 -0
  167. package/lib/web/types/src/world/desc.d.ts +16 -0
  168. package/lib/web/types/src/world/effects.d.ts +156 -0
  169. package/lib/web/types/src/world/quat.d.ts +30 -0
  170. package/lib/web/types/src/world/types.d.ts +237 -0
  171. package/native/android/CMakeLists.txt +34 -0
  172. package/native/android/NayanEngineSpec.h +15 -0
  173. package/native/android/build.gradle +26 -0
  174. package/native/android/codegen/CMakeLists.txt +3 -0
  175. package/native/android/proguard-rules.pro +2 -0
  176. package/native/android/src/main/java/com/nayanui/engine/EngineSurfaceView.java +295 -0
  177. package/native/android/src/main/java/com/nayanui/engine/EngineSurfaceViewManager.java +45 -0
  178. package/native/android/src/main/java/com/nayanui/engine/NayanEnginePackage.java +24 -0
  179. package/native/core/build/EngineCore.xcframework/Info.plist +43 -0
  180. package/native/core/build/EngineCore.xcframework/ios-arm64/libengine_core.a +0 -0
  181. package/native/core/build/EngineCore.xcframework/ios-arm64-simulator/libengine_core.a +0 -0
  182. package/native/core/build/android/arm64-v8a/libengine_core.a +0 -0
  183. package/native/core/build/android/armeabi-v7a/libengine_core.a +0 -0
  184. package/native/core/build/android/x86/libengine_core.a +0 -0
  185. package/native/core/build/android/x86_64/libengine_core.a +0 -0
  186. package/native/core/include/drawing-licenses.txt +58 -0
  187. package/native/core/include/engine_core.h +331 -0
  188. package/native/cpp/NayanEngineModule.cpp +998 -0
  189. package/native/cpp/NayanEngineModule.h +174 -0
  190. package/native/cpp/generated/NayanEngineSpecJSI.cpp +2 -0
  191. package/native/cpp/generated/NayanEngineSpecJSI.h +1026 -0
  192. package/native/ios/NayanEngineProvider.h +5 -0
  193. package/native/ios/NayanEngineProvider.mm +21 -0
  194. package/native/ios/NayanEngineSurface.mm +252 -0
  195. package/native/scripts/check-package.mjs +39 -0
  196. package/package.json +162 -4
  197. package/react-native.config.js +18 -0
  198. package/src/native/spec/NativeNayanEngine.ts +265 -0
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ // Colors: every engine option that takes a color accepts either a linear 0..1 tuple or a CSS color
4
+ // string, so theme colors go straight in: `world.spawn({ color: '#FF4757' })`.
5
+
6
+ /** A color as an option takes it: `[r, g, b]` / `[r, g, b, a]` (0..1, channels above 1 glow) or a CSS string. */
7
+
8
+ const HEX = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
9
+ const RGB = /^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+%?)\s*)?\)$/i;
10
+ const NAMED = {
11
+ transparent: [0, 0, 0, 0],
12
+ black: [0, 0, 0, 1],
13
+ white: [1, 1, 1, 1],
14
+ red: [1, 0, 0, 1],
15
+ green: [0, 128 / 255, 0, 1],
16
+ blue: [0, 0, 1, 1],
17
+ yellow: [1, 1, 0, 1],
18
+ orange: [1, 165 / 255, 0, 1],
19
+ purple: [128 / 255, 0, 128 / 255, 1],
20
+ gray: [128 / 255, 128 / 255, 128 / 255, 1],
21
+ grey: [128 / 255, 128 / 255, 128 / 255, 1]
22
+ };
23
+
24
+ // Theme colors repeat endlessly; parse each string once.
25
+ const parsed = new Map();
26
+ const PARSED_LIMIT = 1024;
27
+ function parse(css) {
28
+ const text = css.trim();
29
+ const named = NAMED[text.toLowerCase()];
30
+ if (named) return named;
31
+ const hex = HEX.exec(text);
32
+ if (hex) {
33
+ let digits = hex[1];
34
+ if (digits.length <= 4) digits = [...digits].map(d => d + d).join('');
35
+ const n = i => parseInt(digits.slice(i, i + 2), 16) / 255;
36
+ return [n(0), n(2), n(4), digits.length === 8 ? n(6) : 1];
37
+ }
38
+ const rgb = RGB.exec(text);
39
+ if (rgb) {
40
+ const alpha = rgb[4] === undefined ? 1 : rgb[4].endsWith('%') ? parseFloat(rgb[4]) / 100 : Number(rgb[4]);
41
+ return [Number(rgb[1]) / 255, Number(rgb[2]) / 255, Number(rgb[3]) / 255, alpha];
42
+ }
43
+ throw new Error(`@nayan-ui/engine: "${css}" is not a color (use '#RRGGBB', '#RGB', '#RRGGBBAA', 'rgb(…)', 'rgba(…)' or a 0..1 tuple)`);
44
+ }
45
+
46
+ /**
47
+ * Any color input as an `[r, g, b, a]` tuple (0..1), with its alpha multiplied by `alpha`. Use it when
48
+ * you need the numbers (to brighten, mix or fade a theme color); options take strings directly.
49
+ *
50
+ * ```ts
51
+ * toColor('#FF4757'); // [1, 0.278, 0.341, 1]
52
+ * toColor('#FF4757', 0.5); // half see-through
53
+ * ```
54
+ */
55
+ export function toColor(color, alpha = 1) {
56
+ let c;
57
+ if (typeof color === 'string') {
58
+ let hit = parsed.get(color);
59
+ if (!hit) {
60
+ hit = parse(color);
61
+ if (parsed.size >= PARSED_LIMIT) parsed.clear();
62
+ parsed.set(color, hit);
63
+ }
64
+ c = hit;
65
+ } else c = color;
66
+ return [c[0], c[1], c[2], (c[3] ?? 1) * alpha];
67
+ }
68
+
69
+ /** A color input as a tuple, without copying tuples (the hot path of `spawn`, `set` and `animate`). */
70
+ export function resolveColor(color) {
71
+ return typeof color === 'string' ? toColor(color) : color;
72
+ }
73
+
74
+ /** One color input, or a list to pick from, as tuples. */
75
+ export function resolveColors(colors) {
76
+ if (typeof colors === 'string') return [toColor(colors)];
77
+ if (typeof colors[0] === 'number') return [colors];
78
+ return colors.map(resolveColor);
79
+ }
80
+ //# sourceMappingURL=color.js.map
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+
3
+ // Encodes entity options into the flat layout the Rust core decodes (native/core/include/engine_core.h,
4
+ // native/core/src/world/desc.rs). One reusable Float64Array per world: spawning or changing an entity is
5
+ // a single native call, and doubles keep entity ids and layer bits exact.
6
+ import { resolveColor } from "./color.js";
7
+ export const DESC_LEN = 64;
8
+ const FLAG = {
9
+ MESH: 1 << 0,
10
+ POSITION: 1 << 1,
11
+ ROTATION: 1 << 2,
12
+ SCALE: 1 << 3,
13
+ COLOR: 1 << 4,
14
+ VELOCITY: 1 << 5,
15
+ GROUND_VELOCITY: 1 << 6,
16
+ SPIN: 1 << 7,
17
+ BOB: 1 << 8,
18
+ FOLLOW: 1 << 9,
19
+ LIFETIME: 1 << 10,
20
+ PARENT: 1 << 11,
21
+ PHYSICS: 1 << 12,
22
+ IMPACT: 1 << 13,
23
+ ACCELERATION: 1 << 14,
24
+ PICKABLE: 1 << 15,
25
+ REGION: 1 << 16
26
+ };
27
+ const SLOT = {
28
+ FLAGS: 0,
29
+ MESH: 1,
30
+ POSITION: 2,
31
+ ROTATION: 5,
32
+ SCALE: 9,
33
+ COLOR: 12,
34
+ VELOCITY: 16,
35
+ GROUND_VELOCITY: 19,
36
+ SPIN: 21,
37
+ BOB: 24,
38
+ FOLLOW: 29,
39
+ LIFETIME: 31,
40
+ PARENT: 32,
41
+ PHYSICS: 33,
42
+ IMPACT: 50,
43
+ ACCELERATION: 56,
44
+ PICKABLE: 59,
45
+ REGION: 60
46
+ };
47
+ const BODY_KIND = {
48
+ dynamic: 1,
49
+ kinematic: 2,
50
+ fixed: 3
51
+ };
52
+ const SHAPE = {
53
+ ball: 0,
54
+ box: 1,
55
+ fromMesh: 2,
56
+ cylinder: 3,
57
+ capsule: 4,
58
+ cone: 5
59
+ };
60
+ function encodePhysics(d, physics) {
61
+ const p = SLOT.PHYSICS;
62
+ const shape = physics.shape !== undefined ? SHAPE[physics.shape] : physics.size !== undefined ? SHAPE.box : physics.radius !== undefined ? SHAPE.ball : SHAPE.fromMesh;
63
+ // Sizes <= 0 tell the core to size the collider from the entity's mesh and scale.
64
+ const [sx, sy, sz] = shape === SHAPE.box ? physics.size ? [physics.size[0] / 2, physics.size[1] / 2, physics.size[2] / 2] : [0, 0, 0] : [physics.radius ?? 0, (physics.height ?? 0) / 2, 0];
65
+ d[p] = BODY_KIND[physics.type];
66
+ d[p + 1] = shape;
67
+ d[p + 2] = sx;
68
+ d[p + 3] = sy;
69
+ d[p + 4] = sz;
70
+ d[p + 5] = physics.layer ?? 1;
71
+ d[p + 6] = physics.mask ?? -1; // all layers
72
+ d[p + 7] = physics.sensor ? 1 : 0;
73
+ d[p + 8] = physics.friction ?? 0.5;
74
+ d[p + 9] = physics.bounce ?? 0;
75
+ d[p + 10] = physics.density ?? 1;
76
+ d[p + 11] = physics.drag ?? 0;
77
+ d[p + 12] = physics.angularDrag ?? 0.05;
78
+ d[p + 13] = physics.gravityScale ?? 1;
79
+ d[p + 14] = physics.upright ? 1 : 0;
80
+ d[p + 15] = physics.ccd ? 1 : 0;
81
+ d[p + 16] = physics.planar ? 1 : 0;
82
+ }
83
+
84
+ /** Writes `options` into `d`, with the mesh id already resolved. Only the fields present are flagged. */
85
+ export function encode(d, o, mesh) {
86
+ let flags = 0;
87
+ if (mesh !== undefined) {
88
+ flags |= FLAG.MESH;
89
+ d[SLOT.MESH] = mesh;
90
+ }
91
+ if (o.position) {
92
+ flags |= FLAG.POSITION;
93
+ d.set(o.position, SLOT.POSITION);
94
+ }
95
+ if (o.rotation) {
96
+ flags |= FLAG.ROTATION;
97
+ d.set(o.rotation, SLOT.ROTATION);
98
+ }
99
+ if (o.scale !== undefined) {
100
+ flags |= FLAG.SCALE;
101
+ if (typeof o.scale === 'number') d.fill(o.scale, SLOT.SCALE, SLOT.SCALE + 3);else d.set(o.scale, SLOT.SCALE);
102
+ }
103
+ if (o.color) {
104
+ flags |= FLAG.COLOR;
105
+ const c = resolveColor(o.color);
106
+ d[SLOT.COLOR] = c[0];
107
+ d[SLOT.COLOR + 1] = c[1];
108
+ d[SLOT.COLOR + 2] = c[2];
109
+ d[SLOT.COLOR + 3] = c[3] ?? 1;
110
+ }
111
+ if (o.velocity) {
112
+ flags |= FLAG.VELOCITY;
113
+ d.set(o.velocity, SLOT.VELOCITY);
114
+ }
115
+ if (o.groundVelocity) {
116
+ flags |= FLAG.GROUND_VELOCITY;
117
+ d.set(o.groundVelocity, SLOT.GROUND_VELOCITY);
118
+ }
119
+ if (o.spin) {
120
+ flags |= FLAG.SPIN;
121
+ d.set(o.spin, SLOT.SPIN);
122
+ }
123
+ if (o.bob !== undefined) {
124
+ flags |= FLAG.BOB;
125
+ d.set(o.bob?.amplitude ?? [0, 0, 0], SLOT.BOB);
126
+ d[SLOT.BOB + 3] = o.bob?.speed ?? 0;
127
+ d[SLOT.BOB + 4] = o.bob?.phase ?? 0;
128
+ }
129
+ if (o.follow !== undefined) {
130
+ flags |= FLAG.FOLLOW;
131
+ d[SLOT.FOLLOW] = o.follow?.target ?? -1;
132
+ d[SLOT.FOLLOW + 1] = o.follow?.speed ?? 0;
133
+ }
134
+ if (o.lifetime !== undefined) {
135
+ flags |= FLAG.LIFETIME;
136
+ d[SLOT.LIFETIME] = o.lifetime ?? 0;
137
+ }
138
+ if (o.parent !== undefined) {
139
+ flags |= FLAG.PARENT;
140
+ d[SLOT.PARENT] = o.parent ?? -1;
141
+ }
142
+ if (o.physics !== undefined) {
143
+ flags |= FLAG.PHYSICS;
144
+ if (o.physics === null) d[SLOT.PHYSICS] = 0;else encodePhysics(d, typeof o.physics === 'string' ? {
145
+ type: o.physics
146
+ } : o.physics);
147
+ }
148
+ if (o.impact !== undefined) {
149
+ flags |= FLAG.IMPACT;
150
+ const i = SLOT.IMPACT;
151
+ d[i] = o.impact ? 1 : 0;
152
+ d[i + 1] = o.impact?.sound ?? -1;
153
+ d[i + 2] = o.impact?.minSpeed ?? 1;
154
+ d[i + 3] = o.impact?.maxSpeed ?? 10;
155
+ d[i + 4] = o.impact?.volume ?? 1;
156
+ d[i + 5] = o.impact?.haptic ?? 0;
157
+ }
158
+ if (o.acceleration) {
159
+ flags |= FLAG.ACCELERATION;
160
+ d.set(o.acceleration, SLOT.ACCELERATION);
161
+ }
162
+ if (o.pickable !== undefined) {
163
+ flags |= FLAG.PICKABLE;
164
+ d[SLOT.PICKABLE] = o.pickable ? 1 : 0;
165
+ }
166
+ if (o.textureRegion) {
167
+ flags |= FLAG.REGION;
168
+ d.set(o.textureRegion, SLOT.REGION);
169
+ }
170
+ d[SLOT.FLAGS] = flags;
171
+ }
172
+
173
+ // ── Animations and bursts (layouts in native/core/include/engine_core.h) ─────────
174
+
175
+ export const ANIM_HEADER = 12;
176
+ export const ANIM_KEY_LEN = 23;
177
+ export const BURST_LEN = 36;
178
+ export const EASING = {
179
+ linear: 0,
180
+ easeIn: 1,
181
+ easeOut: 2,
182
+ easeInOut: 3,
183
+ back: 4,
184
+ bounce: 5,
185
+ elastic: 6
186
+ };
187
+ //# sourceMappingURL=desc.js.map