@recast-navigation/three 0.35.0 → 0.35.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.
package/dist/index.mjs CHANGED
@@ -1,2 +1,457 @@
1
- import{DebugDrawerUtils as t}from"@recast-navigation/core";import*as e from"three";import{Box3 as n,Vector3 as i,InstancedBufferGeometry as s,Float32BufferAttribute as r,InstancedInterleavedBuffer as a,InterleavedBufferAttribute as o,WireframeGeometry as d,Sphere as l,UniformsLib as c,Vector2 as h,ShaderLib as u,UniformsUtils as p,ShaderMaterial as f,Vector4 as w,Matrix4 as m,Line3 as v,Mesh as g,MathUtils as y,Object3D as b,MeshBasicMaterial as x,CylinderGeometry as M,BufferGeometry as S,BufferAttribute as A,LineBasicMaterial as U,CircleGeometry as P,CatmullRomCurve3 as D,Line as _,BoxGeometry as z}from"three";import{mergePositionsAndIndices as E,generateSoloNavMesh as C,generateTiledNavMesh as B,generateTileCache as L}from"@recast-navigation/generators";const T=new n,N=new i;class O extends s{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new r([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new r([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(t){const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),n.applyMatrix4(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new a(e,6,1);return this.setAttribute("instanceStart",new o(n,3,0)),this.setAttribute("instanceEnd",new o(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new a(e,6,1);return this.setAttribute("instanceColorStart",new o(n,3,0)),this.setAttribute("instanceColorEnd",new o(n,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new d(t.geometry)),this}fromLineSegments(t){const e=t.geometry;return this.setPositions(e.attributes.position.array),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new n);const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;void 0!==t&&void 0!==e&&(this.boundingBox.setFromBufferAttribute(t),T.setFromBufferAttribute(e),this.boundingBox.union(T))}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new l),null===this.boundingBox&&this.computeBoundingBox();const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;if(void 0!==t&&void 0!==e){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let i=0;for(let s=0,r=t.count;s<r;s++)N.fromBufferAttribute(t,s),i=Math.max(i,n.distanceToSquared(N)),N.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(N));this.boundingSphere.radius=Math.sqrt(i),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(t){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(t)}}c.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new h(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},u.line={uniforms:p.merge([c.common,c.fog,c.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );\n\t\t\t\tvec3 worldUp = normalize( cross( worldDir, tmpFwd ) );\n\t\t\t\tvec3 worldFwd = cross( worldDir, worldUp );\n\t\t\t\tworldPos = position.y < 0.5 ? start: end;\n\n\t\t\t\t// height offset\n\t\t\t\tfloat hw = linewidth * 0.5;\n\t\t\t\tworldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// cap extension\n\t\t\t\t\tworldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;\n\n\t\t\t\t\t// add width to the box\n\t\t\t\t\tworldPos.xyz += worldFwd * hw;\n\n\t\t\t\t\t// endcaps\n\t\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\t\tworldPos.xyz -= worldFwd * 2.0 * hw;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tfloat alpha = opacity;\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t"};class H extends f{constructor(t){super({type:"LineMaterial",uniforms:p.clone(u.line.uniforms),vertexShader:u.line.vertexShader,fragmentShader:u.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(t)}get color(){return this.uniforms.diffuse.value}set color(t){this.uniforms.diffuse.value=t}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(t){!0===t?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(t){this.uniforms.linewidth&&(this.uniforms.linewidth.value=t)}get dashed(){return"USE_DASH"in this.defines}set dashed(t){!0===t!==this.dashed&&(this.needsUpdate=!0),!0===t?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(t){this.uniforms.dashScale.value=t}get dashSize(){return this.uniforms.dashSize.value}set dashSize(t){this.uniforms.dashSize.value=t}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(t){this.uniforms.dashOffset.value=t}get gapSize(){return this.uniforms.gapSize.value}set gapSize(t){this.uniforms.gapSize.value=t}get opacity(){return this.uniforms.opacity.value}set opacity(t){this.uniforms&&(this.uniforms.opacity.value=t)}get resolution(){return this.uniforms.resolution.value}set resolution(t){this.uniforms.resolution.value.copy(t)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(t){this.defines&&(!0===t!==this.alphaToCoverage&&(this.needsUpdate=!0),!0===t?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const G=new w,W=new i,F=new i,R=new w,I=new w,j=new w,V=new i,k=new m,q=new v,Q=new i,J=new n,X=new l,$=new w;let K,Y;function Z(t,e,n){return $.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),$.multiplyScalar(1/$.w),$.x=Y/n.width,$.y=Y/n.height,$.applyMatrix4(t.projectionMatrixInverse),$.multiplyScalar(1/$.w),Math.abs(Math.max($.x,$.y))}class tt extends g{constructor(t=new O,e=new H({color:16777215*Math.random()})){super(t,e),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,n=t.attributes.instanceEnd,i=new Float32Array(2*e.count);for(let t=0,s=0,r=e.count;t<r;t++,s+=2)W.fromBufferAttribute(e,t),F.fromBufferAttribute(n,t),i[s]=0===s?0:i[s-1],i[s+1]=i[s]+W.distanceTo(F);const s=new a(i,2,1);return t.setAttribute("instanceDistanceStart",new o(s,1,0)),t.setAttribute("instanceDistanceEnd",new o(s,1,1)),this}raycast(t,e){const n=this.material.worldUnits,s=t.camera;null!==s||n||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const r=void 0!==t.params.Line2&&t.params.Line2.threshold||0;K=t.ray;const a=this.matrixWorld,o=this.geometry,d=this.material;let l,c;if(Y=d.linewidth+r,null===o.boundingSphere&&o.computeBoundingSphere(),X.copy(o.boundingSphere).applyMatrix4(a),n)l=.5*Y;else{l=Z(s,Math.max(s.near,X.distanceToPoint(K.origin)),d.resolution)}if(X.radius+=l,!1!==K.intersectsSphere(X)){if(null===o.boundingBox&&o.computeBoundingBox(),J.copy(o.boundingBox).applyMatrix4(a),n)c=.5*Y;else{c=Z(s,Math.max(s.near,J.distanceToPoint(K.origin)),d.resolution)}J.expandByScalar(c),!1!==K.intersectsBox(J)&&(n?function(t,e){const n=t.matrixWorld,s=t.geometry,r=s.attributes.instanceStart,a=s.attributes.instanceEnd;for(let o=0,d=Math.min(s.instanceCount,r.count);o<d;o++){q.start.fromBufferAttribute(r,o),q.end.fromBufferAttribute(a,o),q.applyMatrix4(n);const s=new i,d=new i;K.distanceSqToSegment(q.start,q.end,d,s),d.distanceTo(s)<.5*Y&&e.push({point:d,pointOnLine:s,distance:K.origin.distanceTo(d),object:t,face:null,faceIndex:o,uv:null,uv1:null})}}(this,e):function(t,e,n){const s=e.projectionMatrix,r=t.material.resolution,a=t.matrixWorld,o=t.geometry,d=o.attributes.instanceStart,l=o.attributes.instanceEnd,c=Math.min(o.instanceCount,d.count),h=-e.near;K.at(1,j),j.w=1,j.applyMatrix4(e.matrixWorldInverse),j.applyMatrix4(s),j.multiplyScalar(1/j.w),j.x*=r.x/2,j.y*=r.y/2,j.z=0,V.copy(j),k.multiplyMatrices(e.matrixWorldInverse,a);for(let e=0,o=c;e<o;e++){if(R.fromBufferAttribute(d,e),I.fromBufferAttribute(l,e),R.w=1,I.w=1,R.applyMatrix4(k),I.applyMatrix4(k),R.z>h&&I.z>h)continue;if(R.z>h){const t=R.z-I.z,e=(R.z-h)/t;R.lerp(I,e)}else if(I.z>h){const t=I.z-R.z,e=(I.z-h)/t;I.lerp(R,e)}R.applyMatrix4(s),I.applyMatrix4(s),R.multiplyScalar(1/R.w),I.multiplyScalar(1/I.w),R.x*=r.x/2,R.y*=r.y/2,I.x*=r.x/2,I.y*=r.y/2,q.start.copy(R),q.start.z=0,q.end.copy(I),q.end.z=0;const o=q.closestPointToPointParameter(V,!0);q.at(o,Q);const c=y.lerp(R.z,I.z,o),u=c>=-1&&c<=1,p=V.distanceTo(Q)<.5*Y;if(u&&p){q.start.fromBufferAttribute(d,e),q.end.fromBufferAttribute(l,e),q.start.applyMatrix4(a),q.end.applyMatrix4(a);const s=new i,r=new i;K.distanceSqToSegment(q.start,q.end,r,s),n.push({point:r,pointOnLine:s,distance:K.origin.distanceTo(r),object:t,face:null,faceIndex:e,uv:null,uv1:null})}}}(this,s,e))}}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport(G),this.material.uniforms.resolution.value.set(G.z,G.w))}}const et=new e.Color;class nt extends e.Group{pointGeometry=new e.SphereGeometry(.02,32,32);constructor({triMaterial:n,pointMaterial:i,lineMaterial:s}={}){super(),this.debugDrawerUtils=new t,this.triMaterial=n??new e.MeshBasicMaterial({vertexColors:!0,transparent:!0,opacity:.4,depthWrite:!1}),this.pointMaterial=i??new e.MeshBasicMaterial,this.lineMaterial=s??new H({color:16777215,linewidth:2,vertexColors:!0,polygonOffset:!0,polygonOffsetFactor:-4,polygonOffsetUnits:-10})}drawPrimitives(t){for(const e of t)switch(e.type){case"points":this.drawPoints(e);break;case"lines":this.drawLines(e);break;case"tris":this.drawTris(e);break;case"quads":this.drawQuads(e)}}drawHeightfieldSolid(t){const e=this.debugDrawerUtils.drawHeightfieldSolid(t);this.drawPrimitives(e)}drawHeightfieldWalkable(t){const e=this.debugDrawerUtils.drawHeightfieldWalkable(t);this.drawPrimitives(e)}drawCompactHeightfieldSolid(t){const e=this.debugDrawerUtils.drawCompactHeightfieldSolid(t);this.drawPrimitives(e)}drawCompactHeightfieldRegions(t){const e=this.debugDrawerUtils.drawCompactHeightfieldRegions(t);this.drawPrimitives(e)}drawCompactHeightfieldDistance(t){const e=this.debugDrawerUtils.drawCompactHeightfieldDistance(t);this.drawPrimitives(e)}drawHeightfieldLayer(t,e){const n=this.debugDrawerUtils.drawHeightfieldLayer(t,e);this.drawPrimitives(n)}drawHeightfieldLayers(t){const e=this.debugDrawerUtils.drawHeightfieldLayers(t);this.drawPrimitives(e)}drawRegionConnections(t,e=1){const n=this.debugDrawerUtils.drawRegionConnections(t,e);this.drawPrimitives(n)}drawRawContours(t,e=1){const n=this.debugDrawerUtils.drawRawContours(t,e);this.drawPrimitives(n)}drawContours(t,e=1){const n=this.debugDrawerUtils.drawContours(t,e);this.drawPrimitives(n)}drawPolyMesh(t){const e=this.debugDrawerUtils.drawPolyMesh(t);this.drawPrimitives(e)}drawPolyMeshDetail(t){const e=this.debugDrawerUtils.drawPolyMeshDetail(t);this.drawPrimitives(e)}drawNavMesh(t,e=0){const n=this.debugDrawerUtils.drawNavMesh(t,e);this.drawPrimitives(n)}drawNavMeshWithClosedList(t,e,n=0){const i=this.debugDrawerUtils.drawNavMeshWithClosedList(t,e,n);this.drawPrimitives(i)}drawNavMeshNodes(t){const e=this.debugDrawerUtils.drawNavMeshNodes(t);this.drawPrimitives(e)}drawNavMeshBVTree(t){const e=this.debugDrawerUtils.drawNavMeshBVTree(t);this.drawPrimitives(e)}drawNavMeshPortals(t){const e=this.debugDrawerUtils.drawNavMeshPortals(t);this.drawPrimitives(e)}drawNavMeshPolysWithFlags(t,e,n){const i=this.debugDrawerUtils.drawNavMeshPolysWithFlags(t,e,n);this.drawPrimitives(i)}drawNavMeshPoly(t,e,n){const i=this.debugDrawerUtils.drawNavMeshPoly(t,e,n);this.drawPrimitives(i)}reset(){for(const t of this.children)(t instanceof e.Mesh||t instanceof tt)&&t.geometry.dispose();this.clear()}dispose(){this.debugDrawerUtils.dispose(),this.reset(),this.pointGeometry.dispose(),this.triMaterial.dispose(),this.pointMaterial.dispose(),this.lineMaterial.dispose()}drawPoints(t){const n=this.pointGeometry,i=new e.InstancedMesh(n,this.pointMaterial,t.vertices.length/3);for(let n=0;n<t.vertices.length/7;n++){const[s,r,a,o,d,l]=t.vertices[n];i.setMatrixAt(n,(new e.Matrix4).setPosition(s,r,a)),i.setColorAt(n,et.setRGB(o,d,l))}i.instanceMatrix.needsUpdate=!0,this.add(i)}drawLines(t){const e=new O,n=[],i=[];for(let e=0;e<t.vertices.length;e+=2){const[s,r,a,o,d,l]=t.vertices[e],[c,h,u,p,f,w]=t.vertices[e+1];n.push(s,r,a),n.push(c,h,u),i.push(o,d,l),i.push(p,f,w)}e.setPositions(n),e.setColors(i);const s=new tt(e,this.lineMaterial);this.add(s)}drawTris(t){const n=new e.BufferGeometry,i=new Float32Array(3*t.vertices.length),s=new Float32Array(3*t.vertices.length);for(let e=0;e<t.vertices.length;e++){const[n,r,a,o,d,l]=t.vertices[e];i[3*e+0]=n,i[3*e+1]=r,i[3*e+2]=a,s[3*e+0]=o,s[3*e+1]=d,s[3*e+2]=l}n.setAttribute("position",new e.BufferAttribute(i,3)),n.setAttribute("color",new e.BufferAttribute(s,3));const r=this.triMaterial,a=new e.Mesh(n,r);this.add(a)}drawQuads(t){const n=[],i=[];for(let e=0;e<t.vertices.length;e+=4){const s=[t.vertices[e],t.vertices[e+1],t.vertices[e+2],t.vertices[e],t.vertices[e+2],t.vertices[e+3]];for(const[t,e,r,a,o,d]of s)n.push(t,e,r),i.push(a,o,d)}const s=new e.BufferGeometry;s.setAttribute("position",new e.BufferAttribute(new Float32Array(n),3)),s.setAttribute("color",new e.BufferAttribute(new Float32Array(i),3));const r=this.triMaterial,a=new e.Mesh(s,r);this.add(a)}}class it extends b{agentMeshes=new Map;constructor(t,e){super(),this.recastCrowd=t,this.agentMaterial=e?.agentMaterial??new x({color:"red"}),this.update()}update(){const t=this.recastCrowd.getAgents(),e=new Set(this.agentMeshes.keys());for(const n of t){e.delete(n.agentIndex);const t=n.position(),s=n.velocity();let r=this.agentMeshes.get(n.agentIndex);void 0===r?(r=this.createAgentMesh(n),this.add(r),this.agentMeshes.set(n.agentIndex,r)):this.updateAgentGeometry(r,n),r.position.set(t.x,t.y+n.height/2,t.z),r.lookAt((new i).copy(r.position).add(s))}for(const t of e){const e=this.agentMeshes.get(t);e&&(this.remove(e),this.agentMeshes.delete(t))}}createAgentMesh(t){const e=new g;return e.material=this.agentMaterial,this.updateAgentGeometry(e,t),e.userData={radius:t.radius,height:t.height},e}updateAgentGeometry(t,e){if(t.userData.radius!==e.radius||t.userData.height!==e.height){const n=new M(e.radius,e.radius,e.height);t.geometry.dispose(),t.geometry=n,t.userData.radius=e.radius,t.userData.height=e.height}}}class st extends b{constructor(t,e){super(),this.navMesh=t,this.navMeshGeometry=new S,this.navMeshMaterial=e?.navMeshMaterial?e.navMeshMaterial:new x({color:"orange",transparent:!0,opacity:.7,depthWrite:!1}),this.update(),this.mesh=new g(this.navMeshGeometry,this.navMeshMaterial),this.add(this.mesh)}update(){const[t,e]=this.navMesh.getDebugNavMesh();this.navMeshGeometry.setAttribute("position",new A(Float32Array.from(t),3)),this.navMeshGeometry.setIndex(new A(Uint32Array.from(e),1)),this.navMeshGeometry.computeVertexNormals()}}class rt extends b{constructor(t,e){super(),this.offMeshConnections=t??[],this.entryCircleMaterial=e?.entryCircleMaterial??new x({color:"green"}),this.exitCircleMaterial=e?.exitCircleMaterial??new x({color:"blue"}),this.lineMaterial=e?.lineMaterial??new U({color:"red"}),this.update()}update(){this.clear();for(const t of this.offMeshConnections){const e=new P(t.radius,16),n=new g(e,this.entryCircleMaterial);n.position.copy(t.startPosition),n.position.y+=.001,n.rotation.x=-Math.PI/2,this.add(n);const s=new g(e,t.bidirectional?this.entryCircleMaterial:this.exitCircleMaterial);s.position.copy(t.endPosition),s.position.y+=.001,s.rotation.x=-Math.PI/2,this.add(s);const r=(new i).copy(t.startPosition),a=(new i).copy(t.endPosition),o=(new i).addVectors(r,a).multiplyScalar(.5);o.y*=1.2;const d=new D([r,o,a]).getPoints(50),l=(new S).setFromPoints(d),c=new _(l,this.lineMaterial);this.add(c)}}}class at extends b{obstacleMeshes=new Map;constructor(t,e){super(),this.tileCache=t,this.obstacleMaterial=e?.obstacleMaterial?e.obstacleMaterial:new x({color:"red",wireframe:!0,wireframeLinewidth:2}),this.update()}update(){const t=new Set(this.obstacleMeshes.keys());for(const[,e]of this.tileCache.obstacles){const n=this.obstacleMeshes.get(e);if(t.delete(e),!n){const{position:t}=e,n=new g(void 0,this.obstacleMaterial);if(n.position.copy(t),"box"===e.type){const{halfExtents:t,angle:i}=e;n.geometry=new z(2*t.x,2*t.y,2*t.z),n.rotation.y=i}else{if("cylinder"!==e.type)throw new Error(`Unknown obstacle type: ${e}`);{const{radius:t,height:i}=e;n.geometry=new M(t,t,i,16),n.position.y+=i/2}}this.add(n),this.obstacleMeshes.set(e,n)}}for(const e of t){const t=this.obstacleMeshes.get(e);t&&(this.remove(t),this.obstacleMeshes.delete(e))}}}const ot=new i,dt=t=>{const e=[];for(const n of t){const t=n.geometry.attributes.position;if(!t||3!==t.itemSize)continue;n.updateMatrixWorld();const i=new Float32Array(t.array);for(let t=0;t<i.length;t+=3){const e=ot.set(i[t],i[t+1],i[t+2]);n.localToWorld(e),i[t]=e.x,i[t+1]=e.y,i[t+2]=e.z}let s=n.geometry.getIndex()?.array;if(void 0===s){const e=[];for(let n=0;n<t.count;n++)e.push(n);s=e}e.push({positions:i,indices:s})}return E(e)},lt=(t,e={},n=!1)=>{const[i,s]=dt(t);return C(i,s,e,n)},ct=(t,e={},n=!1)=>{const[i,s]=dt(t);return B(i,s,e,n)},ht=(t,e={},n=!1)=>{const[i,s]=dt(t);return L(i,s,e,n)};export{it as CrowdHelper,nt as DebugDrawer,st as NavMeshHelper,rt as OffMeshConnectionsHelper,at as TileCacheHelper,dt as getPositionsAndIndices,lt as threeToSoloNavMesh,ht as threeToTileCache,ct as threeToTiledNavMesh};
2
- //# sourceMappingURL=index.mjs.map
1
+ import { DebugDrawerUtils } from '@recast-navigation/core';
2
+ import * as THREE from 'three';
3
+ import { Object3D, MeshBasicMaterial, Vector3, Mesh, CylinderGeometry, BufferGeometry, BufferAttribute, LineBasicMaterial, CircleGeometry, CatmullRomCurve3, Line, BoxGeometry } from 'three';
4
+ import { LineMaterial, LineSegments2, LineSegmentsGeometry } from 'three/addons';
5
+ import { mergePositionsAndIndices, generateSoloNavMesh, generateTiledNavMesh, generateTileCache } from '@recast-navigation/generators';
6
+
7
+ const _color = new THREE.Color();
8
+ class DebugDrawer extends THREE.Group {
9
+ pointGeometry = new THREE.SphereGeometry(0.02, 32, 32);
10
+ constructor({
11
+ triMaterial,
12
+ pointMaterial,
13
+ lineMaterial
14
+ } = {}) {
15
+ super();
16
+ this.debugDrawerUtils = new DebugDrawerUtils();
17
+ this.triMaterial = triMaterial ?? new THREE.MeshBasicMaterial({
18
+ vertexColors: true,
19
+ transparent: true,
20
+ opacity: 0.4,
21
+ depthWrite: false
22
+ });
23
+ this.pointMaterial = pointMaterial ?? new THREE.MeshBasicMaterial();
24
+ this.lineMaterial = lineMaterial ?? new LineMaterial({
25
+ color: 0xffffff,
26
+ linewidth: 2,
27
+ vertexColors: true,
28
+ polygonOffset: true,
29
+ polygonOffsetFactor: -4,
30
+ polygonOffsetUnits: -10
31
+ });
32
+ }
33
+ drawPrimitives(primitives) {
34
+ for (const primitive of primitives) {
35
+ switch (primitive.type) {
36
+ case 'points':
37
+ this.drawPoints(primitive);
38
+ break;
39
+ case 'lines':
40
+ this.drawLines(primitive);
41
+ break;
42
+ case 'tris':
43
+ this.drawTris(primitive);
44
+ break;
45
+ case 'quads':
46
+ this.drawQuads(primitive);
47
+ break;
48
+ }
49
+ }
50
+ }
51
+ drawHeightfieldSolid(hf) {
52
+ const primitives = this.debugDrawerUtils.drawHeightfieldSolid(hf);
53
+ this.drawPrimitives(primitives);
54
+ }
55
+ drawHeightfieldWalkable(hf) {
56
+ const primitives = this.debugDrawerUtils.drawHeightfieldWalkable(hf);
57
+ this.drawPrimitives(primitives);
58
+ }
59
+ drawCompactHeightfieldSolid(chf) {
60
+ const primitives = this.debugDrawerUtils.drawCompactHeightfieldSolid(chf);
61
+ this.drawPrimitives(primitives);
62
+ }
63
+ drawCompactHeightfieldRegions(chf) {
64
+ const primitives = this.debugDrawerUtils.drawCompactHeightfieldRegions(chf);
65
+ this.drawPrimitives(primitives);
66
+ }
67
+ drawCompactHeightfieldDistance(chf) {
68
+ const primitives = this.debugDrawerUtils.drawCompactHeightfieldDistance(chf);
69
+ this.drawPrimitives(primitives);
70
+ }
71
+ drawHeightfieldLayer(layer, idx) {
72
+ const primitives = this.debugDrawerUtils.drawHeightfieldLayer(layer, idx);
73
+ this.drawPrimitives(primitives);
74
+ }
75
+ drawHeightfieldLayers(lset) {
76
+ const primitives = this.debugDrawerUtils.drawHeightfieldLayers(lset);
77
+ this.drawPrimitives(primitives);
78
+ }
79
+ drawRegionConnections(cset, alpha = 1) {
80
+ const primitives = this.debugDrawerUtils.drawRegionConnections(cset, alpha);
81
+ this.drawPrimitives(primitives);
82
+ }
83
+ drawRawContours(cset, alpha = 1) {
84
+ const primitives = this.debugDrawerUtils.drawRawContours(cset, alpha);
85
+ this.drawPrimitives(primitives);
86
+ }
87
+ drawContours(cset, alpha = 1) {
88
+ const primitives = this.debugDrawerUtils.drawContours(cset, alpha);
89
+ this.drawPrimitives(primitives);
90
+ }
91
+ drawPolyMesh(mesh) {
92
+ const primitives = this.debugDrawerUtils.drawPolyMesh(mesh);
93
+ this.drawPrimitives(primitives);
94
+ }
95
+ drawPolyMeshDetail(dmesh) {
96
+ const primitives = this.debugDrawerUtils.drawPolyMeshDetail(dmesh);
97
+ this.drawPrimitives(primitives);
98
+ }
99
+ drawNavMesh(mesh, flags = 0) {
100
+ const primitives = this.debugDrawerUtils.drawNavMesh(mesh, flags);
101
+ this.drawPrimitives(primitives);
102
+ }
103
+ drawNavMeshWithClosedList(mesh, query, flags = 0) {
104
+ const primitives = this.debugDrawerUtils.drawNavMeshWithClosedList(mesh, query, flags);
105
+ this.drawPrimitives(primitives);
106
+ }
107
+ drawNavMeshNodes(query) {
108
+ const primitives = this.debugDrawerUtils.drawNavMeshNodes(query);
109
+ this.drawPrimitives(primitives);
110
+ }
111
+ drawNavMeshBVTree(mesh) {
112
+ const primitives = this.debugDrawerUtils.drawNavMeshBVTree(mesh);
113
+ this.drawPrimitives(primitives);
114
+ }
115
+ drawNavMeshPortals(mesh) {
116
+ const primitives = this.debugDrawerUtils.drawNavMeshPortals(mesh);
117
+ this.drawPrimitives(primitives);
118
+ }
119
+ drawNavMeshPolysWithFlags(mesh, flags, col) {
120
+ const primitives = this.debugDrawerUtils.drawNavMeshPolysWithFlags(mesh, flags, col);
121
+ this.drawPrimitives(primitives);
122
+ }
123
+ drawNavMeshPoly(mesh, ref, col) {
124
+ const primitives = this.debugDrawerUtils.drawNavMeshPoly(mesh, ref, col);
125
+ this.drawPrimitives(primitives);
126
+ }
127
+ // todo:
128
+ // - drawTileCacheLayerAreas
129
+ // - drawTileCacheLayerRegions
130
+ // - drawTileCacheContours
131
+ // - drawTileCachePolyMesh
132
+ reset() {
133
+ for (const child of this.children) {
134
+ if (child instanceof THREE.Mesh || child instanceof LineSegments2) {
135
+ child.geometry.dispose();
136
+ }
137
+ }
138
+ this.clear();
139
+ }
140
+ dispose() {
141
+ this.debugDrawerUtils.dispose();
142
+ this.reset();
143
+ this.pointGeometry.dispose();
144
+ this.triMaterial.dispose();
145
+ this.pointMaterial.dispose();
146
+ this.lineMaterial.dispose();
147
+ }
148
+ drawPoints(primitive) {
149
+ const geometry = this.pointGeometry;
150
+ const instancedMesh = new THREE.InstancedMesh(geometry, this.pointMaterial, primitive.vertices.length / 3);
151
+ for (let point = 0; point < primitive.vertices.length / 7; point++) {
152
+ const [x, y, z, r, g, b] = primitive.vertices[point];
153
+ instancedMesh.setMatrixAt(point, new THREE.Matrix4().setPosition(x, y, z));
154
+ instancedMesh.setColorAt(point, _color.setRGB(r, g, b));
155
+ }
156
+ instancedMesh.instanceMatrix.needsUpdate = true;
157
+ this.add(instancedMesh);
158
+ }
159
+ drawLines(primitive) {
160
+ const lineSegmentsGeometry = new LineSegmentsGeometry();
161
+ const positions = [];
162
+ const colors = [];
163
+ for (let i = 0; i < primitive.vertices.length; i += 2) {
164
+ const [x1, y1, z1, r1, g1, b1] = primitive.vertices[i];
165
+ const [x2, y2, z2, r2, g2, b2] = primitive.vertices[i + 1];
166
+ positions.push(x1, y1, z1);
167
+ positions.push(x2, y2, z2);
168
+ colors.push(r1, g1, b1);
169
+ colors.push(r2, g2, b2);
170
+ }
171
+ lineSegmentsGeometry.setPositions(positions);
172
+ lineSegmentsGeometry.setColors(colors);
173
+ const lineSegments = new LineSegments2(lineSegmentsGeometry, this.lineMaterial);
174
+ this.add(lineSegments);
175
+ }
176
+ drawTris(primitive) {
177
+ const geometry = new THREE.BufferGeometry();
178
+ const positions = new Float32Array(primitive.vertices.length * 3);
179
+ const colors = new Float32Array(primitive.vertices.length * 3);
180
+ for (let i = 0; i < primitive.vertices.length; i++) {
181
+ const [x, y, z, r, g, b] = primitive.vertices[i];
182
+ positions[i * 3 + 0] = x;
183
+ positions[i * 3 + 1] = y;
184
+ positions[i * 3 + 2] = z;
185
+ colors[i * 3 + 0] = r;
186
+ colors[i * 3 + 1] = g;
187
+ colors[i * 3 + 2] = b;
188
+ }
189
+ geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
190
+ geometry.setAttribute('color', new THREE.BufferAttribute(colors, 3));
191
+ const material = this.triMaterial;
192
+ const mesh = new THREE.Mesh(geometry, material);
193
+ this.add(mesh);
194
+ }
195
+ drawQuads(primitive) {
196
+ const positions = [];
197
+ const colors = [];
198
+ for (let i = 0; i < primitive.vertices.length; i += 4) {
199
+ const vertices = [primitive.vertices[i], primitive.vertices[i + 1], primitive.vertices[i + 2], primitive.vertices[i], primitive.vertices[i + 2], primitive.vertices[i + 3]];
200
+ for (const [x, y, z, r, g, b] of vertices) {
201
+ positions.push(x, y, z);
202
+ colors.push(r, g, b);
203
+ }
204
+ }
205
+ const geometry = new THREE.BufferGeometry();
206
+ geometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(positions), 3));
207
+ geometry.setAttribute('color', new THREE.BufferAttribute(new Float32Array(colors), 3));
208
+ const material = this.triMaterial;
209
+ const mesh = new THREE.Mesh(geometry, material);
210
+ this.add(mesh);
211
+ }
212
+ }
213
+
214
+ class CrowdHelper extends Object3D {
215
+ agentMeshes = new Map();
216
+ constructor(crowd, params) {
217
+ super();
218
+ this.recastCrowd = crowd;
219
+ this.agentMaterial = params?.agentMaterial ?? new MeshBasicMaterial({
220
+ color: 'red'
221
+ });
222
+ this.update();
223
+ }
224
+ /**
225
+ * Update the three debug view of the crowd agents.
226
+ *
227
+ * This should be called after updating the crowd.
228
+ */
229
+ update() {
230
+ const agents = this.recastCrowd.getAgents();
231
+ const unseen = new Set(this.agentMeshes.keys());
232
+ for (const agent of agents) {
233
+ unseen.delete(agent.agentIndex);
234
+ const position = agent.position();
235
+ const velocity = agent.velocity();
236
+ let agentMesh = this.agentMeshes.get(agent.agentIndex);
237
+ if (agentMesh === undefined) {
238
+ agentMesh = this.createAgentMesh(agent);
239
+ this.add(agentMesh);
240
+ this.agentMeshes.set(agent.agentIndex, agentMesh);
241
+ } else {
242
+ this.updateAgentGeometry(agentMesh, agent);
243
+ }
244
+ agentMesh.position.set(position.x, position.y + agent.height / 2, position.z);
245
+ agentMesh.lookAt(new Vector3().copy(agentMesh.position).add(velocity));
246
+ }
247
+ for (const agentId of unseen) {
248
+ const agentMesh = this.agentMeshes.get(agentId);
249
+ if (agentMesh) {
250
+ this.remove(agentMesh);
251
+ this.agentMeshes.delete(agentId);
252
+ }
253
+ }
254
+ }
255
+ createAgentMesh(agent) {
256
+ const mesh = new Mesh();
257
+ mesh.material = this.agentMaterial;
258
+ this.updateAgentGeometry(mesh, agent);
259
+ mesh.userData = {
260
+ radius: agent.radius,
261
+ height: agent.height
262
+ };
263
+ return mesh;
264
+ }
265
+ updateAgentGeometry(agentMesh, agentParams) {
266
+ if (agentMesh.userData.radius !== agentParams.radius || agentMesh.userData.height !== agentParams.height) {
267
+ const geometry = new CylinderGeometry(agentParams.radius, agentParams.radius, agentParams.height);
268
+ agentMesh.geometry.dispose();
269
+ agentMesh.geometry = geometry;
270
+ agentMesh.userData.radius = agentParams.radius;
271
+ agentMesh.userData.height = agentParams.height;
272
+ }
273
+ }
274
+ }
275
+
276
+ class NavMeshHelper extends Object3D {
277
+ constructor(navMesh, params) {
278
+ super();
279
+ this.navMesh = navMesh;
280
+ this.navMeshGeometry = new BufferGeometry();
281
+ this.navMeshMaterial = params?.navMeshMaterial ? params.navMeshMaterial : new MeshBasicMaterial({
282
+ color: 'orange',
283
+ transparent: true,
284
+ opacity: 0.7,
285
+ depthWrite: false
286
+ });
287
+ this.update();
288
+ this.mesh = new Mesh(this.navMeshGeometry, this.navMeshMaterial);
289
+ this.add(this.mesh);
290
+ }
291
+ /**
292
+ * Update the three debug nav mesh.
293
+ *
294
+ * This should be called after updating the nav mesh.
295
+ */
296
+ update() {
297
+ const [positions, indices] = this.navMesh.getDebugNavMesh();
298
+ this.navMeshGeometry.setAttribute('position', new BufferAttribute(Float32Array.from(positions), 3));
299
+ this.navMeshGeometry.setIndex(new BufferAttribute(Uint32Array.from(indices), 1));
300
+ this.navMeshGeometry.computeVertexNormals();
301
+ }
302
+ }
303
+
304
+ class OffMeshConnectionsHelper extends Object3D {
305
+ constructor(offMeshConnections, params) {
306
+ super();
307
+ this.offMeshConnections = offMeshConnections ?? [];
308
+ this.entryCircleMaterial = params?.entryCircleMaterial ?? new MeshBasicMaterial({
309
+ color: 'green'
310
+ });
311
+ this.exitCircleMaterial = params?.exitCircleMaterial ?? new MeshBasicMaterial({
312
+ color: 'blue'
313
+ });
314
+ this.lineMaterial = params?.lineMaterial ?? new LineBasicMaterial({
315
+ color: 'red'
316
+ });
317
+ this.update();
318
+ }
319
+ /**
320
+ * Update the three debug view of the off mesh connections.
321
+ */
322
+ update() {
323
+ this.clear();
324
+ for (const offMeshConnection of this.offMeshConnections) {
325
+ // start and end circles
326
+ const circleGeometry = new CircleGeometry(offMeshConnection.radius, 16);
327
+ const startMesh = new Mesh(circleGeometry, this.entryCircleMaterial);
328
+ startMesh.position.copy(offMeshConnection.startPosition);
329
+ startMesh.position.y += 0.001;
330
+ startMesh.rotation.x = -Math.PI / 2;
331
+ this.add(startMesh);
332
+ const endMesh = new Mesh(circleGeometry, offMeshConnection.bidirectional ? this.entryCircleMaterial : this.exitCircleMaterial);
333
+ endMesh.position.copy(offMeshConnection.endPosition);
334
+ endMesh.position.y += 0.001;
335
+ endMesh.rotation.x = -Math.PI / 2;
336
+ this.add(endMesh);
337
+ // line between points
338
+ const start = new Vector3().copy(offMeshConnection.startPosition);
339
+ const end = new Vector3().copy(offMeshConnection.endPosition);
340
+ const middle = new Vector3().addVectors(start, end).multiplyScalar(0.5);
341
+ middle.y *= 1.2;
342
+ const curve = new CatmullRomCurve3([start, middle, end]);
343
+ const curvePoints = curve.getPoints(50);
344
+ const lineGeometry = new BufferGeometry().setFromPoints(curvePoints);
345
+ const line = new Line(lineGeometry, this.lineMaterial);
346
+ this.add(line);
347
+ }
348
+ }
349
+ }
350
+
351
+ class TileCacheHelper extends Object3D {
352
+ obstacleMeshes = new Map();
353
+ constructor(tileCache, params) {
354
+ super();
355
+ this.tileCache = tileCache;
356
+ this.obstacleMaterial = params?.obstacleMaterial ? params.obstacleMaterial : new MeshBasicMaterial({
357
+ color: 'red',
358
+ wireframe: true,
359
+ wireframeLinewidth: 2
360
+ });
361
+ this.update();
362
+ }
363
+ /**
364
+ * Update the obstacle meshes.
365
+ *
366
+ * This should be called after adding or removing obstacles.
367
+ */
368
+ update() {
369
+ const unseen = new Set(this.obstacleMeshes.keys());
370
+ for (const [, obstacle] of this.tileCache.obstacles) {
371
+ const obstacleMesh = this.obstacleMeshes.get(obstacle);
372
+ unseen.delete(obstacle);
373
+ if (!obstacleMesh) {
374
+ const {
375
+ position
376
+ } = obstacle;
377
+ const mesh = new Mesh(undefined, this.obstacleMaterial);
378
+ mesh.position.copy(position);
379
+ if (obstacle.type === 'box') {
380
+ const {
381
+ halfExtents,
382
+ angle
383
+ } = obstacle;
384
+ mesh.geometry = new BoxGeometry(halfExtents.x * 2, halfExtents.y * 2, halfExtents.z * 2);
385
+ mesh.rotation.y = angle;
386
+ } else if (obstacle.type === 'cylinder') {
387
+ const {
388
+ radius,
389
+ height
390
+ } = obstacle;
391
+ mesh.geometry = new CylinderGeometry(radius, radius, height, 16);
392
+ mesh.position.y += height / 2;
393
+ } else {
394
+ throw new Error(`Unknown obstacle type: ${obstacle}`);
395
+ }
396
+ this.add(mesh);
397
+ this.obstacleMeshes.set(obstacle, mesh);
398
+ }
399
+ }
400
+ for (const obstacle of unseen) {
401
+ const obstacleMesh = this.obstacleMeshes.get(obstacle);
402
+ if (obstacleMesh) {
403
+ this.remove(obstacleMesh);
404
+ this.obstacleMeshes.delete(obstacle);
405
+ }
406
+ }
407
+ }
408
+ }
409
+
410
+ const _position = new Vector3();
411
+ const getPositionsAndIndices = meshes => {
412
+ const toMerge = [];
413
+ for (const mesh of meshes) {
414
+ const positionAttribute = mesh.geometry.attributes.position;
415
+ if (!positionAttribute || positionAttribute.itemSize !== 3) {
416
+ continue;
417
+ }
418
+ mesh.updateMatrixWorld();
419
+ const positions = new Float32Array(positionAttribute.array);
420
+ for (let i = 0; i < positions.length; i += 3) {
421
+ const pos = _position.set(positions[i], positions[i + 1], positions[i + 2]);
422
+ mesh.localToWorld(pos);
423
+ positions[i] = pos.x;
424
+ positions[i + 1] = pos.y;
425
+ positions[i + 2] = pos.z;
426
+ }
427
+ let indices = mesh.geometry.getIndex()?.array;
428
+ if (indices === undefined) {
429
+ // this will become indexed when merging with other meshes
430
+ const ascendingIndex = [];
431
+ for (let i = 0; i < positionAttribute.count; i++) {
432
+ ascendingIndex.push(i);
433
+ }
434
+ indices = ascendingIndex;
435
+ }
436
+ toMerge.push({
437
+ positions,
438
+ indices
439
+ });
440
+ }
441
+ return mergePositionsAndIndices(toMerge);
442
+ };
443
+
444
+ const threeToSoloNavMesh = (meshes, navMeshGeneratorConfig = {}, keepIntermediates = false) => {
445
+ const [positions, indices] = getPositionsAndIndices(meshes);
446
+ return generateSoloNavMesh(positions, indices, navMeshGeneratorConfig, keepIntermediates);
447
+ };
448
+ const threeToTiledNavMesh = (meshes, navMeshGeneratorConfig = {}, keepIntermediates = false) => {
449
+ const [positions, indices] = getPositionsAndIndices(meshes);
450
+ return generateTiledNavMesh(positions, indices, navMeshGeneratorConfig, keepIntermediates);
451
+ };
452
+ const threeToTileCache = (meshes, navMeshGeneratorConfig = {}, keepIntermediates = false) => {
453
+ const [positions, indices] = getPositionsAndIndices(meshes);
454
+ return generateTileCache(positions, indices, navMeshGeneratorConfig, keepIntermediates);
455
+ };
456
+
457
+ export { CrowdHelper, DebugDrawer, NavMeshHelper, OffMeshConnectionsHelper, TileCacheHelper, getPositionsAndIndices, threeToSoloNavMesh, threeToTileCache, threeToTiledNavMesh };
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "email": "isaac@isaacmason.com",
7
7
  "url": "https://isaacmason.com/"
8
8
  },
9
- "version": "0.35.0",
9
+ "version": "0.35.1",
10
10
  "license": "MIT",
11
11
  "homepage": "https://github.com/isaac-mason/recast-navigation-js",
12
12
  "bugs": {
@@ -27,8 +27,8 @@
27
27
  "lint": "eslint src"
28
28
  },
29
29
  "dependencies": {
30
- "@recast-navigation/core": "0.35.0",
31
- "@recast-navigation/generators": "0.35.0"
30
+ "@recast-navigation/core": "0.35.1",
31
+ "@recast-navigation/generators": "0.35.1"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@types/three": "0.x.x",
@@ -42,7 +42,6 @@
42
42
  "@rollup/plugin-babel": "^6.0.4",
43
43
  "@rollup/plugin-commonjs": "^25.0.7",
44
44
  "@rollup/plugin-node-resolve": "^15.0.1",
45
- "@rollup/plugin-terser": "^0.4.3",
46
45
  "@rollup/plugin-typescript": "^11.1.6",
47
46
  "@types/three": "^0.169.0",
48
47
  "eslint": "^9.6.0",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../node_modules/three/examples/jsm/lines/LineSegmentsGeometry.js","../../../node_modules/three/examples/jsm/lines/LineMaterial.js","../../../node_modules/three/examples/jsm/lines/LineSegments2.js","../src/debug/debug-drawer.ts","../src/helpers/crowd-helper.ts","../src/helpers/nav-mesh-helper.ts","../src/helpers/off-mesh-connections-helper.ts","../src/helpers/tile-cache-helper.ts","../src/utils/get-positions-and-indices.ts","../src/utils/generators.ts"],"sourcesContent":["import {\n\tBox3,\n\tFloat32BufferAttribute,\n\tInstancedBufferGeometry,\n\tInstancedInterleavedBuffer,\n\tInterleavedBufferAttribute,\n\tSphere,\n\tVector3,\n\tWireframeGeometry\n} from 'three';\n\nconst _box = new Box3();\nconst _vector = new Vector3();\n\nclass LineSegmentsGeometry extends InstancedBufferGeometry {\n\n\tconstructor() {\n\n\t\tsuper();\n\n\t\tthis.isLineSegmentsGeometry = true;\n\n\t\tthis.type = 'LineSegmentsGeometry';\n\n\t\tconst 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\t\tconst uvs = [ - 1, 2, 1, 2, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 2, 1, - 2 ];\n\t\tconst index = [ 0, 2, 1, 2, 3, 1, 2, 4, 3, 4, 5, 3, 4, 6, 5, 6, 7, 5 ];\n\n\t\tthis.setIndex( index );\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );\n\t\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\t}\n\n\tapplyMatrix4( matrix ) {\n\n\t\tconst start = this.attributes.instanceStart;\n\t\tconst end = this.attributes.instanceEnd;\n\n\t\tif ( start !== undefined ) {\n\n\t\t\tstart.applyMatrix4( matrix );\n\n\t\t\tend.applyMatrix4( matrix );\n\n\t\t\tstart.needsUpdate = true;\n\n\t\t}\n\n\t\tif ( this.boundingBox !== null ) {\n\n\t\t\tthis.computeBoundingBox();\n\n\t\t}\n\n\t\tif ( this.boundingSphere !== null ) {\n\n\t\t\tthis.computeBoundingSphere();\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n\tsetPositions( array ) {\n\n\t\tlet lineSegments;\n\n\t\tif ( array instanceof Float32Array ) {\n\n\t\t\tlineSegments = array;\n\n\t\t} else if ( Array.isArray( array ) ) {\n\n\t\t\tlineSegments = new Float32Array( array );\n\n\t\t}\n\n\t\tconst instanceBuffer = new InstancedInterleavedBuffer( lineSegments, 6, 1 ); // xyz, xyz\n\n\t\tthis.setAttribute( 'instanceStart', new InterleavedBufferAttribute( instanceBuffer, 3, 0 ) ); // xyz\n\t\tthis.setAttribute( 'instanceEnd', new InterleavedBufferAttribute( instanceBuffer, 3, 3 ) ); // xyz\n\n\t\t//\n\n\t\tthis.computeBoundingBox();\n\t\tthis.computeBoundingSphere();\n\n\t\treturn this;\n\n\t}\n\n\tsetColors( array ) {\n\n\t\tlet colors;\n\n\t\tif ( array instanceof Float32Array ) {\n\n\t\t\tcolors = array;\n\n\t\t} else if ( Array.isArray( array ) ) {\n\n\t\t\tcolors = new Float32Array( array );\n\n\t\t}\n\n\t\tconst instanceColorBuffer = new InstancedInterleavedBuffer( colors, 6, 1 ); // rgb, rgb\n\n\t\tthis.setAttribute( 'instanceColorStart', new InterleavedBufferAttribute( instanceColorBuffer, 3, 0 ) ); // rgb\n\t\tthis.setAttribute( 'instanceColorEnd', new InterleavedBufferAttribute( instanceColorBuffer, 3, 3 ) ); // rgb\n\n\t\treturn this;\n\n\t}\n\n\tfromWireframeGeometry( geometry ) {\n\n\t\tthis.setPositions( geometry.attributes.position.array );\n\n\t\treturn this;\n\n\t}\n\n\tfromEdgesGeometry( geometry ) {\n\n\t\tthis.setPositions( geometry.attributes.position.array );\n\n\t\treturn this;\n\n\t}\n\n\tfromMesh( mesh ) {\n\n\t\tthis.fromWireframeGeometry( new WireframeGeometry( mesh.geometry ) );\n\n\t\t// set colors, maybe\n\n\t\treturn this;\n\n\t}\n\n\tfromLineSegments( lineSegments ) {\n\n\t\tconst geometry = lineSegments.geometry;\n\n\t\tthis.setPositions( geometry.attributes.position.array ); // assumes non-indexed\n\n\t\t// set colors, maybe\n\n\t\treturn this;\n\n\t}\n\n\tcomputeBoundingBox() {\n\n\t\tif ( this.boundingBox === null ) {\n\n\t\t\tthis.boundingBox = new Box3();\n\n\t\t}\n\n\t\tconst start = this.attributes.instanceStart;\n\t\tconst end = this.attributes.instanceEnd;\n\n\t\tif ( start !== undefined && end !== undefined ) {\n\n\t\t\tthis.boundingBox.setFromBufferAttribute( start );\n\n\t\t\t_box.setFromBufferAttribute( end );\n\n\t\t\tthis.boundingBox.union( _box );\n\n\t\t}\n\n\t}\n\n\tcomputeBoundingSphere() {\n\n\t\tif ( this.boundingSphere === null ) {\n\n\t\t\tthis.boundingSphere = new Sphere();\n\n\t\t}\n\n\t\tif ( this.boundingBox === null ) {\n\n\t\t\tthis.computeBoundingBox();\n\n\t\t}\n\n\t\tconst start = this.attributes.instanceStart;\n\t\tconst end = this.attributes.instanceEnd;\n\n\t\tif ( start !== undefined && end !== undefined ) {\n\n\t\t\tconst center = this.boundingSphere.center;\n\n\t\t\tthis.boundingBox.getCenter( center );\n\n\t\t\tlet maxRadiusSq = 0;\n\n\t\t\tfor ( let i = 0, il = start.count; i < il; i ++ ) {\n\n\t\t\t\t_vector.fromBufferAttribute( start, i );\n\t\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );\n\n\t\t\t\t_vector.fromBufferAttribute( end, i );\n\t\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );\n\n\t\t\t}\n\n\t\t\tthis.boundingSphere.radius = Math.sqrt( maxRadiusSq );\n\n\t\t\tif ( isNaN( this.boundingSphere.radius ) ) {\n\n\t\t\t\tconsole.error( 'THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.', this );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\ttoJSON() {\n\n\t\t// todo\n\n\t}\n\n\tapplyMatrix( matrix ) {\n\n\t\tconsole.warn( 'THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4().' );\n\n\t\treturn this.applyMatrix4( matrix );\n\n\t}\n\n}\n\nexport { LineSegmentsGeometry };\n","import {\n\tShaderLib,\n\tShaderMaterial,\n\tUniformsLib,\n\tUniformsUtils,\n\tVector2,\n} from 'three';\n\nUniformsLib.line = {\n\n\tworldUnits: { value: 1 },\n\tlinewidth: { value: 1 },\n\tresolution: { value: new Vector2( 1, 1 ) },\n\tdashOffset: { value: 0 },\n\tdashScale: { value: 1 },\n\tdashSize: { value: 1 },\n\tgapSize: { value: 1 } // todo FIX - maybe change to totalSize\n\n};\n\nShaderLib[ 'line' ] = {\n\n\tuniforms: UniformsUtils.merge( [\n\t\tUniformsLib.common,\n\t\tUniformsLib.fog,\n\t\tUniformsLib.line\n\t] ),\n\n\tvertexShader:\n\t/* glsl */`\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tworldStart = start.xyz;\n\t\t\t\tworldEnd = end.xyz;\n\n\t\t\t#else\n\n\t\t\t\tvUv = uv;\n\n\t\t\t#endif\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec3 ndcStart = clipStart.xyz / clipStart.w;\n\t\t\tvec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd.xy - ndcStart.xy;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\tvec3 worldDir = normalize( end.xyz - start.xyz );\n\t\t\t\tvec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );\n\t\t\t\tvec3 worldUp = normalize( cross( worldDir, tmpFwd ) );\n\t\t\t\tvec3 worldFwd = cross( worldDir, worldUp );\n\t\t\t\tworldPos = position.y < 0.5 ? start: end;\n\n\t\t\t\t// height offset\n\t\t\t\tfloat hw = linewidth * 0.5;\n\t\t\t\tworldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;\n\n\t\t\t\t// don't extend the line if we're rendering dashes because we\n\t\t\t\t// won't be rendering the endcaps\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t// cap extension\n\t\t\t\t\tworldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;\n\n\t\t\t\t\t// add width to the box\n\t\t\t\t\tworldPos.xyz += worldFwd * hw;\n\n\t\t\t\t\t// endcaps\n\t\t\t\t\tif ( position.y > 1.0 || position.y < 0.0 ) {\n\n\t\t\t\t\t\tworldPos.xyz -= worldFwd * 2.0 * hw;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t\t// project the worldpos\n\t\t\t\tvec4 clip = projectionMatrix * worldPos;\n\n\t\t\t\t// shift the depth of the projected points so the line\n\t\t\t\t// segments overlap neatly\n\t\t\t\tvec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n\t\t\t\tclip.z = clipPose.z * clip.w;\n\n\t\t\t#else\n\n\t\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\t\t\t\t// undo aspect ratio adjustment\n\t\t\t\tdir.x /= aspect;\n\t\t\t\toffset.x /= aspect;\n\n\t\t\t\t// sign flip\n\t\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t\t// endcaps\n\t\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\t\toffset += - dir;\n\n\t\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\t\toffset += dir;\n\n\t\t\t\t}\n\n\t\t\t\t// adjust for linewidth\n\t\t\t\toffset *= linewidth;\n\n\t\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\t\toffset /= resolution.y;\n\n\t\t\t\t// select end\n\t\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t\t// back to clip space\n\t\t\t\toffset *= clip.w;\n\n\t\t\t\tclip.xy += offset;\n\n\t\t\t#endif\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t`,\n\n\tfragmentShader:\n\t/* glsl */`\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float linewidth;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#ifdef WORLD_UNITS\n\n\t\t\tvarying vec4 worldPos;\n\t\t\tvarying vec3 worldStart;\n\t\t\tvarying vec3 worldEnd;\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvarying vec2 vUv;\n\n\t\t\t#endif\n\n\t\t#else\n\n\t\t\tvarying vec2 vUv;\n\n\t\t#endif\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n\t\t\tfloat mua;\n\t\t\tfloat mub;\n\n\t\t\tvec3 p13 = p1 - p3;\n\t\t\tvec3 p43 = p4 - p3;\n\n\t\t\tvec3 p21 = p2 - p1;\n\n\t\t\tfloat d1343 = dot( p13, p43 );\n\t\t\tfloat d4321 = dot( p43, p21 );\n\t\t\tfloat d1321 = dot( p13, p21 );\n\t\t\tfloat d4343 = dot( p43, p43 );\n\t\t\tfloat d2121 = dot( p21, p21 );\n\n\t\t\tfloat denom = d2121 * d4343 - d4321 * d4321;\n\n\t\t\tfloat numer = d1343 * d4321 - d1321 * d4343;\n\n\t\t\tmua = numer / denom;\n\t\t\tmua = clamp( mua, 0.0, 1.0 );\n\t\t\tmub = ( d1343 + d4321 * ( mua ) ) / d4343;\n\t\t\tmub = clamp( mub, 0.0, 1.0 );\n\n\t\t\treturn vec2( mua, mub );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tfloat alpha = opacity;\n\n\t\t\t#ifdef WORLD_UNITS\n\n\t\t\t\t// Find the closest points on the view ray and the line segment\n\t\t\t\tvec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n\t\t\t\tvec3 lineDir = worldEnd - worldStart;\n\t\t\t\tvec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n\t\t\t\tvec3 p1 = worldStart + lineDir * params.x;\n\t\t\t\tvec3 p2 = rayEnd * params.y;\n\t\t\t\tvec3 delta = p1 - p2;\n\t\t\t\tfloat len = length( delta );\n\t\t\t\tfloat norm = len / linewidth;\n\n\t\t\t\t#ifndef USE_DASH\n\n\t\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t\tfloat dnorm = fwidth( norm );\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n\t\t\t\t\t#else\n\n\t\t\t\t\t\tif ( norm > 0.5 ) {\n\n\t\t\t\t\t\t\tdiscard;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t#else\n\n\t\t\t\t#ifdef USE_ALPHA_TO_COVERAGE\n\n\t\t\t\t\t// artifacts appear on some hardware if a derivative is taken within a conditional\n\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\tfloat len2 = a * a + b * b;\n\t\t\t\t\tfloat dlen = fwidth( len2 );\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\talpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\t\t\tfloat a = vUv.x;\n\t\t\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, alpha );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\t\t\t#include <fog_fragment>\n\t\t\t#include <premultiplied_alpha_fragment>\n\n\t\t}\n\t\t`\n};\n\nclass LineMaterial extends ShaderMaterial {\n\n\tconstructor( parameters ) {\n\n\t\tsuper( {\n\n\t\t\ttype: 'LineMaterial',\n\n\t\t\tuniforms: UniformsUtils.clone( ShaderLib[ 'line' ].uniforms ),\n\n\t\t\tvertexShader: ShaderLib[ 'line' ].vertexShader,\n\t\t\tfragmentShader: ShaderLib[ 'line' ].fragmentShader,\n\n\t\t\tclipping: true // required for clipping support\n\n\t\t} );\n\n\t\tthis.isLineMaterial = true;\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n\tget color() {\n\n\t\treturn this.uniforms.diffuse.value;\n\n\t}\n\n\tset color( value ) {\n\n\t\tthis.uniforms.diffuse.value = value;\n\n\t}\n\n\tget worldUnits() {\n\n\t\treturn 'WORLD_UNITS' in this.defines;\n\n\t}\n\n\tset worldUnits( value ) {\n\n\t\tif ( value === true ) {\n\n\t\t\tthis.defines.WORLD_UNITS = '';\n\n\t\t} else {\n\n\t\t\tdelete this.defines.WORLD_UNITS;\n\n\t\t}\n\n\t}\n\n\tget linewidth() {\n\n\t\treturn this.uniforms.linewidth.value;\n\n\t}\n\n\tset linewidth( value ) {\n\n\t\tif ( ! this.uniforms.linewidth ) return;\n\t\tthis.uniforms.linewidth.value = value;\n\n\t}\n\n\tget dashed() {\n\n\t\treturn 'USE_DASH' in this.defines;\n\n\t}\n\n\tset dashed( value ) {\n\n\t\tif ( ( value === true ) !== this.dashed ) {\n\n\t\t\tthis.needsUpdate = true;\n\n\t\t}\n\n\t\tif ( value === true ) {\n\n\t\t\tthis.defines.USE_DASH = '';\n\n\t\t} else {\n\n\t\t\tdelete this.defines.USE_DASH;\n\n\t\t}\n\n\t}\n\n\tget dashScale() {\n\n\t\treturn this.uniforms.dashScale.value;\n\n\t}\n\n\tset dashScale( value ) {\n\n\t\tthis.uniforms.dashScale.value = value;\n\n\t}\n\n\tget dashSize() {\n\n\t\treturn this.uniforms.dashSize.value;\n\n\t}\n\n\tset dashSize( value ) {\n\n\t\tthis.uniforms.dashSize.value = value;\n\n\t}\n\n\tget dashOffset() {\n\n\t\treturn this.uniforms.dashOffset.value;\n\n\t}\n\n\tset dashOffset( value ) {\n\n\t\tthis.uniforms.dashOffset.value = value;\n\n\t}\n\n\tget gapSize() {\n\n\t\treturn this.uniforms.gapSize.value;\n\n\t}\n\n\tset gapSize( value ) {\n\n\t\tthis.uniforms.gapSize.value = value;\n\n\t}\n\n\tget opacity() {\n\n\t\treturn this.uniforms.opacity.value;\n\n\t}\n\n\tset opacity( value ) {\n\n\t\tif ( ! this.uniforms ) return;\n\t\tthis.uniforms.opacity.value = value;\n\n\t}\n\n\tget resolution() {\n\n\t\treturn this.uniforms.resolution.value;\n\n\t}\n\n\tset resolution( value ) {\n\n\t\tthis.uniforms.resolution.value.copy( value );\n\n\t}\n\n\tget alphaToCoverage() {\n\n\t\treturn 'USE_ALPHA_TO_COVERAGE' in this.defines;\n\n\t}\n\n\tset alphaToCoverage( value ) {\n\n\t\tif ( ! this.defines ) return;\n\n\t\tif ( ( value === true ) !== this.alphaToCoverage ) {\n\n\t\t\tthis.needsUpdate = true;\n\n\t\t}\n\n\t\tif ( value === true ) {\n\n\t\t\tthis.defines.USE_ALPHA_TO_COVERAGE = '';\n\n\t\t} else {\n\n\t\t\tdelete this.defines.USE_ALPHA_TO_COVERAGE;\n\n\t\t}\n\n\t}\n\n}\n\nexport { LineMaterial };\n","import {\n\tBox3,\n\tInstancedInterleavedBuffer,\n\tInterleavedBufferAttribute,\n\tLine3,\n\tMathUtils,\n\tMatrix4,\n\tMesh,\n\tSphere,\n\tVector3,\n\tVector4\n} from 'three';\nimport { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry.js';\nimport { LineMaterial } from '../lines/LineMaterial.js';\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\n\t// transform into clip space, adjust the x and y values by the pixel width offset, then\n\t// transform back into world space to get world offset. Note clip space is [-1, 1] so full\n\t// width does not need to be halved.\n\t_clipToWorldVector.set( 0, 0, - distance, 1.0 ).applyMatrix4( camera.projectionMatrix );\n\t_clipToWorldVector.multiplyScalar( 1.0 / _clipToWorldVector.w );\n\t_clipToWorldVector.x = _lineWidth / resolution.width;\n\t_clipToWorldVector.y = _lineWidth / resolution.height;\n\t_clipToWorldVector.applyMatrix4( camera.projectionMatrixInverse );\n\t_clipToWorldVector.multiplyScalar( 1.0 / _clipToWorldVector.w );\n\n\treturn Math.abs( Math.max( _clipToWorldVector.x, _clipToWorldVector.y ) );\n\n}\n\nfunction raycastWorldUnits( lineSegments, intersects ) {\n\n\tconst matrixWorld = lineSegments.matrixWorld;\n\tconst geometry = lineSegments.geometry;\n\tconst instanceStart = geometry.attributes.instanceStart;\n\tconst instanceEnd = geometry.attributes.instanceEnd;\n\tconst segmentCount = Math.min( geometry.instanceCount, instanceStart.count );\n\n\tfor ( let i = 0, l = segmentCount; i < l; i ++ ) {\n\n\t\t_line.start.fromBufferAttribute( instanceStart, i );\n\t\t_line.end.fromBufferAttribute( instanceEnd, i );\n\n\t\t_line.applyMatrix4( matrixWorld );\n\n\t\tconst pointOnLine = new Vector3();\n\t\tconst point = new Vector3();\n\n\t\t_ray.distanceSqToSegment( _line.start, _line.end, point, pointOnLine );\n\t\tconst isInside = point.distanceTo( pointOnLine ) < _lineWidth * 0.5;\n\n\t\tif ( isInside ) {\n\n\t\t\tintersects.push( {\n\t\t\t\tpoint,\n\t\t\t\tpointOnLine,\n\t\t\t\tdistance: _ray.origin.distanceTo( point ),\n\t\t\t\tobject: lineSegments,\n\t\t\t\tface: null,\n\t\t\t\tfaceIndex: i,\n\t\t\t\tuv: null,\n\t\t\t\tuv1: null,\n\t\t\t} );\n\n\t\t}\n\n\t}\n\n}\n\nfunction raycastScreenSpace( lineSegments, camera, intersects ) {\n\n\tconst projectionMatrix = camera.projectionMatrix;\n\tconst material = lineSegments.material;\n\tconst resolution = material.resolution;\n\tconst matrixWorld = lineSegments.matrixWorld;\n\n\tconst geometry = lineSegments.geometry;\n\tconst instanceStart = geometry.attributes.instanceStart;\n\tconst instanceEnd = geometry.attributes.instanceEnd;\n\tconst segmentCount = Math.min( geometry.instanceCount, instanceStart.count );\n\n\tconst near = - camera.near;\n\n\t//\n\n\t// pick a point 1 unit out along the ray to avoid the ray origin\n\t// sitting at the camera origin which will cause \"w\" to be 0 when\n\t// applying the projection matrix.\n\t_ray.at( 1, _ssOrigin );\n\n\t// ndc space [ - 1.0, 1.0 ]\n\t_ssOrigin.w = 1;\n\t_ssOrigin.applyMatrix4( camera.matrixWorldInverse );\n\t_ssOrigin.applyMatrix4( projectionMatrix );\n\t_ssOrigin.multiplyScalar( 1 / _ssOrigin.w );\n\n\t// screen space\n\t_ssOrigin.x *= resolution.x / 2;\n\t_ssOrigin.y *= resolution.y / 2;\n\t_ssOrigin.z = 0;\n\n\t_ssOrigin3.copy( _ssOrigin );\n\n\t_mvMatrix.multiplyMatrices( camera.matrixWorldInverse, matrixWorld );\n\n\tfor ( let i = 0, l = segmentCount; i < l; i ++ ) {\n\n\t\t_start4.fromBufferAttribute( instanceStart, i );\n\t\t_end4.fromBufferAttribute( instanceEnd, i );\n\n\t\t_start4.w = 1;\n\t\t_end4.w = 1;\n\n\t\t// camera space\n\t\t_start4.applyMatrix4( _mvMatrix );\n\t\t_end4.applyMatrix4( _mvMatrix );\n\n\t\t// skip the segment if it's entirely behind the camera\n\t\tconst isBehindCameraNear = _start4.z > near && _end4.z > near;\n\t\tif ( isBehindCameraNear ) {\n\n\t\t\tcontinue;\n\n\t\t}\n\n\t\t// trim the segment if it extends behind camera near\n\t\tif ( _start4.z > near ) {\n\n\t\t\tconst deltaDist = _start4.z - _end4.z;\n\t\t\tconst t = ( _start4.z - near ) / deltaDist;\n\t\t\t_start4.lerp( _end4, t );\n\n\t\t} else if ( _end4.z > near ) {\n\n\t\t\tconst deltaDist = _end4.z - _start4.z;\n\t\t\tconst t = ( _end4.z - near ) / deltaDist;\n\t\t\t_end4.lerp( _start4, t );\n\n\t\t}\n\n\t\t// clip space\n\t\t_start4.applyMatrix4( projectionMatrix );\n\t\t_end4.applyMatrix4( projectionMatrix );\n\n\t\t// ndc space [ - 1.0, 1.0 ]\n\t\t_start4.multiplyScalar( 1 / _start4.w );\n\t\t_end4.multiplyScalar( 1 / _end4.w );\n\n\t\t// screen space\n\t\t_start4.x *= resolution.x / 2;\n\t\t_start4.y *= resolution.y / 2;\n\n\t\t_end4.x *= resolution.x / 2;\n\t\t_end4.y *= resolution.y / 2;\n\n\t\t// create 2d segment\n\t\t_line.start.copy( _start4 );\n\t\t_line.start.z = 0;\n\n\t\t_line.end.copy( _end4 );\n\t\t_line.end.z = 0;\n\n\t\t// get closest point on ray to segment\n\t\tconst param = _line.closestPointToPointParameter( _ssOrigin3, true );\n\t\t_line.at( param, _closestPoint );\n\n\t\t// check if the intersection point is within clip space\n\t\tconst zPos = MathUtils.lerp( _start4.z, _end4.z, param );\n\t\tconst isInClipSpace = zPos >= - 1 && zPos <= 1;\n\n\t\tconst isInside = _ssOrigin3.distanceTo( _closestPoint ) < _lineWidth * 0.5;\n\n\t\tif ( isInClipSpace && isInside ) {\n\n\t\t\t_line.start.fromBufferAttribute( instanceStart, i );\n\t\t\t_line.end.fromBufferAttribute( instanceEnd, i );\n\n\t\t\t_line.start.applyMatrix4( matrixWorld );\n\t\t\t_line.end.applyMatrix4( matrixWorld );\n\n\t\t\tconst pointOnLine = new Vector3();\n\t\t\tconst point = new Vector3();\n\n\t\t\t_ray.distanceSqToSegment( _line.start, _line.end, point, pointOnLine );\n\n\t\t\tintersects.push( {\n\t\t\t\tpoint: point,\n\t\t\t\tpointOnLine: pointOnLine,\n\t\t\t\tdistance: _ray.origin.distanceTo( point ),\n\t\t\t\tobject: lineSegments,\n\t\t\t\tface: null,\n\t\t\t\tfaceIndex: i,\n\t\t\t\tuv: null,\n\t\t\t\tuv1: null,\n\t\t\t} );\n\n\t\t}\n\n\t}\n\n}\n\nclass LineSegments2 extends Mesh {\n\n\tconstructor( geometry = new LineSegmentsGeometry(), material = new LineMaterial( { color: Math.random() * 0xffffff } ) ) {\n\n\t\tsuper( geometry, material );\n\n\t\tthis.isLineSegments2 = true;\n\n\t\tthis.type = 'LineSegments2';\n\n\t}\n\n\t// for backwards-compatibility, but could be a method of LineSegmentsGeometry...\n\n\tcomputeLineDistances() {\n\n\t\tconst geometry = this.geometry;\n\n\t\tconst instanceStart = geometry.attributes.instanceStart;\n\t\tconst instanceEnd = geometry.attributes.instanceEnd;\n\t\tconst lineDistances = new Float32Array( 2 * instanceStart.count );\n\n\t\tfor ( let i = 0, j = 0, l = instanceStart.count; i < l; i ++, j += 2 ) {\n\n\t\t\t_start.fromBufferAttribute( instanceStart, i );\n\t\t\t_end.fromBufferAttribute( instanceEnd, i );\n\n\t\t\tlineDistances[ j ] = ( j === 0 ) ? 0 : lineDistances[ j - 1 ];\n\t\t\tlineDistances[ j + 1 ] = lineDistances[ j ] + _start.distanceTo( _end );\n\n\t\t}\n\n\t\tconst instanceDistanceBuffer = new InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1\n\n\t\tgeometry.setAttribute( 'instanceDistanceStart', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0\n\t\tgeometry.setAttribute( 'instanceDistanceEnd', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1\n\n\t\treturn this;\n\n\t}\n\n\traycast( raycaster, intersects ) {\n\n\t\tconst worldUnits = this.material.worldUnits;\n\t\tconst camera = raycaster.camera;\n\n\t\tif ( camera === null && ! worldUnits ) {\n\n\t\t\tconsole.error( 'LineSegments2: \"Raycaster.camera\" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.' );\n\n\t\t}\n\n\t\tconst threshold = ( raycaster.params.Line2 !== undefined ) ? raycaster.params.Line2.threshold || 0 : 0;\n\n\t\t_ray = raycaster.ray;\n\n\t\tconst matrixWorld = this.matrixWorld;\n\t\tconst geometry = this.geometry;\n\t\tconst material = this.material;\n\n\t\t_lineWidth = material.linewidth + threshold;\n\n\t\t// check if we intersect the sphere bounds\n\t\tif ( geometry.boundingSphere === null ) {\n\n\t\t\tgeometry.computeBoundingSphere();\n\n\t\t}\n\n\t\t_sphere.copy( geometry.boundingSphere ).applyMatrix4( matrixWorld );\n\n\t\t// increase the sphere bounds by the worst case line screen space width\n\t\tlet sphereMargin;\n\t\tif ( worldUnits ) {\n\n\t\t\tsphereMargin = _lineWidth * 0.5;\n\n\t\t} else {\n\n\t\t\tconst distanceToSphere = Math.max( camera.near, _sphere.distanceToPoint( _ray.origin ) );\n\t\t\tsphereMargin = getWorldSpaceHalfWidth( camera, distanceToSphere, material.resolution );\n\n\t\t}\n\n\t\t_sphere.radius += sphereMargin;\n\n\t\tif ( _ray.intersectsSphere( _sphere ) === false ) {\n\n\t\t\treturn;\n\n\t\t}\n\n\t\t// check if we intersect the box bounds\n\t\tif ( geometry.boundingBox === null ) {\n\n\t\t\tgeometry.computeBoundingBox();\n\n\t\t}\n\n\t\t_box.copy( geometry.boundingBox ).applyMatrix4( matrixWorld );\n\n\t\t// increase the box bounds by the worst case line width\n\t\tlet boxMargin;\n\t\tif ( worldUnits ) {\n\n\t\t\tboxMargin = _lineWidth * 0.5;\n\n\t\t} else {\n\n\t\t\tconst distanceToBox = Math.max( camera.near, _box.distanceToPoint( _ray.origin ) );\n\t\t\tboxMargin = getWorldSpaceHalfWidth( camera, distanceToBox, material.resolution );\n\n\t\t}\n\n\t\t_box.expandByScalar( boxMargin );\n\n\t\tif ( _ray.intersectsBox( _box ) === false ) {\n\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( worldUnits ) {\n\n\t\t\traycastWorldUnits( this, intersects );\n\n\t\t} else {\n\n\t\t\traycastScreenSpace( this, camera, intersects );\n\n\t\t}\n\n\t}\n\n\tonBeforeRender( renderer ) {\n\n\t\tconst uniforms = this.material.uniforms;\n\n\t\tif ( uniforms && uniforms.resolution ) {\n\n\t\t\trenderer.getViewport( _viewport );\n\t\t\tthis.material.uniforms.resolution.value.set( _viewport.z, _viewport.w );\n\n\t\t}\n\n\t}\n\n}\n\nexport { LineSegments2 };\n",null,null,null,null,null,null,null],"names":["_box","Box3","_vector","Vector3","LineSegmentsGeometry","InstancedBufferGeometry","constructor","super","this","isLineSegmentsGeometry","type","setIndex","setAttribute","Float32BufferAttribute","applyMatrix4","matrix","start","attributes","instanceStart","end","instanceEnd","undefined","needsUpdate","boundingBox","computeBoundingBox","boundingSphere","computeBoundingSphere","setPositions","array","lineSegments","Float32Array","Array","isArray","instanceBuffer","InstancedInterleavedBuffer","InterleavedBufferAttribute","setColors","colors","instanceColorBuffer","fromWireframeGeometry","geometry","position","fromEdgesGeometry","fromMesh","mesh","WireframeGeometry","fromLineSegments","setFromBufferAttribute","union","Sphere","center","getCenter","maxRadiusSq","i","il","count","fromBufferAttribute","Math","max","distanceToSquared","radius","sqrt","isNaN","console","error","toJSON","applyMatrix","warn","UniformsLib","line","worldUnits","value","linewidth","resolution","Vector2","dashOffset","dashScale","dashSize","gapSize","ShaderLib","uniforms","UniformsUtils","merge","common","fog","vertexShader","fragmentShader","LineMaterial","ShaderMaterial","parameters","clone","clipping","isLineMaterial","setValues","color","diffuse","defines","WORLD_UNITS","dashed","USE_DASH","opacity","copy","alphaToCoverage","USE_ALPHA_TO_COVERAGE","_viewport","Vector4","_start","_end","_start4","_end4","_ssOrigin","_ssOrigin3","_mvMatrix","Matrix4","_line","Line3","_closestPoint","_sphere","_clipToWorldVector","_ray","_lineWidth","getWorldSpaceHalfWidth","camera","distance","set","projectionMatrix","multiplyScalar","w","x","width","y","height","projectionMatrixInverse","abs","LineSegments2","Mesh","material","random","isLineSegments2","computeLineDistances","lineDistances","j","l","distanceTo","instanceDistanceBuffer","raycast","raycaster","intersects","threshold","params","Line2","ray","matrixWorld","sphereMargin","boxMargin","near","distanceToPoint","origin","intersectsSphere","expandByScalar","intersectsBox","min","instanceCount","pointOnLine","point","distanceSqToSegment","push","object","face","faceIndex","uv","uv1","raycastWorldUnits","segmentCount","at","matrixWorldInverse","z","multiplyMatrices","deltaDist","t","lerp","param","closestPointToPointParameter","zPos","MathUtils","isInClipSpace","isInside","raycastScreenSpace","onBeforeRender","renderer","getViewport","_color","THREE","Color","DebugDrawer","Group","pointGeometry","SphereGeometry","triMaterial","pointMaterial","lineMaterial","debugDrawerUtils","DebugDrawerUtils","MeshBasicMaterial","vertexColors","transparent","depthWrite","polygonOffset","polygonOffsetFactor","polygonOffsetUnits","drawPrimitives","primitives","primitive","drawPoints","drawLines","drawTris","drawQuads","drawHeightfieldSolid","hf","drawHeightfieldWalkable","drawCompactHeightfieldSolid","chf","drawCompactHeightfieldRegions","drawCompactHeightfieldDistance","drawHeightfieldLayer","layer","idx","drawHeightfieldLayers","lset","drawRegionConnections","cset","alpha","drawRawContours","drawContours","drawPolyMesh","drawPolyMeshDetail","dmesh","drawNavMesh","flags","drawNavMeshWithClosedList","query","drawNavMeshNodes","drawNavMeshBVTree","drawNavMeshPortals","drawNavMeshPolysWithFlags","col","drawNavMeshPoly","ref","reset","child","children","dispose","clear","instancedMesh","InstancedMesh","vertices","length","r","g","b","setMatrixAt","setPosition","setColorAt","setRGB","instanceMatrix","add","lineSegmentsGeometry","positions","x1","y1","z1","r1","g1","b1","x2","y2","z2","r2","g2","b2","BufferGeometry","BufferAttribute","CrowdHelper","Object3D","agentMeshes","Map","crowd","recastCrowd","agentMaterial","update","agents","getAgents","unseen","Set","keys","agent","delete","agentIndex","velocity","agentMesh","get","createAgentMesh","updateAgentGeometry","lookAt","agentId","remove","userData","agentParams","CylinderGeometry","NavMeshHelper","navMesh","navMeshGeometry","navMeshMaterial","indices","getDebugNavMesh","from","Uint32Array","computeVertexNormals","OffMeshConnectionsHelper","offMeshConnections","entryCircleMaterial","exitCircleMaterial","LineBasicMaterial","offMeshConnection","circleGeometry","CircleGeometry","startMesh","startPosition","rotation","PI","endMesh","bidirectional","endPosition","middle","addVectors","curvePoints","CatmullRomCurve3","getPoints","lineGeometry","setFromPoints","Line","TileCacheHelper","obstacleMeshes","tileCache","obstacleMaterial","wireframe","wireframeLinewidth","obstacle","obstacles","obstacleMesh","halfExtents","angle","BoxGeometry","Error","_position","getPositionsAndIndices","meshes","toMerge","positionAttribute","itemSize","updateMatrixWorld","pos","localToWorld","getIndex","ascendingIndex","mergePositionsAndIndices","threeToSoloNavMesh","navMeshGeneratorConfig","keepIntermediates","generateSoloNavMesh","threeToTiledNavMesh","generateTiledNavMesh","threeToTileCache","generateTileCache"],"mappings":"8vBAWA,MAAMA,EAAO,IAAIC,EACXC,EAAU,IAAIC,EAEpB,MAAMC,UAA6BC,EAElC,WAAAC,GAECC,QAEAC,KAAKC,wBAAyB,EAE9BD,KAAKE,KAAO,uBAMZF,KAAKG,SAFS,CAAE,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,IAGnEH,KAAKI,aAAc,WAAY,IAAIC,EAL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