@vuer-ai/vuer-sim
v0.0.1
Published
Simulation material editing for vuer: material tables, physics and sensor material editors, and a 3D property overlay.
Keywords
Readme
@vuer-ai/vuer-sim
Material editing for vuer simulation scenes: the
TypeScript half of vuer-sim. It edits the
material table that Python stores in <bundle>/materials.json (physics materials
for MuJoCo and USD, and LiDAR/depth sensor materials), and saves it back through a
vuer event so that Python writes the file.

Install
pnpm add @vuer-ai/vuer-sim @dreamlake/uikit react react-dom lucide-react three @react-three/fiber @react-three/drei
# inside a vuer app, for useVuerTransport:
pnpm add @vuer-ai/vuerThe package is not on npm yet. Peers: @dreamlake/uikit ^0.3.0, React 18+, three,
@react-three/fiber, @react-three/drei, and @vuer-ai/vuer ^0.0.103 || ^0.1.0 (optional; only the
@vuer-ai/vuer-sim/vuer entry imports it). Set up the uikit stylesheet as its
README says; this package styles itself with the uikit CSS variables, so it needs
no Tailwind scan of its own.
Usage
import { Canvas } from '@react-three/fiber'
import {
MaterialInspector, OverlayLegend, SensorMaterialOverlay,
createWebSocketTransport, useMaterialTable,
} from '@vuer-ai/vuer-sim'
const transport = createWebSocketTransport('ws://localhost:8012')
function Editor() {
const editor = useMaterialTable(transport) // sends VUER_SIM_MATERIALS_LOAD
const [geom, setGeom] = useState(null)
return (
<>
<Canvas>
<SensorMaterialOverlay geoms={editor.scene} table={editor.table}
property="restitution" selected={geom?.name} onSelect={setGeom} />
</Canvas>
<OverlayLegend property="restitution" />
<MaterialInspector geom={geom} editing={editor} timestep={0.002} />
<button disabled={!editor.dirty} onClick={editor.save}>Save</button>
</>
)
}Inside a <Vuer> app, use the app's socket instead of a second connection:
import { useVuerTransport, useMaterialTable } from '@vuer-ai/vuer-sim/vuer'
const editor = useMaterialTable(useVuerTransport())On the Python side (pip install 'vuer-sim[viewer]'):
from vuer import Vuer
from vuer_sim.viewer import attach
app = Vuer()
attach(app, "path/to/bundle", scene=scene_summary(model)) # handles load and save
app.run()Exports
| Export | What it does |
| --- | --- |
| useMaterialTable(transport) | Load, edit (setPhysics, setSensor, assign, addMaterial, setTable) and save() a table. State: table, scene, loaded, dirty, saving, revision, error, path, savedAt. |
| MaterialInspector | The selected geom's material: assignment (by geom or by visual material) and the physics or sensor part. |
| PhysicsMaterialEditor | Friction, restitution (with the derived solref damping ratio), density, solref time constant, solimp, condim, priority, margin. Warns when timestep > timeconst * min(0.5, dampratio). |
| SensorMaterialEditor | LiDAR reflectivity, dropout, depth noise, intensity override, transparent. |
| SensorMaterialOverlay | r3f group that draws the scene geoms coloured by a property (friction, restitution, density, lidar_reflectivity, dropout, transparent). |
| OverlayLegend, overlayColors | The legend, and the pure colour function behind the overlay. |
| parseTable, serializeTable, resolve | The stored format (byte-identical to Python) and the assignment rules. |
| restitutionToDampratio, dampratioToRestitution, setRestitution | The restitution mapping, identical to Python. |
| createWebSocketTransport, createLocalTransport | Transports: vuer's wire protocol over a plain WebSocket, or in memory. |
| useVuerTransport (/vuer) | Transport over useSocket() of @vuer-ai/vuer. |
Protocol
| Client -> server | Server -> client |
| --- | --- |
| VUER_SIM_MATERIALS_LOAD {} | VUER_SIM_MATERIALS {json, path, saved: false, revision, scene} |
| VUER_SIM_MATERIALS_SAVE {json, revision} | VUER_SIM_MATERIALS {json, path, saved: true, revision}, or {error, revision} |
The table travels as its stored JSON text, because vuer packs server floats as
float32. revision counts saves; the server refuses a save from a stale revision.
Development
pnpm install
pnpm check:specs && pnpm lint && pnpm typecheck && pnpm test # what PR CI runs
pnpm build # manual dispatch in CI
pnpm demo # the editor; ?ws=ws://localhost:8012 (default) &theme=light|darkRun the Python side with uv run --group heavy python examples/edit_materials.py
in vuer-ai/vuer-sim. scripts/screenshot.py runs both, edits a material in a real
browser, checks the saved file and writes docs/editor-{light,dark}.png (local only).
Release
As in vuer-ts: bump version in package.json, commit Release vX.Y.Z - <summary>,
merge, tag vX.Y.Z on main, then pnpm publish --access public once the owner
approves publishing.
License
MIT
