Cannot read property 'isInterleavedBufferAttribute' of undefined

Viewed 710

I'm tring to use three.js "version": "0.113.2".

I have the message Cannot read property 'isInterleavedBufferAttribute' of undefined.

My three.js have following code as the messaged say.

However, I didn't do it myself.Some things my code is conducing this.

Someone tell me how to fix this problem.

function get( attribute ) {

    if ( attribute.isInterleavedBufferAttribute ) { attribute = attribute.data; }

    return buffers.get( attribute );

}

function remove( attribute ) {

    if ( attribute.isInterleavedBufferAttribute ) { attribute = attribute.data; }

    var data = buffers.get( attribute );

    if ( data ) {

        gl.deleteBuffer( data.buffer );

        buffers.delete( attribute );

    }

}

function update( attribute, bufferType ) {

    if ( attribute.isInterleavedBufferAttribute ) { attribute = attribute.data; }

    var data = buffers.get( attribute );

    if ( data === undefined ) {

        buffers.set( attribute, createBuffer( attribute, bufferType ) );

    } else if ( data.version < attribute.version ) {

        updateBuffer( data.buffer, attribute, bufferType );

        data.version = attribute.version;

    }

}

}

A part of my code which tries to add pointcloud on the scene. If add comment the last line scene.add( points ),the error message will stop.

        var vertices = [];
        var colors = [];
        var pcUrl = " <?php echo $pcUrl ?> ";
        var req = new XMLHttpRequest(); 
        req.open("get", pcUrl, true); 
        req.send(null); 
        req.onload = function(){
        convertCSVtoArray(req.responseText); 
        }


        function convertCSVtoArray(str){ 
            line = str.split("\n"); /

            for (var  i  =0; i< line.length-1 ; ++i){
                row = line[i].split(',');

                var x = row[0];
                var y = row[1];
                var z = row[2];

                vertices.push( x, y, z );
            }
        }
        var geometry = new THREE.BufferGeometry();
        geometry.setAttribute( vertices );

        var material = new THREE.PointsMaterial( { color: 0xff4444 } );
        var points = new THREE.Points( geometry, material );
        scene.add( points );
1 Answers

geometry.setAttribute( vertices );

It should be:

geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
Related