Buckets:
ktongue/docker_container / simsite /frontend /node_modules /three-stdlib /lines /LineSegmentsGeometry.cjs
| ; | |
| Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); | |
| const THREE = require("three"); | |
| const _box = /* @__PURE__ */ new THREE.Box3(); | |
| const _vector = /* @__PURE__ */ new THREE.Vector3(); | |
| class LineSegmentsGeometry extends THREE.InstancedBufferGeometry { | |
| constructor() { | |
| super(); | |
| this.isLineSegmentsGeometry = true; | |
| this.type = "LineSegmentsGeometry"; | |
| 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]; | |
| const uvs = [-1, 2, 1, 2, -1, 1, 1, 1, -1, -1, 1, -1, -1, -2, 1, -2]; | |
| const index = [0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5]; | |
| this.setIndex(index); | |
| this.setAttribute("position", new THREE.Float32BufferAttribute(positions, 3)); | |
| this.setAttribute("uv", new THREE.Float32BufferAttribute(uvs, 2)); | |
| } | |
| applyMatrix4(matrix) { | |
| const start = this.attributes.instanceStart; | |
| const end = this.attributes.instanceEnd; | |
| if (start !== void 0) { | |
| start.applyMatrix4(matrix); | |
| end.applyMatrix4(matrix); | |
| start.needsUpdate = true; | |
| } | |
| if (this.boundingBox !== null) { | |
| this.computeBoundingBox(); | |
| } | |
| if (this.boundingSphere !== null) { | |
| this.computeBoundingSphere(); | |
| } | |
| return this; | |
| } | |
| setPositions(array) { | |
| let lineSegments; | |
| if (array instanceof Float32Array) { | |
| lineSegments = array; | |
| } else if (Array.isArray(array)) { | |
| lineSegments = new Float32Array(array); | |
| } | |
| const instanceBuffer = new THREE.InstancedInterleavedBuffer(lineSegments, 6, 1); | |
| this.setAttribute("instanceStart", new THREE.InterleavedBufferAttribute(instanceBuffer, 3, 0)); | |
| this.setAttribute("instanceEnd", new THREE.InterleavedBufferAttribute(instanceBuffer, 3, 3)); | |
| this.computeBoundingBox(); | |
| this.computeBoundingSphere(); | |
| return this; | |
| } | |
| setColors(array, itemSize = 3) { | |
| let colors; | |
| if (array instanceof Float32Array) { | |
| colors = array; | |
| } else if (Array.isArray(array)) { | |
| colors = new Float32Array(array); | |
| } | |
| const instanceColorBuffer = new THREE.InstancedInterleavedBuffer(colors, itemSize * 2, 1); | |
| this.setAttribute("instanceColorStart", new THREE.InterleavedBufferAttribute(instanceColorBuffer, itemSize, 0)); | |
| this.setAttribute("instanceColorEnd", new THREE.InterleavedBufferAttribute(instanceColorBuffer, itemSize, itemSize)); | |
| return this; | |
| } | |
| fromWireframeGeometry(geometry) { | |
| this.setPositions(geometry.attributes.position.array); | |
| return this; | |
| } | |
| fromEdgesGeometry(geometry) { | |
| this.setPositions(geometry.attributes.position.array); | |
| return this; | |
| } | |
| fromMesh(mesh) { | |
| this.fromWireframeGeometry(new THREE.WireframeGeometry(mesh.geometry)); | |
| return this; | |
| } | |
| fromLineSegments(lineSegments) { | |
| const geometry = lineSegments.geometry; | |
| this.setPositions(geometry.attributes.position.array); | |
| return this; | |
| } | |
| computeBoundingBox() { | |
| if (this.boundingBox === null) { | |
| this.boundingBox = new THREE.Box3(); | |
| } | |
| const start = this.attributes.instanceStart; | |
| const end = this.attributes.instanceEnd; | |
| if (start !== void 0 && end !== void 0) { | |
| this.boundingBox.setFromBufferAttribute(start); | |
| _box.setFromBufferAttribute(end); | |
| this.boundingBox.union(_box); | |
| } | |
| } | |
| computeBoundingSphere() { | |
| if (this.boundingSphere === null) { | |
| this.boundingSphere = new THREE.Sphere(); | |
| } | |
| if (this.boundingBox === null) { | |
| this.computeBoundingBox(); | |
| } | |
| const start = this.attributes.instanceStart; | |
| const end = this.attributes.instanceEnd; | |
| if (start !== void 0 && end !== void 0) { | |
| const center = this.boundingSphere.center; | |
| this.boundingBox.getCenter(center); | |
| let maxRadiusSq = 0; | |
| for (let i = 0, il = start.count; i < il; i++) { | |
| _vector.fromBufferAttribute(start, i); | |
| maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(_vector)); | |
| _vector.fromBufferAttribute(end, i); | |
| maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(_vector)); | |
| } | |
| this.boundingSphere.radius = Math.sqrt(maxRadiusSq); | |
| if (isNaN(this.boundingSphere.radius)) { | |
| console.error( | |
| "THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.", | |
| this | |
| ); | |
| } | |
| } | |
| } | |
| toJSON() { | |
| } | |
| applyMatrix(matrix) { | |
| console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."); | |
| return this.applyMatrix4(matrix); | |
| } | |
| } | |
| exports.LineSegmentsGeometry = LineSegmentsGeometry; | |
| //# sourceMappingURL=LineSegmentsGeometry.cjs.map | |
Xet Storage Details
- Size:
- 4.66 kB
- Xet hash:
- f1242c3d283c76035b17174db1a2b3dcb1057f08eeabf501294217265447d1fd
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.