• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript THREE.SphereGeometry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: buildPommel

    /**
     * Creates a spherical pommel and merges it with the swords geometry.
     * Given: the geometry of the sword, and some parameters about
     *        the geometry of the sword
     * Returns: The Sword
     */
    buildPommel(template : SwordTemplate, genParams : GenerationParameters, sword: Sword, numHands: number = 1, pommelBladeWidthRatio = 0.50) : Sword {
        var pommelRadius = genParams.bladeThickness;
        var pommelGeometry = new THREE.SphereGeometry(pommelRadius, 5, 5);
        var handleLength = 0.4 * numHands;
        // Translates the pommel to fall below the handle
        pommelGeometry.translate(0,-handleLength,0);

        // Convert the box to a buffer geometry
        var pommelBufferGeometry = new THREE.BufferGeometry().fromGeometry(pommelGeometry);

        // Number of vertices in the model prior to appending this geometry
        var priorNumVertices = sword.geometryData.vertices.length / 3;

        // Append the vertices to the swords vertex array and add their indices to the vertex indices array
        var vertices = pommelBufferGeometry.getAttribute("position");
        // Loop through all of the position attributes and add the XYZ values to the swords geometry
        for (var i = 0; i < vertices.count; i++) {
            sword.geometryData.addVertex(vertices.getX(i), vertices.getY(i), vertices.getZ(i));
        }

        // Append the vertices to the swords vertex array and add their indices to the vertex indices array
        var normals = pommelBufferGeometry.getAttribute("normal");
        // Loop through all of the position attributes and add the XYZ values to the swords geometry
        for (var i = 0; i < vertices.count; i++) {
            sword.geometryData.addNormal(normals.getX(i), normals.getY(i), normals.getZ(i));
        }

        // Add a color for each vertex (Gold)
        for (var i = 0; i < vertices.count; i++) {
            sword.geometryData.addColor(0.9, 0.8, 0.35);
        }

        var triangles = pommelBufferGeometry.getIndex();
        if (triangles != undefined) {
            // Loop through all of the triangles and add the values to the swords geometry
            for (var i = 0; i < triangles.count; i++) {
                sword.geometryData.addTriangle(triangles.getX(i), triangles.getY(i), triangles.getZ(i));
            }
        } else {
            // We need to add index values based on the vertices being added
            Assert.equal(vertices.count % 3, 0, "ERROR:: Verices are not organized into triangles");
            for (var i = 0; i < vertices.count;) {
                sword.geometryData.addTriangle(priorNumVertices + i, priorNumVertices + i + 1, priorNumVertices + i + 2);
                i += 3;
            }
        }

        return sword;
    }
开发者ID:ShiJbey,项目名称:WeaponGenerator,代码行数:55,代码来源:SwordGenerator.ts


示例2: _getFlatImageSphereGeo

    private _getFlatImageSphereGeo(transform: Transform): THREE.Geometry {
        let gpano: IGPano = transform.gpano;
        let phiStart: number = 2 * Math.PI * gpano.CroppedAreaLeftPixels / gpano.FullPanoWidthPixels;
        let phiLength: number = 2 * Math.PI * gpano.CroppedAreaImageWidthPixels / gpano.FullPanoWidthPixels;
        let thetaStart: number = Math.PI * gpano.CroppedAreaTopPixels / gpano.FullPanoHeightPixels;
        let thetaLength: number = Math.PI * gpano.CroppedAreaImageHeightPixels / gpano.FullPanoHeightPixels;
        let geometry: THREE.SphereGeometry = new THREE.SphereGeometry(
            this._imageSphereRadius,
            20,
            40,
            phiStart - Math.PI / 2,
            phiLength,
            thetaStart,
            thetaLength
        );

        geometry.applyMatrix(new THREE.Matrix4().getInverse(transform.rt));

        return geometry;
    }
开发者ID:Caboosey,项目名称:mapillary-js,代码行数:20,代码来源:ImagePlaneFactory.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.SphereGeometry类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript THREE.TextureLoader类代码示例发布时间:2022-05-25
下一篇:
TypeScript THREE.Scene类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap