CanvasApp

Struct CanvasApp 

Source
pub struct CanvasApp { /* private fields */ }
Expand description

The main canvas application for WASM.

Implementations§

Source§

impl CanvasApp

Source

pub fn new(canvas_id: &str) -> Result<CanvasApp, JsValue>

Create a new canvas application attached to the given canvas element ID.

§Errors

Returns an error if the canvas element is not found or 2D context fails.

Source

pub fn render(&mut self)

Render the current scene to the canvas.

Source

pub fn handle_touch(&mut self, x: f32, y: f32, phase: &str) -> Option<String>

Handle a touch event at the given coordinates.

Source

pub fn handle_click(&mut self, x: f32, y: f32) -> Option<String>

Handle a mouse click at the given coordinates.

Source

pub fn add_element(&mut self, json: &str) -> Result<String, JsValue>

Add an element to the scene from JSON.

§Errors

Returns an error if JSON parsing fails.

Source

pub fn remove_element(&mut self, id: &str) -> Result<(), JsValue>

Remove an element from the scene.

§Errors

Returns an error if the element is not found.

Source

pub fn get_scene_json(&self) -> String

Get the current scene as JSON.

Source

pub fn set_scene_json(&mut self, json: &str) -> Result<(), JsValue>

Update the entire scene from JSON.

§Errors

Returns an error if JSON parsing fails.

Source

pub fn apply_scene_document(&mut self, json: &str) -> Result<(), JsValue>

Apply a canonical scene document serialized as JSON.

§Errors

Returns an error if the JSON is invalid or the scene cannot be converted.

Source

pub fn element_count(&self) -> usize

Get the number of elements in the scene.

Source

pub fn frame_count(&self) -> u64

Get the current frame count.

Source

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

Resize the canvas.

Source

pub fn set_background_color(&mut self, color: &str)

Set the background color (CSS color string).

Source

pub fn is_connected(&self) -> bool

Check if connected to AI backend.

Source

pub fn update_video_frame( &mut self, stream_id: &str, data: &[u8], width: u32, height: u32, timestamp: f64, )

The data should be RGBA bytes.

Source

pub fn remove_video_stream(&mut self, stream_id: &str)

Remove a video stream from the cache.

Source

pub fn get_video_stream_ids(&self) -> Vec<String>

Get the list of registered video stream IDs.

Source

pub fn has_video_frame(&self, stream_id: &str) -> bool

Check if a video stream has a cached frame.

Source

pub fn get_video_frame_timestamp(&self, stream_id: &str) -> f64

Get the timestamp of the last frame for a video stream. Returns 0.0 if the stream doesn’t exist.

Source

pub fn set_holographic_config(&mut self, preset: &str) -> Result<(), JsValue>

Enable holographic mode with a preset configuration.

Supported presets: “portrait”, “4k” Pass an empty string or “off” to disable holographic mode.

§Errors

Returns an error if the preset is not recognized.

Source

pub fn is_holographic_mode(&self) -> bool

Check if holographic mode is currently enabled.

Source

pub fn get_quilt_dimensions(&self) -> JsValue

Get the quilt dimensions for the current holographic configuration.

Returns a JS object: { width, height, views, columns, rows } Returns null if holographic mode is not enabled.

Source

pub fn render_quilt(&mut self) -> Result<Vec<u8>, JsValue>

Render the current scene as a holographic quilt.

Returns the quilt as RGBA pixel data (Vec<u8>). The dimensions can be obtained from getQuiltDimensions().

§Errors

Returns an error if holographic mode is not enabled.

Source

pub fn set_holographic_camera( &mut self, pos_x: f32, pos_y: f32, pos_z: f32, target_x: f32, target_y: f32, target_z: f32, )

Set the holographic camera position and target.

§Arguments
  • pos_x, pos_y, pos_z - Camera position in world space
  • target_x, target_y, target_z - Point the camera looks at
Source

pub fn get_holographic_preset(&self) -> String

Get the current holographic configuration preset name.

Returns “portrait”, “4k”, or “none” if holographic mode is disabled.

Source

pub fn get_quilt_view_info(&self, view_index: u32) -> JsValue

Get information about a specific quilt view.

Returns a JS object with view offset, dimensions, and camera position, or null if the view index is out of range or holographic mode is disabled.

Source

pub fn get_holographic_stats(&self) -> JsValue

