chandlerprall / Physijs

Physics plugin for Three.js
MIT License
2.77k stars 455 forks source link

Physijs.ConcaveMesh scale property not respected #60

Open lazd opened 11 years ago

lazd commented 11 years ago

It doesn't seem scaling works for Physijs.ConcaveMesh:

var groundMesh = new Physijs.ConcaveMesh(geometry, faceMaterial, 0);
groundMesh.scale.set(10, 10, 10);
scene.add(groundMesh);

The mesh appears and can be collided with, but it is considered to be it's default size by the physics engine. I had a look at 1afa96be42ba2b879a9dbb92984e6296f8bb9f91, then added a breakpoint at line 784, and the ConcaveMesh doesn't seem to have object._physijs.width and friends. Setting those variables manually to 1 doesn't help either.

Related to #20

lazd commented 11 years ago

The same happens for Physijs.ConvexMesh, by the way.

nrox commented 11 years ago

physijs is not accounting for scaling concave mesh.

chandlerprall commented 11 years ago

Scaling needs to be refactored to apply the object's scaling entirely in the worker, passing the object's scale and letting createShape apply them as needed.

gaet commented 10 years ago

How can we use createShape() function of physijs_worker just before add scene?

    mesh = new Physijs.ConvexMesh(geometry,ground_material,0);
mesh.scale.set(40,40,40); //work but collisions are not update

    mesh = createShape(mesh._physijs); //don't work
  or
var _worker = new Worker( Physijs.scripts.worker || 'physijs_worker.js' );
mesh = _worker.createShape(mesh._physijs);  // don't work too

scene.add( mesh);

Because I use blender export model (three.js), and I have this problem to scale my model. Physijs don't use the "scale" attribut of my js file (model.js).

chandlerprall commented 10 years ago

As a work around you could apply the scale directly to the geometry itself. Something like

geometry.vertices.forEach(function( v ){ v.multiplyScalar( the_scale ) });
JScott commented 10 years ago

Has there been any traction on this issue? Applying the scale directly to the geometry causes weird errors with the entire scene and modifying the original model isn't a great solution for me.

It's worth mentioning that I have the same problem with Physijs.SphereMesh. I'm not sure if that's related or another issue entirely.