joint_compute_node is a comparison sample that uses the same ComputePhysicsSpace GPU Joint scenario as joint_compute, but synchronizes the computed state into ordinary CPU-side Node objects before drawing. It makes the boundary between GPU physics, readback, syncNodesFromPhysics(), and standard Space.draw() explicit. The shared initial scenario is defined in jointScenario.js.
http://localhost:8765/samples/joint/joint_compute_node.html
joint_computejoint_compute reads the ping-pong BodyState directly from a vertex shader. This sample records ComputePhysicsSpace.encodeStateReadback(), submits the command buffer, reads the state with readStateReadback(), and updates ordinary Node transforms with syncNodesFromPhysics(). Rendering then uses Space.draw() and SmoothShader, without a Compute-specific renderer.
WebgApp owns the command encoder for the normal frame path. onBeforeDraw closes the default Render Pass, records the Compute work and readback copy into the same encoder, and reopens a Render Pass for Node drawing. WebgApp closes the pass, resolves the FrameTimer GPU queries, and calls queue.submit() at the end of the frame; the next frame’s onUpdate starts the asynchronous readback. This keeps GPU timing queries and the physics readback in one command buffer.
The GPU-to-CPU transfer and Node updates cost more than GPU-direct rendering for a large number of bodies. The benefit is that the normal Shape, Node, and WebgApp rendering path remains available. Because readback is asynchronous, a completed state is shown on a subsequent frame, with a readback delay between GPU state and display.
The sample registers six hanging ropes, a DistanceJoint pendulum, and a kinematic Capsule crossing the rope centers. The contact setup includes the rope links and driver Capsule. The palette is intentionally different from joint_compute: green/lime ropes, a red pendulum Sphere, a cyan driver Capsule, and a gold visual connector.
A / D: move the driver Capsule left/rightQ: quasiStatic, prescribing position with zero contact velocityI: impact, passing the prescribed velocity to the contact solverP: pause/resumeR: reset the bodies, Joints, and Node displayH: show/hide the Help PanelThe Help Panel starts visible with its body collapsed. Press H to show or hide it
ComputePhysicsSpace.encodeFixedStep()
-> encodeStateReadback()
-> queue.submit()
-> readStateReadback()
-> syncNodesFromPhysics()
-> Space.draw()
The ComputeSphereCollider / ComputeCapsuleCollider physics bodies and the normal rendering Shape objects are separate. Place visual Node objects in Space, and register GPU-simulated bodies separately as descriptors in ComputePhysicsSpace. This corresponds to the “Two Ways to Render Compute State” section in Chapter 27, Physics.
joint/
joint_compute_node.js
joint_compute_node.html
joint_compute_node.md / joint_compute_node.en.md
jointScenario.js
index.html / index.en.html