Skip to main content

SSRuntimeContext

Struct SSRuntimeContext 

Source
pub struct SSRuntimeContext { /* private fields */ }

Implementations§

Source§

impl SSRuntimeContext

Source

pub fn new(data: Option<Box<[u8]>>) -> Result<SSRuntimeContext, JsValue>

Source

pub fn reset(&mut self)

Source

pub fn bind_resource(&mut self, resource: &SSRuntimeResource) -> bool

Source

pub fn load_ssab_copy(&mut self, data: &[u8]) -> bool

Source

pub fn get_render_mode(&self) -> u8

Source

pub fn set_render_mode(&mut self, mode: u8)

Source

pub fn setup_animation(&mut self, name: &str) -> Result<(), JsValue>

Source

pub fn setup_animation_by_hash(&mut self, name_hash: u32) -> Result<(), JsValue>

Source

pub fn prepare_frame_data(&mut self, frame_no: f32) -> Result<usize, JsValue>

Build the frame data for frame_no and return its byte length. Read the bytes with get_frame_data_buf, which does not evaluate again.

Evaluating the frame is the expensive half of a tick, so it happens here once. The buf/len pair is pure, like every other one on this type.

Source

pub fn get_frame_data_buf(&self) -> *const u8

Pointer to what the last prepare_frame_data built. Null before the first call; valid until the next one.

Source

pub fn get_frame_data_len(&self) -> usize

Source

pub fn get_world_matrices_buf(&self) -> *const f32

Source

pub fn get_world_matrices_len(&self) -> usize

Source

pub fn get_mesh_vertices_x_buf(&self) -> *const f32

Source

pub fn get_mesh_vertices_x_len(&self) -> usize

Source

pub fn get_mesh_vertices_y_buf(&self) -> *const f32

Source

pub fn get_mesh_vertices_y_len(&self) -> usize

Source

pub fn get_mesh_uvs_buf(&self) -> *const f32

Source

pub fn get_mesh_uvs_len(&self) -> usize

Source

pub fn get_mesh_indices_buf(&self) -> *const i32

Source

pub fn get_mesh_indices_len(&self) -> usize

Source

pub fn get_mesh_vertex_offsets_buf(&self) -> *const u32

Source

pub fn get_mesh_vertex_offsets_len(&self) -> usize

Source

pub fn get_mesh_index_offsets_buf(&self) -> *const u32

Source

pub fn get_mesh_index_offsets_len(&self) -> usize

Source

pub fn get_nines_vertices_buf(&self) -> *const f32

Source

pub fn get_nines_vertices_len(&self) -> usize

Source

pub fn get_nines_uvs_buf(&self) -> *const f32

Source

pub fn get_nines_uvs_len(&self) -> usize

Source

pub fn get_nines_box_coords_buf(&self) -> *const f32

Source

pub fn get_nines_box_coords_len(&self) -> usize

Source

pub fn get_nines_indices_buf(&self) -> *const i32

Source

pub fn get_nines_indices_len(&self) -> usize

Source

pub fn get_nines_vertex_offsets_buf(&self) -> *const u32

Source

pub fn get_nines_vertex_offsets_len(&self) -> usize

Source

pub fn get_nines_index_offsets_buf(&self) -> *const u32

Source

pub fn get_nines_index_offsets_len(&self) -> usize

Source

pub fn get_local_uvs_buf(&self) -> *const f32

Source

pub fn get_local_uvs_len(&self) -> usize

Source

pub fn get_cell_meta_buf(&self) -> *const f32

Source

pub fn get_cell_meta_len(&self) -> usize

Source

pub fn get_local_vertices_buf(&self) -> *const f32

Source

pub fn get_local_vertices_len(&self) -> usize

Source

pub fn get_shape_vertices_buf(&self) -> *const f32

Source

pub fn get_shape_vertices_len(&self) -> usize

Source

pub fn get_shape_vertex_box_coords_buf(&self) -> *const f32

