三个 JS 虚线 material 未显示
Three JS dashed line material not showing
我正在尝试创建带有虚线图案的线条,但不知何故 material 没有反映在我正在创建的线条上,我只是看不出我在这里做错了什么...
我正在使用 this 示例中的代码,它应该会产生以下结果:
当我采取以下代码时:
var geometry = new THREE.Geometry();
geometry.vertices.push(new THREE.Vector3(0,0,0));
geometry.vertices.push(new THREE.Vector3(100,0,0));
var material = new THREE.LineDashedMaterial({ color: 0xffaa00, dashSize: 3, gapSize: 1, linewidth: 2 });
var mesh = new THREE.Line(geometry, material);
scene.add(mesh);
这是我得到的:
如有任何提示,我们将不胜感激!
geometry.computeLineDistances();
http://threejs.org/docs/#api/core/Geometry
.lineDistances
包含线几何图形顶点之间距离的数组。这是 LinePieces/LineDashedMaterial 正确呈现所必需的。也可以使用 computeLineDistances 生成线距离。
Geometry.computeLineDistances()
已被弃用,因此 Derte Trdelnik 的回答现在无法使用。
我正在尝试创建带有虚线图案的线条,但不知何故 material 没有反映在我正在创建的线条上,我只是看不出我在这里做错了什么...
我正在使用 this 示例中的代码,它应该会产生以下结果:
当我采取以下代码时:
var geometry = new THREE.Geometry();
geometry.vertices.push(new THREE.Vector3(0,0,0));
geometry.vertices.push(new THREE.Vector3(100,0,0));
var material = new THREE.LineDashedMaterial({ color: 0xffaa00, dashSize: 3, gapSize: 1, linewidth: 2 });
var mesh = new THREE.Line(geometry, material);
scene.add(mesh);
这是我得到的:
如有任何提示,我们将不胜感激!
geometry.computeLineDistances();
http://threejs.org/docs/#api/core/Geometry
.lineDistances
包含线几何图形顶点之间距离的数组。这是 LinePieces/LineDashedMaterial 正确呈现所必需的。也可以使用 computeLineDistances 生成线距离。
Geometry.computeLineDistances()
已被弃用,因此 Derte Trdelnik 的回答现在无法使用。