summit/frontend/node_modules/three-stdlib/interactive/SelectionBox.cjs.map

1 line
9.5 KiB
Plaintext
Raw Normal View History

2025-12-08 16:31:30 +00:00
{"version":3,"file":"SelectionBox.cjs","sources":["../../src/interactive/SelectionBox.js"],"sourcesContent":["import { Frustum, Vector3 } from 'three'\n\nconst frustum = /* @__PURE__ */ new Frustum()\nconst center = /* @__PURE__ */ new Vector3()\n\nconst tmpPoint = /* @__PURE__ */ new Vector3()\n\nconst vecNear = /* @__PURE__ */ new Vector3()\nconst vecTopLeft = /* @__PURE__ */ new Vector3()\nconst vecTopRight = /* @__PURE__ */ new Vector3()\nconst vecDownRight = /* @__PURE__ */ new Vector3()\nconst vecDownLeft = /* @__PURE__ */ new Vector3()\n\nconst vecFarTopLeft = /* @__PURE__ */ new Vector3()\nconst vecFarTopRight = /* @__PURE__ */ new Vector3()\nconst vecFarDownRight = /* @__PURE__ */ new Vector3()\nconst vecFarDownLeft = /* @__PURE__ */ new Vector3()\n\nconst vectemp1 = /* @__PURE__ */ new Vector3()\nconst vectemp2 = /* @__PURE__ */ new Vector3()\nconst vectemp3 = /* @__PURE__ */ new Vector3()\n\nclass SelectionBox {\n constructor(camera, scene, deep) {\n this.camera = camera\n this.scene = scene\n this.startPoint = new Vector3()\n this.endPoint = new Vector3()\n this.collection = []\n this.deep = deep || Number.MAX_VALUE\n }\n\n select(startPoint, endPoint) {\n this.startPoint = startPoint || this.startPoint\n this.endPoint = endPoint || this.endPoint\n this.collection = []\n\n this.updateFrustum(this.startPoint, this.endPoint)\n this.searchChildInFrustum(frustum, this.scene)\n\n return this.collection\n }\n\n updateFrustum(startPoint, endPoint) {\n startPoint = startPoint || this.startPoint\n endPoint = endPoint || this.endPoint\n\n // Avoid invalid frustum\n\n if (startPoint.x === endPoint.x) {\n endPoint.x += Number.EPSILON\n }\n\n if (startPoint.y === endPoint.y) {\n endPoint.y += Number.EPSILON\n }\n\n this.camera.updateProjectionMatrix()\n this.camera.updateMatrixWorld()\n\n if (this.camera.isPerspectiveCamera) {\n tmpPoint.copy(startPoint)\n tmpPoint.x = Math.min(startPoint.x, endPoint.x)\n tmpPoint.y = Math.max(startPoint.y, endPoint.y)\n endPoint.x = Math.max(startPoint.x, endPoint.x)\n endPoint.y = Math.min(startPoint.y, endPoint.y)\n\n vecNear.setFromMatrixPosition(this.camera.matrixWorld)\n vecTopLeft.copy(tmpPoint)\n vecTopRight.set(endPoint.x, tmpPoint.y, 0)\n vecDownRight.copy(endPoint)\n vecDownLeft.set(tmpPoint.x, endPoint.y, 0)\n\n vecTopLeft.unproject(this.camera)\n vecTopRight.unproject(this.camera)\n vecDownRight.unproject(this.camera)\n vecDownLeft.unproject(this.camera)\n\n vectemp1.copy(vecTopLeft).sub(vecNear)\n vectemp2.copy(vecTopRight).sub(vecNear)\n vectemp3.copy(vecDownRight).sub(vecNear)\n vectemp1.normalize()\n vectemp2.normalize()\n vectemp3.normalize()\n\n vectemp1.multiplyScalar(this.deep)\n vectemp2.multiplyScalar(this.deep)\n vectemp3.multiplyScalar(this.deep)\n vectemp1.add(vecNear)\n vectemp2.add(vecNear)\n vectemp3.add(vecNear)\n\n var planes = frustum.planes\n\n planes[0].setFromCoplanarPoints(vecNear, vecTopLeft, vecTopRight)\n planes[1].setFromCoplanarPoints(vecNear, vecTopRight, vecDownRight)\n planes[2].setFromCoplanarPoints(vecDownRight, vecDownLeft, vecNear)\n planes[3].setFromCoplanarPoints(vecDownLeft, vecTopLeft, vecNear)\n planes[4].setFromCoplanarPoints(vecTopRight, vecDownRight, vecDownLeft)\n planes[5].setFromCoplanarPoints(vectemp3, vectemp2, vectemp1)\n planes[5].normal.multiplyScalar(-1)\n } else if (this.camera.isOrthographicCamera) {\n const left = Math.min(startPoint.x, endPoint.x)\n const top = Math.max(startPoint.y, endPoint.y)\n const right = Math.max(startPoint.x, endPoint.x)\n const down = Math.min(startPoint.y, endPoint.y)\n\n vecTopLeft.set(left, top, -1)\n vecTopRight.set(right, top, -1)\n vecDownRight.set(right, down, -1)\n vecDownLeft.set(left, down, -1)\n\n vecFarTopLeft.set(left, top, 1)\n vecFarTopRight.set(right, top, 1)\n vecFarDownRigh