Source

pub fn get_shape_vertex_box_coords_len(&self) -> usize

Source

pub fn get_shape_vertex_counts_buf(&self) -> *const i32

Source

pub fn get_shape_vertex_counts_len(&self) -> usize

Source

pub fn get_ssab_buf(&self) -> Result<*const u8, JsValue>

Source

pub fn get_ssab_len(&self) -> Result<usize, JsValue>

Source

pub fn get_frame_no(&self) -> f32

Source

pub fn is_finished(&self) -> bool

true once the configured loops have completed, and sticky until the next play / setup_animation. Never true under an infinite loop count, and never raised by stop.

This is a state, not a pulse: to notify once, take its rising edge.

Source

pub fn just_looped(&self) -> bool

Source

pub fn is_playing(&self) -> bool

Source

pub fn is_playing_forward(&self) -> bool

Source

pub fn is_pausing(&self) -> bool

Source

pub fn is_clock_playing(&self) -> bool

The character’s clock: true from play until stop or the next setup, after track 0 has finished as well.

Source

pub fn is_clock_pausing(&self) -> bool

true while pause holds a playing clock, after track 0 has finished as well. Implies is_clock_playing.

Source

pub fn is_stack_in_motion(&self) -> bool

true while the track stack would move the pose on a running clock for a reason other than track 0’s own animation stepping: a fade on any track, or another source still playing on a track that is heard. Independent of the clock; read it with is_clock_playing and is_clock_pausing.

Source

pub fn get_skip_frames(&self) -> bool

Source

pub fn get_playback_direction(&self) -> WebPlaybackDirection

Source

pub fn get_playback_style(&self) -> WebPlaybackStyle

Source

pub fn get_loop_count(&self) -> i32

Source

pub fn get_remaining_loops(&self) -> i32

Source

pub fn get_start_frame(&self) -> i32

Source

pub fn get_end_frame(&self) -> i32

Source

pub fn get_frame_rate(&self) -> i32

Source

pub fn get_speed_scale(&self) -> f32

Source

pub fn set_skip_frames(&mut self, skip: bool)

Source

pub fn set_loop_count(&mut self, loop_count: i32)

Source

pub fn set_frame_rate(&mut self, frame_rate: i32)

Source

pub fn set_playback_direction( &mut self, direction: WebPlaybackDirection, style: WebPlaybackStyle, )

Source

pub fn set_speed_scale(&mut self, speed_scale: f32)

Source

pub fn set_animation_section( &mut self, start_frame: i32, end_frame: i32, ) -> Result<(), JsValue>

Throws Invalid parameter when both ends are in range and the end is before the start; the section and the playhead stay as they were.

Source

pub fn set_coordinate_system(&mut self, coordinate_system: WebCoordinateSystem)

Source

pub fn get_coordinate_system(&self) -> WebCoordinateSystem

Source

pub fn set_origin(&mut self, origin: WebOrigin)

Source

pub fn get_origin(&self) -> WebOrigin

Source

pub fn set_unit(&mut self, unit: WebUnit)

Source

pub fn get_unit(&self) -> WebUnit

Source

pub fn update(&mut self, delta: f32) -> f32

Source

pub fn play(&mut self)

Source

pub fn play_with_start_frame(&mut self, frame_no: f32)

Source

pub fn pause(&mut self)

Holds playback in place (idempotent). is_playing stays true; read is_pausing to tell a held animation from a running one.

Source

pub fn resume(&mut self)

Lifts a pause (idempotent). play rewinds, so it is not a resume.

Source

pub fn stop(&mut self)

Source

pub fn set_frame_no(&mut self, frame: f32)

Source

pub fn next_frame(&mut self)

Source

pub fn prev_frame(&mut self)

Source

pub fn set_track_animation( &mut self, track: u32, name: &str, ) -> Result<(), JsValue>

Source

pub fn set_track_animation_by_hash( &mut self, track: u32, hash: u32, ) -> Result<(), JsValue>

