mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-09 20:31:29 +11:00
Fix handling of interactivity (#295)
* Fix handling of interactivity * Sort out silly mixup
This commit is contained in:
parent
c503973739
commit
fd6bfe91d6
|
@ -104,6 +104,7 @@ async fn render(mut scenes: SceneSet, index: usize, args: &Args) -> Result<()> {
|
|||
images: &mut images,
|
||||
resolution: None,
|
||||
base_color: None,
|
||||
interactive: false,
|
||||
};
|
||||
(example_scene.function)(&mut builder, &mut scene_params);
|
||||
let mut transform = Affine::IDENTITY;
|
||||
|
|
|
@ -17,6 +17,10 @@ use vello::{kurbo::Vec2, peniko::Color, SceneBuilder};
|
|||
|
||||
pub struct SceneParams<'a> {
|
||||
pub time: f64,
|
||||
/// Whether blocking should be limited
|
||||
/// Will not change between runs
|
||||
// TODO: Just never block/handle this automatically?
|
||||
pub interactive: bool,
|
||||
pub text: &'a mut SimpleText,
|
||||
pub images: &'a mut ImageCache,
|
||||
pub resolution: Option<Vec2>,
|
||||
|
|
|
@ -114,14 +114,14 @@ pub fn svg_function_of<R: AsRef<str>>(
|
|||
params.resolution = Some(*resolution);
|
||||
return;
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
if cfg!(target_arch = "wasm32") || !params.interactive {
|
||||
let contents = contents.take().unwrap();
|
||||
let contents = contents();
|
||||
let (scene_frag, resolution) = render_svg_contents(&name, contents.as_ref());
|
||||
builder.append(&scene_frag, None);
|
||||
params.resolution = Some(resolution);
|
||||
cached_scene = Some((scene_frag, resolution))
|
||||
cached_scene = Some((scene_frag, resolution));
|
||||
return;
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
|
@ -129,7 +129,7 @@ pub fn svg_function_of<R: AsRef<str>>(
|
|||
if !has_started_parse {
|
||||
has_started_parse = true;
|
||||
// Prefer jank over loading screen for first time
|
||||
timeout = std::time::Duration::from_millis(400);
|
||||
timeout = std::time::Duration::from_millis(75);
|
||||
let tx = tx.take().unwrap();
|
||||
let contents = contents.take().unwrap();
|
||||
let name = name.clone();
|
||||
|
|
|
@ -271,6 +271,7 @@ fn run(
|
|||
images: &mut images,
|
||||
resolution: None,
|
||||
base_color: None,
|
||||
interactive: true,
|
||||
};
|
||||
(example_scene.function)(&mut builder, &mut scene_params);
|
||||
|
||||
|
|
Loading…
Reference in a new issue