1import{r as u,j as n,b as Pe}from"./index-BawMCgu8.js";import{v as _e,a as re,_ as ie,C as De,O as Be}from"./OrbitControls-DYqG4YG1.js";import{aR as ke,F as de,aS as oe,ac as I,aT as He,aj as ae,ak as Se,V as y,al as Te,am as ue,aU as fe,a as $,i as Ge,aV as N,aW as We,e as Ie,a6 as Ne,C as we,aX as Fe,au as Ve,R as pe,aH as qe,Q as Je}from"./three.module-ClqPj1K9.js";import{c as Xe,P as $e,a as Ye}from"./PipelineWorkspacePage-BDtuj-cH.js";import"./locale-en-B8Z5F_o1.js";import"./locale-zh-CN-CFdD1mPv.js";import"./locale-fr-j4CMJpfE.js";import"./locale-de-DuE2gagy.js";import"./locale-it-C6yb6RzN.js";import"./locale-ja-VjZBy5eF.js";import"./locale-ko-Cl0W-Az5.js";import"./locale-es-DwboUZze.js";import"./locale-zh-Hant-uT5aTnfX.js";import"./locale-ru-DEr1xfTZ.js";import"./locale-id-Buh3Uolz.js";import"./locale-pt-BR-CqD5J4_0.js";import"./pipeline-BcFGB0IF.js";import"./zoom-in-CWl6FHRb.js";import"./utensils-crossed-DkdXdCqk.js";import"./focus-B2P-yv9L.js";import"./rotate-cw-Cs8sg7VG.js";import"./pen-line-Fq8TC4Qi.js";import"./html2canvas.esm-CBrSDip1.js";import"./save-BInnCtLF.js";import"./jszip.min-CCODYnd_.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";import"./table-DvUKeEob.js";const be=_e>=125?"uv1":"uv2",he=new ae,q=new y;class le extends ke{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const t=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],i=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],e=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(e),this.setAttribute("position",new de(t,3)),this.setAttribute("uv",new de(i,2))}applyMatrix4(t){const i=this.attributes.instanceStart,e=this.attributes.instanceEnd;
1return i!==void 0&&(i.applyMatrix4(t),e.applyMatrix4(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(t){let i;t instanceof Float32Array?i=t:Array.isArray(t)&&(i=new Float32Array(t));const e=new oe(i,6,1);return this.setAttribute("instanceStart",new I(e,3,0)),this.setAttribute("instanceEnd",new I(e,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t,i=3){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const s=new oe(e,i*2,1);return this.setAttribute("instanceColorStart",new I(s,i,0)),this.setAttribute("instanceColorEnd",new I(s,i,i)),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 He(t.geometry)),this}fromLineSegments(t){const i=t.geometry;return this.setPositions(i.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ae);const t=this.attributes.instanceStart,i=this.attributes.instanceEnd;t!==void 0&&i!==void 0&&(this.boundingBox.setFromBufferAttribute(t),he.setFromBufferAttribute(i),this.boundingBox.union(he))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Se),this.boundingBox===null&&this.computeBoundingBox();const t=this.attributes.instanceStart,i=this.attributes.instanceEnd;if(t!==void 0&&i!==void 0){const e=this.boundingSphere.center;this.boundingBox.getCenter(e);let s=0;for(let o=0,p=t.count;o<p;o++)q.fromBufferAttribute(t,o),s=Math.max(s,e.distanceToSquared(q)),q.fromBufferAttribute(i,o),s=Math.max(s,e.distanceToSquared(q));this.boundingSphere.radius=Math.sqrt(s),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)}}class je extends le{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(t){const i=t.length-3,e=new Float32Array(2*i);for(let s=0;s<i;s+=3)e[2*s]=t[s],e[2*s+1]=t[s+1],e[2*s+2]=t[s+2],e[2*s+3]=t[s+3],e[2*s+4]=t[s+4],e[2*s+5]=t[s+5];return super.setPositions(e),this}setColors(t,i=3){const e=t.length-i,s=new Float32Array(2*e);if(i===3)for(let o=0;o<e;o+=i)s[2*o]=t[o],s[2*o+1]=t[o+1],s[2*o+2]=t[o+2],s[2*o+3]=t[o+3],s[2*o+4]=t[o+4],s[2*o+5]=t[o+5];else for(let o=0;o<e;o+=i)s[2*o]=t[o],s[2*o+1]=t[o+1],s[2*o+2]=t[o+2],s[2*o+3]=t[o+3],s[2*o+4]=t[o+4],s[2*o+5]=t[o+5],s[2*o+6]=t[o+6],s[2*o+7]=t[o+7];return super.setColors(s,i),this}fromLine(t){const i=t.geometry;return this.setPositions(i.attributes.position.array),this}}class ce extends Te{constructor(t){super({type:"LineMaterial",uniforms:ue.clone(ue.merge([fe.common,fe.fog,{worldUnits:{value:1},linewidth:{value:1},resolution:{value:new $(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}}])),vertexShader:` 2 #include <common> 3 #include <fog_pars_vertex> 4 #include <logdepthbuf_pars_vertex> 5 #include <clipping_planes_pars_vertex> 6 7 uniform float linewidth; 8 uniform vec2 resolution; 9 10 attribute vec3 instanceStart; 11 attribute vec3 instanceEnd; 12 13 #ifdef USE_COLOR 14 #ifdef USE_LINE_COLOR_ALPHA 15 varying vec4 vLineColor; 16 attribute vec4 instanceColorStart; 17 attribute vec4 instanceColorEnd; 18 #else 19 varying vec3 vLineColor; 20 attribute vec3 instanceColorStart; 21 attribute vec3 instanceColorEnd; 22 #endif 23 #endif 24 25 #ifdef WORLD_UNITS 26 27 varying vec4 worldPos; 28 varying vec3 worldStart; 29 varying vec3 worldEnd; 30 31 #ifdef USE_DASH 32 33 varying vec2 vUv; 34 35 #endif 36 37 #else 38 39 varying vec2 vUv; 40 41 #endif 42 43 #ifdef USE_DASH 44 45 uniform float dashScale; 46 attribute float instanceDistanceStart; 47 attribute float instanceDistanceEnd; 48 varying float vLineDistance; 49 50 #endif 51 52 void trimSegment( const in vec4 start, inout vec4 end ) { 53 54 // trim end segment so it terminates between the camera plane and the near plane 55 56 // conservative estimate of the near plane 57 float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column 58 float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column 59 float nearEstimate = - 0.5 * b / a; 60 61 float alpha = ( nearEstimate - start.z ) / ( end.z - start.z ); 62 63 end.xyz = mix( start.xyz, end.xyz, alpha ); 64 65 } 66 67 void main() { 68 69 #ifdef USE_COLOR 70 71 vLineColor = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd; 72 73 #endif 74 75 #ifdef USE_DASH 76 77 vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd; 78 vUv = uv; 79 80 #endif 81 82 float aspect = resolution.x / resolution.y; 83 84 // camera space 85 vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 ); 86 vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 ); 87 88 #ifdef WORLD_UNITS 89 90 worldStart = start.xyz; 91 worldEnd = end.xyz; 92 93 #else 94 95 vUv = uv; 96 97 #endif 98 99 // special case for perspective projection, and segments that terminate either in, or behind, the camera plane 100 // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space 101 // but we need to perform ndc-space calculations in the shader, so we must address this issue directly 102 // perhaps there is a more elegant solution -- WestLangley 103 104 bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column 105 106 if ( perspective ) { 107 108 if ( start.z < 0.0 && end.z >= 0.0 ) { 109 110 trimSegment( start, end ); 111 112 } else if ( end.z < 0.0 && start.z >= 0.0 ) { 113 114 trimSegment( end, start ); 115 116 } 117 118 } 119 120 // clip space 121 vec4 clipStart = projectionMatrix * start; 122 vec4 clipEnd = projectionMatrix * end; 123 124 // ndc space 125 vec3 ndcStart = clipStart.xyz / clipStart.w; 126 vec3 ndcEnd = clipEnd.xyz / clipEnd.w; 127 128 // direction 129 vec2 dir = ndcEnd.xy - ndcStart.xy; 130 131 // account for clip-space aspect ratio 132 dir.x *= aspect; 133 dir = normalize( dir ); 134 135 #ifdef WORLD_UNITS 136 137 // get the offset direction as perpendicular to the view vector
138 vec3 worldDir = normalize( end.xyz - start.xyz ); 139 vec3 offset; 140 if ( position.y < 0.5 ) { 141 142 offset = normalize( cross( start.xyz, worldDir ) ); 143 144 } else { 145 146 offset = normalize( cross( end.xyz, worldDir ) ); 147 148 } 149 150 // sign flip 151 if ( position.x < 0.0 ) offset *= - 1.0; 152 153 float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) ); 154 155 // don't extend the line if we're rendering dashes because we 156 // won't be rendering the endcaps 157 #ifndef USE_DASH 158 159 // extend the line bounds to encompass endcaps 160 start.xyz += - worldDir * linewidth * 0.5; 161 end.xyz += worldDir * linewidth * 0.5; 162 163 // shift the position of the quad so it hugs the forward edge of the line 164 offset.xy -= dir * forwardOffset; 165 offset.z += 0.5; 166 167 #endif 168 169 // endcaps 170 if ( position.y > 1.0 || position.y < 0.0 ) { 171 172 offset.xy += dir * 2.0 * forwardOffset; 173 174 } 175 176 // adjust for linewidth 177 offset *= linewidth * 0.5; 178 179 // set the world position 180 worldPos = ( position.y < 0.5 ) ? start : end; 181 worldPos.xyz += offset; 182 183 // project the worldpos 184 vec4 clip = projectionMatrix * worldPos; 185 186 // shift the depth of the projected points so the line 187 // segments overlap neatly 188 vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd; 189 clip.z = clipPose.z * clip.w; 190 191 #else 192 193 vec2 offset = vec2( dir.y, - dir.x ); 194 // undo aspect ratio adjustment 195 dir.x /= aspect; 196 offset.x /= aspect; 197 198 // sign flip 199 if ( position.x < 0.0 ) offset *= - 1.0; 200 201 // endcaps 202 if ( position.y < 0.0 ) { 203 204 offset += - dir; 205 206 } else if ( position.y > 1.0 ) { 207 208 offset += dir; 209 210 } 211 212 // adjust for linewidth 213 offset *= linewidth; 214 215 // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ... 216 offset /= resolution.y; 217 218 // select end 219 vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd; 220 221 // back to clip space 222 offset *= clip.w; 223 224 clip.xy += offset; 225 226 #endif 227 228 gl_Position = clip; 229 230 vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation 231 232 #include <logdepthbuf_vertex> 233 #include <clipping_planes_vertex> 234 #include <fog_vertex> 235 236 } 237 `,fragmentShader:` 238 uniform vec3 diffuse; 239 uniform float opacity; 240 uniform float linewidth; 241 242 #ifdef USE_DASH 243 244 uniform float dashOffset; 245 uniform float dashSize; 246 uniform float gapSize; 247 248 #endif 249 250 varying float vLineDistance; 251 252 #ifdef WORLD_UNITS 253 254 varying vec4 worldPos; 255 varying vec3 worldStart; 256 varying vec3 worldEnd; 257 258 #ifdef USE_DASH 259 260 varying vec2 vUv; 261 262 #endif 263 264 #else 265 266 varying vec2 vUv; 267 268 #endif 269 270 #include <common> 271 #include <fog_pars_fragment> 272 #include <logdepthbuf_pars_fragment> 273 #include <clipping_planes_pars_fragment> 274 275 #ifdef USE_COLOR 276 #ifdef USE_LINE_COLOR_ALPHA 277 varying vec4 vLineColor; 278 #else 279 varying vec3 vLineColor; 280 #endif 281 #endif 282 283 vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) { 284 285 float mua; 286 float mub; 287 288 vec3 p13 = p1 - p3; 289 vec3 p43 = p4 - p3; 290 291 vec3 p21 = p2 - p1; 292 293 float d1343 = dot( p13, p43 ); 294 float d4321 = dot( p43, p21 );
295 float d1321 = dot( p13, p21 ); 296 float d4343 = dot( p43, p43 ); 297 float d2121 = dot( p21, p21 ); 298 299 float denom = d2121 * d4343 - d4321 * d4321; 300 301 float numer = d1343 * d4321 - d1321 * d4343; 302 303 mua = numer / denom; 304 mua = clamp( mua, 0.0, 1.0 ); 305 mub = ( d1343 + d4321 * ( mua ) ) / d4343; 306 mub = clamp( mub, 0.0, 1.0 ); 307 308 return vec2( mua, mub ); 309 310 } 311 312 void main() { 313 314 #include <clipping_planes_fragment> 315 316 #ifdef USE_DASH 317 318 if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps 319 320 if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX 321 322 #endif 323 324 float alpha = opacity; 325 326 #ifdef WORLD_UNITS 327 328 // Find the closest points on the view ray and the line segment 329 vec3 rayEnd = normalize( worldPos.xyz ) * 1e5; 330 vec3 lineDir = worldEnd - worldStart; 331 vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd ); 332 333 vec3 p1 = worldStart + lineDir * params.x; 334 vec3 p2 = rayEnd * params.y; 335 vec3 delta = p1 - p2; 336 float len = length( delta ); 337 float norm = len / linewidth; 338 339 #ifndef USE_DASH 340 341 #ifdef USE_ALPHA_TO_COVERAGE 342 343 float dnorm = fwidth( norm ); 344 alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm ); 345 346 #else 347 348 if ( norm > 0.5 ) { 349 350 discard; 351 352 } 353 354 #endif 355 356 #endif 357 358 #else 359 360 #ifdef USE_ALPHA_TO_COVERAGE 361 362 // artifacts appear on some hardware if a derivative is taken within a conditional 363 float a = vUv.x; 364 float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; 365 float len2 = a * a + b * b; 366 float dlen = fwidth( len2 ); 367 368 if ( abs( vUv.y ) > 1.0 ) { 369 370 alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 ); 371 372 } 373 374 #else 375 376 if ( abs( vUv.y ) > 1.0 ) { 377 378 float a = vUv.x; 379 float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; 380 float len2 = a * a + b * b; 381 382 if ( len2 > 1.0 ) discard; 383 384 } 385 386 #endif 387 388 #endif 389 390 vec4 diffuseColor = vec4( diffuse, alpha ); 391 #ifdef USE_COLOR 392 #ifdef USE_LINE_COLOR_ALPHA 393 diffuseColor *= vLineColor; 394 #else 395 diffuseColor.rgb *= vLineColor; 396 #endif 397 #endif 398 399 #include <logdepthbuf_fragment> 400 401 gl_FragColor = diffuseColor; 402 403 #include <tonemapping_fragment> 404 #include <${_e>=154?"colorspace_fragment":"encodings_fragment"}> 405 #include <fog_fragment> 406 #include <premultiplied_alpha_fragment> 407 408 } 409 `,clipping:!0}),this.isLineMaterial=!0,this.onBeforeCompile=function(){this.transparent?this.defines.USE_LINE_COLOR_ALPHA="1":delete this.defines.USE_LINE_COLOR_ALPHA},Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(i){this.uniforms.diffuse.value=i}},worldUnits:{enumerable:!0,get:function(){return"WORLD_UNITS"in this.defines},set:function(i){i===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(i){this.uniforms.linewidth.value=i}},dashed:{enumerable:!0,get:function(){return"USE_DASH"in this.defines},set(i){!!i!="USE_DASH"in this.defines&&(this.needsUpdate=!0),i===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(i){this.uniforms.dashScale.value=i}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(i){this.uniforms.dashSize.value=i}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(i){this.uniforms.dashOffset.value=i}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(i){this.uniforms.gapSize.value=i}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(i){this.uniforms.opacity.value=i}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(i){this.uniforms.resolution.value.copy(i)}},alphaToCoverage:{enumerable:!0,get:function(){return"USE_ALPHA_TO_COVERAGE"in this.defines},set:function(i){!!i!="USE_ALPHA_TO_COVERAGE"in this.defines&&(this.needsUpdate=!0),i===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(t)}}const te=new N,me=new y,xe=new y,j=new N,E=new N,O=new N,ne=new y,se=new Ie,L=new We,ge=new y,J=new ae,X=new Se,R=new N;let P,W;function ye(f,t,i){return R.set(0,0,-t,1).applyMatrix4(f.projectionMatrix),R.multiplyScalar(1/R.w),R.x=W/i.width,R.y=W/i.height,R.applyMatrix4(f.projectionMatrixInverse),R.multiplyScalar(1/R.w),Math.abs(Math.max(R.x,R.y))}function Ke(f,t){const i=f.matrixWorld,e=f.geometry,s=e.attributes.instanceStart,o=e.attributes.instanceEnd,p=Math.min(e.instanceCount,s.count);for(let a=0,x=p;a<x;a++){L.start.fromBufferAttribute(s,a),L.end.fromBufferAttribute(o,a),L.applyMatrix4(i);const c=new y,h=new y;P.distanceSqToSegment(L.start,L.end,h,c),h.distanceTo(c)<W*.5&&t.push({point:h,pointOnLine:c,distance:P.origin.distanceTo(h),object:f,face:null,faceIndex:a,uv:null,[be]:null})}}function Qe(f,t,i){const e=t.projectionMatrix,o=f.material.resolution,p=f.matrixWorld,a=f.geometry,x=a.attributes.instanceStart,c=a.attributes.instanceEnd,h=Math.min(a.instanceCount,x.count),l=-t.near;
409P.at(1,O),O.w=1,O.applyMatrix4(t.matrixWorldInverse),O.applyMatrix4(e),O.multiplyScalar(1/O.w),O.x*=o.x/2,O.y*=o.y/2,O.z=0,ne.copy(O),se.multiplyMatrices(t.matrixWorldInverse,p);for(let v=0,w=h;v<w;v++){if(j.fromBufferAttribute(x,v),E.fromBufferAttribute(c,v),j.w=1,E.w=1,j.applyMatrix4(se),E.applyMatrix4(se),j.z>l&&E.z>l)continue;if(j.z>l){const m=j.z-E.z,S=(j.z-l)/m;j.lerp(E,S)}else if(E.z>l){const m=E.z-j.z,S=(E.z-l)/m;E.lerp(j,S)}j.applyMatrix4(e),E.applyMatrix4(e),j.multiplyScalar(1/j.w),E.multiplyScalar(1/E.w),j.x*=o.x/2,j.y*=o.y/2,E.x*=o.x/2,E.y*=o.y/2,L.start.copy(j),L.start.z=0,L.end.copy(E),L.end.z=0;const M=L.closestPointToPointParameter(ne,!0);L.at(M,ge);const _=Ne.lerp(j.z,E.z,M),U=_>=-1&&_<=1,D=ne.distanceTo(ge)<W*.5;if(U&&D){L.start.fromBufferAttribute(x,v),L.end.fromBufferAttribute(c,v),L.start.applyMatrix4(p),L.end.applyMatrix4(p);const m=new y,S=new y;P.distanceSqToSegment(L.start,L.end,S,m),i.push({point:S,pointOnLine:m,distance:P.origin.distanceTo(S),object:f,face:null,faceIndex:v,uv:null,[be]:null})}}}class Ee extends Ge{constructor(t=new le,i=new ce({color:Math.random()*16777215})){super(t,i),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const t=this.geometry,i=t.attributes.instanceStart,e=t.attributes.instanceEnd,s=new Float32Array(2*i.count);for(let p=0,a=0,x=i.count;p<x;p++,a+=2)me.fromBufferAttribute(i,p),xe.fromBufferAttribute(e,p),s[a]=a===0?0:s[a-1],s[a+1]=s[a]+me.distanceTo(xe);const o=new oe(s,2,1);return t.setAttribute("instanceDistanceStart",new I(o,1,0)),t.setAttribute("instanceDistanceEnd",new I(o,1,1)),this}raycast(t,i){const e=this.material.worldUnits,s=t.camera;s===null&&!e&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const o=t.params.Line2!==void 0&&t.params.Line2.threshold||0;P=t.ray;const p=this.matrixWorld,a=this.geometry,x=this.material;W=x.linewidth+o,a.boundingSphere===null&&a.computeBoundingSphere(),X.copy(a.boundingSphere).applyMatrix4(p);let c;if(e)c=W*.5;else{const l=Math.max(s.near,X.distanceToPoint(P.origin));c=ye(s,l,x.resolution)}if(X.radius+=c,P.intersectsSphere(X)===!1)return;a.boundingBox===null&&a.computeBoundingBox(),J.copy(a.boundingBox).applyMatrix4(p);let h;if(e)h=W*.5;else{const l=Math.max(s.near,J.distanceToPoint(P.origin));h=ye(s,l,x.resolution)}J.expandByScalar(h),P.intersectsBox(J)!==!1&&(e?Ke(this,i):Qe(this,s,i))}onBeforeRender(t){const i=this.material.uniforms;i&&i.resolution&&(t.getViewport(te),this.material.uniforms.resolution.value.set(te.z,te.w))}}class Ze extends Ee{constructor(t=new je,i=new ce({color:Math.random()*16777215})){super(t,i),this.isLine2=!0,this.type="Line2"}}const et=u.forwardRef(function({points:t,color:i=16777215,vertexColors:e,linewidth:s,lineWidth:o,segments:p,dashed:a,...x},c){var h,l;const v=re(U=>U.size),w=u.useMemo(()=>p?new Ee:new Ze,[p]),[b]=u.useState(()=>new ce),M=(e==null||(h=e[0])==null?void 0:h.length)===4?4:3,_=u.useMemo(()=>{const U=p?new le:new je,D=t.map(m=>{const S=Array.isArray(m);return m instanceof y||m instanceof N?[m.x,m.y,m.z]:m instanceof $?[m.x,m.y,0]:S&&m.length===3?[m[0],m[1],m[2]]:S&&m.length===2?[m[0],m[1],0]:m});if(U.setPositions(D.flat()),e){i=16777215;const m=e.map(S=>S instanceof we?S.toArray():S);U.setColors(m.flat(),M)}return U},[t,p,e,M]);return u.useLayoutEffect(()=>{w.computeLineDistances()},[t,w]),u.useLayoutEffect(()=>{a?b.defines.USE_DASH="":delete b.defines.USE_DASH,b.needsUpdate=!0},[a,b]),u.useEffect(()=>()=>{_.dispose(),b.dispose()},[_]),u.createElement("primitive",ie({object:w,ref:c},x),u.createElement("primitive",{object:_,attach:"geometry"}),u.createElement("primitive",ie({object:b,attach:"material",color:i,vertexColors:!!e,resolution:[v.width,v.height],linewidth:(l=s??o)!==null&&l!==void 0?l:1,dashed:a,transparent:M===4},x)))}),Le=u.forwardRef(({threshold:f=15,geometry:t,...i},e)=>{const s=u.useRef(null);u.useImperativeHandle(e,()=>s.current,[]);const o=u.useMemo(()=>[0,0,0,1,0,0],[]),p=u.useRef(),a=u.useRef();return u.useLayoutEffect(()=>{const x=s.current.parent,c=t??(x==null?void 0:x.geometry);if(!c||p.current===c&&a.current===f)return;p.current=c,a.current=f;const l=new Fe(c,f).attributes.position.array;s.current.geometry.setPositions(l),s.current.geometry.attributes.instanceStart.needsUpdate=!0,s.current.geometry.attributes.instanceEnd.needsUpdate=!0,s.current.computeLineDistances()}),u.createElement(et,ie({segments:!0,points:o,ref:s,raycast:()=>null},i))});function tt({position:f,color:t,name:i,isHead:e,onDrag:s,onDragStart:o,onDragEnd:p}){const a=u.useRef(null),[x,c]=u.useState(!1),[h,l]=u.useState(!1),{camera:v,gl:w}=re(),b=u.useRef(new Ve),M=u.useRef(new y),_=e?.1:.04,U=D=>{D.stopPropagation(),l(!0),o(),w.domElement.style.cursor="grabbing";const m=new y;v.getWorldDirection(m),b.current.setFromNormalAndCoplanarPoint(m,f);const S=new y,r=new pe;r.setFromCamera(D.pointer,v),r.ray.intersectPlane(b.current,S),M.current.copy(f).sub(S);const g=z=>{const C=w.domElement.getBoundingClientRect(),B=(z.clientX-C.left)/C.width*2-1,T=-((z.clientY-C.top)/C.height)*2+1,G=new $(B,T),F=new pe;F.setFromCamera(G,v);const V=new y;F.ray.intersectPlane(b.current,V),V&&s(V.add(M.current))},d=()=>{l(!1),p(),w.domElement.style.cursor="auto",window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",d)};window.addEventListener("pointermove",g),window.addEventListener("pointerup",d)};return n.jsxs("mesh",{ref:a,position:f,onPointerDown:U,onPointerOver:()=>{c(!0),w.domElement.style.cursor="grab"},onPointerOut:()=>{h||(c(!1),w.domElement.style.cursor="auto")},children:[e?n.jsx("sphereGeometry",{args:[_,16,16]}):n.jsx("sphereGeometry",{args:[_,12,12]}
409),n.jsx("meshStandardMaterial",{color:x||h?"#ffffff":t,emissive:x||h?t:"#000000",emissiveIntensity:x||h?.5:0,roughness:.3,metalness:.1}),x&&!h&&n.jsx("sprite",{position:[0,_+.06,0],scale:[.3,.08,1],children:n.jsx("spriteMaterial",{transparent:!0,opacity:.9,color:"#000"})})]})}const nt={head:"Head",neck:"Neck",spine:"Chest",hips:"Hips",l_shoulder:"L Shoulder",l_elbow:"L Elbow",l_wrist:"L Wrist",r_shoulder:"R Shoulder",r_elbow:"R Elbow",r_wrist:"R Wrist",l_hip:"L Hip",l_knee:"L Knee",l_ankle:"L Ankle",r_hip:"R Hip",r_knee:"R Knee",r_ankle:"R Ankle"},st={standing:"Standing",hands_on_hips:"Hands on Hips",walking:"Walking",running:"Running",fashion_pose:"Fashion Pose",crossed_legs_stand:"Crossed Legs",hand_on_hip_one:"One Hand on Hip",arms_crossed:"Arms Crossed",waving:"Waving",hands_up:"Hands Up",hands_on_head:"Hands on Head",peace_sign:"Peace Sign",sitting:"Sitting",squat:"Squat",lunge:"Lunge",stretching:"Stretching",yoga_tree:"Yoga Tree Pose",kick:"Kick",bowing:"Bowing",looking_back:"Looking Back"},it={daily:"Daily",fashion:"Fashion",gesture:"Gesture",sit_squat:"Sit & Squat",sport:"Sport",art:"Art"};function ot({onReady:f}){const{gl:t,scene:i,camera:e}=re();return f(t,i,e),null}const Me="#6b7280",Ae="#a5b4fc";function A({from:f,to:t,radius:i,wireframe:e=!1,wireframeColor:s}){const o=f.distanceTo(t);if(o<.001)return null;const p=new y().addVectors(f,t).multiplyScalar(.5),a=new y().subVectors(t,f).normalize(),x=new Je().setFromUnitVectors(new y(0,1,0),a),c=s??Ae;return n.jsxs("mesh",{position:p,quaternion:x,children:[n.jsx("cylinderGeometry",{args:[i,i,o,e?8:16]}),e?n.jsxs(n.Fragment,{children:[n.jsx("meshBasicMaterial",{transparent:!0,opacity:0,depthWrite:!1}),n.jsx(Le,{color:c,threshold:15})]}):n.jsx("meshStandardMaterial",{color:Me,opacity:1})]})}function ve({jointPositions:f,wireframe:t=!1,wireframeColor:i}){const e=f,s=i??Ae,o=t?s:Me,p=t?s:"#f3f4f6",a=t?s:"#374151",x=t?s:"#1f2937",c={color:o,opacity:1,roughness:.72,metalness:.05},h=({color:_}={})=>t?n.jsxs(n.Fragment,{children:[n.jsx("meshBasicMaterial",{transparent:!0,opacity:0,depthWrite:!1}),n.jsx(Le,{color:_??s,threshold:15})]}):n.jsx("meshStandardMaterial",{...c,color:_??o}),l=t?{sphereW:14,sphereH:10,cyl:10}:{sphereW:20,sphereH:16,cyl:16},v=e.neck&&e.hips?new y().addVectors(e.neck,e.hips).multiplyScalar(.5):null,w=_=>_?new y(_.x,_.y-.015,_.z+.045):null,b=w(e.l_ankle),M=w(e.r_ankle);return n.jsxs(n.Fragment,{children:[e.head&&n.jsxs("mesh",{position:e.head,scale:[.94,1.08,1.14],children:[t?n.jsx("icosahedronGeometry",{args:[.11,1]}):n.jsx("sphereGeometry",{args:[.1,32,28]}),n.jsx(h,{})]}),e.head&&n.jsxs("mesh",{position:[e.head.x-.098,e.head.y+.005,e.head.z],rotation:[0,0,Math.PI/2],children:[n.jsx("cylinderGeometry",{args:[.025,.028,.015,l.cyl]}),n.jsx(h,{})]}),e.head&&n.jsxs("mesh",{position:[e.head.x+.098,e.head.y+.005,e.head.z],rotation:[0,0,Math.PI/2],children:[n.jsx("cylinderGeometry",{args:[.025,.028,.015,l.cyl]}),n.jsx(h,{})]}),e.head&&n.jsxs("mesh",{position:[e.head.x,e.head.y,e.head.z+.112],scale:[.9,1,1],children:[n.jsx("circleGeometry",{args:[.078,t?20:40]}),n.jsx(h,{color:p})]}),e.head&&n.jsxs("mesh",{position:[e.head.x-.03,e.head.y+.015,e.head.z+.115],children:[n.jsx("sphereGeometry",{args:[.01,8,8]}),n.jsx(h,{color:x})]}),e.head&&n.jsxs("mesh",{position:[e.head.x+.03,e.head.y+.015,e.head.z+.115],children:[n.jsx("sphereGeometry",{args:[.01,8,8]}),n.jsx(h,{color:x})]}),e.head&&n.jsxs("mesh",{position:[e.head.x,e.head.y-.005,e.head.z+.128],rotation:[Math.PI/2,0,0],children:[n.jsx("coneGeometry",{args:[.022,.055,t?8:16]}),n.jsx(h,{color:a})]}),e.head&&n.jsxs("mesh",{position:[e.head.x,e.head.y-.055,e.head.z+.094],children:[n.jsx("boxGeometry",{args:[.06,.014,.008]}),n.jsx(h,{color:a})]}),e.head&&e.neck&&n.jsx(A,{from:e.neck,to:e.head,radius:.048,wireframe:t,wireframeColor:s}),e.neck&&v&&n.jsx(A,{from:e.neck,to:v,radius:.145,wireframe:t,wireframeColor:s}),v&&e.hips&&n.jsx(A,{from:v,to:e.hips,radius:.12,wireframe:t,wireframeColor:s}),!t&&e.l_shoulder&&n.jsxs("mesh",{position:e.l_shoulder,children:[n.jsx("sphereGeometry",{args:[.07,l.sphereW,l.sphereH]}),n.jsx("meshStandardMaterial",{...c})]}),!t&&e.r_shoulder&&n.jsxs("mesh",{position:e.r_shoulder,children:[n.jsx("sphereGeometry",{args:[.07,l.sphereW,l.sphereH]}),n.jsx("meshStandardMaterial",{...c})]}),e.neck&&e.l_shoulder&&n.jsx(A,{from:e.neck,to:e.l_shoulder,radius:.055,wireframe:t,
409wireframeColor:s}),e.neck&&e.r_shoulder&&n.jsx(A,{from:e.neck,to:e.r_shoulder,radius:.055,wireframe:t,wireframeColor:s}),e.l_shoulder&&e.l_elbow&&n.jsx(A,{from:e.l_shoulder,to:e.l_elbow,radius:.052,wireframe:t,wireframeColor:s}),e.l_elbow&&e.l_wrist&&n.jsx(A,{from:e.l_elbow,to:e.l_wrist,radius:.045,wireframe:t,wireframeColor:s}),e.r_shoulder&&e.r_elbow&&n.jsx(A,{from:e.r_shoulder,to:e.r_elbow,radius:.052,wireframe:t,wireframeColor:s}),e.r_elbow&&e.r_wrist&&n.jsx(A,{from:e.r_elbow,to:e.r_wrist,radius:.045,wireframe:t,wireframeColor:s}),!t&&e.l_elbow&&n.jsxs("mesh",{position:e.l_elbow,children:[n.jsx("sphereGeometry",{args:[.048,l.sphereW,l.sphereH]}),n.jsx("meshStandardMaterial",{...c})]}),!t&&e.r_elbow&&n.jsxs("mesh",{position:e.r_elbow,children:[n.jsx("sphereGeometry",{args:[.048,l.sphereW,l.sphereH]}),n.jsx("meshStandardMaterial",{...c})]}),!t&&e.l_wrist&&n.jsxs("mesh",{position:e.l_wrist,scale:[.9,1.2,.55],children:[n.jsx("sphereGeometry",{args:[.045,l.sphereW,l.sphereH]}),n.jsx("meshStandardMaterial",{...c})]}),!t&&e.r_wrist&&n.jsxs("mesh",{position:e.r_wrist,scale:[.9,1.2,.55],children:[n.jsx("sphereGeometry",{args:[.045,l.sphereW,l.sphereH]}),n.jsx("meshStandardMaterial",{...c})]}),e.hips&&e.l_hip&&n.jsx(A,{from:e.hips,to:e.l_hip,radius:.08,wireframe:t,wireframeColor:s}),e.hips&&e.r_hip&&n.jsx(A,{from:e.hips,to:e.r_hip,radius:.08,wireframe:t,wireframeColor:s}),e.l_hip&&e.l_knee&&n.jsx(A,{from:e.l_hip,to:e.l_knee,radius:.072,wireframe:t,wireframeColor:s}),e.l_knee&&e.l_ankle&&n.jsx(A,{from:e.l_knee,to:e.l_ankle,radius:.06,wireframe:t,wireframeColor:s}),e.r_hip&&e.r_knee&&n.jsx(A,{from:e.r_hip,to:e.r_knee,radius:.072,wireframe:t,wireframeColor:s}),e.r_knee&&e.r_ankle&&n.jsx(A,{from:e.r_knee,to:e.r_ankle,radius:.06,wireframe:t,wireframeColor:s}),!t&&e.l_knee&&n.jsxs("mesh",{position:e.l_knee,children:[n.jsx("sphereGeometry",{args:[.056,l.sphereW,l.sphereH]}),n.jsx("meshStandardMaterial",{...c})]}),!t&&e.r_knee&&n.jsxs("mesh",{position:e.r_knee,children:[n.jsx("sphereGeometry",{args:[.056,l.sphereW,l.sphereH]}),n.jsx("meshStandardMaterial",{...c})]}),!t&&b&&n.jsxs("mesh",{position:b,children:[n.jsx("boxGeometry",{args:[.07,.035,.15]}),n.jsx("meshStandardMaterial",{...c})]}),!t&&M&&n.jsxs("mesh",{position:M,children:[n.jsx("boxGeometry",{args:[.07,.035,.15]}),n.jsx("meshStandardMaterial",{...c})]})]})}const Bt=u.forwardRef(function({width:t=400,height:i=500,onPoseChange:e},s){const{t:o}=Pe(),{joints:p}=Xe(),[a,x]=u.useState(()=>{const r={};for(const g of p)r[g.id]=g.position.clone();return r}),[c,h]=u.useState(!1),[l,v]=u.useState("standing"),w=u.useRef(null),b=u.useRef(null),M=u.useRef(null),_=u.useRef(null),U=u.useRef(null),D=u.useCallback((r,g,d)=>{w.current=r,b.current=g,M.current=d},[]),m=u.useCallback((r,g)=>{x(d=>{const z={...d,[r]:g.clone()};if(e){const C={};for(const[B,T]of Object.entries(z))C[B]=[T.x,T.y,T.z];e(C)}return z})},[e]),S=u.useCallback(r=>{v(r.id),x(()=>{const g={};for(const[d,[z,C,B]]of Object.entries(r.positions))g[d]=new y(z,C,B);return e&&e(r.positions),g})},[e]);return u.useImperativeHandle(s,()=>({exportImage:async()=>{const r=w.current,g=b.current,d=M.current;if(!r||!g||!d)return"";const z=_.current,C=U.current;z&&(z.visible=!1),C&&(C.visible=!0);const B=new we;r.getClearColor(B);const T=r.getClearAlpha();r.setClearColor("#000000",1);const G=new $;r.getSize(G);const F=1280,V=Math.round(F*(G.y/Math.max(G.x,1)));r.setSize(F,V,!1);let Y=1/0,K=-1/0,Q=1/0,Z=-1/0;for(const H of Object.values(a))H.y<Y&&(Y=H.y),H.y>K&&(K=H.y),H.x<Q&&(Q=H.x),H.x>Z&&(Z=H.x);const k=new y(0,.9,0),Ce=Math.max(Math.abs(Y-k.y),Math.abs(K-k.y),Math.abs(Q-k.x),Math.abs(Z-k.x))+.12,Ue=(d.fov??45)*Math.PI/180,ze=Ce/Math.tan(Ue/2)*1.15,Oe=d.position.clone(),ee=new y().subVectors(d.position,k).normalize();ee.lengthSq()<1e-4&&ee.set(0,0,1),d.position.copy(k).add(ee.multiplyScalar(ze)),d.lookAt(k),d.updateMatrixWorld(),r.render(g,d);const Re=r.domElement.toDataURL("image/png");return d.position.copy(Oe),d.lookAt(k),d.updateMatrixWorld(),z&&(z.visible=!0),C&&(C.visible=!1),r.setClearColor(B,T),r.setSize(G.x,G.y,!1),r.render(g,d),Re},getJointPositions:()=>{const r={};for(const[g,d]of Object.entries(a))r[g]=[d.x,d.y,d.z];return r}}),[a]),n.jsxs("div",{className:"space-y-3",children:[n.jsx("div",{className:"space-y-1.5 max-h-[160px] overflow-y-auto pr-1",children:$e.map(r=>{const g=Ye.filter(d=>d.group===r);return g.length===0?null:n.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[n.jsx("span",{className:"text-[10px] text-[var(--text-tertiary)] w-10 shrink-0 tracking-wide",children:o(`poseEditor.group.${r}`,it[r]??r)}),g.map(d=>n.jsx("button",{onClick:()=>S(d),className:`px-2.5 py-1 rounded-md text-[11px] font-medium transition-all cursor-pointer ${l===d.id?"bg-ui-accent text-white":"border border-ui-border text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)]"}`,children:o(`poseEditor.pose.${d.id}`,st[d.id]??d.name)},d.id))]},r)})}),n.jsx("div",{className:"rounded-xl border border-ui-border overflow-hidden",style:{width:t,height:i,background:"linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%)"},children:n.jsxs(De,{camera:{position:[0,1,2.5],fov:45},gl:{preserveDrawingBuffer:!0,antialias:!0},onCreated:({gl:r})=>{r.toneMapping=qe},children:[n.jsx(ot,{onReady:D}),n.jsx("ambientLight",{intensity:.6}),n.jsx("directionalLight",{position:[2,3,2],intensity:.8}),n.jsx("directionalLight",{position:[-2,2,-1],intensity:.3}),n.jsxs("group",{ref:_,children:[n.jsx("gridHelper",{args:[4,20,"#475569","#334155"]}),n.jsx(ve,{jointPositions:a,wireframe:!0}),p.map(r=>{const g=a[r.id];return g?n.jsx(tt,{position:g,color:r.color,name:o(`poseEditor.joint.${r.id}`,nt[r.id]??r.name),isHead:r.id==="head",onDrag:d=>m(r.id,d),onDragStart:()=>h(!0),onDragEnd:()=>h(!1)},r.id):null})]}
409),n.jsxs("group",{ref:U,visible:!1,children:[n.jsx("gridHelper",{args:[8,32,"#ffffff","#888888"],position:[0,0,0]}),n.jsx("axesHelper",{args:[1.2]}),n.jsx(ve,{jointPositions:a,wireframe:!0,wireframeColor:"#ffffff"})]}),n.jsx(Be,{enabled:!c,enablePan:!1,minDistance:1.5,maxDistance:5,target:[0,.9,0]})]})}),n.jsx("p",{className:"text-[11px] text-[var(--text-tertiary)]",children:o("poseEditor.hint3d","Drag joints to pose · Scroll to zoom · Right-drag to rotate · Exports a gray mannequin silhouette")})]})});export{Bt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.