Questions tagged [cannon.js]

cannon.js is a lightweight and simple 3D physics engine for the web.

cannon.js is a lightweight and simple 3D physics engine for the web.

What is cannon.js?

Inspired by three.js and ammo.js, and driven by the fact that the web lacks a physics engine, here comes cannon.js.

Features

  • Lightweight, smaller file size than physics engine ports, such as ammo.js and JigLibJS.
  • 100% open source JavaScript, written from scratch.
  • Uses an iterative Gauss-Seidel solver to solve constraints.
  • Uses the SPOOK stepper.
153 questions
11
votes
1 answer

cannon.js registering collision without colliding

I'm creating simple car game with cannon.js and I'm struggling with this. What I want to do: When I run with car into another object (e.g. sphere) I want to know about it. For example increase score or whatever, but without applying forces to both…
martinerk0
  • 403
  • 1
  • 4
  • 17
7
votes
0 answers

Cannon.js physics is too bouncy despite restitution set to 0

I want to simulate some blocks falling, but more like wooden blocks that don't have any elasticity or rubberiness to them. But I can't find settings that act like this. I've set restitution to 0 but there is still a lot of bounce when objects…
Jonathan Plackett
  • 2,346
  • 2
  • 20
  • 33
7
votes
1 answer

How to rotate a CannonJS RigidBody?

Does anyone know how I can rotate a CannonJS (the physics library) CANNON.RigidBody? I'm trying to make the object rotate with the camera, so both are facing the same direction. I know I have to modify the quaternion, but this doesn't work…
Joey Morani
  • 25,431
  • 32
  • 84
  • 131
6
votes
1 answer

Handling Proper Rotation of Cannon Body Based on Quaternion?

This one is bugging me quite a bit. I'm trying to achieve rotation of a Cannon.Body based on the mouse input. By using the (Cannon) Three FPS example to demonstrate, you can see what the issue…
Matt DeVenge
  • 111
  • 2
  • 8
5
votes
0 answers

useConvexPolyhedron collision on react-three/cannon clipping through object

I am having issues trying to make collision work properly with an imported glb file only used for collision. There are two parts to this question: I am currently getting a whole lot of faceNormal errors and vertices warnings in the…
5
votes
2 answers

Create CANNON.RigidBody from THREE.Mesh or THREE.Geometry

I am creating a THREE.Mesh object using a THREE.JSONLoader object like so: // Create castle. loader.load('/Meshes/CastleTower.js', function(geometry, materials) { var tmp_material = new THREE.MeshLambertMaterial(); …
rgajrawala
  • 2,148
  • 1
  • 22
  • 35
4
votes
1 answer

How to understand "useBox" in react-three-fiber

I'm interested in learning how to create dynamic objects and group them together entirely in react/JavaScript. I'm looking at the chair and table in this example as my model: https://codesandbox.io/s/ragdoll-physics-forked-bntr9 At this point, I'm…
NealWalters
  • 17,197
  • 42
  • 141
  • 251
4
votes
1 answer

Using Physics with an Imported Model in Three.js

I am learning Three.js. I am trying to use Cannon-es to attach a cylinder body to a rose mesh I created in blender allowing it to fall into a vase. My issue is when I try to update the rose's position to equal the body's position it states that the…
4
votes
1 answer

Three.js keep camera behind object

The short version: How can one make a camera follow an object controlled by physics within a Three.js scene? The long version: I'm working on a Three.js scene in which the W,A,S,D keys move a sphere along a plane. So far, however, I haven't figured…
duhaime
  • 25,611
  • 17
  • 169
  • 224
4
votes
1 answer

A-Frame Physics System : custom physics materials

I have created a scene in A-Frame using 'A-Frame Physics System' (https://github.com/donmccurdy/aframe-physics-system) :
KK1993
  • 43
  • 3
4
votes
1 answer

Cannon JS Collision detect amount of force

I have two Cannon.js Objects, and have attached the "collide" event listener to both. carBody.addEventListener("collide",function(e){ }); I want to be able to react differently depending on how much force the collision has is there a way to do…
Jim Wiberley
  • 41
  • 1
  • 3
4
votes
1 answer

How to set gravity to the center of a big sphere (planet) in Babylon.js?

I made a sphere in Babylon.js at the point [0,0,0], I want it to be like a planet with it's own gravity. Then I want a sphere (that will be the player) to be attracted to the center of the big sphere ("planet"). Here is the demo I…
Giovanne Afonso
  • 666
  • 7
  • 21
4
votes
2 answers

Cannon.js complex shapes

I need to know how can I generate a complex shape to integrate in my Three.js scene, with the benefit of Cannon.js physics. I started from this example: http://schteppe.github.io/cannon.js/demos/bunny.html Looking at the code, I noticed that the…
Rotan
  • 577
  • 6
  • 16
4
votes
1 answer

Convert javaScript object to different object type

This has to do with Three.js + Socket IO + CANNON.js. I have an CANNON.RigidBody object on my SERVER, that i cannot send as it is. So i transform it like this: // Create a sphere var mass = 5, radius = 1.8; var sphereShape = new…
Thor88
  • 323
  • 3
  • 7
3
votes
0 answers

Cannonjs glitch while moving body

I have an issue with character movement in cannonjs and maybe some one can give me a hint. the issue: As you can see, there is a visual glitch when character moves. In cannonjs world I have a plane as a floor and sphere as the character…
1
2 3
10 11