three-stdlib 2.31.0 → 2.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/_polyfill/uv1.cjs +6 -0
  2. package/_polyfill/uv1.cjs.map +1 -0
  3. package/_polyfill/uv1.d.ts +5 -0
  4. package/_polyfill/uv1.js +6 -0
  5. package/_polyfill/uv1.js.map +1 -0
  6. package/controls/ArcballControls.cjs.map +1 -1
  7. package/controls/ArcballControls.d.ts +2 -2
  8. package/controls/ArcballControls.js.map +1 -1
  9. package/controls/FirstPersonControls.cjs.map +1 -1
  10. package/controls/FirstPersonControls.d.ts +1 -1
  11. package/controls/FirstPersonControls.js.map +1 -1
  12. package/exporters/ColladaExporter.cjs +3 -2
  13. package/exporters/ColladaExporter.cjs.map +1 -1
  14. package/exporters/ColladaExporter.js +3 -2
  15. package/exporters/ColladaExporter.js.map +1 -1
  16. package/lines/LineSegments2.cjs +3 -2
  17. package/lines/LineSegments2.cjs.map +1 -1
  18. package/lines/LineSegments2.js +3 -2
  19. package/lines/LineSegments2.js.map +1 -1
  20. package/loaders/ColladaLoader.cjs +7 -6
  21. package/loaders/ColladaLoader.cjs.map +1 -1
  22. package/loaders/ColladaLoader.js +7 -6
  23. package/loaders/ColladaLoader.js.map +1 -1
  24. package/loaders/FBXLoader.cjs +4 -4
  25. package/loaders/FBXLoader.cjs.map +1 -1
  26. package/loaders/FBXLoader.js +4 -4
  27. package/loaders/FBXLoader.js.map +1 -1
  28. package/loaders/LWOLoader.cjs +3 -1
  29. package/loaders/LWOLoader.cjs.map +1 -1
  30. package/loaders/LWOLoader.js +3 -1
  31. package/loaders/LWOLoader.js.map +1 -1
  32. package/misc/ProgressiveLightmap.cjs +12 -10
  33. package/misc/ProgressiveLightmap.cjs.map +1 -1
  34. package/misc/ProgressiveLightmap.js +12 -10
  35. package/misc/ProgressiveLightmap.js.map +1 -1
  36. package/modifiers/TessellateModifier.cjs +20 -19
  37. package/modifiers/TessellateModifier.cjs.map +1 -1
  38. package/modifiers/TessellateModifier.js +20 -19
  39. package/modifiers/TessellateModifier.js.map +1 -1
  40. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"LineSegments2.cjs","sources":["../../src/lines/LineSegments2.js"],"sourcesContent":["import {\n Box3,\n InstancedInterleavedBuffer,\n InterleavedBufferAttribute,\n Line3,\n MathUtils,\n Matrix4,\n Mesh,\n Sphere,\n Vector3,\n Vector4,\n} from 'three'\nimport { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry'\nimport { LineMaterial } from '../lines/LineMaterial'\n\nconst _viewport = new Vector4();\n\nconst _start = new Vector3()\nconst _end = new Vector3()\n\nconst _start4 = new Vector4()\nconst _end4 = new Vector4()\n\nconst _ssOrigin = new Vector4()\nconst _ssOrigin3 = new Vector3()\nconst _mvMatrix = new Matrix4()\nconst _line = new Line3()\nconst _closestPoint = new Vector3()\n\nconst _box = new Box3()\nconst _sphere = new Sphere()\nconst _clipToWorldVector = new Vector4()\n\nlet _ray, _lineWidth\n\n// Returns the margin required to expand by in world space given the distance from the camera,\n// line width, resolution, and camera projection\nfunction getWorldSpaceHalfWidth(camera, distance, resolution) {\n // transform into clip space, adjust the x and y values by the pixel width offset, then\n // transform back into world space to get world offset. Note clip space is [-1, 1] so full\n // width does not need to be halved.\n _clipToWorldVector.set(0, 0, -distance, 1.0).applyMatrix4(camera.projectionMatrix)\n _clipToWorldVector.multiplyScalar(1.0 / _clipToWorldVector.w)\n _clipToWorldVector.x = _lineWidth / resolution.width\n _clipToWorldVector.y = _lineWidth / resolution.height\n _clipToWorldVector.applyMatrix4(camera.projectionMatrixInverse)\n _clipToWorldVector.multiplyScalar(1.0 / _clipToWorldVector.w)\n\n return Math.abs(Math.max(_clipToWorldVector.x, _clipToWorldVector.y))\n}\n\nfunction raycastWorldUnits(lineSegments, intersects) {\n\n const matrixWorld = lineSegments.matrixWorld;\n const geometry = lineSegments.geometry;\n const instanceStart = geometry.attributes.instanceStart;\n const instanceEnd = geometry.attributes.instanceEnd;\n const segmentCount = Math.min(geometry.instanceCount, instanceStart.count);\n\n for (let i = 0, l = segmentCount; i < l; i++) {\n _line.start.fromBufferAttribute(instanceStart, i)\n _line.end.fromBufferAttribute(instanceEnd, i)\n\n _line.applyMatrix4(matrixWorld);\n\n const pointOnLine = new Vector3()\n const point = new Vector3()\n\n _ray.distanceSqToSegment(_line.start, _line.end, point, pointOnLine)\n const isInside = point.distanceTo(pointOnLine) < _lineWidth * 0.5\n\n if (isInside) {\n intersects.push({\n point,\n pointOnLine,\n distance: _ray.origin.distanceTo(point),\n object: lineSegments,\n face: null,\n faceIndex: i,\n uv: null,\n uv2: null,\n })\n }\n }\n}\n\nfunction raycastScreenSpace(lineSegments, camera, intersects) {\n const projectionMatrix = camera.projectionMatrix\n const material = lineSegments.material\n const resolution = material.resolution\n const matrixWorld = lineSegments.matrixWorld\n\n const geometry = lineSegments.geometry\n const instanceStart = geometry.attributes.instanceStart\n const instanceEnd = geometry.attributes.instanceEnd\n const segmentCount = Math.min(geometry.instanceCount, instanceStart.count);\n\n const near = -camera.near\n\n //\n\n // pick a point 1 unit out along the ray to avoid the ray origin\n // sitting at the camera origin which will cause \"w\" to be 0 when\n // applying the projection matrix.\n _ray.at(1, _ssOrigin)\n\n // ndc space [ - 1.0, 1.0 ]\n _ssOrigin.w = 1\n _ssOrigin.applyMatrix4(camera.matrixWorldInverse)\n _ssOrigin.applyMatrix4(projectionMatrix)\n _ssOrigin.multiplyScalar(1 / _ssOrigin.w)\n\n // screen space\n _ssOrigin.x *= resolution.x / 2\n _ssOrigin.y *= resolution.y / 2\n _ssOrigin.z = 0\n\n _ssOrigin3.copy(_ssOrigin)\n\n _mvMatrix.multiplyMatrices(camera.matrixWorldInverse, matrixWorld)\n\n for (let i = 0, l = segmentCount; i < l; i++) {\n _start4.fromBufferAttribute(instanceStart, i)\n _end4.fromBufferAttribute(instanceEnd, i)\n\n _start4.w = 1\n _end4.w = 1\n\n // camera space\n _start4.applyMatrix4(_mvMatrix)\n _end4.applyMatrix4(_mvMatrix)\n\n // skip the segment if it's entirely behind the camera\n const isBehindCameraNear = _start4.z > near && _end4.z > near\n if (isBehindCameraNear) {\n continue\n }\n\n // trim the segment if it extends behind camera near\n if (_start4.z > near) {\n const deltaDist = _start4.z - _end4.z\n const t = (_start4.z - near) / deltaDist\n _start4.lerp(_end4, t)\n } else if (_end4.z > near) {\n const deltaDist = _end4.z - _start4.z\n const t = (_end4.z - near) / deltaDist\n _end4.lerp(_start4, t)\n }\n\n // clip space\n _start4.applyMatrix4(projectionMatrix)\n _end4.applyMatrix4(projectionMatrix)\n\n // ndc space [ - 1.0, 1.0 ]\n _start4.multiplyScalar(1 / _start4.w)\n _end4.multiplyScalar(1 / _end4.w)\n\n // screen space\n _start4.x *= resolution.x / 2\n _start4.y *= resolution.y / 2\n\n _end4.x *= resolution.x / 2\n _end4.y *= resolution.y / 2\n\n // create 2d segment\n _line.start.copy(_start4)\n _line.start.z = 0\n\n _line.end.copy(_end4)\n _line.end.z = 0\n\n // get closest point on ray to segment\n const param = _line.closestPointToPointParameter(_ssOrigin3, true)\n _line.at(param, _closestPoint)\n\n // check if the intersection point is within clip space\n const zPos = MathUtils.lerp(_start4.z, _end4.z, param)\n const isInClipSpace = zPos >= -1 && zPos <= 1\n\n const isInside = _ssOrigin3.distanceTo(_closestPoint) < _lineWidth * 0.5\n\n if (isInClipSpace && isInside) {\n _line.start.fromBufferAttribute(instanceStart, i)\n _line.end.fromBufferAttribute(instanceEnd, i)\n\n _line.start.applyMatrix4(matrixWorld)\n _line.end.applyMatrix4(matrixWorld)\n\n const pointOnLine = new Vector3()\n const point = new Vector3()\n\n _ray.distanceSqToSegment(_line.start, _line.end, point, pointOnLine)\n\n intersects.push({\n point: point,\n pointOnLine: pointOnLine,\n distance: _ray.origin.distanceTo(point),\n object: lineSegments,\n face: null,\n faceIndex: i,\n uv: null,\n uv2: null,\n })\n }\n }\n}\n\nclass LineSegments2 extends Mesh {\n constructor(geometry = new LineSegmentsGeometry(), material = new LineMaterial({ color: Math.random() * 0xffffff })) {\n super(geometry, material)\n\n this.isLineSegments2 = true\n\n this.type = 'LineSegments2'\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 raycast(raycaster, intersects) {\n const worldUnits = this.material.worldUnits\n const camera = raycaster.camera\n\n if (camera === null && !worldUnits) {\n console.error(\n 'LineSegments2: \"Raycaster.camera\" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.',\n )\n }\n\n const threshold = raycaster.params.Line2 !== undefined ? raycaster.params.Line2.threshold || 0 : 0\n\n _ray = raycaster.ray\n\n const matrixWorld = this.matrixWorld\n const geometry = this.geometry\n const material = this.material\n\n _lineWidth = material.linewidth + threshold\n\n // check if we intersect the sphere bounds\n if (geometry.boundingSphere === null) {\n geometry.computeBoundingSphere()\n }\n\n _sphere.copy(geometry.boundingSphere).applyMatrix4(matrixWorld)\n\n // increase the sphere bounds by the worst case line screen space width\n let sphereMargin\n if (worldUnits) {\n sphereMargin = _lineWidth * 0.5\n } else {\n const distanceToSphere = Math.max(camera.near, _sphere.distanceToPoint(_ray.origin))\n sphereMargin = getWorldSpaceHalfWidth(camera, distanceToSphere, material.resolution)\n }\n\n _sphere.radius += sphereMargin\n\n if (_ray.intersectsSphere(_sphere) === false) {\n return\n }\n\n // check if we intersect the box bounds\n if (geometry.boundingBox === null) {\n geometry.computeBoundingBox()\n }\n\n _box.copy(geometry.boundingBox).applyMatrix4(matrixWorld)\n\n // increase the box bounds by the worst case line width\n let boxMargin\n if (worldUnits) {\n boxMargin = _lineWidth * 0.5\n } else {\n const distanceToBox = Math.max(camera.near, _box.distanceToPoint(_ray.origin))\n boxMargin = getWorldSpaceHalfWidth(camera, distanceToBox, material.resolution)\n }\n\n _box.expandByScalar(boxMargin)\n\n if (_ray.intersectsBox(_box) === false) {\n return\n }\n\n if (worldUnits) {\n raycastWorldUnits(this, intersects)\n } else {\n raycastScreenSpace(this, camera, intersects)\n }\n }\n\n onBeforeRender(renderer) {\n\n const uniforms = this.material.uniforms;\n\n if (uniforms && uniforms.resolution) {\n\n renderer.getViewport(_viewport);\n this.material.uniforms.resolution.value.set(_viewport.z, _viewport.w);\n\n }\n\n }\n}\n\nexport { LineSegments2 }\n"],"names":["Vector4","Vector3","Matrix4","Line3","Box3","Sphere","MathUtils","Mesh","LineSegmentsGeometry","LineMaterial","InstancedInterleavedBuffer","InterleavedBufferAttribute"],"mappings":";;;;;AAeA,MAAM,YAAY,IAAIA,MAAAA;AAEtB,MAAM,SAAS,IAAIC,MAAAA,QAAS;AAC5B,MAAM,OAAO,IAAIA,MAAAA,QAAS;AAE1B,MAAM,UAAU,IAAID,MAAAA,QAAS;AAC7B,MAAM,QAAQ,IAAIA,MAAAA,QAAS;AAE3B,MAAM,YAAY,IAAIA,MAAAA,QAAS;AAC/B,MAAM,aAAa,IAAIC,MAAAA,QAAS;AAChC,MAAM,YAAY,IAAIC,MAAAA,QAAS;AAC/B,MAAM,QAAQ,IAAIC,MAAAA,MAAO;AACzB,MAAM,gBAAgB,IAAIF,MAAAA,QAAS;AAEnC,MAA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IACjC;AAED,YAAQ,KAAK,SAAS,cAAc,EAAE,aAAa,WAAW;AAG9D,QAAI;AACJ,QAAI,YAAY;AACd,qBAAe,aAAa;AAAA,IAClC,OAAW;AACL,YAAM,mBAAmB,KAAK,IAAI,OAAO,MAAM,QAAQ,gBAAgB,KAAK,MAAM,CAAC;AACnF,qBAAe,uBAAuB,QAAQ,kBAAkB,SAAS,UAAU;AAAA,IACpF;AAED,YAAQ,UAAU;AAElB,QAAI,KAAK,iBAAiB,OAAO,MAAM,OAAO;AAC5C;AAAA,IACD;AAGD,QAAI,SAAS,gBAAgB,MAAM;AACjC,eAAS,mBAAoB;AAAA,IAC9B;AAED,SAAK,KAAK,SAAS,WAAW,EAAE,aAAa,WAAW;AAGxD,QAAI;AACJ,QAAI,YAAY;AACd,kBAAY,aAAa;AAAA,IAC/B,OAAW;AACL,YAAM,gBAAgB,KAAK,IAAI,OAAO,MAAM,KAAK,gBAAgB,KAAK,MAAM,CAAC;AAC7E,kBAAY,uBAAuB,QAAQ,eAAe,SAAS,UAAU;AAAA,IAC9E;AAED,SAAK,eAAe,SAAS;AAE7B,QAAI,KAAK,cAAc,IAAI,MAAM,OAAO;AACtC;AAAA,IACD;AAED,QAAI,YAAY;AACd,wBAAkB,MAAM,UAAU;AAAA,IACxC,OAAW;AACL,yBAAmB,MAAM,QAAQ,UAAU;AAAA,IAC5C;AAAA,EACF;AAAA,EAED,eAAe,UAAU;AAEvB,UAAM,WAAW,KAAK,SAAS;AAE/B,QAAI,YAAY,SAAS,YAAY;AAEnC,eAAS,YAAY,SAAS;AAC9B,WAAK,SAAS,SAAS,WAAW,MAAM,IAAI,UAAU,GAAG,UAAU,CAAC;AAAA,IAErE;AAAA,EAEF;AACH;;"}
