Three.js显示物体的运动轨迹

    技术2022-07-11  74

    在实际应用中需要显示出一些物体的移动轨迹,比如模拟激光切割钢板时,钢板上需要显示激光发射头在钢板上切割的轨迹。`

    关键代码:

    pathGeometry = new THREE.BufferGeometry(); pathVertices = new Float32Array(pathPointsBuf); pathGeometry.setAttribute('position', new THREE.BufferAttribute(pathVertices, 3)); var pathMaterial = new THREE.LineBasicMaterial({ color: 0xff0000 }); pathLine = new THREE.Line(pathGeometry, pathMaterial); ... pathPointsBuf.push(fire.position.x, 410, fire.position.z); pathVertices = new Float32Array(pathPointsBuf); pathGeometry.setAttribute('position', new THREE.BufferAttribute(pathVertices, 3)); scene.add(pathLine);
    Processed: 0.012, SQL: 9