Source

pub fn set_track_alpha(&mut self, track: u32, alpha: f32) -> Result<(), JsValue>

Source

pub fn get_track_alpha(&self, track: u32) -> Option<f32>

Source

pub fn set_track_blend(&mut self, track: u32, blend: u32) -> Result<(), JsValue>

blend: 0 = mix (lerp onto what is below), 1 = additive (offset from the setup pose).

Source

pub fn get_track_blend(&self, track: u32) -> Option<u32>

Source

pub fn set_track_sync(&mut self, track: u32, sync: u32) -> Result<(), JsValue>

sync: 0 = free (start from the head), 1 = start (start at track 0’s phase). Set it before laying an animation on the track.

Source

pub fn get_track_sync(&self, track: u32) -> Option<u32>

Source

pub fn get_track_count(&self) -> u32

Source

pub fn clear_track(&mut self, track: u32) -> Result<(), JsValue>

Source

pub fn crossfade( &mut self, track: u32, name: &str, duration_ms: f32, ) -> Result<(), JsValue>

Source

pub fn crossfade_by_hash( &mut self, track: u32, hash: u32, duration_ms: f32, ) -> Result<(), JsValue>

Source

pub fn fade_track( &mut self, track: u32, target_alpha: f32, duration_ms: f32, ) -> Result<(), JsValue>

Source

pub fn get_track_fade_progress(&self, track: u32) -> Option<f32>

Source

pub fn cancel_track_fade(&mut self, track: u32) -> Result<(), JsValue>

Source

pub fn set_track_frame(&mut self, track: u32, frame: f32) -> Result<(), JsValue>

Source

pub fn get_track_frame(&self, track: u32) -> Option<f32>

Source

pub fn set_track_speed(&mut self, track: u32, speed: f32) -> Result<(), JsValue>

Source

pub fn get_track_speed(&self, track: u32) -> Option<f32>

Source

pub fn set_track_frame_rate( &mut self, track: u32, frame_rate: i32, ) -> Result<(), JsValue>

Source

pub fn get_track_frame_rate(&self, track: u32) -> Option<i32>

Source

pub fn set_track_skip_frames( &mut self, track: u32, skip: bool, ) -> Result<(), JsValue>

Source

pub fn get_track_skip_frames(&self, track: u32) -> Option<bool>

Source

pub fn set_track_playback_direction( &mut self, track: u32, direction: WebPlaybackDirection, style: WebPlaybackStyle, ) -> Result<(), JsValue>

Source

pub fn get_track_playback_direction( &self, track: u32, ) -> Option<WebPlaybackDirection>

Source

pub fn get_track_playback_style(&self, track: u32) -> Option<WebPlaybackStyle>

Source

pub fn set_track_loop_count( &mut self, track: u32, loop_count: i32, ) -> Result<(), JsValue>

Belongs to the animation on the track: laying another one there starts it looping forever again, so state the count after laying it.

Source

pub fn get_track_loop_count(&self, track: u32) -> Option<i32>

Source

pub fn is_track_finished(&self, track: u32) -> bool

is_finished for one track; false for a track with no animation.

Source

pub fn track_just_looped(&self, track: u32) -> bool

just_looped for one track.

Source

pub fn set_track_outgoing_event_threshold( &mut self, track: u32, threshold: f32, ) -> Result<(), JsValue>

The outgoing side of a crossfade on the track fires events while its share, 1 - t, is at least this. Silent from the start by default.

Source

pub fn get_track_outgoing_event_threshold(&self, track: u32) -> Option<f32>

Source

pub fn get_track_main_source(&self, track: u32) -> Option<u32>

Source

pub fn add_track_source( &mut self, track: u32, name: &str, weight: f32, ) -> Result<u32, JsValue>

Source

pub fn add_track_source_by_hash( &mut self, track: u32, hash: u32, weight: f32, ) -> Result<u32, JsValue>

