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


TypeScript Vector3.normalize方法代码示例

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


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

示例1: _pixelToBearing

 private _pixelToBearing(pixel: number[]): number[] {
     if (this._gpano) {
         let lon: number = pixel[0] * 2 * Math.PI;
         let lat: number = -pixel[1] * 2 * Math.PI;
         let x: number = Math.cos(lat) * Math.sin(lon);
         let y: number = -Math.sin(lat);
         let z: number = Math.cos(lat) * Math.cos(lon);
         return [x, y, z];
     } else {
         let v: THREE.Vector3 = new THREE.Vector3(pixel[0], pixel[1], this._focal);
         v.normalize();
         return [v.x, v.y, v.z];
     }
 }
开发者ID:Caboosey,项目名称:mapillary-js,代码行数:14,代码来源:Transform.ts

示例2: _getRt

    private _getRt(node: Node): THREE.Matrix4 {
        let axis: THREE.Vector3 = new THREE.Vector3(
            node.apiNavImIm.rotation[0],
            node.apiNavImIm.rotation[1],
            node.apiNavImIm.rotation[2]);

        let angle: number = axis.length();
        axis.normalize();
        let rt: THREE.Matrix4 = new THREE.Matrix4();
        rt.makeRotationAxis(axis, angle);
        rt.setPosition(new THREE.Vector3(
            node.translation[0],
            node.translation[1],
            node.translation[2]));

        return rt;
    }
开发者ID:CharlesXuuu,项目名称:mapillary-js,代码行数:17,代码来源:Transform.ts

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