在編寫Three.js程序的時候,你設置線模型Line對應線材質LineBasicMaterial的線寬屬性.lineWidth,是無效的。
以下是vue中設置three.js線條寬度:
1.導入three.js
import * as THREE from 'three'
import OrbitControls from 'three-orbitcontrols'
import { Line2 } from 'three/examples/jsm/lines/Line2'
import { LineGeometry } from 'three/examples/jsm/lines/LineGeometry'
import { LineMaterial } from 'three/examples/jsm/lines/LineMaterial'
2.創建線條模型
var geometry = new LineGeometry()
var pointArr = [
-100, 0, 0,
-100, 100, 0,
0, 0, 0,
100, 100, 0,
100, 0, 0
]
geometry.setPositions(pointArr)
var material = new LineMaterial({
color: 0xffffff,
linewidth: 5
})
material.resolution.set(window.innerWidth, window.innerHeight)
var line = new Line2(geometry, material)
line.computeLineDistances()
scene.add(line)