Source

pub fn set_source_weight( &mut self, handle: u32, weight: f32, ) -> Result<(), JsValue>

Source

pub fn get_source_weight(&self, handle: u32) -> Option<f32>

Source

pub fn set_source_frame( &mut self, handle: u32, frame: f32, ) -> Result<(), JsValue>

Source

pub fn get_source_frame(&self, handle: u32) -> Option<f32>

Source

pub fn get_source_animation_index(&self, handle: u32) -> Option<u32>

Which animation the source plays, as an index into the ssab’s animations; the table a passed event index addresses.

Source

pub fn get_current_animation_index(&self) -> Option<u32>

Which animation track 0’s main source plays, as an index into the ssab’s animations; a crossfade or a track animation on track 0 changes it from the call on.

Source

pub fn set_source_event_threshold( &mut self, handle: u32, threshold: f32, ) -> Result<(), JsValue>

Source

pub fn get_source_event_threshold(&self, handle: u32) -> Option<f32>

Source

pub fn get_passed_event_source_handle(&self, index: i32) -> u32

Source

pub fn get_passed_event_count(&self) -> i32

Source

pub fn get_passed_event_index(&self, index: i32) -> i32

Source

pub fn get_active_event_instance( &mut self, slot_index: u32, ) -> WebEventInstanceInfo

Mirror of ss_runtime_get_active_event_instance. Returns SS6 defaults (is_synthetic_default = true, loop_num = 1, speed = 1.0) when no event is active. Most Players should pass the returned value directly to SSRuntimeInstanceSlot::step, which resolves the labels internally.

Source

pub fn get_active_effect_event(&mut self, slot_index: u32) -> WebEffectEventInfo

Mirror of ss_runtime_get_active_effect_event.

Source

pub fn find_part_index(&self, part_name: &str) -> i32

Mirror of ss_runtime_find_part_index. -1 if not loaded / not found.

Source

pub fn set_part_visibility_override( &mut self, part: u32, force: u8, cascade: bool, ) -> Result<(), JsValue>

Mirror of ss_runtime_set_part_visibility_override. force: 0=clear/revert, 1=force-hide. Anything else, 2 (reserved for force-visible) included, is rejected.

Source

pub fn clear_part_visibility_override( &mut self, part: u32, ) -> Result<(), JsValue>

Mirror of ss_runtime_clear_part_visibility_override.

Source

pub fn set_part_color_override( &mut self, part: u32, blend_op: u8, rgba: u32, priority_mode: u8, ) -> Result<(), JsValue>

Mirror of ss_runtime_set_part_color_override. rgba packed 0xRRGGBBAA (fills all four corners); blend_op: 0=Mix 1=Mul 2=Add 3=Sub; priority_mode: 0=OverwriteOnNextKeyframe 1=HoldUntilNextAnimation 2=Permanent.

Source

pub fn set_part_color_override_corners( &mut self, part: u32, blend_op: u8, rgba_ltrtlbrb: &[u32], priority_mode: u8, ) -> Result<(), JsValue>

Mirror of ss_runtime_set_part_color_override_corners. rgba_ltrtlbrb = 4 packed RGBA in ssruntime corner order lt, rt, lb, rb.

Source

pub fn clear_part_color_override(&mut self, part: u32) -> Result<(), JsValue>

Mirror of ss_runtime_clear_part_color_override.

Source

pub fn set_part_cell_override( &mut self, part: u32, cellmap_name_hash: u32, cell_name_hash: u32, priority_mode: u8, ) -> Result<(), JsValue>

Mirror of ss_runtime_set_part_cell_override. (0, 0) reverts to the animation; Normal + Mask parts only; errors if the cell is unresolvable.

Source

pub fn clear_part_cell_override(&mut self, part: u32) -> Result<(), JsValue>

Mirror of ss_runtime_clear_part_cell_override.

Source

pub fn clear_all_part_overrides(&mut self)