1
+ {"version":3,"file":"LineSegments2.cjs","sources":["../../src/lines/LineSegments2.js"],"sourcesContent":["import {\n Box3,\n InstancedInterleavedBuffer,\n InterleavedBufferAttribute,\n Line3,\n MathUtils,\n Matrix4,\n Mesh,\n Sphere,\n Vector3,\n Vector4,\n} from 'three'\nimport { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry'\nimport { LineMaterial } from '../lines/LineMaterial'\nimport { UV1 } from '../_polyfill/uv1'\n\nconst _viewport = new Vector4();\n\nconst _start = new Vector3()\nconst _end = new Vector3()\n\nconst _start4 = new Vector4()\nconst _end4 = new Vector4()\n\nconst _ssOrigin = new Vector4()\nconst _ssOrigin3 = new Vector3()\nconst _mvMatrix = new Matrix4()\nconst _line = new Line3()\nconst _closestPoint = new Vector3()\n\nconst _box = new Box3()\nconst _sphere = new Sphere()\nconst _clipToWorldVector = new Vector4()\n\nlet _ray, _lineWidth\n\n// Returns the margin required to expand by in world space given the distance from the camera,\n// line width, resolution, and camera projection\nfunction getWorldSpaceHalfWidth(camera, distance, resolution) {\n // transform into clip space, adjust the x and y values by the pixel width offset, then\n // transform back into world space to get world offset. Note clip space is [-1, 1] so full\n // width does not need to be halved.\n _clipToWorldVector.set(0, 0, -distance, 1.0).applyMatrix4(camera.projectionMatrix)\n _clipToWorldVector.multiplyScalar(1.0 / _clipToWorldVector.w)\n _clipToWorldVector.x = _lineWidth / resolution.width\n _clipToWorldVector.y = _lineWidth / resolution.height\n _clipToWorldVector.applyMatrix4(camera.projectionMatrixInverse)\n _clipToWorldVector.multiplyScalar(1.0 / _clipToWorldVector.w)\n\n return Math.abs(Math.max(_clipToWorldVector.x, _clipToWorldVector.y))\n}\n\nfunction raycastWorldUnits(lineSegments, intersects) {\n\n const matrixWorld = lineSegments.matrixWorld;\n const geometry = lineSegments.geometry;\n const instanceStart = geometry.attributes.instanceStart;\n const instanceEnd = geometry.attributes.instanceEnd;\n const segmentCount = Math.min(geometry.instanceCount, instanceStart.count);\n\n for (let i = 0, l = segmentCount; i < l; i++) {\n _line.start.fromBufferAttribute(instanceStart, i)\n _line.end.fromBufferAttribute(instanceEnd, i)\n\n _line.applyMatrix4(matrixWorld);\n\n const pointOnLine = new Vector3()\n const point = new Vector3()\n\n _ray.distanceSqToSegment(_line.start, _line.end, point, pointOnLine)\n const isInside = point.distanceTo(pointOnLine) < _lineWidth * 0.5\n\n if (isInside) {\n intersects.push({\n point,\n pointOnLine,\n distance: _ray.origin.distanceTo(point),\n object: lineSegments,\n face: null,\n faceIndex: i,\n uv: null,\n [UV1]: null,\n })\n }\n }\n}\n\nfunction raycastScreenSpace(lineSegments, camera, intersects) {\n const projectionMatrix = camera.projectionMatrix\n const material = lineSegments.material\n const resolution = material.resolution\n const matrixWorld = lineSegments.matrixWorld\n\n const geometry = lineSegments.geometry\n const instanceStart = geometry.attributes.instanceStart\n const instanceEnd = geometry.attributes.instanceEnd\n const segmentCount = Math.min(geometry.instanceCount, instanceStart.count);\n\n const near = -camera.near\n\n //\n\n // pick a point 1 unit out along the ray to avoid the ray origin\n // sitting at the camera origin which will cause \"w\" to be 0 when\n // applying the projection matrix.\n _ray.at(1, _ssOrigin)\n\n // ndc space [ - 1.0, 1.0 ]\n _ssOrigin.w = 1\n _ssOrigin.applyMatrix4(camera.matrixWorldInverse)\n _ssOrigin.applyMatrix4(projectionMatrix)\n _ssOrigin.multiplyScalar(1 / _ssOrigin.w)\n\n // screen space\n _ssOrigin.x *= resolution.x / 2\n _ssOrigin.y *= resolution.y / 2\n _ssOrigin.z = 0\n\n _ssOrigin3.copy(_ssOrigin)\n\n _mvMatrix.multiplyMatrices(camera.matrixWorldInverse, matrixWorld)\n\n for (let i = 0, l = segmentCount; i < l; i++) {\n _start4.fromBufferAttribute(instanceStart, i)\n _end4.fromBufferAttribute(instanceEnd, i)\n\n _start4.w = 1\n _end4.w = 1\n\n // camera space\n _start4.applyMatrix4(_mvMatrix)\n _end4.applyMatrix4(_mvMatrix)\n\n // skip the segment if it's entirely behind the camera\n const isBehindCameraNear = _start4.z > near && _end4.z > near\n if (isBehindCameraNear) {\n continue\n }\n\n // trim the segment if it extends behind camera near\n if (_start4.z > near) {\n const deltaDist = _start4.z - _end4.z\n const t = (_start4.z - near) / deltaDist\n _start4.lerp(_end4, t)\n } else if (_end4.z > near) {\n const deltaDist = _end4.z - _start4.z\n const t = (_end4.z - near) / deltaDist\n _end4.lerp(_start4, t)\n }\n\n // clip space\n _start4.applyMatrix4(projectionMatrix)\n _end4.applyMatrix4(projectionMatrix)\n\n // ndc space [ - 1.0, 1.0 ]\n _start4.multiplyScalar(1 / _start4.w)\n _end4.multiplyScalar(1 / _end4.w)\n\n // screen space\n _start4.x *= resolution.x / 2\n _start4.y *= resolution.y / 2\n\n _end4.x *= resolution.x / 2\n _end4.y *= resolution.y / 2\n\n // create 2d segment\n _line.start.copy(_start4)\n _line.start.z = 0\n\n _line.end.copy(_end4)\n _line.end.z = 0\n\n // get closest point on ray to segment\n const param = _line.closestPointToPointParameter(_ssOrigin3, true)\n _line.at(param, _closestPoint)\n\n // check if the intersection point is within clip space\n const zPos = MathUtils.lerp(_start4.z, _end4.z, param)\n const isInClipSpace = zPos >= -1 && zPos <= 1\n\n const isInside = _ssOrigin3.distanceTo(_closestPoint) < _lineWidth * 0.5\n\n if (isInClipSpace && isInside) {\n _line.start.fromBufferAttribute(instanceStart, i)\n _line.end.fromBufferAttribute(instanceEnd, i)\n\n _line.start.applyMatrix4(matrixWorld)\n _line.end.applyMatrix4(matrixWorld)\n\n const pointOnLine = new Vector3()\n const point = new Vector3()\n\n _ray.distanceSqToSegment(_line.start, _line.end, point, pointOnLine)\n\n intersects.push({\n point: point,\n pointOnLine: pointOnLine,\n distance: _ray.origin.distanceTo(point),\n object: lineSegments,\n face: null,\n faceIndex: i,\n uv: null,\n [UV1]: null,\n })\n }\n }\n}\n\nclass LineSegments2 extends Mesh {\n constructor(geometry = new LineSegmentsGeometry(), material = new LineMaterial({ color: Math.random() * 0xffffff })) {\n super(geometry, material)\n\n this.isLineSegments2 = true\n\n this.type = 'LineSegments2'\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 raycast(raycaster, intersects) {\n const worldUnits = this.material.worldUnits\n const camera = raycaster.camera\n\n if (camera === null && !worldUnits) {\n console.error(\n 'LineSegments2: \"Raycaster.camera\" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.',\n )\n }\n\n const threshold = raycaster.params.Line2 !== undefined ? raycaster.params.Line2.threshold || 0 : 0\n\n _ray = raycaster.ray\n\n const matrixWorld = this.matrixWorld\n const geometry = this.geometry\n const material = this.material\n\n _lineWidth = material.linewidth + threshold\n\n // check if we intersect the sphere bounds\n if (geometry.boundingSphere === null) {\n geometry.computeBoundingSphere()\n }\n\n _sphere.copy(geometry.boundingSphere).applyMatrix4(matrixWorld)\n\n // increase the sphere bounds by the worst case line screen space width\n let sphereMargin\n if (worldUnits) {\n sphereMargin = _lineWidth * 0.5\n } else {\n const distanceToSphere = Math.max(camera.near, _sphere.distanceToPoint(_ray.origin))\n sphereMargin = getWorldSpaceHalfWidth(camera, distanceToSphere, material.resolution)\n }\n\n _sphere.radius += sphereMargin\n\n if (_ray.intersectsSphere(_sphere) === false) {\n return\n }\n\n // check if we intersect the box bounds\n if (geometry.boundingBox === null) {\n geometry.computeBoundingBox()\n }\n\n _box.copy(geometry.boundingBox).applyMatrix4(matrixWorld)\n\n // increase the box bounds by the worst case line width\n let boxMargin\n if (worldUnits) {\n boxMargin = _lineWidth * 0.5\n } else {\n const distanceToBox = Math.max(camera.near, _box.distanceToPoint(_ray.origin))\n boxMargin = getWorldSpaceHalfWidth(camera, distanceToBox, material.resolution)\n }\n\n _box.expandByScalar(boxMargin)\n\n if (_ray.intersectsBox(_box) === false) {\n return\n }\n\n if (worldUnits) {\n raycastWorldUnits(this, intersects)\n } else {\n raycastScreenSpace(this, camera, intersects)\n }\n }\n\n onBeforeRender(renderer) {\n\n const uniforms = this.material.uniforms;\n\n if (uniforms && uniforms.resolution) {\n\n renderer.getViewport(_viewport);\n this.material.uniforms.resolution.value.set(_viewport.z, _viewport.w);\n\n }\n\n }\n}\n\nexport { LineSegments2 }\n"],"names":["Vector4","Vector3","Matrix4","Line3","Box3","Sphere","UV1","MathUtils","Mesh","LineSegmentsGeometry","LineMaterial","InstancedInterleavedBuffer","InterleavedBufferAttribute"],"mappings":";;;;;;AAgBA,MAAM,YAAY,IAAIA,MAAAA;AAEtB,MAAM,SAAS,IAAIC,MAAAA,QAAS;AAC5B,MAAM,OAAO,IAAIA,MAAAA,QAAS;AAE1B,MAAM,UAAU,IAAID,MAAAA,QAAS;AAC7B,MAAM,QAAQ,IAAIA,MAAAA,QAAS;AAE3B,MAAM,YAAY,IAAIA,MAAAA,QAAS;AAC/B,MAAM,aAAa,IAAIC,MAAAA,QAAS;AAChC,MAAM,YAAY,IAAIC,MAAAA,QAAS;AAC/B,MAAM,QAAQ,IAAIC,MAAAA,MAAO;AACzB,MAAM,gBAAgB,IAAIF,MAAAA,QAAS;AAEnC,MAAM,OAAO,IAAIG,MAAAA,KAAM;AACvB,MAAM,UAAU,IAAIC,MAAAA,OAAQ;AAC5B,MAAM,qBAAqB,IAAIL,MAAAA,QAAS;AAExC,IAAI,MAAM;AAIV,SAAS,uBAAuB,QAAQ,UAAU,YAAY;AAI5D,qBAAmB,IAAI,GAAG,GAAG,CAAC,UAAU,CAAG,EAAE,aAAa,OAAO,gBAAgB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e,uBAAuB,QAAQ,kBAAkB,SAAS,UAAU;AAAA,IACpF;AAED,YAAQ,UAAU;AAElB,QAAI,KAAK,iBAAiB,OAAO,MAAM,OAAO;AAC5C;AAAA,IACD;AAGD,QAAI,SAAS,gBAAgB,MAAM;AACjC,eAAS,mBAAoB;AAAA,IAC9B;AAED,SAAK,KAAK,SAAS,WAAW,EAAE,aAAa,WAAW;AAGxD,QAAI;AACJ,QAAI,YAAY;AACd,kBAAY,aAAa;AAAA,IAC/B,OAAW;AACL,YAAM,gBAAgB,KAAK,IAAI,OAAO,MAAM,KAAK,gBAAgB,KAAK,MAAM,CAAC;AAC7E,kBAAY,uBAAuB,QAAQ,eAAe,SAAS,UAAU;AAAA,IAC9E;AAED,SAAK,eAAe,SAAS;AAE7B,QAAI,KAAK,cAAc,IAAI,MAAM,OAAO;AACtC;AAAA,IACD;AAED,QAAI,YAAY;AACd,wBAAkB,MAAM,UAAU;AAAA,IACxC,OAAW;AACL,yBAAmB,MAAM,QAAQ,UAAU;AAAA,IAC5C;AAAA,EACF;AAAA,EAED,eAAe,UAAU;AAEvB,UAAM,WAAW,KAAK,SAAS;AAE/B,QAAI,YAAY,SAAS,YAAY;AAEnC,eAAS,YAAY,SAAS;AAC9B,WAAK,SAAS,SAAS,WAAW,MAAM,IAAI,UAAU,GAAG,UAAU,CAAC;AAAA,IAErE;AAAA,EAEF;AACH;;"}
@@ -1,6 +1,7 @@
1
1
  import { Vector4, Vector3, Matrix4, Line3, Box3, Sphere, Mesh, InstancedInterleavedBuffer, InterleavedBufferAttribute, MathUtils } from "three";
2
2
  import { LineSegmentsGeometry } from "./LineSegmentsGeometry.js";
3
3
  import { LineMaterial } from "./LineMaterial.js";
4
+ import { UV1 } from "../_polyfill/uv1.js";
4
5
  const _viewport = new Vector4();
5
6
  const _start = new Vector3();
6
7
  const _end = new Vector3();
@@ -47,7 +48,7 @@ function raycastWorldUnits(lineSegments, intersects) {
47
48
  face: null,
48
49
  faceIndex: i,
49
50
  uv: null,
50
- uv2: null
51
+ [UV1]: null
51
52
  });
52
53
  }
53
54
  }
@@ -125,7 +126,7 @@ function raycastScreenSpace(lineSegments, camera, intersects) {
125
126
  face: null,
126
127
  faceIndex: i,
127
128
  uv: null,
128
- uv2: null
129
+ [UV1]: null
129
130
  });
130
131
  }
131
132
  }
@@ -1 +1 @@
1
- {"version":3,"file":"LineSegments2.js","sources":["../../src/lines/LineSegments2.js"],"sourcesContent":["import {\n Box3,\n InstancedInterleavedBuffer,\n InterleavedBufferAttribute,\n Line3,\n MathUtils,\n Matrix4,\n Mesh,\n Sphere,\n Vector3,\n Vector4,\n} from 'three'\nimport { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry'\nimport { LineMaterial } from '../lines/LineMaterial'\n\nconst _viewport = new Vector4();\n\nconst _start = new Vector3()\nconst _end = new Vector3()\n\nconst _start4 = new Vector4()\nconst _end4 = new Vector4()\n\nconst _ssOrigin = new Vector4()\nconst _ssOrigin3 = new Vector3()\nconst _mvMatrix = new Matrix4()\nconst _line = new Line3()\nconst _closestPoint = new Vector3()\n\nconst _box = new Box3()\nconst _sphere = new Sphere()\nconst _clipToWorldVector = new Vector4()\n\nlet _ray, _lineWidth\n\n// Returns the margin required to expand by in world space given the distance from the camera,\n// line width, resolution, and camera projection\nfunction getWorldSpaceHalfWidth(camera, distance, resolution) {\n // transform into clip space, adjust the x and y values by the pixel width offset, then\n // transform back into world space to get world offset. Note clip space is [-1, 1] so full\n // width does not need to be halved.\n _clipToWorldVector.set(0, 0, -distance, 1.0).applyMatrix4(camera.projectionMatrix)\n _clipToWorldVector.multiplyScalar(1.0 / _clipToWorldVector.w)\n _clipToWorldVector.x = _lineWidth / resolution.width\n _clipToWorldVector.y = _lineWidth / resolution.height\n _clipToWorldVector.applyMatrix4(camera.projectionMatrixInverse)\n _clipToWorldVector.multiplyScalar(1.0 / _clipToWorldVector.w)\n\n return Math.abs(Math.max(_clipToWorldVector.x, _clipToWorldVector.y))\n}\n\nfunction raycastWorldUnits(lineSegments, intersects) {\n\n const matrixWorld = lineSegments.matrixWorld;\n const geometry = lineSegments.geometry;\n const instanceStart = geometry.attributes.instanceStart;\n const instanceEnd = geometry.attributes.instanceEnd;\n const segmentCount = Math.min(geometry.instanceCount, instanceStart.count);\n\n for (let i = 0, l = segmentCount; i < l; i++) {\n _line.start.fromBufferAttribute(instanceStart, i)\n _line.end.fromBufferAttribute(instanceEnd, i)\n\n _line.applyMatrix4(matrixWorld);\n\n const pointOnLine = new Vector3()\n const point = new Vector3()\n\n _ray.distanceSqToSegment(_line.start, _line.end, point, pointOnLine)\n const isInside = point.distanceTo(pointOnLine) < _lineWidth * 0.5\n\n if (isInside) {\n intersects.push({\n point,\n pointOnLine,\n distance: _ray.origin.distanceTo(point),\n object: lineSegments,\n face: null,\n faceIndex: i,\n uv: null,\n uv2: null,\n })\n }\n }\n}\n\nfunction raycastScreenSpace(lineSegments, camera, intersects) {\n const projectionMatrix = camera.projectionMatrix\n const material = lineSegments.material\n const resolution = material.resolution\n const matrixWorld = lineSegments.matrixWorld\n\n const geometry = lineSegments.geometry\n const instanceStart = geometry.attributes.instanceStart\n const instanceEnd = geometry.attributes.instanceEnd\n const segmentCount = Math.min(geometry.instanceCount, instanceStart.count);\n\n const near = -camera.near\n\n //\n\n // pick a point 1 unit out along the ray to avoid the ray origin\n // sitting at the camera origin which will cause \"w\" to be 0 when\n // applying the projection matrix.\n _ray.at(1, _ssOrigin)\n\n // ndc space [ - 1.0, 1.0 ]\n _ssOrigin.w = 1\n _ssOrigin.applyMatrix4(camera.matrixWorldInverse)\n _ssOrigin.applyMatrix4(projectionMatrix)\n _ssOrigin.multiplyScalar(1 / _ssOrigin.w)\n\n // screen space\n _ssOrigin.x *= resolution.x / 2\n _ssOrigin.y *= resolution.y / 2\n _ssOrigin.z = 0\n\n _ssOrigin3.copy(_ssOrigin)\n\n _mvMatrix.multiplyMatrices(camera.matrixWorldInverse, matrixWorld)\n\n for (let i = 0, l = segmentCount; i < l; i++) {\n _start4.fromBufferAttribute(instanceStart, i)\n _end4.fromBufferAttribute(instanceEnd, i)\n\n _start4.w = 1\n _end4.w = 1\n\n // camera space\n _start4.applyMatrix4(_mvMatrix)\n _end4.applyMatrix4(_mvMatrix)\n\n // skip the segment if it's entirely behind the camera\n const isBehindCameraNear = _start4.z > near && _end4.z > near\n if (isBehindCameraNear) {\n continue\n }\n\n // trim the segment if it extends behind camera near\n if (_start4.z > near) {\n const deltaDist = _start4.z - _end4.z\n const t = (_start4.z - near) / deltaDist\n _start4.lerp(_end4, t)\n } else if (_end4.z > near) {\n const deltaDist = _end4.z - _start4.z\n const t = (_end4.z - near) / deltaDist\n _end4.lerp(_start4, t)\n }\n\n // clip space\n _start4.applyMatrix4(projectionMatrix)\n _end4.applyMatrix4(projectionMatrix)\n\n // ndc space [ - 1.0, 1.0 ]\n _start4.multiplyScalar(1 / _start4.w)\n _end4.multiplyScalar(1 / _end4.w)\n\n // screen space\n _start4.x *= resolution.x / 2\n _start4.y *= resolution.y / 2\n\n _end4.x *= resolution.x / 2\n _end4.y *= resolution.y / 2\n\n // create 2d segment\n _line.start.copy(_start4)\n _line.start.z = 0\n\n _line.end.copy(_end4)\n _line.end.z = 0\n\n // get closest point on ray to segment\n const param = _line.closestPointToPointParameter(_ssOrigin3, true)\n _line.at(param, _closestPoint)\n\n // check if the intersection point is within clip space\n const zPos = MathUtils.lerp(_start4.z, _end4.z, param)\n const isInClipSpace = zPos >= -1 && zPos <= 1\n\n const isInside = _ssOrigin3.distanceTo(_closestPoint) < _lineWidth * 0.5\n\n if (isInClipSpace && isInside) {\n _line.start.fromBufferAttribute(instanceStart, i)\n _line.end.fromBufferAttribute(instanceEnd, i)\n\n _line.start.applyMatrix4(matrixWorld)\n _line.end.applyMatrix4(matrixWorld)\n\n const pointOnLine = new Vector3()\n const point = new Vector3()\n\n _ray.distanceSqToSegment(_line.start, _line.end, point, pointOnLine)\n\n intersects.push({\n point: point,\n pointOnLine: pointOnLine,\n distance: _ray.origin.distanceTo(point),\n object: lineSegments,\n face: null,\n faceIndex: i,\n uv: null,\n uv2: null,\n })\n }\n }\n}\n\nclass LineSegments2 extends Mesh {\n constructor(geometry = new LineSegmentsGeometry(), material = new LineMaterial({ color: Math.random() * 0xffffff })) {\n super(geometry, material)\n\n this.isLineSegments2 = true\n\n this.type = 'LineSegments2'\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 raycast(raycaster, intersects) {\n const worldUnits = this.material.worldUnits\n const camera = raycaster.camera\n\n if (camera === null && !worldUnits) {\n console.error(\n 'LineSegments2: \"Raycaster.camera\" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.',\n )\n }\n\n const threshold = raycaster.params.Line2 !== undefined ? raycaster.params.Line2.threshold || 0 : 0\n\n _ray = raycaster.ray\n\n const matrixWorld = this.matrixWorld\n const geometry = this.geometry\n const material = this.material\n\n _lineWidth = material.linewidth + threshold\n\n // check if we intersect the sphere bounds\n if (geometry.boundingSphere === null) {\n geometry.computeBoundingSphere()\n }\n\n _sphere.copy(geometry.boundingSphere).applyMatrix4(matrixWorld)\n\n // increase the sphere bounds by the worst case line screen space width\n let sphereMargin\n if (worldUnits) {\n sphereMargin = _lineWidth * 0.5\n } else {\n const distanceToSphere = Math.max(camera.near, _sphere.distanceToPoint(_ray.origin))\n sphereMargin = getWorldSpaceHalfWidth(camera, distanceToSphere, material.resolution)\n }\n\n _sphere.radius += sphereMargin\n\n if (_ray.intersectsSphere(_sphere) === false) {\n return\n }\n\n // check if we intersect the box bounds\n if (geometry.boundingBox === null) {\n geometry.computeBoundingBox()\n }\n\n _box.copy(geometry.boundingBox).applyMatrix4(matrixWorld)\n\n // increase the box bounds by the worst case line width\n let boxMargin\n if (worldUnits) {\n boxMargin = _lineWidth * 0.5\n } else {\n const distanceToBox = Math.max(camera.near, _box.distanceToPoint(_ray.origin))\n boxMargin = getWorldSpaceHalfWidth(camera, distanceToBox, material.resolution)\n }\n\n _box.expandByScalar(boxMargin)\n\n if (_ray.intersectsBox(_box) === false) {\n return\n }\n\n if (worldUnits) {\n raycastWorldUnits(this, intersects)\n } else {\n raycastScreenSpace(this, camera, intersects)\n }\n }\n\n onBeforeRender(renderer) {\n\n const uniforms = this.material.uniforms;\n\n if (uniforms && uniforms.resolution) {\n\n renderer.getViewport(_viewport);\n this.material.uniforms.resolution.value.set(_viewport.z, _viewport.w);\n\n }\n\n }\n}\n\nexport { LineSegments2 }\n"],"names":[],"mappings":";;;AAeA,MAAM,YAAY,IAAI;AAEtB,MAAM,SAAS,IAAI,QAAS;AAC5B,MAAM,OAAO,IAAI,QAAS;AAE1B,MAAM,UAAU,IAAI,QAAS;AAC7B,MAAM,QAAQ,IAAI,QAAS;AAE3B,MAAM,YAAY,IAAI,QAAS;AAC/B,MAAM,aAAa,IAAI,QAAS;AAChC,MAAM,YAAY,IAAI,QAAS;AAC/B,MAAM,QAAQ,IAAI,MAAO;AACzB,MAAM,gBAAgB,IAAI,QAAS;AAEnC,MAAM,OAAO,IAAI,KAAM;AACvB,MAAM,UAAU,IAAI,OAAQ;AAC5B,MAAM,qBAAqB,IAAI,QAAS;AAExC,IAAI,MAAM;AA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K,MAAM,CAAC;AACnF,qBAAe,uBAAuB,QAAQ,kBAAkB,SAAS,UAAU;AAAA,IACpF;AAED,YAAQ,UAAU;AAElB,QAAI,KAAK,iBAAiB,OAAO,MAAM,OAAO;AAC5C;AAAA,IACD;AAGD,QAAI,SAAS,gBAAgB,MAAM;AACjC,eAAS,mBAAoB;AAAA,IAC9B;AAED,SAAK,KAAK,SAAS,WAAW,EAAE,aAAa,WAAW;AAGxD,QAAI;AACJ,QAAI,YAAY;AACd,kBAAY,aAAa;AAAA,IAC/B,OAAW;AACL,YAAM,gBAAgB,KAAK,IAAI,OAAO,MAAM,KAAK,gBAAgB,KAAK,MAAM,CAAC;AAC7E,kBAAY,uBAAuB,QAAQ,eAAe,SAAS,UAAU;AAAA,IAC9E;AAED,SAAK,eAAe,SAAS;AAE7B,QAAI,KAAK,cAAc,IAAI,MAAM,OAAO;AACtC;AAAA,IACD;AAED,QAAI,YAAY;AACd,wBAAkB,MAAM,UAAU;AAAA,IACxC,OAAW;AACL,yBAAmB,MAAM,QAAQ,UAAU;AAAA,IAC5C;AAAA,EACF;AAAA,EAED,eAAe,UAAU;AAEvB,UAAM,WAAW,KAAK,SAAS;AAE/B,QAAI,YAAY,SAAS,YAAY;AAEnC,eAAS,YAAY,SAAS;AAC9B,WAAK,SAAS,SAAS,WAAW,MAAM,IAAI,UAAU,GAAG,UAAU,CAAC;AAAA,IAErE;AAAA,EAEF;AACH;"}
1
+ {"version":3,"file":"LineSegments2.js","sources":["../../src/lines/LineSegments2.js"],"sourcesContent":["import {\n Box3,\n InstancedInterleavedBuffer,\n InterleavedBufferAttribute,\n Line3,\n MathUtils,\n Matrix4,\n Mesh,\n Sphere,\n Vector3,\n Vector4,\n} from 'three'\nimport { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry'\nimport { LineMaterial } from '../lines/LineMaterial'\nimport { UV1 } from '../_polyfill/uv1'\n\nconst _viewport = new Vector4();\n\nconst _start = new Vector3()\nconst _end = new Vector3()\n\nconst _start4 = new Vector4()\nconst _end4 = new Vector4()\n\nconst _ssOrigin = new Vector4()\nconst _ssOrigin3 = new Vector3()\nconst _mvMatrix = new Matrix4()\nconst _line = new Line3()\nconst _closestPoint = new Vector3()\n\nconst _box = new Box3()\nconst _sphere = new Sphere()\nconst _clipToWorldVector = new Vector4()\n\nlet _ray, _lineWidth\n\n// Returns the margin required to expand by in world space given the distance from the camera,\n// line width, resolution, and camera projection\nfunction getWorldSpaceHalfWidth(camera, distance, resolution) {\n // transform into clip space, adjust the x and y values by the pixel width offset, then\n // transform back into world space to get world offset. Note clip space is [-1, 1] so full\n // width does not need to be halved.\n _clipToWorldVector.set(0, 0, -distance, 1.0).applyMatrix4(camera.projectionMatrix)\n _clipToWorldVector.multiplyScalar(1.0 / _clipToWorldVector.w)\n _clipToWorldVector.x = _lineWidth / resolution.width\n _clipToWorldVector.y = _lineWidth / resolution.height\n _clipToWorldVector.applyMatrix4(camera.projectionMatrixInverse)\n _clipToWorldVector.multiplyScalar(1.0 / _clipToWorldVector.w)\n\n return Math.abs(Math.max(_clipToWorldVector.x, _clipToWorldVector.y))\n}\n\nfunction raycastWorldUnits(lineSegments, intersects) {\n\n const matrixWorld = lineSegments.matrixWorld;\n const geometry = lineSegments.geometry;\n const instanceStart = geometry.attributes.instanceStart;\n const instanceEnd = geometry.attributes.instanceEnd;\n const segmentCount = Math.min(geometry.instanceCount, instanceStart.count);\n\n for (let i = 0, l = segmentCount; i < l; i++) {\n _line.start.fromBufferAttribute(instanceStart, i)\n _line.end.fromBufferAttribute(instanceEnd, i)\n\n _line.applyMatrix4(matrixWorld);\n\n const pointOnLine = new Vector3()\n const point = new Vector3()\n\n _ray.distanceSqToSegment(_line.start, _line.end, point, pointOnLine)\n const isInside = point.distanceTo(pointOnLine) < _lineWidth * 0.5\n\n if (isInside) {\n intersects.push({\n point,\n pointOnLine,\n distance: _ray.origin.distanceTo(point),\n object: lineSegments,\n face: null,\n faceIndex: i,\n uv: null,\n [UV1]: null,\n })\n }\n }\n}\n\nfunction raycastScreenSpace(lineSegments, camera, intersects) {\n const projectionMatrix = camera.projectionMatrix\n const material = lineSegments.material\n const resolution = material.resolution\n const matrixWorld = lineSegments.matrixWorld\n\n const geometry = lineSegments.geometry\n const instanceStart = geometry.attributes.instanceStart\n const instanceEnd = geometry.attributes.instanceEnd\n const segmentCount = Math.min(geometry.instanceCount, instanceStart.count);\n\n const near = -camera.near\n\n //\n\n // pick a point 1 unit out along the ray to avoid the ray origin\n // sitting at the camera origin which will cause \"w\" to be 0 when\n // applying the projection matrix.\n _ray.at(1, _ssOrigin)\n\n // ndc space [ - 1.0, 1.0 ]\n _ssOrigin.w = 1\n _ssOrigin.applyMatrix4(camera.matrixWorldInverse)\n _ssOrigin.applyMatrix4(projectionMatrix)\n _ssOrigin.multiplyScalar(1 / _ssOrigin.w)\n\n // screen space\n _ssOrigin.x *= resolution.x / 2\n _ssOrigin.y *= resolution.y / 2\n _ssOrigin.z = 0\n\n _ssOrigin3.copy(_ssOrigin)\n\n _mvMatrix.multiplyMatrices(camera.matrixWorldInverse, matrixWorld)\n\n for (let i = 0, l = segmentCount; i < l; i++) {\n _start4.fromBufferAttribute(instanceStart, i)\n _end4.fromBufferAttribute(instanceEnd, i)\n\n _start4.w = 1\n _end4.w = 1\n\n // camera space\n _start4.applyMatrix4(_mvMatrix)\n _end4.applyMatrix4(_mvMatrix)\n\n // skip the segment if it's entirely behind the camera\n const isBehindCameraNear = _start4.z > near && _end4.z > near\n if (isBehindCameraNear) {\n continue\n }\n\n // trim the segment if it extends behind camera near\n if (_start4.z > near) {\n const deltaDist = _start4.z - _end4.z\n const t = (_start4.z - near) / deltaDist\n _start4.lerp(_end4, t)\n } else if (_end4.z > near) {\n const deltaDist = _end4.z - _start4.z\n const t = (_end4.z - near) / deltaDist\n _end4.lerp(_start4, t)\n }\n\n // clip space\n _start4.applyMatrix4(projectionMatrix)\n _end4.applyMatrix4(projectionMatrix)\n\n // ndc space [ - 1.0, 1.0 ]\n _start4.multiplyScalar(1 / _start4.w)\n _end4.multiplyScalar(1 / _end4.w)\n\n // screen space\n _start4.x *= resolution.x / 2\n _start4.y *= resolution.y / 2\n\n _end4.x *= resolution.x / 2\n _end4.y *= resolution.y / 2\n\n // create 2d segment\n _line.start.copy(_start4)\n _line.start.z = 0\n\n _line.end.copy(_end4)\n _line.end.z = 0\n\n // get closest point on ray to segment\n const param = _line.closestPointToPointParameter(_ssOrigin3, true)\n _line.at(param, _closestPoint)\n\n // check if the intersection point is within clip space\n const zPos = MathUtils.lerp(_start4.z, _end4.z, param)\n const isInClipSpace = zPos >= -1 && zPos <= 1\n\n const isInside = _ssOrigin3.distanceTo(_closestPoint) < _lineWidth * 0.5\n\n if (isInClipSpace && isInside) {\n _line.start.fromBufferAttribute(instanceStart, i)\n _line.end.fromBufferAttribute(instanceEnd, i)\n\n _line.start.applyMatrix4(matrixWorld)\n _line.end.applyMatrix4(matrixWorld)\n\n const pointOnLine = new Vector3()\n const point = new Vector3()\n\n _ray.distanceSqToSegment(_line.start, _line.end, point, pointOnLine)\n\n intersects.push({\n point: point,\n pointOnLine: pointOnLine,\n distance: _ray.origin.distanceTo(point),\n object: lineSegments,\n face: null,\n faceIndex: i,\n uv: null,\n [UV1]: null,\n })\n }\n }\n}\n\nclass LineSegments2 extends Mesh {\n constructor(geometry = new LineSegmentsGeometry(), material = new LineMaterial({ color: Math.random() * 0xffffff })) {\n super(geometry, material)\n\n this.isLineSegments2 = true\n\n this.type = 'LineSegments2'\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 raycast(raycaster, intersects) {\n const worldUnits = this.material.worldUnits\n const camera = raycaster.camera\n\n if (camera === null && !worldUnits) {\n console.error(\n 'LineSegments2: \"Raycaster.camera\" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.',\n )\n }\n\n const threshold = raycaster.params.Line2 !== undefined ? raycaster.params.Line2.threshold || 0 : 0\n\n _ray = raycaster.ray\n\n const matrixWorld = this.matrixWorld\n const geometry = this.geometry\n const material = this.material\n\n _lineWidth = material.linewidth + threshold\n\n // check if we intersect the sphere bounds\n if (geometry.boundingSphere === null) {\n geometry.computeBoundingSphere()\n }\n\n _sphere.copy(geometry.boundingSphere).applyMatrix4(matrixWorld)\n\n // increase the sphere bounds by the worst case line screen space width\n let sphereMargin\n if (worldUnits) {\n sphereMargin = _lineWidth * 0.5\n } else {\n const distanceToSphere = Math.max(camera.near, _sphere.distanceToPoint(_ray.origin))\n sphereMargin = getWorldSpaceHalfWidth(camera, distanceToSphere, material.resolution)\n }\n\n _sphere.radius += sphereMargin\n\n if (_ray.intersectsSphere(_sphere) === false) {\n return\n }\n\n // check if we intersect the box bounds\n if (geometry.boundingBox === null) {\n geometry.computeBoundingBox()\n }\n\n _box.copy(geometry.boundingBox).applyMatrix4(matrixWorld)\n\n // increase the box bounds by the worst case line width\n let boxMargin\n if (worldUnits) {\n boxMargin = _lineWidth * 0.5\n } else {\n const distanceToBox = Math.max(camera.near, _box.distanceToPoint(_ray.origin))\n boxMargin = getWorldSpaceHalfWidth(camera, distanceToBox, material.resolution)\n }\n\n _box.expandByScalar(boxMargin)\n\n if (_ray.intersectsBox(_box) === false) {\n return\n }\n\n if (worldUnits) {\n raycastWorldUnits(this, intersects)\n } else {\n raycastScreenSpace(this, camera, intersects)\n }\n }\n\n onBeforeRender(renderer) {\n\n const uniforms = this.material.uniforms;\n\n if (uniforms && uniforms.resolution) {\n\n renderer.getViewport(_viewport);\n this.material.uniforms.resolution.value.set(_viewport.z, _viewport.w);\n\n }\n\n }\n}\n\nexport { LineSegments2 }\n"],"names":[],"mappings":";;;;AAgBA,MAAM,YAAY,IAAI;AAEtB,MAAM,SAAS,IAAI,QAAS;AAC5B,MAAM,OAAO,IAAI,QAAS;AAE1B,MAAM,UAAU,IAAI,QAAS;AAC7B,MAAM,QAAQ,IAAI,QAAS;AAE3B,MAAM,YAAY,IAAI,QAAS;AAC/B,MAAM,aAAa,IAAI,QAAS;AAChC,MAAM,YAAY,IAAI,QAAS;AAC/B,MAAM,QAAQ,IAAI,MAAO;AACzB,MAAM,gBAAgB,IAAI,QAAS;AAEnC,MAAM,OAAO,IAAI,KAAM;AACvB,MAAM,UAAU,IAAI,OAAQ;AAC5B,MAAM,qBAAqB,IAAI,QAAS;AAExC,IAAI,MAAM;AAIV,SAAS,uBAAuB,QAAQ,UAAU,YAAY;AAI5D,qBAAmB,IAAI,GAAG,GAAG,CAAC,UAAU,CAAG,EAAE,aAAa,OAAO,gBAAgB;AACjF,qBAAmB,eAAe,IAAM,mBAAmB,CAAC;AAC5D,qBAAmB,IAAI,aAAa,WAAW;AAC/C,qBAAmB,IAAI,aAAa,WAAW;AAC/C,qBAAmB,aAAa,OAAO,uBAAuB;AAC9D,qBAAmB,eAAe,IAAM,mBAAmB,CAAC;AAE5D,SAAO,KAAK,IAAI,KAAK,IAAI,mBAAmB,GAAG,mBAAmB,CAAC,CAAC;AACtE;AAEA,SAAS,kBAAkB,cAAc,YAAY;AAEnD,QAAM,cAAc,aAAa;AACjC,QAAM,WAAW,aAAa;AAC9B,QAAM,gBAAgB,SAAS,WAAW;AAC1C,QAAM,cAAc,SAAS,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;AAE7B,QAAI,KAAK,cAAc,IAAI,MAAM,OAAO;AACtC;AAAA,IACD;AAED,QAAI,YAAY;AACd,wBAAkB,MAAM,UAAU;AAAA,IACxC,OAAW;AACL,yBAAmB,MAAM,QAAQ,UAAU;AAAA,IAC5C;AAAA,EACF;AAAA,EAED,eAAe,UAAU;AAEvB,UAAM,WAAW,KAAK,SAAS;AAE/B,QAAI,YAAY,SAAS,YAAY;AAEnC,eAAS,YAAY,SAAS;AAC9B,WAAK,SAAS,SAAS,WAAW,MAAM,IAAI,UAAU,GAAG,UAAU,CAAC;AAAA,IAErE;AAAA,EAEF;AACH;"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const THREE = require("three");
4
4
  const TGALoader = require("./TGALoader.cjs");
5
+ const uv1 = require("../_polyfill/uv1.cjs");
5
6
  class ColladaLoader extends THREE.Loader {
6
7
  constructor(manager) {
7
8
  super(manager);
@@ -1365,7 +1366,7 @@ class ColladaLoader extends THREE.Loader {
1365
1366
  const position2 = { array: [], stride: 0 };
1366
1367
  const normal = { array: [], stride: 0 };
1367
1368
  const uv = { array: [], stride: 0 };
1368
- const uv2 = { array: [], stride: 0 };
1369
+ const uv1$1 = { array: [], stride: 0 };
1369
1370
  const color = { array: [], stride: 0 };
1370
1371
  const skinIndex = { array: [], stride: 4 };
1371
1372
  const skinWeight = { array: [], stride: 4 };
@@ -1443,7 +1444,7 @@ class ColladaLoader extends THREE.Loader {
1443
1444
  uv.stride = sources[id].stride;
1444
1445
  break;
1445
1446
  case "TEXCOORD1":
1446
- buildGeometryData(primitive, sources[id], input.offset, uv2.array);
1447
+ buildGeometryData(primitive, sources[id], input.offset, uv1$1.array);
1447
1448
  uv.stride = sources[id].stride;
1448
1449
  break;
1449
1450
  default:
@@ -1464,8 +1465,8 @@ class ColladaLoader extends THREE.Loader {
1464
1465
  uv.stride = sources[input.id].stride;
1465
1466
  break;
1466
1467
  case "TEXCOORD1":
1467
- buildGeometryData(primitive, sources[input.id], input.offset, uv2.array);
1468
- uv2.stride = sources[input.id].stride;
1468
+ buildGeometryData(primitive, sources[input.id], input.offset, uv1$1.array);
1469
+ uv1$1.stride = sources[input.id].stride;
1469
1470
  break;
1470
1471
  }
1471
1472
  }
@@ -1480,8 +1481,8 @@ class ColladaLoader extends THREE.Loader {
1480
1481
  geometry.setAttribute("color", new THREE.Float32BufferAttribute(color.array, color.stride));
1481
1482
  if (uv.array.length > 0)
1482
1483
  geometry.setAttribute("uv", new THREE.Float32BufferAttribute(uv.array, uv.stride));
1483
- if (uv2.array.length > 0)
1484
- geometry.setAttribute("uv2", new THREE.Float32BufferAttribute(uv2.array, uv2.stride));
1484
+ if (uv1$1.array.length > 0)
1485
+ geometry.setAttribute(uv1.UV1, new THREE.Float32BufferAttribute(uv1$1.array, uv1$1.stride));
1485
1486
  if (skinIndex.array.length > 0) {
1486
1487
  geometry.setAttribute("skinIndex", new THREE.Float32BufferAttribute(skinIndex.array, skinIndex.stride));
1487
1488
  }