具有pointcloudmaterial和linebasicmaterial的多个材料

时间:2014-09-20 07:38:35

标签: three.js

我想绘制一条带有两个顶点[10,10,0] [ - 10,-10,0]的直线。我可以成功创建一条线,

var geometry = new THREE.Geometry();
geometry.vertices.push(new THREE.Vector(10,10,0));
geometry.vertices.push(new THREE.Vector(-10,-10,0));
geometry.verticesNeedUpdate = true;
var material = new THREE.LineBasicMaterial({ color: 0xff0000, linewidth: 2, side: 2 });
var line = new THREE.Line(geometry, material);
scene.add(line);

我喜欢在线的顶点上绘制两个粒子,

var geometry = new THREE.Geometry();
geometry.vertices.push(new THREE.Vector(10,10,0));
geometry.vertices.push(new THREE.Vector(-10,-10,0));
geometry.verticesNeedUpdate = true;
var material = new THREE.LineBasicMaterial({ color: 0xff0000, linewidth: 2, side: 2 });
var material1 = new THREE.PointCloudMaterial({ color: 0xff0000, size: 3, sizeAttenuation: false });
var materials = new THREE.MeshFaceMaterial([material, material1]);
var line = new THREE.Mesh(geometry, materials);
scene.add(line);

此方法不起作用,网格已创建但在场景中不可见。 任何人都可以提出一些好的建议..

1 个答案:

答案 0 :(得分:0)

AFAIK网格需要至少3个顶点才能在网格中创建一个面。看看Line class docs如何创建一条线 例如。

var line = new THREE.Line( geometry, material )