Discord
Login
Community
DARK THEME

cannon.js

How in this engine to make a box with initial settings such that the axes of the box coincide with the axes of the world. With each new frame, I rotate the box by a given angle. Now I want to know where this box is to draw it.

I rotate the new frame again by the angle I will give.

init = function()
  world = new CANNON.World()
  ground = new CANNON.Body(object
  mass = 0  // when the mass is set to zero, the object will be static
  shape = new CANNON.Plane() 
  end)
  world.addBody(ground)

  box = new CANNON.Box( new CANNON.Vec3(5, 15, 30))
  world.addBody( box )
end

Cannon only does the calculations the way I understand it. To draw the result you have to use your own routines to present the results.

In his demo @gilles uses Babylon, but one could also create his own 'visualizer' I think.

https://microstudio.dev/i/gilles/cannondemo/

Yeah, I'm currently experimenting with matter.js and, while it does have a renderer of it's own, I found it easiest to grab the vertices and pass them into a screen.drawPolygon function. I would presume the same thing would work with cannon, grab the shape and pass it to some 3d renderer (like babylon, or maybe a custom raytracer)

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community