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));
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值