Rendering spheres (or points) in a particle system

后端 未结 3 792
失恋的感觉
失恋的感觉 2021-01-06 19:45

I am using the Three.JS library to display a point cloud in a web brower. The point cloud is generated once at start up and no further points are added or removed. But it do

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-06 20:26

    I don't think rendering a point cloud with spheres is very efficient. You should be able to get away with a particle system and use a texture or a small canvas program to draw a circle.

    One of the first three.js sample uses a canvas program, here are the important bits:

    var PI2 = Math.PI * 2;
    var program = function ( context )
    {
        context.beginPath();
        context.arc( 0, 0, 1, 0, PI2, true );
        context.closePath();
        context.fill();    
    };
    var particle = new THREE.Particle( new THREE.ParticleCanvasMaterial( {
        color: Math.random() * 0x808008 + 0x808080,
        program: program
    } ) );
    

    three.js particles

    Feel free to adapt the code for the WebGL renderer.

    Another clever solution I've seen in the examples is using an encoded webm video to store the data and pass that to a GLSL shader which is rendered through a particle system in three.js three.js webgl kinect

    If your point cloud comes from a Kinect, these resources might be useful:

    1. DepthCam
    2. KinectJS

    George MacKeron's kinect to js solution

提交回复
热议问题