Skip to content

EralChen/heatmap-points-wasm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

三维热力图插值

demo

vite 中使用

vite.config.js

import { defineConfig } from 'vite';
import wasm from 'vite-plugin-wasm';
export default defineConfig({
  plugins: [wasm()],
});

main.js

import { interpolate_wasm } from 'heatmap-points-wasm';
const inputPoints = [
    { x: 0, y: 0, z: 0, value: 1 },
    { x: 1, y: 1, z: 1, value: 2 },
    { x: 2, y: 2, z: 2, value: 3 },
];
const interpolatedPoints = interpolate_wasm(
    JSON.stringify(inputPoints), // 输入点云数据的 JSON 字符串
    10, // grid size
);
console.log(JSON.parse(interpolatedPoints)); // 输出插值后的点云数据

项目结构

heatmap-points-wasm/
├── src/
│   ├── lib.rs              # WASM 库入口和导出函数
│   ├── main.rs             # Rust 可执行文件入口
│   └── interpolation.rs    # 核心插值算法实现
├── Cargo.toml              # Rust 项目配置
└── README.md               # 项目文档

环境要求

# 安装 Rust 参考官网   https://www.rust-lang.org/tools/install

# 添加 WASM 编译目标
rustup target add wasm32-unknown-unknown

# 安装 wasm-bindgen CLI 工具
cargo install wasm-bindgen-cli

开发相关

1. 构建 Rust 可执行文件

# 运行 main.rs
cargo run main

这将:

  • 执行三维插值计算
  • 输出插值结果统计信息
  • 生成 interpolated_point_cloud.json 文件

2. 构建 WASM 模块

# 打npm包
wasm-pack build

# 发布
cd pkg
npm publish --access public --registry https://registry.npmjs.org

APP

打包之后,进入 app 目录

cd app
npm install
npm run dev

即可以在浏览器中查看效果

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published