zeroxr
Version:
ZeroXR is a lightweight React Renderer for WebGL run on WebXR devices
1 lines • 70.6 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("React")):"function"==typeof define&&define.amd?define(["React"],e):"object"==typeof exports?exports.zeroxr=e(require("React")):t.zeroxr=e(t.React)}(self,(function(t){return(()=>{var e,n,r,o,i,a={213:(t,e,n)=>{"use strict";n.d(e,{Cq:()=>o,m8:()=>a,GP:()=>i});var r=n(913);const o={textDetector:{model:window.TextDetector?new TextDetector:null,enable:!1,onResult:null},barcodeDetector:{model:window.BarcodeDetector?new BarcodeDetector({formats:["qr_code"]}):null,enable:!1,onResult:null},faceDetector:{model:window.FaceDetector?new FaceDetector({maxDetectedFaces:1,fastMode:!1}):null,enable:!1,onResult:null}};function i(t,e){o[t].onResult=e}function a(t,e){for(let n in o){const r=o[n];r.model&&r.enable&&r.onResult&&s(r,t,e)}}function s(t,e,n){try{t.model.detect(e).then((async e=>{const o=await(0,r.cH)(e,n);t.onResult(o)}))}catch(t){console.error("Shape detection fail ",t)}}},605:(t,e,n)=>{"use strict";n.d(e,{fL:()=>s,Fq:()=>m,H4:()=>d});var r=n(931),o=(n(377),n(213));n(913);document.querySelector("video");const i=r.gl.createFramebuffer();let a=0,s=null,c=null,l=null,u=null,f=!1;function d(t,e,n,r){}function h(t,e){requestIdleCallback((n=>{!function(t,e,n){r.gl.clientWaitSync(t,0,0)!=r.gl.TIMEOUT_EXPIRED?(r.gl.deleteSync(t),r.gl.bindBuffer(r.gl.PIXEL_PACK_BUFFER,u),r.gl.getBufferSubData(r.gl.PIXEL_PACK_BUFFER,0,c),function(t){let e=t.camera.height/4|0,n=2*t.camera.width;l||(l=new Uint8Array(n));for(let r=0;r<e;++r){const e=r*n,o=(t.camera.height/2-r-1)*n;l.set(c.subarray(e,e+n)),c.copyWithin(e,o,o+n),c.set(l,o)}}(e),s.data.set(c),(0,o.m8)(s,e),f=!1):h(t,e)}(t,e)}),{timeout:3e3})}function m(t,e){a++,a%20!=0||f||function(t,e){r.gl.bindFramebuffer(r.gl.FRAMEBUFFER,i),r.gl.framebufferTexture2D(r.gl.FRAMEBUFFER,r.gl.COLOR_ATTACHMENT0,r.gl.TEXTURE_2D,t,0),u?r.gl.bindBuffer(r.gl.PIXEL_PACK_BUFFER,u):(u=r.gl.createBuffer(),r.gl.bindBuffer(r.gl.PIXEL_PACK_BUFFER,u),r.gl.bufferData(r.gl.PIXEL_PACK_BUFFER,e.camera.width*e.camera.height,r.gl.STREAM_READ),c=new Uint8ClampedArray(e.camera.width*e.camera.height),s=new ImageData(e.camera.width/2,e.camera.height/2)),r.gl.readPixels(e.camera.width/4,e.camera.height/4,e.camera.width/2,e.camera.height/2,r.gl.RGBA,r.gl.UNSIGNED_BYTE,0);const n=r.gl.fenceSync(r.gl.SYNC_GPU_COMMANDS_COMPLETE,0);f=!0,requestIdleCallback((t=>h(n,e)))}(t,e)}},931:(t,e,n)=>{"use strict";n.d(e,{Ns:()=>f,gl:()=>c,Ah:()=>l,bq:()=>u});var r=n(828),o=n(196),i=n(792),a=n(387);const s={NaturalWidth:8192,NaturalHeight:3435,FontHeight:307,MaxAscent:314,MaxDescent:130,Glyphs:[[0,-1,-1,0,0,0,0,0,0],[1,-1,-1,0,0,0,0,0,0],[2,-1,-1,0,0,0,0,0,0],[3,-1,-1,0,0,0,0,0,0],[4,-1,-1,0,0,0,0,0,0],[5,-1,-1,0,0,0,0,0,0],[6,-1,-1,0,0,0,0,0,0],[7,-1,-1,0,0,0,0,0,0],[8,-1,-1,0,0,0,0,0,0],[9,-1,-1,0,0,0,0,0,0],[10,-1,-1,0,0,0,0,0,0],[11,-1,-1,0,0,0,0,0,0],[12,-1,-1,0,0,0,0,0,0],[13,1365,3220,128,128,116,253,-64,64],[14,-1,-1,0,0,0,0,0,0],[15,-1,-1,0,0,0,0,0,0],[16,-1,-1,0,0,0,0,0,0],[17,-1,-1,0,0,0,0,0,0],[18,-1,-1,0,0,0,0,0,0],[19,-1,-1,0,0,0,0,0,0],[20,-1,-1,0,0,0,0,0,0],[21,-1,-1,0,0,0,0,0,0],[22,-1,-1,0,0,0,0,0,0],[23,-1,-1,0,0,0,0,0,0],[24,-1,-1,0,0,0,0,0,0],[25,-1,-1,0,0,0,0,0,0],[26,-1,-1,0,0,0,0,0,0],[27,-1,-1,0,0,0,0,0,0],[28,-1,-1,0,0,0,0,0,0],[29,-1,-1,0,0,0,0,0,0],[30,-1,-1,0,0,0,0,0,0],[31,-1,-1,0,0,0,0,0,0],[32,1237,3220,128,128,119,253,-64,64],[33,3410,1438,164,317,106,253,-29,250],[34,6106,2964,203,197,121,253,-41,250],[35,2278,1756,276,314,158,253,-59,250],[36,6816,752,260,327,152,253,-54,257],[37,4379,752,338,333,234,253,-52,259],[38,3184,1114,300,322,192,253,-54,254],[39,6656,2964,153,197,70,253,-41,250],[40,1362,0,187,380,75,253,-52,274],[41,1549,0,187,380,75,253,-61,274],[42,4683,2964,238,232,127,253,-56,250],[43,5471,2693,263,263,173,253,-44,215],[44,6309,2964,174,197,72,253,-54,96],[45,259,3220,204,151,98,253,-53,141],[46,7774,2964,164,164,72,253,-46,97],[47,4951,752,233,333,104,253,-66,256],[48,3773,1114,275,322,173,253,-51,254],[49,7387,1756,202,314,119,253,-52,250],[50,7079,1114,253,319,151,253,-52,254],[51,1418,1114,256,323,155,253,-50,254],[52,3102,1756,272,314,158,253,-56,250],[53,6824,1114,255,319,155,253,-49,250],[54,6559,1114,265,319,161,253,-51,251],[55,4936,1756,253,314,143,253,-55,250],[56,4048,1114,264,322,162,253,-51,254],[57,5300,1114,265,320,163,253,-52,254],[58,810,2964,164,256,72,253,-46,189],[59,6375,2383,174,290,72,253,-54,189],[60,6549,2383,256,280,168,253,-44,219],[61,5132,2964,263,200,175,253,-44,183],[62,6805,2383,256,280,168,253,-44,219],[63,4573,1114,249,321,148,253,-51,254],[64,318,1114,319,323,215,253,-52,213],[65,4945,1438,309,315,187,253,-61,250],[66,1724,1756,277,314,181,253,-42,250],[67,3484,1114,289,322,181,253,-53,254],[68,0,1756,296,314,200,253,-42,250],[69,4681,1756,255,314,163,253,-42,250],[70,5189,1756,250,314,153,253,-42,250],[71,2884,1114,300,322,200,253,-53,254],[72,880,1756,285,314,201,253,-42,250],[73,7589,1756,156,314,72,253,-42,250],[74,1146,1438,233,318,132,253,-60,250],[75,1165,1756,280,314,179,253,-41,250],[76,5935,1756,246,314,141,253,-42,250],[77,7199,1438,328,314,240,253,-44,250],[78,296,1756,292,314,208,253,-42,250],[79,1915,1114,325,322,219,253,-53,254],[80,3374,1756,263,314,166,253,-42,250],[81,0,1438,333,318,218,253,-53,254],[82,5536,1438,271,315,172,253,-42,250],[83,4312,1114,261,322,156,253,-52,254],[84,1445,1756,279,314,159,253,-60,250],[85,620,1438,284,318,200,253,-42,250],[86,7527,1438,300,314,182,253,-59,250],[87,6065,1438,384,314,265,253,-59,250],[88,7827,1438,297,314,175,253,-61,250],[89,588,1756,292,314,174,253,-59,250],[90,2828,1756,274,314,167,253,-53,250],[91,2445,0,178,379,83,253,-39,273],[92,4717,752,234,333,103,253,-65,256],[93,2623,0,178,379,83,253,-56,273],[94,3559,2964,257,244,169,253,-44,256],[95,853,3220,256,143,128,253,-64,44],[96,7245,2964,183,170,65,253,-67,245],[97,7654,2693,244,257,145,253,-53,190],[98,898,1114,260,323,161,253,-47,255],[99,7185,2693,239,259,132,253,-53,191],[100,637,1114,261,323,161,253,-53,255],[101,6937,2693,248,259,142,253,-53,191],[102,1379,1438,213,318,87,253,-60,254],[103,5565,1114,260,320,160,253,-51,191],[104,6071,1114,244,320,150,253,-47,255],[105,7986,2070,162,311,64,253,-49,247],[106,3577,0,190,376,65,253,-77,247],[107,6315,1114,244,320,135,253,-47,255],[108,7761,1114,155,319,65,253,-45,255],[109,0,2964,324,256,230,253,-47,191],[110,324,2964,244,256,150,253,-47,191],[111,6676,2693,261,259,155,253,-53,191],[112,2486,1438,260,317,161,253,-47,191],[113,2225,1438,261,317,161,253,-53,191],[114,974,2964,204,255,98,253,-47,191],[115,7424,2693,230,258,123,253,-54,191],[116,6163,2383,212,295,95,253,-59,227],[117,568,2964,242,256,147,253,-47,188],[118,1994,2964,255,251,133,253,-61,187],[119,1413,2964,325,251,203,253,-61,187],[120,1738,2964,256,251,134,253,-61,187],[121,774,2070,255,313,133,253,-61,187],[122,1178,2964,235,252,119,253,-57,187],[123,2245,0,200,379,92,253,-54,273],[124,3314,752,146,354,68,253,-39,272],[125,2045,0,200,379,92,253,-54,273],[126,6995,2964,250,172,167,253,-41,165],[127,-1,-1,0,0,0,0,0,0],[128,-1,-1,0,0,0,0,0,0],[129,-1,-1,0,0,0,0,0,0],[130,-1,-1,0,0,0,0,0,0],[131,-1,-1,0,0,0,0,0,0],[132,-1,-1,0,0,0,0,0,0],[133,-1,-1,0,0,0,0,0,0],[134,-1,-1,0,0,0,0,0,0],[135,-1,-1,0,0,0,0,0,0],[136,-1,-1,0,0,0,0,0,0],[137,-1,-1,0,0,0,0,0,0],[138,-1,-1,0,0,0,0,0,0],[139,-1,-1,0,0,0,0,0,0],[140,-1,-1,0,0,0,0,0,0],[141,-1,-1,0,0,0,0,0,0],[142,-1,-1,0,0,0,0,0,0],[143,-1,-1,0,0,0,0,0,0],[144,-1,-1,0,0,0,0,0,0],[145,-1,-1,0,0,0,0,0,0],[146,-1,-1,0,0,0,0,0,0],[147,-1,-1,0,0,0,0,0,0],[148,-1,-1,0,0,0,0,0,0],[149,-1,-1,0,0,0,0,0,0],[150,-1,-1,0,0,0,0,0,0],[151,-1,-1,0,0,0,0,0,0],[152,-1,-1,0,0,0,0,0,0],[153,-1,-1,0,0,0,0,0,0],[154,-1,-1,0,0,0,0,0,0],[155,-1,-1,0,0,0,0,0,0],[156,-1,-1,0,0,0,0,0,0],[157,-1,-1,0,0,0,0,0,0],[158,-1,-1,0,0,0,0,0,0],[159,-1,-1,0,0,0,0,0,0],[160,1109,3220,128,128,119,253,-64,64],[161,3246,1438,164,317,106,253,-29,191],[162,7148,1756,239,314,134,253,-53,250],[163,2746,1438,256,317,147,253,-57,253],[164,5734,2693,263,262,147,253,-58,224],[165,5254,1438,282,315,154,253,-64,250],[166,3168,752,146,354,68,253,-39,272],[167,3460,752,237,349,153,253,-42,254],[168,7938,2964,216,160,65,253,-76,240],[169,2240,1114,322,322,210,253,-54,254],[170,3137,2964,210,249,99,253,-57,254],[171,4264,2964,239,242,146,253,-49,183],[172,5395,2964,263,199,175,253,-44,170],[173,463,3220,190,149,82,257,-54,143],[174,2562,1114,322,322,210,253,-54,254],[175,653,3220,200,145,65,253,-68,229],[176,4921,2964,211,211,105,253,-53,254],[177,675,2693,263,268,173,253,-44,215],[178,4055,2964,209,243,99,253,-55,291],[179,3347,2964,212,245,102,253,-55,291],[180,7428,2964,182,170,65,253,-49,245],[181,7574,752,236,327,152,257,-42,201],[182,0,2070,260,313,162,253,-44,187],[183,7610,2964,164,164,72,253,-46,161],[184,6809,2964,186,186,65,253,-58,64],[185,4503,2964,180,240,88,253,-53,288],[186,2916,2964,221,249,107,253,-57,254],[187,3816,2964,239,243,146,253,-44,183],[188,5550,752,350,331,236,253,-53,258],[189,5900,752,349,331,240,253,-53,258],[190,5184,752,366,331,251,253,-55,258],[191,4822,1114,248,321,148,253,-50,191],[192,545,385,309,366,187,253,-61,301],[193,854,385,309,366,187,253,-61,301],[194,4354,385,309,364,187,253,-61,299],[195,650,752,309,361,187,253,-61,296],[196,7460,385,309,362,187,253,-61,297],[197,1736,0,309,379,187,253,-61,314],[198,6449,1438,376,314,266,253,-61,250],[199,2801,0,289,376,181,253,-53,254],[200,3150,385,255,365,163,253,-42,301],[201,3405,385,255,365,163,253,-42,301],[202,6950,385,255,363,163,253,-42,299],[203,1560,752,255,361,163,253,-42,297],[204,3845,385,184,365,72,253,-70,301],[205,3660,385,185,365,72,253,-42,301],[206,5526,385,212,364,72,253,-70,299],[207,274,752,216,362,72,253,-72,297],[208,4633,1438,312,315,200,253,-58,250],[209,1268,752,292,361,208,253,-42,296],[210,6333,0,325,369,219,253,-53,301],[211,6008,0,325,369,219,253,-53,301],[212,7510,0,325,367,219,253,-53,299],[213,4029,385,325,364,219,253,-53,296],[214,1692,385,325,365,219,253,-53,297],[215,2403,2964,250,250,165,253,-42,209],[216,6249,752,325,331,219,253,-53,259],[217,6658,0,284,369,200,253,-42,301],[218,6942,0,284,369,200,253,-42,301],[219,0,385,284,367,200,253,-42,299],[220,2601,385,284,365,200,253,-42,297],[221,2017,385,292,365,174,253,-59,301],[222,5807,1438,258,315,162,253,-42,250],[223,1158,1114,260,323,158,253,-46,256],[224,2258,2070,244,312,145,253,-53,245],[225,2014,2070,244,312,145,253,-53,245],[226,1852,2383,244,309,145,253,-53,242],[227,4554,2383,244,306,145,253,-53,239],[228,4075,2383,244,307,145,253,-53,240],[229,3002,1438,244,317,145,253,-53,250],[230,6345,2693,331,259,225,253,-53,191],[231,1029,2070,239,313,132,253,-53,191],[232,5687,1756,248,314,142,253,-53,246],[233,5439,1756,248,314,142,253,-53,246],[234,509,2383,248,310,142,253,-53,242],[235,2587,2383,248,308,142,253,-53,240],[236,1482,2383,185,310,64,253,-76,246],[237,1667,2383,185,310,64,253,-45,246],[238,5012,2383,212,306,64,253,-74,242],[239,5459,2383,216,305,64,253,-76,240],[240,7810,752,262,325,156,253,-53,257],[241,5675,2383,244,304,150,253,-47,239],[242,3898,1756,261,314,155,253,-53,246],[243,3637,1756,261,314,155,253,-53,246],[244,0,2383,261,310,155,253,-53,242],[245,3321,2383,261,307,155,253,-53,239],[246,2326,2383,261,308,155,253,-53,240],[247,2653,2964,263,249,175,253,-44,208],[248,938,2693,263,267,155,253,-54,195],[249,6423,1756,242,314,147,253,-47,246],[250,6665,1756,242,314,147,253,-47,246],[251,1001,2383,242,310,147,253,-47,242],[252,3079,2383,242,308,147,253,-47,240],[253,4046,0,255,371,133,253,-61,245],[254,823,0,260,382,161,253,-47,256],[255,1437,385,255,366,133,253,-61,240],[257,5919,2383,244,296,145,253,-53,229],[258,959,752,309,361,187,253,-61,296],[259,2835,2383,244,308,145,253,-53,241],[260,4301,0,309,370,187,253,-61,250],[261,757,2383,244,310,145,253,-53,190],[262,4610,0,289,370,181,253,-53,302],[263,6907,1756,241,314,132,253,-53,246],[268,7835,0,289,367,181,253,-53,299],[269,1243,2383,239,310,132,253,-53,242],[270,6101,385,296,363,200,253,-42,299],[271,0,1114,318,324,161,253,-53,256],[280,4899,0,263,370,163,253,-42,250],[281,3582,2383,249,307,142,253,-53,191],[282,7205,385,255,363,163,253,-42,299],[283,261,2383,248,310,142,253,-53,242],[286,4663,385,300,364,200,253,-53,296],[287,5423,0,260,370,160,253,-51,241],[304,490,752,160,362,72,253,-44,297],[305,2249,2964,154,251,64,253,-45,187],[306,333,1438,287,318,204,253,-42,250],[307,3351,0,226,376,129,253,-49,247],[321,4159,1756,261,314,141,253,-57,250],[322,7570,1114,191,319,66,253,-63,255],[323,2309,385,292,365,208,253,-42,301],[324,6348,2070,244,311,150,253,-47,246],[327,4963,385,292,364,208,253,-42,299],[328,3831,2383,244,307,150,253,-47,242],[336,5683,0,325,369,219,253,-53,301],[337,4420,1756,261,314,155,253,-53,246],[338,6825,1438,374,314,277,253,-48,250],[339,5997,2693,348,259,241,253,-53,191],[344,5255,385,271,364,172,253,-42,299],[345,4798,2383,214,306,98,253,-57,242],[346,5162,0,261,370,156,253,-52,302],[347,1498,2070,230,313,123,253,-54,246],[350,3090,0,261,376,156,253,-52,254],[351,1268,2070,230,313,123,253,-54,191],[352,284,385,261,367,156,253,-52,299],[353,2096,2383,230,309,123,253,-54,242],[354,3767,0,279,372,159,253,-60,250],[355,3697,752,212,349,95,253,-59,227],[356,6397,385,279,363,159,253,-60,299],[357,5825,1114,246,320,95,253,-59,252],[366,539,0,284,382,200,253,-42,314],[367,904,1438,242,318,147,253,-47,250],[368,7226,0,284,369,200,253,-42,301],[369,6181,1756,242,314,147,253,-47,246],[376,7769,385,292,362,174,253,-59,297],[377,1163,385,274,366,167,253,-53,302],[378,7306,2070,235,311,119,253,-57,246],[379,0,752,274,362,167,253,-53,297],[380,5224,2383,235,305,119,253,-57,240],[381,6676,385,274,363,167,253,-53,299],[382,4319,2383,235,307,119,253,-57,242],[536,278,0,261,384,156,253,-52,254],[537,5070,1114,230,321,123,253,-54,191],[538,1083,0,279,380,159,253,-60,250],[539,2956,752,212,357,95,253,-59,227],[1025,2734,752,222,358,135,257,-39,294],[1040,1728,2070,286,312,156,257,-65,248],[1041,7068,2070,238,311,148,257,-39,247],[1042,6100,2070,248,311,159,257,-39,247],[1043,7541,2070,223,311,126,257,-39,247],[1044,2170,752,287,359,166,257,-62,247],[1045,7764,2070,222,311,135,257,-39,247],[1046,2502,2070,338,311,209,257,-64,247],[1047,4388,1438,245,316,140,257,-55,249],[1048,4313,2070,265,311,187,257,-39,247],[1049,2885,385,265,365,187,257,-39,301],[1050,5346,2070,252,311,148,257,-39,247],[1051,2554,1756,274,314,171,257,-64,247],[1052,3173,2070,301,311,223,257,-39,247],[1053,4578,2070,258,311,180,257,-39,247],[1054,1939,1438,286,317,190,257,-48,250],[1055,4836,2070,255,311,177,257,-39,247],[1056,6830,2070,238,311,148,257,-39,247],[1057,3872,1438,259,316,154,257,-48,249],[1058,5091,2070,255,311,133,257,-61,247],[1059,2001,1756,277,314,150,257,-62,247],[1060,3574,1438,298,316,196,257,-51,249],[1061,4043,2070,270,311,140,257,-65,247],[1062,2457,752,277,359,179,257,-39,247],[1063,5849,2070,251,311,169,257,-43,247],[1064,2840,2070,333,311,255,257,-39,247],[1065,1815,752,355,359,255,257,-39,247],[1066,3763,2070,280,311,168,257,-61,247],[1067,3474,2070,289,311,211,257,-39,247],[1068,6592,2070,238,311,148,257,-39,247],[1069,4131,1438,257,316,152,257,-57,249],[1070,1592,1438,347,317,260,257,-39,250],[1071,5598,2070,251,311,151,257,-61,247],[1072,7846,2383,232,271,136,257,-52,204],[1073,7329,752,245,327,146,257,-49,260],[1074,3858,2693,237,265,145,257,-42,201],[1075,5268,2693,203,265,102,257,-42,201],[1076,260,2070,258,313,140,257,-59,201],[1077,7608,2383,238,271,137,257,-50,204],[1078,1445,2693,312,265,184,257,-64,201],[1079,0,2693,226,271,118,257,-56,204],[1080,3379,2693,241,265,157,257,-42,201],[1081,1674,1114,241,323,157,257,-42,259],[1082,4805,2693,232,265,126,257,-42,201],[1083,1201,2693,244,267,140,257,-62,201],[1084,2623,2693,268,265,184,257,-42,201],[1085,3138,2693,241,265,157,257,-42,201],[1086,7360,2383,248,271,148,257,-50,204],[1087,4569,2693,236,265,152,257,-42,201],[1088,6574,752,242,330,150,257,-42,204],[1089,451,2693,224,271,119,257,-50,204],[1090,5037,2693,231,265,113,257,-59,201],[1091,7076,752,253,327,125,257,-64,201],[1092,0,0,278,385,178,257,-50,259],[1093,2891,2693,247,265,128,257,-60,201],[1094,518,2070,256,313,154,257,-42,201],[1095,4095,2693,237,265,150,257,-45,201],[1096,1757,2693,307,265,223,257,-42,201],[1097,7745,1756,327,313,225,257,-42,201],[1098,2064,2693,283,265,174,257,-59,201],[1099,2347,2693,276,265,192,257,-42,201],[1100,4332,2693,237,265,145,257,-42,201],[1101,226,2693,225,271,118,257,-57,204],[1102,7061,2383,299,271,207,257,-42,204],[1103,3620,2693,238,265,136,257,-60,201],[1105,7332,1114,238,319,137,257,-50,252],[7843,4147,752,232,341,136,257,-52,274],[7867,3909,752,238,341,137,257,-50,274],[8211,0,3220,259,151,153,253,-53,141],[8217,6483,2964,173,197,73,253,-53,250],[8220,5882,2964,224,197,124,253,-47,251],[8222,5658,2964,224,197,122,253,-54,96],[65533,5738,385,363,363,256,257,-54,259]]},c=new OffscreenCanvas(16,16).getContext("webgl2",{xrCompatible:!0});c.disable(c.DEPTH_TEST),c.enable(c.BLEND),c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);const l=new r.Z,u=new class{constructor(){this.charMap={},this.initFontData(s),this.texture=new a.Z,this.texture.setUrl("assets/font_tiny.png"),this.program=(0,o.E)("SDFTextShaders")}updateTextNode(t,e){this.texture.texture?this.updateGeometry(t,e):this.texture.onLoad((()=>{this.updateGeometry(t,e)}))}updateGeometry(t,e){const n=this.extractGlyphs(.03,e).glyphs,r=new Float32Array(4*n.length*2),o=new Float32Array(4*n.length*2),a=new Uint16Array(3*n.length*2);let c,l=0,u=0,f=0,d=0,h=0;for(const t of n){const e=t.attributes;r[l++]=h+t.bearingX,r[l++]=t.ascend,r[l++]=h+t.bearingX+t.width,r[l++]=t.ascend,r[l++]=h+t.bearingX,r[l++]=-t.descend,r[l++]=h+t.bearingX+t.width,r[l++]=-t.descend,h+=t.advance;const n=e.X/s.NaturalWidth,i=e.Y/s.NaturalHeight,c=(e.X+e.Width)/s.NaturalWidth,m=(e.Y+e.Height)/s.NaturalHeight;o[u++]=n,o[u++]=i,o[u++]=c,o[u++]=i,o[u++]=n,o[u++]=m,o[u++]=c,o[u++]=m,a[f++]=d+0,a[f++]=d+1,a[f++]=d+2,a[f++]=d+1,a[f++]=d+2,a[f++]=d+3,d+=4}t.geometrys.length>0?c=t.geometrys[0]:(c=new i.Z,c.program=this.program,c.setUniform("u_color",t.color),c.setUniform("u_texture",this.texture),t.geometrys=[c]),c.addAttribute("a_position",r),c.addAttribute("a_uv",o),c.setIndexBuffer(a),t.updateMatrix=!0}initFontData(t){this.charMap.CharMap=[];for(const e of t.Glyphs){const t={X:e[1],Y:e[2],Width:e[3],Height:e[4],AdvanceX:e[5],AdvanceY:e[6],BearingX:e[7],BearingY:e[8]};this.charMap.CharMap[e[0]]=t}}extractGlyphs(t,e){const n={glyphs:[],maxAscend:0,maxDescend:0,totalWidth:0};for(const r of e.toString()){let e=this.charMap.CharMap[r.charCodeAt(0)];if(!e)continue;const o=t/s.FontHeight,i=e.BearingY*o,a=(e.Height-e.BearingY)*o,c=e.Width*o,l=e.BearingX*o,u=e.AdvanceX*o;i>n.maxAscend&&(n.maxAscend=i),a>n.maxDescend&&(n.maxDescend=a),n.totalWidth+=c,n.glyphs.push({attributes:{...e,scale:o},code:r,ascend:i,descend:a,width:c,bearingX:l,advance:u})}return n}};function f(t){return new(n(806)("./"+t).default)}},792:(t,e,n)=>{"use strict";n.d(e,{Z:()=>i});var r=n(387),o=n(931);class i{constructor(){this.indexBuffer=null,this.attributes={},this.count=0,this.countElement=0,this.material=null,this.texture=null,this.state=null,this.program=null,this.uniforms={}}setMaterial(t){this.material=t}addAttribute(t,e){let n=this.program.attributes[t];if(!n)return;const r=o.gl.createBuffer();o.gl.bindBuffer(o.gl.ARRAY_BUFFER,r),o.gl.bufferData(o.gl.ARRAY_BUFFER,e,o.gl.DYNAMIC_DRAW);const i=this.attributes[t];i&&(this.countElement-=i.value.length/n.size),this.attributes[t]={vertexBuffer:r,value:e},this.countElement+=e.length/n.size}setIndexBuffer(t){this.indexBuffer=o.gl.createBuffer(),o.gl.bindBuffer(o.gl.ELEMENT_ARRAY_BUFFER,this.indexBuffer),o.gl.bufferData(o.gl.ELEMENT_ARRAY_BUFFER,t,o.gl.DYNAMIC_DRAW),this.count=t.length}setUniform(t,e){this.uniforms[t]=e}draw(t){this.program.useProgram(),this.indexBuffer&&o.gl.bindBuffer(o.gl.ELEMENT_ARRAY_BUFFER,this.indexBuffer);for(const t in this.attributes){let e=this.attributes[t],n=this.program.attributes[t];o.gl.bindBuffer(o.gl.ARRAY_BUFFER,e.vertexBuffer),o.gl.vertexAttribPointer(n.location,n.size,n.type,!1,0,0),o.gl.enableVertexAttribArray(n.location)}for(const t in this.uniforms){const e=this.uniforms[t];e instanceof r.Z?(e.bindTo(0),this.program.uniforms[t].set(0)):this.program.uniforms[t].set(e)}this.program.uniforms.u_time&&this.program.uniforms.u_time.set(t/350),this.indexBuffer?o.gl.drawElements(o.gl.TRIANGLES,this.count,o.gl.UNSIGNED_SHORT,0):o.gl.drawArrays(o.gl.TRIANGLES,0,this.countElement)}}},828:(t,e,n)=>{"use strict";n.d(e,{Z:()=>d});var r=n(167),o=n(18);n(746);const i=[0,0,0],a=[0,0,-1],s=[0,0,0],c=[0,0,0];function l(t){r.AU(i,t),r.hR(a,t),o.Fv(a,a),o.SO(s,a),o.t8(c,s[0]<0?1:0,s[1]<0?1:0,s[2]<0?1:0)}function u(t,e){let n=[t,e],r=(n[c[0]][0]-i[0])*s[0],l=(n[1-c[0]][0]-i[0])*s[0],u=(n[c[1]][1]-i[1])*s[1],f=(n[1-c[1]][1]-i[1])*s[1];if(r>f||u>l)return null;u>r&&(r=u),f<l&&(l=f);let d=(n[c[2]][2]-i[2])*s[2],h=(n[1-c[2]][2]-i[2])*s[2];if(r>h||d>l)return null;d>r&&(r=d),h<l&&(l=h);let m=-1;if(r>0&&l>0)m=Math.min(r,l);else if(r>0)m=r;else{if(!(l>0))return null;m=l}let _=o.d9(a);return o.bA(_,_,m),o.IH(_,_,i),_}const f=r.Ue();class d{constructor(){this.parent=null,this.childs=[],this.layer=null,this.geometrys=[],this.localMatrix=null,this.worldMatrix=null,this.program=null,this.translation=null,this.rotation=null,this.scale=null,this.rotateX=null,this.rotateY=null,this.rotateZ=null,this.projectionMatrix=null,this.vMatrix=r.Ue(),this.u_transform=r.Ue(),this.matrix=null,this.camera=null,this.events={},this.isTarget=!1,this.visible=!0,this.updateMatrix=!0,this.anchor=!1,this.isAbsolute=!1}setStyleAbsolute(){this.matrix=r.Ue(),this.isAbsolute=!0}addGeometry(t){this.geometrys.push(t)}addChild(t){t.parent&&t.parent.removeChild(t),t.parent=this,this.childs.push(t)}removeChild(t){let e=this.childs.indexOf(t);e>=0&&(t.parent=null,this.childs.splice(e,1))}removeAll(){for(const t in this.childs)this.childs[t].parent=null;this.childs=[]}computeWorldMatrix(){for(child in this.worldMatrix=this.parent.worldMatrix*this.localMatrix,this.childs)child.computeWorldMatrix()}setTransform(){this.matrix?r.JG(this.u_transform,this.matrix):this.parent&&this.parent.u_transform?r.JG(this.u_transform,this.parent.u_transform):this.u_transform=r.Ue(),this.translation&&r.Iu(this.u_transform,this.u_transform,this.translation),this.scale&&r.bA(this.u_transform,this.u_transform,this.scale),this.rotation&&r.U1(this.u_transform,this.u_transform,this.rotation.rad,this.rotation.axis),this.rotateX&&r.lM(this.u_transform,this.u_transform,this.rotateX),this.rotateY&&r.uD(this.u_transform,this.u_transform,this.rotateY),this.rotateZ&&r.jI(this.u_transform,this.u_transform,this.rotateZ);for(const t of this.geometrys)t.setUniform("projectionMatrix",this.projectionMatrix),t.setUniform("vMatrix",this.vMatrix),t.setUniform("u_transform",this.u_transform);this.updateMatrix=!1}render(t,e,n){if(this.visible){if(this.projectionMatrix=e,this.anchor){n&&(this.vMatrix=n);for(const t in this.childs)this.childs[t].anchor=!0}(this.updateMatrix||this.anchor)&&this.setTransform();for(const e of this.geometrys)e.draw(t);for(const r in this.childs)this.childs[r].render(t,e,n)}}_onXRFrame(t,e){this.onXRFrame(t,e);for(const n in this.childs)this.childs[n]._onXRFrame(t,e)}onXRFrame(t,e){}addEventListener(t,e){this.events[t]=e}dispatchEvent(t,e){this.events[t]&&this.events[t](e)}hitTestXR(t){if(!this.visible||0==this.events.size)return null;let e=!1;for(const n of this.geometrys){if(!n.min)continue;e||(e=!0,r.U_(f,this.u_transform),r.Jp(f,f,t.matrix),l(f));let i=u(n.min,n.max);if(i)return o.fF(i,i,this.u_transform),{node:this,intersectionPoint:i}}for(const e of this.childs){const n=e.hitTestXR(t);if(n)return n}return null}hitTest(t,e){if(!this.visible||0==this.events.size)return null;let n=!1;for(const i of this.geometrys){if(!i.min)continue;n||(n=!0,r.U_(f,this.u_transform),this.anchor?r.Jp(f,f,e.matrix):r.Jp(f,f,t.matrix),l(f));let a=u(i.min,i.max);if(a)return o.fF(a,a,this.u_transform),{node:this,intersectionPoint:a}}for(const n of this.childs){const r=n.hitTest(t,e);if(r)return r}return null}}},196:(t,e,n)=>{"use strict";n.d(e,{$:()=>c,E:()=>s});var r=n(931);function o(t,e,n){switch(n){case t.FLOAT:return t.uniform1f.bind(t,e);case t.FLOAT_VEC2:return t.uniform2fv.bind(t,e);case t.FLOAT_VEC3:return t.uniform3fv.bind(t,e);case t.FLOAT_VEC4:return t.uniform4fv.bind(t,e);case t.INT:return t.uniform1i.bind(t,e);case t.INT_VEC2:return t.uniform2iv.bind(t,e);case t.INT_VEC3:return t.uniform3iv.bind(t,e);case t.INT_VEC4:return t.uniform4iv.bind(t,e);case t.FLOAT_MAT2:return t.uniformMatrix2fv.bind(t,e,!1);case t.FLOAT_MAT3:return t.uniformMatrix3fv.bind(t,e,!1);case t.FLOAT_MAT4:return t.uniformMatrix4fv.bind(t,e,!1);case t.SAMPLER_2D:case t.SAMPLER_CUBE:return t.uniform1i.bind(t,e);default:return function(){throw new Error("This uniform type is not supported")}}}function i(t,e,n){const r=n?t.UNSIGNED_BYTE:t.FLOAT;switch(e.type){case t.FLOAT:return{type:r,size:1};case t.FLOAT_VEC2:return{type:r,size:2};case t.FLOAT_VEC3:return{type:r,size:3};case t.FLOAT_VEC4:case t.FLOAT_MAT2:return{type:r,size:4};case t.FLOAT_MAT3:return{type:r,size:9};case t.FLOAT_MAT4:return{type:r,size:16}}throw new Error("Unsupported type")}const a={};function s(t){let e=a[t];if(!e){const r=n(677)("./"+t);e=new c(r.VERT_CODE,r.FRAG_CODE),a[t]=e}return e}class c{constructor(t,e){this.shaderProgram=this.createProgram(t,e),this.attributes=function(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let o=0;o<r;o++){const r=t.getActiveAttrib(e,o),{type:a,size:s}=i(t,r,!1),c=t.getAttribLocation(e,r.name);n[r.name]={location:c,size:s,type:a}}return n}(r.gl,this.shaderProgram),this.uniforms=function(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let i=0;i<r;i++){const r=t.getActiveUniform(e,i),a=t.getUniformLocation(e,r.name);n[r.name]={location:a,set:o(t,a,r.type),size:r.size,type:r.type}}return n}(r.gl,this.shaderProgram)}compileShader(t,e){let n=r.gl.createShader(t);return r.gl.shaderSource(n,e),r.gl.compileShader(n),n}createProgram(t,e){let n=this.compileShader(r.gl.VERTEX_SHADER,t),o=this.compileShader(r.gl.FRAGMENT_SHADER,e),i=r.gl.createProgram();return r.gl.attachShader(i,n),r.gl.attachShader(i,o),r.gl.linkProgram(i),i}useProgram(){r.gl.useProgram(this.shaderProgram)}}},387:(t,e,n)=>{"use strict";n.d(e,{Z:()=>i});var r=n(931);const o={};class i{constructor(t){this._onLoads=[]}createTexture(){this.texture=r.gl.createTexture(),r.gl.bindTexture(r.gl.TEXTURE_2D,this.texture),r.gl.texParameteri(r.gl.TEXTURE_2D,r.gl.TEXTURE_WRAP_S,r.gl.CLAMP_TO_EDGE),r.gl.texParameteri(r.gl.TEXTURE_2D,r.gl.TEXTURE_WRAP_T,r.gl.CLAMP_TO_EDGE),r.gl.texParameteri(r.gl.TEXTURE_2D,r.gl.TEXTURE_MIN_FILTER,r.gl.LINEAR),r.gl.texParameteri(r.gl.TEXTURE_2D,r.gl.TEXTURE_MAG_FILTER,r.gl.LINEAR)}setUrl(t){if(o[t])this.texture=o[t],this.handleOnLoad();else{this.createTexture();const e=new Image;e.crossOrigin="anonymous",e.onload=()=>{this.bindTexture(e),o[t]=this.texture,this.handleOnLoad()},e.src=t}}setBase64(t){this.texture||this.createTexture();const e=new Image;e.onload=()=>{this.bindTexture(e),this.handleOnLoad()},e.src=t}setSrc(t){this.texture||this.createTexture(),this.bindTexture(t)}bindTexture(t){r.gl.bindTexture(r.gl.TEXTURE_2D,this.texture),r.gl.pixelStorei(r.gl.UNPACK_FLIP_Y_WEBGL,0),r.gl.texImage2D(r.gl.TEXTURE_2D,0,r.gl.RGBA,r.gl.RGBA,r.gl.UNSIGNED_BYTE,t)}handleOnLoad(){for(let t of this._onLoads)t()}onLoad(t){this._onLoads.push(t)}bindTo(t){r.gl.activeTexture(r.gl.TEXTURE0+t),r.gl.bindTexture(r.gl.TEXTURE_2D,this.texture)}}},959:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>a});var r=n(828),o=n(196),i=n(792);class a extends r.Z{constructor(){super(),this.color=[0,0,1];let t=(0,o.E)("ViewShader"),e=new i.Z;e.program=t,e.setIndexBuffer(new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23])),e.addAttribute("a_position",new Float32Array([-1,-1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,1,-1,1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1])),e.setUniform("u_color",new Float32Array(this.color)),e.min=[-1,-1,-1],e.max=[1,1,1],this.addGeometry(e)}}},825:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>a});var r=n(792),o=n(828),i=n(196);class a extends o.Z{constructor(){super();const t=new r.Z;t.program=(0,i.E)("ViewShader");const e=[],n=[];let o=0;e.push(0,0,0);for(let t=0;t<=100;t++)o+=2*Math.PI/100,e.push(Math.cos(o),Math.sin(o),0),n.push(0,t,t+1);t.setIndexBuffer(new Uint16Array(n)),t.addAttribute("a_position",new Float32Array(e)),t.setUniform("u_color",new Float32Array(0,0,1)),this.addGeometry(t)}}},199:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>a});var r=n(792),o=n(828),i=n(196);class a extends o.Z{constructor(){super(),this.color=[0,1,1]}setRadius(t){const e=new r.Z,n=[-t,-t,0,-t,t,0,t,t,0,t,-t,0,-t,-t,0];e.program=(0,i.E)("CircleShader"),e.setIndexBuffer(new Uint16Array([0,1,2,0,2,3])),e.addAttribute("a_position",new Float32Array(n)),e.setUniform("u_color",new Float32Array(this.color)),e.setUniform("u_radius",t),this.addGeometry(e)}}},438:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>a});var r=n(792),o=n(828),i=n(196);class a extends o.Z{constructor(){super(),this.color=[.1,.633,.664],this.borderColor=[.5,.5,.5],this.border=.01}setRadius(t){const e=new r.Z,n=[-t,-t,0,-t,t,0,t,t,0,t,-t,0,-t,-t,0];e.program=(0,i.E)("CircleBorderShader"),e.setIndexBuffer(new Uint16Array([0,1,2,0,2,3])),e.addAttribute("a_position",new Float32Array(n)),e.setUniform("u_color",new Float32Array(this.color)),e.setUniform("u_borderColor",new Float32Array(this.borderColor)),e.setUniform("u_radius",t),e.setUniform("u_border",this.border),e.min=[-t,-t,0],e.max=[t,t,0],this.geometrys=[e]}setColor(t){this.color=t;const e=this.geometrys[0];e&&e.setUniform("u_color",new Float32Array(t))}setBorderColor(t){this.borderColor=t;const e=this.geometrys[0];e&&e.setUniform("u_borderColor",new Float32Array(t))}setBorder(t){this.border=t;const e=this.geometrys[0];e&&e.setUniform("u_border",t)}}},532:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>a});var r=n(828),o=n(792),i=n(196);class a extends r.Z{constructor(){super(),this.time_old=0,this.setBuffer()}setBuffer(){let t=(0,i.E)("ViewShader"),e=new o.Z;e.program=t,e.setIndexBuffer(new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23])),e.addAttribute("a_position",new Float32Array([-1,-1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,1,-1,1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1])),e.setUniform("u_color",new Float32Array([0,0,1])),this.addGeometry(e)}update(t){let e=t-this.time_old;this.time_old=t,this.rotateZ+=.0025*e,this.rotateY+=.0025*e,this.rotateX+=.0025*e}}},904:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>a});var r=n(828),o=n(196),i=n(792);class a extends r.Z{constructor(){super()}setSize(t,e){const n=new i.Z;n.program=(0,o.E)("ViewShader");const r=[],a=[],s=[],c=t,l=t,u=20,f=2*Math.PI;let d=0;const h=[],m=e/2;function _(t){const e=d,n=t?c:l,o=t?1:-1;for(let t=1;t<=u;t++)r.push(0,m*o,0),d++;const i=d;for(let t=0;t<=u;t++){const e=t/u*f+0,i=Math.cos(e),a=Math.sin(e);r.push(n*a),r.push(m*o),r.push(n*i),d++}for(let n=0;n<u;n++){const r=e+n,o=i+n;t?(a.push(o,o+1,r),s.push(.5*Math.random(),.5*Math.random(),.5*Math.random())):(a.push(o+1,o,r),s.push(.5*Math.random(),.5*Math.random(),.5*Math.random()))}}!function(){for(let t=0;t<=10;t++){const n=[],o=t/10,i=o*(l-c)+c;for(let t=0;t<=u;t++){const a=t/u*f+0,s=Math.sin(a),c=Math.cos(a);r.push(i*s),r.push(-o*e+m),r.push(i*c),n.push(d++)}h.push(n)}for(let t=0;t<u;t++)for(let e=0;e<10;e++){const n=h[e][t],r=h[e+1][t],o=h[e+1][t+1],i=h[e][t+1];a.push(n,r,i),s.push(.5*Math.random(),.5*Math.random(),.5*Math.random()),a.push(r,o,i),s.push(.5*Math.random(),.5*Math.random(),.5*Math.random())}}(),c>0&&_(!0),l>0&&_(!1),n.setIndexBuffer(new Uint16Array(a)),n.addAttribute("a_position",new Float32Array(r)),n.setUniform("u_color",new Float32Array(s)),this.addGeometry(n)}}},766:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>d});var r=n(828),o=n(792),i=n(196);function a(t,e){let n=t,r=e.map((t=>`#define ${t}\n`)).join("");if(t.startsWith("#version")){const e=t.indexOf("\n")+1;n=t.substr(0,e)+r+t.substr(e)}else n=r+t;return n}const s={POSITION:"a_position",NORMAL:"a_normal",TANGENT:"a_tangent",COLOR_0:"a_color_0",TEXCOORD_0:"a_texcoord_0",TEXCOORD_1:"a_texcoord_1"},c=(WebGLRenderingContext,4);class l extends class{constructor(){this.samplers={},this.uniforms=[],this.renderOrder=c}setTexture(t,e){this.samplers[t]=e}setUniform(t,e,n){this.uniforms[t]={value:e,length:n}}}{constructor(){super()}get materialName(){return"PBR"}get vertexSource(){return"\nattribute vec3 POSITION, NORMAL;\nattribute vec2 TEXCOORD_0, TEXCOORD_1;\n\nuniform vec3 CAMERA_POSITION;\nuniform vec3 LIGHT_DIRECTION;\n\nvarying vec3 vLight; // Vector from vertex to light.\nvarying vec3 vView; // Vector from vertex to camera.\nvarying vec2 vTex;\n\n#ifdef USE_NORMAL_MAP\nattribute vec4 TANGENT;\nvarying mat3 vTBN;\n#else\nvarying vec3 vNorm;\n#endif\n\n#ifdef USE_VERTEX_COLOR\nattribute vec4 COLOR_0;\nvarying vec4 vCol;\n#endif\n\nvec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vec3 n = normalize(vec3(model * vec4(NORMAL, 0.0)));\n#ifdef USE_NORMAL_MAP\n vec3 t = normalize(vec3(model * vec4(TANGENT.xyz, 0.0)));\n vec3 b = cross(n, t) * TANGENT.w;\n vTBN = mat3(t, b, n);\n#else\n vNorm = n;\n#endif\n\n#ifdef USE_VERTEX_COLOR\n vCol = COLOR_0;\n#endif\n\n vTex = TEXCOORD_0;\n vec4 mPos = model * vec4(POSITION, 1.0);\n vLight = -LIGHT_DIRECTION;\n vView = CAMERA_POSITION - mPos.xyz;\n return proj * view * mPos;\n}"}get fragmentSource(){return"\n#define M_PI 3.14159265\n\nuniform vec4 baseColorFactor;\n#ifdef USE_BASE_COLOR_MAP\nuniform sampler2D baseColorTex;\n#endif\n\nvarying vec3 vLight;\nvarying vec3 vView;\nvarying vec2 vTex;\n\n#ifdef USE_VERTEX_COLOR\nvarying vec4 vCol;\n#endif\n\n#ifdef USE_NORMAL_MAP\nuniform sampler2D normalTex;\nvarying mat3 vTBN;\n#else\nvarying vec3 vNorm;\n#endif\n\n#ifdef USE_METAL_ROUGH_MAP\nuniform sampler2D metallicRoughnessTex;\n#endif\nuniform vec2 metallicRoughnessFactor;\n\n#ifdef USE_OCCLUSION\nuniform sampler2D occlusionTex;\nuniform float occlusionStrength;\n#endif\n\n#ifdef USE_EMISSIVE_TEXTURE\nuniform sampler2D emissiveTex;\n#endif\nuniform vec3 emissiveFactor;\n\nuniform vec3 LIGHT_COLOR;\n\nconst vec3 dielectricSpec = vec3(0.04);\nconst vec3 black = vec3(0.0);\n\n\nvec3 lambertDiffuse(vec3 cDiff) {\n return cDiff / M_PI;\n}\n\nfloat specD(float a, float nDotH) {\n float aSqr = a * a;\n float f = ((nDotH * nDotH) * (aSqr - 1.0) + 1.0);\n return aSqr / (M_PI * f * f);\n}\n\nfloat specG(float roughness, float nDotL, float nDotV) {\n float k = (roughness + 1.0) * (roughness + 1.0) / 8.0;\n float gl = nDotL / (nDotL * (1.0 - k) + k);\n float gv = nDotV / (nDotV * (1.0 - k) + k);\n return gl * gv;\n}\n\nvec3 specF(float vDotH, vec3 F0) {\n float exponent = (-5.55473 * vDotH - 6.98316) * vDotH;\n float base = 2.0;\n return F0 + (1.0 - F0) * pow(base, exponent);\n}\n\nvec4 fragment_main() {\n#ifdef USE_BASE_COLOR_MAP\n vec4 baseColor = texture2D(baseColorTex, vTex) * baseColorFactor;\n#else\n vec4 baseColor = baseColorFactor;\n#endif\n\n#ifdef USE_VERTEX_COLOR\n baseColor *= vCol;\n#endif\n\n#ifdef USE_NORMAL_MAP\n vec3 n = texture2D(normalTex, vTex).rgb;\n n = normalize(vTBN * (2.0 * n - 1.0));\n#else\n vec3 n = normalize(vNorm);\n#endif\n\n#ifdef FULLY_ROUGH\n float metallic = 0.0;\n#else\n float metallic = metallicRoughnessFactor.x;\n#endif\n\n float roughness = metallicRoughnessFactor.y;\n\n#ifdef USE_METAL_ROUGH_MAP\n vec4 metallicRoughness = texture2D(metallicRoughnessTex, vTex);\n metallic *= metallicRoughness.b;\n roughness *= metallicRoughness.g;\n#endif\n \n vec3 l = normalize(vLight);\n vec3 v = normalize(vView);\n vec3 h = normalize(l+v);\n\n float nDotL = clamp(dot(n, l), 0.001, 1.0);\n float nDotV = abs(dot(n, v)) + 0.001;\n float nDotH = max(dot(n, h), 0.0);\n float vDotH = max(dot(v, h), 0.0);\n\n // From GLTF Spec\n vec3 cDiff = mix(baseColor.rgb * (1.0 - dielectricSpec.r), black, metallic); // Diffuse color\n vec3 F0 = mix(dielectricSpec, baseColor.rgb, metallic); // Specular color\n float a = roughness * roughness;\n\n#ifdef FULLY_ROUGH\n vec3 specular = F0 * 0.45;\n#else\n vec3 F = specF(vDotH, F0);\n float D = specD(a, nDotH);\n float G = specG(roughness, nDotL, nDotV);\n vec3 specular = (D * F * G) / (4.0 * nDotL * nDotV);\n#endif\n float halfLambert = dot(n, l) * 0.5 + 0.5;\n halfLambert *= halfLambert;\n\n vec3 color = (halfLambert * LIGHT_COLOR * lambertDiffuse(cDiff)) + specular;\n\n#ifdef USE_OCCLUSION\n float occlusion = texture2D(occlusionTex, vTex).r;\n color = mix(color, color * occlusion, occlusionStrength);\n#endif\n \n vec3 emissive = emissiveFactor;\n#ifdef USE_EMISSIVE_TEXTURE\n emissive *= texture2D(emissiveTex, vTex).rgb;\n#endif\n color += emissive;\n\n // gamma correction\n //color = pow(color, vec3(1.0/2.2));\n\n return vec4(color, baseColor.a);\n}"}getProgramDefines(t){}}const u={POSITION:"a_position",NORMAL:"a_normal",TANGENT:"a_tangent",COLOR_0:"a_color_0",TEXCOORD_0:"a_texcoord_0",TEXCOORD_1:"a_texcoord_1"};class f{constructor(){this.buffers=[]}getBaseUri(t){const e=t.lastIndexOf(".gltf");return t.substring(0,e)}loadFromUrl(t,e){fetch(e).then((n=>{let r=this.getBaseUri(e)+".bin";fetch(r).then((e=>{e.arrayBuffer().then((e=>{this.buffers.push(e),n.json().then((e=>{this.buildScene(t,e)}))}))}))}))}buildScene(t,e){let n=e.scenes[e.scene];t.name=n.name;for(let r of n.nodes){let n=e.nodes[r],o=this.buildNode(n,e);t.addChild(o)}}buildNode(t,e){let n=new r.Z;if(n.name=t.name,"mesh"in t){let r=e.meshes[t.mesh];for(let t of r.primitives){const r=this.buildGeometry(t,e),o=this.buildMaterial(t,e);r.setMaterial(o),n.addGeometry(r)}}if(t.matrix?n.matrix=new Float32Array(t.matrix):(t.translation&&(n.translation=t.translation),t.scale&&(n.scale=t.scale)),t.children)for(let r of t.children){let t=e.nodes[r];n.addChild(this.buildNode(t,e))}return n}buildGeometry(t,e){const n=new o.Z;let r=[];for(const e in t.attributes)r.push(e);const c=function(t){const e=function(t){let e=[];for(const n of t)n in s&&e.push(n);return e.sort(),e.join(),e.map((t=>`HAS_${t}`))}(t),n=a(VERT_CODE,e),r=a(FRAG_CODE,e);return new i.$(n,r)}(r);n.program=c;for(const r in t.attributes){const o=t.attributes[r];let i=e.accessors[o],a=this.getBufferData(i,e);n.addAttribute(u[r],a)}if("indices"in t){let r=e.accessors[t.indices],o=this.getBufferData(r,e);n.setIndexBuffer(o,r)}return n}getBufferData(t,e){let n=e.bufferViews[t.bufferView],r=this.buffers[n.buffer];return this.createDataView(r,n.byteOffset,n.byteLength,t.componentType)}getArrayBuffer(t){return fetch(t).then((t=>t.json()))}createDataView(t,e,n,r){switch(r){case 5120:return new Int8Array(t,e,n);case 5121:return new Uint8Array(t,e,n);case 5122:return new Int16Array(t,e,n/2);case 5123:return new Uint16Array(t,e,n/2);case 5124:return new Int32Array(t,e,n/4);case 5125:return new Uint32Array(t,e,n/4);case 5126:return new Float32Array(t,e,n/4);default:throw new Error(`Unsupported GL component type: ${r}`)}}buildMaterial(t,e){const n=e.materials[t.material];let r=new l;r.alphaMode=n.alphaMode,r.name=n.name,r.alphaCutoff=n.alphaCutoff,r.doubleSided=n.doubleSided;let o=n.pbrMetallicRoughness||{};return this.setTexture(r,o),this.setUniform(r,o),r}setUniform(t,e){t.setUniform("baseColorFactor",e.baseColorFactor||[1,1,1,1]),t.setUniform("metallicRoughnessFactor",e.metallicRoughnessFactor||[1,1]),t.setUniform("occlusionStrength",e.occlusionTexture&&e.occlusionTexture.strength||1),t.setUniform("emissiveFactor",e.emissiveFactor|[0,0,0])}setTexture(t,e){t.setTexture("baseColorTex",e.baseColorTexture),t.setTexture("metallicRoughnessTex",e.metallicRoughnessTexture),t.setTexture("occlusionTex",e.occlusionTexture),t.setTexture("emissiveTex",e.emissiveTexture)}}class d extends r.Z{constructor(){super()}setSource(t){(new f).loadFromUrl(this,t)}}},377:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>s});var r=n(792),o=n(828),i=n(196),a=n(387);class s extends o.Z{constructor(){super(),this.texture=new a.Z,this.program=(0,i.E)("ImageShader"),this.width=0,this.height=0}setUrl(t){this.texture.onLoad((()=>{this.updateGeometry()})),this.texture.setUrl(t)}setSrc(t){this.texture.setSrc(t),this.updateGeometry()}setSize(t,e){this.width=t,this.height=e;const n=this.geometrys[0];if(n){const r=[0,e,t,e,0,0,t,0];n.addAttribute("a_position",new Float32Array(r))}}updateGeometry(){let t=this.geometrys[0];if(!t){t=new r.Z,t.program=this.program;const e=[0,1,2,1,2,3],n=[0,0,1,0,0,1,1,1];t.setIndexBuffer(new Int16Array(e)),t.addAttribute("a_uv",new Float32Array(n)),t.setUniform("u_image",this.texture),this.updateMatrix=!0;const o=[0,this.height,this.width,this.height,0,0,this.width,0];t.addAttribute("a_position",new Float32Array(o)),this.geometrys=[t]}}}},868:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>a});var r=n(828),o=n(196),i=n(792);class a extends r.Z{constructor(){super();const t=new i.Z;t.program=(0,o.E)("ViewShader");const e=[],n=[],r=[];for(let t=0;t<2;t++){const n=1*t-.5;for(let t=0;t<2;t++){const r=1*t-.5;e.push(r,-n,0)}}for(let t=0;t<1;t++)for(let e=0;e<1;e++){const o=e+2*t,i=e+2*(t+1),a=e+1+2*(t+1),s=e+1+2*t;n.push(o,i,s),n.push(i,a,s),r.push(Math.random(),Math.random(),Math.random()),r.push(Math.random(),Math.random(),Math.random())}t.setIndexBuffer(new Uint16Array(n)),t.addAttribute("a_position",new Float32Array(e)),t.setUniform("u_color",new Float32Array(r)),this.addGeometry(t)}}},609:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>a});var r=n(828),o=n(792),i=n(196);class a extends r.Z{constructor(){super(),this.color=[0,1,1]}setSize(t,e){const n=new o.Z,r=[0,0,0,0,e,0,t,e,0,t,0,0,0,0,0];n.program=(0,i.E)("ViewShader"),n.setIndexBuffer(new Uint16Array([0,1,2,0,2,3])),n.addAttribute("a_position",new Float32Array(r)),n.setUniform("u_color",new Float32Array(this.color)),this.addGeometry(n)}}},604:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>a});var r=n(792),o=n(828),i=n(196);class a extends o.Z{constructor(){super()}setRadius(t){const e=new r.Z;e.program=(0,i.E)("ViewShader");const n=[],o=[],a=[],s=Math.PI,c=Math.min(0+s,Math.PI),l=2*Math.PI;let u=0;const f=[];for(let e=0;e<=30;e++){const r=[],o=e/30;let i=0;0==e?i=.0125:30==e&&c==Math.PI&&(i=-.0125);for(let e=0;e<=40;e++){const i=e/40;n.push(-t*Math.cos(0+i*l)*Math.sin(0+o*s)),n.push(t*Math.cos(0+o*s)),n.push(t*Math.sin(0+i*l)*Math.sin(0+o*s)),r.push(u++)}f.push(r)}for(let t=0;t<30;t++)for(let e=0;e<40;e++){const n=f[t][e+1],r=f[t][e],i=f[t+1][e],s=f[t+1][e+1];0!=t&&(o.push(n,r,s),a.push(Math.random(),Math.random(),Math.random())),(29!=t||c<Math.PI)&&(o.push(r,i,s),a.push(Math.random(),Math.random(),Math.random()))}e.setIndexBuffer(new Uint16Array(o)),e.addAttribute("a_position",new Float32Array(n)),e.setUniform("u_color",new Float32Array(a)),this.addGeometry(e)}}},549:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>a});var r=n(792),o=n(828),i=n(196);class a extends o.Z{constructor(){super(),this.color=[.1,.633,.664],this.setGeometry()}setGeometry(){const t=new r.Z;t.program=(0,i.E)("Target"),t.setIndexBuffer(new Uint16Array([0,1,2,0,2,3])),t.addAttribute("a_position",new Float32Array([-1,-1,0,-1,1,0,1.5,1,0,1.5,-1,0,-1,-1,0])),t.setUniform("u_color",new Float32Array(this.color)),t.min=[-1,-1,0],t.max=[1,1,0],this.geometrys=[t]}setColor(t){this.color=t;const e=this.geometrys[0];e&&e.setUniform("u_color",new Float32Array(t))}}},906:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>i});var r=n(931),o=n(828);class i extends o.Z{constructor(){super(),this.color=[0,0,0]}setText(t){r.bq.updateTextNode(this,t)}setColor(t){this.color=t;const e=this.geometrys[0];e&&e.setUniform("u_color",new Float32Array(t))}}},685:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>a});var r=n(828),o=n(196),i=n(792);class a extends r.Z{constructor(){super();let t=(0,o.E)("ViewShader"),e=new i.Z;e.program=t,e.setIndexBuffer(new Uint16Array([0,1,2])),e.addAttribute("a_position",new Float32Array([-1,1,0,1,1,0,1,-1,0])),e.setUniform("u_color",new Float32Array([0,0,1,0,1,1,1,0,1])),this.addGeometry(e)}}},313:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>a});var r=n(792),o=n(828),i=n(196);class a extends o.Z{constructor(){super(),this.color=[.1,.3,.3]}setSize(t,e){let n=this.geometrys[0];if(!n){n=new r.Z,n.program=(0,i.E)("ViewShader");const t=[0,1,2,0,2,3];n.setIndexBuffer(new Uint16Array(t)),n.setUniform("u_color",new Float32Array(this.color)),this.addGeometry(n)}const o=[0,0,0,0,e,0,t,e,0,t,0,0];n.addAttribute("a_position",new Float32Array(o)),n.min=[0,0,0],n.max=[t,e,0]}setColor(t){this.color=t;const e=this.geometrys[0];e&&e.setUniform("u_color",new Float32Array(t))}}},965:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>a});var r=n(792),o=n(828),i=n(196);class a extends o.Z{constructor(){super(),this.color=[.1,.633,.664],this.setGeometry()}setGeometry(){let t=this.geometrys[0];if(!t){t=new r.Z,t.program=(0,i.E)("ViewBorderShader");const e=[0,1,2,0,2,3];t.setIndexBuffer(new Uint16Array(e)),t.setUniform("u_color",new Float32Array(this.color)),this.addGeometry(t)}t.addAttribute("a_position",new Float32Array([0,0,0,0,1,0,2,1,0,2,0,0])),t.min=[0,0,0],t.max=[2,1,0]}setColor(t){this.color=t;const e=this.geometrys[0];e&&e.setUniform("u_color",new Float32Array(t))}}},806:(t,e,n)=>{var r={"./Box":959,"./Box.js":959,"./Circle":825,"./Circle.js":825,"./Circle2":199,"./Circle2.js":199,"./CircleBorder":438,"./CircleBorder.js":438,"./Cube":532,"./Cube.js":532,"./Cylinder":904,"./Cylinder.js":904,"./Entity":766,"./Entity.js":766,"./Image":377,"./Image.js":377,"./Plane":868,"./Plane.js":868,"./Rectangle":609,"./Rectangle.js":609,"./Sphere":604,"./Sphere.js":604,"./Target":549,"./Target.js":549,"./Text":906,"./Text.js":906,"./Triangle":685,"./Triangle.js":685,"./View":313,"./View.js":313,"./ViewBorder":965,"./ViewBorder.js":965};function o(t){var e=i(t);return n(e)}function i(t){if(!n.o(r,t)){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}return r[t]}o.keys=function(){return Object.keys(r)},o.resolve=i,t.exports=o,o.id=806},393:(t,e,n)=>{"use strict";n.r(e),n.d(e,{VERT_CODE:()=>r,FRAG_CODE:()=>o});const r="\nattribute vec3 a_position;\n\nuniform mat4 projectionMatrix;\nuniform mat4 vMatrix;\nuniform mat4 u_transform;\n\nvarying vec3 v_position;\n\nvoid main() { \n gl_Position = projectionMatrix * vMatrix * u_transform * vec4(a_position, 1.0);\n v_position = a_position;\n}",o="\nprecision mediump float;\n\nuniform vec3 u_color;\nuniform vec3 u_borderColor;\nuniform float u_radius;\nuniform float u_border;\n\nvarying vec3 v_position;\n\nvoid main() { \n float d = distance(v_position, vec3(0, 0, 0));\n if ( d <= u_radius - u_border) {\n gl_FragColor = vec4(u_color, 0.8); \n } else if (d <= u_radius){\n gl_FragColor = vec4(u_borderColor, 0.8); \n } else discard;\n}"},521:(t,e,n)=>{"use strict";n.r(e),n.d(e,{VERT_CODE:()=>r,FRAG_CODE:()=>o});const r="\nattribute vec3 a_position;\n\nuniform mat4 projectionMatrix;\nuniform mat4 vMatrix;\nuniform mat4 u_transform;\n\nvarying vec3 v_position;\n\nvoid main() { \n gl_Position = projectionMatrix * vMatrix * u_transform * vec4(a_position, 1.0);\n v_position = a_position;\n}",o="\nprecision mediump float;\n\nuniform vec3 u_color;\nuniform float u_radius;\nvarying vec3 v_position;\n\nvoid main() { \n float d = distance(v_position, vec3(0, 0, 0));\n if ( d <= u_radius) {\n gl_FragColor = vec4(u_color, 0.5); \n } else discard;\n}"},226:(t,e,n)=>{"use strict";n.r(e),n.d(e,{VERT_CODE:()=>r,FRAG_CODE:()=>o});const r="\nattribute vec3 a_position;\nuniform mat4 u_transform;\nuniform mat4 vMatrix;\nuniform mat4 projectionMatrix;\n\n#ifdef HAS_NORMAL\nattribute vec3 a_normal;\nvarying vec3 v_normal;\nvarying highp vec3 v_lighting;\n#endif\n#ifdef HAS_TANGENT\nattribute vec4 a_tangent;\nvarying vec4 v_tangent;\n#endif\n#ifdef HAS_TEXCOORD_0\nattribute vec2 a_texcoord_0;\nvarying vec2 v_texcoord_0;\n#endif\n#ifdef HAS_TEXCOORD_1\nattribute vec2 a_texcoord_1;\nvarying vec2 v_texcoord_1;\n#endif\n#ifdef HAS_COLOR_0\nattribute vec3 a_color_0;\nvarying vec3 v_color_0;\n#endif\n// if color is vec4 in source data, create a single-float\n// alpha attribute to carry the extra data\n\nhighp vec3 white = vec3(1.0, 1.0, 1.0);\n\n#ifdef HAS_NORMAL\nmat4 inverse(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00\n ) / det;\n}\n\nmat4 transpose(mat4 m) {\n return mat4(\n m[0][0], m[1][0], m[2][0], m[3][0],\n m[0][1], m[1][1], m[2][1], m[3][1],\n