Get statistics from the holographic renderer.

Returns a JS object with: framesRendered, avgRenderTimeMs, peakRenderTimeMs, totalViewsRendered Returns null if holographic mode is not enabled.

Source

pub fn reset_holographic_stats(&mut self)

Reset holographic rendering statistics.

Source

pub fn process_voice( &mut self, transcript: String, confidence: f32, is_final: bool, timestamp: f64, ) -> JsValue

Process a voice recognition result.

This method handles speech recognition results from the Web Speech API. If a touch event is pending within the fusion window, it will create a fused intent combining the voice command with the touch location.

§Arguments
  • transcript - The recognized speech text
  • confidence - Confidence score (0.0 to 1.0)
  • is_final - Whether this is a final (committed) result
  • timestamp - Timestamp when the speech was recognized (ms since epoch)
§Returns

JSON-encoded fusion result if fusion occurs, or null if no fusion.

Source

pub fn has_pending_touch(&self) -> bool

Check if there’s a pending touch waiting for voice fusion.

Returns true if a touch event is stored and still within the fusion window.

Source

pub fn fusion_time_remaining(&self) -> u32

Get the remaining time in the fusion window for a pending touch.

Returns the time in milliseconds, or 0 if no pending touch or expired.

Source

pub fn set_fusion_window(&mut self, window_ms: u32)

Configure the fusion time window.

Sets how long a touch event waits for a voice command before expiring.

§Arguments
  • window_ms - Time window in milliseconds (default: 2000)
Source

pub fn clear_pending_touch(&mut self)

Clear any pending touch event.

Call this to cancel touch+voice fusion if the user cancels the operation.

Source

pub fn get_fusion_window(&self) -> u32

Get the current fusion window configuration in milliseconds.

Source

pub fn get_min_voice_confidence(&self) -> f32

Get the minimum confidence threshold for voice recognition.

Source

pub fn set_min_voice_confidence(&mut self, confidence: f32)

Set the minimum confidence threshold for voice recognition.

Voice events with confidence below this threshold will be ignored.

§Arguments
  • confidence - Minimum confidence (0.0 to 1.0, default: 0.5)

Trait Implementations§

Source§

impl From<CanvasApp> for JsValue

Source§

fn from(value: CanvasApp) -> Self

Converts to this type from the input type.
Source§

impl FromWasmAbi for CanvasApp

Source§

type Abi = u32

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: u32) -> Self

Recover a Self from Self::Abi. Read more
Source§

impl IntoWasmAbi for CanvasApp

Source§

type Abi = u32

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> u32

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl LongRefFromWasmAbi for CanvasApp

Source§

type Abi = u32

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRef<CanvasApp>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl OptionFromWasmAbi for CanvasApp

Source§

fn is_none(abi: &Self::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
Source§

impl OptionIntoWasmAbi for CanvasApp

Source§

fn none() -> Self::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
Source§

impl RefFromWasmAbi for CanvasApp

Source§

type Abi = u32

The Wasm ABI type references to Self are recovered from.
Source§

type Anchor = RcRef<CanvasApp>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don’t persist beyond one function call, and so that they remain anonymous.
Source§

unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor

Recover a Self::Anchor from Self::Abi. Read more
Source§

impl RefMutFromWasmAbi for CanvasApp

Source§

type Abi = u32

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRefMut<CanvasApp>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl TryFromJsValue for CanvasApp

Source§

fn try_from_js_value(value: JsValue) -> Result<Self, JsValue>

Performs the conversion.
Source§

fn try_from_js_value_ref(value: &JsValue) -> Option<Self>

Performs the conversion.
Source§

impl VectorFromWasmAbi for CanvasApp

Source§

type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi

Source§

unsafe fn vector_from_abi(js: Self::Abi) -> Box<[CanvasApp]>

Source§

impl VectorIntoWasmAbi for CanvasApp

Source§

impl WasmDescribe for CanvasApp

Source§

impl WasmDescribeVector for CanvasApp

Source§

impl SupportsConstructor for CanvasApp

Source§

impl SupportsInstanceProperty for CanvasApp

Source§

impl SupportsStaticProperty for CanvasApp

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> 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> ReturnWasmAbi for T
where T: IntoWasmAbi,

Source§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
Source§

fn return_abi(self) -> <T as ReturnWasmAbi>::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err.
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> 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