如何修复Face4到Face3

时间:2017-09-09 16:21:49

标签: three.js

我找到了旧代码,它几乎可以工作。

import random
import asyncio
from aiohttp import ClientSession
import csv

headers =[]
def extractsites(file):
    sites = []
    readfile = open(file, "r")
    reader = csv.reader(readfile, delimiter=",")
    raw = list(reader)
    for a in raw:
        sites.append((a[1]))
    return sites

async def bound_fetch(sem, url):
    async with sem:
        print("doing request for "+ url)
        async with ClientSession() as session:
            async with session.get(url) as response:
                responseheader = await response.headers
                print(headers)


async def run():
    urls = extractsites("cisco-umbrella.csv")
    tasks = []
    sem = asyncio.Semaphore(100)
    for i in urls:
        task = asyncio.ensure_future(bound_fetch(sem, "http://"+i))
        tasks.append(task)
    headers = await asyncio.wait(*tasks)
    print(headers)


def main():
    loop = asyncio.get_event_loop()
    future = asyncio.ensure_future(run())
    loop.run_until_complete(future)

if __name__ == '__main__':
    main()

我找到了解决方法(bound_headersvar geom = new THREE.Geometry(); geom.vertices = testRect.verts(); for ( var i = 0; i < verts.length; i+=4 ) { geom.faceVertexUvs[0].push([ new THREE.Vector2(1.0 - ((verts[i].x - testRect.x) / testRect.width), 1.0 - ((verts[i].z - testRect.y) / testRect.height)), new THREE.Vector2(1.0 - ((verts[i+1].x - testRect.x) / testRect.width), 1.0 - ((verts[i+1].z - testRect.y) / testRect.height)), new THREE.Vector2(1.0 - ((verts[i+2].x - testRect.x) / testRect.width), 1.0 - ((verts[i+2].z - testRect.y) / testRect.height)), new THREE.Vector2(1.0 - ((verts[i+3].x - testRect.x) / testRect.width), 1.0 - ((verts[i+3].z - testRect.y) / testRect.height)) ]); } for ( var i=0, vl=verts.length; i<vl; i+=4) { geom.faces.push(new THREE.Face4(i, i+1, i+2, i+3)); }

Face4

但似乎没有足够的多边形http://dt-byte.ru/fea28697.png

试图这样做

Face3

但有些事情没有帮助(

帮助解决此问题)

1 个答案:

答案 0 :(得分:2)

如果几何体由四边形(A,B,C,D)定义,则可以通过2个三角形(A,B,C)和(A,C,D)绘制相同的几何体。 p>

quad to triangles

以某种方式调整代码:

for ( var i=0, vl=verts.length; i<vl; i+=4) {

    geom.faces.push( new THREE.Face3( i, i+1, i+2 ) );
    geom.faces.push( new THREE.Face3( i, i+2, i+3 ) );
}