Skip to content

eulerjs API / @eulerjs/scene

@eulerjs/scene ​

Physics for a three.js scene, read from it: ScenePhysics makes the bodies its objects' userData.physics asks for, and EulerPhysics() is a drop-in for three.js's RapierPhysics, JoltPhysics and AmmoPhysics addons.

Classes ​

ClassDescription
ScenePhysicsMakes the bodies for a three.js scene from what its objects say about themselves, in userData.physics (see PhysicsData). Use it with world.use(new ScenePhysics()).

Interfaces ​

InterfaceDescription
EulerPhysicsAPIWhat EulerPhysics() hands back: three.js's RapierPhysics, JoltPhysics and AmmoPhysics API, on eulerjs.
EulerPhysicsOptions-
PhysicsDataWhat an object's userData.physics says about it: three.js's own convention, as its RapierPhysics, JoltPhysics and AmmoPhysics read it (mass and restitution), and a little more. A glTF node's extras arrive in userData, so a Blender custom property physics comes through as this.

Functions ​

FunctionDescription
EulerPhysicseulerjs as three.js's physics addons are: await EulerPhysics() in place of await RapierPhysics(), and the rest of an example runs as it was. It steps on its own, 60 times a second, as they do, but at a fixed timestep, so the same scene always plays out the same way.
primitiveShapeThe primitive collider a geometry is, from three.js's own geometries: a box for BoxGeometry, its hull for RoundedBoxGeometry (convex, and rounder than a box), a sphere for SphereGeometry and IcosahedronGeometry, a cylinder, a cone or a capsule for theirs. Only while the geometry is still the shape its parameters say, centred on its origin and standing along y, as three.js made it: one translated, turned or cut since (a half sphere, a slice of a cylinder) isn't, nor is a round one with too few sides to be round (see ROUNDNESS), and neither is one that scale stretches out of round. Undefined for those and for any other geometry.

Released under the MIT License.