{"version":3,"file":"Wireframe.cjs","sources":["../../src/lines/Wireframe.js"],"sourcesContent":["import { InstancedInterleavedBuffer, InterleavedBufferAttribute, Mesh, Vector3 } from 'three'\nimport { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry'\nimport { LineMaterial } from '../lines/LineMaterial'\n\nconst _start = new Vector3()\nconst _end = new Vector3()\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\nexport { Wireframe }\n"],"names":["Vector3","Mesh","LineSegmentsGeometry","LineMaterial","InstancedInterleavedBuffer","InterleavedBufferAttribute"],"mappings":";;;;;AAIA,MAAM,SAAS,IAAIA,MAAAA,QAAS;AAC5B,MAAM,OAAO,IAAIA,MAAAA,QAAS;AAE1B,MAAM,kBAAkBC,MAAAA,KAAK;AAAA,EAC3B,YAAY,WAAW,IAAIC,0CAAsB,GAAE,WAAW,IAAIC,aAAAA,aAAa,EAAE,OAAO,KAAK,WAAW,SAAU,CAAA,GAAG;AACnH,UAAM,UAAU,QAAQ;AAExB,SAAK,cAAc;AAEnB,SAAK,OAAO;AAAA,EACb;AAAA;AAAA,EAID,uBAAuB;AACrB,UAAM,WAAW,KAAK;AAEtB,UAAM,gBAAgB,SAAS,WAAW;AAC1C,UAAM,cAAc,SAAS,WAAW;AACxC,UAAM,gBAAgB,IAAI,aAAa,IAAI,cAAc,KAAK;AAE9D,aAAS,IAAI,GAAG,IAAI,GAAG,IAAI,cAAc,OAAO,IAAI,GAAG,KAAK,KAAK,GAAG;AAClE,aAAO,oBAAoB,eAAe,CAAC;AAC3C,WAAK,oBAAoB,aAAa,CAAC;AAEvC,oBAAc,CAAC,IAAI,MAAM,IAAI,IAAI,cAAc,IAAI,CAAC;AACpD,oBAAc,IAAI,CAAC,IAAI,cAAc,CAAC,IAAI,OAAO,WAAW,IAAI;AAAA,IACjE;AAED,UAAM,yBAAyB,IAAIC,MAAAA,2BAA2B,eAAe,GAAG,CAAC;AAEjF,aAAS,aAAa,yBAAyB,IAAIC,MAA0B,2BAAC,wBAAwB,GAAG,CAAC,CAAC;AAC3G,aAAS,aAAa,uBAAuB,IAAIA,MAA0B,2BAAC,wBAAwB,GAAG,CAAC,CAAC;AAEzG,WAAO;AAAA,EACR;AACH;;"}