首页 > Web开发 > 详细

Three.js设置线条宽度

时间:2020-09-16 16:05:07      阅读:409      评论:0      收藏:0      [点我收藏+]

在编写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)

  

Three.js设置线条宽度

原文:https://www.cnblogs.com/fitnessprogrammer/p/13679368.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!