@bornengine/engine 0.4.16
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/README.md +231 -0
- package/native/android/Cargo.lock +1848 -0
- package/native/android/Cargo.toml +24 -0
- package/native/android/src/lib.rs +702 -0
- package/native/ios/Cargo.lock +1690 -0
- package/native/ios/Cargo.toml +32 -0
- package/native/ios/src/lib.rs +1267 -0
- package/native/linux/Cargo.lock +3279 -0
- package/native/linux/Cargo.toml +29 -0
- package/native/linux/src/lib.rs +1331 -0
- package/native/macos/Cargo.lock +3310 -0
- package/native/macos/Cargo.toml +46 -0
- package/native/macos/src/lib.rs +1302 -0
- package/native/shared/Cargo.lock +1899 -0
- package/native/shared/Cargo.toml +62 -0
- package/native/shared/assets/default_font.ttf +0 -0
- package/native/shared/build.rs +270 -0
- package/native/shared/shaders/common/clouds.wgsl +122 -0
- package/native/shared/shaders/common/fog.wgsl +16 -0
- package/native/shared/shaders/common/foliage_wind.wgsl +98 -0
- package/native/shared/shaders/common/imposter.wgsl +112 -0
- package/native/shared/shaders/common/pbr.wgsl +186 -0
- package/native/shared/shaders/common/shadows.wgsl +186 -0
- package/native/shared/shaders/common/sky.wgsl +8 -0
- package/native/shared/shaders/common/tonemap.wgsl +25 -0
- package/native/shared/shaders/impulse_field.wgsl +57 -0
- package/native/shared/shaders/material_abi.wgsl +383 -0
- package/native/shared/shaders/materials/test_minimal.wgsl +42 -0
- package/native/shared/src/anim_mixer.rs +61 -0
- package/native/shared/src/attach.rs +263 -0
- package/native/shared/src/audio/decode.rs +123 -0
- package/native/shared/src/audio/mod.rs +863 -0
- package/native/shared/src/audio/render.rs +892 -0
- package/native/shared/src/audio/spsc.rs +156 -0
- package/native/shared/src/audio/stream.rs +226 -0
- package/native/shared/src/custom_shaders.rs +104 -0
- package/native/shared/src/decals.rs +245 -0
- package/native/shared/src/drs.rs +211 -0
- package/native/shared/src/engine.rs +261 -0
- package/native/shared/src/ffi.rs +116 -0
- package/native/shared/src/ffi_core/assets.rs +388 -0
- package/native/shared/src/ffi_core/audio_ffi.rs +184 -0
- package/native/shared/src/ffi_core/draw.rs +334 -0
- package/native/shared/src/ffi_core/game_loop.rs +577 -0
- package/native/shared/src/ffi_core/input.rs +234 -0
- package/native/shared/src/ffi_core/mod.rs +127 -0
- package/native/shared/src/ffi_core/models.rs +1154 -0
- package/native/shared/src/ffi_core/ragdoll_ffi.rs +261 -0
- package/native/shared/src/ffi_core/scene.rs +626 -0
- package/native/shared/src/ffi_core/vfx.rs +212 -0
- package/native/shared/src/ffi_core/visual.rs +691 -0
- package/native/shared/src/frame_callbacks.rs +122 -0
- package/native/shared/src/geometry.rs +236 -0
- package/native/shared/src/handles.rs +182 -0
- package/native/shared/src/input.rs +448 -0
- package/native/shared/src/jolt_sys.rs +822 -0
- package/native/shared/src/lib.rs +55 -0
- package/native/shared/src/models.rs +1093 -0
- package/native/shared/src/models_gltf.rs +1280 -0
- package/native/shared/src/particles.rs +391 -0
- package/native/shared/src/physics_jolt.rs +1908 -0
- package/native/shared/src/picking.rs +298 -0
- package/native/shared/src/postfx.rs +345 -0
- package/native/shared/src/profiler.rs +492 -0
- package/native/shared/src/ragdoll.rs +474 -0
- package/native/shared/src/renderer/atmosphere_lut.rs +573 -0
- package/native/shared/src/renderer/brdf_lut.rs +154 -0
- package/native/shared/src/renderer/draw2d.rs +143 -0
- package/native/shared/src/renderer/formats.rs +822 -0
- package/native/shared/src/renderer/froxel.rs +421 -0
- package/native/shared/src/renderer/gi_bake.rs +653 -0
- package/native/shared/src/renderer/graph.rs +462 -0
- package/native/shared/src/renderer/hiz.rs +269 -0
- package/native/shared/src/renderer/hot_reload.rs +390 -0
- package/native/shared/src/renderer/impulse_field.rs +456 -0
- package/native/shared/src/renderer/lighting.rs +154 -0
- package/native/shared/src/renderer/material_instancing.rs +171 -0
- package/native/shared/src/renderer/material_pipeline.rs +700 -0
- package/native/shared/src/renderer/material_system.rs +1996 -0
- package/native/shared/src/renderer/material_system_tests.rs +601 -0
- package/native/shared/src/renderer/material_system_wasm.rs +41 -0
- package/native/shared/src/renderer/mod.rs +12556 -0
- package/native/shared/src/renderer/model_draw.rs +641 -0
- package/native/shared/src/renderer/occlusion.rs +429 -0
- package/native/shared/src/renderer/planar_pass.rs +593 -0
- package/native/shared/src/renderer/planar_reflection.rs +499 -0
- package/native/shared/src/renderer/post_pass.rs +249 -0
- package/native/shared/src/renderer/postfx_chain.rs +728 -0
- package/native/shared/src/renderer/pt_pass.rs +577 -0
- package/native/shared/src/renderer/scene_pass.rs +607 -0
- package/native/shared/src/renderer/shader_include.rs +205 -0
- package/native/shared/src/renderer/shader_library.rs +135 -0
- package/native/shared/src/renderer/shaders/ao.rs +570 -0
- package/native/shared/src/renderer/shaders/core.rs +1243 -0
- package/native/shared/src/renderer/shaders/env.rs +907 -0
- package/native/shared/src/renderer/shaders/gi.rs +810 -0
- package/native/shared/src/renderer/shaders/mod.rs +19 -0
- package/native/shared/src/renderer/shaders/post.rs +1558 -0
- package/native/shared/src/renderer/shaders/pt.rs +1859 -0
- package/native/shared/src/renderer/shaders/ssgi.rs +1586 -0
- package/native/shared/src/renderer/shadow_pass.rs +731 -0
- package/native/shared/src/renderer/ssgi_pass.rs +392 -0
- package/native/shared/src/renderer/ssr_pass.rs +188 -0
- package/native/shared/src/renderer/texture_store.rs +473 -0
- package/native/shared/src/renderer/transient.rs +591 -0
- package/native/shared/src/renderer/types.rs +941 -0
- package/native/shared/src/renderer/util.rs +152 -0
- package/native/shared/src/scene.rs +1362 -0
- package/native/shared/src/sdf_cache.rs +274 -0
- package/native/shared/src/shadows.rs +1036 -0
- package/native/shared/src/staging.rs +102 -0
- package/native/shared/src/string_header.rs +266 -0
- package/native/shared/src/text_renderer.rs +502 -0
- package/native/shared/src/textures.rs +197 -0
- package/native/tvos/Cargo.lock +1693 -0
- package/native/tvos/Cargo.toml +36 -0
- package/native/tvos/metal-patched/Cargo.toml +178 -0
- package/native/tvos/metal-patched/LICENSE-APACHE +201 -0
- package/native/tvos/metal-patched/LICENSE-MIT +25 -0
- package/native/tvos/metal-patched/src/acceleration_structure.rs +667 -0
- package/native/tvos/metal-patched/src/acceleration_structure_pass.rs +108 -0
- package/native/tvos/metal-patched/src/argument.rs +366 -0
- package/native/tvos/metal-patched/src/blitpass.rs +102 -0
- package/native/tvos/metal-patched/src/buffer.rs +71 -0
- package/native/tvos/metal-patched/src/capturedescriptor.rs +76 -0
- package/native/tvos/metal-patched/src/capturemanager.rs +113 -0
- package/native/tvos/metal-patched/src/commandbuffer.rs +192 -0
- package/native/tvos/metal-patched/src/commandqueue.rs +44 -0
- package/native/tvos/metal-patched/src/computepass.rs +107 -0
- package/native/tvos/metal-patched/src/constants.rs +152 -0
- package/native/tvos/metal-patched/src/counters.rs +119 -0
- package/native/tvos/metal-patched/src/depthstencil.rs +190 -0
- package/native/tvos/metal-patched/src/device.rs +2134 -0
- package/native/tvos/metal-patched/src/drawable.rs +39 -0
- package/native/tvos/metal-patched/src/encoder.rs +2041 -0
- package/native/tvos/metal-patched/src/heap.rs +281 -0
- package/native/tvos/metal-patched/src/indirect_encoder.rs +344 -0
- package/native/tvos/metal-patched/src/lib.rs +657 -0
- package/native/tvos/metal-patched/src/library.rs +902 -0
- package/native/tvos/metal-patched/src/mps.rs +575 -0
- package/native/tvos/metal-patched/src/pipeline/compute.rs +475 -0
- package/native/tvos/metal-patched/src/pipeline/mod.rs +71 -0
- package/native/tvos/metal-patched/src/pipeline/render.rs +762 -0
- package/native/tvos/metal-patched/src/renderpass.rs +443 -0
- package/native/tvos/metal-patched/src/resource.rs +182 -0
- package/native/tvos/metal-patched/src/sampler.rs +165 -0
- package/native/tvos/metal-patched/src/sync.rs +178 -0
- package/native/tvos/metal-patched/src/texture.rs +352 -0
- package/native/tvos/metal-patched/src/types.rs +90 -0
- package/native/tvos/metal-patched/src/vertexdescriptor.rs +250 -0
- package/native/tvos/src/audio_backend.rs +197 -0
- package/native/tvos/src/lib.rs +1891 -0
- package/native/visionos/Cargo.lock +1693 -0
- package/native/visionos/Cargo.toml +40 -0
- package/native/visionos/src/audio_backend.rs +197 -0
- package/native/visionos/src/lib.rs +1887 -0
- package/native/watchos/Cargo.lock +16 -0
- package/native/watchos/Cargo.toml +19 -0
- package/native/watchos/shaders/bloom_postfx.metal +99 -0
- package/native/watchos/src/BloomWatchApp.swift +1267 -0
- package/native/watchos/src/BloomWatchAudio.swift +179 -0
- package/native/watchos/src/audio.rs +55 -0
- package/native/watchos/src/draw_list.rs +229 -0
- package/native/watchos/src/ffi_stubs.rs +915 -0
- package/native/watchos/src/ffi_stubs_manual.rs +35 -0
- package/native/watchos/src/lib.rs +1124 -0
- package/native/watchos/src/models.rs +746 -0
- package/native/watchos/src/postfx.rs +95 -0
- package/native/watchos/src/scene.rs +534 -0
- package/native/watchos/src/textures.rs +184 -0
- package/native/web/Cargo.lock +1657 -0
- package/native/web/Cargo.toml +43 -0
- package/native/web/bloom_glue.js +695 -0
- package/native/web/build.sh +131 -0
- package/native/web/index.html +35 -0
- package/native/web/jolt_bridge.js +1519 -0
- package/native/web/src/input_ffi.rs +286 -0
- package/native/web/src/lib.rs +1796 -0
- package/native/web/src/material_ffi.rs +710 -0
- package/native/web/src/parity_ffi.rs +343 -0
- package/native/web/src/physics_ffi.rs +643 -0
- package/native/web/src/ragdoll_ffi.rs +250 -0
- package/native/web/src/render_settings.rs +98 -0
- package/native/windows/Cargo.lock +1815 -0
- package/native/windows/Cargo.toml +68 -0
- package/native/windows/src/lib.rs +1486 -0
- package/package.json +4279 -0
- package/src/audio/index.ts +315 -0
- package/src/core/colors.ts +63 -0
- package/src/core/index.ts +1206 -0
- package/src/core/keys.ts +63 -0
- package/src/core/types.ts +104 -0
- package/src/index.ts +171 -0
- package/src/math/index.ts +516 -0
- package/src/mobile/index.ts +294 -0
- package/src/models/index.ts +1258 -0
- package/src/physics/index.ts +1134 -0
- package/src/scene/index.ts +698 -0
- package/src/shapes/index.ts +120 -0
- package/src/text/index.ts +48 -0
- package/src/textures/index.ts +187 -0
- package/src/vfx/index.ts +191 -0
- package/src/world/index.ts +24 -0
- package/src/world/loader.ts +423 -0
- package/src/world/prefab.ts +217 -0
- package/src/world/render.ts +172 -0
- package/src/world/saver.ts +108 -0
- package/src/world/serialize.ts +301 -0
- package/src/world/terrain.ts +355 -0
- package/src/world/types.ts +160 -0
- package/src/world/validate.ts +319 -0
- package/src/world/version.ts +114 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
//! Input FFI surface for web: keyboard/mouse/gamepad/touch getters plus
|
|
2
|
+
//! the injection entry points the JS glue calls from DOM event
|
|
3
|
+
//! listeners. Split from lib.rs (2000-line file policy).
|
|
4
|
+
|
|
5
|
+
use crate::engine;
|
|
6
|
+
use wasm_bindgen::prelude::*;
|
|
7
|
+
|
|
8
|
+
// ============================================================
|
|
9
|
+
// Input - Keyboard
|
|
10
|
+
// ============================================================
|
|
11
|
+
|
|
12
|
+
#[wasm_bindgen]
|
|
13
|
+
pub fn bloom_is_key_pressed(key: f64) -> f64 {
|
|
14
|
+
if engine().input.is_key_pressed(key as usize) { 1.0 } else { 0.0 }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
#[wasm_bindgen]
|
|
18
|
+
pub fn bloom_is_key_down(key: f64) -> f64 {
|
|
19
|
+
if engine().input.is_key_down(key as usize) { 1.0 } else { 0.0 }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
#[wasm_bindgen]
|
|
23
|
+
pub fn bloom_is_key_released(key: f64) -> f64 {
|
|
24
|
+
if engine().input.is_key_released(key as usize) { 1.0 } else { 0.0 }
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#[wasm_bindgen]
|
|
28
|
+
pub fn bloom_is_key_repeated(key: f64) -> f64 {
|
|
29
|
+
if engine().input.is_key_repeated(key as usize) { 1.0 } else { 0.0 }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ============================================================
|
|
33
|
+
// Input - Mouse
|
|
34
|
+
// ============================================================
|
|
35
|
+
|
|
36
|
+
#[wasm_bindgen]
|
|
37
|
+
pub fn bloom_get_mouse_x() -> f64 {
|
|
38
|
+
engine().input.mouse_x
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#[wasm_bindgen]
|
|
42
|
+
pub fn bloom_get_mouse_y() -> f64 {
|
|
43
|
+
engine().input.mouse_y
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
#[wasm_bindgen]
|
|
47
|
+
pub fn bloom_is_mouse_button_pressed(btn: f64) -> f64 {
|
|
48
|
+
if engine().input.is_mouse_button_pressed(btn as usize) { 1.0 } else { 0.0 }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
#[wasm_bindgen]
|
|
52
|
+
pub fn bloom_is_mouse_button_down(btn: f64) -> f64 {
|
|
53
|
+
if engine().input.is_mouse_button_down(btn as usize) { 1.0 } else { 0.0 }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#[wasm_bindgen]
|
|
57
|
+
pub fn bloom_is_mouse_button_released(btn: f64) -> f64 {
|
|
58
|
+
if engine().input.is_mouse_button_released(btn as usize) { 1.0 } else { 0.0 }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#[wasm_bindgen]
|
|
62
|
+
pub fn bloom_get_mouse_delta_x() -> f64 {
|
|
63
|
+
engine().input.mouse_delta_x
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
#[wasm_bindgen]
|
|
67
|
+
pub fn bloom_get_mouse_delta_y() -> f64 {
|
|
68
|
+
engine().input.mouse_delta_y
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Accumulated scroll wheel delta since the last call. Reading consumes the
|
|
72
|
+
// value. Used by the editor's orbit camera and any scrollable UI panel.
|
|
73
|
+
#[wasm_bindgen]
|
|
74
|
+
pub fn bloom_get_mouse_wheel() -> f64 {
|
|
75
|
+
engine().input.consume_mouse_wheel()
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
#[wasm_bindgen]
|
|
79
|
+
pub fn bloom_get_char_pressed() -> f64 {
|
|
80
|
+
engine().input.pop_char() as f64
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Model bounds accessors. Return the axis-aligned bounding box of a loaded
|
|
84
|
+
// model in model-local coordinates.
|
|
85
|
+
#[wasm_bindgen]
|
|
86
|
+
pub fn bloom_get_model_bounds_min_x(model_handle: f64) -> f64 {
|
|
87
|
+
engine().models.get_bounds(model_handle).0[0] as f64
|
|
88
|
+
}
|
|
89
|
+
#[wasm_bindgen]
|
|
90
|
+
pub fn bloom_get_model_bounds_min_y(model_handle: f64) -> f64 {
|
|
91
|
+
engine().models.get_bounds(model_handle).0[1] as f64
|
|
92
|
+
}
|
|
93
|
+
#[wasm_bindgen]
|
|
94
|
+
pub fn bloom_get_model_bounds_min_z(model_handle: f64) -> f64 {
|
|
95
|
+
engine().models.get_bounds(model_handle).0[2] as f64
|
|
96
|
+
}
|
|
97
|
+
#[wasm_bindgen]
|
|
98
|
+
pub fn bloom_get_model_bounds_max_x(model_handle: f64) -> f64 {
|
|
99
|
+
engine().models.get_bounds(model_handle).1[0] as f64
|
|
100
|
+
}
|
|
101
|
+
#[wasm_bindgen]
|
|
102
|
+
pub fn bloom_get_model_bounds_max_y(model_handle: f64) -> f64 {
|
|
103
|
+
engine().models.get_bounds(model_handle).1[1] as f64
|
|
104
|
+
}
|
|
105
|
+
#[wasm_bindgen]
|
|
106
|
+
pub fn bloom_get_model_bounds_max_z(model_handle: f64) -> f64 {
|
|
107
|
+
engine().models.get_bounds(model_handle).1[2] as f64
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ============================================================
|
|
111
|
+
// Input - Gamepad
|
|
112
|
+
// ============================================================
|
|
113
|
+
|
|
114
|
+
// EN-063 — arity MUST match the manifest (and the shared macro): these
|
|
115
|
+
// carried a leading `gamepad` param the manifest never declared, so the
|
|
116
|
+
// game's single argument landed in it and the real one arrived undefined
|
|
117
|
+
// -> NaN -> `as usize` = 0. Every axis read axis 0 and every button read
|
|
118
|
+
// button 0 — silently, on the platform with no debugger. This is verbatim
|
|
119
|
+
// the argument-shift class ffi_core/mod.rs says the shared macro exists to
|
|
120
|
+
// prevent; the web crate hand-mirrors it and drifted.
|
|
121
|
+
#[wasm_bindgen]
|
|
122
|
+
pub fn bloom_is_gamepad_available() -> f64 {
|
|
123
|
+
if engine().input.is_gamepad_available() { 1.0 } else { 0.0 }
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
#[wasm_bindgen]
|
|
127
|
+
pub fn bloom_get_gamepad_axis(axis: f64) -> f64 {
|
|
128
|
+
engine().input.get_gamepad_axis(axis as usize) as f64
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
#[wasm_bindgen]
|
|
132
|
+
pub fn bloom_is_gamepad_button_pressed(button: f64) -> f64 {
|
|
133
|
+
if engine().input.is_gamepad_button_pressed(button as usize) { 1.0 } else { 0.0 }
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
#[wasm_bindgen]
|
|
137
|
+
pub fn bloom_is_gamepad_button_down(button: f64) -> f64 {
|
|
138
|
+
if engine().input.is_gamepad_button_down(button as usize) { 1.0 } else { 0.0 }
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
#[wasm_bindgen]
|
|
142
|
+
pub fn bloom_is_gamepad_button_released(button: f64) -> f64 {
|
|
143
|
+
if engine().input.is_gamepad_button_released(button as usize) { 1.0 } else { 0.0 }
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
#[wasm_bindgen]
|
|
147
|
+
pub fn bloom_get_gamepad_axis_count() -> f64 {
|
|
148
|
+
engine().input.get_gamepad_axis_count() as f64
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// ============================================================
|
|
152
|
+
// Input - Touch
|
|
153
|
+
// ============================================================
|
|
154
|
+
|
|
155
|
+
// EN-063 — take the slot index, like the manifest and the shared macro.
|
|
156
|
+
// Hardcoding slot 0 meant every finger reported the FIRST finger's
|
|
157
|
+
// coordinates while `is_touch_active(i)` honoured the index: on a phone
|
|
158
|
+
// both thumbsticks tracked one thumb.
|
|
159
|
+
#[wasm_bindgen]
|
|
160
|
+
pub fn bloom_get_touch_x(index: f64) -> f64 {
|
|
161
|
+
engine().input.get_touch_x(index as usize)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
#[wasm_bindgen]
|
|
165
|
+
pub fn bloom_get_touch_y(index: f64) -> f64 {
|
|
166
|
+
engine().input.get_touch_y(index as usize)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
#[wasm_bindgen]
|
|
170
|
+
pub fn bloom_get_touch_count() -> f64 {
|
|
171
|
+
engine().input.get_touch_count() as f64
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
#[wasm_bindgen]
|
|
175
|
+
pub fn bloom_is_touch_active(index: f64) -> f64 {
|
|
176
|
+
if engine().input.is_touch_active(index as usize) { 1.0 } else { 0.0 }
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
#[wasm_bindgen]
|
|
180
|
+
pub fn bloom_get_max_touch_points() -> f64 {
|
|
181
|
+
engine().input.max_touch_points() as f64
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// ============================================================
|
|
185
|
+
// Input injection (called from JS event listeners)
|
|
186
|
+
// ============================================================
|
|
187
|
+
|
|
188
|
+
// Injection goes through inject_key_* (staged, applied at the top of
|
|
189
|
+
// begin_frame), NOT set_key_* (which writes keys_down directly). A direct
|
|
190
|
+
// write made outside the poll phase is folded into `prev` before the edge
|
|
191
|
+
// is computed, so `isKeyPressed` never fires — the exact bug input.rs's
|
|
192
|
+
// pending_key_down staging was added to cure. Mirrors the shared macro.
|
|
193
|
+
#[wasm_bindgen]
|
|
194
|
+
pub fn bloom_inject_key_down(key: f64) {
|
|
195
|
+
engine().input.inject_key_down(key as usize);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
#[wasm_bindgen]
|
|
199
|
+
pub fn bloom_inject_key_up(key: f64) {
|
|
200
|
+
engine().input.inject_key_up(key as usize);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// EN-063: mouse / touch / wheel / char injection. DOM event handlers run in
|
|
204
|
+
// their own tasks, which on a single-threaded wasm host always land BETWEEN
|
|
205
|
+
// frames — i.e. before the next begin_frame(), exactly where a native
|
|
206
|
+
// message pump writes. So the immediate setters are correct here (edges are
|
|
207
|
+
// computed at begin_frame from prev-frame state); only same-gap taps need
|
|
208
|
+
// care, which the JS glue handles by deferring the matching -up one frame.
|
|
209
|
+
|
|
210
|
+
#[wasm_bindgen]
|
|
211
|
+
pub fn bloom_inject_mouse_move(x: f64, y: f64) {
|
|
212
|
+
engine().input.set_mouse_position(x, y);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/// Relative movement (pointer-lock `movementX/Y`). Feeds the raw-delta
|
|
216
|
+
/// accumulator that `begin_frame` prefers while the cursor is disabled —
|
|
217
|
+
/// the camera-orbit path.
|
|
218
|
+
#[wasm_bindgen]
|
|
219
|
+
pub fn bloom_inject_mouse_delta(dx: f64, dy: f64) {
|
|
220
|
+
engine().input.accumulate_mouse_delta(dx, dy);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
#[wasm_bindgen]
|
|
224
|
+
pub fn bloom_inject_mouse_button_down(button: f64) {
|
|
225
|
+
engine().input.set_mouse_button_down(button as usize);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
#[wasm_bindgen]
|
|
229
|
+
pub fn bloom_inject_mouse_button_up(button: f64) {
|
|
230
|
+
engine().input.set_mouse_button_up(button as usize);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
#[wasm_bindgen]
|
|
234
|
+
pub fn bloom_inject_mouse_wheel(dy: f64) {
|
|
235
|
+
engine().input.accumulate_mouse_wheel(dy);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
#[wasm_bindgen]
|
|
239
|
+
pub fn bloom_inject_touch(index: f64, x: f64, y: f64, active: f64) {
|
|
240
|
+
engine().input.set_touch(index as usize, x, y, active != 0.0);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/// Deferred release: keeps the slot active for the current frame and clears
|
|
244
|
+
/// it at end_frame, so a touch that begins and ends inside one frame is
|
|
245
|
+
/// still seen by the game.
|
|
246
|
+
#[wasm_bindgen]
|
|
247
|
+
pub fn bloom_inject_touch_release(index: f64, x: f64, y: f64) {
|
|
248
|
+
engine().input.release_touch(index as usize, x, y);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
#[wasm_bindgen]
|
|
252
|
+
pub fn bloom_inject_char(codepoint: f64) {
|
|
253
|
+
engine().input.push_char(codepoint as u32);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
#[wasm_bindgen]
|
|
257
|
+
pub fn bloom_inject_gamepad_axis(axis: f64, value: f64) {
|
|
258
|
+
engine().input.set_gamepad_axis(axis as usize, value as f32);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
#[wasm_bindgen]
|
|
262
|
+
pub fn bloom_inject_gamepad_button_down(button: f64) {
|
|
263
|
+
engine().input.set_gamepad_button_down(button as usize);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
#[wasm_bindgen]
|
|
267
|
+
pub fn bloom_inject_gamepad_button_up(button: f64) {
|
|
268
|
+
engine().input.set_gamepad_button_up(button as usize);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
/// EN-031 — gamepad rumble. The Gamepad API exposes vibrationActuator, but
|
|
273
|
+
/// only behind a user-gesture requirement and with patchy support, so the web
|
|
274
|
+
/// port records the request (keeping the symbol and the state consistent with
|
|
275
|
+
/// native) without driving a motor. Wire `playEffect` here when the browser
|
|
276
|
+
/// story settles.
|
|
277
|
+
#[wasm_bindgen]
|
|
278
|
+
pub fn bloom_gamepad_rumble(low: f64, high: f64, seconds: f64) {
|
|
279
|
+
let inp = &mut engine().input;
|
|
280
|
+
inp.rumble = [
|
|
281
|
+
(low as f32).clamp(0.0, 1.0),
|
|
282
|
+
(high as f32).clamp(0.0, 1.0),
|
|
283
|
+
(seconds as f32).clamp(0.0, 10.0),
|
|
284
|
+
];
|
|
285
|
+
}
|
|
286
|
+
|