@bornengine/engine 0.4.16 → 0.5.0
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 +24 -14
- package/native/android/Cargo.lock +577 -28
- package/native/android/Cargo.toml +2 -0
- package/native/android/src/lib.rs +39 -3
- package/native/ios/Cargo.lock +573 -24
- package/native/ios/Cargo.toml +2 -0
- package/native/ios/src/lib.rs +72 -9
- package/native/ios/src/text_input.rs +48 -0
- package/native/linux/Cargo.lock +623 -35
- package/native/linux/Cargo.toml +3 -0
- package/native/macos/Cargo.lock +630 -35
- package/native/macos/Cargo.toml +3 -0
- package/native/shared/Cargo.lock +430 -27
- package/native/shared/Cargo.toml +5 -0
- package/native/shared/build.rs +41 -1
- package/native/shared/src/engine.rs +54 -2
- package/native/shared/src/ffi.rs +54 -1
- package/native/shared/src/ffi_core/mod.rs +2 -0
- package/native/shared/src/ffi_core/ui.rs +182 -0
- package/native/shared/src/input.rs +317 -12
- package/native/shared/src/lib.rs +1 -0
- package/native/shared/src/renderer/mod.rs +47 -201
- package/native/shared/src/renderer/texture_store.rs +5 -0
- package/native/shared/src/renderer/ui_pass.rs +742 -0
- package/native/shared/src/textures.rs +2 -0
- package/native/shared/src/ui/commands.rs +213 -0
- package/native/shared/src/ui/egui.rs +1282 -0
- package/native/shared/src/ui/imgui.rs +1056 -0
- package/native/shared/src/ui/input.rs +173 -0
- package/native/shared/src/ui/mod.rs +252 -0
- package/native/shared/src/ui/responses.rs +61 -0
- package/native/tvos/Cargo.lock +576 -27
- package/native/tvos/Cargo.toml +2 -0
- package/native/visionos/Cargo.lock +571 -22
- package/native/visionos/Cargo.toml +2 -0
- package/native/watchos/src/ffi_stubs.rs +27 -0
- package/native/web/Cargo.lock +346 -11
- package/native/web/Cargo.toml +6 -0
- package/native/web/bloom_glue.js +84 -11
- package/native/web/build.sh +150 -34
- package/native/web/src/lib.rs +2 -0
- package/native/web/src/ui_ffi.rs +148 -0
- package/native/windows/Cargo.lock +638 -38
- package/native/windows/Cargo.toml +3 -0
- package/native/windows/src/lib.rs +50 -1
- package/native/windows/src/windows_text.rs +69 -0
- package/package.json +91 -2
- package/src/debug-ui/index.ts +4 -0
- package/src/debug-ui/types.ts +1 -0
- package/src/game/adapters/audio-source-component.ts +67 -0
- package/src/game/adapters/rigid-body-component.ts +69 -0
- package/src/game/adapters/scene-node-component.ts +49 -0
- package/src/game/game-component.ts +89 -0
- package/src/game/game-object.ts +338 -0
- package/src/game/game-scene.ts +303 -0
- package/src/game/index.ts +7 -0
- package/src/game/transform.ts +315 -0
- package/src/index.ts +27 -0
- package/src/ui/api.ts +216 -0
- package/src/ui/index.ts +5 -0
- package/src/ui/opcodes.ts +66 -0
- package/src/ui/types.ts +82 -0
|
@@ -14,6 +14,8 @@ jolt = ["bloom-shared/jolt"]
|
|
|
14
14
|
# unaffected; pure-2D games opt out via Perry feature forwarding.
|
|
15
15
|
models3d = ["bloom-shared/models3d"]
|
|
16
16
|
image-extras = ["bloom-shared/image-extras"]
|
|
17
|
+
hot-reload = ["bloom-shared/hot-reload"]
|
|
18
|
+
dev = ["hot-reload"]
|
|
17
19
|
|
|
18
20
|
[dependencies]
|
|
19
21
|
bloom-shared = { path = "../shared", default-features = false, features = ["mp3"] }
|
|
@@ -3,13 +3,17 @@ use bloom_shared::renderer::Renderer;
|
|
|
3
3
|
use bloom_shared::string_header::{str_from_header, alloc_perry_string};
|
|
4
4
|
use bloom_shared::audio::{parse_wav, parse_ogg, parse_mp3};
|
|
5
5
|
|
|
6
|
-
use std::
|
|
6
|
+
use std::collections::VecDeque;
|
|
7
|
+
use std::sync::{Mutex, OnceLock};
|
|
7
8
|
use std::sync::atomic::{AtomicBool, Ordering};
|
|
8
9
|
|
|
9
10
|
static mut ENGINE: OnceLock<EngineState> = OnceLock::new();
|
|
10
11
|
static mut NATIVE_WINDOW: *mut libc::c_void = std::ptr::null_mut();
|
|
11
12
|
static AUDIO_RUNNING: AtomicBool = AtomicBool::new(false);
|
|
12
13
|
static mut ASSET_BASE_PATH: Option<String> = None;
|
|
14
|
+
static ANDROID_UI_KEYBOARD_REQUEST: std::sync::atomic::AtomicI32 =
|
|
15
|
+
std::sync::atomic::AtomicI32::new(-1);
|
|
16
|
+
static ANDROID_UI_TEXT: OnceLock<Mutex<VecDeque<String>>> = OnceLock::new();
|
|
13
17
|
|
|
14
18
|
fn engine() -> &'static mut EngineState {
|
|
15
19
|
unsafe { ENGINE.get_mut().expect("Engine not initialized") }
|
|
@@ -378,15 +382,47 @@ pub extern "C" fn bloom_android_on_touch(action: i32, x: f64, y: f64, pointer_in
|
|
|
378
382
|
}
|
|
379
383
|
}
|
|
380
384
|
|
|
385
|
+
/// Poll from the Android UI host and translate the result to an
|
|
386
|
+
/// InputMethodManager show/hide request on its UI thread. -1 means no change.
|
|
387
|
+
#[no_mangle]
|
|
388
|
+
pub extern "C" fn bloom_android_take_keyboard_request() -> i32 {
|
|
389
|
+
ANDROID_UI_KEYBOARD_REQUEST.swap(-1, Ordering::AcqRel)
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/// Inject committed text from the host's InputConnection as UTF-8 bytes.
|
|
393
|
+
#[no_mangle]
|
|
394
|
+
pub extern "C" fn bloom_android_inject_text_utf8(bytes: *const u8, len: usize) {
|
|
395
|
+
if bytes.is_null() || len == 0 { return; }
|
|
396
|
+
let text = unsafe { std::slice::from_raw_parts(bytes, len) };
|
|
397
|
+
let text = String::from_utf8_lossy(text).into_owned();
|
|
398
|
+
let queue = ANDROID_UI_TEXT.get_or_init(|| Mutex::new(VecDeque::new()));
|
|
399
|
+
if let Ok(mut queue) = queue.lock() {
|
|
400
|
+
queue.push_back(text);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
381
404
|
#[no_mangle]
|
|
382
405
|
pub extern "C" fn bloom_begin_drawing() {
|
|
383
|
-
|
|
406
|
+
let pending_text = ANDROID_UI_TEXT
|
|
407
|
+
.get_or_init(|| Mutex::new(VecDeque::new()))
|
|
408
|
+
.lock()
|
|
409
|
+
.map(|mut queue| queue.drain(..).collect::<Vec<_>>())
|
|
410
|
+
.unwrap_or_default();
|
|
411
|
+
let engine = engine();
|
|
412
|
+
for text in pending_text {
|
|
413
|
+
engine.ui.inject_text(text);
|
|
414
|
+
}
|
|
415
|
+
engine.begin_frame();
|
|
384
416
|
}
|
|
385
417
|
|
|
386
418
|
#[no_mangle]
|
|
387
419
|
pub extern "C" fn bloom_end_drawing() {
|
|
388
420
|
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
|
389
|
-
engine()
|
|
421
|
+
let engine = engine();
|
|
422
|
+
engine.end_frame();
|
|
423
|
+
if let Some(show) = engine.ui.take_keyboard_request() {
|
|
424
|
+
ANDROID_UI_KEYBOARD_REQUEST.store(if show { 1 } else { 0 }, Ordering::Release);
|
|
425
|
+
}
|
|
390
426
|
}));
|
|
391
427
|
if let Err(e) = result {
|
|
392
428
|
let msg = if let Some(s) = e.downcast_ref::<&str>() {
|