cannon.js

Moving cannonJS object in 3D according to its quaternion

微笑、不失礼 提交于 2021-02-08 03:51:23
问题 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 object, is to change its velocity. Here's what I have done here: http://codepen.io/Tomo0613/pen/xVjqqK enter code here But i definitely have problems with understanding quaternions. Is there a way to update, the vector of the body according to its quaternion as i rotate it, or that's always

Moving cannonJS object in 3D according to its quaternion

岁酱吖の 提交于 2021-02-08 03:50:44
问题 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 object, is to change its velocity. Here's what I have done here: http://codepen.io/Tomo0613/pen/xVjqqK enter code here But i definitely have problems with understanding quaternions. Is there a way to update, the vector of the body according to its quaternion as i rotate it, or that's always

Moving cannonJS object in 3D according to its quaternion

做~自己de王妃 提交于 2021-02-08 03:49:23
问题 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 object, is to change its velocity. Here's what I have done here: http://codepen.io/Tomo0613/pen/xVjqqK enter code here But i definitely have problems with understanding quaternions. Is there a way to update, the vector of the body according to its quaternion as i rotate it, or that's always

Cannonjs - Change on body position&quaternion not affecting on child shapes

自古美人都是妖i 提交于 2020-03-25 12:30:53
问题 I use cannonjs vs three.js . Ussually in three.js it is easy with 3dObject container. I added a lot of bodies and translate/rotate then in circle but now i wanna rotate them all together. Any idea... /* globals CANNON THREE GROUP1 GROUP2 GROUP3 app world scene */ /** From visual JS project */ function orbit(cx, cy, angle, p) { var s = Math.sin(angle); var c = Math.cos(angle); // translate point back to origin: p.x -= cx; p.y -= cy; // rotate point // eslint-disable-next-line no-undef xnew = p

Position a body in cannon.js relative to local rotation

余生颓废 提交于 2019-12-11 16:53:59
问题 I have a body in cannon.js that has a quaternion rotation applied to it. I want to move it 100 units along a vector relative to it's local rotation. Eg let body = new CANNON.Body({ mass: 0 }); body.quaternion.setFromAxisAngle(new CANNON.Vec3(0,0,1),(2*Math.PI)/6); body.position.set(0,0,100); //this is wrong Using body.position.set(x, y, z); moves the body relative to the world rather than the local rotation. I think I need to add a vector after applying the quaternion to it, but the docs for

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

社会主义新天地 提交于 2019-12-01 18:55:10
问题 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(); THREE.ColorUtils.adjustHSV(tmp_material.color, 0, 0, 0.9); var castle = new THREE.Mesh(geometry, tmp_material); castle.scale.set(0.2, 0.2, 0.2); castle.rotation.setX(-Math.PI/2); scene.add(castle); }); Is it possible to create a CANNON.RigidBody from the THREE.Mesh ( var castle )

Move camera in aframe with physics engine

时光怂恿深爱的人放手 提交于 2019-11-28 05:43:12
问题 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 for motion. Here is my example scene: <script src="https://aframe.io/releases/0.3.0/aframe.min.js"></script> <script src="//cdn.rawgit.com/donmccurdy/aframe-extras/v2.3.0/dist/aframe-extras.min.js"></script> <a-scene physics> <!-- Camera --> <a-entity id="cameraWrapper" geometry="box" dynamic-body