{"version":3,"file":"Wireframe.cjs","sources":["../../src/lines/Wireframe.js"],"sourcesContent":["import { InstancedInterleavedBuffer, InterleavedBufferAttribute, Mesh, Vector3, Vector4 } from 'three'\nimport { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry'\nimport { LineMaterial } from '../lines/LineMaterial'\n\nconst _start = /* @__PURE__ */ new Vector3()\nconst _end = /* @__PURE__ */ new Vector3()\nconst _viewport = /* @__PURE__ */ new Vector4()\n\nclass Wireframe extends Mesh {\n constructor(geometry = new LineSegmentsGeometry(), material = new LineMaterial({ color: Math.random() * 0xffffff })) {\n super(geometry, material)\n\n this.isWireframe = true\n\n this.type = 'Wireframe'\n }\n\n // for backwards-compatibility, but could be a method of LineSegmentsGeometry...\n\n computeLineDistances() {\n const geometry = this.geometry\n\n const instanceStart = geometry.attributes.instanceStart\n const instanceEnd = geometry.attributes.instanceEnd\n const lineDistances = new Float32Array(2 * instanceStart.count)\n\n for (let i = 0, j = 0, l = instanceStart.count; i < l; i++, j += 2) {\n _start.fromBufferAttribute(instanceStart, i)\n _end.fromBufferAttribute(instanceEnd, i)\n\n lineDistances[j] = j === 0 ? 0 : lineDistances[j - 1]\n lineDistances[j + 1] = lineDistances[j] + _start.distanceTo(_end)\n }\n\n const instanceDistanceBuffer = new InstancedInterleavedBuffer(lineDistances, 2, 1) // d0, d1\n\n geometry.setAttribute('instanceDistanceStart', new InterleavedBufferAttribute(instanceDistanceBuffer, 1, 0)) // d0\n geometry.setAttribute('instanceDistanceEnd', new InterleavedBufferAttribute(instanceDistanceBuffer, 1, 1)) // d1\n\n return this\n }\n\n onBeforeRender(renderer) {\n const uniforms = this.material.uniforms\n\n if (uniforms && uniforms.resolution) {\n renderer.getViewport(_viewport)\n this.material.uniforms.resolution.value.set(_viewport.z, _viewport.w)\n }\n }\n}\n\nexport { Wireframe }\n"],"names":["Vector3","Vector4","Mesh","LineSegmentsGeometry","LineMaterial","InstancedInterleavedBuffer","InterleavedBufferAttribute"],"mappings":";;;;;A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