Giter Site home page Giter Site logo

rusted-gltf-transform's Introduction

rusted-gltf-transform (EXTREMELY WIP)

rusted-gltf-transform is a Rust/WASM module that provides functionality for optimizing glTF files using the gltf-transform library. It allows you to perform various optimizations on glTF models, including texture optimization and general glTF optimization.

screenshot

Features

• Texture optimization: Compress textures to WebP format, resize textures, and apply quality settings. • glTF optimization: Prune unused data, deduplicate data, and apply other optimizations to reduce the size of glTF files. • WASM-based: The module is compiled to WebAssembly, allowing it to be used in web applications and native apps.

Building the WASM Module

To build the module, follow these steps:

Install Rust and wasm-pack:

Install Rust

Install wasm-pack

Clone the repository:

git clone https://github.com/antpb/rusted-gltf-transform.git

cd rusted-gltf-transform

Build the WASM module:

wasm-pack build --target web This command will compile the Rust code to WASM and generate the necessary JavaScript bindings. The output will be placed in the pkg directory.

Using the WASM Module in a JS app

To use the module in your JavaScript app, follow these steps:

Install the module as a dependency in your project:

npm install path/to/rusted-gltf-transform/pkg

Import the module in your JS code:

import init, { optimize_textures, optimize_gltf } from 'rusted-gltf-transform';

async function optimizeModel(input) {
  await init();

  // Optimize textures
  const optimizedTextures = await optimize_textures(input);

  // Optimize glTF
  const optimizedGltf = await optimize_gltf(input);

  // Return the optimized glTF
  return optimizedGltf;
}

In this example, the optimizeModel function takes the input glTF file as a Uint8Array and returns the optimized glTF as a JavaScript value. Use the optimized glTF in your application as needed.

Configuration

The module provides some configuration options for texture optimization:

targetFormat: The target format for texture compression (default: "webp"). quality: The quality setting for texture compression (default: 70). resize: The dimensions to resize textures to (default: [512, 512]). You can modify these options by updating the corresponding values in the optimize_textures function in the Rust code.

License

This project is licensed under the MIT License.

rusted-gltf-transform's People

Contributors

antpb avatar

Stargazers

 avatar  avatar

Watchers

 avatar

rusted-gltf-transform's Issues

Meshopt

Need a wasm module for meshopt

VRM workaround

we need a vrm workaround, one idea i have is to write out all the modules for glTF-transform as if they were regular old glTF extensions and do some extension trickery to get the vrm in. Currently with the example implementation you are just sending raw data so the extension doesnt matter much going in, just need to ensure if vrm went in, vrm comes out.

Sharp

ehhh kinda low priority since the default texture handling can be entirely web client side. still be nice to have

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.