UNPKG

x_ite

Version:

X_ITE X3D Browser, view and manipulate X3D, VRML, glTF and other 3D sources in HTML.

2 lines 1.43 MB
/* X_ITE v11.5.0 */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.X3D=t():e.X3D=t()}(self,(()=>(()=>{var t={37:(e,t,i)=>{"use strict";i.d(t,{A:()=>c});var n=i(1497),s=i(1510);const r=Symbol(),o=Symbol(),a=Symbol(),l={get(e,t){const i=e[t];if(void 0!==i)return i;if("string"==typeof t){const i=+t;return Number.isInteger(i)?e[r][i]:void 0}},set:(e,t,i)=>void 0!==e[t]&&(e[t]=i,!0),has:(e,t)=>Number.isInteger(+t)?t<e[r].length:t in e,ownKeys:e=>Object.keys(e[r]),getOwnPropertyDescriptor(e,t){if("string"!=typeof t)return;const i=+t;if(Number.isInteger(i)&&i<e[r].length){const i=Object.getOwnPropertyDescriptor(e[r],t);return i&&(i.writable=!1),i}}};function h(e,t){const i=new Proxy(this,l);n.A.call(this),this[r]=[],this[o]=new Map,this[a]=t;for(const[t,i]of e)this.add(t,i);return i}Object.assign(Object.setPrototypeOf(h.prototype,n.A.prototype),{*[Symbol.iterator](){yield*this[r]},copy(){const e=new this.constructor;return e.assign(this),e},clear(){this[r].length=0,this[o].clear(),this.addEvent()},assign(e){if(!(e instanceof this.constructor))throw new Error("Couldn't assign info array, wrong type.");this[r]=Array.from(e[r]),this[o]=new Map(e[o]),this.addEvent()},equals(e){const t=this[r],i=e[r],n=t.length;if(t===i)return!0;if(n!==i.length)return!1;for(let e=0;e<n;++e)if(t[e]!==i[e])return!1;return!0},has(e){return this[o].has(e)},get(e){return this[o].get(e)},add(e,t){if(this[o].has(e))throw new Error(`Couldn't add value to ${this.getTypeName()}, key '${e}' already exists.`);if(!(t instanceof this[a]))throw new Error(`Couldn't add value to ${this.getTypeName()}, value for key '${e}' has wrong type.`);this[r].push(t),this[o].set(e,t),this.addEvent()},alias(e,t){this[o].set(e,t),this.addEvent()},update(e,t,i){if(!(i instanceof this[a]))throw new Error(`Couldn't update value of ${this.getTypeName()}, value for key '${key}' has wrong type.`);const n=this[o].get(e);if(e!==t&&this.remove(t),this[o].delete(e),this[o].set(t,i),void 0!==n){const e=this[r].indexOf(n);e>-1&&(this[r][e]=i)}else this[r].push(i);this.addEvent()},remove(e){const t=this[o].get(e);if(void 0===t)return;const i=this[r].indexOf(t);this[o].delete(e),i>-1&&this[r].splice(i,1),this.addEvent()},at:Array.prototype.at,entries:Array.prototype.entries,every:Array.prototype.every,filter(e,t){return new this.constructor(Array.prototype.filter.call(this,e,t))},find:Array.prototype.find,findIndex:Array.prototype.findIndex,findLast:Array.prototype.findLast,findLastIndex:Array.prototype.findLastIndex,flat:Array.prototype.flat,flatMap:Array.prototype.flatMap,forEach:Array.prototype.forEach,includes:Array.prototype.includes,indexOf:Array.prototype.indexOf,join:Array.prototype.join,keys:Array.prototype.keys,lastIndexOf:Array.prototype.lastIndexOf,map(e,t){return new this.constructor(Array.prototype.map.call(this,e,t))},reduce:Array.prototype.reduce,reduceRight:Array.prototype.reduceRight,slice(e,t){return new this.constructor(Array.prototype.slice.call(this,e,t))},some:Array.prototype.some,toReversed(){return new this.constructor([...this].reverse())},toSorted(e){return new this.constructor([...this].sort(e))},toSpliced(e,t,...i){const n=[...this];return n.splice(e,t,...i),new this.constructor(n)},values:Array.prototype.values,with(e,t){const i=[...this];return i[e]=t,new this.constructor(i)},toVRMLStream(e){for(const t of this[r])try{t.toVRMLStream(e),e.string+=e.Break(),this.getTypeName().match(/Proto/)&&(e.string+=e.TidyBreak())}catch(e){}},toXMLStream(e){for(const t of this[r])try{t.toXMLStream(e),e.string+=e.TidyBreak()}catch(e){}},toJSONStream(e,t){let i=!1;for(const t of this[r])try{t.toJSONStream(e,!0),e.string+=",",e.string+=e.TidyBreak(),i=!0}catch(e){}return i&&!t&&e.JSONRemoveComma(),i}});for(const e of Object.keys(h.prototype))Object.defineProperty(h.prototype,e,{enumerable:!1});Object.defineProperties(h.prototype,{length:{get(){return this[r].length}}});const d=h,c=s.A.add("X3DInfoArray",d)},93:(t,i,n)=>{"use strict";n.d(i,{A:()=>g});var s=n(4817),r=n(2798),o=n(8533),a=n(1510);function l(e=0,t=0,i=0,n=1){this.x=e,this.y=t,this.z=i,this.w=n}Object.assign(l.prototype,{*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w},copy(){const e=Object.create(l.prototype);return e.x=this.x,e.y=this.y,e.z=this.z,e.w=this.w,e},assign({x:e,y:t,z:i,w:n}){return this.x=e,this.y=t,this.z=i,this.w=n,this},set(e=0,t=0,i=0,n=1){return this.x=e,this.y=t,this.z=i,this.w=n,this},setMatrix(e){if(e[0]>e[4])var t=e[0]>e[8]?0:2;else t=e[4]>e[8]?1:2;const i=e[0]+e[4]+e[8];if(i>e[3*t+t]){this[3]=Math.sqrt(i+1)/2;const t=4*this[3];this[0]=(e[5]-e[7])/t,this[1]=(e[6]-e[2])/t,this[2]=(e[1]-e[3])/t}else{const i=(t+1)%3,n=(t+2)%3;this[t]=Math.sqrt(e[3*t+t]-e[3*i+i]-e[3*n+n]+1)/2;const s=4*this[t];this[i]=(e[3*t+i]+e[3*i+t])/s,this[n]=(e[3*t+n]+e[3*n+t])/s,this[3]=(e[3*i+n]-e[3*n+i])/s}return this},getMatrix(e=new r.A){const{x:t,y:i,z:n,w:s}=this,o=t*t,a=t*i,l=i*i,h=i*n,d=n*t,c=n*n,u=s*t,p=s*i,g=s*n;return e[0]=1-2*(l+c),e[1]=2*(a+g),e[2]=2*(d-p),e[3]=2*(a-g),e[4]=1-2*(c+o),e[5]=2*(h+u),e[6]=2*(d+p),e[7]=2*(h-u),e[8]=1-2*(l+o),e},setEuler(e,t,i,n="XYZ"){const s=Math.cos(e/2),r=Math.cos(t/2),o=Math.cos(i/2),a=Math.sin(e/2),l=Math.sin(t/2),h=Math.sin(i/2);switch(n){case"XYZ":this.x=a*r*o+s*l*h,this.y=s*l*o-a*r*h,this.z=s*r*h+a*l*o,this.w=s*r*o-a*l*h;break;case"ZYX":this.x=a*r*o-s*l*h,this.y=s*l*o+a*r*h,this.z=s*r*h-a*l*o,this.w=s*r*o+a*l*h;break;case"YXZ":this.x=a*r*o+s*l*h,this.y=s*l*o-a*r*h,this.z=s*r*h-a*l*o,this.w=s*r*o+a*l*h;break;case"ZXY":this.x=a*r*o-s*l*h,this.y=s*l*o+a*r*h,this.z=s*r*h+a*l*o,this.w=s*r*o-a*l*h;break;case"YZX":this.x=a*r*o+s*l*h,this.y=s*l*o+a*r*h,this.z=s*r*h-a*l*o,this.w=s*r*o-a*l*h;break;case"XZY":this.x=a*r*o-s*l*h,this.y=s*l*o-a*r*h,this.z=s*r*h+a*l*o,this.w=s*r*o+a*l*h}return this},getEuler(e=[],t="XYZ"){const{0:i,1:n,2:s,3:r,4:a,5:l,6:h,7:d,8:c}=this.getMatrix(u);switch(t){case"XYZ":e[1]=Math.asin(o.A.clamp(h,-1,1)),Math.abs(h)<.9999999?(e[0]=Math.atan2(-d,c),e[2]=Math.atan2(-r,i)):(e[0]=Math.atan2(l,a),e[2]=0);break;case"ZYX":e[1]=Math.asin(-o.A.clamp(s,-1,1)),Math.abs(s)<.9999999?(e[0]=Math.atan2(l,c),e[2]=Math.atan2(n,i)):(e[0]=0,e[2]=Math.atan2(-r,a));break;case"YXZ":e[0]=Math.asin(-o.A.clamp(d,-1,1)),Math.abs(d)<.9999999?(e[1]=Math.atan2(h,c),e[2]=Math.atan2(n,a)):(e[1]=Math.atan2(-s,i),e[2]=0);break;case"ZXY":e[0]=Math.asin(o.A.clamp(l,-1,1)),Math.abs(l)<.9999999?(e[1]=Math.atan2(-s,c),e[2]=Math.atan2(-r,a)):(e[1]=0,e[2]=Math.atan2(n,i));break;case"YZX":e[2]=Math.asin(o.A.clamp(n,-1,1)),Math.abs(n)<.9999999?(e[0]=Math.atan2(-d,a),e[1]=Math.atan2(-s,i)):(e[0]=0,e[1]=Math.atan2(h,c));break;case"XZY":e[2]=Math.asin(-o.A.clamp(r,-1,1)),Math.abs(r)<.9999999?(e[0]=Math.atan2(l,a),e[1]=Math.atan2(h,i)):(e[0]=Math.atan2(-d,c),e[1]=0)}return e},isReal(){return!(this.x||this.y||this.z)},isImag(){return!this.w},equals({x:e,y:t,z:i,w:n}){return this.x===e&&this.y===t&&this.z===i&&this.w===n},negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},inverse(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},add({x:e,y:t,z:i,w:n}){return this.x+=e,this.y+=t,this.z+=i,this.w+=n,this},subtract({x:e,y:t,z:i,w:n}){return this.x-=e,this.y-=t,this.z-=i,this.w-=n,this},multiply(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},multLeft(e){const{x:t,y:i,z:n,w:s}=this,{x:r,y:o,z:a,w:l}=e;return this.x=s*r+t*l+i*a-n*o,this.y=s*o+i*l+n*r-t*a,this.z=s*a+n*l+t*o-i*r,this.w=s*l-t*r-i*o-n*a,this},multRight(e){const{x:t,y:i,z:n,w:s}=this,{x:r,y:o,z:a,w:l}=e;return this.x=l*t+r*s+o*n-a*i,this.y=l*i+o*s+a*t-r*n,this.z=l*n+a*s+r*i-o*t,this.w=l*s-r*t-o*i-a*n,this},divide(e){return this.x/=e,this.y/=e,this.z/=e,this.w/=e,this},multVecQuat(e){const{x:t,y:i,z:n,w:s}=this,{x:r,y:o,z:a}=e,l=2*(i*a-n*o),h=2*(n*r-t*a),d=2*(t*o-i*r);return e.x+=s*l+i*d-n*h,e.y+=s*h+n*l-t*d,e.z+=s*d+t*h-i*l,e},multQuatVec(e){const{x:t,y:i,z:n,w:s}=this,{x:r,y:o,z:a}=e,l=2*(n*o-i*a),h=2*(t*a-n*r),d=2*(i*r-t*o);return e.x+=s*l-i*d+n*h,e.y+=s*h-n*l+t*d,e.z+=s*d-t*h+i*l,e},normalize(){const e=Math.hypot(this.x,this.y,this.z,this.w);return e&&(this.x/=e,this.y/=e,this.z/=e,this.w/=e),this},dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w},norm(){const{x:e,y:t,z:i,w:n}=this;return e*e+t*t+i*i+n*n},magnitude(){return Math.hypot(this.x,this.y,this.z,this.w)},pow(t){if(t instanceof l)return this.assign(e.assign(t).multRight(this.log()).exp());if(this.isReal())return this.set(0,0,0,this.w**t);const i=this.magnitude(),n=i**t,s=t*Math.acos(this.w/i),r=n/this.imag.magnitude()*Math.sin(s);return this.x*=r,this.y*=r,this.z*=r,this.w=n*Math.cos(s),this},log(){if(this.isReal())return this.w>0?this.set(0,0,0,Math.log(this.w)):this.set(Math.PI,0,0,Math.log(-this.w));const e=this.magnitude(),t=this.imag.normalize().multiply(Math.acos(this.w/e)),i=Math.log(e);return this.x=t.x,this.y=t.y,this.z=t.z,this.w=i,this},exp(){if(this.isReal())return this.set(0,0,0,Math.exp(this.w));const e=this.imag,t=e.magnitude(),i=Math.exp(this.w),n=i*Math.cos(t),s=e.multiply(i*Math.sin(t)/t);return this.x=s.x,this.y=s.y,this.z=s.z,this.w=n,this},slerp(e,t){return o.A.slerp(this,h.assign(e),t)},squad(e,t,i,n){return o.A.slerp(o.A.slerp(this,h.assign(i),n),o.A.slerp(d.assign(e),c.assign(t),n),2*n*(1-n))},toString(){return this.x+" "+this.y+" "+this.z+" "+this.w}});for(const e of Object.keys(l.prototype))Object.defineProperty(l.prototype,e,{enumerable:!1});Object.defineProperties(l.prototype,{length:{value:4},0:{get(){return this.x},set(e){this.x=e}},1:{get(){return this.y},set(e){this.y=e}},2:{get(){return this.z},set(e){this.z=e}},3:{get(){return this.w},set(e){this.w=e}},real:{get(){return this.w}},imag:{get:(()=>{const e=new s.A;return function(){return e.set(this.x,this.y,this.z)}})()}}),Object.assign(l,{Identity:Object.freeze(new l),spline:(()=>{const e=new l,t=new l,i=new l,n=new l;return function(s,r,o){return e.assign(s),t.assign(r),i.assign(o),e.dot(t)<0&&e.negate(),i.dot(t)<0&&i.negate(),n.assign(t).inverse(),t.multRight(h.assign(n).multRight(e).log().add(d.assign(n).multRight(i).log()).divide(-4).exp()).normalize().copy()}})()});const h=new l,d=new l,c=new l,u=new r.A,p=l,g=a.A.add("Quaternion",p)},216:(e,t,i)=>{"use strict";i.d(t,{A:()=>b});var n=i(1497),s=i(8041),r=i(4180),o=i(8035),a=i(1510);const l=Symbol(),h=Symbol(),d=Symbol(),c=Symbol(),u=Symbol(),p=Symbol(),g=Symbol(),f=Symbol(),m=Symbol(),A=Symbol(),_=Symbol.for("X_ITE.X3DField.uniformLocation"),y=[];function x(e){n.A.call(this),this[l]=e}Object.assign(Object.setPrototypeOf(x.prototype,n.A.prototype),{[l]:void 0,[h]:s.A.initializeOnly,[d]:void 0,[c]:null,[u]:null,[p]:null,[g]:null,[f]:null,[m]:null,[A]:null,[_]:null,create(){return new this.constructor},equals(e){return this[l]===e.valueOf()},assign(e){this.set(e.getValue()),this.addEvent()},set(e){this[l]=e},setValue(e){this.set(e instanceof this.constructor?e.getValue():e),this.addEvent()},getValue(){return this[l]},getType(){return s.A[this.constructor.typeName]},setAccessType(e){this[h]=e},getAccessType(){return this[h]},isInitializable(){return!!(this[h]&s.A.initializeOnly)},isInput(){return!!(this[h]&s.A.inputOnly)},isOutput(){return!!(this[h]&s.A.outputOnly)},isReadable(){return this[h]!==s.A.inputOnly},isWritable(){return this[h]!==s.A.outputOnly},setUnit(e){this[d]=e},getUnit(){return this[d]},isReference(e){return e===this[h]||e===s.A.inputOutput},addReference(e){const t=this.getReferences();if(!t.has(e)){switch(t.add(e),this.getAccessType()&e.getAccessType()){case s.A.initializeOnly:e.addFieldInterest(this),this.processEvent(r.A.from(e));break;case s.A.inputOnly:e.addFieldInterest(this);break;case s.A.outputOnly:this.addFieldInterest(e);break;case s.A.inputOutput:e.addFieldInterest(this),this.addFieldInterest(e),this.processEvent(r.A.from(e))}this.processReferencesCallbacks()}},removeReference(e){switch(this[c]?.delete(e),this.getAccessType()&e.getAccessType()){case s.A.initializeOnly:case s.A.inputOnly:e.removeFieldInterest(this);break;case s.A.outputOnly:this.removeFieldInterest(e);break;case s.A.inputOutput:e.removeFieldInterest(this),this.removeFieldInterest(e)}this.processReferencesCallbacks()},getReferences(){return this[c]??=new o.A},addReferencesCallback(e,t){this[u]=new Map(this[u]),this[u].set(e,t)},removeReferencesCallback(e){this[u]?.delete(e)},getReferencesCallbacks(){return this[u]??=new Map},processReferencesCallbacks(){for(const e of this[u]?.values()??y)e()},addFieldInterest(e){this.getFieldInterests().add(e)},removeFieldInterest(e){this[p]?.delete(e)},getFieldInterests(){return this[p]??=new o.A},addFieldCallback(e,t){this[g]=new Map(this[g]),this[g].set(e,t)},removeFieldCallback(e){this[g]?.delete(e)},getFieldCallbacks(){return this[g]??=new Map},addInputRoute(e){this.getInputRoutes().add(e),this.processRouteCallbacks()},removeInputRoute(e){this[f]?.delete(e),this.processRouteCallbacks()},getInputRoutes(){return this[f]??=new o.A},addOutputRoute(e){this.getOutputRoutes().add(e),this.processRouteCallbacks()},removeOutputRoute(e){this[m]?.delete(e),this.processRouteCallbacks()},getOutputRoutes(){return this[m]??=new o.A},addRouteCallback(e,t){this[A]=new Map(this[A]),this[A].set(e,t)},removeRouteCallback(e){this[A]?.delete(e)},getRouteCallbacks(){return this[A]??=new Map},processRouteCallbacks(){for(const e of this[A]?.values()??y)e()},processEvent(e=r.A.create(this)){e.add(this),this.setTainted(!1);const t=e.field;t!==this&&this.set(t.getValue(),t.length),this.processInterests();let i=!0;for(const t of this[p]??y)e.has(t)||(i?(i=!1,t.addEventObject(this,e)):t.addEventObject(this,r.A.copy(e)));i&&r.A.push(e);for(const e of this[g]?.values()??y)e(this.valueOf())},fromString(e,t){},dispose(){for(const e of this[c]??y)e.removeFieldInterest(this);for(const e of new Set(this[f]))e.dispose();for(const e of new Set(this[m]))e.dispose();this[c]?.clear(),this[u]?.clear(),this[p]?.clear(),this[g]?.clear(),this[f]?.clear(),this[m]?.clear(),this[A]?.clear(),n.A.prototype.dispose.call(this)}});for(const e of Object.keys(x.prototype))Object.defineProperty(x.prototype,e,{enumerable:!1});const w=x,b=a.A.add("X3DField",w)},225:(e,t,i)=>{"use strict";i.d(t,{A:()=>l});var n=i(37),s=i(7204),r=i(1510);function o(e=[]){return n.A.call(this,Array.from(e,(e=>[e.getNodeName(),e])),s.A)}Object.setPrototypeOf(o.prototype,n.A.prototype);for(const e of Object.keys(o.prototype))Object.defineProperty(o.prototype,e,{enumerable:!1});Object.defineProperties(o,{typeName:{value:"NamedNodesArray",enumerable:!0}});const a=o,l=r.A.add("NamedNodesArray",a)},254:(e,t,i)=>{"use strict";i.d(t,{A:()=>p});var n=i(2844),s=i(9281),r=i(1715),o=i(7693),a=i(8431),l=i(8041),h=i(5835),d=i(1510);function c(e){a.A.call(this,e),this.addType(l.A.OrientationInterpolator),this._keyValue.setUnit("angle"),this._value_changed.setUnit("angle")}Object.assign(Object.setPrototypeOf(c.prototype,a.A.prototype),{initialize(){a.A.prototype.initialize.call(this),this._keyValue.addInterest("set_keyValue__",this)},set_keyValue__(){const e=this._key,t=this._keyValue;t.length<e.length&&t.resize(e.length,t.length?t[t.length-1]:new n.A.SFRotation)},interpolate:(()=>{const e=new h.A,t=new h.A;return function(i,n,s){e.assign(this._keyValue[i].getValue()),t.assign(this._keyValue[n].getValue()),this._value_changed=e.slerp(t,s)}})()}),Object.defineProperties(c,{...o.A.getStaticProperties("OrientationInterpolator","Interpolation",1,"children","2.0"),fieldDefinitions:{value:new r.A([new s.A(l.A.inputOutput,"metadata",new n.A.SFNode),new s.A(l.A.inputOnly,"set_fraction",new n.A.SFFloat),new s.A(l.A.inputOutput,"key",new n.A.MFFloat),new s.A(l.A.inputOutput,"keyValue",new n.A.MFRotation),new s.A(l.A.outputOnly,"value_changed",new n.A.SFRotation)]),enumerable:!0}});const u=c,p=d.A.add("OrientationInterpolator",u)},408:(e,t,i)=>{"use strict";i.d(t,{A:()=>x});var n=i(4961),s=i(8041),r=i(7888),o=i(7693),a=i(8573),l=i(1510),h=i(4688);const d=Symbol(),c=Symbol(),u=Symbol(),p=Symbol(),g=Symbol(),f=Symbol(),m=Symbol(),A=Symbol();function _(e,t,i,s,r){n.A.call(this,e),this[d]=e,this[c]=t,this[u]=i,this[g]=s,this[f]=r,t instanceof a.A&&t.getInlineNode().getLoadState().addInterest("reconnect",this),s instanceof a.A&&s.getInlineNode().getLoadState().addInterest("reconnect",this),this.reconnect()}Object.assign(Object.setPrototypeOf(_.prototype,n.A.prototype),{getExecutionContext(){return this[d]},getRouteId(){return _.getRouteId(this[c],this[u],this[g],this[f])},getSourceNode(){return this[c]},getSourceField(){return this[p]?this[p].getAccessType()===s.A.inputOutput?this[p].getName()+"_changed":this[p].getName():this[u]},getDestinationNode(){return this[g]},getDestinationField(){return this[m]?this[m].getAccessType()===s.A.inputOutput?"set_"+this[m].getName():this[m].getName():this[f]},reconnect(){try{this.disconnect(),this.connect()}catch(e){(this[c]instanceof o.A||this[c].getInlineNode().checkLoadState()===s.A.COMPLETE_STATE)&&(this[g]instanceof o.A||this[g].getInlineNode().checkLoadState()===s.A.COMPLETE_STATE)&&console.warn(e.message)}},connect(){if(!this[A]){try{const e=this[c]instanceof o.A?this[c]:this[c].getExportedNode();this[p]=e.getField(this[u])}catch(t){var e=t}try{const e=this[g]instanceof o.A?this[g]:this[g].getExportedNode();this[m]=e.getField(this[f])}catch(e){var t=e}if(!this[p]||!this[m])throw e??t;if(this[p].getType()!==this[m].getType())throw new Error(`Bad ROUTE statement: Source field type must match destination field type of fields named "${this[p].getName()}" and "${this[m].getName()}".`);if(!this[p].isOutput())throw new Error(`Bad ROUTE statement: Source field "${this[p].getName()}" must be an output.`);if(!this[m].isInput())throw new Error(`Bad ROUTE statement: Destination field "${this[m].getName()}" must be an input.`);this[p].addOutputRoute(this),this[m].addInputRoute(this),this[p].addFieldInterest(this[m])}},disconnect(){this[p]?.removeOutputRoute(this),this[m]?.removeInputRoute(this),this[p]&&this[m]&&this[p].removeFieldInterest(this[m]),this[p]=null,this[m]=null},toVRMLStream(e){if(!e.ExistsRouteNode(this[c]))throw new Error("Source node does not exist in scene graph.");if(!e.ExistsRouteNode(this[g]))throw new Error("Destination node does not exist in scene graph.");const t=this[c]instanceof o.A?e.Name(this[c]):e.ImportedName(this[c]),i=this[g]instanceof o.A?e.Name(this[g]):e.ImportedName(this[g]);e.string+=e.Indent(),e.string+="ROUTE",e.string+=e.Space(),e.string+=t,e.string+=".",e.string+=this.getSourceField(),e.string+=e.Space(),e.string+="TO",e.string+=e.Space(),e.string+=i,e.string+=".",e.string+=this.getDestinationField()},toXMLStream(e){if(!e.ExistsRouteNode(this[c]))throw new Error("Source node does not exist in scene graph.");if(!e.ExistsRouteNode(this[g]))throw new Error("Destination node does not exist in scene graph.");const t=this[c]instanceof o.A?e.Name(this[c]):e.ImportedName(this[c]),i=this[g]instanceof o.A?e.Name(this[g]):e.ImportedName(this[g]);e.string+=e.Indent(),e.string+="<ROUTE",e.string+=e.Space(),e.string+="fromNode='",e.string+=e.XMLEncode(t),e.string+="'",e.string+=e.Space(),e.string+="fromField='",e.string+=e.XMLEncode(this.getSourceField()),e.string+="'",e.string+=e.Space(),e.string+="toNode='",e.string+=e.XMLEncode(i),e.string+="'",e.string+=e.Space(),e.string+="toField='",e.string+=e.XMLEncode(this.getDestinationField()),e.string+="'",e.string+=e.closingTags?"></ROUTE>":"/>"},toJSONStream(e){if(!e.ExistsRouteNode(this[c]))throw new Error("Source node does not exist in scene graph.");if(!e.ExistsRouteNode(this[g]))throw new Error("Destination node does not exist in scene graph.");const t=this[c]instanceof o.A?e.Name(this[c]):e.ImportedName(this[c]),i=this[g]instanceof o.A?e.Name(this[g]):e.ImportedName(this[g]);e.string+=e.Indent(),e.string+="{",e.string+=e.TidySpace(),e.string+='"',e.string+="ROUTE",e.string+='"',e.string+=":",e.string+=e.TidyBreak(),e.string+=e.IncIndent(),e.string+=e.Indent(),e.string+="{",e.string+=e.TidyBreak(),e.string+=e.IncIndent(),e.string+=e.Indent(),e.string+='"',e.string+="@fromNode",e.string+='"',e.string+=":",e.string+=e.TidySpace(),e.string+='"',e.string+=e.JSONEncode(t),e.string+='"',e.string+=",",e.string+=e.TidyBreak(),e.string+=e.Indent(),e.string+='"',e.string+="@fromField",e.string+='"',e.string+=":",e.string+=e.TidySpace(),e.string+='"',e.string+=e.JSONEncode(this.getSourceField()),e.string+='"',e.string+=",",e.string+=e.TidyBreak(),e.string+=e.Indent(),e.string+='"',e.string+="@toNode",e.string+='"',e.string+=":",e.string+=e.TidySpace(),e.string+='"',e.string+=e.JSONEncode(i),e.string+='"',e.string+=",",e.string+=e.TidyBreak(),e.string+=e.Indent(),e.string+='"',e.string+="@toField",e.string+='"',e.string+=":",e.string+=e.TidySpace(),e.string+='"',e.string+=e.JSONEncode(this.getDestinationField()),e.string+='"',e.string+=e.TidyBreak(),e.string+=e.DecIndent(),e.string+=e.Indent(),e.string+="}",e.string+=e.TidyBreak(),e.string+=e.DecIndent(),e.string+=e.Indent(),e.string+="}"},dispose(){this[A]||(this[A]=!0,this.disconnect(),this[c]instanceof a.A&&this[c].getInlineNode().getLoadState().removeInterest("reconnect",this),this[g]instanceof a.A&&this[g].getInlineNode().getLoadState().removeInterest("reconnect",this),this[d].deleteRoute(this),n.A.prototype.dispose.call(this))}});for(const e of Object.keys(_.prototype))Object.defineProperty(_.prototype,e,{enumerable:!1});Object.defineProperties(_.prototype,{sourceNode:{get(){return this[c]instanceof o.A?r.A.get(this[c]):this[c]},enumerable:!0},sourceField:{get:_.prototype.getSourceField,enumerable:!0},destinationNode:{get(){return this[g]instanceof o.A?r.A.get(this[g]):this[g]},enumerable:!0},destinationField:{get:_.prototype.getDestinationField,enumerable:!0}}),Object.defineProperties(_,{typeName:{value:"X3DRoute",enumerable:!0}}),Object.assign(_,{getRouteId(e,t,i,n){const r=e instanceof o.A?e.getField(t):h.try((()=>e.getExportedNode().getField(t))),a=i instanceof o.A?i.getField(n):h.try((()=>i.getExportedNode().getField(n)));return r&&(t=r.getName(),r.getAccessType()===s.A.inputOutput&&(t+="_changed")),a&&(n=a.getName(),a.getAccessType()===s.A.inputOutput&&(n="set_"+n)),`${e.getId()}.${t}.${i.getId()}.${n}`}});const y=_,x=l.A.add("X3DRoute",y)},442:(e,t,i)=>{"use strict";i.d(t,{A:()=>l});var n=i(37),s=i(408),r=i(1510);function o(e=[]){return n.A.call(this,Array.from(e,(e=>[e.getId(),e])),s.A)}Object.setPrototypeOf(o.prototype,n.A.prototype);for(const e of Object.keys(o.prototype))Object.defineProperty(o.prototype,e,{enumerable:!1});Object.defineProperties(o,{typeName:{value:"RouteArray",enumerable:!0}});const a=o,l=r.A.add("RouteArray",a)},591:(e,t,i)=>{"use strict";i.d(t,{A:()=>o});var n=i(1510);function s(e){this.gl=e,this.vertexArrays=new Map}Object.assign(s.prototype,{update(e=!0){return e&&this.dispose(),this},enable(e){const{gl:t,vertexArrays:i}=this,n=i.get(e);if(n)return t.bindVertexArray(n),!1;{i.size>100&&this.dispose();const n=t.createVertexArray();return i.set(e,n),t.bindVertexArray(n),!0}},dispose(){const{gl:e,vertexArrays:t}=this;for(const i of t.values())e.deleteVertexArray(i);t.clear()}});const r=s,o=n.A.add("VertexArray",r)},659:(e,t,i)=>{"use strict";i.d(t,{A:()=>d});var n=i(2844),s=i(7693),r=i(8895),o=i(8041),a=i(1510);function l(e){this.addType(o.A.X3DTimeDependentNode),this.addChildObjects(o.A.outputOnly,"initialized",new n.A.SFTime,o.A.inputOutput,"isEvenLive",new n.A.SFBool),this.startTimeValue=0,this.pauseTimeValue=0,this.resumeTimeValue=0,this.stopTimeValue=0,this.start=0,this.pause=0,this.pauseInterval=0,this.timeouts=new Map,this.disabled=!1}Object.assign(Object.setPrototypeOf(l.prototype,r.A.prototype),{initialize(){this.getLive().addInterest("set_live__",this),this._isEvenLive.addInterest(Symbol.for("X_ITE.X3DBaseNode.set_live__"),this),this._initialized.addInterest("set_loop__",this),this._enabled.addInterest("set_enabled__",this),this._loop.addInterest("set_loop__",this),this._startTime.addInterest("set_startTime__",this),this._pauseTime.addInterest("set_pauseTime__",this),this._resumeTime.addInterest("set_resumeTime__",this),this._stopTime.addInterest("set_stopTime__",this),this.startTimeValue=this._startTime.getValue(),this.pauseTimeValue=this._pauseTime.getValue(),this.resumeTimeValue=this._resumeTime.getValue(),this.stopTimeValue=this._stopTime.getValue(),this._initialized=this.getBrowser().getCurrentTime()},checkLiveState(){return this.isLive()&&(this.getExecutionContext().getLive().getValue()||this._isEvenLive.getValue())},getElapsedTime(){return this.getBrowser().getCurrentTime()-this.start-this.pauseInterval},resetElapsedTime(){this.start=this.getBrowser().getCurrentTime(),this.pause=this.getBrowser().getCurrentTime(),this.pauseInterval=0},set_live__(){this.getLive().getValue()?this.disabled&&(this.disabled=!1,this._isActive.getValue()&&!this._isPaused.getValue()&&this.real_resume()):this.disabled||!this._isActive.getValue()||this._isPaused.getValue()||(this.disabled=!0,this.real_pause())},set_enabled__(){this._enabled.getValue()?this.set_loop__():this.stop()},set_loop__(){this._enabled.getValue()&&this._loop.getValue()&&this.stopTimeValue<=this.startTimeValue&&this.startTimeValue<=this.getBrowser().getCurrentTime()&&this.do_start(),this.set_loop()},set_startTime__(){this.startTimeValue=this._startTime.getValue(),this._enabled.getValue()&&(this.removeTimeout("start"),this.startTimeValue<=this.getBrowser().getCurrentTime()?this.do_start():this.addTimeout("start","do_start",this.startTimeValue))},set_pauseTime__(){if(this.pauseTimeValue=this._pauseTime.getValue(),this._enabled.getValue()){if(this.removeTimeout("pause"),this.pauseTimeValue<=this.resumeTimeValue)return;this.pauseTimeValue<=this.getBrowser().getCurrentTime()?this.do_pause():this.addTimeout("pause","do_pause",this.pauseTimeValue)}},set_resumeTime__(){if(this.resumeTimeValue=this._resumeTime.getValue(),this._enabled.getValue()){if(this.removeTimeout("resume"),this.resumeTimeValue<=this.pauseTimeValue)return;this.resumeTimeValue<=this.getBrowser().getCurrentTime()?this.do_resume():this.addTimeout("resume","do_resume",this.resumeTimeValue)}},set_stopTime__(){if(this.stopTimeValue=this._stopTime.getValue(),this._enabled.getValue()){if(this.removeTimeout("stop"),this.stopTimeValue<=this.startTimeValue)return;this.stopTimeValue<=this.getBrowser().getCurrentTime()?this.do_stop():this.addTimeout("stop","do_stop",this.stopTimeValue)}},do_start(){this._isActive.getValue()||(this.resetElapsedTime(),this._isActive=!0,this._elapsedTime=0,this.set_start(),this.getLive().getValue()?this.getBrowser().timeEvents().addInterest("set_time",this):(this.disabled=!0,this.real_pause()))},do_pause(){this._isActive.getValue()&&!this._isPaused.getValue()&&(this._isPaused=!0,this.getLive().getValue()&&this.real_pause())},real_pause(){this.pause=Date.now()/1e3,this.set_pause(),this.getBrowser().timeEvents().removeInterest("set_time",this)},do_resume(){this._isActive.getValue()&&this._isPaused.getValue()&&(this._isPaused=!1,this.getLive().getValue()&&this.real_resume())},real_resume(){const e=Date.now()/1e3-this.pause;this.pauseInterval+=e,this.set_resume(e),this.getBrowser().timeEvents().addInterest("set_time",this),this.getBrowser().addBrowserEvent()},do_stop(){this.stop()},stop(){this._isActive.getValue()&&(this.set_stop(),this._elapsedTime=this.getElapsedTime(),this._isPaused.getValue()&&(this._isPaused=!1),this._isActive=!1,this.getBrowser().timeEvents().removeInterest("set_time",this))},addTimeout(e,t,i){this.removeTimeout(e),this.timeouts.set(e,setTimeout(this.processTimeout.bind(this,t),1e3*(i-this.getBrowser().getCurrentTime())))},removeTimeout(e){clearTimeout(this.timeouts.get(e)),this.timeouts.delete(e)},processTimeout(e){this._enabled.getValue()&&this.getLive().getValue()&&(this.getBrowser().advanceTime(),this[e]())},set_loop:Function.prototype,set_start:Function.prototype,set_pause:Function.prototype,set_resume:Function.prototype,set_stop:Function.prototype,set_time:Function.prototype,dispose(){for(const e of[...this.timeouts.keys()])this.removeTimeout(e)}}),Object.defineProperties(l,s.A.getStaticProperties("X3DTimeDependentNode","Time",1));const h=l,d=a.A.add("X3DTimeDependentNode",h)},851:(e,t,i)=>{"use strict";i.d(t,{A:()=>l});var n=i(1510);const s=[],r=[],o=[];const a=function(e,t){const i=e.order,n=e.length,a=t.values,l=t.vectors;let h,d,c,u,p,g,f,m,A,_,y,x,w;for(x=0;x<i;++x)for(s[x]=s[x]??[],r[x]=a[x]=e.get1(x,x),o[x]=0,w=0;w<i;++w)l[x][w]=x===w?1:0,s[x][w]=e.get1(w,x);for(x=0;x<50;++x){for(h=0,_=0;_<i-1;++_)for(y=_+1;y<i;++y)h+=Math.abs(s[_][y]);if(0===h)break;for(A=x<3?.2*h/n:0,_=0;_<i-1;++_)for(y=_+1;y<i;++y)if(m=100*Math.abs(s[_][y]),x>3&&Math.abs(a[_])+m===Math.abs(a[_])&&Math.abs(a[y])+m===Math.abs(a[y]))s[_][y]=0;else if(Math.abs(s[_][y])>A){for(f=a[y]-a[_],Math.abs(f)+m===Math.abs(f)?p=s[_][y]/f:(d=.5*f/s[_][y],p=1/(Math.abs(d)+Math.sqrt(1+d*d)),d<0&&(p=-p)),c=1/Math.sqrt(1+p*p),u=p*c,g=u/(1+c),f=p*s[_][y],o[_]-=f,o[y]+=f,a[_]-=f,a[y]+=f,s[_][y]=0,w=0;w<_;++w)m=s[w][_],f=s[w][y],s[w][_]=m-u*(f+m*g),s[w][y]=f+u*(m-f*g);for(w=_+1;w<y;++w)m=s[_][w],f=s[w][y],s[_][w]=m-u*(f+m*g),s[w][y]=f+u*(m-f*g);for(w=y+1;w<i;++w)m=s[_][w],f=s[y][w],s[_][w]=m-u*(f+m*g),s[y][w]=f+u*(m-f*g);for(w=0;w<i;++w)m=l[w][_],f=l[w][y],l[w][_]=m-u*(f+m*g),l[w][y]=f+u*(m-f*g)}for(_=0;_<i;++_)a[_]=r[_]+=o[_],o[_]=0}return t},l=n.A.add("eigen_decomposition",a)},921:(e,t,i)=>{"use strict";i.d(t,{A:()=>u});var n=i(7204),s=i(2112),r=i(9287),o=i(5471),a=i(2589),l=i(8041),h=i(1510);function d(e){s.A.call(this,e),this.addType(l.A.X3DWorld),this.addChildObjects(l.A.outputOnly,"activeLayer",new n.A(this.layer0)),this.defaultLayerSet=new r.A(e),this.layerSet=this.defaultLayerSet,this.layer0=new o.A(e)}Object.assign(Object.setPrototypeOf(d.prototype,s.A.prototype),{initialize(){s.A.prototype.initialize.call(this),this.layerSet.setPrivate(!0),this.layerSet.setup(),this.layerSet.setLayer0(this.layer0),this.layerSet._activeLayer.addInterest("set_rootNodes__",this),this.getExecutionContext().getRootNodes().addInterest("set_rootNodes__",this),this.set_rootNodes__(),this.layer0.setPrivate(!0),this.layer0.setLayer0(!0),this.layer0.setup(),this.set_activeLayer__()},getCache(){return this.getBrowser().getBrowserOption("Cache")},getLayerSet(){return this.layerSet},getActiveLayer(){return this._activeLayer.getValue()},getLayer0(){return this.layer0},set_rootNodes__(){const e=this.layerSet,t=this.getExecutionContext().getRootNodes();this.layerSet=this.defaultLayerSet,this.layer0._children=t;for(const e of t){const t=(0,a.A)(l.A.LayerSet,e);t&&(this.layerSet=t)}this.layerSet!==e&&(this.layerSet.setLayer0(this.layer0),e._activeLayerNode.removeInterest("set_activeLayer__",this),this.layerSet._activeLayerNode.addInterest("set_activeLayer__",this),this.set_activeLayer__())},set_activeLayer__(){this._activeLayer=this.layerSet.getActiveLayer()},bindBindables(){const e=this.getExecutionContext().getWorldURL();this.layerSet.bindBindables(decodeURIComponent(new URL(e).hash.substring(1)))},traverse(e,t){this.layerSet.traverse(e,t)}});for(const e of Object.keys(d.prototype))Object.defineProperty(d.prototype,e,{enumerable:!1});Object.defineProperties(d,{typeName:{value:"X3DWorld",enumerable:!0}}),l.A.addConstant(d.typeName);const c=d,u=h.A.add("X3DWorld",c)},1100:(e,t,i)=>{"use strict";i.d(t,{A:()=>r});let n=0;const s={POINT:n++,WIREFRAME:n++,FLAT:n++,GOURAUD:n++,PHONG:n++},r=i(1510).A.add("Shading",s)},1189:(e,t,i)=>{"use strict";i.d(t,{A:()=>s});const n=function(e){return Object.assign([],{top:0,pop(){return 0!==this.top?this[--this.top]:new e},push(e){this[this.top++]=e},clear(){this.length=0,this.top=0}})},s=i(1510).A.add("ObjectCache",n)},1287:(e,t,i)=>{"use strict";i.d(t,{A:()=>c});var n=i(2844),s=i(2112),r=i(2900),o=i(7888),a=i(8041),l=i(1510);function h(e){s.A.call(this,e),this.addType(a.A.X3DProtoDeclarationNode),this.addChildObjects(a.A.outputOnly,"updateInstances",new n.A.SFTime)}Object.assign(Object.setPrototypeOf(h.prototype,s.A.prototype),{canUserDefinedFields:()=>!0,createInstance(e,t=!0){if(!1===t)return new r.A(e,this);{const t=new r.A(e,this);return t.setup(),o.A.get(t)}},newInstance(){return this.createInstance(this.getExecutionContext())},requestUpdateInstances(){this._updateInstances=this.getBrowser().getCurrentTime()},updateInstances(){this._updateInstances.processEvent()}});for(const e of Object.keys(h.prototype))Object.defineProperty(h.prototype,e,{enumerable:!1});Object.defineProperties(h,{typeName:{value:"X3DProtoDeclarationNode",enumerable:!0}}),a.A.addConstant(h.typeName);const d=h,c=l.A.add("X3DProtoDeclarationNode",d)},1301:(e,t,i)=>{"use strict";i.d(t,{A:()=>T});var n=i(7163),s=i(9812),r=i(2844),o=i(216),a=i(7245),l=i(2947),h=i(8041),d=i(5357),c=i(4504),u=i(2798),p=i(8074),g=i(5835),f=i(7186),m=i(4817),A=i(9748),_=i(7166),y=i(1510),x=i(4688);const w=(0,s.A)({Whitespaces:/[\x20\n,\t\r]+/gy,Comment:/#\/\*[\s\S]*?\*\/#|#.*?(?=[\n\r]|$)/gy,Comment3_2:/#.*?(?=[\n\r]|$)/gy,Break:/\r?\n/g,Header:/^#(VRML|X3D) V(.*?) (utf8)(?:[ \t]+(.*?))?[ \t]*[\n\r]/gy,AS:/AS/gy,COMPONENT:/COMPONENT/gy,DEF:/DEF/gy,EXPORT:/EXPORT/gy,EXTERNPROTO:/EXTERNPROTO/gy,FALSE:/FALSE|false/gy,IMPORT:/IMPORT/gy,IS:/IS/gy,META:/META/gy,NULL:/NULL/gy,TRUE:/TRUE|true/gy,PROFILE:/PROFILE/gy,PROTO:/PROTO/gy,ROUTE:/ROUTE/gy,TO:/TO/gy,UNIT:/UNIT/gy,USE:/USE/gy,OpenBrace:/\{/gy,CloseBrace:/\}/gy,OpenBracket:/\[/gy,CloseBracket:/\]/gy,Period:/\./gy,Colon:/\:/gy,Id:/[^\x30-\x39\x00-\x20\x22\x23\x27\x2b\x2c\x2d\x2e\x5b\x5c\x5d\x7b\x7d\x7f]{1}[^\x00-\x20\x22\x23\x27\x2c\x2e\x5b\x5c\x5d\x7b\x7d\x7f]*/gy,ComponentNameId:/[^\x30-\x39\x00-\x20\x22\x23\x27\x2b\x2c\x2d\x2e\x5b\x5c\x5d\x7b\x7d\x7f\x3a]{1}[^\x00-\x20\x22\x23\x27\x2c\x2e\x5b\x5c\x5d\x7b\x7d\x7f\x3a]*/gy,initializeOnly:/initializeOnly/gy,inputOnly:/inputOnly/gy,outputOnly:/outputOnly/gy,inputOutput:/inputOutput/gy,field:/field/gy,eventIn:/eventIn/gy,eventOut:/eventOut/gy,exposedField:/exposedField/gy,FieldType:/[SM]F(?:Bool|ColorRGBA|Color|Double|Float|Image|Int32|Matrix3d|Matrix3f|Matrix4d|Matrix4f|Node|Rotation|String|Time|Vec2d|Vec2f|Vec3d|Vec3f|Vec4d|Vec4f)/gy,int32:/(?:0[xX][\da-fA-F]+)|(?:[+-]?\d+)/gy,double:/[+-]?(?:(?:(?:\d*\.\d+)|(?:\d+(?:\.)?))(?:[eE][+-]?\d+)?)/gy,doubleQuotes:/"/gy,noDoubleQuotes:/[^"]+/gy,CONSTANTS:/([+-]?)\b(NAN|INFINITY|INF|PI|PI2|PI1_4|PI2_4|PI3_4|PI4_4|PI5_4|PI6_4|PI7_4|PI8_4|PI1_2|PI2_2|PI3_2|PI4_2|PI1_3|PI2_3|PI3_3|PI4_3|PI5_3|PI6_3|SQRT1_2|SQRT2)\b/giy,HTMLColor:/[a-zA-Z]+|0[xX][\da-fA-F]+|rgba?\(.*?\)/gy});function b(e){n.A.call(this,e),this.Grammar={Comment:w.Comment}}Object.assign(Object.setPrototypeOf(b.prototype,n.A.prototype),{accessTypes:{field:h.A.initializeOnly,eventIn:h.A.inputOnly,eventOut:h.A.outputOnly,exposedField:h.A.inputOutput,initializeOnly:h.A.initializeOnly,inputOnly:h.A.inputOnly,outputOnly:h.A.outputOnly,inputOutput:h.A.inputOutput},SFImage:new r.A.SFImage,SFNode:new r.A.SFNode,MFString:new r.A.MFString,Color3:new d.A,Color4:new c.A,Matrix3:new u.A,Matrix4:new p.A,Rotation4:new g.A,Vector2:new f.A,Vector3:new m.A,Vector4:new A.A,CONSTANTS:{NAN:Number.NaN,INFINITY:Number.POSITIVE_INFINITY,INF:Number.POSITIVE_INFINITY,PI:Math.PI,PI2:2*Math.PI,PI1_4:1*Math.PI/4,PI2_4:2*Math.PI/4,PI3_4:3*Math.PI/4,PI4_4:4*Math.PI/4,PI5_4:5*Math.PI/4,PI6_4:6*Math.PI/4,PI7_4:7*Math.PI/4,PI8_4:8*Math.PI/4,PI1_2:1*Math.PI/2,PI2_2:2*Math.PI/2,PI3_2:3*Math.PI/2,PI4_2:4*Math.PI/2,PI1_3:1*Math.PI/3,PI2_3:2*Math.PI/3,PI3_3:3*Math.PI/3,PI4_3:4*Math.PI/3,PI5_3:5*Math.PI/3,PI6_3:6*Math.PI/3,SQRT1_2:Math.SQRT1_2,SQRT2:Math.SQRT2},unknownLevel:0,getEncoding:()=>"STRING",setInput(e){this.input=e,this.lineNumber=1,this.lastIndex=0},isValid(){return"string"==typeof this.input&&!!this.input.match(/^(?:#X3D|#VRML|(?:[\x20\n,\t\r]*|#.*?[\r\n])*(PROFILE|COMPONENT|META|UNIT|EXTERNPROTO|PROTO|DEF|NULL|IMPORT|EXPORT|ROUTE|\w+(?:[\x20\n,\t\r]*|#.*?[\r\n])\{|$))/)},parseIntoScene(e,t){try{this.resolve=e,this.reject=t,this.getScene().setEncoding("VRML"),this.getScene().setProfile(this.getBrowser().getProfile("Full")),this.x3dScene()}catch(e){throw new Error(this.getError(e))}},getError(e){_.A&&console.error(e);const t=e.message,i=this.lastIndex===this.input.length?"Unexpected end of file. ":"";let n=this.getLine(),s=this.getLastLine(),r=this.getLastLine(),o=s.length-n.length+1;s.length>80&&(s=s.substring(o-40,o+40),r="",o=40);let a=this.getExecutionContext().getWorldURL();a.startsWith("data:")&&(a=a.substring(0,a.indexOf(",")));return`\n********************************************************************************\nParser error at line ${this.lineNumber}:${o}\nin '${a}'\n\n${r}\n${s}\n${Array(o).join(" ")}^\n${i}${t}\n********************************************************************************\n`},getLine(){let e=this.input,t=this.lastIndex,i="";for(;t<e.length&&"\n"!==e[t]&&"\r"!==e[t];)i+=e[t++];return this.lastIndex=t,i},getLastLine(){let e=this.input,t=Math.min(this.lastIndex,this.input.length-1),i="";for(t<e.length&&("\n"!==e[t]||"\r"!==e[t])&&--t;t>=0&&"\n"!==e[t]&&"\r"!==e[t];)i=e[t--]+i;return this.lastIndex=t,i},comments(){for(;this.comment(););},comment(){return!!this.whitespaces()||this.Grammar.Comment.parse(this)},whitespaces(){return!!w.Whitespaces.parse(this)&&(this.lines(this.result[0]),!0)},lines(e){const t=e.match(w.Break);t&&(this.lineNumber+=t.length)},x3dScene:(()=>{const e=["EnvironmentalSensor","PointingDeviceSensor","Scripting","Sound","Text"];return function(){const t=this.getBrowser(),i=this.getScene();if(this.headerStatement(),this.profileStatement(),this.componentStatements(),this.unitStatements(),this.metaStatements(),"2.0"===i.getSpecificationVersion()){i.setProfile(t.getProfile("Interchange"));for(const n of e)i.updateComponent(t.getComponent(n))}if(this.resolve)t.loadComponents(i).then((()=>{try{if(this.statements(this.getExecutionContext().rootNodes),this.lastIndex<this.input.length)throw new Error("Unknown statement.");this.resolve(i)}catch(e){throw new Error(this.getError(e))}})).catch(this.reject);else if(this.statements(this.getExecutionContext().rootNodes),this.lastIndex<this.input.length)throw new Error("Unknown statement.")}})(),headerStatement(){return!!w.Header.parse(this)&&(this.getScene().setSpecificationVersion(this.result[2]),this.getScene().getSpecificationVersion()<=3.2&&(this.Grammar.Comment=w.Comment3_2),!0)},profileStatement(){if(this.comments(),w.PROFILE.parse(this)){if(this.profileNameId()){const e=this.getBrowser().getProfile(this.result[0]);return void this.getScene().setProfile(e)}throw new Error("Expected a profile name.")}},componentStatements(){let e;for(;e=this.componentStatement();)this.getScene().updateComponent(e)},componentStatement(){if(this.comments(),w.COMPONENT.parse(this)){if(this.componentNameId()){const e=this.result[0];if(this.comments(),w.Colon.parse(this)){if(this.componentSupportLevel()){const t=this.value;return this.getBrowser().getComponent(e,t)}throw new Error("Expected a component support level.")}throw new Error("Expected a ':' after component name.")}throw new Error("Expected a component name.")}return null},componentSupportLevel(){return this.int32()},unitStatements(){for(;this.unitStatement(););},unitStatement(){if(this.comments(),w.UNIT.parse(this)){if(this.categoryNameId()){const e=this.result[0];if(this.unitNameId()){const t=this.result[0];if(this.unitConversionFactor()){const i=this.value;try{return this.getScene().updateUnit(e,t,i),!0}catch(e){return console.warn(`Parser error at line ${this.lineNumber}: ${e.message}`),!0}}throw new Error("Expected unit conversion factor.")}throw new Error("Expected unit name identifier.")}throw new Error("Expected category name identifier after UNIT statement.")}return!1},unitConversionFactor(){return this.double()},metaStatements(){for(;this.metaStatement(););},metaStatement(){if(this.comments(),w.META.parse(this)){if(this.metaKey()){const e=this.value;if(this.metaValue()){const t=this.value;return this.getScene().addMetaData(e,t),!0}throw new Error("Expected metadata value.")}throw new Error("Expected metadata key.")}return!1},metaKey(){return this.string()},metaValue(){return this.string()},exportStatement(){if(this.comments(),w.EXPORT.parse(this)){if(this.nodeNameId()){const t=this.result[0];this.comments();const i=this.getScene().getLocalNode(t);if(w.AS.parse(this)){if(!this.exportedNodeNameId())throw new Error("No name given after AS.");var e=this.result[0]}else e=t;try{const t=this.getScene().getExportedNode(e);this.getScene().addExportedNode(this.getScene().getUniqueExportName(e),t)}catch{}return this.getScene().updateExportedNode(e,i),!0}throw new Error("No name given after EXPORT.")}return!1},importStatement(){if(this.comments(),w.IMPORT.parse(this)){if(this.nodeNameId()){const t=this.result[0],i=this.getExecutionContext().getNamedNode(t);if(this.comments(),w.Period.parse(this)){if(this.exportedNodeNameId()){const t=this.result[0];if(this.comments(),w.AS.parse(this)){if(!this.nodeNameId())throw new Error("No name given after AS.");var e=this.result[0]}else e=t;return this.renameExistingNode(e),this.getExecutionContext().addImportedNode(i,t,e),!0}throw new Error("Expected exported node name.")}throw new Error("Expected a '.' after exported node name.")}throw new Error("No name given after IMPORT statement.")}return!1},statements(e){for(;this.statement(e););},statement(e){if(this.protoStatement())return!0;if(this.routeStatement())return!0;if(this.importStatement())return!0;if(this.exportStatement())return!0;const t=this.nodeStatement();return!1!==t&&(e.push(t),!0)},nodeStatement(){if(this.comments(),w.DEF.parse(this)){if(this.nodeNameId())return this.node(this.result[0]);throw new Error("No name given after DEF.")}if(w.USE.parse(this)){if(this.nodeNameId())return this.getExecutionContext().getNamedNode(this.result[0]).getValue();throw new Error("No name given after USE.")}return w.NULL.parse(this)?null:this.node("")},protoStatement(){return!!this.proto()||!!this.externproto()},protoStatements(){for(;this.protoStatement(););},proto(){if(this.comments(),w.PROTO.parse(this)){if(this.nodeTypeId()){const e=this.result[0];if(this.comments(),w.OpenBracket.parse(this)){const t=this.interfaceDeclarations();if(this.comments(),w.CloseBracket.parse(this)){if(this.comments(),w.OpenBrace.parse(this)){const i=new l.A(this.getExecutionContext());for(const e of t)i.addUserDefinedField(e.getAccessType(),e.getName(),e);if(this.pushExecutionContext(i.getBody()),this.protoBody(i.getBody().rootNodes),this.popExecutionContext(),this.comments(),w.CloseBrace.parse(this)){i.setup();try{const t=this.getExecutionContext().getProtoDeclaration(e);this.getExecutionContext().updateProtoDeclaration(this.getExecutionContext().getUniqueProtoName(e),t)}catch{}return this.getExecutionContext().updateProtoDeclaration(e,i),!0}throw new Error("Expected a '}' at the end of PROTO body.")}throw new Error("Expected a '{' at the beginning of PROTO body.")}throw new Error("Expected a ']' at the end of PROTO interface declaration.")}throw new Error("Expected a '[' at the beginning of PROTO interface declaration.")}throw new Error("Invalid PROTO definition name.")}return!1},protoBody(e){this.protoStatements();const t=this.rootNodeStatement();!1!==t&&e.push(t),this.statements(e)},rootNodeStatement(){if(this.comments(),w.DEF.parse(this)){if(this.nodeNameId()){const e=this.result[0],t=this.node(e);if(!1!==t)return t;throw new Error("Expected node type name after DEF.")}throw new Error("No name given after DEF.")}const e=this.node("");return!1!==e&&e},interfaceDeclarations(){const e=[];let t;for(;t=this.interfaceDeclaration();)e.push(t);return e},restrictedInterfaceDeclaration(){if(this.comments(),w.inputOnly.parse(this)||w.eventIn.parse(this)){if(this.fieldType()){const e=this.result[0];if(this.inputOnlyId()){const t=this.result[0],i=new r.A[e];return i.setAccessType(h.A.inputOnly),i.setName(t),i}throw new Error("Expected a name for field.")}throw this.Id(),new Error(`Unknown event or field type: '${this.result[0]}'.`)}if(w.outputOnly.parse(this)||w.eventOut.parse(this)){if(this.fieldType()){const e=this.result[0];if(this.outputOnlyId()){const t=this.result[0],i=new r.A[e];return i.setAccessType(h.A.outputOnly),i.setName(t),i}throw new Error("Expected a name for field.")}throw this.Id(),new Error(`Unknown event or field type: '${this.result[0]}'.`)}if(w.initializeOnly.parse(this)||w.field.parse(this)){if(this.fieldType()){const e=this.result[0];if(this.initializeOnlyId()){const t=this.result[0],i=new r.A[e];if(this.fieldValue(i))return i.setAccessType(h.A.initializeOnly),i.setName(t),i;throw new Error(`Couldn't read value for field '${t}'.`)}throw new Error("Expected a name for field.")}throw this.Id(),new Error(`Unknown event or field type: '${this.result[0]}'.`)}return null},interfaceDeclaration(){const e=this.restrictedInterfaceDeclaration();if(e)return e;if(this.comments(),w.inputOutput.parse(this)||w.exposedField.parse(this)){if(this.fieldType()){const e=this.result[0];if(this.inputOutputId()){const t=this.result[0],i=new r.A[e];if(this.fieldValue(i))return i.setAccessType(h.A.inputOutput),i.setName(t),i;throw new Error(`Couldn't read value for field '${t}'.`)}throw new Error("Expected a name for field.")}throw this.Id(),new Error(`Unknown event or field type: '${this.result[0]}'.`)}return null},externproto(){if(this.comments(),w.EXTERNPROTO.parse(this)){if(this.nodeTypeId()){const e=this.result[0];if(this.comments(),w.OpenBracket.parse(this)){const t=this.externInterfaceDeclarations();if(this.comments(),w.CloseBracket.parse(this)){if(this.URLList(this.MFString)){const i=new a.A(this.getExecutionContext(),this.MFString);for(const e of t)i.addUserDefinedField(e.getAccessType(),e.getName(),e);i.setup();try{const t=this.getExecutionContext().getExternProtoDeclaration(e);this.getExecutionContext().updateExternProtoDeclaration(this.getExecutionContext().getUniqueExternProtoName(e),t)}catch{}return this.getExecutionContext().updateExternProtoDeclaration(e,i),!0}throw new Error(`Expected a URL list after EXTERNPROTO interface declaration '${e}'.`)}throw new Error("Expected a ']' at the end of EXTERNPROTO interface declaration.")}throw new Error("Expected a '[' at the beginning of EXTERNPROTO interface declaration.")}throw new Error("Invalid EXTERNPROTO definition name.")}return!1},externInterfaceDeclarations(){const e=[];let t;for(;t=this.externInterfaceDeclaration();)e.push(t);return e},externInterfaceDeclaration(){if(this.comments(),w.inputOnly.parse(this)||w.eventIn.parse(this)){if(this.fieldType()){const e=this.result[0];if(this.inputOnlyId()){const t=this.result[0],i=new r.A[e];return i.setAccessType(h.A.inputOnly),i.setName(t),i}throw new Error("Expected a name for field.")}throw this.Id(),new Error(`Unknown event or field type: '${this.result[0]}'.`)}if(w.outputOnly.parse(this)||w.eventOut.parse(this)){if(this.fieldType()){const e=this.result[0];if(this.outputOnlyId()){const t=this.result[0],i=new r.A[e];return i.setAccessType(h.A.outputOnly),i.setName(t),i}throw new Error("Expected a name for field.")}throw this.Id(),new Error(`Unknown event or field type: '${this.result[0]}'.`)}if(w.initializeOnly.parse(this)||w.field.parse(this)){if(this.fieldType()){const e=this.result[0];if(this.initializeOnlyId()){const t=this.result[0],i=new r.A[e];return i.setAccessType(h.A.initializeOnly),i.setName(t),i}throw new Error("Expected a name for field.")}throw this.Id(),new Error(`Unknown event or field type: '${this.result[0]}'.`)}if(w.inputOutput.parse(this)||w.exposedField.parse(this)){if(this.fieldType()){const e=this.result[0];if(this.inputOutputId()){const t=this.result[0],i=new r.A[e];return i.setAccessType(h.A.inputOutput),i.setName(t),i}throw new Error("Expected a name for field.")}throw this.Id(),new Error(`Unknown event or field type: '${this.result[0]}'.`)}return null},URLList(e){return this.mfstringValue(e)},routeStatement(){if(this.comments(),w.ROUTE.parse(this)){if(this.nodeNameId()){const e=this.result[0],t=this.getExecutionContext().getLocalNode(e);if(this.comments(),w.Period.parse(this)){if(this.outputOnlyId()){const e=this.result[0];if(this.comments(),w.TO.parse(this)){if(this.nodeNameId()){const i=this.result[0],n=this.getExecutionContext().getLocalNode(i);if(this.comments(),w.Period.parse(this)){if(this.inputOnlyId())try{const i=this.result[0];return this.getExecutionContext().addRoute(t,e,n,i),!0}catch(e){return console.warn(`Parser error at line ${this.lineNumber}: ${e.message}`),!0}throw new Error("Bad ROUTE specification: Expected a field name.")}throw new Error("Bad ROUTE specification: Expected a '.' after node name.")}throw new Error("Bad ROUTE specification: Expected a node name.")}throw new Error("Bad ROUTE specification: Expected a 'TO'.")}throw new Error("Bad ROUTE specification: Expected a field name.")}throw new Error("Bad ROUTE specification: Expected a '.' after node name.")}throw new Error("Bad ROUTE specification: Expected a node name.")}return!1},node(e){if(this.nodeTypeId()){const t=this.result[0],i=this.getExecutionContext().createNode(t,!1)??this.getExecutionContext().createProto(t,!1);if(!i)return this.unknownLevel||console.warn(`Parser error at line ${this.lineNumber}: Unknown node type or proto '${t}', you probably have insufficient component/profile statements, and/or an inappropriate specification version.`),this.comments(),!(!w.OpenBrace.parse(this)||(++this.unknownLevel,this.nodeBody(this.getExecutionContext().createNode("MetadataBoolean",!1)),--this.unknownLevel,this.comments(),!w.CloseBrace.parse(this)))&&null;if(e.length&&(this.renameExistingNode(e),this.getExecutionContext().updateNamedNode(e,i)),this.comments(),w.OpenBrace.parse(this)){if(i.canUserDefinedFields()?this.scriptBody(i):this.nodeBody(i),this.comments(),w.CloseBrace.parse(this))return this.isInsideProtoDeclaration()||i.setup(),i;throw new Error("Expected '}' at the end of node body.")}throw new Error("Expected '{' at the beginning of node body.")}return!1},scriptBody(e){for(;this.scriptBodyElement(e););},scriptBodyElement(e){const t=this.lastIndex,i=this.lineNumber;if(this.Id()){const t=this.accessTypes[this.result[0]];i