pub struct GyroLiquidGameScene { /* private fields */ }Expand description
Shareable high-fidelity gyroscope liquid water GameScene ready for GameEngineHost, arbitrary dynamic resize, and edge-to-edge fullscreen.
Cloning GyroLiquidGameScene shares the same underlying solver/renderer handle so UI controls can tilt, shake, stir, change viscosity/fill, toggle buoyant bodies, and read live GyroLiquidStats seamlessly while GameEngineHost drives fixed-step physics and zero-copy pooled rendering.
Implementations§
Source§impl GyroLiquidGameScene
Interactive physics controls, sensor bindings, telemetry inspection, and offscreen pooled rendering on GyroLiquidGameScene.
impl GyroLiquidGameScene
Interactive physics controls, sensor bindings, telemetry inspection, and offscreen pooled rendering on GyroLiquidGameScene.
Sourcepub fn with_config(config: GyroLiquidConfig) -> Self
pub fn with_config(config: GyroLiquidConfig) -> Self
Sourcepub fn bind_device_motion(&self, signal: Signal<DeviceMotionSample>)
pub fn bind_device_motion(&self, signal: Signal<DeviceMotionSample>)
Binds a reactive Signal<DeviceMotionSample> (e.g. from use_device_motion()) so live hardware sensor updates drive the liquid seamlessly.
§Arguments
&Self- Liquid game scene handle.Signal<DeviceMotionSample>- Reactive device motion signal.
Sourcepub fn set_device_motion(&self, sample: Option<DeviceMotionSample>)
pub fn set_device_motion(&self, sample: Option<DeviceMotionSample>)
Injects an explicit DeviceMotionSample (useful for live custom bridges or deterministic testing) and clears it when passed None.
§Arguments
&Self- Liquid game scene handle.Option<DeviceMotionSample>- Hardware or synthetic motion sample.
Sourcepub fn set_sensor_mode(&self, mode: FluidSensorMode)
pub fn set_sensor_mode(&self, mode: FluidSensorMode)
Selects the sensor input mode (Auto, LiveHardware, or VirtualTilt).
§Arguments
&Self- Liquid game scene handle.FluidSensorMode- Desired sensor driving mode.
Sourcepub fn set_virtual_tilt(&self, roll_rad: f32, pitch_rad: f32)
pub fn set_virtual_tilt(&self, roll_rad: f32, pitch_rad: f32)
Sets virtual desktop/simulator tilt angles (roll_rad, pitch_rad).
§Arguments
&Self- Liquid game scene handle.f32- In-plane roll angle in radians (0.0= upright,+π/2= clockwise right-down).f32- Out-of-plane pitch angle in radians (0.0= upright vertical,+π/2= face-up flat).
Sourcepub fn rotate_container_by(&self, delta_rad: f32)
pub fn rotate_container_by(&self, delta_rad: f32)
Rotates the virtual container angle by delta_rad radians (positive clockwise in screen space).
§Arguments
&Self- Liquid game scene handle.f32- Rotation increment in radians.
Sourcepub fn apply_shake_impulse(&self, ax: f32, ay: f32)
pub fn apply_shake_impulse(&self, ax: f32, ay: f32)
Injects a physical linear frame shake acceleration impulse (ax, ay) in m/s².
§Arguments
&Self- Liquid game scene handle.f32- Horizontal shake acceleration inm/s².f32- Vertical shake acceleration inm/s².
Sourcepub fn apply_stir_impulse(
&self,
norm_x: f32,
norm_y: f32,
vel_x_mps: f32,
vel_y_mps: f32,
)
pub fn apply_stir_impulse( &self, norm_x: f32, norm_y: f32, vel_x_mps: f32, vel_y_mps: f32, )
Applies a direct pointer/touch stirring wake impulse at normalized vessel coordinates (norm_x, norm_y).
§Arguments
&Self- Liquid game scene handle.f32- Normalized x-coordinate in[0.0, 1.0].f32- Normalized y-coordinate in[0.0, 1.0].f32- Stir velocity x-component inm/s.f32- Stir velocity y-component inm/s.
Sourcepub fn set_fill_ratio(&self, fill_ratio: f32)
pub fn set_fill_ratio(&self, fill_ratio: f32)
Updates the liquid fill ratio (0.20..=0.85) and captures a discontinuous snapshot cleanly.
§Arguments
&Self- Liquid game scene handle.f32- Target fill fraction in[0.20, 0.85].
Sourcepub fn set_viscosity(&self, viscosity: f32)
pub fn set_viscosity(&self, viscosity: f32)
Updates the relative liquid viscosity (0.2..=6.0, where 1.0 = 20 °C pure water).
§Arguments
&Self- Liquid game scene handle.f32- Relative viscosity multiplier.
Sourcepub fn set_surface_tension(&self, surface_tension: f32)
pub fn set_surface_tension(&self, surface_tension: f32)
Updates the relative liquid surface tension (0.0..=3.0, where 1.0 = 0.0728 N/m).
§Arguments
&Self- Liquid game scene handle.f32- Relative surface tension multiplier.
Sourcepub fn set_buoyant_bodies_enabled(&self, enabled: bool)
pub fn set_buoyant_bodies_enabled(&self, enabled: bool)
Enables or disables Archimedes buoyant floating objects (orb + ice cube).
§Arguments
&Self- Liquid game scene handle.bool- Whether floating buoyant objects are active.
Sourcepub fn reset_water(&self)
pub fn reset_water(&self)
Resets the water, buoyant objects, bubbles, and virtual tilt to a calm upright resting pool.
§Arguments
&Self- Liquid game scene handle.
Sourcepub fn stats(&self) -> GyroLiquidStats
pub fn stats(&self) -> GyroLiquidStats
Sourcepub fn center_of_mass(&self) -> (f32, f32)
pub fn center_of_mass(&self) -> (f32, f32)
Sourcepub fn buoyant_bodies(&self) -> Vec<BuoyantBody>
pub fn buoyant_bodies(&self) -> Vec<BuoyantBody>
Sourcepub fn has_invalid_or_escaped_state(&self) -> bool
pub fn has_invalid_or_escaped_state(&self) -> bool
Sourcepub fn render_to_pooled_frame(
&self,
viewport_w: u32,
viewport_h: u32,
alpha: f32,
) -> Option<PooledFrameLease>
pub fn render_to_pooled_frame( &self, viewport_w: u32, viewport_h: u32, alpha: f32, ) -> Option<PooledFrameLease>
Renders the interpolated liquid scene directly into the internal RenderBufferPool for offscreen inspection or custom blitting.
§Arguments
&Self- Liquid game scene handle.u32- Target viewport width in logical pixels.u32- Target viewport height in logical pixels.f32- Interpolation alpha in[0.0, 1.0].
§Returns
Option<PooledFrameLease>- Rendered zero-copy RGBA8 frame lease.
Trait Implementations§
Source§impl Clone for GyroLiquidGameScene
impl Clone for GyroLiquidGameScene
Source§impl Debug for GyroLiquidGameScene
impl Debug for GyroLiquidGameScene
Source§impl Default for GyroLiquidGameScene
Default handheld gyroscope liquid water game scene.
impl Default for GyroLiquidGameScene
Default handheld gyroscope liquid water game scene.
Source§impl GameScene for GyroLiquidGameScene
GameScene integration driving fixed-step SI liquid physics, sensor ingestion, pointer stirring, and zero-copy pooled optical rendering inside GameEngineHost.
impl GameScene for GyroLiquidGameScene
GameScene integration driving fixed-step SI liquid physics, sensor ingestion, pointer stirring, and zero-copy pooled optical rendering inside GameEngineHost.
Source§fn fixed_update(&mut self, dt: f32, input: &InputState)
fn fixed_update(&mut self, dt: f32, input: &InputState)
Advances SI PBF liquid physics by one fixed timestep dt using live hardware sensors (or virtual tilt) plus pointer stirring and keyboard controls.
§Arguments
&Self- Mutable liquid scene handle.f32- Fixed simulation timestep in seconds.&InputState- Real-time polled pointer and keyboard input state.
Source§fn render(&mut self, alpha: f32, ctx: &mut GameRenderContext<'_>)
fn render(&mut self, alpha: f32, ctx: &mut GameRenderContext<'_>)
Renders the photorealistic optical water into the bounded RenderBufferPool and blits it zero-copy into ctx, adapting cleanly to arbitrary resize and fullscreen bounds.
§Arguments
&Self- Mutable liquid scene handle.f32- Render interpolation alpha in[0.0, 1.0].&mut GameRenderContext<'_>- Active viewport draw surface.