PageSourceSearch

https://scaniverse.nianticspatial.com/_next/static/chunks/3881.0acd6707de28a9c3.js

js nianticspatial.com collected 2026-10-09 22:39:42 UTC 67,265 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3881],{93881:(e,t,r)=>{r.d(t,{USDLoader:()=>S});var i=r(85339),s=r(90315);let l=/^def\s+(?:(\w+)\s+)?"?([^"]+)"?$/,a=/^string\s+(\w+)$/,n=/^(?:uniform\s+)?(\w+(?:\[\])?)\s+(.+)$/,o=Symbol("valueMetadata"),h={Attribute:1,Prim:6,Relationship:8};class f{parseText(e){e=this._preprocess(e);let t={},r=e.split("\n"),i=null,s=t,l=[t];for(let e of r)if(e.includes("=")){let t=this._findAssignmentOperator(e);if(-1===t){i=e.trim();continue}let r=e.slice(0,t).trim(),a=e.slice(t+1).trim();if(a.endsWith("{")){let e={};l.push(e),s[r]=e,s=e}else if(a.endsWith("(")){let e=a.slice(0,-1).trim();s[r]=e;let t={};void 0===s[o]&&(s[o]={}),s[o][r]=t,l.push(t),s=t}else s[r]=a}else if(e.includes(":")&&!e.includes("=")){let t=e.indexOf(":"),r=e.slice(0,t).trim(),i=e.slice(t+1).trim();/^[\d.]+$/.test(r)&&(s[r]=i)}else if(e.endsWith("{")){let t=s[i=e.slice(0,-1).trim()||i]||{};l.push(t),s[i]=t,s=t}else if(e.endsWith("}")){if(l.pop(),0===l.length)continue;s=l[l.length-1]}else if(e.endsWith("(")){let t={};l.push(t),s[i=e.split("(")[0].trim()||i]=t,s=t}else e.endsWith(")")?(l.pop(),s=l[l.length-1]):e.trim()&&(i=e.trim());return t}_preprocess(e){e=this._stripBlockComments(e);let t=(e=this._collapseTripleQuotedStrings(e)).split("\n"),r=[],i=!1,s=0,l=0,a="";for(let e=0;e<t.length;e++){let n=t[e],o=(n=this._stripInlineComment(n)).trim();if(i){for(let e of(a+=" "+o,o))"["===e?s++:"]"===e?s--:"("===e&&s>0?l++:")"===e&&s>0&&l--;0===s&&0===l&&(r.push(a),a="",i=!1)}else{if(o.includes("=")){let e=this._findAssignmentOperator(o);if(-1!==e){let t=o.slice(e+1).trim(),r=0,n=0;for(let e of t)"["===e?r++:"]"===e&&n++;if(r>n){i=!0,s=r-n,l=0,a=o;continue}}}r.push(o)}}return r.join("\n")}_stripBlockComments(e){let t="",r=0;for(;r<e.length;)if("/"===e[r]&&r+1<e.length&&"*"===e[r+1]){let t=r+2;for(;t<e.length;){if("*"===e[t]&&t+1<e.length&&"/"===e[t+1]){t+=2;break}t++}r=t}else t+=e[r],r++;return t}_collapseTripleQuotedStrings(e){let t="",r=0;for(;r<e.length;){if(r+2<e.length){let i=e.slice(r,r+3);if("'''"===i||'"""'===i){for(t+=i,r+=3;r<e.length;)if(r+2<e.length&&e.slice(r,r+3)===i){t+=i,r+=3;break}else"\n"===e[r]?t+="\\n":"\r"!==e[r]&&(t+=e[r]),r++;continue}}t+=e[r],r++}return t}_stripInlineComment(e){if(e.trim().startsWith("#usda"))return e;let t=!1,r=null,i=!1;for(let s=0;s<e.length;s++){let l=e[s];if(i){i=!1;continue}if("\\"===l){i=!0;continue}if(t||'"'!==l&&"'"!==l){if(t&&l===r)t=!1,r=null;else if(!t&&"#"===l)return e.slice(0,s).trimEnd()}else t=!0,r=l}return e}_findAssignmentOperator(e){let t=!1,r=null,i=!1;for(let s=0;s<e.length;s++){let l=e[s];if(i){i=!1;continue}if("\\"===l){i=!0;continue}if(t||'"'!==l&&"'"!==l){if(t&&l===r)t=!1,r=null;else if(!t&&"="===l)return s}else t=!0,r=l}return -1}parseData(e){let t=this.parseText(e),r={},i={};if("#usda 1.0"in t){let e=t["#usda 1.0"];e.upAxis&&(i.upAxis=e.upAxis.replace(/"/g,"")),e.defaultPrim&&(i.defaultPrim=e.defaultPrim.replace(/"/g,"")),void 0!==e.metersPerUnit&&(i.metersPerUnit=parseFloat(e.metersPerUnit)),void 0!==e.framesPerSecond&&(i.framesPerSecond=parseFloat(e.framesPerSecond)),void 0!==e.timeCodesPerSecond&&(i.timeCodesPerSecond=parseFloat(e.timeCodesPerSecond))}r["/"]={specType:h.Prim,fields:i};let s=(e,t)=>{let i=[];for(let a in e){if("#usda 1.0"===a||"variants"===a)continue;let n=a.match(l);if(n){let l=n[1]||"",o=n[2],f="/"===t?"/"+o:t+"/"+o;i.push(o);let u={typeName:l},p=e[a];this._extractPrimData(p,f,u,r,h),r[f]={specType:h.Prim,fields:u},s(p,f)}}i.length>0&&r[t]&&(r[t].fields.primChildren=i)};return s(t,"/"),this._inferSkelElementSize(r),{specsByPath:r}}_inferSkelElementSize(e){for(let t in e){let r=e[t];if(r.specType!==h.Prim||"Mesh"!==r.fields.typeName)continue;let i=e[t+".points"];if(!i||!i.fields.default)continue;let s=i.fields.default.length/3;0!==s&&(this._inferElementSize(e[t+".primvars:skel:jointIndices"],s),this._inferElementSize(e[t+".primvars:skel:jointWeights"],s))}}_inferElementSize(e,t){if(!e||void 0!==e.fields.elementSize||!e.fields.default)return;let r=e.fields.default.length;r>0&&r%t==0&&(e.fields.elementSize=r/t)}_extractPrimData(e,t,r,i,s){if(e&&"object"==typeof e)for(let l in e){if(l.startsWith("def "))continue;if("prepend references"===l){r.references=[e[l]];continue}if("payload"===l){r.payload=e[l];continue}if("variants"===l){let t={},i=e[l];for(let e in i){let r=e.match(a);if(r){let s=r[1],l=i[e].replace(/"/g,"");t[s]=l}}Object.keys(t).length>0&&(r.variantSelection=t);continue}if(l.startsWith("rel ")){let r=t+"."+l.slice(4),a=e[l].replace(/[<>]/g,""),n=e[o]?.[l],h={targetPaths:[a]};n?.bindMaterialAs!==void 0&&(h.bindMaterialAs=this._parseString(String(n.bindMaterialAs).trim())),i[r]={specType:s.Relationship,fields:h};continue}if(l.includes("xformOpOrder")){r.xformOpOrder=e[l].replace(/[\[\]]/g,"").split(",").map(e=>e.trim().replace(/"/g,""));continue}let h=l.match(n);if(h){let r=h[1],a=h[2],n=e[l];
1if(a.endsWith(".connect")){let e=t+"."+a.slice(0,-8),l=String(n).trim();l.startsWith("<")&&(l=l.slice(1)),l.endsWith(">")&&(l=l.slice(0,-1)),i[e]||(i[e]={specType:s.Attribute,fields:{typeName:r}}),i[e].fields.connectionPaths=[l];continue}if(a.endsWith(".timeSamples")&&"object"==typeof n){let e=t+"."+a.slice(0,-12),l=[],o=[];for(let e in n){let t=parseFloat(e);isNaN(t)||(l.push(t),o.push(this._parseAttributeValue(r,n[e])))}let h=l.map((e,t)=>({t:e,v:o[t]})).sort((e,t)=>e.t-t.t);i[e]={specType:s.Attribute,fields:{timeSamples:{times:h.map(e=>e.t),values:h.map(e=>e.v)},typeName:r}}}else{let e=this._parseAttributeValue(r,n),l=t+"."+a;i[l]?(i[l].fields.default=e,i[l].fields.typeName=r):i[l]={specType:s.Attribute,fields:{default:e,typeName:r}}}}}}_parseAttributeValue(e,t){if(null==t)return;let r=String(t).trim();if(e.endsWith("[]")){let t;try{let e=r.replace(/\(/g,"[").replace(/\)/g,"]");e.endsWith(",")&&(e=e.slice(0,-1));let i=JSON.parse(e);t=Array.isArray(i)&&Array.isArray(i[0])?i.flat():i}catch(e){t=r.replace(/[\[\]]/g,"").split(",").map(e=>{let t=e.trim(),r=parseFloat(t);return isNaN(r)?t.replace(/"/g,""):r})}if(e.startsWith("quat"))for(let e=0;e<t.length;e+=4){let r=t[e];t[e]=t[e+1],t[e+1]=t[e+2],t[e+2]=t[e+3],t[e+3]=r}return t}if(e.includes("3")||e.includes("2")||e.includes("4"))return r.replace(/[()]/g,"").split(",").map(e=>parseFloat(e.trim()));if(e.startsWith("quat")){let e=r.replace(/[()]/g,"").split(",").map(e=>parseFloat(e.trim()));return[e[1],e[2],e[3],e[0]]}return e.includes("matrix")?r.replace(/[()]/g,"").split(",").map(e=>parseFloat(e.trim())):"float"===e||"double"===e||"int"===e?parseFloat(r):"string"===e||"token"===e?this._parseString(r):"asset"===e?r.replace(/@/g,"").replace(/"/g,""):this._parseString(r)}_parseString(e){(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1));let t="",r=0;for(;r<e.length;)if("\\"===e[r]&&r+1<e.length){let i=e[r+1];switch(i){case"n":t+="\n";break;case"t":t+="	";break;case"r":t+="\r";break;case"\\":t+="\\";break;case'"':t+='"';break;case"'":t+="'";break;default:t+=i}r+=2}else t+=e[r],r++;return t}}let u=new TextDecoder,p=new Float32Array(32);for(let e=0;e<32;e++)p[e]=Math.pow(2,e-15);let d={Invalid:0,Bool:1,UChar:2,Int:3,UInt:4,Int64:5,UInt64:6,Half:7,Float:8,Double:9,String:10,Token:11,AssetPath:12,Matrix2d:13,Matrix3d:14,Matrix4d:15,Quatd:16,Quatf:17,Quath:18,Vec2d:19,Vec2f:20,Vec2h:21,Vec2i:22,Vec3d:23,Vec3f:24,Vec3h:25,Vec3i:26,Vec4d:27,Vec4f:28,Vec4i:30,Dictionary:31,TokenListOp:32,StringListOp:33,PathListOp:34,IntListOp:36,Int64ListOp:37,UIntListOp:38,UInt64ListOp:39,PathVector:40,TokenVector:41,Specifier:42,Permission:43,Variability:44,VariantSelectionMap:45,TimeSamples:46,DoubleVector:48};function c(e,t,r,i,s,l){for(;t<r;){let a=e[t++];if(t>r)break;let n=a>>4;if(15===n){let i;do{if(t>=r)break;n+=i=e[t++]}while(255===i&&t<r)}if(n>0){t+n>r&&(n=r-t);for(let r=0;r<n&&!(s>=l);r++)i[s++]=e[t++]}if(t>=r||t+2>r)break;let o=e[t++]|e[t++]<<8;if(0===o)break;let h=(15&a)+4;if(19===h){let i;do{if(t>=r)break;h+=i=e[t++]}while(255===i&&t<r)}let f=s-o;if(f<0)break;for(let e=0;e<h&&!(s>=l);e++)i[s++]=i[f+e]}return s}function m(e,t){let r=new Uint8Array(t),i=e[0];if(0===i)return c(e,1,e.length,r,0,t),r;{let s=1,l=[];for(let t=0;t<i;t++){let t=(e[s]|e[s+1]<<8|e[s+2]<<16|e[s+3]<<24)>>>0;l.push(t),s+=4}let a=s,n=0;for(let s=0;s<i;s++){let i=l[s],o=Math.min(65536,t-n);c(e,a,a+i,r,n,n+o),a+=i,n+=o}return r}}function g(e,t){return function(e,t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=0,s=r.getInt32(i,!0),l=i+=4,a=i+(2*t+7>>3),n=new Int32Array(t),o=0,h=l,f=a;for(let i=0;i<t;){let l=e[h++];for(let e=0;e<4&&i<t;e++,i++){let t=0;switch(l>>2*e&3){case 0:t=s;break;case 1:t=r.getInt8(f),f+=1;break;case 2:t=r.getInt16(f,!0),f+=2;break;case 3:t=r.getInt32(f,!0),f+=4}o+=t,n[i]=o}}return n}(m(new Uint8Array(e),4*t+(2*t+7>>3)+4),t)}class y{constructor(e){this.buffer=e,this.view=new DataView(e),this.offset=0}seek(e){this.offset=e}tell(){return this.offset}readUint8(){let e=this.view.getUint8(this.offset);return this.offset+=1,e}readInt8(){let e=this.view.getInt8(this.offset);return this.offset+=1,e}readUint16(){let e=this.view.getUint16(this.offset,!0);return this.offset+=2,e}readInt16(){let e=this.view.getInt16(this.offset,!0);return this.offset+=2,e}readUint32(){let e=this.view.getUint32(this.offset,!0);return this.offset+=4,e}readInt32(){let e=this.view.getInt32(this.offset,!0);return this.offset+=4,e}readUint64(){let e=this.view.getUint32(this.offset,!0),t=this.view.getUint32(this.offset+4,!0);return this.offset+=8,0x100000000*t+e}readInt64(){let e=this.view.getUint32(this.offset,!0),t=this.view.getInt32(this.offset+4,!0);return this.offset+=8,0x100000000*t+e}readFloat32(){let e=this.view.getFloat32(this.offset,!0);return this.offset+=4,e}readFloat64(){let e=this.view.getFloat64(this.offset,!0);return this.offset+=8,e}readBytes(e){let t=new Uint8Array(this.buffer,this.offset,e);return this.offset+=e,t}readString(e){let t=this.readBytes(e),r=0;for(;r<e&&0!==t[r];)r++;return u.decode(t.subarray(0,r))}}class _{constructor(e,t){this.lo=e,this.hi=t}get isArray(){return(0x80000000&this.hi)!=0}get isInlined(){return(0x40000000&this.hi)!=0}get isCompressed(){return(0x20000000&this.hi)!=0}get typeEnum(){return this.hi>>16&255}get payload(){return this.lo+(65535&this.hi)*0x100000000}getInlinedValue(){return this.lo}}class b{parseData(e){for(let t of(this.buffer=e instanceof ArrayBuffer?e:e.buffer,this.reader=new y(this.buffer),this.version={major:0,minor:0,patch:0},this._conversionBuffer=new ArrayBuffer(4),this._conversionView=new DataView(this._conversionBuffer),this._readBootstrap(),this._readTOC(),this._readTokens(),this._readStrings(),this._readFields(),this._readFieldSets(),this._readPaths(),this._readSpecs(),this.specsByPath={},this.specs)){let e=this.paths[t.pathIndex];if(!e)continue;let r=this._getFieldsForSpec(t);this.specsByPath[e]={specType:t.specType,fields:r}}return{specsByPath:this.specsByPath}}_readBootstrap(){let e=this.reader;if(e.seek(0),"PXR-USDC"!==e.readString(8))throw Error("THREE.USDCParser: Not a valid USDC file.");this.version.major=e.readUint8(),this.version.minor=e.readUint8(),this.version.patch=e.readUint8(),e.readBytes(5),this.tocOffset=e.readUint64()}_readTOC(){let e=this.reader;e.seek(this.tocOffset);let t=e.readUint64();this.sections={};for(let r=0;r<t;r++){let t=e.readString(16),r=e.readUint64(),i=e.readUint64();this.sections[t]={start:r,size:i}}}_readTokens(){let e=this.sections.TOKENS;if(!e)return;let t=this.reader;t.seek(e.start);let r=t.readUint64();if(this.tokens=[],0===this.version.major&&this.version.minor<4){let e=t.readUint64(),i=t.readBytes(e),s=0;for(let e=0;e<r;e++){let e=s;for(;e<i.length&&0!==i[e];)e++;this.tokens.push(u.decode(i.subarray(s,e))),s=e+1}}else{let e=t.readUint64(),i=t.readUint64(),s=m(t.readBytes(i),e),l=0;for(let e=0;e<r;e++){let e=l;for(;e<s.length&&0!==s[e];)e++;this.tokens.push(u.decode(s.subarray(l,e))),l=e+1}}}_readStrings(){let e=this.sections.STRINGS;if(!e){this.strings=[];return}let t=this.reader;t.seek(e.start);let r=t.readUint64();this.strings=[];for(let e=0;e<r;e++)this.strings.push(t.readUint32())}_readFields(){let e=this.sections.FIELDS;if(!e)return;let t=this.reader;if(t.seek(e.start),this.fields=[],0===this.version.major&&this.version.minor<4){let r=Math.floor(e.size/12);for(let e=0;e<r;e++){let e=t.readUint32(),r=t.readUint32(),i=t.readUint32();this.fields.push({tokenIndex:e,valueRep:new _(r,i)})}}else{let e=t.readUint64(),r=t.readUint64(),i=t.readBytes(r),s=g(i.buffer.slice(i.byteOffset,i.byteOffset+r),e),l=t.readUint64(),a=m(t.readBytes(l),8*e),n=new DataView(a.buffer,a.byteOffset,a.byteLength);for(let t=0;t<e;t++){let e=n.getUint32(8*t,!0),r=n.getUint32(8*t+4,!0);this.fields.push({tokenIndex:s[t],valueRep:new _(e,r)})}}}_readFieldSets(){let e=this.sections.FIELDSETS;if(!e)return;let t=this.reader;if(t.seek(e.start),this.fieldSets=[],0===this.version.major&&this.version.minor<4){let r=Math.floor(e.size/4);for(let e=0;e<r;e++)this.fieldSets.push(t.readUint32())}else{let e=t.readUint64(),r=t.readUint64(),i=t.readBytes(r),s=g(i.buffer.slice(i.byteOffset,i.byteOffset+r),e);for(let t=0;t<e;t++)this.fieldSets.push(s[t])}}_readPaths(){let e=this.sections.PATHS;if(!e)return;let t=this.reader;t.seek(e.start);let r=t.readUint64();if(this.paths=Array(r).fill(""),0===this.version.major&&this.version.minor<4)this._readPathsRecursive("");else{t.readUint64();let e=t.readUint64(),i=t.readBytes(e),s=g(i.buffer.slice(i.byteOffset,i.byteOffset+e),r),l=t.readUint64(),a=t.readBytes(l),n=g(
1a.buffer.slice(a.byteOffset,a.byteOffset+l),r),o=t.readUint64(),h=t.readBytes(o),f=g(h.buffer.slice(h.byteOffset,h.byteOffset+o),r);this._buildPathsFromCompressed(s,n,f)}}_readPathsRecursive(e,t=0){let r,i=this.reader;if(t>1e3)return;let s=i.readUint32(),l=i.readUint32(),a=i.readUint8(),n=(1&a)!=0,o=(2&a)!=0;if(""===e)r="/";else{let t=this.tokens[l]||"";r=(4&a)!=0?e+"."+t:"/"===e?"/"+t:e+"/"+t}if(this.paths[s]=r,n&&o){let s=i.readUint64();this._readPathsRecursive(r,t+1),i.seek(s),this._readPathsRecursive(e,t+1)}else n?this._readPathsRecursive(r,t+1):o&&this._readPathsRecursive(e,t+1)}_buildPathsFromCompressed(e,t,r){let i=(s,l)=>{let a=s;for(;a<e.length;){let s,n=a++,o=e[n],h=t[n],f=r[n];if(""===l)l=s="/";else{let e=this.tokens[Math.abs(h)]||"";s=h<0?l+"."+e:"/"===l?"/"+e:l+"/"+e}this.paths[o]=s;let u=f>0||-1===f,p=f>=0;if(u)p&&i(n+f,l),l=s;else if(p);else break}};i(0,"")}_readSpecs(){let e=this.sections.SPECS;if(!e)return;let t=this.reader;if(t.seek(e.start),this.specs=[],0===this.version.major&&this.version.minor<4){let r=0===this.version.minor&&1===this.version.patch?16:12,i=Math.floor(e.size/r);for(let e=0;e<i;e++){let e=t.readUint32(),i=t.readUint32(),s=t.readUint32();16===r&&t.readUint32(),this.specs.push({pathIndex:e,fieldSetIndex:i,specType:s})}}else{let e=t.readUint64(),r=t.readUint64(),i=t.readBytes(r),s=g(i.buffer.slice(i.byteOffset,i.byteOffset+r),e),l=t.readUint64(),a=t.readBytes(l),n=g(a.buffer.slice(a.byteOffset,a.byteOffset+l),e),o=t.readUint64(),h=t.readBytes(o),f=g(h.buffer.slice(h.byteOffset,h.byteOffset+o),e);for(let t=0;t<e;t++)this.specs.push({pathIndex:s[t],fieldSetIndex:n[t],specType:f[t]})}}_readValue(e){let t,r=e.typeEnum,i=e.isArray,s=e.isInlined;if(r===d.TimeSamples)return this._readTimeSamples(e);if(s)return this._readInlinedValue(e);let l=e.payload;if(0===l&&i)return[];if(l<0||l>=this.buffer.byteLength)throw RangeError("USDCParser: Invalid payload offset "+l+" for type "+r+".");let a=this.reader.tell();return this.reader.seek(l),t=i?this._readArrayValue(e):this._readScalarValue(r),this.reader.seek(a),t}_readInlinedValue(e){let t=e.typeEnum,r=e.getInlinedValue(),i=this._conversionView;switch(t){case d.Bool:return 0!==r;case d.UChar:return 255&r;case d.Int:case d.UInt:return r;case d.Float:case d.Double:return i.setUint32(0,r,!0),i.getFloat32(0,!0);case d.Token:return this.tokens[r]||"";case d.String:return this.tokens[this.strings[r]]||"";case d.AssetPath:return this.tokens[r]||"";case d.Specifier:case d.Permission:case d.Variability:return r;case d.Vec2h:return i.setUint32(0,r,!0),[this._halfToFloat(i.getUint16(0,!0)),this._halfToFloat(i.getUint16(2,!0))];case d.Vec2f:case d.Vec2i:return i.setUint32(0,r,!0),[i.getInt8(0),i.getInt8(1)];case d.Vec3f:case d.Vec3i:return i.setUint32(0,r,!0),[i.getInt8(0),i.getInt8(1),i.getInt8(2)];case d.Vec4f:case d.Vec4i:return i.setUint32(0,r,!0),[i.getInt8(0),i.getInt8(1),i.getInt8(2),i.getInt8(3)];case d.Matrix2d:return i.setUint32(0,r,!0),[i.getInt8(0),0,0,i.getInt8(1)];case d.Matrix3d:{i.setUint32(0,r,!0);let e=i.getInt8(0);return[e,0,0,0,i.getInt8(1),0,0,0,i.getInt8(2)]}case d.Matrix4d:{i.setUint32(0,r,!0);let e=i.getInt8(0),t=i.getInt8(1);return[e,0,0,0,0,t,0,0,0,0,i.getInt8(2),0,0,0,0,i.getInt8(3)]}default:return r}}_readTimeSamples(e){let t=this.reader,r=e.payload,i=t.tell();t.seek(r);let s=t.tell(),l=t.readInt64();t.seek(s+l);let a=new _(t.readUint32(),t.readUint32()),n=this._readValue(a);t.seek(s+l+8);let o=t.tell(),h=t.readInt64();t.seek(o+h);let f=t.readUint64(),u=[];for(let e=0;e<f;e++){let e=t.readUint32(),r=t.readUint32();u.push(new _(e,r))}let p=[];for(let e=0;e<f;e++)p.push(this._readValue(u[e]));return t.seek(i),{times:n instanceof Float64Array?Array.from(n):Array.isArray(n)?n:[n],values:p}}_readScalarValue(e){let t=this.reader;switch(e){case d.Invalid:return null;case d.Bool:return 0!==t.readUint8();case d.UChar:return t.readUint8();case d.Int:return t.readInt32();case d.UInt:return t.readUint32();case d.Int64:return t.readInt64();case d.UInt64:return t.readUint64();case d.Half:return this._readHalf();case d.Float:return t.readFloat32();case d.Double:return t.readFloat64();case d.String:case d.Token:{let e=t.readUint32();return this.tokens[e]||""}case d.AssetPath:{let e=t.readUint32();return this.tokens[e]||""}
1case d.Vec2f:return[t.readFloat32(),t.readFloat32()];case d.Vec2d:return[t.readFloat64(),t.readFloat64()];case d.Vec2i:return[t.readInt32(),t.readInt32()];case d.Vec3f:return[t.readFloat32(),t.readFloat32(),t.readFloat32()];case d.Vec3d:return[t.readFloat64(),t.readFloat64(),t.readFloat64()];case d.Vec3i:return[t.readInt32(),t.readInt32(),t.readInt32()];case d.Vec4f:return[t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32()];case d.Vec4d:return[t.readFloat64(),t.readFloat64(),t.readFloat64(),t.readFloat64()];case d.Quatf:return[t.readFloat32(),t.readFloat32(),t.readFloat32(),t.readFloat32()];case d.Quatd:return[t.readFloat64(),t.readFloat64(),t.readFloat64(),t.readFloat64()];case d.Matrix4d:{let e=[];for(let r=0;r<16;r++)e.push(t.readFloat64());return e}case d.TokenVector:{let e=t.readUint64(),r=[];for(let i=0;i<e;i++){let e=t.readUint32();r.push(this.tokens[e]||"")}return r}case d.PathVector:{let e=t.readUint64(),r=[];for(let i=0;i<e;i++){let e=t.readUint32();r.push(this.paths[e]||"")}return r}case d.DoubleVector:{let e=t.readUint64(),r=new Float64Array(e);for(let i=0;i<e;i++)r[i]=t.readFloat64();return r}case d.Dictionary:{let e=t.readUint64(),r={};for(let i=0;i<e;i++){let e=t.readUint32(),i=this.tokens[e],s=t.position+t.readInt64(),l=t.position;t.position=s;let a=new _(t.readUint64()),n=null;a.isInlined?n=this._readInlinedValue(a):a.isArray?(t.position=a.payload,n=this._readArrayValue(a)):(t.position=a.payload,n=this._readScalarValue(a.typeEnum)),t.position=l,void 0!==i&&null!==n&&(r[i]=n)}return r}case d.TokenListOp:case d.StringListOp:case d.IntListOp:case d.Int64ListOp:case d.UIntListOp:case d.UInt64ListOp:return null;case d.PathListOp:{let e=t.readUint8(),r=()=>{let e=t.readUint64(),r=[];for(let i=0;i<e;i++){let e=t.readUint32();r.push(this.paths[e])}return r},i=null,s=null,l=null,a=null;if((2&e)!=0&&(i=r()),(4&e)!=0&&(s=r()),(32&e)!=0&&(l=r()),(64&e)!=0&&(a=r()),(8&e)!=0&&r(),(16&e)!=0&&r(),l&&l.length>0)return l;if(i&&i.length>0)return i;if(a&&a.length>0)return a;if(s&&s.length>0)return s;return null}case d.VariantSelectionMap:{let e=t.readUint64(),r={};for(let i=0;i<e;i++){let e=t.readUint32(),i=t.readUint32(),s=this.tokens[this.strings[e]],l=this.tokens[this.strings[i]];s&&l&&(r[s]=l)}return r}default:return console.warn("USDCParser: Unsupported scalar type",e),null}}_readArrayValue(e){let t,r=this.reader,i=e.typeEnum,s=e.isCompressed;if(!Number.isSafeInteger(t=0===this.version.major&&this.version.minor<7?r.readUint32():r.readUint64())||t<0)throw RangeError("USDCParser: Invalid array size "+t+" for type "+i+".");if(t>0x7fffffff)throw RangeError("USDCParser: Array size "+t+" exceeds implementation limits.");if(0===t)return[];if(s)return this._readCompressedArray(i,t);switch(i){case d.Int:{let e=new Int32Array(t);for(let i=0;i<t;i++)e[i]=r.readInt32();return e}case d.UInt:{let e=new Uint32Array(t);for(let i=0;i<t;i++)e[i]=r.readUint32();return e}case d.Float:{let e=new Float32Array(t);for(let i=0;i<t;i++)e[i]=r.readFloat32();return e}case d.Double:{let e=new Float64Array(t);for(let i=0;i<t;i++)e[i]=r.readFloat64();return e}
1case d.Vec2f:{let e=new Float32Array(2*t);for(let i=0;i<2*t;i++)e[i]=r.readFloat32();return e}case d.Vec3f:{let e=new Float32Array(3*t);for(let i=0;i<3*t;i++)e[i]=r.readFloat32();return e}case d.Vec4f:{let e=new Float32Array(4*t);for(let i=0;i<4*t;i++)e[i]=r.readFloat32();return e}case d.Vec3h:{let e=new Float32Array(3*t);for(let r=0;r<3*t;r++)e[r]=this._readHalf();return e}case d.Quatf:{let e=new Float32Array(4*t);for(let i=0;i<4*t;i++)e[i]=r.readFloat32();return e}case d.Quath:{let e=new Float32Array(4*t);for(let r=0;r<4*t;r++)e[r]=this._readHalf();return e}case d.Matrix4d:{let e=new Float64Array(16*t);for(let i=0;i<16*t;i++)e[i]=r.readFloat64();return e}case d.Token:{let e=[];for(let i=0;i<t;i++){let t=r.readUint32();e.push(this.tokens[t]||"")}return e}case d.Half:{let e=new Float32Array(t);for(let r=0;r<t;r++)e[r]=this._readHalf();return e}default:return console.warn("USDCParser: Unsupported array type",i),[]}}_readCompressedArray(e,t){let r=this.reader;switch(e){case d.Int:case d.UInt:{let e=r.readUint64(),i=r.readBytes(e);return g(i.buffer.slice(i.byteOffset,i.byteOffset+e),t)}case d.Float:{let e=r.readInt8();if(105===e){let e=r.readUint64(),i=r.readBytes(e),s=g(i.buffer.slice(i.byteOffset,i.byteOffset+e),t),l=new Float32Array(t);for(let e=0;e<t;e++)l[e]=s[e];return l}if(116===e){let e=r.readUint32(),i=new Float32Array(e);for(let t=0;t<e;t++)i[t]=r.readFloat32();let s=r.readUint64(),l=r.readBytes(s),a=g(l.buffer.slice(l.byteOffset,l.byteOffset+s),t),n=new Float32Array(t);for(let e=0;e<t;e++)n[e]=i[a[e]];return n}return console.warn("USDCParser: Unknown float compression code",e),new Float32Array(t)}default:return console.warn("USDCParser: Unsupported compressed array type",e),[]}}_readHalf(){return this._halfToFloat(this.reader.readUint16())}_halfToFloat(e){let t=(32768&e)>>15,r=(31744&e)>>10,i=1023&e;return 0===r?0===i?t?-0:0:(t?-1:1)*6103515625e-14*(i/1024):31===r?i?NaN:t?-1/0:1/0:(t?-1:1)*p[r]*(1+i/1024)}_getFieldsForSpec(e){let t={},r=e.fieldSetIndex,i=0;for(;r<this.fieldSets.length&&i<1e4;){let e=this.fieldSets[r];if(0xffffffff===e||-1===e)break;let s=this.fields[e];if(s){let e=this.tokens[s.tokenIndex],r=this._readValue(s.valueRep);t[e]=r}r++,i++}return t}}let P=/^(.+?)\/\{(\w+)=(\w+)\}\/(.+)$/,w={Attribute:1,Prim:6,Relationship:8},A={projection:"perspective",clippingRange:[1,1e6],horizontalAperture:20.955,verticalAperture:15.2908,horizontalApertureOffset:0,verticalApertureOffset:0,focalLength:50,focusDistance:0,fStop:0};class v{constructor(e=null){this.textureCache={},this.skinnedMeshes=[],this.manager=e,this.texturePromises=[]}compose(e,t={},r={},s=""){this.specsByPath=e.specsByPath,this.assets=t,this.externalVariantSelections=r,this.basePath=s,this.skinnedMeshes=[],this.skeletons={},this.texturePromises=[],this._buildIndexes();let l=this.specsByPath["/"],a=l?l.fields:{};this.fps=a.timeCodesPerSecond||a.framesPerSecond||24;let n=new i.YJl;this._buildHierarchy(n,"/"),this._bindSkeletons();let o=Object.keys(this.skeletons);1===o.length&&(n.skeleton=this.skeletons[o[0]].skeleton),n.animations=this._buildAnimations();let h=a.metersPerUnit;return void 0!==h&&1!==h&&n.scale.setScalar(h),l&&l.fields&&"Z"===l.fields.upAxis&&(n.rotation.x=-Math.PI/2),n}applyTransform(e,t,r={}){let s={...t,...r},l=s.xformOpOrder;if(l&&l.length>0){let t=new i.kn4,r=new i.kn4,a=null;for(let e=0;e<l.length;e++){let n=l[e],o=n.startsWith("!invert!"),h=o?n.slice(8):n;if("xformOp:transform"===h){let e=s["xformOp:transform"];e&&16===e.length&&(r.set(e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15]),o&&r.invert(),t.multiply(r))}else if("xformOp:translate"===h){let e=s["xformOp:translate"];e&&(r.makeTranslation(e[0],e[1],e[2]),o&&r.invert(),t.multiply(r))}else if("xformOp:translate:pivot"===h){let e=s["xformOp:translate:pivot"];e&&(r.makeTranslation(e[0],e[1],e[2]),o&&r.invert(),t.multiply(r))}else if("xformOp:scale"===h){let e=s["xformOp:scale"];e&&(Array.isArray(e)?(r.makeScale(e[0],e[1],e[2]),a=[e[0],e[1],e[2]]):(r.makeScale(e,e,e),a=[e,e,e]),o&&r.invert(),t.multiply(r))}else if("xformOp:rotateXYZ"===h){let e=s["xformOp:rotateXYZ"];if(e){let s=new i.O9p(e[0]*Math.PI/180,e[1]*Math.PI/180,e[2]*Math.PI/180,"ZYX");r.makeRotationFromEuler(s),o&&r.invert(),t.multiply(r)}}else if("xformOp:rotateX"===h){let e=s["xformOp:rotateX"];void 0!==e&&(r.makeRotationX(e*Math.PI/180),o&&r.invert(),t.multiply(r))}else if("xformOp:rotateY"===h){let e=s["xformOp:rotateY"];void 0!==e&&(r.makeRotationY(e*Math.PI/180),o&&r.invert(),t.multiply(r))}else if("xformOp:rotateZ"===h){let e=s["xformOp:rotateZ"];void 0!==e&&(r.makeRotationZ(e*Math.PI/180),o&&r.invert(),t.multiply(r))}else if("xformOp:orient"===h){let e=s["xformOp:orient"];if(e&&4===e.length){let s=new i.PTz(e[0],e[1],e[2],e[3]);r.makeRotationFromQuaternion(s),o&&r.invert(),t.multiply(r)}}}if(e.matrix.copy(t),e.matrix.decompose(e.position,e.quaternion,e.scale),a){let t=a[0]<0,r=a[1]<0;3==+!!t+ +!!r+ +!!(a[2]<0)&&(e.scale.set(a[0],a[1],a[2]),e.quaternion.set(e.quaternion.x,-e.quaternion.y,e.quaternion.z,-e.quaternion.w))}return}if(s["xformOp:translate"]){let t=s["xformOp:translate"];e.position.set(t[0],t[1],t[2])}if(s["xformOp:translate:pivot"]){let t=s["xformOp:translate:pivot"];e.pivot=new i.Pq0(t[0],t[1],t[2])}if(s["xformOp:scale"]){let t=s["xformOp:scale"];Array.isArray(t)?e.scale.set(t[0],t[1],t[2]):e.scale.set(t,t,t)}if(s["xformOp:rotateXYZ"]){let t=s["xformOp:rotateXYZ"];e.rotation.set(t[0]*Math.PI/180,t[1]*Math.PI/180,t[2]*Math.PI/180)}if(s["xformOp:orient"]){let t=s["xformOp:orient"];4===t.length&&e.quaternion.set(t[0],t[1],t[2],t[3])}}_buildIndexes(){for(let e in this.childrenByPath=new Map,this.attributesByPrimPath=new Map,this.materialsByRo
1ot=new Map,this.shadersByMaterialPath=new Map,this.geomSubsetsByMeshPath=new Map,this.specsByPath){let t=this.specsByPath[e];if(t.specType===w.Prim){let r=e.lastIndexOf("/");if(r>0){let t=e.slice(0,r),i=e.slice(r+1);this.childrenByPath.has(t)||this.childrenByPath.set(t,[]),this.childrenByPath.get(t).push({name:i,path:e})}else if(0===r&&e.length>1){let t=e.slice(1);this.childrenByPath.has("/")||this.childrenByPath.set("/",[]),this.childrenByPath.get("/").push({name:t,path:e})}let i=t.fields.typeName;if("Material"===i){let t=e.split("/"),r=t.length>1?"/"+t[1]:"/";this.materialsByRoot.has(r)||this.materialsByRoot.set(r,[]),this.materialsByRoot.get(r).push(e)}if("Shader"===i&&r>0){let t=e.slice(0,r);for(;t.length>0;){let r=this.specsByPath[t];if(r&&r.specType===w.Prim&&"Material"===r.fields.typeName){this.shadersByMaterialPath.has(t)||this.shadersByMaterialPath.set(t,[]),this.shadersByMaterialPath.get(t).push(e);break}let i=t.lastIndexOf("/");if(i<=0)break;t=t.slice(0,i)}}if("GeomSubset"===i&&r>0){let t=e.slice(0,r);this.geomSubsetsByMeshPath.has(t)||this.geomSubsetsByMeshPath.set(t,[]),this.geomSubsetsByMeshPath.get(t).push(e)}}else if(t.specType===w.Attribute||t.specType===w.Relationship){let r=e.lastIndexOf(".");if(r>0){let i=e.slice(0,r),s=e.slice(r+1);this.attributesByPrimPath.has(i)||this.attributesByPrimPath.set(i,new Map),this.attributesByPrimPath.get(i).set(s,t)}}}}_isDirectChild(e,t,r){if(!t.startsWith(r))return!1;let i=t.slice(r.length);return!(0===i.length||i.startsWith("{"))&&!i.includes("/")}_buildHierarchy(e,t){let r=[],s=new Set,l=this.childrenByPath.get(t);if(l)for(let e of l)s.has(e.path)||(s.add(e.path),r.push(e));for(let e of this._getVariantPaths(t)){let t=this.childrenByPath.get(e);if(t)for(let e of t)s.has(e.path)||(s.add(e.path),r.push(e))}for(let{name:t,path:s}of r){let r=this.specsByPath[s];if(!r||r.specType!==w.Prim)continue;let l=r.fields.typeName,a=this._getReferences(r);if(a.length>0){let n=this._getLocalVariantSelections(r.fields),o=[];for(let e of a){let t=this._resolveReference(e,n);t&&o.push(t)}if(o.length>0){let a=this._getAttributes(s);if(1===o.length){let i=this._findSingleMesh(o[0]);if(i&&("Xform"===l||!l)){i.name=t,this.applyTransform(i,r.fields,a),this._applyMaterialBinding(i,s),e.add(i),this._buildHierarchy(i,s);continue}}let n=new i.B69;for(let e of(n.name=t,this.applyTransform(n,r.fields,a),o))for(;e.children.length>0;)n.add(e.children[0]);e.add(n),this._buildHierarchy(n,s);continue}}if("SkelRoot"===l){let l=new i.B69;l.name=t,l.userData.isSkelRoot=!0;let a=this._getAttributes(s);this.applyTransform(l,r.fields,a),e.add(l),this._buildHierarchy(l,s)}else if("Skeleton"===l){let t=this._buildSkeleton(s);t&&(this.skeletons[s]=t),this._buildHierarchy(e,s)}else if("SkelAnimation"===l);else if("Mesh"===l){let t=this._buildMesh(s,r);t&&(e.add(t),this._buildHierarchy(t,s))}else if("Camera"===l){let i=this._buildCamera(s);i.name=t;let l=this._getAttributes(s);this.applyTransform(i,r.fields,l),e.add(i),this._buildHierarchy(i,s)}else if("DistantLight"===l||"SphereLight"===l||"RectLight"===l||"DiskLight"===l){let i=this._buildLight(s,l);i.name=t;let a=this._getAttributes(s);this.applyTransform(i,r.fields,a),e.add(i),this._buildHierarchy(i,s)}else if("Cube"===l||"Sphere"===l||"Cylinder"===l||"Cone"===l||"Capsule"===l){let t=this._buildGeomPrimitive(s,r,l);t&&(e.add(t),this._buildHierarchy(t,s))}else if("Material"===l||"Shader"===l||"GeomSubset"===l);else{let l=new i.B69;l.name=t;let a=this._getAttributes(s);this.applyTransform(l,r.fields,a),e.add(l),this._buildHierarchy(l,s)}}}_getVariantPaths(e){let t=this.specsByPath[e],r=t?.fields?.variantSetChildren,i=[];if(!r||0===r.length)return i;for(let s of r){let r=this.externalVariantSelections[s]||null;if(!r){let e=t.fields.variantSelection;r=e?e[s]:null}if(!r){let t=e+"/{"+s+"=}",i=this.specsByPath[t];i?.fields?.variantChildren&&(r=i.fields.variantChildren[0])}if(r){let t=e+"/{"+s+"="+r+"}";i.push(t)}}return i}_resolveFilePath(e){let t=e;if(t.startsWith("./")&&(t=t.slice(2)),!this.basePath)return t;let r=this.basePath.endsWith("/")?this.basePath:this.basePath+"/";return i.r6x.resolveURL(t,r)}_resolveReference(e,t={}){if(!e)return null;let r=e.match(/@([^@]+)@(?:<([^>]+)>)?/);if(!r)return null;let s=r[1],l=r[2],a=this._resolveFilePath(s),n={...t,...this.externalVariantSelections},o=this.assets[a];if(!o)return null;if(o.specsByPath){let e=new v(this.manager),t=this._getBasePath(a),r=e.compose(o,this.assets,n,t);
1if(l){let e=l.split("/").pop(),t=null;for(let i of r.children)if(i.name===e){t=i;break}if(t){r.remove(t);let e=new i.YJl;return e.add(t),e}}return r}return o.isGroup||o.isObject3D?o.clone():null}_findSingleMesh(e){for(let t of e.children)if(t.isMesh)return e.remove(t),t;if(1===e.children.length){let t=e.children[0];if(t.children&&1===t.children.length){let e=t.children[0];if(e.isMesh&&!this._hasNonIdentityTransform(t))return t.remove(e),e}}return null}_hasNonIdentityTransform(e){let t=e.position,r=e.rotation,i=e.scale,s=0!==t.x||0!==t.y||0!==t.z,l=0!==r.x||0!==r.y||0!==r.z,a=1!==i.x||1!==i.y||1!==i.z;return s||l||a}_getBasePath(e){let t=e.lastIndexOf("/");return t>=0?e.slice(0,t):""}_getLocalVariantSelections(e){let t={};if(e.variantSelection)for(let r in e.variantSelection)t[r]=e.variantSelection[r];return t}_getReferences(e){let t=[];if(e.fields.references&&e.fields.references.length>0){let r=e.fields.references[0];if("string"==typeof r)for(let e of r.matchAll(/@([^@]+)@(?:<([^>]+)>)?/g))t.push(e[0]);else r.assetPath&&t.push("@"+r.assetPath+"@")}if(0===t.length&&e.fields.payload){let r=e.fields.payload;"string"==typeof r?t.push(r):r.assetPath&&t.push("@"+r.assetPath+"@")}return t}_resolveAttributeValue(e,t=new Set){let r=String(e).replace(/<|>/g,"");if(t.has(r))return;let i=this.specsByPath[r]?.fields;if(!i)return;let s=new Set(t);if(s.add(r),i.connectionPaths)for(let e of i.connectionPaths){let t=this._resolveAttributeValue(e,s);if(void 0!==t)return t}if(void 0!==i.default)return i.default;let{times:l,values:a}=i.timeSamples||{};if(l&&a&&l.length>0){let e=l.indexOf(0);return a[e>=0?e:0]}}_getAttributes(e){let t={};this._collectAttributesFromPath(e,t);let r=e.match(P);if(r){let i=r[1],s=r[4];for(let r of this._getVariantPaths(i)){if(e.startsWith(r))continue;let i=r+"/"+s;this._collectAttributesFromPath(i,t)}}else{let r=e.split("/");for(let e=1;e<r.length-1;e++){let i=r.slice(0,e+1).join("/"),s=r.slice(e+1).join("/");for(let e of this._getVariantPaths(i)){let r=e+"/"+s;this._collectAttributesFromPath(r,t)}}}return t}_collectAttributesFromPath(e,t){let r=this.attributesByPrimPath.get(e);if(r)for(let[i,s]of r){let r=this._resolveAttributeValue(e+"."+i);void 0!==r&&(t[i]=r),s.fields?.elementSize!==void 0&&(t[i+":elementSize"]=s.fields.elementSize),i.startsWith("primvars:")&&s.fields?.typeName!==void 0&&(t[i+":typeName"]=s.fields.typeName)}}_buildGeomPrimitive(e,t,r){let s,l=this._getAttributes(e),a=e.split("/").pop();switch(r){case"Cube":{let e=l.size||2;s=new i.iNn(e,e,e);break}case"Sphere":{let e=l.radius||1;s=new i.Gu$(e,32,16);break}case"Cylinder":{let e=l.height||2,t=l.radius||1;s=new i.Ho_(t,t,e,32);break}case"Cone":{let e=l.height||2,t=l.radius||1;s=new i.qFE(t,e,32);break}case"Capsule":{let e=l.height||1,t=l.radius||.5;s=new i.qU7(t,e,16,32)}}let n=l.axis||"Z";"X"===n?s.rotateZ(-Math.PI/2):"Z"===n&&s.rotateX(Math.PI/2);let o=this._buildMaterial(e,t.fields),h=new i.eaF(s,o);return h.name=a,this.applyTransform(h,t.fields,l),h}_buildMesh(e,t){let r,s,l,a=this._getAttributes(e),n=a["primvars:skel:jointIndices"],o=a["primvars:skel:jointWeights"],h=n&&o&&n.length>0&&o.length>0,f=this._getGeomSubsets(e);if(f.length>0){r=this._buildGeometryWithSubsets(a,f,h);let i=this._getMaterialPath(e,t.fields);s=f.map(e=>{let t=e.materialPath||i;return this._buildMaterialForPath(t)})}else r=this._buildGeometry(e,a,h),s=this._buildMaterial(e,t.fields);let u=a["primvars:displayColor"];if(u&&u.length>=3){let e=e=>{e.color&&1===e.color.r&&1===e.color.g&&1===e.color.b&&!e.map&&e.color.setRGB(u[0],u[1],u[2],i.er$)};Array.isArray(s)?s.forEach(e):e(s)}let p=a["primvars:displayOpacity"];if(p&&1===p.length&&0===f.length){let e=p[0],t=t=>{e<1&&1===t.opacity&&!1===t.transparent&&(t.opacity=e,t.transparent=!0)};Array.isArray(s)?s.forEach(t):t(s)}if(h){l=new i.I46(r,s);let t=this.specsByPath[e+".skel:skeleton"];t||(t=this.specsByPath[e+".rel skel:skeleton"]);let n=null;t&&(t.fields.targetPaths&&t.fields.targetPaths.length>0?n=t.fields.targetPaths[0]:t.fields.default&&(n=t.fields.default.replace(/<|>/g,"")));let o=a["skel:joints"],h=a["primvars:skel:geomBindTransform"];this.skinnedMeshes.push({mesh:l,skeletonPath:n,path:e,localJoints:o,geomBindTransform:h})}else l=new i.eaF(r,s);return l.name=e.split("/").pop(),this.applyTransform(l,t.fields,a),l}_buildCamera(e){let t,r=this._getAttributes(e),s=r.projection,l="string"==typeof s?s.toLowerCase():A.projection,a=r.clippingRange||A.clippingRange,n=Math.max(Number.EPSILON,this._parseNumber(a[0],A.clippingRange[0])),o=Math.max(n+Number.EPSILON,this._parseNumber(a[1],A.clippingRange[1])),h=this._parseNumber(r.horizontalAperture,A.horizontalAperture),f=this._parseNumber(r.verticalAperture,A.verticalAperture),u=this._parseNumber(r.horizontalApertureOffset,A.horizontalApertureOffset),p=this._parseNumber(r.verticalApertureOffset,A.verticalApertureOffset),d=this._parseNumber(r.focalLength,A.focalLength),c=this._parseNumber(r.focusDistance,A.focusDistance),m=this._parseNumber(r.fStop,A.fStop);if("orthographic"===l){let e=h/10,r=f/10,s=u/10,l=p/10;t=new i.qUd(s-.5*e,s+.5*e,l+.5*r,l-.5*r,n,o)}else{let e=Math.max(Number.EPSILON,f),r=Math.max(Number.EPSILON,d),s=2*Math.atan(e/(2*r))*180/Math.PI;(t=new i.ubm(s,h/e,n,o)).filmGauge=Math.max(h,f),t.filmOffset=u,t.focus=c,t.setFocalLength(r),0!==p&&(t.userData.verticalApertureOffset=p)}return t.userData.fStop=m,t.userData.usdProjection=l,t}_buildLight(e,t){let r,s=this._getAttributes(e),l=this._parseNumber(s["inputs:intensity"],1),a=s["inputs:color"]||[1,1,1],n=!0===s["inputs:enableColorTemperature"],o=this._parseNumber(s["inputs:colorTemperature"],6500),h=new i.Q1f(a[0],a[1],a[2]);if(n){let e=this._colorTemperature(o);h.multiply(e)}switch(t){case"DistantLight":r=new i.ZyN(h,l);break;case"SphereLight":{let e=this._parseNumber(s["shaping:cone:angle"],0);if(e>0){let t=e*Math.PI/180,a=this._parseNumber(s["shaping:cone:softness"],0);r=new i.nCl(h,l,0,t,a)}else r=new i.HiM(h,l);break}case"RectLight":{let e=this._parseNumber(s["inputs:width"],1),t=this._parseNumber(s["inputs:height"],1);r=new i.ure(h,l,e,t);break}case"DiskLight":{let e=2*this._parseNumber(s["inputs:radius"],.5);r=new i.ure(h,l,e,e)}}return r}_colorTemperature(e){let t,r,s,l=e/100;return l<=66?(t=1,r=.3900815787690196*Math.log(l)-.6318414437886275):(t=1.292936186062745*Math.pow(l-60,-.1332047592),r=1.1298908608952942*Math.pow(l-60,-.0755148492)),s=l>=66?1:l<=19?0:.543206789110196*Math.log(l-10)-1.19625408914,new i.Q1f(Math.min(Math.max(t,0),1),Math.min(Math.max(r,0),1),Math.min(Math.max(s,0),1))}_parseNumber(e,t){let r=Number(e);return Number.isFinite(r)?r:t}_getGeomSubsets(e){let t=[],r=this.geomSubsetsByMeshPath.get(e);if(!r)return t;for(let e of r){let r=this._getAttributes(e).indices;if(!r||0===r.length)continue;let i=this._getMaterialBindingTarget(e);t.push({name:e.split("/").pop(),indices:r,materialPath:i})}return t}_getMaterialBindingSpec(e){let t="material:binding",r=e+"."+t,i=this.specsByPath[r]||null,s=e.split("/");for(let e=1;e<s.length;e++){let r=s.slice(0,e+1).join("/"),l=s.slice(e+1).join("/");for(let e of this._getVariantPaths(r)){let r=l?e+"/"+l+"."+t:e+"."+t,s=this.specsByPath[r];s?.fields?.targetPaths?.length>0&&(i=s)}}return i}
1_getMaterialBindingTarget(e){let t=e.split("/").filter(Boolean),r=null;for(let e=0;e<t.length;e++){let i="/"+t.slice(0,e+1).join("/"),s=this._getMaterialBindingSpec(i);s?.fields?.targetPaths?.length&&(r&&r.fields?.bindMaterialAs==="strongerThanDescendants"||(r=s))}return r?.fields.targetPaths[0]||null}_buildGeometry(e,t,r=!1){let s=new i.LoY,l=t.points;if(!l||0===l.length)return s;let a=t.faceVertexIndices,n=t.faceVertexCounts,o=t["primvars:arnold:polygon_holes"],h=this._buildHoleMap(o),f=a,u=null;if(n&&n.length>0){let e=this._triangulateIndicesWithPattern(a,n,l,h);f=e.indices,u=e.pattern}let p=l;f&&f.length>0&&(p=this._expandAttribute(l,f,3)),s.setAttribute("position",new i.THS(new Float32Array(p),3));let d=t.normals||t["primvars:normals"],c=t["normals:indices"]||t["primvars:normals:indices"];if(d&&d.length>0){let e=d;if(c&&c.length>0&&u){let t=this._applyTriangulationPattern(c,u);e=this._expandAttribute(d,t,3)}else if(d.length===l.length)f&&f.length>0&&(e=this._expandAttribute(d,f,3));else if(u){let t=this._applyTriangulationPattern(Array.from({length:d.length/3},(e,t)=>t),u);e=this._expandAttribute(d,t,3)}s.setAttribute("normal",new i.THS(new Float32Array(e),3))}else{let e=this._computeVertexNormals(l,f);s.setAttribute("normal",new i.THS(new Float32Array(this._expandAttribute(e,f,3)),3))}let{uvs:m,uvIndices:g}=this._findUVPrimvar(t),y=a?a.length:0;if(m&&m.length>0){let e=m;if(g&&g.length>0&&u){let t=this._applyTriangulationPattern(g,u);e=this._expandAttribute(m,t,2)}else if(f&&m.length/2==l.length/3)e=this._expandAttribute(m,f,2);else if(u&&m.length/2===y){let t=this._applyTriangulationPattern(Array.from({length:y},(e,t)=>t),u);e=this._expandAttribute(m,t,2)}s.setAttribute("uv",new i.THS(new Float32Array(e),2))}let{uvs2:_,uv2Indices:b}=this._findUV2Primvar(t);if(_&&_.length>0){let e=_;if(b&&b.length>0&&u){let t=this._applyTriangulationPattern(b,u);e=this._expandAttribute(_,t,2)}else if(f&&_.length/2==l.length/3)e=this._expandAttribute(_,f,2);else if(u&&_.length/2===y){let t=this._applyTriangulationPattern(Array.from({length:y},(e,t)=>t),u);e=this._expandAttribute(_,t,2)}s.setAttribute("uv1",new i.THS(new Float32Array(e),2))}if(r){let e=t["primvars:skel:jointIndices"],r=t["primvars:skel:jointWeights"],l=t["primvars:skel:jointIndices:elementSize"]||4;if(e&&r){let t,a,n=p.length/3;f&&f.length>0?(t=this._expandAttribute(e,f,l),a=this._expandAttribute(r,f,l)):(t=e,a=r);let o=new Uint16Array(4*n),h=new Float32Array(4*n);this._selectTopWeights(t,a,l,n,o,h),s.setAttribute("skinIndex",new i.THS(o,4)),s.setAttribute("skinWeight",new i.THS(h,4))}}return s}_buildGeometryWithSubsets(e,t,r=!1){let s=new i.LoY,l=e.points;if(!l||0===l.length)return s;let a=e.faceVertexIndices,n=e.faceVertexCounts;if(!n||0===n.length)return s;let o=e["primvars:arnold:polygon_holes"],h=this._buildHoleMap(o),f=h.holeFaces,u=h.parentToHoles,{uvs:p,uvIndices:d}=this._findUVPrimvar(e),{uvs2:c,uv2Indices:m}=this._findUV2Primvar(e),g=e.normals||e["primvars:normals"],y=e["normals:indices"]||e["primvars:normals:indices"],_=r?e["primvars:skel:jointIndices"]:null,b=r?e["primvars:skel:jointWeights"]:null,P=e["primvars:skel:jointIndices:elementSize"]||4,w=[],A=0;for(let e=0;e<n.length;e++){if(w.push(A),f.has(e))continue;let t=n[e],r=u.get(e);if(r&&r.length>0){let e=t;for(let t of r)e+=n[t];A+=e-2}else t>=3&&(A+=t-2)}let v=new Int32Array(A).fill(-1);for(let e=0;e<t.length;e++){let r=t[e];for(let t=0;t<r.indices.length;t++){let i=r.indices[t];if(i>=n.length)continue;let s=w[i],l=n[i]-2;for(let t=0;t<l;t++)v[s+t]=e}}let S=[];for(let e=0;e<A;e++)S.push({original:e,subset:v[e]});S.sort((e,t)=>e.subset-t.subset);let x=[],U=S.length>0?S[0].subset:-1,k=0;for(let e=0;e<S.length;e++)S[e].subset!==U&&(U>=0&&x.push({start:3*k,count:(e-k)*3,materialIndex:U}),U=S[e].subset,k=e);for(let e of(U>=0&&S.length>k&&x.push({start:3*k,count:(S.length-k)*3,materialIndex:U}),x))s.addGroup(e.start,e.count,e.materialIndex);let{indices:T,pattern:F}=this._triangulateIndicesWithPattern(a,n,l,h),I=n.reduce((e,t)=>e+t,0),B=p&&!d&&p.length/2===I||c&&!m&&c.length/2===I?this._applyTriangulationPattern(Array.from({length:I},(e,t)=>t),F):null,M=d?this._applyTriangulationPattern(d,F):p&&p.length/2===I?B:null,O=m?this._applyTriangulationPattern(m,F):c&&c.length/2===I?B:null,V=g&&y&&y.length>0,C=g&&g.length/3===I,R=V?this._applyTriangulationPattern(y,F):C?this._applyTriangulationPattern(Array.from({length:I},(e,t)=>t),F):null,D=!g&&T.length>0?this._computeVertexNormals(l,T):null,N=3*A,L=new Float32Array(3*N),W=p?new Float32Array(2*N):null,j=c?new Float32Array(2*N):null,z=g||D?new Float32Array(3*N):null,H=_?new Uint16Array(N*P):null,E=b?new Float32Array(N*P):null;for(let e=0;e<S.length;e++){let t=S[e].original;for(let r=0;r<3;r++){let i=3*t+r,s=3*e+r,a=T[i];if(L[3*s]=l[3*a],L[3*s+1]=l[3*a+1],L[3*s+2]=l[3*a+2],W&&p)if(M){let e=M[i];W[2*s]=p[2*e],W[2*s+1]=p[2*e+1]}
1else p.length/2==l.length/3&&(W[2*s]=p[2*a],W[2*s+1]=p[2*a+1]);if(j&&c)if(O){let e=O[i];j[2*s]=c[2*e],j[2*s+1]=c[2*e+1]}else c.length/2==l.length/3&&(j[2*s]=c[2*a],j[2*s+1]=c[2*a+1]);if(z)if(g&&R){let e=R[i];z[3*s]=g[3*e],z[3*s+1]=g[3*e+1],z[3*s+2]=g[3*e+2]}else g&&g.length===l.length?(z[3*s]=g[3*a],z[3*s+1]=g[3*a+1],z[3*s+2]=g[3*a+2]):D&&(z[3*s]=D[3*a],z[3*s+1]=D[3*a+1],z[3*s+2]=D[3*a+2]);if(H&&E&&_&&b)for(let e=0;e<P;e++)H[s*P+e]=_[a*P+e]||0,E[s*P+e]=b[a*P+e]||0}}if(s.setAttribute("position",new i.THS(L,3)),W&&s.setAttribute("uv",new i.THS(W,2)),j&&s.setAttribute("uv1",new i.THS(j,2)),s.setAttribute("normal",new i.THS(z,3)),H&&E){let e=new Uint16Array(4*N),t=new Float32Array(4*N);this._selectTopWeights(H,E,P,N,e,t),s.setAttribute("skinIndex",new i.THS(e,4)),s.setAttribute("skinWeight",new i.THS(t,4))}return s}_selectTopWeights(e,t,r,i,s,l){if(r<=4){for(let a=0;a<i;a++)for(let i=0;i<4;i++)i<r?(s[4*a+i]=e[a*r+i]||0,l[4*a+i]=t[a*r+i]||0):(s[4*a+i]=0,l[4*a+i]=0);return}let a=new Uint32Array(r);for(let n=0;n<i;n++){let i=n*r;for(let e=0;e<r;e++)a[e]=e;for(let e=0;e<4;e++){let s=e,l=t[i+a[e]]||0;for(let n=e+1;n<r;n++){let e=t[i+a[n]]||0;e>l&&(l=e,s=n)}if(s!==e){let t=a[e];a[e]=a[s],a[s]=t}}let o=0;for(let e=0;e<4;e++)o+=t[i+a[e]]||0;for(let r=0;r<4;r++){let h=a[r];o>0?(s[4*n+r]=e[i+h]||0,l[4*n+r]=(t[i+h]||0)/o):(s[4*n+r]=0,l[4*n+r]=0)}}}_findUVPrimvar(e){for(let t in e){if(!t.startsWith("primvars:")||t.endsWith(":typeName")||t.endsWith(":elementSize")||t.endsWith(":indices")||t.includes("skel:"))continue;let r=e[t+":typeName"];if(r&&r.includes("texCoord"))return{uvs:e[t],uvIndices:e[t+":indices"]}}return{uvs:e["primvars:st"]||e["primvars:UVMap"],uvIndices:e["primvars:st:indices"]}}_findUV2Primvar(e){return{uvs2:e["primvars:st1"],uv2Indices:e["primvars:st1:indices"]}}_buildHoleMap(e){if(!e||0===e.length)return{parentToHoles:new Map,holeFaces:new Set};let t=new Map,r=new Set;for(let i=0;i<e.length;i+=2){let s=e[i],l=e[i+1];r.add(s),t.has(l)||t.set(l,[]),t.get(l).push(s)}return{parentToHoles:t,holeFaces:r}}_triangulateIndicesWithPattern(e,t,r=null,i=null){let s=[],l=[],a=[],n=0;for(let e=0;e<t.length;e++)a.push(n),n+=t[e];let o=i?.parentToHoles||new Map,h=i?.holeFaces||new Set,f=0;for(let i=0;i<t.length;i++){let n=t[i];if(h.has(i)){f+=n;continue}let u=o.get(i);if(u&&u.length>0&&r&&r.length>0){let i=new Map,o=[];for(let t=0;t<n;t++){let r=e[f+t];o.push(r),i.set(r,f+t)}let h=[];for(let r of u){let s=a[r],l=t[r],n=[];for(let t=0;t<l;t++){let r=e[s+t];n.push(r),i.set(r,s+t)}h.push(n)}for(let e of this._triangulateNGonWithHoles(o,h,r))s.push(e[0],e[1],e[2]),l.push(i.get(e[0]),i.get(e[1]),i.get(e[2]))}else if(3===n)s.push(e[f],e[f+1],e[f+2]),l.push(f,f+1,f+2);else if(4===n)s.push(e[f],e[f+1],e[f+2],e[f],e[f+2],e[f+3]),l.push(f,f+1,f+2,f,f+2,f+3);else if(n>4)if(r&&r.length>0){let t=[];for(let r=0;r<n;r++)t.push(e[f+r]);for(let e of this._triangulateNGon(t,r))s.push(e[0],e[1],e[2]),l.push(f+t.indexOf(e[0]),f+t.indexOf(e[1]),f+t.indexOf(e[2]))}else for(let t=1;t<n-1;t++)s.push(e[f],e[f+t],e[f+t+1]),l.push(f,f+t,f+t+1);f+=n}return{indices:s,pattern:l}}_applyTriangulationPattern(e,t){let r=[];for(let i=0;i<t.length;i++)r.push(e[t[i]]);return r}_triangulateNGon(e,t){let r=[],s=[];for(let r of e)s.push(new i.Pq0(t[3*r],t[3*r+1],t[3*r+2]));let l=new i.Pq0;for(let e=0;e<s.length;e++){let t=s[e],r=s[(e+1)%s.length];l.x+=(t.y-r.y)*(t.z+r.z),l.y+=(t.z-r.z)*(t.x+r.x),l.z+=(t.x-r.x)*(t.y+r.y)}l.normalize();let a=new i.Pq0,n=new i.Pq0;for(let e of(Math.abs(l.y)>.9?a.set(1,0,0):a.set(0,1,0),n.crossVectors(l,a).normalize(),a.crossVectors(n,l).normalize(),s))r.push(new i.I9Y(e.dot(a),e.dot(n)));let o=i.xJ6.triangulateShape(r,[]),h=[];for(let t of o)h.push([e[t[0]],e[t[1]],e[t[2]]]);return h}_triangulateNGonWithHoles(e,t,r){let s=[];for(let t of e)s.push(new i.Pq0(r[3*t],r[3*t+1],r[3*t+2]));let l=new i.Pq0;for(let e=0;e<s.length;e++){let t=s[e],r=s[(e+1)%s.length];l.x+=(t.y-r.y)*(t.z+r.z),l.y+=(t.z-r.z)*(t.x+r.x),l.z+=(t.x-r.x)*(t.y+r.y)}l.normalize();let a=new i.Pq0,n=new i.Pq0;Math.abs(l.y)>.9?a.set(1,0,0):a.set(0,1,0),n.crossVectors(l,a).normalize(),a.crossVectors(n,l).normalize();let o=[];for(let e of s)o.push(new i.I9Y(e.dot(a),e.dot(n)));let h=[];for(let e of t){let t=[];for(let s of e){let e=new i.Pq0(r[3*s],r[3*s+1],r[3*s+2]);t.push(new i.I9Y(e.dot(a),e.dot(n)))}h.push(t)}let f=[...e];for(let e of t)f.push(...e);let u=i.xJ6.triangulateShape(o,h),p=[];for(let e of u)p.push([f[e[0]],f[e[1]],f[e[2]]]);return p}_triangulateIndices(e,t){let r=[],i=0;for(let s=0;s<t.length;s++){let l=t[s];if(3===l)r.push(e[i],e[i+1],e[i+2]);else if(4===l)r.push(e[i],e[i+1],e[i+2],e[i],e[i+2],e[i+3]);else if(l>4)for(let t=1;t<l-1;t++)r.push(e[i],e[i+t],e[i+t+1]);i+=l}return r}_expandAttribute(e,t,r){let i=Array(t.length*r);for(let s=0;s<t.length;s++){let l=t[s];for(let t=0;t<r;t++)i[s*r+t]=e[l*r+t]}return i}_computeVertexNormals(e,t){let r=e.length/3,i=new Float32Array(3*r);for(let r=0;r<t.length;r+=3){let s=t[r],l=t[r+1],a=t[r+2],n=e[3*s],o=e[3*s+1],h=e[3*s+2],f=e[3*l],u=e[3*l+1],p=e[3*l+2],d=e[3*a],c=e[3*a+1],m=e[3*a+2],g=f-n,y=u-o,_=p-h,b=d-n,P=c-o,w=m-h,A=y*w-_*P,v=_*b-g*w,S=g*P-y*b;i[3*s]+=A,i[3*s+1]+=v,i[3*s+2]+=S,i[3*l]+=A,i[3*l+1]+=v,i[3*l+2]+=S,i[3*a]+=A,i[3*a+1]+=v,i[3*a+2]+=S}for(let e=0;e<r;e++){let t=i[3*e],r=i[3*e+1],s=i[3*e+2],l=Math.sqrt(t*t+r*r+s*s);l>0&&(i[3*e]/=l,i[3*e+1]/=l,i[3*e+2]/=l)}return i}_getMaterialPath(e,t){let r=null,i=t["material:binding"];return i&&(r=Array.isArray(i)?i[0]:i),r||(r=this._getMaterialBindingTarget(e)),r}_buildMaterial(e,t){let r=new i.uSd,s=null,l=t["material:binding"];if(l&&(s=Array.isArray(l)?l[0]:l),s||(s=this._getMaterialBindingTarget(e)),!s){let t=[],r=e+"/";
1for(let e in this.specsByPath){if(!e.startsWith(r)||!e.endsWith(".material:binding"))continue;let i=this.specsByPath[e];if(!i)continue;let s=i.fields.targetPaths;s&&s.length>0&&t.push(s[0])}t.length>0&&(s=this._pickBestMaterial(t))}if(!s){let t="/"+e.split("/")[1],r=this.materialsByRoot.get(t);if(r){for(let e of r)if(e.startsWith(t+"/Looks/")||e.startsWith(t+"/Materials/")){s=e;break}}}return s&&this._applyMaterial(r,s),r}_buildMaterialForPath(e){let t=new i.uSd;return e&&this._applyMaterial(t,e),t}_applyMaterialBinding(e,t){let r=this._getMaterialBindingTarget(t);if(!r)return;r=String(r).replace(/^<|>$/g,"");let s=new i.uSd;this._applyMaterial(s,r),e.material=s}_pickBestMaterial(e){for(let t of e){let e=this.shadersByMaterialPath.get(t);if(e)for(let r of e){let e=this._getAttributes(r);if("UsdUVTexture"===e["info:id"]&&e["inputs:file"])return t}}return e[0]}_applyMaterial(e,t){if(!this.specsByPath[t])return;let r=this.shadersByMaterialPath.get(t);if(r)for(let t of r){let r=this.specsByPath[t];if(!r)continue;let i=this._getAttributes(t)["info:id"]||r.f
1ields["info:id"];"UsdPreviewSurface"===i||"ND_UsdPreviewSurface_surfaceshader"===i?this._applyPreviewSurface(e,t):"arnold:openpbr_surface"===i&&this._applyOpenPBRSurface(e,t)}}_applyTextureOrValue(e,t,r,i,s,l,a,n){let o=this.specsByPath[t+"."+i];if(o&&o.fields.connectionPaths&&o.fields.connectionPaths.length>0)for(let t of n===this._getTextureFromOpenPBRConnection?o.fields.connectionPaths:[o.fields.connectionPaths[0]]){let r=n.call(this,t);if(r)return r.colorSpace=l,e[s]=r,!0}return void 0!==r[i]&&a&&a(r[i]),!1}_applyPreviewSurface(e,t){let r=this._getAttributes(t),s=(i,s,l,a)=>this._applyTextureOrValue(e,t,r,i,s,l,a,this._getTextureFromConnection),l=e=>{let r=t+"."+e;return this.specsByPath[r]};if(s("inputs:diffuseColor","map",i.er$,t=>{Array.isArray(t)&&t.length>=3&&e.color.setRGB(t[0],t[1],t[2],i.er$)}),e.map&&e.map.userData.scale){let t=e.map.userData.scale;Array.isArray(t)&&t.length>=3&&e.color.setRGB(t[0],t[1],t[2],i.er$)}if(s("inputs:emissiveColor","emissiveMap",i.er$,t=>{Array.isArray(t)&&t.length>=3&&e.emissive.setRGB(t[0],t[1],t[2],i.er$)}),e.emissiveMap)if(e.emissiveMap.userData.scale){let t=e.emissiveMap.userData.scale;Array.isArray(t)&&t.length>=3&&e.emissive.setRGB(t[0],t[1],t[2],i.er$)}else e.emissive.set(0xffffff);if(s("inputs:normal","normalMap",i.jf0,null),e.normalMap&&e.normalMap.userData.scale){let t=e.normalMap.userData.scale;e.normalScale=new i.I9Y(t[0],t[1])}if(s("inputs:roughness","roughnessMap",i.jf0,t=>{e.roughness=t})&&(e.roughness=1),s("inputs:metallic","metalnessMap",i.jf0,t=>{e.metalness=t})&&(e.metalness=1),s("inputs:occlusion","aoMap",i.jf0,null),void 0!==r["inputs:ior"]&&(e.ior=r["inputs:ior"]),s("inputs:specularColor","specularColorMap",i.er$,t=>{Array.isArray(t)&&t.length>=3&&e.specularColor.setRGB(t[0],t[1],t[2],i.er$)}),e.specularColorMap&&e.specularColorMap.userData.scale){let t=e.specularColorMap.userData.scale;Array.isArray(t)&&t.length>=3&&e.specularColor.setRGB(t[0],t[1],t[2],i.er$)}void 0!==r["inputs:clearcoat"]&&(e.clearcoat=r["inputs:clearcoat"]),void 0!==r["inputs:clearcoatRoughness"]&&(e.clearcoatRoughness=r["inputs:clearcoatRoughness"]);let a=void 0!==r["inputs:opacityThreshold"]?r["inputs:opacityThreshold"]:0,n=l("inputs:opacity");if(n?.fields?.connectionPaths?.length>0)a>0?(e.alphaTest=a,e.transparent=!1):e.transparent=!0;else{let t=void 0!==r["inputs:opacity"]?r["inputs:opacity"]:1;t<1&&(e.transparent=!0,e.opacity=t)}}_applyOpenPBRSurface(e,t){let r=this._getAttributes(t),s=(i,s,l,a)=>this._applyTextureOrValue(e,t,r,i,s,l,a,this._getTextureFromOpenPBRConnection);if(s("inputs:base_color","map",i.er$,t=>{Array.isArray(t)&&t.length>=3&&e.color.setRGB(t[0],t[1],t[2],i.er$)}),e.map&&e.map.userData.scale){let t=e.map.userData.scale;Array.isArray(t)&&t.length>=3&&e.color.setRGB(t[0],t[1],t[2],i.er$)}s("inputs:base_metalness","metalnessMap",i.jf0,t=>{"number"==typeof t&&(e.metalness=t)}),s("inputs:specular_roughness","roughnessMap",i.jf0,t=>{"number"==typeof t&&(e.roughness=t)});let l=s("inputs:emission_color","emissiveMap",i.er$,t=>{Array.isArray(t)&&t.length>=3&&e.emissive.setRGB(t[0],t[1],t[2],i.er$)}),a=r["inputs:emission_luminance"];void 0!==a&&a>0&&(l?e.emissiveIntensity=a:e.emissive.multiplyScalar(a));let n=r["inputs:transmission_weight"];if(void 0!==n&&n>0){e.transmission=n;let t=r["inputs:transmission_depth"];void 0!==t&&(e.thickness=t);let i=r["inputs:transmission_color"];void 0!==i&&Array.isArray(i)&&(e.attenuationColor.setRGB(i[0],i[1],i[2]),e.attenuationDistance=t||1)}let o=r["inputs:geometry_opacity"];void 0!==o&&o<1&&(e.opacity=o,e.transparent=!0);let h=r["inputs:specular_ior"];void 0!==h&&(e.ior=h);let f=r["inputs:coat_weight"];if(void 0!==f&&f>0){e.clearcoat=f;let t=r["inputs:coat_roughness"];void 0!==t&&(e.clearcoatRoughness=t)}let u=r["inputs:thin_film_weight"];if(void 0!==u&&u>0){e.iridescence=u;let t=r["inputs:thin_film_ior"];void 0!==t&&(e.iridescenceIOR=t);let i=r["inputs:thin_film_thickness"];if(void 0!==i){let t=1e3*i;e.iridescenceThicknessRange=[t,t]}}let p=r["inputs:specular_weight"];void 0!==p&&(e.specularIntensity=p);let d=r["inputs:specular_color"];void 0!==d&&Array.isArray(d)&&e.specularColor.setRGB(d[0],d[1],d[2]);let c=r["inputs:specular_roughness_anisotropy"];void 0!==c&&c>0&&(e.anisotropy=c),s("inputs:geometry_normal","normalMap",i.jf0,null)}_getTextureFromOpenPBRConnection(e){let t=e.replace(/<|>/g,""),r=t.split(".")[0],i=this.specsByPath[r];if(!i)return null;let s=this._getAttributes(r),l=s["info:id"]||i.fields["info:id"];if("NodeGraph"===i.fields.typeName){let e=r+"."+t.split(".")[1],i=this.specsByPath[e];return i?.fields?.connectionPaths?.length>0?this._getTextureFromOpenPBRConnection(i.fields.connectionPaths[0]):null}if("arnold:image"===l){let e=s["inputs:filename"];return e?this._loadTextureFromPath(e):null}if(l&&l.startsWith("ND_image_")){let e=s["inputs:file"];return e?this._loadTextureFromPath(e):null}
1if("MayaND_fileTexture_color4"===l){let e=r+".inputs:inColor",t=this.specsByPath[e];return t?.fields?.connectionPaths?.length>0?this._getTextureFromOpenPBRConnection(t.fields.connectionPaths[0]):null}if(l&&l.startsWith("ND_convert_")){let e=r+".inputs:in",t=this.specsByPath[e];return t?.fields?.connectionPaths?.length>0?this._getTextureFromOpenPBRConnection(t.fields.connectionPaths[0]):null}if("arnold:bump2d"===l){let e=r+".inputs:bump_map",t=this.specsByPath[e];return t?.fields?.connectionPaths?.length>0?this._getTextureFromOpenPBRConnection(t.fields.connectionPaths[0]):null}if("arnold:color_correct"===l){let e=r+".inputs:input",t=this.specsByPath[e];return t?.fields?.connectionPaths?.length>0?this._getTextureFromOpenPBRConnection(t.fields.connectionPaths[0]):null}let a=r.substring(0,r.lastIndexOf("/"));if(a){let e=this.specsByPath[a];if(e){let t=this._getAttributes(a);if("arnold:image"===(t["info:id"]||e.fields["info:id"])){let e=t["inputs:filename"];if(e)return this._loadTextureFromPath(e)}}}return null}_loadTextureFromPath(e){if(!e)return null;if(this.textureCache[e])return this.textureCache[e];let t=this._loadTexture(e,null,null);return t&&(this.textureCache[e]=t),t}_getTextureFromConnection(e){let t=e.split(".")[0],r=this.specsByPath[t];if(!r)return null;let i=this._getAttributes(t);
1if("UsdUVTexture"!==(i["info:id"]||r.fields["info:id"]))return null;let s=i["inputs:file"];if(!s)return null;let l=null,a=0,n=t+".inputs:st",o=this.specsByPath[n];if(o?.fields?.connectionPaths?.length>0){let e=o.fields.connectionPaths[0].replace(/<|>/g,"").split(".")[0],t=this.specsByPath[e];if(t){let r=this._getAttributes(e),i=r["info:id"]||t.fields["info:id"];if("UsdTransform2d"===i){l=r;let t=e+".inputs:in",i=this.specsByPath[t];if(i?.fields?.connectionPaths?.length>0){let e=i.fields.connectionPaths[0].replace(/<|>/g,"").split(".")[0],t=this._getAttributes(e)["inputs:varname"];"st1"===t?a=1:"st2"===t&&(a=2)}}else if("UsdPrimvarReader_float2"===i){let e=r["inputs:varname"];"st1"===e?a=1:"st2"===e&&(a=2)}}}let h=i["inputs:scale"],f=i["inputs:bias"],u=s;if(h&&(u+=":s"+h.join(",")),f&&(u+=":b"+f.join(",")),this.textureCache[u])return this.textureCache[u];let p=this._loadTexture(s,i,l);return p&&(h&&(p.userData.scale=h),f&&(p.userData.bias=f),0!==a&&(p.channel=a),this.textureCache[u]=p),p}_applyTextureTransforms(e,t){if(!t)return;let r=t["inputs:scale"];r&&Array.isArray(r)&&r.length>=2&&e.repeat.set(r[0],r[1]);let i=t["inputs:translation"];i&&Array.isArray(i)&&i.length>=2&&e.offset.set(i[0],i[1]);let s=t["inputs:rotation"];"number"==typeof s&&(e.rotation=s*Math.PI/180)}_loadTexture(e,t,r){let i=e;i.startsWith("@")&&(i=i.slice(1)),i.endsWith("@")&&(i=i.slice(0,-1));let s=this._resolveFilePath(i),l=this.assets[s];if(l||(l=this.assets[i]),!l){let e=i.split("/").pop();for(let i in this.assets)if(i.endsWith(e)||i.endsWith("/"+e))return this._createTextureFromData(this.assets[i],t,r);if(this.basePath)return this._createTextureFromData(s,t,r);if(this.manager){let i=this.manager.resolveURL(e);if(i!==e)return this._createTextureFromData(i,t,r)}return console.warn("USDLoader: Texture not found:",i),null}return this._createTextureFromData(l,t,r)}_createTextureFromData(e,t,r){let s;if(!e)return null;let l=this,a=new i.gPd;if("string"==typeof e)s=e;else{if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))return null;let t=new Blob([e]);s=URL.createObjectURL(t)}let n=new Image;return this.texturePromises.push(new Promise(i=>{n.onload=function(){a.image=n,t&&(a.wrapS=l._getWrapMode(t["inputs:wrapS"]),a.wrapT=l._getWrapMode(t["inputs:wrapT"])),l._applyTextureTransforms(a,r),a.needsUpdate=!0,"string"!=typeof e&&URL.revokeObjectURL(s),i()},n.onerror=function(){console.warn("USDLoader: Failed to load texture:",s),"string"!=typeof e&&URL.revokeObjectURL(s),i()}})),n.src=s,a}_getWrapMode(e){return"repeat"===e?i.GJx:"mirror"===e?i.kTW:"clamp"===e?i.ghU:i.GJx}_buildSkeleton(e){let t=this._getAttributes(e),r=t.joints;if(!r||0===r.length)return null;let s=t.bindTransforms,l=t.restTransforms,a=this._flattenMatrixArray(s,r.length),n=this._flattenMatrixArray(l,r.length),o=[],h={},f=[];for(let e=0;e<r.length;e++){let t=r[e],s=t.split("/").pop(),l=new i.$Kf;if(l.name=s,o.push(l),h[t]={bone:l,index:e},a&&a.length>=(e+1)*16){let t=new i.kn4,r=a.slice(16*e,(e+1)*16);t.set(r[0],r[4],r[8],r[12],r[1],r[5],r[9],r[13],r[2],r[6],r[10],r[14],r[3],r[7],r[11],r[15]);let s=t.clone().invert();f.push(s)}else f.push(new i.kn4)}for(let e=0;e<r.length;e++){let t=r[e].split("/");if(t.length>1){let r=h[t.slice(0,-1).join("/")];r&&r.bone.add(o[e])}}if(n&&n.length>=16*r.length)for(let e=0;e<r.length;e++){let t=new i.kn4,r=n.slice(16*e,(e+1)*16);t.set(r[0],r[4],r[8],r[12],r[1],r[5],r[9],r[13],r[2],r[6],r[10],r[14],r[3],r[7],r[11],r[15]),t.decompose(o[e].position,o[e].quaternion,o[e].scale)}let u=o.filter(e=>!e.parent||!e.parent.isBone),p=this.specsByPath[e+".skel:animationSource"],d=null;return p&&p.fields.targetPaths&&p.fields.targetPaths.length>0&&(d=p.fields.targetPaths[0]),{skeleton:new i.EAD(o,f),joints:r,rootBones:u,animationPath:d,path:e}}_bindSkeletons(){for(let e of this.skinnedMeshes){let{mesh:t,skeletonPath:r,localJoints:s,geomBindTransform:l}=e,a=null;if(r&&this.skeletons[r]&&(a=this.skeletons[r]),!a){for(let e in this.skeletons)if(r&&(r.includes(e)||e.includes(r))){a=this.skeletons[e];break}}if(!a){let e=Object.keys(this.skeletons);e.length>0&&(a=this.skeletons[e[0]])}if(!a){console.warn("USDComposer: No skeleton found for skinned mesh",t.name);continue}let{skeleton:n,rootBones:o,joints:h}=a;if(s&&s.length>0){let e=t.geometry.attributes.skinIndex;if(e){let t=[];for(let e=0;e<s.length;e++){let r=s[e],i=h.indexOf(r);t[e]=i>=0?i:0}let r=e.array;for(let e=0;e<r.length;e++){let i=r[e];i<t.length&&(r[e]=t[i])}}}for(let e of o)t.add(e);let f=new i.kn4;l&&16===l.length&&f.set(l[0],l[4],l[8],l[12],l[1],l[5],l[9],l[13],l[2],l[6],l[10],l[14],l[3],l[7],l[11],l[15]),t.bind(n,f)}}_buildAnimations(){let e=[];for(let t in this.specsByPath){let r=this.specsByPath[t];if(r.specType!==w.Prim||"SkelAnimation"!==r.fields.typeName)continue;let i=this._buildAnimationClip(t);i&&e.push(i)}let t=this._buildTransformAnimations();return t.length>0&&e.push(new i.tz3("TransformAnimation",-1,t)),e}_buildTransformAnimations(){let e=[];for(let t in this.specsByPath){let r=this.specsByPath[t];if(r.specType!==w.Prim)continue;let s=r.fields?.typeName;if("Xform"!==s&&"Scope"!==s&&"Mesh"!==s)continue;let l=t.split("/").pop(),a=t+".xformOp:orient",n=this.specsByPath[a];if(n?.fields?.timeSamples){let{times:t,values:r}=n.fields.timeSamples,s=[],a=[];for(let e=0;e<t.length;e++){s.push(t[e]/this.fps);let i=r[e];a.push(i[0],i[1],i[2],i[3])}s.length>0&&e.push(new i.MBL(l+".quaternion",new Float32Array(s),new Float32Array(a)))}let o=t+".xformOp:rotateXYZ",h=this.specsByPath[o];if(h?.fields?.timeSamples){let{times:t,values:r}=h.fields.timeSamples,s=[],a=[],n=new i.O9p,o=new i.PTz;for(let e=0;e<t.length;e++){s.push(t[e]/this.fps);let i=r[e];n.set(i[0]*Math.PI/180,i[1]*Math.PI/180,i[2]*Math.PI/180,"ZYX"),o.setFromEuler(n),a.push(o.x,o.y,o.z,o.w)}s.length>0&&e.push(new i.MBL(l+".quaternion",new Float32Array(s),new Float32Array(a)))}let f=t+".xformOp:translate",u=this.specsByPath[f];if(u?.fields?.timeSamples){let{times:t,values:r}=u.fields.timeSamples,s=[],a=[];for(let e=0;e<t.length;e++){s.push(t[e]/this.fps);let i=r[e];a.push(i[0],i[1],i[2])}s.length>0&&e.push(new i.RiT(l+".position",new Float32Array(s),new Float32Array(a)))}let p=t+".xformOp:scale",d=this.specsByPath[p];if(d?.fields?.timeSamples){let{times:t,values:r}=d.fields.timeSamples,s=[],a=[];for(let e=0;e<t.length;e++){s.push(t[e]/this.fps);let i=r[e];a.push(i[0],i[1],i[2])}s.length>0&&e.push(new i.RiT(l+".scale",new Float32Array(s),new Float32Array(a)))}for(let s of r.fields?.properties||[]){if(!s.startsWith("xformOp:transform"))continue;let r=t+"."+s,a=this.specsByPath[r];if(!a?.fields?.timeSamples)continue;let{times:n,values:o}=a.fields.timeSamples,h=[],f=[],u=[],p=[],d=[],c=[],m=new i.kn4,g=new i.Pq0,y=new i.PTz,_=new i.Pq0;for(let e=0;e<n.length;
1e++){let t=o[e];if(!t||t.length<16)continue;let r=n[e]/this.fps;m.set(t[0],t[4],t[8],t[12],t[1],t[5],t[9],t[13],t[2],t[6],t[10],t[14],t[3],t[7],t[11],t[15]),m.decompose(g,y,_),h.push(r),f.push(g.x,g.y,g.z),u.push(r),p.push(y.x,y.y,y.z,y.w),d.push(r),c.push(_.x,_.y,_.z)}h.length>0&&(e.push(new i.RiT(l+".position",new Float32Array(h),new Float32Array(f))),e.push(new i.MBL(l+".quaternion",new Float32Array(u),new Float32Array(p))),e.push(new i.RiT(l+".scale",new Float32Array(d),new Float32Array(c))));break}}return e}_buildAnimationClip(e){let t=this._getAttributes(e).joints;if(!t||0===t.length)return null;let r=[],s=this._getTimeSampledAttribute(e,"rotations");if(s&&s.times&&s.values){let{times:e,values:l}=s;for(let s=0;s<t.length;s++){let a=t[s].split("/").pop(),n=[],o=[];for(let t=0;t<e.length;t++){let r=l[t];if(!r||r.length<(s+1)*4)continue;n.push(e[t]/this.fps);let i=r[4*s+0],a=r[4*s+1],h=r[4*s+2],f=r[4*s+3];o.push(i,a,h,f)}n.length>0&&r.push(new i.MBL(a+".quaternion",new Float32Array(n),new Float32Array(o)))}}let l=this._getTimeSampledAttribute(e,"translations");if(l&&l.times&&l.values){let{times:e,values:s}=l;for(let l=0;l<t.length;l++){let a=t[l].split("/").pop(),n=[],o=[];for(let t=0;t<e.length;t++){let r=s[t];r&&!(r.length<(l+1)*3)&&(n.push(e[t]/this.fps),o.push(r[3*l+0],r[3*l+1],r[3*l+2]))}n.length>0&&r.push(new i.RiT(a+".position",new Float32Array(n),new Float32Array(o)))}}let a=this._getTimeSampledAttribute(e,"scales");if(a&&a.times&&a.values){let{times:e,values:s}=a;for(let l=0;l<t.length;l++){let a=t[l].split("/").pop(),n=[],o=[];for(let t=0;t<e.length;t++){let r=s[t];r&&!(r.length<(l+1)*3)&&(n.push(e[t]/this.fps),o.push(r[3*l+0],r[3*l+1],r[3*l+2]))}n.length>0&&r.push(new i.RiT(a+".scale",new Float32Array(n),new Float32Array(o)))}}if(0===r.length)return null;let n=e.split("/").pop();return new i.tz3(n,-1,r)}_getTimeSampledAttribute(e,t){let r=this.specsByPath[e+"."+t];if(r&&r.fields.timeSamples){let e=r.fields.timeSamples;if(e.times&&e.values)return e}return null}_flattenMatrixArray(e,t){if(!e||0===e.length)return null;if("number"==typeof e[0])return e;let r=[];for(let i=0;i<t;i++)for(let t=0;t<4;t++){let s=e[4*i+t];s&&4===s.length?r.push(s[0],s[1],s[2],s[3]):r.push(+(0===t),+(1===t),+(2===t),+(3===t))}return r}}class S extends i.aHM{constructor(e){super(e)}load(e,t,r,s){let l=this,a=""===l.path?i.r6x.extractUrlBase(e):l.path,n=new i.Y9S(l.manager);n.setPath(l.path),n.setResponseType("arraybuffer"),n.setRequestHeader(l.requestHeader),n.setWithCredentials(l.withCredentials),n.load(e,function(r){try{l.parse(r,a,t,s)}catch(t){s?s(t):console.error(t),l.manager.itemError(e)}},r,s)}parse(e,t="",r,i){let l=new f,a=new b,n=new TextDecoder;function o(e){return e instanceof ArrayBuffer?e:0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function h(e){let t=e.lastIndexOf(".");return t<0||e.lastIndexOf("/")>t?"":e.slice(t+1).toLowerCase()}function u(e){let t=new Uint8Array([80,88,82,45,85,83,68,67]),r=e instanceof Uint8Array?e:new Uint8Array(e);if(r.byteLength<t.length)return!1;for(let e=0;e<t.length;e++)if(r[e]!==t[e])return!1;return!0}let p=(e,t)=>(r&&Promise.all(e.texturePromises).then(()=>r(t)).catch(e=>i?i(e):console.error(e)),t);if("string"==typeof e){let r=new v(this.manager),i=l.parseData(e);return p(r,r.compose(i,{},{},t))}if(u(e)){let r=new v(this.manager),i=a.parseData(o(e));return p(r,r.compose(i,{},{},t))}let d=new Uint8Array(e);if(80===d[0]&&75===d[1]){let e=(0,s.AO)(d),t=function(e){let t={};for(let r in e){let i=e[r],s=h(r);if("png"===s||"jpg"===s||"jpeg"===s||"avif"===s){t[r]=i;continue}("usd"===s||"usda"===s||"usdc"===s)&&(u(i)?t[r]=a.parseData(o(i)):t[r]=l.parseData(n.decode(i)))}return t}(e),{file:r,filename:i,basePath:f}=function(e){let t=Object.keys(e);if(t.length<1)return{file:void 0,filename:"",basePath:""};let r=t[0],i=h(r),s=!1,l=r.lastIndexOf("/"),a=l>=0?r.slice(0,l):"";if("usda"===i)return{file:e[r],filename:r,basePath:a};if("usdc"===i)s=!0;else if("usd"===i)if(!u(e[r]))return{file:e[r],filename:r,basePath:a};else s=!0;return s?{file:e[r],filename:r,basePath:a}:{file:void 0,filename:"",basePath:""}}(e);if(!r)throw Error("THREE.USDLoader: Invalid USDZ package. The first ZIP entry must be a USD layer (.usd/.usda/.usdc).");let c=new v(this.manager),m=t[i];if(!m)throw Error('THREE.USDLoader: Failed to parse root layer "'+i+'".');return p(c,c.compose(m,t,{},f))}let c=new v(this.manager),m=n.decode(d),g=l.parseData(m);return p(c,c.compose(g,{},{},t))}}}}]);

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.