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


TypeScript BufferGeometry.setIndex方法代码示例

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


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

示例1: _getImageSphereGeo

    private _getImageSphereGeo(transform: Transform, node: Node): THREE.BufferGeometry {
        let t: THREE.Matrix4 = new THREE.Matrix4().getInverse(transform.srt);

        // push everything at least 5 meters in front of the camera
        let minZ: number = 5.0 * transform.scale;
        let maxZ: number = this._imageSphereRadius * transform.scale;

        let vertices: number[] = node.mesh.vertices;
        let numVertices: number = vertices.length / 3;
        let positions: Float32Array = new Float32Array(vertices.length);
        for (let i: number = 0; i < numVertices; ++i) {
            let index: number = 3 * i;
            let x: number = vertices[index + 0];
            let y: number = vertices[index + 1];
            let z: number = vertices[index + 2];

            let l: number = Math.sqrt(x * x + y * y + z * z);
            let boundedL: number = Math.max(minZ, Math.min(l, maxZ));
            let factor: number = boundedL / l;
            let p: THREE.Vector3 = new THREE.Vector3(x * factor, y * factor, z * factor);

            p.applyMatrix4(t);

            positions[index + 0] = p.x;
            positions[index + 1] = p.y;
            positions[index + 2] = p.z;
        }

        let faces: number[] = node.mesh.faces;
        let indices: Uint16Array = new Uint16Array(faces.length);
        for (let i: number = 0; i < faces.length; ++i) {
            indices[i] = faces[i];
        }

        let geometry: THREE.BufferGeometry = new THREE.BufferGeometry();

        geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
        geometry.setIndex(new THREE.BufferAttribute(indices, 1));

        return geometry;
    }
开发者ID:Caboosey,项目名称:mapillary-js,代码行数:41,代码来源:ImagePlaneFactory.ts

示例2: _getFlatImagePlaneGeo

    private _getFlatImagePlaneGeo(transform: Transform): THREE.BufferGeometry {
        let width: number = transform.width;
        let height: number = transform.height;
        let size: number = Math.max(width, height);
        let dx: number = width / 2.0 / size;
        let dy: number = height / 2.0 / size;

        let vertices: THREE.Vector3[] = [];
        vertices.push(transform.pixelToVertex(-dx, -dy, this._imagePlaneDepth));
        vertices.push(transform.pixelToVertex( dx, -dy, this._imagePlaneDepth));
        vertices.push(transform.pixelToVertex( dx, dy, this._imagePlaneDepth));
        vertices.push(transform.pixelToVertex(-dx, dy, this._imagePlaneDepth));

        let positions: Float32Array = new Float32Array(12);
        for (let i: number = 0; i < vertices.length; i++) {
            let index: number = 3 * i;
            positions[index + 0] = vertices[i].x;
            positions[index + 1] = vertices[i].y;
            positions[index + 2] = vertices[i].z;
        }

        let indices: Uint16Array = new Uint16Array(6);
        indices[0] = 0;
        indices[1] = 1;
        indices[2] = 3;
        indices[3] = 1;
        indices[4] = 2;
        indices[5] = 3;

        let geometry: THREE.BufferGeometry = new THREE.BufferGeometry();

        geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
        geometry.setIndex(new THREE.BufferAttribute(indices, 1));

        return geometry;
    }
开发者ID:Caboosey,项目名称:mapillary-js,代码行数:36,代码来源:ImagePlaneFactory.ts


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