summit/frontend/node_modules/three-stdlib/lines/LineSegmentsGeometry.cjs.map

1 line
8.1 KiB
Plaintext
Raw Normal View History

2025-12-08 16:31:30 +00:00
{"version":3,"file":"LineSegmentsGeometry.cjs","sources":["../../src/lines/LineSegmentsGeometry.js"],"sourcesContent":["import {\n Box3,\n Float32BufferAttribute,\n InstancedBufferGeometry,\n InstancedInterleavedBuffer,\n InterleavedBufferAttribute,\n Sphere,\n Vector3,\n WireframeGeometry,\n} from 'three'\n\nconst _box = /* @__PURE__ */ new Box3()\nconst _vector = /* @__PURE__ */ new Vector3()\n\nclass LineSegmentsGeometry extends InstancedBufferGeometry {\n constructor() {\n super()\n\n this.isLineSegmentsGeometry = true\n\n this.type = 'LineSegmentsGeometry'\n\n const positions = [-1, 2, 0, 1, 2, 0, -1, 1, 0, 1, 1, 0, -1, 0, 0, 1, 0, 0, -1, -1, 0, 1, -1, 0]\n const uvs = [-1, 2, 1, 2, -1, 1, 1, 1, -1, -1, 1, -1, -1, -2, 1, -2]\n const index = [0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5]\n\n this.setIndex(index)\n this.setAttribute('position', new Float32BufferAttribute(positions, 3))\n this.setAttribute('uv', new Float32BufferAttribute(uvs, 2))\n }\n\n applyMatrix4(matrix) {\n const start = this.attributes.instanceStart\n const end = this.attributes.instanceEnd\n\n if (start !== undefined) {\n start.applyMatrix4(matrix)\n\n end.applyMatrix4(matrix)\n\n start.needsUpdate = true\n }\n\n if (this.boundingBox !== null) {\n this.computeBoundingBox()\n }\n\n if (this.boundingSphere !== null) {\n this.computeBoundingSphere()\n }\n\n return this\n }\n\n setPositions(array) {\n let lineSegments\n\n if (array instanceof Float32Array) {\n lineSegments = array\n } else if (Array.isArray(array)) {\n lineSegments = new Float32Array(array)\n }\n\n const instanceBuffer = new InstancedInterleavedBuffer(lineSegments, 6, 1) // xyz, xyz\n\n this.setAttribute('instanceStart', new InterleavedBufferAttribute(instanceBuffer, 3, 0)) // xyz\n this.setAttribute('instanceEnd', new InterleavedBufferAttribute(instanceBuffer, 3, 3)) // xyz\n\n //\n\n this.computeBoundingBox()\n this.computeBoundingSphere()\n\n return this\n }\n\n setColors(array, itemSize = 3) {\n let colors\n\n if (array instanceof Float32Array) {\n colors = array\n } else if (Array.isArray(array)) {\n colors = new Float32Array(array)\n }\n\n const instanceColorBuffer = new InstancedInterleavedBuffer(colors, itemSize * 2, 1) // rgb(a), rgb(a)\n\n this.setAttribute('instanceColorStart', new InterleavedBufferAttribute(instanceColorBuffer, itemSize, 0)) // rgb(a)\n this.setAttribute('instanceColorEnd', new InterleavedBufferAttribute(instanceColorBuffer, itemSize, itemSize)) // rgb(a)\n\n return this\n }\n\n fromWireframeGeometry(geometry) {\n this.setPositions(geometry.attributes.position.array)\n\n return this\n }\n\n fromEdgesGeometry(geometry) {\n this.setPositions(geometry.attributes.position.array)\n\n return this\n }\n\n fromMesh(mesh) {\n this.fromWireframeGeometry(new WireframeGeometry(mesh.geometry))\n\n // set colors, maybe\n\n return this\n }\n\n fromLineSegments(lineSegments) {\n const geometry = lineSegments.geometry\n\n this.setPositions(geometry.attributes.position.array) // assumes non-indexed\n\n // set colors, maybe\n\n return this\n }\n\n computeBoundingBox() {\n if (this.boundingBox === null) {\n this.boundingBox = new Box3()\n }\n\n const start = this.attributes.instanceStart\n const end = this.attributes.instanceEnd\n\n if (start !== undefined && end !== undefined) {\n this.boundingBox.setFromBufferAttribute(start)\n\n _box.setFromBufferAttribute(end)\n\n this.boundingBox.union(_box)\n }\n }\n\n computeBoundingSphere() {\n if (this.boundingSphere === null) {\n this.boundingSphere = new Sphere()\n }\n\n if (this.boundingBox === null) {\n this.computeBoundingBox()\n }\n\n const start = this.attributes.instanceStart\n const end = this.attributes.instanceEnd\n\n if (start !== undefined && end !== undefined) {\n const center = this.boundingSphere.center\n\n this.boun