VR-Procedural-Generated-Forest/p5xr.js

96 lines
207 KiB
JavaScript
Raw Normal View History

2022-06-27 09:26:20 +02:00
(()=>{var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{};function t(e,t,i,r){Object.defineProperty(e,t,{get:i,set:r,enumerable:!0,configurable:!0})}var i,r={};i=r,Object.defineProperty(i,"__esModule",{value:!0,configurable:!0}),t(r,"default",(()=>dt));
/**
* @license
* webxr-polyfill
* Copyright (c) 2017 Google
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @license
* cardboard-vr-display
* Copyright (c) 2015-2017 Google
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @license
* webvr-polyfill-dpdb
* Copyright (c) 2017 Google
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @license
* wglu-preserve-state
* Copyright (c) 2016, Brandon Jones.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @license
* nosleep.js
* Copyright (c) 2017, Rich Tibbett
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
const n=void 0!==e?e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},s=Symbol("@@webxr-polyfill/EventTarget");class a{constructor(){this[s]={listeners:new Map}}addEventListener(e,t){if("string"!=typeof e)throw new Error("`type` must be a string");if("function"!=typeof t)throw new Error("`listener` must be a function");const i=this[s].listeners.get(e)||[];i.push(t),this[s].listeners.set(e,i)}removeEventListener(e,t){if("string"!=typeof e)throw new Error("`type` must be a string");if("function"!=typeof t)throw new Error("`listener` must be a function");const i=this[s].listeners.get(e)||[];for(let e=i.length;e>=0;e--)i[e]===t&&i.pop()}dispatchEvent(e,t){const i=this[s].listeners.get(e)||[],r=[];for(let e=0;e<i.length;e++)r[e]=i[e];for(let e of r)e(t);"function"==typeof this[`on${e}`]&&this[`on${e}`](t)}}let o="undefined"!=typeof Float32Array?Float32Array:Array;Math.PI;function l(){let e=new o(16);return o!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function c(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function h(e,t){let i=t[0],r=t[1],n=t[2],s=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],A=t[11],p=t[12],f=t[13],m=t[14],g=t[15],v=i*o-r*a,w=i*l-n*a,y=i*c-s*a,b=r*l-n*o,E=r*c-s*o,x=n*c-s*l,M=h*f-u*p,S=h*m-d*p,_=h*g-A*p,R=u*m-d*f,F=u*g-A*f,T=d*g-A*m,P=v*T-w*F+y*R+b*_-E*S+x*M;return P?(P=1/P,e[0]=(o*T-l*F+c*R)*P,e[1]=(n*F-r*T-s*R)*P,e[2]=(f*x-m*E+g*b)*P,e[3]=(d*E-u*x-A*b)*P,e[4]=(l*_-a*T-c*S)*P,e[5]=(i*T-n*_+s*S)*P,e[6]=(m*y-p*x-g*w)*P,e[7]=(h*x-d*y+A*w)*P,e[8]=(a*F-o*_+c*M)*P,e[9]=(r*_-i*F-s*M)*P,e[10]=(p*E-f*y+g*v)*P,e[11]=(u*y-h*E-A*v)*P,e[12]=(o*S-a*R-l*M)*P,e[13]=(i*R-r*S+n*M)*P,e[14]=(f*w-p*b-m*v)*P,e[15]=(h*b-u*w+d*v)*P,e):null}function u(e,t,i){let r=t[0],n=t[1],s=t[2],a=t[3],o=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=t[9],A=t[10],p=t[11],f=t[12],m=t[13],g=t[14],v=t[15],w=i[0],y=i[1],b=i[2],E=i[3];return e[0]=w*r+y*o+b*u+E*f,e[1]=w*n+y*l+b*d+E*m,e[2]=w*s+y*c+b*A+E*g,e[3]=w*a+y*h+b*p+E*v,w=i[4],y=i[5],b=i[6],E=i[7],e[4]=w*r+y*o+b*u+E*f,e[5]=w*n+y*l+b*d+E*m,e[6]=w*s+y*c+b*A+E*g,e[7]=w*a+y*h+b*p+E*v,w=i[8],y=i[9],b=i[10],E=i[11],e[8]=w*r+y*o+b*u+E*f,e[9]=w*n+y*l+b*d+E*m,e[10]=w*s+y*c+b*A+E*g,e[11]=w*a+y*h+b*p+E*v,w=i[12],y=i[13],b=i[14],E=i[15],e[12]=w*r+y*o+b*u+E*f,e[13]=w*n+y*l+b*d+E*m,e[14]=w*s+y*c+b*A+E*g,e[15]=w*a+y*h+b*p+E*v,e}function d(e,t,i){let r=t[0],n=t[1],s=t[2],a=t[3],o=r+r,l=n+n,c=s+s,h=r*o,u=r*l,d=r*c,A=n*l,p=n*c,f=s*c,m=a*o,g=a*l,v=a*c;return e[0]=1-(A+f),e[1]=u+v,e[2]=d-g,e[3]=0,e[4]=u-v,e[5]=1-(h+f),e[6]=p+m,e[7]=0,e[8]=d+g,e[9]=p-m,e[10]=1-(h+A),e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e}function A(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function p(e,t){let i=t[0]+t[5]+t[10],r=0;return i>0?(r=2*Math.sqrt(i+1),e[3]=.25*r,e[0]=(t[6]-t[9])/r,e[1]=(t[8]-t[2])/r,e[2]=(t[1]-t[4])/r):t[0]>t[5]&&t[0]>t[10]?(r=2*Math.sqrt(1+t[0]-t[5]-t[10]),e[3]=(t[6]-t[9])/r,e[0]=.25*r,e[1]=(t[1]+t[4])/r,e[2]=(t[8]+t[2])/r):t[5]>t[10]?(r=2*Math.sqrt(1+t[5]-t[0]-t[10]),e[3]=(t[8]-t[2])/r,e[0]=(t[1]+t[4])/r,e[1]=.25*r,e[2]=(t[6]+t[9])/r):(r=2*Math.sqrt(1+t[10]-t[0]-t[5]),e[3]=(t[1]-t[4])/r,e[0]=(t[8]+t[2])/r,e[1]=(t[6]+t[9])/r,e[2]=.25*r),e}function f(e,t,i,r,n){let s,a=1/Math.tan(t/2);return e[0]=a/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(s=1/(r-n),e[10]=(n+r)*s,e[14]=2*n*r*s):(e[10]=-1,e[14]=-2*r),e}function m(){let e=new o(3);return o!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function g(e){var t=new o(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function v(e,t,i){let r=new o(3);return r[0]=e,r[1]=t,r[2]=i,r}function w(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function y(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function b(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function E(e,t){let i=t[0],r=t[1],n=t[2],s=i*i+r*r+n*n;return s>0&&(s=1/Math.sqrt(s),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s),e}function x(e,t){return e[0]*t[