Skip to content
This repository was archived by the owner on Mar 16, 2026. It is now read-only.

Klaaktu/polyvis-wasm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nightly release

GeoRust wrapper for my homework.

Build

wasm-pack build --target web

How to use

import * as wasm from "polyvis_wasm.js";
await wasm.default();
const instance = wasm.new_session();

There are some convenience functions and instance methods. See polyvis_wasm.d.ts.

See mtel0004/FIT3162/src/utils.ts for adapting types between JS and the WASM module (JS number type is 64-bit float).

Notes

Importing YAML save is not supported, due to lack of a maintained & popular YAML library. Export is supported (YAML is more human-readable).

Considerations

The spiral of rationale

  1. Use iShape-js, a wasm build of iOverlay in a Javascript web app.
  2. Switch to GeoRust and write a wrapper. Because iOverlay doesn't have all the features we need (e.g. calculate area, convex check) and GeoRust doesn't compile to WASM. GeoRust is the most popular Rust geometry library and uses iOverlay as a dependency.
  3. Write a full backend. Because passing (copying) a lot of data is slow.

Further reading: https://kylebarron.dev/blog/geos-wasm (p.s. GEOS says it's a port of JTS, not the other way around.)

To do

  • Use std::sync::LazyLock instead of instance? (Not recommended in general)
  • Use WASM's linear memory in JS?
  • Import JS functions to Rust to avoid data copy and using structs to pass data.
  • Multi-threading?

About

georust wrapper for my homework

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors