For my project, I am using a THREE.JSONLoader
to create a THREE.Mesh
object as shown below:
// Creating a 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);
});
I'm wondering if it's possible to convert the THREE.Mesh
(specifically the var castle
) or the THREE.Geometry
(specifically the var geometry
) object into a CANNON.RigidBody
? Essentially, how can I make any custom THREE.Mesh
"solid"?
Update
To tackle this question, I used Blender to design a new castle out of boxes and then exported it to the Three.js format. By setting the mass of a CANNON.Body
to 0
, it becomes static. You can see how I implemented this in my code here.