Threejs:绘制四边形网格

时间:2017-01-07 21:10:05

标签: three.js

我正在研究应用程序需要在妻子框架中显示四元素的项目(四元素计数可以是数千个),并且还能够选择四元素。我使用2 face3来生成四边形,这导致了trias之间的对角线边缘。什么是创建四元素的好方法

squareGeometry = new THREE.Geometry(); 
squareGeometry.vertices.push(new THREE.Vector3(-1.0,  1.0, 0.0)); 
squareGeometry.vertices.push(new THREE.Vector3( 1.0,  1.0, 0.0)); 
squareGeometry.vertices.push(new THREE.Vector3( 1.0, -1.0, 0.0)); 
squareGeometry.vertices.push(new THREE.Vector3(-1.0, -1.0, 0.0)); 
squareGeometry.faces.push(new THREE.Face3(0, 1, 2)); 
squareGeometry.faces.push(new THREE.Face3(0, 3, 2));

material = new THREE.MeshBasicMaterial({color: 0x999999, specular: 0x101010, side: THREE.DoubleSide, wireframe: true});
mesh = new THREE.Mesh( squareGeometry, material );
scene.add(mesh)

更新:    Three.JS wireframe material - all polygons vs. just edges上的建议有助于为硬边创建线框。如何共享边缘。下面是一个带有四个QUAD元素的图像,如图所示,只有自由边/硬边显示在线框中 注意:我使用JsonLoader加载一个JSON文件,该文件有QUAD面和定义它们的顶点

使用自定义着色器是隐藏对角线的更好选择吗?

4 Quad Shaded

var material = new THREE.MeshPhongMaterial( {
    color: 0xeee000, 
    opacity: 0.5,
    transparent: true,
    side: THREE.DoubleSide,
    shading: THREE.FlatShading,
    polygonOffset: true,
    polygonOffsetFactor: 1, 
    polygonOffsetUnits: 1
} );
mesh = new THREE.Mesh( geometry, material );

scene.add( mesh );

var geo = new THREE.EdgesGeometry( mesh.geometry); 
var mat = new THREE.LineBasicMaterial( { color: 0xffffff, linewidth: 1 } );
var wireframe = new THREE.LineSegments( geo, mat );
mesh.add( wireframe );

0 个答案:

没有答案