157 questions
11
votes
1
answer
6k
views
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 ...
8
votes
0
answers
1k
views
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 ...
7
votes
1
answer
5k
views
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 ...
6
votes
1
answer
7k
views
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 is.
...
6
votes
2
answers
7k
views
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....
5
votes
1
answer
1k
views
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 ...
5
votes
0
answers
615
views
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 ...
4
votes
2
answers
4k
views
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/...
4
votes
1
answer
3k
views
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 ...
4
votes
1
answer
8k
views
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 ...
4
votes
1
answer
856
views
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) :
<!DOCTYPE>
<html>
<head>
<script src="aframe.min.js">&...
4
votes
1
answer
2k
views
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 ...
4
votes
1
answer
1k
views
My glb file is not loading into my three.js file
My glb file wont show up inside my thee.js world. I have followed all the documentations and tutorals but nothing works. the world loads and evry thing works fine its just that the moddle dose not ...
4
votes
1
answer
4k
views
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/...
4
votes
1
answer
268
views
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,
...
4
votes
0
answers
383
views
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 ...
3
votes
1
answer
6k
views
What would be "realistic" values for gravity, mass and contact material in cannon.js? [closed]
i've looked in the cannon.js examples, and they seem to mostly use between -10 and -40 for gravity and something between 1 and 10 for the mass of an object (or CANNON.RigidBody as they are called), ...
3
votes
1
answer
1k
views
Cannon JS — Position Vector NaN after initiating body with properties
I'm using a simple setup Cannon.js, following the examples online, but when I set any property in the constructor, the position and angular velocity x, y and z are all NaN.
This works, but does not ...
3
votes
2
answers
3k
views
Cloth Simulaltion of a 3d obj cloth model
I have seen many cloth simulations in three.js . I found it is done only with 2d plane surfaces . But is there a way that I can simulate a 3d cloth model like the one below ..
There are many tutorials ...
3
votes
1
answer
2k
views
How to manually apply gravity on bodies (cannon.js)?
I m looking for a proper way to apply (or disable) gravity on individual objects (without loosing collide events or rotation velocity)
I have read this issue but looking for a more complete answer.
...
3
votes
1
answer
397
views
Sending a vector3 to script from patches is not working
So I'm making a ball bounce in spark AR with cannon.js. Everything was working fine until I wanted to get the position of the forehead from the facetracker via the patch editor to a script.
Error:
...
3
votes
1
answer
719
views
How to create a spring in a-frame and cannon.js
I am trying to make a rope-like constraint where the constraint is like a spring that bounces back.
I'm trying to use the constraint component:
<a-box id="other-box" dynamic-body />
<a-box ...
2
votes
1
answer
2k
views
Cannon.js - How to prevent jittery/shaky blocks?
I'm using Cannon.js with Three.js. I have set a scene which has 5 columns of 4 blocks stacked on top of each other.
I want these to be interactable with other objects I'm planning on adding to the ...
2
votes
1
answer
1k
views
how can I make a ball bounce inside a Box with CANNON.js and THREE.js?
I have a sphere and BoxGeometry in THREE.js.
I've setted the standard gravity but my sphere (which is in the center of the box) keep falling down through the box
here are my CANNON.js params
Box
const ...
2
votes
1
answer
4k
views
Cannon.js + Three.js: Minimal car + physics
I'm trying to figure out how to create a minimal car with physics using Three.js and Cannon.js. I have created my visual and physics-based elements of my car and wheels, and my car responds to up ...
2
votes
2
answers
3k
views
Move camera in aframe with physics engine
I am using a physics engine in my aframe application, and I want the camera to move when the user clicks a button.
I want to keep the physics engine properties so I am using applyImpulse as a method ...
2
votes
1
answer
2k
views
How to group object bodies (parent/child) in Cannon.js?
I've searched everywhere and looked well issues and doc, but it seem that appart from creating a constraint between two Cannon bodies, there is no way to group shapes of different masses (for example)....
2
votes
1
answer
3k
views
Move Cannon.JS Body Toward Dynamic Position?
I'm having a hard time wrapping my head around how to do this.
What I'm trying to do, is move a physics body, by the means of velocity, toward another body, until it reaches and hits said body. (Think ...
2
votes
3
answers
3k
views
How do I keep Transform Control from moving your object if there is a collision, using raycasting?
So I'm using Three.js and I have some cubes inside of a box. I'm using the Transform Control to move the cubes around inside of the box with my mouse. I'd like to use raycasting in order to check ...
2
votes
2
answers
2k
views
CannonJS lock rotation on specific axes
I have seen the CannonJS FPS Demo and noticed that it used a sphere for player collisions. My character is not in a form of a sphere, but rather a box or a capsule.
I have tried using a box for ...
2
votes
2
answers
2k
views
Moving cannonJS object in 3D according to its quaternion
I would like to achieve a space ship like move on a cannonJS body.
(Im really a beginner)
I found some examples but none of them are exactly what I'm looking for.
As i know the correct way to move an ...
2
votes
2
answers
896
views
react-three/cannon : offset around the GLTF model, model dosent touch the floor
i'm trying react-three/cannon and my goal is to drop a "Cube" and a "GLTF model" from a position and let them land on a "Floor".
it works well for the Cube (he touches ...
2
votes
1
answer
2k
views
Cannon.js is there a way to check if an object is colliding with 2 other objects at the same time?
I'm using Cannon.js to make a game where a ball bounces of of your head and the sides of the screen have boxes as boundaries. when the ball collides with the head it adds one more to the score. I want ...
2
votes
2
answers
907
views
Collision issue between bodies depending on the velocity of one
I need to make a ball entering a tube with multiple tubes in my world. I created a tube by creating multiple box shapes that I then move and rotate to complete the tour of the tube. So far so good.
I'...
2
votes
1
answer
4k
views
Using cannon.js for collision detection in a three.js game
I'm working on something with three.js where i need a way to handle collisions between objects very generally. I was thinking of using cannon.js since it supports the primitives i need but i don't ...
2
votes
1
answer
10k
views
Creating a room with Three.js and cannon.js
I'm just getting started with Three.js and cannon.js and I've been trying to create a simple room for a while with no success. I'm working off of this example and I've been trying to add walls and a ...
2
votes
0
answers
1k
views
Updating position and rotation of a RigidBody or MeshCollider and making it follow along it's child mesh, using react-three/rapier or cannon
So I have a react-three/fiber scene component, where I am animating a rigged character. I want to apply colliders to eg. the hands, so that the movement and rotation of the skinned mesh will apply to ...
2
votes
1
answer
1k
views
Deterministic Dice Roller with react-three-fiber
I found this great example of creating 3D dice with react-three-fiber at https://codesandbox.io/s/reverent-lalande-5qdk4j. I want to do something similar but with deterministic rolling, meaning I can ...
2
votes
0
answers
160
views
How can I create a gravitational attraction between objects with cannon.js and three.js?
I can create gravity in the whole world but I want to create a gravitational attraction between objects so I can simulate planets and stuff.
I tried making a function for Newton's law of universal ...
2
votes
0
answers
1k
views
Three.js & @react-three/fiber - TextGeometry() cannot read properties of undefined (reading 'yMax')
I'm getting the error "Uncaught TypeError: Cannot read property 'yMax' of undefined" when adding text to a three.js scene using React-three/fiber. I've successfully rendered other geometries ...
2
votes
0
answers
549
views
cannon.js object is flipping end to end
I'm working on a little three.js scene in which I want to drive a car down a road. The trouble is my car is flipping end to end each frame, instead of rolling on its tires:
Does anyone know how I can ...
2
votes
0
answers
2k
views
Cannon.js - Is there a way to add physics to a character model?
I've been using Cannon.js with Three.js a lot recently and they work great together.
There's to be one part which I'm struggling to find information/examples about.
Is it possible to rig a character ...
2
votes
0
answers
2k
views
Create Rope in Three.js using Physics from Ammo.js or Cannon.js
I have been trying to create in three.js a rope hanging from a point using any of the 3D physics libraries (ammo.js, cannon.js), but the only one I have successfully done is with (2D)verlet.js.
I ...
2
votes
1
answer
2k
views
How to enable collision in babylon.js mesh
I've been making a game in Babylon.js. In my game, there is a place where I have put a height map, it shows up when I run the scene, but when I try walking on it (or just standing on it) I fall ...
1
vote
1
answer
2k
views
Cannonjs and THREE.js one unit off
Hey guys I am trying to make a simple 3js and cannon js demo, it is done except for the fact that it appears that there is a one unit off.
https://www.dropbox.com/s/qqaal0hgq9a506e/Screenshot%202014-...
1
vote
1
answer
900
views
How to apply quadratic drag force to a body in cannon.js?
I want to apply a drag force to a cannon.js' body, I've tried in a way but it's breaking the physics, wanted to know if there is a more correct way or if someone has already done something similar.
...
1
vote
2
answers
776
views
Cannon.js: Finding the side of a dice is using quaternions
Here is a fiddle with some of the code I'm working with.
I'm rolling the dice, not randomly yet, but that'll be added later. But right now I'm having a hard time to find out which side the dice has ...
1
vote
1
answer
2k
views
CANNON.js: Visual representation of a RigidBody
I have a THREE.js Scene where Objects have physcis applied to them using CANNON.js. The RigidBody is initialized like so:
let shape = new CANNON.Box(new CANNON.Vec3(1, 1, 1));
let body = new CANNON....
1
vote
1
answer
2k
views
CannonJS floor. Make a ball stick to the ground
Noob Question: I'm trying to drop a ball to the floor and make it stick there or even roll over a plane. Right now it passes trough the plane. I'm not sure where I made a mistake or if I'm doing ...
1
vote
1
answer
838
views
Is there any thing like origin point in Three.js
Please I want to know if there is anything like origin point in three.js just as we have it in Blender, please I have tried to do a research on this topic but to no avail. I want to make a pinball ...