yew_spline

Crates.ioyew_spline
lib.rsyew_spline
version0.2.1
sourcesrc
created_at2022-10-25 23:47:47.956087
updated_at2022-10-25 23:47:47.956087
descriptionSpline runtime component for Yew
homepagehttps://krirogn.dev
repositoryhttps://github.com/krirogn/yew_spline
max_upload_size
id697398
size1,363,616
Kristian Fredrik (krirogn)

documentation

README

Yew Spline

Yew Spline is a Spline runtime component for Yew based on the @splinetool/runtime NPM package, so you can display Spline scenes in Yew.

Spline is a 3d editor that let's you make interactive 3d scenes to be viewed on the web. For more information visit https://spline.design/.

How to use

First you add yew_spline to your cargo.toml

[dependencies]
yew = "0.19.3^"
yew_spline = "..."

Then you use the component in your Html.

Examples

Use the splinecode URL

use yew::prelude::*;
use yew_spline::spline::Spline;

#[function_component(App)]
pub fn app() -> Html {
    html! {
        <Spline scene={"https://prod.spline.design/123/scene.splinecode"} />
    }
}

Use a local splinecode file
If you download a splinecode file to use locally instead of loading it in from the Spline servers, you have to link the directory it's in, in the index.html file.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Yew Spline</title>

    <link data-trunk rel="copy-dir" href="./src/assets">
</head>
<body>
    
</body>
</html>

In this example I have the standard src folder, but I have an assets folder with a spline folder nested inside.

use yew::prelude::*;
use yew_spline::spline::Spline;

#[function_component(App)]
pub fn app() -> Html {
    html! {
        <Spline scene={"assets/spline/scene.splinecode"} />
    }
}

License

Yew Spline is MIT licensed. See license

Commit count: 12

cargo fmt