Three.js点、线、面、立方体

平面和缓冲平面:

        var geometry = new Three.PlaneBufferGeometry( 10, 10, 1,1 );
        var material = new Three.MeshBasicMaterial( { color: 0xffff00 } );
        var mesh= new Three.Mesh( geometry, material );
        this.scene.add( mesh);

        var geometry = new Three.PlaneGeometry( 10, 10, 1,1 );
        var material = new Three.MeshBasicMaterial( { color: 0xffff00 } );
        var mesh= new Three.Mesh( geometry, material );
        this.scene.add( mesh);

球体和缓冲球体

        var geometry = new Three.SphereGeometry(1.6,40,40);
        var material = new Three.MeshLambertMaterial({
            color:0x0000FF,
            wireframe:false});
        this.mesh = new Three.Mesh( geometry, material );
        this.mesh.position.set(0,0,0)
        this.scene.add( this.mesh );

        var geometry = new Three.SphereBufferGeometry(1.6,40,40);
        var material = new Three.MeshLambertMaterial({
            color:0x0000FF,
            wireframe:false});
        this.mesh = new Three.Mesh( geometry, material );
        this.mesh.position.set(0,0,0)
        this.scene.add( this.mesh );

 线:

        var geometry = new Three.BufferGeometry();
        var vertices = new Float32Array( [
          -1.0, -1.0,  1.0,
          1.0, -1.0,  1.0
        ] );
        geometry.setAttribute( 'position', new Three.BufferAttribute( vertices, 3 ) );
        var material = new Three.MeshBasicMaterial( { color: 0xff0000 } );
        var line = new Three.Line( geometry, material );
        this.scene.add(line)

点:

        var geometry = new Three.BufferGeometry();
        geometry.setAttribute( 'position', new Three.BufferAttribute( vertices, 3 ) );
        var sprite = new Three.TextureLoader().load( './static/img/BG.jpg' );
        var material = new Three.PointsMaterial({
            size: 1,
            transparent: true,
            color: 0x96CDCD,
            alphaTest: 0.5,
            map:sprite
        });          
        var vertices = new Float32Array( [
          -1.0, -1.0,  1.0,
          1.0, -1.0,  1.0
        ] );
        geometry.addAttribute('position', new Three.Float32BufferAttribute(vertices, 3));
        var line = new Three.Points( geometry, material );
        this.scene.add(line)

立方体和缓冲立方体:

        var geometry = new Three.BoxGeometry( 1, 1, 1 );
        var material = new Three.MeshBasicMaterial( {color: 0x00ff00} );
        var cube = new Three.Mesh( geometry, material );
        this.scene.add(cube)

        var geometry = new Three.BoxBufferGeometry( 1, 1, 1 );
        var material = new Three.MeshBasicMaterial( {color: 0x00ff00} );
        var cube = new Three.Mesh( geometry, material );
        this.scene.add(cube)

圆形几何体和圆形缓冲几何体:

        var geometry = new Three.CircleGeometry( 5, 32 );
        var material = new Three.MeshBasicMaterial( { color: 0xffff00 } );
        var circle = new Three.Mesh( geometry, material );
        this.scene.add( circle );

var geometry = new Three.CircleBufferGeometry( 5, 32 ); var material = new Three.MeshBasicMaterial( { color: 0xffff00 } ); var circle = new Three.Mesh( geometry, material ); this.scene.add( circle );

圆锥几何体和圆锥缓冲几何体:

        var geometry = new Three.ConeGeometry( 5, 32 );
        var material = new Three.MeshBasicMaterial( { color: 0xffff00 } );
        var cone= new Three.Mesh( geometry, material );
        this.scene.add( cone);
        var geometry = new Three.ConeBufferGeometry( 5, 32 );
        var material = new Three.MeshBasicMaterial( { color: 0xffff00 } );
        var cone= new Three.Mesh( geometry, material );
        this.scene.add( cone);

圆柱和圆柱缓冲几何体:

        var geometry = new Three.CylinderGeometry(5, 5, 20, 32);
        var material = new Three.MeshBasicMaterial( { color: 0xffff00 } );
        var cylinder= new Three.Mesh( geometry, material );
        this.scene.add( cylinder)
        var geometry = new Three.CylinderBufferGeometry(5, 5, 20, 32);
        var material = new Three.MeshBasicMaterial( { color: 0xffff00 } );
        var cylinder= new Three.Mesh( geometry, material );
        this.scene.add( cylinder)

十二面几何体和缓冲十二面几何体

        var geometry = new Three.DodecahedronBufferGeometry(5, 5, 20, 32);
var material = new Three.MeshBasicMaterial( { color: 0xffff00 } );
var mesh= new Three.Mesh( geometry, material );
this.scene.add( mesh)
        var geometry = new Three.DodecahedronBufferGeometry(5, 5, 20, 32);
var material = new Three.MeshBasicMaterial( { color: 0xffff00 } );
var mesh= new Three.Mesh( geometry, material );
this.scene.add( mesh)
posted @ 2021-05-17 17:42  _Lawrence  阅读(500)  评论(0编辑  收藏  举报