LineDashedMaterial in three.js
To use LineDashedMaterial in three.js:
var geometry = new THREE.Geometry();
geometry.vertices.push(new THREE.Vector3(590058.52, 231354.16, 766.42));
geometry.vertices.push(new THREE.Vector3(589941.68, 231476.67, 736.52));
geometry.vertices.push(new THREE.Vector3(589781.32, 231491.91, 757.73));
geometry.vertices.push(new THREE.Vector3(589711.88, 231445.56, 768.16));
geometry.vertices.push(new THREE.Vector3(589702.04, 231336.49, 772.91));
geometry.computeLineDistances();
let material = new THREE.LineDashedMaterial( {
color: 0xff0000,
linewidth: 1,
scale: 1,
dashSize: 5,
gapSize: 3,
} );
let line = new THREE.Line(geometry, material);
scene.add(line);
var geometry = new THREE.Geometry();
geometry.vertices.push(new THREE.Vector3(590058.52, 231354.16, 766.42));
geometry.vertices.push(new THREE.Vector3(589941.68, 231476.67, 736.52));
geometry.vertices.push(new THREE.Vector3(589781.32, 231491.91, 757.73));
geometry.vertices.push(new THREE.Vector3(589711.88, 231445.56, 768.16));
geometry.vertices.push(new THREE.Vector3(589702.04, 231336.49, 772.91));
geometry.computeLineDistances();
let material = new THREE.LineDashedMaterial( {
color: 0xff0000,
linewidth: 1,
scale: 1,
dashSize: 5,
gapSize: 3,
} );
let line = new THREE.Line(geometry, material);
scene.add(line);
Note:
- You need to call geometry.computeLineDistances() to make the dash work
- computeLineDistances( ) only works with Geometry (Not work with BufferGeometry)
- The linewidth has no effect in Windows, it is always equals 1
Comments
Post a Comment