效果图:
代码实现:
方法一:
const pointArr = new Float32Array([
-347, 50, -520,
-347, 50, 127,
-345, 50, 145,
-339, 50, 185,
-284, 50, 270,
-71, 50, 543
])
const geometry = new THREE.BufferGeometry()
geometry.setAttribute('position', new BufferAttribute(pointArr, 3))
const lineMaterial = new THREE.LineBasicMaterial({ color: '#ff0000', side: THREE.DoubleSide })
const line = new THREE.Line(geometry, lineMaterial)
this.scene.add(line)
方法二:
const pointArr = [
-347, 50, -520,
-347, 50, 127,
-345, 50, 145,
-339, 50, 185,
-284, 50, 270,
-71, 50, 543
]
const geometry = new THREE.BufferGeometry()
geometry.setAttribute('position', new Float32BufferAttribute(pointArr, 3))
const lineMaterial = new THREE.LineBasicMaterial({ color: '#ff0000', side: THREE.DoubleSide })
const line = new THREE.Line(geometry, lineMaterial)
this.scene.add(line)