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‘
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)
原文:https://www.cnblogs.com/fitnessprogrammer/p/13679368.html