Three.js設置線條寬度


在編寫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)

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM