Software
MeshCat
By meshcat-dev, from github.com/meshcat-dev/meshcat (opens in a new tab)
- Middleware
- Tool
- MIT
MeshCat is a browser-based 3D viewer built on three.js that is controlled remotely by sending geometry and transform commands over WebSockets, so it can be driven from other languages.
Facts
- GitHub stars
- 344read on 28 Nov 2026
- Last update
- 25 Jun 2026Newest commit on master
- Maintenance
- Maintaineda commit in the last 12 months
- Difficulty
- Intermediate
- Hardware it needs, as the project states it
- A web browser that supports WebSockets and WebGL-based rendering.
Checked on GitHub on 28 Nov 2026.
Licenses
- Code
- MIT (opens in a new tab)
Read by Robotheca from LICENSE (opens in a new tab) (MIT) at commit f9dd4cc (opens in a new tab), on 16 Oct 2026.
- Commercial use
- Yes
At a glance
- What it is
- Runs in a browser and listens for geometry commands sent over WebSockets, building a tree of objects and transforms.
- Can be used programmatically from JavaScript through a Viewer constructor and a handle_command function.
- Accepts Three.js object JSON, plus extensions for mesh files in obj, dae and stl formats.
- Supports lines with configurable width via LineGeometry and LineMaterial, and text rendered as textures.
- Offers commands to set objects, transforms, properties, animations, camera target, and capture images.
- Has interfaces in other languages, including meshcat-python and MeshCat.jl for Julia.
Robotheca's summary of the project's documents, not the creator's words.
- Robots on Robotheca
- Used by AlohaScorpion, Dual Scorpion and Roboto Origin.
- Licence
- MIT. Commercial use: Yes. Where it was read
- Install
- In the creator's words: The project's README (opens in a new tab)
- Maintenance
- Maintained, last commit on 25 Jun 2026.
Works with
The robots on Robotheca that use it or can run it, each with how the link was found.
- No photo yet
Found by Robotheca in requirements-macos.txt (opens in a new tab)
- Ready to build

