chandlerprall / Physijs

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

Object does not go inside open ended Cylinder Mesh, instead seems to collide #304

Open AngVen opened 6 years ago

AngVen commented 6 years ago

Hello,

Consider as tube and a sphere

        var mOil1 = new THREE.MeshLambertMaterial({
            color: 0xAD8D30,
            refractionRatio: 0.5,
            opacity: 0.7,
            transparent: true,
            side: THREE.DoubleSide
        });

        var mPhyGlass = Physijs.createMaterial(
            mOil1,
            .4, // low friction
            .6 // high restitution
        );
        var glassTube = new Physijs.CylinderMesh(
            new THREE.CylinderGeometry(1, 1, 10, 24,1,true),
            mPhyGlass,
            0.1
        );
        glassTube.castShadow = true;
        glassTube.receiveShadow = true;
        glassTube.position.set(
            0,
            6,
            0
        );

var mPhyOil = Physijs.createMaterial( mOil1, .4, // low friction .6 // high restitution ); var sphere_geometry = new THREE.SphereGeometry(0.5, 32, 32); var Ballshape = new Physijs.SphereMesh( sphere_geometry, mPhyOil, 0.5, { restitution: Math.random() * 1.5 } ); Ballshape.castShadow = true; Ballshape.receiveShadow = true; Ballshape.position.set( 0, 12, 0 );

The scene has a ground... // Ground ground = new Physijs.BoxMesh( new THREE.BoxGeometry(100, 1, 100), ground_material, 0 // mass ); ground.receiveShadow = true; scene.add(ground);

The glassTube cylinder geometry is open ended. Now when you simulate the Ballshape falls and sits on the top of the tube.

The scene has a ground... // Ground ground = new Physijs.BoxMesh( new THREE.BoxGeometry(100, 1, 100), ground_material, 0 // mass ); ground.receiveShadow = true; scene.add(ground);

Effectively it is supposed to go thru to tube.

I am trying to simulate a glass tube filled with some small objects. ( off course this tube here is open ended on both sides, but will create something like a text tube) When the tube is tilted the objects will roll out. (since the tube is resting on the ground vertically assuming that it would be as if closed at the bottom)

is there something that i am missing or is this the behavior of collision and that i cannot achieve the desired effect.