I've been working with the Physijs script for simulating physics, such as gravitation.
I'm trying to use Raycaster from the THREE.js
script to move objects within my scene.
The issue I'm facing is that the Raycaster only moves objects (simple boxes) when declared like this:
var box = new Physijs.Mesh(cubeGeometry.clone(), createMaterial);
However, in this case, the physics simulation does not work properly. It only works if I declare it like this:
var create = new Physijs.BoxMesh(cubeGeometry.clone(), createMaterial);
But when declared like this, the Raycaster or moving functionality stops working.
The key difference between these two declarations is that in the first one, it's just a Mesh
, whereas in the second one, it's a BoxMesh
.
Does anyone have any insights into why this setup isn't functioning correctly? I need to use BoxMesh
in order to implement gravity and other physics simulations.
Here is the code snippet for adding a cube to the scene:
function addCube()
{
controls.enable = false;
var cubeGeometry = new THREE.CubeGeometry(85, 85, 85);
var createTexture = new THREE.ImageUtils.loadTexture("images/rocks.jpg");
var createMaterial = new THREE.MeshBasicMaterial({ map: createTexture });
var box = new Physijs.BoxMesh(cubeGeometry.clone(), createMaterial);
box.castShadow = true;
box.receiveShadow = true;
box.position.set(0, 300, 0);
objects.push(box);
scene.add(box);
}