-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp5xr.min.js
More file actions
7 lines (7 loc) · 70.6 KB
/
Copy pathp5xr.min.js
File metadata and controls
7 lines (7 loc) · 70.6 KB
1
2
3
4
5
6
7
(()=>{function t(t,e,n,i){Object.defineProperty(t,e,{get:n,set:i,enumerable:!0,configurable:!0})}var e={};Object.defineProperty(e,"__esModule",{value:!0});e.LEFT="left",e.RIGHT="right",e.AR="AR",e.VR="VR",e.AR_BUTTON="AR_BUTTON",e.VR_BUTTON="VR_BUTTON";var n=function(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=ln(e);if(n&&n.has(t))return n.get(t);var i={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if("default"!==o&&Object.prototype.hasOwnProperty.call(t,o)){var s=r?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(i,o,s):i[o]=t[o]}i.default=t,n&&n.set(t,i);return i}(e),i=function(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=on(e);if(n&&n.has(t))return n.get(t);var i={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if("default"!==o&&Object.prototype.hasOwnProperty.call(t,o)){var s=r?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(i,o,s):i[o]=t[o]}i.default=t,n&&n.set(t,i);return i}(e),r={};Object.defineProperty(r,"__esModule",{value:!0});var o={};t(o,"create",(()=>c)),t(o,"fromMat4",(()=>u)),t(o,"clone",(()=>l)),t(o,"copy",(()=>p)),t(o,"fromValues",(()=>d)),t(o,"set",(()=>f)),t(o,"identity",(()=>g)),t(o,"transpose",(()=>v)),t(o,"invert",(()=>m)),t(o,"adjoint",(()=>y)),t(o,"determinant",(()=>x)),t(o,"multiply",(()=>w)),t(o,"translate",(()=>M)),t(o,"rotate",(()=>_)),t(o,"scale",(()=>b)),t(o,"fromTranslation",(()=>S)),t(o,"fromRotation",(()=>R)),t(o,"fromScaling",(()=>T)),t(o,"fromMat2d",(()=>P)),t(o,"fromQuat",(()=>E)),t(o,"normalFromMat4",(()=>O)),t(o,"projection",(()=>z)),t(o,"str",(()=>C)),t(o,"frob",(()=>I)),t(o,"add",(()=>A)),t(o,"subtract",(()=>V)),t(o,"multiplyScalar",(()=>L)),t(o,"multiplyScalarAndAdd",(()=>N)),t(o,"exactEquals",(()=>q)),t(o,"equals",(()=>D)),t(o,"mul",(()=>F)),t(o,"sub",(()=>k));var s=1e-6,a="undefined"!=typeof Float32Array?Float32Array:Array,h=Math.random;Math.PI;function c(){var t=new a(9);return a!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function u(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}function l(t){var e=new a(9);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function p(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function d(t,e,n,i,r,o,s,h,c){var u=new a(9);return u[0]=t,u[1]=e,u[2]=n,u[3]=i,u[4]=r,u[5]=o,u[6]=s,u[7]=h,u[8]=c,u}function f(t,e,n,i,r,o,s,a,h,c){return t[0]=e,t[1]=n,t[2]=i,t[3]=r,t[4]=o,t[5]=s,t[6]=a,t[7]=h,t[8]=c,t}function g(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function v(t,e){if(t===e){var n=e[1],i=e[2],r=e[5];t[1]=e[3],t[2]=e[6],t[3]=n,t[5]=e[7],t[6]=i,t[7]=r}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}function m(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=e[4],a=e[5],h=e[6],c=e[7],u=e[8],l=u*s-a*c,p=-u*o+a*h,d=c*o-s*h,f=n*l+i*p+r*d;return f?(f=1/f,t[0]=l*f,t[1]=(-u*i+r*c)*f,t[2]=(a*i-r*s)*f,t[3]=p*f,t[4]=(u*n-r*h)*f,t[5]=(-a*n+r*o)*f,t[6]=d*f,t[7]=(-c*n+i*h)*f,t[8]=(s*n-i*o)*f,t):null}function y(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=e[4],a=e[5],h=e[6],c=e[7],u=e[8];return t[0]=s*u-a*c,t[1]=r*c-i*u,t[2]=i*a-r*s,t[3]=a*h-o*u,t[4]=n*u-r*h,t[5]=r*o-n*a,t[6]=o*c-s*h,t[7]=i*h-n*c,t[8]=n*s-i*o,t}function x(t){var e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],s=t[5],a=t[6],h=t[7],c=t[8];return e*(c*o-s*h)+n*(-c*r+s*a)+i*(h*r-o*a)}function w(t,e,n){var i=e[0],r=e[1],o=e[2],s=e[3],a=e[4],h=e[5],c=e[6],u=e[7],l=e[8],p=n[0],d=n[1],f=n[2],g=n[3],v=n[4],m=n[5],y=n[6],x=n[7],w=n[8];return t[0]=p*i+d*s+f*c,t[1]=p*r+d*a+f*u,t[2]=p*o+d*h+f*l,t[3]=g*i+v*s+m*c,t[4]=g*r+v*a+m*u,t[5]=g*o+v*h+m*l,t[6]=y*i+x*s+w*c,t[7]=y*r+x*a+w*u,t[8]=y*o+x*h+w*l,t}function M(t,e,n){var i=e[0],r=e[1],o=e[2],s=e[3],a=e[4],h=e[5],c=e[6],u=e[7],l=e[8],p=n[0],d=n[1];return t[0]=i,t[1]=r,t[2]=o,t[3]=s,t[4]=a,t[5]=h,t[6]=p*i+d*s+c,t[7]=p*r+d*a+u,t[8]=p*o+d*h+l,t}function _(t,e,n){var i=e[0],r=e[1],o=e[2],s=e[3],a=e[4],h=e[5],c=e[6],u=e[7],l=e[8],p=Math.sin(n),d=Math.cos(n);return t[0]=d*i+p*s,t[1]=d*r+p*a,t[2]=d*o+p*h,t[3]=d*s-p*i,t[4]=d*a-p*r,t[5]=d*h-p*o,t[6]=c,t[7]=u,t[8]=l,t}function b(t,e,n){var i=n[0],r=n[1];return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=r*e[3],t[4]=r*e[4],t[5]=r*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function S(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=e[0],t[7]=e[1],t[8]=1,t}function R(t,e){var n=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=n,t[2]=0,t[3]=-n,t[4]=i,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function T(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=e[1],t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function P(t,e){return t[0]=e[0],t[1]=e[1],t[2]=0,t[3]=e[2],t[4]=e[3],t[5]=0,t[6]=e[4],t[7]=e[5],t[8]=1,t}function E(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=n+n,a=i+i,h=r+r,c=n*s,u=i*s,l=i*a,p=r*s,d=r*a,f=r*h,g=o*s,v=o*a,m=o*h;return t[0]=1-l-f,t[3]=u-m,t[6]=p+v,t[1]=u+m,t[4]=1-c-f,t[7]=d-g,t[2]=p-v,t[5]=d+g,t[8]=1-c-l,t}function O(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=e[4],a=e[5],h=e[6],c=e[7],u=e[8],l=e[9],p=e[10],d=e[11],f=e[12],g=e[13],v=e[14],m=e[15],y=n*a-i*s,x=n*h-r*s,w=n*c-o*s,M=i*h-r*a,_=i*c-o*a,b=r*c-o*h,S=u*g-l*f,R=u*v-p*f,T=u*m-d*f,P=l*v-p*g,E=l*m-d*g,O=p*m-d*v,z=y*O-x*E+w*P+M*T-_*R+b*S;return z?(z=1/z,t[0]=(a*O-h*E+c*P)*z,t[1]=(h*T-s*O-c*R)*z,t[2]=(s*E-a*T+c*S)*z,t[3]=(r*E-i*O-o*P)*z,t[4]=(n*O-r*T+o*R)*z,t[5]=(i*T-n*E-o*S)*z,t[6]=(g*b-v*_+m*M)*z,t[7]=(v*w-f*b-m*x)*z,t[8]=(f*_-g*w+m*y)*z,t):null}function z(t,e,n){return t[0]=2/e,t[1]=0,t[2]=0,t[3]=0,t[4]=-2/n,t[5]=0,t[6]=-1,t[7]=1,t[8]=1,t}function C(t){return"mat3("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+")"}function I(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])}function A(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t[4]=e[4]+n[4],t[5]=e[5]+n[5],t[6]=e[6]+n[6],t[7]=e[7]+n[7],t[8]=e[8]+n[8],t}function V(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t[4]=e[4]-n[4],t[5]=e[5]-n[5],t[6]=e[6]-n[6],t[7]=e[7]-n[7],t[8]=e[8]-n[8],t}function L(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*n,t}function N(t,e,n,i){return t[0]=e[0]+n[0]*i,t[1]=e[1]+n[1]*i,t[2]=e[2]+n[2]*i,t[3]=e[3]+n[3]*i,t[4]=e[4]+n[4]*i,t[5]=e[5]+n[5]*i,t[6]=e[6]+n[6]*i,t[7]=e[7]+n[7]*i,t[8]=e[8]+n[8]*i,t}function q(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]}function D(t,e){var n=t[0],i=t[1],r=t[2],o=t[3],a=t[4],h=t[5],c=t[6],u=t[7],l=t[8],p=e[0],d=e[1],f=e[2],g=e[3],v=e[4],m=e[5],y=e[6],x=e[7],w=e[8];return Math.abs(n-p)<=s*Math.max(1,Math.abs(n),Math.abs(p))&&Math.abs(i-d)<=s*Math.max(1,Math.abs(i),Math.abs(d))&&Math.abs(r-f)<=s*Math.max(1,Math.abs(r),Math.abs(f))&&Math.abs(o-g)<=s*Math.max(1,Math.abs(o),Math.abs(g))&&Math.abs(a-v)<=s*Math.max(1,Math.abs(a),Math.abs(v))&&Math.abs(h-m)<=s*Math.max(1,Math.abs(h),Math.abs(m))&&Math.abs(c-y)<=s*Math.max(1,Math.abs(c),Math.abs(y))&&Math.abs(u-x)<=s*Math.max(1,Math.abs(u),Math.abs(x))&&Math.abs(l-w)<=s*Math.max(1,Math.abs(l),Math.abs(w))}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var F=w,k=V,X={};t(X,"create",(()=>kt)),t(X,"identity",(()=>Xt)),t(X,"setAxisAngle",(()=>Ut)),t(X,"getAxisAngle",(()=>Bt)),t(X,"getAngle",(()=>jt)),t(X,"dot",(()=>xe)),t(X,"multiply",(()=>$t)),t(X,"rotateX",(()=>Wt)),t(X,"rotateY",(()=>Ht)),t(X,"rotateZ",(()=>Gt)),t(X,"calculateW",(()=>Yt)),t(X,"exp",(()=>Kt)),t(X,"ln",(()=>Jt)),t(X,"pow",(()=>Zt)),t(X,"scale",(()=>ye)),t(X,"slerp",(()=>Qt)),t(X,"random",(()=>te)),t(X,"invert",(()=>ee)),t(X,"conjugate",(()=>ne)),t(X,"fromMat3",(()=>ie)),t(X,"fromEuler",(()=>re)),t(X,"str",(()=>oe)),t(X,"clone",(()=>pe)),t(X,"fromValues",(()=>de)),t(X,"copy",(()=>fe)),t(X,"set",(()=>ge)),t(X,"add",(()=>ve)),t(X,"mul",(()=>me)),t(X,"lerp",(()=>we)),t(X,"length",(()=>Me)),t(X,"len",(()=>_e)),t(X,"squaredLength",(()=>be)),t(X,"sqrLen",(()=>Se)),t(X,"normalize",(()=>Re)),t(X,"exactEquals",(()=>Te)),t(X,"equals",(()=>Pe)),t(X,"rotationTo",(()=>Ee)),t(X,"sqlerp",(()=>Oe)),t(X,"setAxes",(()=>ze));var U={};function B(){var t=new a(3);return a!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function j(t){var e=new a(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function $(t){var e=t[0],n=t[1],i=t[2];return Math.hypot(e,n,i)}function W(t,e,n){var i=new a(3);return i[0]=t,i[1]=e,i[2]=n,i}function H(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function G(t,e,n,i){return t[0]=e,t[1]=n,t[2]=i,t}function Y(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function K(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function J(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t}function Z(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t[2]=e[2]/n[2],t}function Q(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function tt(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function et(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.min(e[2],n[2]),t}function nt(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t}function it(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t}function rt(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function ot(t,e,n,i){return t[0]=e[0]+n[0]*i,t[1]=e[1]+n[1]*i,t[2]=e[2]+n[2]*i,t}function st(t,e){var n=e[0]-t[0],i=e[1]-t[1],r=e[2]-t[2];return Math.hypot(n,i,r)}function at(t,e){var n=e[0]-t[0],i=e[1]-t[1],r=e[2]-t[2];return n*n+i*i+r*r}function ht(t){var e=t[0],n=t[1],i=t[2];return e*e+n*n+i*i}function ct(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function ut(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function lt(t,e){var n=e[0],i=e[1],r=e[2],o=n*n+i*i+r*r;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function pt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function dt(t,e,n){var i=e[0],r=e[1],o=e[2],s=n[0],a=n[1],h=n[2];return t[0]=r*h-o*a,t[1]=o*s-i*h,t[2]=i*a-r*s,t}function ft(t,e,n,i){var r=e[0],o=e[1],s=e[2];return t[0]=r+i*(n[0]-r),t[1]=o+i*(n[1]-o),t[2]=s+i*(n[2]-s),t}function gt(t,e,n,i,r,o){var s=o*o,a=s*(2*o-3)+1,h=s*(o-2)+o,c=s*(o-1),u=s*(3-2*o);return t[0]=e[0]*a+n[0]*h+i[0]*c+r[0]*u,t[1]=e[1]*a+n[1]*h+i[1]*c+r[1]*u,t[2]=e[2]*a+n[2]*h+i[2]*c+r[2]*u,t}function vt(t,e,n,i,r,o){var s=1-o,a=s*s,h=o*o,c=a*s,u=3*o*a,l=3*h*s,p=h*o;return t[0]=e[0]*c+n[0]*u+i[0]*l+r[0]*p,t[1]=e[1]*c+n[1]*u+i[1]*l+r[1]*p,t[2]=e[2]*c+n[2]*u+i[2]*l+r[2]*p,t}function mt(t,e){e=e||1;var n=2*h()*Math.PI,i=2*h()-1,r=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(n)*r,t[1]=Math.sin(n)*r,t[2]=i*e,t}function yt(t,e,n){var i=e[0],r=e[1],o=e[2],s=n[3]*i+n[7]*r+n[11]*o+n[15];return s=s||1,t[0]=(n[0]*i+n[4]*r+n[8]*o+n[12])/s,t[1]=(n[1]*i+n[5]*r+n[9]*o+n[13])/s,t[2]=(n[2]*i+n[6]*r+n[10]*o+n[14])/s,t}function xt(t,e,n){var i=e[0],r=e[1],o=e[2];return t[0]=i*n[0]+r*n[3]+o*n[6],t[1]=i*n[1]+r*n[4]+o*n[7],t[2]=i*n[2]+r*n[5]+o*n[8],t}function wt(t,e,n){var i=n[0],r=n[1],o=n[2],s=n[3],a=e[0],h=e[1],c=e[2],u=r*c-o*h,l=o*a-i*c,p=i*h-r*a,d=r*p-o*l,f=o*u-i*p,g=i*l-r*u,v=2*s;return u*=v,l*=v,p*=v,d*=2,f*=2,g*=2,t[0]=a+u+d,t[1]=h+l+f,t[2]=c+p+g,t}function Mt(t,e,n,i){var r=[],o=[];return r[0]=e[0]-n[0],r[1]=e[1]-n[1],r[2]=e[2]-n[2],o[0]=r[0],o[1]=r[1]*Math.cos(i)-r[2]*Math.sin(i),o[2]=r[1]*Math.sin(i)+r[2]*Math.cos(i),t[0]=o[0]+n[0],t[1]=o[1]+n[1],t[2]=o[2]+n[2],t}function _t(t,e,n,i){var r=[],o=[];return r[0]=e[0]-n[0],r[1]=e[1]-n[1],r[2]=e[2]-n[2],o[0]=r[2]*Math.sin(i)+r[0]*Math.cos(i),o[1]=r[1],o[2]=r[2]*Math.cos(i)-r[0]*Math.sin(i),t[0]=o[0]+n[0],t[1]=o[1]+n[1],t[2]=o[2]+n[2],t}function bt(t,e,n,i){var r=[],o=[];return r[0]=e[0]-n[0],r[1]=e[1]-n[1],r[2]=e[2]-n[2],o[0]=r[0]*Math.cos(i)-r[1]*Math.sin(i),o[1]=r[0]*Math.sin(i)+r[1]*Math.cos(i),o[2]=r[2],t[0]=o[0]+n[0],t[1]=o[1]+n[1],t[2]=o[2]+n[2],t}function St(t,e){var n=t[0],i=t[1],r=t[2],o=e[0],s=e[1],a=e[2],h=Math.sqrt(n*n+i*i+r*r)*Math.sqrt(o*o+s*s+a*a),c=h&&pt(t,e)/h;return Math.acos(Math.min(Math.max(c,-1),1))}function Rt(t){return t[0]=0,t[1]=0,t[2]=0,t}function Tt(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"}function Pt(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function Et(t,e){var n=t[0],i=t[1],r=t[2],o=e[0],a=e[1],h=e[2];return Math.abs(n-o)<=s*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-a)<=s*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(r-h)<=s*Math.max(1,Math.abs(r),Math.abs(h))}t(U,"create",(()=>B)),t(U,"clone",(()=>j)),t(U,"length",(()=>$)),t(U,"fromValues",(()=>W)),t(U,"copy",(()=>H)),t(U,"set",(()=>G)),t(U,"add",(()=>Y)),t(U,"subtract",(()=>K)),t(U,"multiply",(()=>J)),t(U,"divide",(()=>Z)),t(U,"ceil",(()=>Q)),t(U,"floor",(()=>tt)),t(U,"min",(()=>et)),t(U,"max",(()=>nt)),t(U,"round",(()=>it)),t(U,"scale",(()=>rt)),t(U,"scaleAndAdd",(()=>ot)),t(U,"distance",(()=>st)),t(U,"squaredDistance",(()=>at)),t(U,"squaredLength",(()=>ht)),t(U,"negate",(()=>ct)),t(U,"inverse",(()=>ut)),t(U,"normalize",(()=>lt)),t(U,"dot",(()=>pt)),t(U,"cross",(()=>dt)),t(U,"lerp",(()=>ft)),t(U,"hermite",(()=>gt)),t(U,"bezier",(()=>vt)),t(U,"random",(()=>mt)),t(U,"transformMat4",(()=>yt)),t(U,"transformMat3",(()=>xt)),t(U,"transformQuat",(()=>wt)),t(U,"rotateX",(()=>Mt)),t(U,"rotateY",(()=>_t)),t(U,"rotateZ",(()=>bt)),t(U,"angle",(()=>St)),t(U,"zero",(()=>Rt)),t(U,"str",(()=>Tt)),t(U,"exactEquals",(()=>Pt)),t(U,"equals",(()=>Et)),t(U,"sub",(()=>zt)),t(U,"mul",(()=>Ct)),t(U,"div",(()=>It)),t(U,"dist",(()=>At)),t(U,"sqrDist",(()=>Vt)),t(U,"len",(()=>Lt)),t(U,"sqrLen",(()=>Nt)),t(U,"forEach",(()=>qt));var Ot,zt=K,Ct=J,It=Z,At=st,Vt=at,Lt=$,Nt=ht,qt=(Ot=B(),function(t,e,n,i,r,o){var s,a;for(e||(e=3),n||(n=0),a=i?Math.min(i*e+n,t.length):t.length,s=n;s<a;s+=e)Ot[0]=t[s],Ot[1]=t[s+1],Ot[2]=t[s+2],r(Ot,Ot,o),t[s]=Ot[0],t[s+1]=Ot[1],t[s+2]=Ot[2];return t});function Dt(t){var e=t[0],n=t[1],i=t[2],r=t[3];return Math.hypot(e,n,i,r)}function Ft(t){var e=t[0],n=t[1],i=t[2],r=t[3];return e*e+n*n+i*i+r*r}!function(){var t,e=(t=new a(4),a!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();function kt(){var t=new a(4);return a!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Xt(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function Ut(t,e,n){n*=.5;var i=Math.sin(n);return t[0]=i*e[0],t[1]=i*e[1],t[2]=i*e[2],t[3]=Math.cos(n),t}function Bt(t,e){var n=2*Math.acos(e[3]),i=Math.sin(n/2);return i>s?(t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i):(t[0]=1,t[1]=0,t[2]=0),n}function jt(t,e){var n=xe(t,e);return Math.acos(2*n*n-1)}function $t(t,e,n){var i=e[0],r=e[1],o=e[2],s=e[3],a=n[0],h=n[1],c=n[2],u=n[3];return t[0]=i*u+s*a+r*c-o*h,t[1]=r*u+s*h+o*a-i*c,t[2]=o*u+s*c+i*h-r*a,t[3]=s*u-i*a-r*h-o*c,t}function Wt(t,e,n){n*=.5;var i=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(n),h=Math.cos(n);return t[0]=i*h+s*a,t[1]=r*h+o*a,t[2]=o*h-r*a,t[3]=s*h-i*a,t}function Ht(t,e,n){n*=.5;var i=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(n),h=Math.cos(n);return t[0]=i*h-o*a,t[1]=r*h+s*a,t[2]=o*h+i*a,t[3]=s*h-r*a,t}function Gt(t,e,n){n*=.5;var i=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(n),h=Math.cos(n);return t[0]=i*h+r*a,t[1]=r*h-i*a,t[2]=o*h+s*a,t[3]=s*h-o*a,t}function Yt(t,e){var n=e[0],i=e[1],r=e[2];return t[0]=n,t[1]=i,t[2]=r,t[3]=Math.sqrt(Math.abs(1-n*n-i*i-r*r)),t}function Kt(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=Math.sqrt(n*n+i*i+r*r),a=Math.exp(o),h=s>0?a*Math.sin(s)/s:0;return t[0]=n*h,t[1]=i*h,t[2]=r*h,t[3]=a*Math.cos(s),t}function Jt(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=Math.sqrt(n*n+i*i+r*r),a=s>0?Math.atan2(s,o)/s:0;return t[0]=n*a,t[1]=i*a,t[2]=r*a,t[3]=.5*Math.log(n*n+i*i+r*r+o*o),t}function Zt(t,e,n){return Jt(t,e),ye(t,t,n),Kt(t,t),t}function Qt(t,e,n,i){var r,o,a,h,c,u=e[0],l=e[1],p=e[2],d=e[3],f=n[0],g=n[1],v=n[2],m=n[3];return(o=u*f+l*g+p*v+d*m)<0&&(o=-o,f=-f,g=-g,v=-v,m=-m),1-o>s?(r=Math.acos(o),a=Math.sin(r),h=Math.sin((1-i)*r)/a,c=Math.sin(i*r)/a):(h=1-i,c=i),t[0]=h*u+c*f,t[1]=h*l+c*g,t[2]=h*p+c*v,t[3]=h*d+c*m,t}function te(t){var e=h(),n=h(),i=h(),r=Math.sqrt(1-e),o=Math.sqrt(e);return t[0]=r*Math.sin(2*Math.PI*n),t[1]=r*Math.cos(2*Math.PI*n),t[2]=o*Math.sin(2*Math.PI*i),t[3]=o*Math.cos(2*Math.PI*i),t}function ee(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=n*n+i*i+r*r+o*o,a=s?1/s:0;return t[0]=-n*a,t[1]=-i*a,t[2]=-r*a,t[3]=o*a,t}function ne(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function ie(t,e){var n,i=e[0]+e[4]+e[8];if(i>0)n=Math.sqrt(i+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{var r=0;e[4]>e[0]&&(r=1),e[8]>e[3*r+r]&&(r=2);var o=(r+1)%3,s=(r+2)%3;n=Math.sqrt(e[3*r+r]-e[3*o+o]-e[3*s+s]+1),t[r]=.5*n,n=.5/n,t[3]=(e[3*o+s]-e[3*s+o])*n,t[o]=(e[3*o+r]+e[3*r+o])*n,t[s]=(e[3*s+r]+e[3*r+s])*n}return t}function re(t,e,n,i){var r=.5*Math.PI/180;e*=r,n*=r,i*=r;var o=Math.sin(e),s=Math.cos(e),a=Math.sin(n),h=Math.cos(n),c=Math.sin(i),u=Math.cos(i);return t[0]=o*h*u-s*a*c,t[1]=s*a*u+o*h*c,t[2]=s*h*c-o*a*u,t[3]=s*h*u+o*a*c,t}function oe(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}var se,ae,he,ce,ue,le,pe=function(t){var e=new a(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},de=function(t,e,n,i){var r=new a(4);return r[0]=t,r[1]=e,r[2]=n,r[3]=i,r},fe=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},ge=function(t,e,n,i,r){return t[0]=e,t[1]=n,t[2]=i,t[3]=r,t},ve=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t},me=$t,ye=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t},xe=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},we=function(t,e,n,i){var r=e[0],o=e[1],s=e[2],a=e[3];return t[0]=r+i*(n[0]-r),t[1]=o+i*(n[1]-o),t[2]=s+i*(n[2]-s),t[3]=a+i*(n[3]-a),t},Me=Dt,_e=Me,be=Ft,Se=be,Re=function(t,e){var n=e[0],i=e[1],r=e[2],o=e[3],s=n*n+i*i+r*r+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=n*s,t[1]=i*s,t[2]=r*s,t[3]=o*s,t},Te=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},Pe=function(t,e){var n=t[0],i=t[1],r=t[2],o=t[3],a=e[0],h=e[1],c=e[2],u=e[3];return Math.abs(n-a)<=s*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(i-h)<=s*Math.max(1,Math.abs(i),Math.abs(h))&&Math.abs(r-c)<=s*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(o-u)<=s*Math.max(1,Math.abs(o),Math.abs(u))},Ee=(se=B(),ae=W(1,0,0),he=W(0,1,0),function(t,e,n){var i=pt(e,n);return i<-.999999?(dt(se,ae,e),Lt(se)<1e-6&&dt(se,he,e),lt(se,se),Ut(t,se,Math.PI),t):i>.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(dt(se,e,n),t[0]=se[0],t[1]=se[1],t[2]=se[2],t[3]=1+i,Re(t,t))}),Oe=(ce=kt(),ue=kt(),function(t,e,n,i,r,o){return Qt(ce,e,r,o),Qt(ue,n,i,o),Qt(t,ce,ue,2*o*(1-o)),t}),ze=(le=c(),function(t,e,n,i){return le[0]=n[0],le[3]=n[1],le[6]=n[2],le[1]=i[0],le[4]=i[1],le[7]=i[2],le[2]=-e[0],le[5]=-e[1],le[8]=-e[2],Re(t,ie(t,le))}),Ce={};Object.defineProperty(Ce,"__esModule",{value:!0});var Ie={};Object.defineProperty(Ie,"__esModule",{value:!0});Ie.default=class{constructor(){this._pose=null,this._view=null,this.poseMatrix=new p5.Matrix,this.initialMVMatrix=new p5.Matrix,this.leftPMatrix=new p5.Matrix,this.rightPMatrix=new p5.Matrix,this.position=new p5.Vector(0,0,0),this.setPosition=function(t,e,n){this.position.set(t,e,n),p5.instance._renderer.translate(-t,-e,-n)}}set pose(t){this._pose=t,this.poseMatrix.set(t.transform.matrix)}get pose(){return this._pose}set view(t){this._view=t;const e=p5.instance._renderer;e.uViewMatrix&&(e.uViewMatrix.mat4=this._view.transform.inverse.matrix),e.uMVMatrix.mat4=this._view.transform.inverse.matrix,e.uPMatrix.mat4=this._view.projectionMatrix,e._curCamera.cameraMatrix.mat4=this._view.transform.inverse.matrix,"left"===t.eye?this.leftPMatrix.set(p5.instance._renderer.uPMatrix.copy()):this.rightPMatrix.set(p5.instance._renderer.uPMatrix.copy())}get view(){return this._view}getRayFromScreen(t,e){const n={origin:new p5.Vector(0,0,0),direction:new p5.Vector};let i=this.poseMatrix.copy();i.transpose(i),i=i.mat4,n.origin.x=i[3],n.origin.y=i[7],n.origin.z=i[11];let r=this.initialMVMatrix.copy();r.transpose(r),r=r.mat4;const o=n.origin.copy();n.origin.x=r[0]*o.x+r[1]*o.y+r[2]*o.z+r[3],n.origin.y=r[4]*o.x+r[5]*o.y+r[6]*o.z+r[7],n.origin.z=r[8]*o.x+r[9]*o.y+r[10]*o.z+r[11];const s=new p5.Vector(t,e,-1);let a=new p5.Matrix;a.invert(this.leftPMatrix.copy()),a.transpose(a),a=a.mat4;const h=s.copy();s.x=a[0]*h.x+a[1]*h.y+a[2]*h.z,s.y=a[4]*h.x+a[5]*h.y+a[6]*h.z,s.normalize();const c=new p5.Vector(t,e,-1);let u=new p5.Matrix;u.invert(this.rightPMatrix.copy()),u.transpose(u),u=u.mat4;const l=c.copy();return c.x=u[0]*l.x+u[1]*l.y+u[2]*l.z,c.y=u[4]*l.x+u[5]*l.y+u[6]*l.z,c.normalize(),n.direction=p5.Vector.add(s,c).normalize(),n}};var Ae=Be(Ie),Ve={};Object.defineProperty(Ve,"__esModule",{value:!0});Ve.default=class{constructor(t){this.options=t||{},this.options.color=t.color||"rgb(237, 34, 93)",this.options.background=t.background||"white",this.options.opacity=t.opacity||.95,this.options.disabledOpacity=t.disabledOpacity||.5,this.options.height=t.height||window.innerWidth/5,this.options.fontSize=t.fontSize||this.options.height/3,this.options.corners=t.corners||"square",this.options.cssprefix=t.cssprefix||"webvr-ui",this.options.textEnterXRTitle=t.textEnterXRTitle||"ENTER XR",this.options.textXRNotFoundTitle=t.textXRNotFoundTitle||"XR NOT FOUND",this.options.textExitXRTitle=t.textExitXRTitle||"EXIT XR",this.options.onRequestSession=t.onRequestSession||function(){},this.options.onEndSession=t.onEndSession||function(){},this.options.injectCSS=!1!==t.injectCSS,this.options=t,this.device=null,this.session=null,this.logoScale=1.2,this._WEBXR_UI_CSS_INJECTED={},this.domElement=t.domElement||this.__createDefaultView(t),this.__defaultDisplayStyle=this.domElement.style.display||"initial",this.domElement.addEventListener("click",(()=>this.__onXRButtonClicked())),this._enabled=!1,this.__forceDisabled=!1,this.__setDisabledAttribute(!0),this.setTitle(this.options.textXRNotFoundTitle)}__generateInnerHTML(t,e){const n=e*this.logoScale;return`<button class="${t}-button">\n <div class="${t}-title"></div>\n <div class="${t}-logo" >${this.__generateXRIconString(t,n)+this.__generateNoXRIconString(t,n)}</div>\n </button>`}__createDefaultView(t){t.injectCSS&&(this._WEBXR_UI_CSS_INJECTED[t.cssprefix]||(this.__injectCSS(this.__generateCSS(t)),this._WEBXR_UI_CSS_INJECTED[t.cssprefix]=!0));const e=document.createElement("div");return e.innerHTML=this.__generateInnerHTML(t.cssprefix,t.fontSize),e.firstChild}__createXRIcon(t,e){const n=document.createElement("div");return n.innerHTML=generateXRIconString(t,e),n.firstChild}__createNoXRIcon(t,e){const n=document.createElement("div");return n.innerHTML=generateNoXRIconString(t,e),n.firstChild}__generateXRIconString(t,e){return`<svg class="${t}-svg" version="1.1" x="0px" y="0px"\n width="${28/18*e}px" height="${e}px" viewBox="0 0 28 18" xml:space="preserve">\n <path d="M26.8,1.1C26.1,0.4,25.1,0,24.2,0H3.4c-1,0-1.7,0.4-2.4,1.1C0.3,1.7,0,2.7,0,3.6v10.7\n c0,1,0.3,1.9,0.9,2.6C1.6,17.6,2.4,18,3.4,18h5c0.7,0,1.3-0.2,1.8-0.5c0.6-0.3,1-0.8,1.3-1.4l\n 1.5-2.6C13.2,13.1,13,13,14,13v0h-0.2 h0c0.3,0,0.7,0.1,0.8,0.5l1.4,2.6c0.3,0.6,0.8,1.1,1.3,\n 1.4c0.6,0.3,1.2,0.5,1.8,0.5h5c1,0,2-0.4,2.7-1.1c0.7-0.7,1.2-1.6,1.2-2.6 V3.6C28,2.7,27.5,\n 1.7,26.8,1.1z M7.4,11.8c-1.6,0-2.8-1.3-2.8-2.8c0-1.6,1.3-2.8,2.8-2.8c1.6,0,2.8,1.3,2.8,2.8\n C10.2,10.5,8.9,11.8,7.4,11.8z M20.1,11.8c-1.6,0-2.8-1.3-2.8-2.8c0-1.6,1.3-2.8,2.8-2.8C21.7\n ,6.2,23,7.4,23,9 C23,10.5,21.7,11.8,20.1,11.8z"/>\n </svg>`}__generateNoXRIconString(t,e){const n=28/18;return`<svg class="${t}-svg-error" x="0px" y="0px"\n width="${n*e}px" height="${n*e}px" viewBox="0 0 28 28" xml:space="preserve">\n <path d="M17.6,13.4c0-0.2-0.1-0.4-0.1-0.6c0-1.6,1.3-2.8,2.8-2.8s2.8,1.3,2.8,2.8s-1.3,2.8-2.8,2.8\n c-0.2,0-0.4,0-0.6-0.1l5.9,5.9c0.5-0.2,0.9-0.4,1.3-0.8\n c0.7-0.7,1.1-1.6,1.1-2.5V7.4c0-1-0.4-1.9-1.1-2.5c-0.7-0.7-1.6-1-2.5-1\n H8.1 L17.6,13.4z"/>\n <path d="M10.1,14.2c-0.5,0.9-1.4,1.4-2.4,1.4c-1.6,0-2.8-1.3-2.8-2.8c0-1.1,0.6-2,1.4-2.5\n L0.9,5.1 C0.3,5.7,0,6.6,0,7.5v10.7c0,1,0.4,1.8,1.1,2.5c0.7,0.7,1.6,1,2.5,1\n h5c0.7,0,1.3-0.1,1.8-0.5c0.6-0.3,1-0.8,1.3-1.4l1.3-2.6 L10.1,14.2z"/>\n <path d="M25.5,27.5l-25-25C-0.1,2-0.1,1,0.5,0.4l0,0C1-0.1,2-0.1,2.6,0.4l25,25c0.6,0.6,0.6,1.5\n ,0,2.1l0,0 C27,28.1,26,28.1,25.5,27.5z"/>\n </svg>`}setDevice(t){return this.device=t,this}setSession(t){return this.session=t,this.__updateButtonState(),this}__updateButtonState(){this.session?(this.setTitle(this.options.textExitXRTitle),this.setTooltip("Exit XR presentation"),this.__setDisabledAttribute(!1)):this._enabled?(this.setTitle(this.options.textEnterXRTitle),this.setTooltip("Enter XR"),this.__setDisabledAttribute(!1)):(this.setTitle(this.options.textXRNotFoundTitle),this.setTooltip("No XR headset found."),this.__setDisabledAttribute(!0))}setTitle(t){return this.domElement.title=t,this.ifChild(this.domElement,this.options.cssprefix,"title",(e=>{t?(e.innerText=t,e.style.display="initial"):e.style.display="none"})),this}__generateCSS(t){const{height:e}=t,n=t.background?t.background:t.color,i=t.cssprefix;let r;return r="round"===t.corners?t.height/2:"square"===t.corners?2:t.corners,`\n @font-face {\n font-family: 'Karla';\n font-style: normal;\n font-weight: 400;\n src: local('Karla'), local('Karla-Regular'),\n url(https://fonts.gstatic.com/s/karla/v5/31P4mP32i98D9CEnGyeX9Q.woff2) format('woff2');\n unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;\n }\n @font-face {\n font-family: 'Karla';\n font-style: normal;\n font-weight: 400;\n src: local('Karla'), local('Karla-Regular'),\n url(https://fonts.gstatic.com/s/karla/v5/Zi_e6rBgGqv33BWF8WTq8g.woff2) format('woff2');\n unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074,\n U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;\n }\n\n button.${i}-button {\n font-family: 'Karla', sans-serif;\n\n border: ${n} 2px solid;\n border-radius: ${r}px;\n box-sizing: border-box;\n background: ${t.background?t.background:"none"};\n opacity: ${t.opacity};\n height: ${e}px;\n min-width: ${9.6*t.fontSize}px;\n display: inline-block;\n position: absolute;\n top: 5%;\n left: 15%;\n cursor: pointer;\n }\n\n button.${i}-button:focus {\n outline: none;\n }\n\n /*\n * Logo\n */\n\n .${i}-logo {\n width: ${e}px;\n height: ${e}px;\n position: absolute;\n top:0px;\n left:0px;\n width: ${e-4}px;\n height: ${e-4}px;\n }\n .${i}-svg {\n fill: ${t.color};\n margin-top: ${(e-t.fontSize*this.logoScale)/2-2}px;\n margin-left: ${e/3}px;\n }\n .${i}-svg-error {\n fill: ${t.color};\n display:none;\n margin-top: ${(e-28/18*t.fontSize*this.logoScale)/2-2}px;\n margin-left: ${e/3}px;\n }\n\n\n /*\n * Title\n */\n\n .${i}-title {\n color: ${t.color};\n position: relative;\n font-size: ${t.fontSize}px;\n padding-left: ${1.05*e}px;\n padding-right: ${r-10<5?e/3:r-10}px;\n }\n\n /*\n * disabled\n */\n\n button.${i}-button[disabled=true] {\n opacity: ${t.disabledOpacity};\n }\n\n button.${i}-button[disabled=true] > .${i}-logo > .${i}-svg {\n display:none;\n }\n\n button.${i}-button[disabled=true] > .${i}-logo > .${i}-svg-error {\n display:initial;\n }\n `}__injectCSS(t){const e=document.createElement("style");e.innerHTML=t;const n=document.getElementsByTagName("head")[0];n.insertBefore(e,n.firstChild)}ifChild(t,e,n,i){const r=t.querySelector(`.${e}-${n}`);r&&i(r)}setTooltip(t){return this.domElement.title=t,this}show(){return this.domElement.style.display=this.__defaultDisplayStyle,this}hide(){return this.domElement.style.display="none",this}enable(){return this._enabled=!0,this.__setDisabledAttribute(!1),this.__forceDisabled=!1,this}disable(){return this._enabled=!1,this.__setDisabledAttribute(!0),this.__forceDisabled=!0,this}remove(){this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement)}setAvailable(t,e){const n=e.slice(-2).toUpperCase();if(t){const t=`Enter ${n}`;this.setTitle(t),this.setTooltip(t),this.enable(),console.log(`${e} supported`),this.setDevice(!0)}else if("VR"===n)console.log("VR not supported. Falling back to inline mode."),this.hide();else{const t=`${n} not supported`;this.setTitle(t),this.setTooltip(t),this.disable(),console.log(`${e} not supported`)}}__setDisabledAttribute(t){t||this.__forceDisabled?this.domElement.setAttribute("disabled","true"):this.domElement.removeAttribute("disabled")}__onXRButtonClicked(){this.session?this.options.onEndSession(this.session):this.device&&("undefined"!=typeof DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission&&DeviceMotionEvent.requestPermission().then((t=>{"granted"===t&&window.addEventListener("devicemotion",(()=>{}))})).catch(console.error),"undefined"!=typeof DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission&&DeviceOrientationEvent.requestPermission().then((t=>{"granted"===t&&window.addEventListener("deviceorientation",(()=>{}))})).catch(console.error),this.options.onRequestSession(this.device))}};var Le=Be(Ve),Ne={};Object.defineProperty(Ne,"__esModule",{value:!0});var qe={};
/**
* @license Quaternion.js v1.4.0 27/03/2022
*
* Copyright (c) 2022, Robert Eisele (robert@xarg.org)
* Licensed under the MIT license.
**/!function(t){"use strict";function e(t,e){var n=Math.abs(t),i=Math.abs(e);return 0===t?Math.log(i):0===e?Math.log(n):n<3e3&&i<3e3?.5*Math.log(t*t+e*e):(t/=2,e/=2,.5*Math.log(t*t+e*e)+Math.LN2)}var n={w:1,x:0,y:0,z:0};function i(t,e,i,r,o){if(void 0!==o)return t.w=e,t.x=i,t.y=r,void(t.z=o);if("object"==typeof e&&void 0===r){if("w"in e||"x"in e||"y"in e||"z"in e)return t.w=e.w||0,t.x=e.x||0,t.y=e.y||0,void(t.z=e.z||0);if("re"in e&&"im"in e)return t.w=e.re,t.x=e.im,t.y=0,void(t.z=0);if(4===e.length)return t.w=e[0],t.x=e[1],t.y=e[2],void(t.z=e[3]);if(3===e.length)return t.w=0,t.x=e[0],t.y=e[1],void(t.z=e[2]);throw new Error("Invalid object")}if("string"!=typeof e||void 0!==r)void 0===e&&t!==n?(t.w=1,t.x=t.y=t.z=0):(t.w=e||0,i&&3===i.length?(t.x=i[0],t.y=i[1],t.z=i[2]):(t.x=i||0,t.y=r||0,t.z=o||0));else{var s=e.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),a=1,h=0,c={i:"x",j:"y",k:"z"};if(null===s)throw new Error("Parse error");t.w=t.x=t.y=t.z=0;for(var u=0;u<s.length;u++){var l=s[u],p=s[u+1];if(" "===l||"\t"===l||"\n"===l);else if("+"===l)a++;else if("-"===l)h++;else{if(a+h===0)throw new Error("Parse error"+l);var d=c[l];if(void 0!==d)" "===p||isNaN(p)?l="1":(l=p,u++);else{if(isNaN(l))throw new Error("Parser error");void 0!==(d=c[p])&&u++}t[d||"w"]+=parseFloat((h%2?"-":"")+l),a=h=0}}if(a+h>0)throw new Error("Parser error")}}function r(t,e,n){var i="";return 0!==t&&(""!==n?i+=t<0?" - ":" + ":t<0&&(i+="-"),1===(t=Math.abs(t))&&""!==e||(i+=t),i+=e),i}function o(t,e,n,r){if(!(this instanceof o))return new o(t,e,n,r);i(this,t,e,n,r)}o.prototype={w:1,x:0,y:0,z:0,add:function(t,e,r,s){return i(n,t,e,r,s),new o(this.w+n.w,this.x+n.x,this.y+n.y,this.z+n.z)},sub:function(t,e,r,s){return i(n,t,e,r,s),new o(this.w-n.w,this.x-n.x,this.y-n.y,this.z-n.z)},neg:function(){return new o(-this.w,-this.x,-this.y,-this.z)},norm:function(){var t=this.w,e=this.x,n=this.y,i=this.z;return Math.sqrt(t*t+e*e+n*n+i*i)},normSq:function(){var t=this.w,e=this.x,n=this.y,i=this.z;return t*t+e*e+n*n+i*i},normalize:function(){var t=this.w,e=this.x,n=this.y,i=this.z,r=Math.sqrt(t*t+e*e+n*n+i*i);return r<o.EPSILON?o.ZERO:new o(t*(r=1/r),e*r,n*r,i*r)},mul:function(t,e,r,s){i(n,t,e,r,s);var a=this.w,h=this.x,c=this.y,u=this.z,l=n.w,p=n.x,d=n.y,f=n.z;return new o(a*l-h*p-c*d-u*f,a*p+h*l+c*f-u*d,a*d+c*l+u*p-h*f,a*f+u*l+h*d-c*p)},scale:function(t){return new o(this.w*t,this.x*t,this.y*t,this.z*t)},dot:function(t,e,r,o){return i(n,t,e,r,o),this.w*n.w+this.x*n.x+this.y*n.y+this.z*n.z},inverse:function(){var t=this.w,e=this.x,n=this.y,i=this.z,r=t*t+e*e+n*n+i*i;return 0===r?o.ZERO:new o(t*(r=1/r),-e*r,-n*r,-i*r)},div:function(t,e,r,s){i(n,t,e,r,s);var a=this.w,h=this.x,c=this.y,u=this.z,l=n.w,p=n.x,d=n.y,f=n.z,g=l*l+p*p+d*d+f*f;return 0===g?o.ZERO:new o((a*l+h*p+c*d+u*f)*(g=1/g),(h*l-a*p-c*f+u*d)*g,(c*l-a*d-u*p+h*f)*g,(u*l-a*f-h*d+c*p)*g)},conjugate:function(){return new o(this.w,-this.x,-this.y,-this.z)},exp:function(){var t=this.w,e=this.x,n=this.y,i=this.z,r=Math.sqrt(e*e+n*n+i*i),s=Math.exp(t),a=s/r*Math.sin(r);return 0===r?new o(s,0,0,0):new o(s*Math.cos(r),e*a,n*a,i*a)},log:function(){var t=this.w,n=this.x,i=this.y,r=this.z;if(0===i&&0===r)return new o(e(t,n),Math.atan2(n,t),0,0);var s=n*n+i*i+r*r+t*t,a=Math.sqrt(n*n+i*i+r*r),h=Math.atan2(a,t)/a;return new o(.5*Math.log(s),n*h,i*h,r*h)},pow:function(t,r,s,a){if(i(n,t,r,s,a),0===n.y&&0===n.z){if(1===n.w&&0===n.x)return this;if(0===n.w&&0===n.x)return o.ONE;if(0===this.y&&0===this.z){var h=this.w,c=this.x;if(0===h&&0===c)return o.ZERO;var u=Math.atan2(c,h),l=e(h,c);if(0===n.x){if(0===c&&h>=0)return new o(Math.pow(h,n.w),0,0,0);if(0===h)switch(n.w%4){case 0:return new o(Math.pow(c,n.w),0,0,0);case 1:return new o(0,Math.pow(c,n.w),0,0);case 2:return new o(-Math.pow(c,n.w),0,0,0);case 3:return new o(0,-Math.pow(c,n.w),0,0)}}return h=Math.exp(n.w*l-n.x*u),c=n.x*l+n.w*u,new o(h*Math.cos(c),h*Math.sin(c),0,0)}}return this.log().mul(n).exp()},equals:function(t,e,r,s){i(n,t,e,r,s);var a=o.EPSILON;return Math.abs(n.w-this.w)<a&&Math.abs(n.x-this.x)<a&&Math.abs(n.y-this.y)<a&&Math.abs(n.z-this.z)<a},isFinite:function(){return isFinite(this.w)&&isFinite(this.x)&&isFinite(this.y)&&isFinite(this.z)},isNaN:function(){return isNaN(this.w)||isNaN(this.x)||isNaN(this.y)||isNaN(this.z)},toString:function(){var t=this.w,e=this.x,n=this.y,i=this.z,o="";return isNaN(t)||isNaN(e)||isNaN(n)||isNaN(i)?"NaN":(o=r(t,"",o),o+=r(e,"i",o),o+=r(n,"j",o),""===(o+=r(i,"k",o))?"0":o)},real:function(){return this.w},imag:function(){return[this.x,this.y,this.z]},toVector:function(){return[this.w,this.x,this.y,this.z]},toMatrix:function(t){var e=this.w,n=this.x,i=this.y,r=this.z,o=e*n,s=e*i,a=e*r,h=n*n,c=n*i,u=n*r,l=i*i,p=i*r,d=r*r;return t?[[1-2*(l+d),2*(c-a),2*(u+s)],[2*(c+a),1-2*(h+d),2*(p-o)],[2*(u-s),2*(p+o),1-2*(h+l)]]:[1-2*(l+d),2*(c-a),2*(u+s),2*(c+a),1-2*(h+d),2*(p-o),2*(u-s),2*(p+o),1-2*(h+l)]},toMatrix4:function(t){var e=this.w,n=this.x,i=this.y,r=this.z,o=e*n,s=e*i,a=e*r,h=n*n,c=n*i,u=n*r,l=i*i,p=i*r,d=r*r;return t?[[1-2*(l+d),2*(c-a),2*(u+s),0],[2*(c+a),1-2*(h+d),2*(p-o),0],[2*(u-s),2*(p+o),1-2*(h+l),0],[0,0,0,1]]:[1-2*(l+d),2*(c-a),2*(u+s),0,2*(c+a),1-2*(h+d),2*(p-o),0,2*(u-s),2*(p+o),1-2*(h+l),0,0,0,0,1]},toEuler:function(){var t=this.w,e=this.x,n=this.y,i=this.z,r=2*(t*n-i*e);return{roll:Math.atan2(2*(t*e+n*i),1-2*(e*e+n*n)),pitch:r>=1?Math.PI/2:r<=-1?-Math.PI/2:Math.asin(r),yaw:Math.atan2(2*(t*i+e*n),1-2*(n*n+i*i))}},clone:function(){return new o(this)},rotateVector:function(t){var e=this.w,n=this.x,i=this.y,r=this.z,o=t[0],s=t[1],a=t[2],h=2*(i*a-r*s),c=2*(r*o-n*a),u=2*(n*s-i*o);return[o+e*h+i*u-r*c,s+e*c+r*h-n*u,a+e*u+n*c-i*h]},slerp:function(t,e,r,s){i(n,t,e,r,s);var a=this.w,h=this.x,c=this.y,u=this.z,l=n.w,p=n.x,d=n.y,f=n.z,g=a*l+h*p+c*d+u*f;if(g<0&&(a=-a,h=-h,c=-c,u=-u,g=-g),g>=1-o.EPSILON)return function(t){return new o(a+t*(l-a),h+t*(p-h),c+t*(d-c),u+t*(f-u)).normalize()};var v=Math.acos(g),m=Math.sin(v);return function(t){var e=v*t,n=Math.sin(e),i=Math.cos(e)-g*n/m,r=n/m;return new o(i*a+r*l,i*h+r*p,i*c+r*d,i*u+r*f)}}},o.ZERO=new o(0,0,0,0),o.ONE=new o(1,0,0,0),o.I=new o(0,1,0,0),o.J=new o(0,0,1,0),o.K=new o(0,0,0,1),o.EPSILON=1e-16,o.fromAxisAngle=function(t,e){var n=.5*e,i=t[0],r=t[1],s=t[2],a=Math.sin(n),h=Math.cos(n),c=a/Math.sqrt(i*i+r*r+s*s);return new o(h,i*c,r*c,s*c)},o.fromBetweenVectors=function(t,e){var n=t[0],i=t[1],r=t[2],s=e[0],a=e[1],h=e[2],c=n*s+i*a+r*h;o.EPSILON;var u=i*h-r*a,l=r*s-n*h,p=n*a-i*s;return new o(c+Math.sqrt(c*c+u*u+l*l+p*p),u,l,p).normalize()},o.random=function(){var t=Math.random(),e=Math.random(),n=Math.random(),i=Math.sqrt(1-t),r=Math.sqrt(t);return new o(r*Math.cos(2*Math.PI*n),i*Math.sin(2*Math.PI*e),i*Math.cos(2*Math.PI*e),r*Math.sin(2*Math.PI*n))},o.fromEuler=function(t,e,n,i){var r=.5*t,s=.5*e,a=.5*n,h=Math.cos(r),c=Math.cos(s),u=Math.cos(a),l=Math.sin(r),p=Math.sin(s),d=Math.sin(a);return void 0===i||"ZXY"===i?new o(h*c*u-l*p*d,h*u*p-c*l*d,h*c*d+u*l*p,c*u*l+h*p*d):"XYZ"===i||"RPY"===i?new o(h*c*u-l*p*d,c*u*l+h*p*d,h*u*p-c*l*d,h*c*d+u*l*p):"YXZ"===i?new o(h*c*u+l*p*d,h*u*p+c*l*d,c*u*l-h*p*d,h*c*d-u*l*p):"ZYX"===i||"YPR"===i?new o(h*c*u+l*p*d,h*c*d-u*l*p,h*u*p+c*l*d,c*u*l-h*p*d):"YZX"===i?new o(h*c*u-l*p*d,h*c*d+u*l*p,c*u*l+h*p*d,h*u*p-c*l*d):"XZY"===i?new o(h*c*u+l*p*d,c*u*l-h*p*d,h*c*d-u*l*p,h*u*p+c*l*d):null},o.fromMatrix=function(t){if(9===t.length)var e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],h=t[6],c=t[7],u=t[8];else e=t[0][0],n=t[0][1],i=t[0][2],r=t[1][0],s=t[1][1],a=t[1][2],h=t[2][0],c=t[2][1],u=t[2][2];var l,p=e+s+u;return p>0?new o(.25*(l=2*Math.sqrt(p+1)),(c-a)/l,(i-h)/l,(r-n)/l):e>s&e>u?new o((c-a)/(l=2*Math.sqrt(1+e-s-u)),.25*l,(n+r)/l,(i+h)/l):s>u?new o((i-h)/(l=2*Math.sqrt(1+s-e-u)),(n+r)/l,.25*l,(a+c)/l):new o((r-n)/(l=2*Math.sqrt(1+u-e-s)),(i+h)/l,(a+c)/l,.25*l)},"function"==typeof define&&define.amd?define([],(function(){return o})):(Object.defineProperty(o,"__esModule",{value:!0}),o.default=o,o.Quaternion=o,qe=o)}();var De,Fe=(De=qe)&&De.__esModule?De:{default:De};Ne.default=class{constructor(t,e,n){this._inputSource=t,this._targetRayPose=e.getPose(this._inputSource.targetRaySpace,n),this._pose=void 0,this.gamepad=t.gamepad,this._dir=U.create();const i=o.create(),r=U.create();this._dir[2]=-1,this._targetRayPose&&(U.transformMat4(r,r,this._targetRayPose.transform.matrix),o.fromMat4(i,this._targetRayPose.transform.matrix),U.transformMat3(this._dir,this._dir,i)),this.direction=this._dir}get direction(){return new p5.Vector(this._dir[0],this._dir[1],this._dir[2])}set direction(t){this._dir=U.copy(this._dir,t),U.normalize(this._dir,this._dir),this.inv_dir=U.fromValues(1/this._dir[0],1/this._dir[1],1/this._dir[2]),this.sign=[this.inv_dir[0]<0?1:0,this.inv_dir[1]<0?1:0,this.inv_dir[2]<0?1:0]}get pose(){return this.updatePose(),this._pose.transform.matrix}get position(){this.updatePose();const t=this._pose?.transform?.position;return new p5.Vector(t.x,t.y,t.z)}get rotation(){if(this.updatePose(),this._pose){const{x:t,y:e,z:n,w:i}=this._pose?.transform?.orientation,r=new Fe.default(t,e,n,i).toEuler();return p5.instance.angleMode===RADIANS?new p5.Vector(-r.yaw,r.pitch,-r.roll):new p5.Vector(p5.toDegrees(-r.yaw),p5.toDegrees(r.pitch),p5.toDegrees(-r.roll))}return new p5.Vector(0,0,0)}get trigger(){return this.updateGamepad(),this.gamepad?.buttons[0]}get grip(){return this.updateGamepad(),this.gamepad.buttons[1]}get touchpad(){return this.updateGamepad(),this.gamepad.buttons[2]}get thumbstick(){return this.updateGamepad(),this.gamepad.buttons[3]}get touchpad2D(){return this.updateGamepad(),new p5.Vector(this.gamepad.axes[0],this.gamepad.axes[1])}get thumbstick2D(){return this.updateGamepad(),new p5.Vector(this.gamepad.axes[2],this.gamepad.axes[3])}updatePose(){return this._pose=window.p5xr.instance.frame.getPose(this._inputSource.gripSpace,window.p5xr.instance.xrRefSpace),this._pose}updateGamepad(){return this.gamepad=this._inputSource.gamepad,this.gamepad}};var ke=Be(Ne),Xe={};Object.defineProperty(Xe,"__esModule",{value:!0});Xe.THUMB=0,Xe.INDEX=1,Xe.MIDDLE=2,Xe.RING=3,Xe.PINKY=4;p5.prototype._mainHandMode=p5.prototype.RIGHT;const Ue=p5.prototype;function Be(t){return t&&t.__esModule?t:{default:t}}p5.prototype.hands=Array.from({length:50},(()=>({x:0,y:0,z:0,rad:.1,mat:new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}))),p5.prototype.fingerLeft=Ue.hands[9],p5.prototype.fingerRight=Ue.hands[34],p5.prototype.finger=Ue.fingerRight,p5.prototype.fingerMain=Ue.fingerRight,p5.prototype.fingerAlt=Ue.fingerLeft,p5.prototype.fingers=[Ue.hands[4],Ue.hands[9],Ue.hands[14],Ue.hands[19],Ue.hands[24],Ue.hands[29],Ue.hands[34],Ue.hands[39],Ue.hands[44],Ue.hands[49]],p5.prototype.fingersLeft=Ue.fingers.slice(0,5),p5.prototype.fingersRight=Ue.fingers.slice(5,10),p5.prototype.fingersMain=Ue.fingersRight,p5.prototype.fingersAlt=Ue.fingersLeft,p5.prototype.handLeft=Ue.hands.slice(0,25),p5.prototype.handRight=Ue.hands.slice(25,50),p5.prototype.handMain=Ue.handRight,p5.prototype.hand=Ue.handMain,p5.prototype.handAlt=Ue.handLeft,p5.prototype.flatMatrices=new Float32Array(400),p5.prototype.flatMatricesFull=new Float32Array(800),p5.prototype.radii=new Float32Array(25),p5.prototype.radiiFull=new Float32Array(50),p5.prototype._pinchTreshold=.025,p5.prototype.fingersArePinched=!1,p5.prototype.pFingersArePinched=!1,p5.prototype._handleOnPinch=function(){const t=this.fingerMain,e=this.fingersRight[0],n=this.dist(t.x,t.y,t.z,e.x,e.y,e.z);if(this._setProperty("fingersArePinched",n<this._pinchTreshold),!this.pFingersArePinched&&this.fingersArePinched){const t=this._isGlobal?window:this;"function"==typeof t.fingersPinched&&t.fingersPinched()}},p5.prototype._handleHandInput=function(t,e,n){if(this._setProperty("flatMatrices",this.flatMatrices),this._setProperty("radii",this.radii),this._setProperty("hands",this.hands),this._setProperty("fingerLeft",this.fingerLeft),this._setProperty("fingerRight",this.fingerRight),this._setProperty("finger",this.finger),this._setProperty("fingerMain",this.fingerMain),this._setProperty("fingerAlt",this.fingerAlt),this._setProperty("fingers",this.fingers),this._setProperty("fingersLeft",this.fingersLeft),this._setProperty("fingersRight",this.fingersRight),this._setProperty("fingersMain",this.fingersMain),this._setProperty("fingersAlt",this.fingersAlt),this._setProperty("handLeft",this.handLeft),this._setProperty("handRight",this.handRight),this._setProperty("hand",this.hand),this._setProperty("handMain",this.handMain),this._setProperty("handAlt",this.handAlt),!n.hand)return;if(!t.fillPoses(n.hand.values(),e,this.flatMatrices))return;t.fillJointRadii(n.hand.values(),this.radii)||console.log("radii not filled");const i="left"===n.handedness?0:25;this.flatMatricesFull.set(this.flatMatrices,16*i),this.radiiFull.set(this.radii,i);for(let t=0;t<25;t++){const e=this.flatMatrices.slice(16*t,16*(t+1));this.hands[t+i].x=e[12],this.hands[t+i].y=e[13],this.hands[t+i].z=e[14],this.hands[t+i].mat4=e,this.hands[t+i].rad=radii[t]}this._handleOnPinch(),this._setProperty("pFingersArePinched",this.fingersArePinched)},p5.prototype.mainHandMode=function(t){t===this.LEFT?(this.finger=this.fingerLeft,this.fingerMain=this.fingerLeft,this.fingerAlt=this.fingerRight,this.hand=this.handLeft,this.handMain=this.handLeft,this.handAlt=this.handRight):t===this.RIGHT&&(this.finger=this.fingerRight,this.fingerMain=this.fingerRight,this.fingerAlt=this.fingerLeft,this.hand=this.handRight,this.handMain=this.handRight,this.handAlt=this.handLeft)};Ce.default=class{constructor(t={}){const{requiredFeatures:e=[],optionalFeatures:n=["hand-tracking"]}=t;this.xrDevice=null,this.isVR=null,this.mode="inline",this.hasImmersive=null,this.isImmersive=!1,this.xrSession=null,this.xrRefSpace=null,this.xrViewerSpace=null,this.xrHitTestSource=null,this.frame=null,this.gl=null,this.curClearColor=color(255,255,255),this.viewer=new Ae.default,this.requiredFeatures=e,this.optionalFeatures=n}__removeLoadingElement(){const t=document.getElementById(window._loadingScreenId);t&&t.parentNode.removeChild(t)}__updateXR(){const t=p5.instance._renderer;t.ambientLightColors.length=0,t.specularColors=[1,1,1],t.directionalLightDirections.length=0,t.directionalLightDiffuseColors.length=0,t.directionalLightSpecularColors.length=0,t.pointLightPositions.length=0,t.pointLightDiffuseColors.length=0,t.pointLightSpecularColors.length=0,t.spotLightPositions.length=0,t.spotLightDirections.length=0,t.spotLightDiffuseColors.length=0,t.spotLightSpecularColors.length=0,t.spotLightAngle.length=0,t.spotLightConc.length=0,t._enableLighting=!1,t._tint=[255,255,255,255]}__setupSensibleXRDefaults(){"undefined"!=typeof linePerspective&&linePerspective()&&(console.log("p5xr: linePerspective is active, setting stroke width to 0.001"),strokeWeight(.001))}__setupCanvas(){createCanvas(windowWidth,windowHeight,WEBGL)}__createButton(){p5.instance._incrementPreload(),this.__setupCanvas(),this.__removeLoadingElement(),this.xrButton=new Le.default({onRequestSession:this.__onXRButtonClicked.bind(this),onEndSession:this.__onEndSession.bind(this),textEnterXRTitle:`Enter ${this.displayMode}`,textXRNotFoundTitle:`${this.displayMode} not found`,textExitXRTitle:`Exit ${this.displayMode}`});let t=document.querySelector("header");t||(t=document.createElement("header"),document.querySelector("body").appendChild(t)),t.appendChild(this.xrButton.domElement),this.__sessionCheck()}async __sessionCheck(){if(navigator?.xr){console.log("XR Available");const t=await navigator.xr.isSessionSupported(this.mode);this.hasImmersive=t,this.xrButton.setAvailable(t,this.mode)}else console.log("XR Not Available"),this.xrButton.disable()}resetXR(){this.xrDevice=null,this.xrSession=null,this.xrButton.setSession(null),this.xrRefSpace=null,this.xrViewerSpace=null,this.xrHitTestSource=null,this.gl=null,this.frame=null}__onXRButtonClicked(){if(!this.hasImmersive)return void this.xrButton.hide();console.log(`Requesting session with mode: ${this.mode}`),this.isImmersive=!0,this.resetXR();const t="undefined"!=typeof CustomWebXRPolyfill,e=window.parent?.p5frame,n=!t&&e,i=n?window.parent:window;n&&console.log("p5xr: p5live experimental xr session persistance mode"),i.xrSession?(console.log("p5xr: p5live mode attempting xr session reuse"),setTimeout((()=>{const t=i.xrSession;this.xrButton.setSession(t),this.__startSketch.call(this,t)}),1)):i.navigator.xr.requestSession(this.mode,{requiredFeatures:this.requiredFeatures,optionalFeatures:this.optionalFeatures}).then((t=>{i.xrSession=t,this.xrButton.setSession(t),this.__startSketch.call(this,t)})).catch((t=>{console.error(`An error occured activating ${this.mode}: ${t}`)}))}startXRWithoutUserAction(){this.hasImmersive=!0,this.__onXRButtonClicked()}__startSketch(t){this.xrSession=t,this.canvas=p5.instance.canvas,this.canvas.style.visibility="visible",p5.instance._renderer._curCamera.cameraType="custom",p5.instance._renderer._curCamera.useLinePerspective=!1,"function"==typeof window.setup&&(p5.instance._setupDone||window.setup(),p5.instance._millisStart=window.performance.now()),this.__setupSensibleXRDefaults();const e=this.isImmersive?"local":"viewer";this.xrSession.requestReferenceSpace(e).then((t=>{this.xrRefSpace=t,this.xrSession.requestAnimationFrame(this.__onXRFrame.bind(this)),this.isImmersive||(this.xrSession.updateRenderState({baseLayer:new XRWebGLLayer(this.xrSession,this.gl),inlineVerticalFieldOfView:Math.PI/180*70}),this.addInlineViewListeners(this.canvas))})),this.__onRequestSession()}__onRequestSession(){this.xrSession.addEventListener("end",(t=>this.__onSessionEnded(t)));const t=this.isImmersive?"local":"viewer";this.gl=this.canvas.getContext(p5.instance.webglVersion),this.gl.makeXRCompatible().then((()=>{this.xrSession.updateRenderState({baseLayer:new XRWebGLLayer(this.xrSession,this.gl)}),this.requiredFeatures.includes("hit-test")&&this.xrSession.requestReferenceSpace("viewer").then((t=>{this.xrViewerSpace=t,this.xrSession.requestHitTestSource({space:this.xrViewerSpace}).then((t=>{this.xrHitTestSource=t}))})),this.xrSession.requestReferenceSpace(t).then((t=>{this.xrRefSpace=t,this.xrSession.requestAnimationFrame(this.__onXRFrame.bind(this))}))})).catch((t=>{console.log(t)}))}__onXRFrame(t,e){const n=this.xrSession=e.session;if(null===n||null===this.gl)return;n.requestAnimationFrame(this.__onXRFrame.bind(this));let i=this.xrRefSpace;this.isVR&&!this.isImmersive&&(i=this.getAdjustedRefSpace(this.xrRefSpace));const r=e.getViewerPose(this.xrRefSpace),o=n.renderState.baseLayer;this.frame=e;for(const t of n.inputSources)_handleHandInput(e,this.xrRefSpace,t);if(r){this.viewer.pose=e.getViewerPose(i),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,o.framebuffer),this.isVR&&this.clearVR();const t=window,n=t.calculate;if(this.viewer.pose.views.length>1){"function"==typeof n&&n();const e=window.performance.now();p5.instance.deltaTime=e-p5.instance._lastFrameTime,p5.instance._frameRate=1e3/p5.instance.deltaTime,p5.instance._setProperty("deltaTime",p5.instance.deltaTime),p5.instance._lastFrameTime=e,t._setProperty("frameCount",t.frameCount+1)}let r=0;for(const t of this.viewer.pose.views){this.viewer.view=t;const e=this.isImmersive?1:pixelDensity(),n=o.getViewport(this.viewer.view);this.gl.viewport(n.x,n.y,n.width*e,n.height*e),this.__updateViewport(n),this.__drawEye(r),r++}}}__updateViewport(t){p5.instance._renderer._viewport[0]=t.x,p5.instance._renderer._viewport[1]=t.y,p5.instance._renderer._viewport[2]=t.width,p5.instance._renderer._viewport[3]=t.height}__drawEye(){const t=window,e=t.setup,n=t.draw;if(p5.instance._renderer.isP3D){if("function"==typeof n){void 0===e&&t.scale(t._pixelDensity,t._pixelDensity),t.resetMatrix(),this.__updateXR(),p5.instance._inUserDraw=!0;try{n()}finally{p5.instance._inUserDraw=!1}}}else console.error("Sketch does not have 3D Renderer")}__getXRInput(t){let e;return this.xrSession.inputSources.forEach((n=>{n.handedness===t&&(e=new ke.default(n,this.frame,this.xrRefSpace))})),e}__onEndSession(t){this.isVR?this.isImmersive&&(console.log("Exiting immersive session"),this.isImmersive=!1,this.__sessionCheck(),console.log("Requesting new session"),navigator.xr.requestSession("inline").then(this.__startSketch.bind(this))):(this.xrHitTestSource.cancel(),this.xrHitTestSource=null),this.isImmersive&&this.hasImmersive&&(this.isImmersive=!1),t.end()}__onSessionEnded(){this.resetXR(),window.parent&&window.parent.xrSession&&(window.parent.xrSession=null)}printUnsupportedMessage(){console.warn("Your browser/hardware does not work with AR Mode currently. This is undergoing heavy development currently.You may be able to fix this by enabling WebXR flags in Chrome.")}remove(){this.xrButton&&this.xrButton.remove(),window.p5xr.instance=null}get instance(){return window.p5xr.instance}set instance(t){return window.p5xr.instance=t,window.p5xr.instance}};var je=function(t){return t&&t.__esModule?t:{default:t}}(Ce);class $e extends je.default{constructor(){super(),this.mode="immersive-vr",this.displayMode="VR",this.isVR=!0,this.lookYaw=0,this.lookPitch=0,this.LOOK_SPEED=.0025,this.primaryTouch=void 0,this.prevTouchX=void 0,this.prevTouchY=void 0,navigator?.xr&&navigator.xr.requestSession("inline").then(this.__startSketch.bind(this)),this.__createButton()}__startSketch(t){super.__startSketch(t)}clearVR(){null!==this.curClearColor&&(p5.instance.background(this.curClearColor),this.gl.clear(this.gl.DEPTH_BUFFER_BIT))}getAdjustedRefSpace(t){const e=X.create();X.rotateX(e,e,-this.lookPitch),X.rotateY(e,e,-this.lookYaw);const n=new XRRigidTransform({x:0,y:0,z:0},{x:e[0],y:e[1],z:e[2],w:e[3]});return t.getOffsetReferenceSpace(n)}rotateInlineView(t,e){this.lookYaw+=t*this.LOOK_SPEED,this.lookPitch+=e*this.LOOK_SPEED,this.lookPitch<.5*-Math.PI&&(this.lookPitch=.5*-Math.PI),this.lookPitch>.5*Math.PI&&(this.lookPitch=.5*Math.PI)}addInlineViewListeners(){this.canvas.addEventListener("mousemove",(t=>{t.buttons&&this.rotateInlineView(t.movementX,t.movementY)})),this.canvas.addEventListener("touchstart",(t=>{if(void 0===this.primaryTouch){const e=t.changedTouches[0];this.primaryTouch=e.identifier,this.prevTouchX=e.pageX,this.prevTouchY=e.pageY}})),this.canvas.addEventListener("touchend",(t=>{for(const e of t.changedTouches)this.primaryTouch===e.identifier&&(this.primaryTouch=void 0,this.rotateInlineView(e.pageX-this.prevTouchX,e.pageY-this.prevTouchY))})),this.canvas.addEventListener("touchcancel",(t=>{for(const e of t.changedTouches)this.primaryTouch===e.identifier&&(this.primaryTouch=void 0)})),this.canvas.addEventListener("touchmove",(t=>{for(const e of t.changedTouches)this.primaryTouch===e.identifier&&(this.rotateInlineView(e.pageX-this.prevTouchX,e.pageY-this.prevTouchY),this.prevTouchX=e.pageX,this.prevTouchY=e.pageY)}))}}r.default=$e;var We=rn(r),He={};Object.defineProperty(He,"__esModule",{value:!0});var Ge=Je(Ce),Ye={};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.default=class{constructor(t,e,n){this.position={x:100*t,y:100*e,z:100*n}}dispose(){}isTracking(){}isStopped(){}transform(){translate(this.position.x,this.position.y,this.position.z)}};var Ke=Je(Ye);function Je(t){return t&&t.__esModule?t:{default:t}}class Ze extends Ge.default{constructor(){super({requiredFeatures:["local","hit-test"]}),this.mode="immersive-ar",this.displayMode="AR",this.canvas=null,this.__createButton()}__startSketch(t){super.__startSketch(t),"function"==typeof touchStarted&&this.xrSession.addEventListener("select",touchStarted)}__onSelect(t){const e=window.mousePressed;"function"==typeof e&&e(t)}__detectHit(t){if(null==t)return console.warn("You must pass the touchStarted event to detectHit."),null;if(!this.xrSession)return null;if(this.xrHitTestSource&&this.viewer.pose&&this.frame){const t=this.frame.getHitTestResults(this.xrHitTestSource);if(t.length>0){const e=t[0].getPose(this.xrRefSpace);return createVector(e.transform.position.x,e.transform.position.y,e.transform.position.z)}}}__createAnchor(t){return null==t?null:new Ke.default(t.x,t.y,t.z)}}He.default=Ze;var Qe=rn(He),tn={};Object.defineProperty(tn,"__esModule",{value:!0});tn.lineFrag="\n#ifdef WEBGL2\n\n#define IN in\n#define OUT out\n\n#ifdef FRAGMENT_SHADER\nout vec4 outColor;\n#define OUT_COLOR outColor\n#endif\n#define TEXTURE texture\n\n#else\n\n#ifdef FRAGMENT_SHADER\n#define IN varying\n#else\n#define IN attribute\n#endif\n#define OUT varying\n#define TEXTURE texture2D\n\n#ifdef FRAGMENT_SHADER\n#define OUT_COLOR gl_FragColor\n#endif\n\n#endif\n#define STROKE_CAP_ROUND 0\n#define STROKE_CAP_PROJECT 1\n#define STROKE_CAP_SQUARE 2\n#define STROKE_JOIN_ROUND 0\n#define STROKE_JOIN_MITER 1\n#define STROKE_JOIN_BEVEL 2\nprecision mediump int;\n\nuniform vec4 uMaterialColor;\nuniform int uStrokeCap;\nuniform int uStrokeJoin;\nuniform float uStrokeWeight;\n\nIN vec4 vColor;\nIN vec2 vTangent;\nIN vec2 vCenter;\nIN vec2 vPosition;\nIN float vMaxDist;\nIN float vCap;\nIN float vJoin;\n\nfloat distSquared(vec2 a, vec2 b) {\n vec2 aToB = b - a;\n return dot(aToB, aToB);\n}\n\nvoid main() {\n if (vCap > 0.) {\n if (\n uStrokeCap == STROKE_CAP_ROUND &&\n distSquared(vPosition, vCenter) > uStrokeWeight * uStrokeWeight * 0.25\n ) {\n discard;\n } else if (\n uStrokeCap == STROKE_CAP_SQUARE &&\n dot(vPosition - vCenter, vTangent) > 0.\n ) {\n discard;\n }\n // Use full area for PROJECT\n } else if (vJoin > 0.) {\n if (\n uStrokeJoin == STROKE_JOIN_ROUND &&\n distSquared(vPosition, vCenter) > uStrokeWeight * uStrokeWeight * 0.25\n ) {\n discard;\n } else if (uStrokeJoin == STROKE_JOIN_BEVEL) {\n vec2 normal = vec2(-vTangent.y, vTangent.x);\n if (abs(dot(vPosition - vCenter, normal)) > vMaxDist) {\n discard;\n }\n }\n // Use full area for MITER\n }\n OUT_COLOR = vec4(vColor.rgb, 1.) * vColor.a;\n}\n",tn.lineVert="\n#ifdef WEBGL2\n\n#define IN in\n#define OUT out\n\n#ifdef FRAGMENT_SHADER\nout vec4 outColor;\n#define OUT_COLOR outColor\n#endif\n#define TEXTURE texture\n\n#else\n\n#ifdef FRAGMENT_SHADER\n#define IN varying\n#else\n#define IN attribute\n#endif\n#define OUT varying\n#define TEXTURE texture2D\n\n#ifdef FRAGMENT_SHADER\n#define OUT_COLOR gl_FragColor\n#endif\n\n#endif\n#define STROKE_CAP_ROUND 0\n#define STROKE_CAP_PROJECT 1\n#define STROKE_CAP_SQUARE 2\n#define STROKE_JOIN_ROUND 0\n#define STROKE_JOIN_MITER 1\n#define STROKE_JOIN_BEVEL 2\n/*\n Part of the Processing project - http://processing.org\n Copyright (c) 2012-15 The Processing Foundation\n Copyright (c) 2004-12 Ben Fry and Casey Reas\n Copyright (c) 2001-04 Massachusetts Institute of Technology\n This library is free software; you can redistribute it and/or\n modify it under the terms of the GNU Lesser General Public\n License as published by the Free Software Foundation, version 2.1.\n This library is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n Lesser General Public License for more details.\n You should have received a copy of the GNU Lesser General\n Public License along with this library; if not, write to the\n Free Software Foundation, Inc., 59 Temple Place, Suite 330,\n Boston, MA 02111-1307 USA\n*/\n\n#define PROCESSING_LINE_SHADER\n\nprecision mediump int;\n\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\nuniform float uStrokeWeight;\n\nuniform bool uUseLineColor;\nuniform vec4 uMaterialColor;\n\nuniform vec4 uViewport;\nuniform int uPerspective;\nuniform int uStrokeJoin;\n\nIN vec4 aPosition;\nIN vec3 aTangentIn;\nIN vec3 aTangentOut;\nIN float aSide;\nIN vec4 aVertexColor;\n\nOUT vec4 vColor;\nOUT vec2 vTangent;\nOUT vec2 vCenter;\nOUT vec2 vPosition;\nOUT float vMaxDist;\nOUT float vCap;\nOUT float vJoin;\n\nvec2 lineIntersection(vec2 aPoint, vec2 aDir, vec2 bPoint, vec2 bDir) {\n // Rotate and translate so a starts at the origin and goes out to the right\n bPoint -= aPoint;\n vec2 rotatedBFrom = vec2(\n bPoint.x*aDir.x + bPoint.y*aDir.y,\n bPoint.y*aDir.x - bPoint.x*aDir.y\n );\n vec2 bTo = bPoint + bDir;\n vec2 rotatedBTo = vec2(\n bTo.x*aDir.x + bTo.y*aDir.y,\n bTo.y*aDir.x - bTo.x*aDir.y\n );\n float intersectionDistance =\n rotatedBTo.x + (rotatedBFrom.x - rotatedBTo.x) * rotatedBTo.y /\n (rotatedBTo.y - rotatedBFrom.y);\n return aPoint + aDir * intersectionDistance;\n}\n\nvoid main() {\n // Caps have one of either the in or out tangent set to 0\n vCap = (aTangentIn == vec3(0.)) != (aTangentOut == (vec3(0.)))\n ? 1. : 0.;\n\n // Joins have two unique, defined tangents\n vJoin = (\n aTangentIn != vec3(0.) &&\n aTangentOut != vec3(0.) &&\n aTangentIn != aTangentOut\n ) ? 1. : 0.;\n\n vec4 posp = uModelViewMatrix * aPosition;\n vec4 posqIn = uModelViewMatrix * (aPosition + vec4(aTangentIn, 0));\n vec4 posqOut = uModelViewMatrix * (aPosition + vec4(aTangentOut, 0));\n\n float facingCamera = pow(\n // The word space tangent's z value is 0 if it's facing the camera\n abs(normalize(posqIn-posp).z),\n\n // Using pow() here to ramp facingCamera up from 0 to 1 really quickly\n // so most lines get scaled and don't get clipped\n 0.25\n );\n\n // using a scale <1 moves the lines towards the camera\n // in order to prevent popping effects due to half of\n // the line disappearing behind the geometry faces.\n float scale = mix(1.0, 0.995, facingCamera);\n // Moving vertices slightly toward the camera\n // to avoid depth-fighting with the fill triangles.\n // Discussed here:\n // http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=252848 \n posp.xyz = posp.xyz * scale;\n posqIn.xyz = posqIn.xyz * scale;\n posqOut.xyz = posqOut.xyz * scale;\n\n vec4 p = uProjectionMatrix * posp;\n vec4 qIn = uProjectionMatrix * posqIn;\n vec4 qOut = uProjectionMatrix * posqOut;\n vCenter = p.xy;\n\n // formula to convert from clip space (range -1..1) to screen space (range 0..[width or height])\n // screen_p = (p.xy/p.w + <1,1>) * 0.5 * uViewport.zw\n\n // prevent division by W by transforming the tangent formula (div by 0 causes\n // the line to disappear, see https://github.com/processing/processing/issues/5183)\n // t = screen_q - screen_p\n //\n // tangent is normalized and we don't care which aDirection it points to (+-)\n // t = +- normalize( screen_q - screen_p )\n // t = +- normalize( (q.xy/q.w+<1,1>)*0.5*uViewport.zw - (p.xy/p.w+<1,1>)*0.5*uViewport.zw )\n //\n // extract common factor, <1,1> - <1,1> cancels out\n // t = +- normalize( (q.xy/q.w - p.xy/p.w) * 0.5 * uViewport.zw )\n //\n // convert to common divisor\n // t = +- normalize( ((q.xy*p.w - p.xy*q.w) / (p.w*q.w)) * 0.5 * uViewport.zw )\n //\n // remove the common scalar divisor/factor, not needed due to normalize and +-\n // (keep uViewport - can't remove because it has different components for x and y\n // and corrects for aspect ratio, see https://github.com/processing/processing/issues/5181)\n // t = +- normalize( (q.xy*p.w - p.xy*q.w) * uViewport.zw )\n\n vec2 tangentIn = normalize((qIn.xy*p.w - p.xy*qIn.w) * uViewport.zw);\n vec2 tangentOut = normalize((qOut.xy*p.w - p.xy*qOut.w) * uViewport.zw);\n\n vec2 curPerspScale;\n if(uPerspective == 1) {\n // Perspective ---\n // convert from world to clip by multiplying with projection scaling factor\n // to get the right thickness (see https://github.com/processing/processing/issues/5182)\n\n // The y value of the projection matrix may be flipped if rendering to a Framebuffer.\n // Multiplying again by its sign here negates the flip to get just the scale.\n curPerspScale = (uProjectionMatrix * vec4(1, sign(uProjectionMatrix[1][1]), 0, 0)).xy;\n } else {\n // No Perspective ---\n // multiply by W (to cancel out division by W later in the pipeline) and\n // convert from screen to clip (derived from clip to screen above)\n curPerspScale = p.w / (0.5 * uViewport.zw);\n }\n\n vec2 offset;\n if (vJoin == 1.) {\n vTangent = normalize(tangentIn + tangentOut);\n vec2 normalIn = vec2(-tangentIn.y, tangentIn.x);\n vec2 normalOut = vec2(-tangentOut.y, tangentOut.x);\n float side = sign(aSide);\n float sideEnum = abs(aSide);\n\n // We generate vertices for joins on either side of the centerline, but\n // the \"elbow\" side is the only one needing a join. By not setting the\n // offset for the other side, all its vertices will end up in the same\n // spot and not render, effectively discarding it.\n if (sign(dot(tangentOut, vec2(-tangentIn.y, tangentIn.x))) != side) {\n // Side enums:\n // 1: the side going into the join\n // 2: the middle of the join\n // 3: the side going out of the join\n if (sideEnum == 2.) {\n // Calculate the position + tangent on either side of the join, and\n // find where the lines intersect to find the elbow of the join\n vec2 c = (posp.xy/posp.w + vec2(1.,1.)) * 0.5 * uViewport.zw;\n vec2 intersection = lineIntersection(\n c + (side * normalIn * uStrokeWeight / 2.),\n tangentIn,\n c + (side * normalOut * uStrokeWeight / 2.),\n tangentOut\n );\n offset = (intersection - c);\n\n // When lines are thick and the angle of the join approaches 180, the\n // elbow might be really far from the center. We'll apply a limit to\n // the magnitude to avoid lines going across the whole screen when this\n // happens.\n float mag = length(offset);\n float maxMag = 3. * uStrokeWeight;\n if (mag > maxMag) {\n offset *= maxMag / mag;\n }\n } else if (sideEnum == 1.) {\n offset = side * normalIn * uStrokeWeight / 2.;\n } else if (sideEnum == 3.) {\n offset = side * normalOut * uStrokeWeight / 2.;\n }\n }\n if (uStrokeJoin == STROKE_JOIN_BEVEL) {\n vec2 avgNormal = vec2(-vTangent.y, vTangent.x);\n vMaxDist = abs(dot(avgNormal, normalIn * uStrokeWeight / 2.));\n } else {\n vMaxDist = uStrokeWeight / 2.;\n }\n } else {\n vec2 tangent = aTangentIn == vec3(0.) ? tangentOut : tangentIn;\n vTangent = tangent;\n vec2 normal = vec2(-tangent.y, tangent.x);\n\n float normalOffset = sign(aSide);\n // Caps will have side values of -2 or 2 on the edge of the cap that\n // extends out from the line\n float tangentOffset = abs(aSide) - 1.;\n offset = (normal * normalOffset + tangent * tangentOffset) *\n uStrokeWeight * 0.5;\n vMaxDist = uStrokeWeight / 2.;\n }\n vPosition = vCenter + offset;\n\n gl_Position.xy = p.xy + offset.xy * curPerspScale;\n gl_Position.zw = p.zw;\n \n vColor = (uUseLineColor ? aVertexColor : uMaterialColor);\n}\n";var en={};Object.defineProperty(en,"__esModule",{value:!0}),en.default=function(t,e){const n=t.split(".").reverse().reduce(((t,e,n)=>t+e*1e3**n),0),i=e.split(".").reverse().reduce(((t,e,n)=>t+e*1e3**n),0);return n===i?0:(n-i)/Math.abs(n-i)};var nn=rn(en);function rn(t){return t&&t.__esModule?t:{default:t}}function on(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(on=function(t){return t?n:e})(t)}const sn=p5.prototype.createCanvas;p5.prototype.createCanvas=function(t,e,n,r){let o=n;const s=n===i.AR||n===i.VR;(n===i.AR_BUTTON||n===i.VR_BUTTON||s)&&(noLoop(),p5xr.instance=n===i.AR||n===i.AR_BUTTON?new Qe.default:new We.default,o=WEBGL,windowWidth,windowHeight,s&&p5xr.instance.startXRWithoutUserAction()),sn.call(this,windowWidth,windowHeight,o,r)};const an=p5.prototype.background;p5.prototype.background=function(...t){const e=this._renderer.GL,n=this._renderer._viewport;return e.scissor(n[0],n[1],n[2],n[3]),e.enable(e.SCISSOR_TEST),an.call(this,...t),e.disable(e.SCISSOR_TEST),this};(0,nn.default)(p5.VERSION,"1.10.0")>=0&&(console.log("p5.xr: overriding p5 v1.10.x line vert shader for v1.9.4"),p5.RendererGL.prototype._getLineShader=function(){return this._customLineShader||(this._customLineShader=new p5.Shader(this,this._webGL2CompatibilityPrefix("vert","mediump")+tn.lineVert,this._webGL2CompatibilityPrefix("frag","mediump")+tn.lineFrag)),this._customLineShader});if((0,nn.default)(p5.VERSION,"1.9.2")>=0){console.log("p5.xr: Overriding camera copy so linePerspective works with push pop");const t=p5.Camera.prototype.copy;p5.Camera.prototype.copy=function(){const e=t.call(this);return e.useLinePerspective=this.useLinePerspective,e};const e=p5.Camera.prototype.set;p5.Camera.prototype.set=function(t){return e.call(this,t),this.useLinePerspective=t.useLinePerspective,this}}var hn=un(r),cn=un(He);function un(t){return t&&t.__esModule?t:{default:t}}function ln(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(ln=function(t){return t?n:e})(t)}window.p5xr={instance:null};for(const t in n)p5.prototype[t]=n[t];p5.prototype.createVRCanvas=function(){noLoop(),p5xr.instance=new hn.default},p5.prototype.createARCanvas=function(){noLoop(),p5xr.instance=new cn.default},p5.prototype.getXRButton=function(){if(p5xr&&p5xr.instance&&p5xr.instance.xrButton)return p5xr.instance.xrButton;console.warn("No XR button found. Make sure to call createVRCanvas() or createARCanvas() first.")},p5.prototype.createXRButton=function(t){return new p5xrButton(t)},p5.prototype.setVRBackgroundColor=function(t,e,n){p5xr.instance.curClearColor=color(t,e,n)},p5.prototype.surroundTexture=function(t){push(),texture(t),rotateX(PI),scale(-1,1,1),sphere(300,60,40),pop()},p5.prototype.createAnchor=function(t){if(!p5xr.instance.isVR)return p5xr.instance.__createAnchor(t)},p5.prototype.detectHit=function(t){if(!p5xr.instance.isVR)return p5xr.instance.__detectHit(t)},p5.prototype.getXRInput=function(t){if(0!==p5xr.instance.xrSession.inputSources.length)return p5xr.instance.__getXRInput(t)},p5.prototype.setViewerPosition=function(t,e,n){const{viewer:i}=p5xr.instance;i.setPosition(t,e,n)},p5.prototype.getViewer=function(){return p5xr.instance&&p5xr.instance.viewer||console.warn("No viewer found. Make sure to call createVRCanvas() or createARCanvas() first."),p5xr.instance.viewer},p5.prototype.sticky=function(t=!1){push(),p5xr.instance.viewer.drawOnTop=t,t&&p5.instance._renderer.GL.disable(p5.instance._renderer.GL.DEPTH_TEST),p5.instance._renderer.uMVMatrix.set(p5.Matrix.identity());const e=p5xr.instance.viewer.position;setViewerPosition(e.x,e.y,e.z)},p5.prototype.noSticky=function(){p5.instance._renderer.GL.enable(p5.instance._renderer.GL.DEPTH_TEST),pop()},p5.prototype.getRayFromScreen=function(t,e){p5xr.instance&&p5xr.instance.viewer||console.warn("No viewer found to calculate Ray. Make sure to call createVRCanvas() or createARCanvas() first.");const{viewer:n}=p5xr.instance;return n.getRayFromScreen(t,e)},p5.prototype.intersectsSphere=function(t){let e={origin:null,direction:null};if(2===arguments.length&&Object.hasOwn(arguments[1],"origin"))e.origin=arguments[1].origin.copy(),e.direction=arguments[1].direction.copy();else{const t=arguments[1]||0,n=arguments[2]||0;e=p5xr.instance.viewer.getRayFromScreen(t,n)}if(null===e)return!1;let n=p5.instance._renderer.uMVMatrix.copy();n.transpose(n),n=n.mat4;const i=new p5.Vector(0,0,0);if(i.x=n[3],i.y=n[7],i.z=n[11],p5.Vector.sub(e.origin,i).mag()<=t)return!0;if(p5.Vector.dot(p5.Vector.sub(i,e.origin),e.direction)<0)return!1;const r=p5.Vector.sub(e.origin,i),o=2*p5.Vector.dot(e.direction,r),s=p5.Vector.mag(r)*p5.Vector.mag(r)-t*t,a=o*o-4*s;return a>=0},p5.prototype.intersectsBox=function(){const t=arguments[0];let e,n,i={origin:null,direction:null};Object.hasOwn(arguments[arguments.length-1],"origin")?(i.origin=arguments[arguments.length-1].origin.copy(),i.direction=arguments[arguments.length-1].direction.copy(),e=arguments.length>2?arguments[1]:t,n=arguments.length>3?arguments[2]:e):5===arguments.length?(i=p5xr.instance.viewer.getRayFromScreen(arguments[3],arguments[4]),e=arguments[1],n=arguments[2]):(i=p5xr.instance.viewer.getRayFromScreen(0,0),e=arguments.length>1?arguments[1]:t,n=arguments.length>2?arguments[2]:e);let r=p5.instance._renderer.uMVMatrix.copy();r.transpose(r),r.invert(r),r=r.mat4;const o=i.origin.copy();i.origin.x=r[0]*o.x+r[1]*o.y+r[2]*o.z+r[3],i.origin.y=r[4]*o.x+r[5]*o.y+r[6]*o.z+r[7],i.origin.z=r[8]*o.x+r[9]*o.y+r[10]*o.z+r[11];const s=i.direction.copy();i.direction.x=r[0]*s.x+r[1]*s.y+r[2]*s.z,i.direction.y=r[4]*s.x+r[5]*s.y+r[6]*s.z,i.direction.z=r[8]*s.x+r[9]*s.y+r[10]*s.z,i.direction.normalize();const a=new p5.Vector(-.5*t,-.5*e,-.5*n),h=new p5.Vector(.5*t,.5*e,.5*n),c=(a.x-i.origin.x)/i.direction.x,u=(h.x-i.origin.x)/i.direction.x,l=(a.y-i.origin.y)/i.direction.y,p=(h.y-i.origin.y)/i.direction.y,d=(a.z-i.origin.z)/i.direction.z,f=(h.z-i.origin.z)/i.direction.z,g=Math.max(Math.max(Math.min(c,u),Math.min(l,p)),Math.min(d,f)),v=Math.min(Math.min(Math.max(c,u),Math.max(l,p)),Math.max(d,f));return!(v<0||g>v)},p5.prototype.intersectsPlane=function(){let t={origin:null,direction:null};const{origin:e,direction:n}=arguments.length>0?arguments[0]:{};e&&n?(t.origin=e.copy(),t.direction=n.copy()):t=p5xr.instance.viewer.getRayFromScreen(arguments[0],arguments[1]);let i=p5.instance._renderer.uMVMatrix.copy();i.transpose(i),i.invert(i),i=i.mat4;const r=t.origin.copy();t.origin.x=i[0]*r.x+i[1]*r.y+i[2]*r.z+i[3],t.origin.y=i[4]*r.x+i[5]*r.y+i[6]*r.z+i[7],t.origin.z=i[8]*r.x+i[9]*r.y+i[10]*r.z+i[11];const o=t.direction.copy();t.direction.x=i[0]*o.x+i[1]*o.y+i[2]*o.z,t.direction.y=i[4]*o.x+i[5]*o.y+i[6]*o.z,t.direction.z=i[8]*o.x+i[9]*o.y+i[10]*o.z,t.direction.normalize();const s=new p5.Vector(0,0,1),a=new p5.Vector(0,0,0),h=p5.Vector.sub(a,t.origin),c=Math.abs(p5.Vector.dot(t.direction,s));if(0===c)return null;const u=Math.abs(p5.Vector.dot(h,s)/c),l=p5.Vector.add(t.origin,t.direction.copy().setMag(u));return createVector(l.x,l.y)},p5.prototype.generateRay=function(t,e,n,i,r,o){const s=new p5.Vector(t,e,n);let a=new p5.Vector(i,r,o);a=p5.Vector.sub(a,s),a.normalize();let h=p5.instance._renderer.uMVMatrix.copy();h.transpose(h),h=h.mat4;const c=s.copy();s.x=h[0]*c.x+h[1]*c.y+h[2]*c.z+h[3],s.y=h[4]*c.x+h[5]*c.y+h[6]*c.z+h[7],s.z=h[8]*c.x+h[9]*c.y+h[10]*c.z+h[11];const u=a.copy();return a.x=h[0]*u.x+h[1]*u.y+h[2]*u.z,a.y=h[4]*u.x+h[5]*u.y+h[6]*u.z,a.z=h[8]*u.x+h[9]*u.y+h[10]*u.z,a.normalize(),{origin:s,direction:a}}})();