Threejs学习笔记之五几何体

二维几何体

PlaneGeometry-矩形面

//PlaneGeometry 矩形面(宽度,高度,宽线段数,高线段数)
var plane = createMesh(new THREE.PlaneGeometry(10, 14, 4, 4));
//多个面
varmesh = THREE.SceneUtils.createMuutiMaterialObject(plane,[aMeterial,bMaterial])

CircleGeometry-圆

//完整圆
circle = createMesh(32);

//自定义圆面
circle = createMesh(new THREE.CircleGeometry(半径, 分段默认8最少3, 从哪里开始画0~2*PI, 角度(弧度)默认x*PI));

ShapeGeometry-自定义图形

shape = createMesh(new THREE.ShapeGeometry(drawShape()));//
 function drawShape() {

            // create a basic shape
            var shape = new THREE.Shape();

            // startpoint
            shape.moveTo(10, 10);

            // straight line upwards
            shape.lineTo(10, 40);

            // the top of the figure, curve to the right
            shape.bezierCurveTo(15, 25, 25, 25, 30, 40);

            // spline back down
            shape.splineThru(
                    [new THREE.Vector2(32, 30),
                        new THREE.Vector2(28, 20),
                        new THREE.Vector2(30, 10),
                    ]);

            // curve at the bottom
            shape.quadraticCurveTo(20, 15, 10, 10);

            // add 'eye' hole one
            var hole1 = new THREE.Path();
            hole1.absellipse(16, 24, 2, 3, 0, Math.PI * 2, true);
            shape.holes.push(hole1);

            // add 'eye hole 2'
            var hole2 = new THREE.Path();
            hole2.absellipse(23, 24, 2, 3, 0, Math.PI * 2, true);
            shape.holes.push(hole2);

            // add 'mouth'
            var hole3 = new THREE.Path();
            hole3.absarc(20, 16, 2, 0, Math.PI, true);
            shape.holes.push(hole3);

            // return the shape
            return shape;
        }

三维几何

BoxGeometry-长方体

var cube = createMesh(new THREE.BoxGeometry(x长, y长, z长));
var cube = createMesh(new THREE.BoxGeometry(x长, y长, z长, x面数理, y面数量, z面数量));

SphereGeometry-球体

sphere = createMesh(new THREE.SphereGeometry();

sphere = createMesh(new THREE.SphereGeometry(半径默认50,
垂直分段默认8越大越光滑, 
水平分段, 
什么地方开始画0~2*PI默认0, 
画多少2*PI为整球 ,
y轴开始画的地方默认0,
画多少2*PI为整球);

CylinderGeometry-圆柱

 cylinder = createMesh(new THREE.CylinderGeometry(controls.radiusTop, controls.radiusBottom, controls.height, controls.radialSegments, controls.heightSegments, controls.openEnded));

TorusGeometry-圆环

 torus = createMesh(new THREE.TorusGeometry(controls.radius, controls.tube, Math.round(controls.radialSegments), Math.round(controls.tubularSegments), controls.arc));

TorusKnotGeometry-环形纽结

 knot = createMesh(new THREE.TorusKnotGeometry(controls.radius, controls.tube, Math.round(controls.radialSegments), Math.round(controls.tubularSegments), Math.round(controls.p), Math.round(controls.q), controls.heightScale));

PolyhedronGeometry-多面体

polyhedron = createMesh(new THREE.PolyhedronGeometry(vertices, indices, controls.radius, controls.detail));

你可能感兴趣的:(【前端】)