当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript SphereGeometry.computeFaceNormals方法代码示例

本文整理汇总了TypeScript中THREE.SphereGeometry.computeFaceNormals方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SphereGeometry.computeFaceNormals方法的具体用法?TypeScript SphereGeometry.computeFaceNormals怎么用?TypeScript SphereGeometry.computeFaceNormals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在THREE.SphereGeometry的用法示例。


在下文中一共展示了SphereGeometry.computeFaceNormals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: constructor

    constructor(position: Vector3, attr: {
        color: Color;
        texture: Texture;
        displayHalo: boolean;
        applyDistortion: boolean;
        size: number;
    }) {
        this.size = attr.size;
        this.position = position;
        var starMaterial: Material;
        attr.texture.wrapS = attr.texture.wrapT = RepeatWrapping;
        if (attr.applyDistortion) {
        	this.starUniforms = {
        		baseTexture: 	{ type: "t", value: attr.texture },
        		baseSpeed:		{ type: "f", value: 0.02 },
        		repeatS:		{ type: "f", value: 1.0 },
        		repeatT:		{ type: "f", value: 1.0 },
        		noiseTexture:	{ type: "t", value: noiseTexture },
        		noiseScale:		{ type: "f", value: 0.5 },
        		blendTexture:	{ type: "t", value: attr.texture },
        		blendSpeed: 	{ type: "f", value: 0.01 },
        		blendOffset: 	{ type: "f", value: 0.25 },
        		bumpTexture:	{ type: "t", value: noiseTexture },
        		bumpSpeed: 		{ type: "f", value: 0.15 },
        		bumpScale: 		{ type: "f", value: 100.0 },
        		alpha: 			{ type: "f", value: 1.0 },
        		time: 			{ type: "f", value: 1.0 }
        	};

        	starMaterial = new ShaderMaterial({
        	    uniforms: this.starUniforms,
        		vertexShader:   starVertex,
        		fragmentShader: starFragment
        	});
        } else {
            starMaterial = new MeshBasicMaterial({
                map: attr.texture
            });
        }
        var shiny = new Mesh(new SphereGeometry(attr.size, 64, 64), starMaterial);

        shiny.position.copy(position);

        if (attr.displayHalo) {
            this.uniform = {
                "c":   { type: "f", value: 0.5 },
                "p":   { type: "f", value: 4 },
                glowColor: { type: "c", value: attr.color },
                viewVector: { type: "v3", value: new Vector3() }
            };
            var customMaterial = new ShaderMaterial({
        	    uniforms: this.uniform,
        		vertexShader: vertex,
        		fragmentShader: fragment,
        		side: FrontSide,
        		blending: AdditiveBlending,
        		transparent: true
        	});

        	var ballGeometry = new SphereGeometry(attr.size, 64, 64);
            ballGeometry.computeFaceNormals();
            ballGeometry.computeVertexNormals();
        	var halo = new Mesh(ballGeometry, customMaterial);
            halo.scale.multiplyScalar(haloScale);
            halo.position.copy(position);

            this.halo = halo;
        }

        this.mesh = shiny;
        var priorRotationMatrix = new Matrix4();
        var axis = new Vector3(
            Math.random() - 0.5,
            0,
            Math.random() - 0.5
        );
        priorRotationMatrix.makeRotationAxis(axis.normalize(), Math.random());

        this.mesh.matrix.multiply(priorRotationMatrix);

        this.rotationMatrix = new Matrix4();
        this.rotationMatrix.makeRotationAxis(new Vector3(0, 1, 0), Math.random() * 0.02 + 0.01)

        this.mesh.rotation.setFromRotationMatrix(this.mesh.matrix);
    }
开发者ID:yyjhao,项目名称:galaxy-tunnel,代码行数:85,代码来源:star.ts


注:本文中的THREE.SphereGeometry.computeFaceNormals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。