Skip to content

Collide with imported geometry  #3

@DustinJSilk

Description

@DustinJSilk

I'm trying to get your "Collisions" example to work with a different shape rather than the IcosahedronGeometry.

I've loaded in a geometry yet the particles still bounce off a sphere shape at the same position. How can i map my geometry uniforms to the collider?

If that makes sense. err..

Heres what i have (the main part of it):

var loader = new THREE.JSONLoader();
    loader.load('./resources/crystal.json', function (geometry, materials) {

        var material = new THREE.MeshNormalMaterial({
            transparent: true,
            opacity: 1
        });
        model = new THREE.Mesh(geometry, material);

        scene.add(model)

        simulationUniforms.colliderPositions.value.push( model.position );

        var numOf = simulationUniforms.colliderPositions.value.length;
        var ss = shaders.setValue( shaders.ss.sim , 'COLLIDERS' , numOf );
        simulation = new PhysicsRenderer( SIZE , ss , renderer );

        var geo = createLookupGeometry( SIZE );

        var mat = new THREE.ShaderMaterial({
            uniforms: renderUniforms,
            vertexShader: shaders.vs.lookup,
            fragmentShader: shaders.fs.lookup,
            blending: THREE.AdditiveBlending,
            transparent: true
        });

        simulation.setUniforms( simulationUniforms );

        var particles = new THREE.PointCloud( geo , mat );

        particles.frustumCulled = false;
        scene.add( particles );


        simulation.addBoundTexture( renderUniforms.t_pos , 'output' );
        simulation.resetRand( 5 );

animate();
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions