Skip to main content

SceneVM

Struct SceneVM 

Source
pub struct SceneVM {
    pub vm: VM,
    /* private fields */
}

Fields§

§vm: VM

Implementations§

Source§

impl SceneVM

Source

pub fn set_rgba_overlay( &mut self, width: u32, height: u32, rgba: Vec<u8>, rect: [f32; 4], )

Source

pub fn set_rgba_overlay_bytes( &mut self, width: u32, height: u32, rgba: &[u8], rect: [f32; 4], )

Source

pub fn clear_rgba_overlay(&mut self)

Source

pub fn vm_layer_count(&self) -> usize

Total number of VM layers (base + overlays).

Source

pub fn add_vm_layer(&mut self) -> usize

Append a new VM layer that will render on top of the existing ones. Returns its layer index.

Source

pub fn remove_vm_layer(&mut self, index: usize) -> Option<VM>

Remove a VM layer by index (cannot remove the base layer at index 0).

Source

pub fn set_active_vm(&mut self, index: usize) -> bool

Switch the VM layer targeted by execute. Returns true if the index existed.

Source

pub fn active_vm_index(&self) -> usize

Index of the currently active VM used by execute.

Source

pub fn atlas_sdf_uv4(&self, id: &Uuid, anim_frame: u32) -> Option<[f32; 4]>

Normalized atlas rect (ofs.x, ofs.y, scale.x, scale.y) for a tile/frame, useful for SDF packing.

Source

pub fn atlas_dims(&self) -> (u32, u32)

Source

pub fn set_layer_enabled(&mut self, index: usize, enabled: bool) -> bool

Enable or disable drawing for a VM layer. Disabled layers still receive commands.

Source

pub fn is_layer_enabled(&self, index: usize) -> Option<bool>

Returns whether a VM layer is enabled.

Source

pub fn set_layer_activity_logging(&mut self, enabled: bool)

Toggle verbose per-layer logging for uploads/atlas/grid events.

Source

pub fn active_vm(&self) -> &VM

Borrow the currently active VM immutably.

Source

pub fn active_vm_mut(&mut self) -> &mut VM

Borrow the currently active VM mutably.

Source

pub fn pick_geo_id_at_uv( &self, fb_w: u32, fb_h: u32, screen_uv: [f32; 2], include_hidden: bool, include_billboards: bool, ) -> Option<(GeoId, Vec3<f32>, f32)>

Ray-pick against the active VM layer using normalized screen UVs.

Source

pub fn ray_from_uv_with_size( &self, fb_w: u32, fb_h: u32, screen_uv: [f32; 2], ) -> Option<(Vec3<f32>, Vec3<f32>)>

Build a world-space ray from screen uv (0..1) using the active VM’s camera and a provided framebuffer size.

Source

pub fn ray_from_uv(&self, screen_uv: [f32; 2]) -> Option<(Vec3<f32>, Vec3<f32>)>

Build a world-space ray from screen uv (0..1) using the active VM’s camera and the current SceneVM size.

Source

pub fn print_geometry_stats(&self)

Prints statistics about 2D and 3D polygons currently loaded in all chunks.

Source

pub fn execute(&mut self, atom: Atom)

Executes a single atom on the currently active VM layer.

Source

pub fn is_gpu_ready(&self) -> bool

Is the GPU initialized and ready?

Source

pub fn frame_in_flight(&self) -> bool

Is a GPU readback currently in flight (WASM only)? Always false on native.

Source

pub fn new(initial_width: u32, initial_height: u32) -> Self

Create a new SceneVM. Always uses GPU backend.

Source

pub fn new_with_window(window: &Window) -> Self

Create a SceneVM that is configured to present directly into a winit window surface.

Source

pub async fn init_async(&mut self)

Initialize GPU backend asynchronously on WASM. On native, this will initialize synchronously if not already.

Source

pub fn blit_texture( &mut self, tex: &mut Texture, _cpu_pixels: &mut [u8], _buf_w: u32, _buf_h: u32, )

Blit a Texture via GPU to the main surface texture, if GPU is ready.

Source

pub fn resize_window_surface(&mut self, width: u32, height: u32)

Update the window surface size and internal storage texture (native only).

Source

pub fn render_to_window(&mut self) -> SceneVMResult<RenderResult>

Render directly into the configured window surface (native only, no CPU readback).

Source

pub async fn render_frame_async( &mut self, out_pixels: &mut [u8], out_w: u32, out_h: u32, )

Single cross-platform async entrypoint for rendering a frame.

Source

pub fn render_frame( &mut self, out_pixels: &mut [u8], out_w: u32, out_h: u32, ) -> RenderResult

Cross-platform synchronous render entrypoint (one function for Native & WASM). Returns a RenderResult. Native: blocks until pixels are ready. WASM: presents the last completed frame and kicks off a new GPU frame if none is in flight. Call this every frame. On WASM, you must call init_async().await once before rendering.

Source

pub fn load_image_rgba<I: IntoDataInput>( &self, input: I, ) -> Option<(Vec<u8>, u32, u32)>

Load an image from various inputs (file path on native, raw bytes, &str) and decode to RGBA8.

Source

pub fn compile_shader_2d( &mut self, body_source: &str, ) -> ShaderCompilationResult

Compile a 2D body shader with the header and return detailed diagnostics. If compilation succeeds (only warnings), the shader is automatically set as active.

Source

pub fn compile_shader_3d( &mut self, body_source: &str, ) -> ShaderCompilationResult

Compile a 3D body shader with the header and return detailed diagnostics. If compilation succeeds (only warnings), the shader is automatically set as active.

Source

pub fn compile_shader_sdf( &mut self, body_source: &str, ) -> ShaderCompilationResult

Compile an SDF body shader with the header and return detailed diagnostics. If compilation succeeds (only warnings), the shader is automatically set as active.

Source

pub fn default_shader_source(kind: &str) -> Option<String>

Fetch the source of a built-in shader body by name (e.g. “ui”, “2d”, “3d”, “sdf”, “noise”).

Trait Implementations§

Source§

impl Default for SceneVM

Available on crate feature gpu only.
Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,