Open source · free files
Dual Scorpion
Robot arm · Advanced
- Score
- Buildability 100 out of 100
- Cost
- $486.88≈ €447
Found by Robotheca in requirements-macos.txt (opens in a new tab)
Ready to build Open source · free files
Roboto Origin
Humanoid · Advanced
- Score
- Buildability 87 out of 100
- Cost
- ¥49,713≈ €6,860
Found by Robotheca in modules/roboparty_xr_teleop/requirements.txt (opens in a new tab)
Use it
How to install it, in the creator's words: The project's README (opens in a new tab)
Robotheca doesn't review code. Read it before running it.
Files and versions
- Repository on GitHubgithub.com/meshcat-dev/meshcat (opens in a new tab)
- The version Robotheca readf9dd4cc (opens in a new tab)
- Latest releasev0.1.0 (29 Aug 2021)
Robotheca never hosts the code: each link goes to the creator's own page.
The README
The creator's own README, copied as written: Readme.md by meshcat-dev, at commit f9dd4cc, under MIT (opens in a new tab). The original on GitHub (opens in a new tab).
Read the README here
MeshCat
MeshCat is a remotely-controllable 3D viewer, built on top of three.js (opens in a new tab). The MeshCat viewer runs in a browser and listens for geometry commands over WebSockets. This makes it easy to create a tree of objects and transformations by sending the appropriate commands over the websocket.
The MeshCat viewer is meant to be combined with an interface in the language of your choice. Current interfaces are:
API
MeshCat can be used programmatically from JS or over a WebSocket connection.
Programmatic API
To create a new MeshCat viewer, use the Viewer constructor:
let viewer = new MeshCat.Viewer(dom_element);
where dom_element is the div in which the viewer should live. The primary interface to the viewer is the handle_command function, which maps directly to the behaviors available over the WebSocket.
Handle a single command and update the viewer. cmd should be a JS object with at least the field type.
Path model (applies to every command that takes a path): MeshCat uses a two-layer node model: a "container" node and a "renderable" node. Typical user paths (e.g., /meshcat/foo) refer to container nodes. When present (see set_object()), the corresponding renderable node is at /meshcat/foo/<object>. The container node services hierarchical operations (e.g., transformations, visibility, etc.). The renderable node contains the concrete 3D object and its intrinsic properties. This separation preserves the distinction between container-level transforms and the object's intrinsic frame (for example, geometry-local pose encoded in the object's matrix).
In every command that takes a path, following that path creates any missing container nodes along the path. Automatically-created nodes will not necessarily produce visible artifacts; default placeholder nodes have no visible features. A renderable node is created when a command explicitly targets .../<object>, or when set_object() is called on a container path (equivalently, on that path with a trailing /<object>).
Available command types are:
<dl>
<dt><code>set_object</code></dt>
<dd>
Set (or replace) the renderable object associated with the container node named by <code>path</code> using the provided JSON description. Any transforms previously applied at that container path are preserved, and existing children of that container remain. To remove transforms and delete children first, send a <code>delete</code> command on that path (see below).
The object will be assigned to the renderable node associated with the path. As such, the two paths /foo/bar and /foo/bar/<object> are equivalent. By convention, use the container form (/foo/bar) when calling set_object.
Additional fields:
<dl>
<dt><code>path</code></dt>
<dd>A <code>"/"</code>-delimited string indicating the container path in the scene tree (for example, <code>"/foo/bar"</code>). The form <code>"/foo/bar/<object>"</code> is also accepted and treated identically. A container at path <code>"/foo/bar"</code> is a child of a container at path <code>"/foo"</code>, so setting the transform of (or deleting) <code>"/foo"</code> also affects its descendants.
<dt><code>object</code></dt>
<dd>The Three.js Object, with its geometry and material, in JSON form as a JS object. The nominal format accepted is anything that [ObjectLoader](https://threejs.org/docs/#api/loaders/ObjectLoader) can handle (i.e., anything you might get by calling the <code>toJSON()</code> method of a Three.js Object3D).
Beyond the nominal format, Meshcat also offers a few extensions for convenience: Within the geometries stanza, the type field can be set to "_meshfile_geometry" to parse using a mesh file format. In this case, the geometry must also have a field named format set to one of "obj" or "dae" or "stl" and a field named "data" with the string contents of the file. Within the geometries stanza, the type field can be set to "LineGeometry" to create lines with configurable width (works in all modern browsers). See the Line2 example below for details. Within the materials stanza, the type field can be set to "_text" to use a string as the texture (i.e., a font rendered onto an image). In this case, the material must also have fields named font_size (in pixels), font_face (a string), and text (the words to render into a texture). Within the materials stanza, the type field can be set to "LineMaterial" to create materials for Line2 objects with configurable line width. See the Line2 example below for details. Within the inner object stanza (i.e., the object with a uuid, not the object argument to set_object), the type field can be set to "_meshfile_object" to parse using a mesh file format. In this case, the geometries and materials and geometry: {uuid} and material: {uuid} are all ignored, and the object must have a field named format set to one of "obj" or "dae" or "stl" and a field named "data" with the string contents of the file. When the format is obj, the object may also have a field named mtl_library with the string contents of the associated mtl file. Within the inner object stanza, the type field can be set to "Line2" to render lines with configurable width using LineGeometry and LineMaterial. See the Line2 example below for details.
Example (nominal format): { type: "set_object", path: "/meshcat/boxes/box1", object: { metadata: {version: 4.5, type: "Object"}, geometries: [ { uuid: "cef79e52-526d-4263-b595-04fa2705974e", type: "BoxGeometry", width: 1, height: 1, depth:1 } ], materials: [ { uuid: "0767ae32-eb34-450c-b65f-3ae57a1102c3", type: "MeshLambertMaterial", color: 16777215, emissive: 0, side: 2, depthFunc: 3, depthTest: true, depthWrite: true } ], object: { uuid: "00c2baef-9600-4c6b-b88d-7e82c40e004f", type: "Mesh", geometry: "cef79e52-526d-4263-b595-04fa2705974e", material: "0767ae32-eb34-450c-b65f-3ae57a1102c3" } } } Note the somewhat indirect way in which geometries and materials are specified. Each Three.js serialized object has a list of geometries and a list of materials, each with a UUID. The actual geometry and material for a given object are simply references to those existing UUIDs. This enables easy re-use of geometries between objects in Three.js, although we don't really rely on that in MeshCat. Some information about the JSON object format can be found on the Three.js wiki (opens in a new tab).
Example (_meshfile_geometry): { type: "set_object", path: "/some/file/geometry", object: { metadata: { version: 4.5, type: "Object" }, geometries: [ { type: "_meshfile_geometry", uuid: "4a08da6b-bbc6-11ee-b7a2-4b79088b524d", format: "obj", data: "v -0.06470900 ..." } ], images: [ { uuid: "c448fc3a-bbc6-11ee-b7a2-4b79088b524d", url: "data:image/png;base64,iVBORw0KGgoAAA==" } ], textures: [ { uuid: "d442ea92-bbc6-11ee-b7a2-4b79088b524d", wrap: [1001, 1001], repeat: [1, 1], image: "c448fc3a-bbc6-11ee-b7a2-4b79088b524d" } ], materials: [ { uuid: "4a08da6e-bbc6-11ee-b7a2-4b79088b524d", type: "MeshLambertMaterial", color: 16777215, reflectivity: 0.5, map: "d442ea92-bbc6-11ee-b7a2-4b79088b524d" } ], object: { uuid: "4a08da6f-bbc6-11ee-b7a2-4b79088b524d", type: "Mesh", geometry: "4a08da6b-bbc6-11ee-b7a2-4b79088b524d", material: "4a08da6e-bbc6-11ee-b7a2-4b79088b524d" } } }
Example (_text): { type: "set_object", path: "/meshcat/text", object: { metadata: { version: 4.5, type: "Object" }, geometries: [ { uuid: "6fe70119-bba7-11ee-b7a2-4b79088b524d", type: "PlaneGeometry", width: 8, height: 8, widthSegments: 1, heightSegments: 1 } ], textures: [ { uuid: "0c8c99a8-bba8-11ee-b7a2-4b79088b524d", type: "_text", text: "Hello, world!", font_size: 300, font_face: "sans-serif" } ], materials: [ { uuid: "6fe7011b-bba7-11ee-b7a2-4b79088b524d", type: "MeshPhongMaterial", transparent: true, map: "0c8c99a8-bba8-11ee-b7a2-4b79088b524d", } ], object: { uuid: "6fe7011c-bba7-11ee-b7a2-4b79088b524d", type: "Mesh", geometry: "6fe70119-bba7-11ee-b7a2-4b79088b524d", material: "6fe7011b-bba7-11ee-b7a2-4b79088b524d", } } }
Example (_meshfile_object): { type: "set_object", path: "/meshcat/wavefront_file", object: { metadata: {version: 4.5, type: "Object"}, object: { uuid: "00c2baef-9600-4c6b-b88d-7e82c40e004f", type: "_meshfile_object", format: "obj", data: "mtllib ./cube.mtl\nusemtl material_0\nv 0.0 0.0 0.0 ...", mtl_library: "newmtl material_0\nKa 0.2 0.2 0.2\n ...", resources: {"cube.png": "data:image/png;base64,iV ..."} } } }
Check test/meshfile_object_obj.html for the full demo.
Example (Line2 with LineGeometry and LineMaterial):
Modern browsers don't support the GL_LINEWIDTH parameter, so standard Line objects won't show varying line widths. MeshCat supports Line2 objects with LineGeometry and LineMaterial for lines with configurable properties.
<pre>
{ type: "set_object", path: "/meshcat/fatline", object: { metadata: {version: 4.5, type: "Object"}, geometries: [ { uuid: "6fe70119-bba7-11ee-b7a2-4b79088b524d", type: "LineGeometry", position: { array: new Float32Array([0, 0, 0, 1, 0, 0, 1, 1, 0]) }, color: { array: new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]) } } ], materials: [ { uuid: "6fe7011b-bba7-11ee-b7a2-4b79088b524d", type: "LineMaterial", color: 16777215, linewidth: 5.0, vertexColors: true, dashed: false, worldUnits: false } ], object: { uuid: "6fe7011c-bba7-11ee-b7a2-4b79088b524d", type: "Line2", geometry: "6fe70119-bba7-11ee-b7a2-4b79088b524d", material: "6fe7011b-bba7-11ee-b7a2-4b79088b524d" } } }
LineGeometry supports these attributes:
<ul>
<li><code>position</code>: Float32Array of vertex positions (x, y, z, x, y, z, ...)
<li><code>color</code>: (optional) Float32Array of per-vertex RGB colors (r, g, b, r, g, b, ...)
</ul>
LineMaterial supports the exact same attributes as documented in the Three.js LineMaterial docs (opens in a new tab).
Check test/fatlines.html for a full demo.
</dd>
<dt><code>set_transform</code></dt>
<dd>
Set the homogeneous transform for a given path in the scene tree. An object's pose is the concatenation of all of the transforms along its path, so setting the transform of <code>"/foo"</code> will move the objects at <code>"/foo/box1"</code> and <code>"/foo/robots/HAL9000"</code>.
Additional fields:
<dl>
<dt><code>path</code></dt>
<dd>A <code>"/"</code>-separated string indicating the object's path in the scene tree. An object at path <code>"/foo/bar"</code> is a child of an object at path <code>"/foo"</code>, so setting the transform of (or deleting) <code>"/foo"</code> will also affect its children.
<dt><code>matrix</code></dt>
<dd>
The homogeneous transformation matrix, given as a 16-element <code>Float32Array</code> in column-major order.
</dd>
</dl>
Example:
<pre>
{ type: "set_transform", path: "/meshcat/boxes", matrix: new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5, 0.0, 0.5, 1]) } delete Delete the object at the given path as well as all of its children.
Additional fields:
<dl>
<dt><code>path</code></dt>
<dd>A <code>"/"</code>-separated string indicating the object's path in the scene tree. An object at path <code>"/foo/bar"</code> is a child of an object at path <code>"/foo"</code>, so setting the transform of (or deleting) <code>"/foo"</code> will also affect its children.
</dl>
Example:
<pre>
{ type: "delete", path: "/meshcat/boxes" } set_property Set a single named property at the given path. If no node exists at that path, missing container nodes are created automatically.
Under the two-layer path model, use a container path (for example, /meshcat/foo) for container-level operations, and use /meshcat/foo/<object> for properties on the renderable object itself.
Additional fields:
<dl>
<dt><code>property</code></dt>
<dd>
The property name to set, as a string.
Property categories
MeshCat supports three categories for <code>property</code>:
<ul>
<li><strong>Convenience properties</strong> are short aliases for assigning values to standard scene-graph properties.
<li><strong>Custom properties</strong> are Meshcat-specific properties that enable custom behavior and are not part of three.js.
<li><strong>Literal properties</strong> are interpreted as literal javascript properties of the object named by the path. The property could be a direct property of the named object (e.g., "type"), or a "chained" property (e.g., "material.map.repeat.x").
</ul>
The following names are convenience properties:
<ul>
<li><code>visible: bool</code>
<li><code>position: number[3]</code>
<li><code>quaternion: number[4]</code>
<li><code>scale: number[3]</code>
<li><code>color: number[4]</code>
<li><code>opacity: number</code> (this is the same as the 4th element of <code>color</code>)
<li><code>modulated_opacity: number</code>
<li><code>top_color: number[3]</code> (only for the Background)
<li><code>bottom_color: number[3]</code> (only for the Background)
</ul>
The following are Meshcat's custom behaviors and their corresponding properties:
<ul>
<li>
<strong>Texture crawl</strong>.
MeshCat provides a feature that will cause the texture on an object to appear to "crawl" along the surface (useful for visualizing tank treads or conveyor belts). The textures are displaced across the surface of the geometry by rotating around a "crawl" axis. By repeatedly updating the displacement amount with respect to time, the texture will appear to crawl around the object.
The properties are:
<ul>
<li><code>crawl_axis</code> a direction, specified in the <strong>geometry</strong> frame (thereby moving with the geometry). The vector must have nonzero length; MeshCat normalizes it internally and uses it only as a direction.</li>
<li><code>crawl_displacement</code> is a distance measure (world-frame scalar distance) indicating the amount the texture should be displaced.</li>
</ul>
The object(s) must have texture coordinates and texture(s) applied.
The "geometry frame" refers to the container frame as this typically contains the pose for the geometry as defined by the external application. For example, when setting crawl_axis on /meshcat/textured_mesh, the axis is expressed in the frame of /meshcat/textured_mesh. As such, this propery (like e.g., position or quaternion) is a container property.
Limitations: Crawling textures only produce physically meaningful results on geometries whose UV layout is compatible with uniform translation. Specifically, the texture must tile seamlessly (using RepeatWrapping) and the UV parameterization must be laid out so that a constant UV offset corresponds to a coherent physical slide across the surface in the crawl direction. Geometries with UV seams, strong UV distortion (e.g., poles of a sphere), or UV atlases where adjacent surface regions map to disjoint parts of the texture image will exhibit tiling artifacts or discontinuous motion. Flat or gently-curved surfaces textured with a uniformly tiling pattern (such as a box or plane with a repeating texture) are the typical well-behaved use case.
</li>
</ul>
Any property name not listed in the convenience or custom properties is evaluated as a literal property on the target object. Chained names (e.g., material.shininess), and are resolved left-to-right so the final name in the chain receives value.
Timing and replay semantics
<ul>
<li>Referencing missing nodes in the <code>path</code> will create those missing nodes. In contrast, naming a missing property does not create that property.
<li>If the property name is an <strong>invalid</strong> chained property that cannot be resolved, Meshcat writes an error to the console and does not assign the value. The chained property cannot be resolved when a named component in the chain is missing or if a named component's property is referenced, but the component has no properties itself.
<li>Property chains can include array indexing syntax such as <code>children[1].material.specular</code>. In error messages, this may appear as <code>children.1</code>.</li>
<li>Calling set_property() before calling set_object() on the same path should generally be considered an error. Unless you are setting a property on a container node, the property will most likely have no effect.
</ul>
</dd>
<dt><code>value</code></dt>
<dd>The new value.</dd>
</dl>
Example 1:
<pre>
{ type: "set_property", path: "/Cameras/default/rotated/<object>", property: "zoom", value: 2.0 } Example 2: { type: "set_property", path: "/Lights/DirectionalLight/<object>", property: "intensity", value: 1.0 } Example 3 (chained properties): { type: "set_property", path: "/Lights/SpotLight/<object>", property: "shadow.radius", value: 1.0 } Example 4 (crawling texture): { type: "set_property", path: "/meshcat/textured_mesh", property: "crawl_axis", value: [1.0, 0.0, 0.0] } { type: "set_property", path: "/meshcat/textured_mesh", property: "crawl_displacement", value: 0.125 } set_animation Create an animation of any number of properties on any number of objects in the scene tree, and optionally start playing that animation.
Additional fields:
<dl>
<dt><code>animations</code></dt>
<dd>
A list of objects, each with two fields:
<dl>
<dt><code>path</code></dt>
<dd>
The path to the object whose property is begin animated. As with <code>set_property</code> above, you will need to append <code><object></code> to the path to set an object's intrinsic property.
</dd>
<dt><code>clip</code></dt>
<dd>
A Three.js <code>AnimationClip</code> in JSON form. The clip in turn has the following fields:
<dl>
<dt><code>fps</code></dt>
<dd>
The frame rate of the clip
</dd>
<dt><code>name</code></dt>
<dd>
A name for this clip. Not currently used.
</dd>
<dt><code>tracks</code></dt>
<dd>
The tracks (i.e. the properties to animate for this particular object. In Three.js, it is possible for a track to specify the name of the object it is attached to, and Three.js will automatically perform a depth-first search for a child object with that name. We choose to ignore that feature, since MeshCat already has unambiguous paths. So each track should just specify a property in its <code>name</code> field, with a single <code>"."</code> before that property name to signify that it applies to exactly the object given by the <code>path</code> above.
Each track has the following fields:
<dl>
<dt><code>name</code></dt>
<dd>
The property to be animated, with a leading <code>"."</code> (e.g. <code>".position"</code>)
</dd>
<dt><code>type</code></dt>
<dd>
The Three.js data type of the property being animated (e.g. <code>"vector3"</code> for the <code>position</code> property)
</dd>
<dt><code>keys</code></dt>
<dd>
The keyframes of the animation. The format is a list of objects, each with a field <code>time</code> (in frames) and <code>value</code> indicating the value of the animated property at that time.
</dd>
</dl>
</dd>
</dl>
</dd>
</dl>
</dd>
<dt><code>options</code></dt>
<dd>
Additional options controlling the animation. Currently supported values are:
<dl>
<dt><code>play</code></dt>
<dd>Boolean [true]. Controls whether the animation should play immediately.</dd>
<dt><code>repetitions</code></dt>
<dd>Integer [1]. Controls the number of repetitions of the animation each time you play it.</dd>
</dl>
</dd>
</dl>
Example:
<pre>
{ type: "set_animation", animations: [{ path: "/Cameras/default", clip: { fps: 30, name: "default", tracks: [{ name: ".position" type: "vector3", keys: [{ time: 0, value: [0, 1, .3] },{ time: 80, value: [0, 1, 2] }], }] } },{ path: "/meshcat/boxes", clip: { fps: 30, name: "default", tracks: [{ name: ".position" type: "vector3", keys: [{ time: 0, value: [0, 1, 0] },{ time: 80, value: [0, -1, 0] }], }] } }], options: { play: true, repetitions: 1 } } set_target Set the target of the 3D camera, around which it rotates. This is expressed in a left-handed coordinate system where y is up.
Example:
<pre>
{
"type": "set_target",
value: [0., 1., 0.]
}
This sets the camera target to (0, 1, 0)
capture_image
Capture an image from the viewport. At the moment it will return the image at a provided resolution (by default 1920x1080).
{
"type": "capture_image",
"xres": 1920,
"yres": 1080
}
This sets the camera target to (0, 1, 0)
set_render_callback
Each render loop updates the camera, renders the scene and updates
animation. Between updating the camera and rendering the scene,
the Viewer invokes a user-configurable callback. This callback
can be used to execute arbitrary code per rendered frame.
The callback is evaluated in a scope such that the Viewer
instance is available as `this`. In declaring the
command, the callback should be a *string* that gets evaluated
into a function. Passing the string "null" will restore the
render callback to being its default no-op function.
For example, the following is an example callback that dispatches
the camera's pose in the world to the open websocket connection.
<pre>
{
"type": "set_render_callback",
"callback": () => { if (this.is_perspective()) { if (this.connection.readyState == 1 /* OPEN */) { this.connection.send(msgpack.encode({ 'type': 'camera_pose', 'camera_pose': this.camera.matrixWorld.elements })); } } }
}
This dispatches the camera's pose in the world to the websocket
connection.
WebSocket API
Note that we do support the MsgPack extension types listed in [msgpack-javascript#extension-types](https://github.com/msgpack/msgpack-javascript#extension-types), with additional support for the <code>Float32Array</code> type which is particularly useful for efficiently sending point data and for <code>Uint32Array</code>, <code>Uint8Array</code>, and <code>Int32Array</code>.
</dd>
Setting opacity
Objects can have their opacity changed in the obvious way, i.e.:
This would assign the opacity value 0.5 to all of the materials found rooted
at "/path/to/my/geometry". (That means using the path "/path" could affect
many geometries.) However, this will overwrite whatever opacity the geometry had
inherently (i.e., from the material defined in the mesh file); a transparent
object could become more opaque.
Meshcat offers a pseudo property "modulated_opacity". Meshcat remembers an object's inherent opacity and, by setting this value, sets the rendered opacity to be the product of the inherent and modulated opacity value. The corresponding command would be:
Setting "modulated_opacity" to 1 will restore the geometry's original
opacity. This does not introduce a queryable modulated_opacity property on
any material. This is what makes it a "pseudo" property. The same tree-based
scope of effect applies to "modulated_opacity" as with "opacity" (and also
the "color" property).
Meshcat always remembers the inherent opacity value. So, if you've overwritten
the value (via setting "opacity" or "color"), you can restore it by setting
the "modulated_opacity" value to 1.0.
Useful Paths
The default MeshCat scene comes with a few objects at pre-set paths. You can replace, delete, or transform these objects just like anything else in the scene.
Camera Control
The camera is just another object in the MeshCat scene, so you can move it around with set_transform commands like any other object. You can also use set_target to change the camera's target. Please note that replacing the camera with set_object is not currently supported (but we expect to implement this in the future).
Controlling the camera is slightly more complicated than moving a single object because the camera actually has two important poses: the origin about which the camera orbits when you click-and-drag with the mouse, and the position of the camera itself. In addition, cameras and controls in Three.js assume a coordinate system in which the Y axis is upward. In robotics, we typically have the Z axis pointing up, and that's what's done in MeshCat. To account for this, the actual camera lives inside a few path elements:
/Cameras/default/rotated/<object>
The /rotated path element exists to remind users that its transform has been rotated to a Y-up coordinate system for the camera inside.
There is one additional complication: the built-in orbit and pan controls (which allow the user to move the view with their mouse) use the translation of only the intrinsic transform of the camera object itself to determine the radius of the orbit. That means that, in practice, you can allow the user to orbit by setting the position property at the path /Cameras/default/rotated/<object> to a nonzero value like [2, 0, 0], or you can lock the orbit controls by setting the position property at that path to [0, 0, 0]. Remember that whatever translation you choose is in the rotated, Y-up coordinate system that the Three.js camera expects. We're sorry.
Examples
To move the camera's center of attention to the point [1, 2, 3], while still allowing the user to orbit and pan manually, we suggest setting the transform of the /Cameras/default path to whatever center point you want and setting the position property of /Cameras/default/rotated/<object> to [2, 0, 0]. That means sending two commands:
{
type: "set_transform",
path: "/Cameras/default",
matrix: new Float32Array([1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
1, 2, 3, 1]) // the translation here is the camera's
// center of attention
},
{
type: "set_property",
path: "/Cameras/default/rotated/<object>",
property: "position",
value: [2, 0, 0] // the offset of the camera about its point of rotation
}
To move the camera itself to the point [1, 2, 3] and lock its controls, we suggest setting the transform of /Cameras/default to the exact camera pose and setting the position property of /Cameras/default/rotated/<object> to [0, 0, 0]:
{
type: "set_transform",
path: "/Cameras/default",
matrix: new Float32Array([1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
1, 2, 3, 1]) // the translation here is now the camera's
// exact pose
},
{
type: "set_property",
path: "/Cameras/default/rotated/<object>",
property: "position",
value: [0, 0, 0] // set to zero to lock the camera controls
}
Developing MeshCat
The MeshCat javascript sources live in src/index.js. We use webpack (opens in a new tab) to bundle up MeshCat with its Three.js dependencies into a single javascript bundle. If you want to edit the MeshCat source, you'll need to regenerate that bundle. Fortunately, it's pretty easy:
Option 1: Use Docker
If you have Docker + BuildKit installed, then you can run rebuild/rebuild.sh
to hermetically regenerate the dist files. The very first time you run it, it
might take a little time to download all of the relevant files. Subsequent runs
should be much faster (~5-10 seconds).
This option offers the easiest way to rebuild, with the drawback that "watch" mode of webpack (to automatically rebuild every time you save) is unavailable.
To install Docker + BuildKit on Ubuntu, run:
sudo apt install docker.io docker-buildx
To run as non-root, you will probably also need to update the docker group
permissions:
https://docs.docker.com/engine/install/linux-postinstall/ (opens in a new tab)
Option 2: Install Yarn + NPM tools
This option offers a convenient "watch" mode during an edit-test development cycle, but if you're not careful when installing the yarn+node+npm tools you might damage other software on your computer.
- Install yarn (opens in a new tab). This should also install
nodeandnpm. Try runningyarn -vandnpm -vto make sure those programs are installed. - Run
yarn- This will read the
project.jsonfile and install all the necessary javascript dependencies.
- This will read the
- Run
yarn build- This will run webpack and create the bundled output in
dist/main.min.js. The build script will also watch for changes to the MeshCat source files and regenerate the bundle whenever those source files change.
- This will run webpack and create the bundled output in
- Try it out! You can load the bundled
main.min.jsin your own application, or you can open updist/index.htmlin your browser.
Note that due to caching, you may need to do a hard refresh (shift+F5 or ctrl+shift+R) in your browser to reload the updated javascript bundle.
Robotheca lists software as a reference: nothing is hosted or run here, and every fact links to where it was read.