Mirror of ss_runtime_clear_all_part_overrides.

Trait Implementations§

Source§

impl From<SSRuntimeContext> for JsValue

Source§

fn from(value: SSRuntimeContext) -> Self

Converts to this type from the input type.
Source§

impl FromWasmAbi for SSRuntimeContext

Source§

type Abi = WasmPtr<WasmRefCell<SSRuntimeContext>>

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

unsafe fn from_abi(js: Self::Abi) -> Self

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

impl IntoWasmAbi for SSRuntimeContext

Source§

type Abi = WasmPtr<WasmRefCell<SSRuntimeContext>>

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

fn into_abi(self) -> Self::Abi

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

impl LongRefFromWasmAbi for SSRuntimeContext

Source§

type Abi = WasmPtr<WasmRefCell<SSRuntimeContext>>

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRef<SSRuntimeContext>

Same as RefFromWasmAbi::Anchor
Source§

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

Same as RefFromWasmAbi::ref_from_abi
Source§

impl NullableFromWasmAbi for SSRuntimeContext

Source§

fn is_null(abi: &Self::MaybeAbi) -> bool

Tests the ABI value for Nullable::Null.
Source§

impl NullableIntoWasmAbi for SSRuntimeContext

Source§

fn null() -> Self::MaybeAbi

Returns the ABI value for Nullable::Null, which JS reads as null. Read more
Source§

impl OptionFromWasmAbi for SSRuntimeContext

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 SSRuntimeContext

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 SSRuntimeContext

Source§

type Abi = WasmPtr<WasmRefCell<SSRuntimeContext>>

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

type Anchor = RcRef<SSRuntimeContext>

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 SSRuntimeContext

Source§

type Abi = WasmPtr<WasmRefCell<SSRuntimeContext>>

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRefMut<SSRuntimeContext>

Same as RefFromWasmAbi::Anchor
Source§

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

Same as RefFromWasmAbi::ref_from_abi
Source§

impl SupportsConstructor for SSRuntimeContext

Source§

impl SupportsInstanceProperty for SSRuntimeContext

Source§

impl SupportsStaticProperty for SSRuntimeContext

Source§

impl TryFromJsValue for SSRuntimeContext

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§

const NULLABLE: bool = false

Whether Self accepts null as a distinct value space, as Nullable<T> does. An enclosing Option then passes null through instead of reading it as None, so Option<T> is itself nullable exactly when T is not. JsValue does not set this: it accepts null as one value among all of them, not as a distinct space, and Option<JsValue> reads it as None like the ABI does. This is the JS-value side of NullableFromWasmAbi, which claims null at the ABI.
Source§

impl VectorFromWasmAbi for SSRuntimeContext

Source§

impl VectorIntoWasmAbi for SSRuntimeContext

Source§

impl WasmDescribe for SSRuntimeContext

Source§

impl WasmDescribeVector for SSRuntimeContext

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, 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> MaybeFromWasmAbi for T

Source§

type MaybeAbi = <T as FromWasmAbi>::Abi

The ABI of Option<Self>.
Source§

unsafe fn from_maybe_abi(js: <T as FromWasmAbi>::Abi) -> T

Recovers a value from the Option<Self> ABI, once is_none has ruled None out. Read more
Source§

unsafe fn try_from_maybe_abi( js: <T as FromWasmAbi>::Abi, ) -> Result<T, &'static str>

Source§

fn is_none(js: &<T as FromWasmAbi>::Abi) -> bool

Tests the ABI value for None.
Source§

impl<T> MaybeIntoWasmAbi for T

Source§

type MaybeAbi = <T as IntoWasmAbi>::Abi

The ABI of Option<Self>.
Source§

fn into_maybe_abi(self) -> <T as IntoWasmAbi>::Abi

Converts a value into the Option<Self> ABI.
Source§

fn none() -> <T as IntoWasmAbi>::Abi

Returns the ABI value for None, which JS reads as undefined. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more