1import{L as B,F as I,$ as R,h as u,Q as N,a1 as x,a6 as L,a8 as g,a0 as k}from"./index-wvLkuzxO.js";class A extends B{constructor(c){super(c),this.animateBonePositions=!0,this.animateBoneRotations=!0}load(c,H,d,f){const l=this,h=new I(l.manager);h.setPath(l.path),h.setRequestHeader(l.requestHeader),h.setWithCredentials(l.withCredentials),h.load(c,function(p){try{H(l.parse(p))}catch(m){f?f(m):console.error(m),l.manager.itemError(c)}},d,f)}parse(c){function H(t){p(t)!=="HIERARCHY"&&console.error("THREE.BVHLoader: HIERARCHY expected.");const s=[],n=f(t,p(t),s);p(t)!=="MOTION"&&console.error("THREE.BVHLoader: MOTION expected.");let e=p(t).split(/[\s]+/);const o=parseInt(e[1]);isNaN(o)&&console.error("THREE.BVHLoader: Failed to read number of frames."),e=p(t).split(/[\s]+/);const i=parseFloat(e[2]);isNaN(i)&&console.error("THREE.BVHLoader: Failed to read frame time.");for(let r=0;r<o;r++)e=p(t).split(/[\s]+/),d(e,r*i,n);return s}function d(t,s,n){if(n.type==="ENDSITE")return;const e={time:s,position:new u,rotation:new N};n.frames.push(e);const o=new N,i=new u(1,0,0),r=new u(0,1,0),E=new u(0,0,1);for(let a=0;a<n.channels.length;a++)switch(n.channels[a]){case"Xposition":e.position.x=parseFloat(t.shift().trim());break;case"Yposition":e.position.y=parseFloat(t.shift().trim());break;case"Zposition":e.position.z=parseFloat(t.shift().trim());break;case"Xrotation":o.setFromAxisAngle(i,parseFloat(t.shift().trim())*Math.PI/180),e.rotation.multiply(o);break;case"Yrotation":o.setFromAxisAngle(r,parseFloat(t.shift().trim())*Math.PI/180),e.rotation.multiply(o);break;case"Zrotation":o.setFromAxisAngle(E,parseFloat(t.shift().trim())*Math.PI/180),e.rotation.multiply(o);break;default:console.warn("THREE.BVHLoader: Invalid channel type.")}for(let a=0;a<n.children.length;a++)d(t,s,n.children[a])}function f(t,s,n){const e={name:"",type:"",frames:[]};n.push(e);let o=s.split(/[\s]+/);o[0].toUpperCase()==="END"&&o[1].toUpperCase()==="SITE"?(e.type="ENDSITE",e.name="ENDSITE"):(e.name=o[1],e.type=o[0].toUpperCase()),p(t)!=="{"&&console.error("THREE.BVHLoader: Expected opening { after type & name"),o=p(t).split(/[\s]+/),o[0]!=="OFFSET"&&console.error("THREE.BVHLoader: Expected OFFSET but got: "+o[0]),o.length!==4&&console.error("THREE.BVHLoader: Invalid number of values for OFFSET.");const i=new u(parseFloat(o[1]),parseFloat(o[2]),parseFloat(o[3]));if((isNaN(i.x)||isNaN(i.y)||isNaN(i.z))&&console.error("THREE.BVHLoader: Invalid values of OFFSET."),e.offset=i,e.type!=="ENDSITE"){o=p(t).split(/[\s]+/),o[0]!=="CHANNELS"&&console.error("THREE.BVHLoader: Expected CHANNELS definition.");const r=parseInt(o[1]);e.channels=o.splice(2,r),e.children=[]}for(;;){const r=p(t);if(r==="}")return e;e.children.push(f(t,r,n))}}function l(t,s){const n=new x;if(s.push(n),n.position.add(t.offset),n.name=t.name,t.type!=="ENDSITE")for(let e=0;e<t.children.length;e++)n.add(l(t.children[e],s));return n}function h(t){const s=[];for(let n=0;n<t.length;n++){const e=t[n];if(e.type==="ENDSITE")continue;const o=[],i=[],r=[];for(let E=0;E<e.frames.length;E++){const a=e.frames[E];o.push(a.time),i.push(a.position.x+e.offset.x),i.push(a.position.y+e.offset.y),i.push(a.position.z+e.offset.z),r.push(a.rotation.x),r.push(a.rotation.y),r.push(a.rotation.z),r.push(a.rotation.w)}m.animateBonePositions&&s.push(new L(e.name+".position",o,i)),m.animateBoneRotations&&s.push(new g(e.name+".quaternion",o,r))}return new k("animation",-1,s)}function p(t){let s;for(;(s=t.shift().trim()).length===0;);return s}const m=this,y=c.split(/[\r\n]+/g),F=H(y),T=[];l(F[0],T);const w=h(F);return{skeleton:new R(T),clip:w}}}export{A as BVHLoader};
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.