var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.createTemplateTagFirstArg=function(R){return R.raw=R};$jscomp.createTemplateTagFirstArgWithRaw=function(R,ca){R.raw=ca;return R};$jscomp.arrayIteratorImpl=function(R){var ca=0;return function(){return ca<R.length?{done:!1,value:R[ca++]}:{done:!0}}};$jscomp.arrayIterator=function(R){return{next:$jscomp.arrayIteratorImpl(R)}};$jscomp.makeIterator=function(R){var ca="undefined"!=typeof Symbol&&Symbol.iterator&&R[Symbol.iterator];return ca?ca.call(R):$jscomp.arrayIterator(R)};
$jscomp.arrayFromIterator=function(R){for(var ca,da=[];!(ca=R.next()).done;)da.push(ca.value);return da};$jscomp.arrayFromIterable=function(R){return R instanceof Array?R:$jscomp.arrayFromIterator($jscomp.makeIterator(R))};
var SN3D=function(){var R=window.atob(config.m),ca=window.atob(config.j)+config.a.split("/").slice(-3,-2)+"/",da=config.a+"front/js/asset/",Aa=config.a+"server/features/",V="",oa="",sa="",ja="",ua="",ka="",Q="editor"===document.body.id?!0:!1,Da=parseInt(document.body.getAttribute("data-color")),va=!1,P=function(){function b(k){k.stopPropagation();k.preventDefault()}function d(k){k.stopPropagation();k.preventDefault();var v=k.clientX,E=k.clientY,M=k.dataTransfer.files[0],S=M.name;if(H.isImage(S))if(51E4<
M.size)alert("Your image exceed the 500ko maximum file size.\nYou can make your image lighter by using https://squoosh.app");else{var ea=new FileReader;ea.onload=function(aa){var Y=aa.target.result,O=document.createElement("img");O.src=Y;O.className=_id+"_"+S;O.id="annotationImage"+C(k.target);Y=new XMLHttpRequest;Y.open("POST",Aa+"save_img.php?folder="+V+"&filename="+O.className);Y.onload=function(){O.src=ka+"user_images/"+O.className;console.warn(S+" uploaded to server")};Y.setRequestHeader("Content-Type",
"application/octet-stream");Y.send(aa.target.result);aa=document.createRange();document.caretPositionFromPoint?(Y=document.caretPositionFromPoint(v,E),aa.setStart(Y.offsetNode,Y.offset),aa.collapse(),aa.insertNode(O)):document.caretRangeFromPoint?(aa=document.caretRangeFromPoint(v,E),aa.insertNode(O)):console.log("could not find carat")};ea.readAsDataURL(M)}}function f(k){var v={position:k.position,camera:k.camera,name:"annotation"+w.length,position_2d:H.convert_to_2d(k.position),distance:0,visible:!0};
w.push(v);r(k.position);L(500);v=h=w.length-1;var E=Z.color_name();k=document.createDocumentFragment();_build("DIV",k,{id:v,"class":"annotation hidden","data-color":E});E=k.firstElementChild;_build("DIV",E,{"class":"content"});_build("BUTTON",E,{"class":"number","data-content":v+1},{click:p});v=k.firstElementChild.children[0];_build("STRONG",v,{"class":"title","data-content":"click to edit",contentEditable:"true"},{keydown:K,paste:W});_build("DIV",v,{"class":"text","data-content":"write, copy/paste, drag image file...",
contentEditable:"true"},{paste:W,dragover:b,drop:d});_build("BUTTON",v,{"class":"delete"},{click:G});_build("BUTTON",v,{"class":"move"},{click:J});_build("BUTTON",v,{"class":"color"},{click:A});g.append(k);ha.add(h);ha.update(h);I.render();t(50)}var g=document.getElementById("annotation_list"),w=[],x=[],h=0,q=!0,u;_id=Date.now();var B=function(k){var v=[];if(void 0!==k.annotations)for(var E=0;E<k.annotations.length;E++){var M={position:new THREE.Vector3(parseFloat(k.annotations[E].x),parseFloat(k.annotations[E].y),
parseFloat(k.annotations[E].z)),camera:new THREE.Vector3(parseFloat(k.annotations[E].camx),parseFloat(k.annotations[E].camy),parseFloat(k.annotations[E].camz)),name:"annotation"+E,distance:0,title:k.annotations[E].title,txt:k.annotations[E].txt,c:k.annotations[E].c,visible:!0};v.push(M)}return v},r=function(k){var v=new THREE.MeshBasicMaterial({color:14157417,toneMapped:!1,visible:!1}),E=new THREE.SphereBufferGeometry(.01,16,16);v=new THREE.Mesh(E,v);v.position.copy(k);Q||H.getJSON();v.name="pointer";
x.push(v);T.get().add(v)};_build=function(k,v,E,M){k=document.createElement(k);if(E)for(a in E)k.setAttribute(a,E[a]);if(M)for(e in M)k.addEventListener(e,M[e]);v.append(k)};var t=function(k){setTimeout(function(v){v=$jscomp.makeIterator(g.children);for(var E=v.next();!E.done;E=v.next())el=E.value,el.classList.add("only_number");g.children[h].classList.remove("only_number");for(v=0;v<w.length;v++){E=x[v].localToWorld(new THREE.Vector3);var M=H.convert_to_2d(E);w[v].position=E;w[v].position_2d=new THREE.Vector2(M.x,
M.y);g.children[v].style.left=M.x+"px";g.children[v].style.top=M.y+"px"}la.annotations()},k)},p=function(){h=parseInt(event.target.parentElement.id);ha.update(h);L(500);t(0)};document.addEventListener("player_needUpdate",function(){0!==w.length&&(D(),t(0))});var D=function(){if(q){q=!1;for(var k=0,v=I.WORLD_SIZE,E=0;E<w.length;E++)if(!1!==w[E].visible){var M=w[E].position.distanceTo(U.get().position);M<v&&(v=M,k=E)}h=k;ha.update(h);setTimeout(function(S){return q=!0},100)}},A=function(){var k=Z.color_names(),
v=event.target.parentElement.parentElement;current=k.indexOf(v.getAttribute("data-color"));v.setAttribute("data-color",k[current+1===k.length?0:current+1]);ha.update(parseInt(v.id))},G=function(){for(var k=event.target.parentElement.parentElement,v=C(event.target),E=v+1;E<w.length;E++){var M=g.children[E];M.id=E-1;M.children[1].setAttribute("data-content",E)}w.splice(v,1);k.remove();x.splice(v,1);T.get().children[v+1].removeFromParent();ha.remove(v);for(k=0;k<w.length;k++)ha.update(k);I.render()},
J=function(){var k=event.target.parentElement.parentElement;u=C(event.target);k.classList.add("displace");la.keepCurrentTarget(!1)},K=function(){var k=event.target;64<=k.innerHTML.length&&"Backspace"!==event.key&&"Delete"!==event.key&&k.nextSibling.focus();"Enter"===event.key&&k.nextSibling.focus()},W=function(){event.preventDefault();var k=event.target,v=event.clipboardData.getData("text/plain"),E=H.isValidUrl(v);k.classList.contains("title")?!E&&64>v.length?(k.textContent=v,ha.update(h)):!E&&64<
v.length&&(k.nextSibling.focus(),k.nextSibling.textContent=v):k.textContent=v;E&&(k.nextSibling.focus(),k.nextSibling.innerHTML=H.isImage(v)?'<img id="annotationImage'+C(k)+'" src="'+v+'" crossOrigin="anonymous" width="100%">':'<a id="annotationLink'+C(k)+'" href="'+v+'" target="_blank">&#10149; Consulter le lien</a>')},C=function(k){return parseInt(k.parentElement.parentElement.id,10)},N=function(k){return document.getElementById(k).children[0]},F=function(k){return document.getElementById(k).getAttribute("data-color")},
L=function(k){q=!1;setTimeout(function(v){return q=!0},k)};return{init:function(){Q?la.stop(!1):la.stop(!0)},create:f,create_all:function(){var k=B(H.getJSON());if(0!==k.length){for(var v=document.createDocumentFragment(),E=0;E<k.length;E++){w.push(k[E]);r(k[E].position);_build("DIV",v,{id:E,"class":"annotation hidden","data-color":k[E].c});_build("DIV",v.children[E],{"class":"content"});_build("BUTTON",v.children[E],{"class":"number","data-content":E+1},{click:p});var M="";""!==k[E].txt&&(M="<div class='text'>"+
H.pdfString(k[E].txt)+"</div>");v.children[E].children[0].innerHTML="<strong class='title'>"+k[E].title+"</strong>"+M}g.append(v);ha.add_all(k);I.render();U.move_to(0)}},load:function(){event.preventDefault();var k=event.target,v=event.clipboardData.getData("text/plain");if(H.isValidUrl(v)){var E=decodeURIComponent(window.atob(v.split("?")[1]));v=new URLSearchParams(v.split("?")[0]+"?&"+E);var M=v.get("id");v=v.get("n");if(v!==V)k.placeholder="Wrong model. This link is attributed to '"+v+"'";else{v=
ka+"data.json";var S=new XMLHttpRequest;S.overrideMimeType("application/json");S.open("GET",v,!1);S.onreadystatechange=function(){if(4==S.readyState&&"200"==S.status)for(var ea=JSON.parse(S.responseText),aa=0;aa<ea.length;aa++)if(ea[aa].id==M){var Y=B(ea[aa]),O=X.get();O.rotation.y=0;O.rotation.x=0;O.rotation.z=0;O.applyMatrix4((new THREE.Matrix4).makeRotationX(0));O.applyMatrix4((new THREE.Matrix4).makeRotationY(0));O.applyMatrix4((new THREE.Matrix4).extractRotation(ea[aa].rotation));O=T.get();O.rotation.y=
0;O.rotation.x=0;O.rotation.z=0;O.applyMatrix4((new THREE.Matrix4).makeRotationX(0));O.applyMatrix4((new THREE.Matrix4).makeRotationY(0));O.children[0].applyMatrix4((new THREE.Matrix4).extractRotation(ea[aa].rotation));0===Y.length&&(k.placeholder="No annotations for this link");for(O=0;O<Y.length;O++)if(f(Y[O]),document.getElementById(O).setAttribute("data-color",Y[O].c),N(O).children[0].innerHTML=Y[O].title,ha.update(O),""!==Y[O].txt){var wa=document.createElement("DIV");wa.className="text";wa.innerHTML=
H.pdfString(Y[O].txt);N(O).insertBefore(wa,N(O).children[0].nextSibling)}}else k.placeholder="Please paste a valid Sketchnote3D link"};S.send(null)}}else k.placeholder="Please paste a valid Sketchnote3D link"},get:function(){return w},move:function(k){x[u].position.copy(k.position);h=u;g.children[u].classList.remove("displace");L(100);t(50);I.render();la.keepCurrentTarget(!0)},get_current:function(){return h},set_current:function(k){return h=k},get_title:function(k){var v=N(k).children[0].innerHTML;
""==v&&(v=N(k).children[0].getAttribute("data-content"));return H.cleanString(v)},get_subtext:function(k){k=N(k).children[0].nextSibling?N(k).children[0].nextSibling.innerHTML:"";return H.cleanString(k)},get_color:F,preventNearestDisplay:L,displayMode:function(){var k=event.target.value,v=g.children;if(0===v.length)alert("Aucune annotation \u00e0 masquer"),event.target.value="0";else{if("1"===k)for(v=$jscomp.makeIterator(v),k=v.next();!k.done;k=v.next())el=k.value,el.children[0].classList.add("undisplayed");
else if("2"===k)for(v=$jscomp.makeIterator(v),k=v.next();!k.done;k=v.next())el=k.value,el.classList.add("undisplayed");else for(v=$jscomp.makeIterator(v),k=v.next();!k.done;k=v.next())el=k.value,el.classList.remove("undisplayed"),el.children[0].classList.remove("undisplayed");I.render()}},get_hex:function(k){return getComputedStyle(document.body).getPropertyValue("--"+F(k)+"-light")},getPointers:function(){return x},toggleButtonDisplay:function(){Array.from(document.getElementsByClassName("delete")).forEach(function(k){return k.classList.toggle("undisplayed")});
Array.from(document.getElementsByClassName("move")).forEach(function(k){return k.classList.toggle("undisplayed")});Array.from(document.getElementsByClassName("color")).forEach(function(k){return k.classList.toggle("undisplayed")})},hide:function(k){for(var v=0;v<w.length;v++)k?H.addClass(v,"undisplayed"):H.removeClass(v,"undisplayed")}}}(),ha=function(){var b=document.getElementById("carousel_title"),d=document.getElementById("carousel"),f=d.children[0],g=document.getElementById("link_bar");Q&&(g.getElementsByTagName("input")[0].value=
"",g.addEventListener("paste",P.load,!1),g.classList.toggle("off"));var w=function(r){var t=document.createElement("LI");t.setAttribute("data-color",Z.color_name());t.addEventListener("click",function(){P.preventNearestDisplay(700);q();P.set_current(r);U.move_to(r,500);x(r)},!1);return t},x=function(r){var t=P.get_title(r),p=P.get_color(r);""===t&&(t="Click to edit");var D=f.children[r];D.innerHTML=t;D.setAttribute("data-color",p);b.innerHTML="Annotation "+(r+1)},h=function(){u();d.children[1].addEventListener("click",
function(){return B(-1)},!1);d.children[2].addEventListener("click",q,!1);d.children[3].addEventListener("click",function(){return B(1)},!1);Q||"true"===H.getJSON().hide_ui&&u()},q=function(){return f.classList.toggle("off")},u=function(){d.classList.toggle("off");Q&&g.classList.toggle("off")},B=function(r){P.preventNearestDisplay(700);r=P.get_current()+r;-1==r&&(r=f.children.length-1);r==f.children.length&&(r=0);P.set_current(r);U.move_to(r,500);x(r)};return{add:function(r){0===r&&h();f.append(w(r))},
remove:function(r){f.children[r].remove();0===f.children.length&&u()},update:x,add_all:function(r){h();for(var t=document.createDocumentFragment(),p=0;p<r.length;p++){var D=w(p);D.innerHTML=r[p].title;D.setAttribute("data-color",r[p].c);t.append(D)}f.append(t)}}}(),T=function(){function b(){var g=X.get();g=H.cloneAnimated(g);g=H.merge_geometries(g);g=H.simplify_geometry(g);var w=new THREE.Mesh,x=new THREE.Object3D;w.geometry=g;x.children[0]=H.center(w);return x.children[0]}var d=void 0,f=function(g){X.get_meshes().forEach(function(w){w=
$jscomp.makeIterator(w.material);for(var x=w.next();!x.done;x=w.next())m=x.value,m.depthWrite=!g,m.polygonOffset=g,m.polygonOffsetFactor=4,m.polygonOffsetUnits=.1})};return{get:function(){return d},getMesh:function(){return T.get().children[0]},getMaterial:function(){return T.getMesh().material},isVisible:function(){return T.getMaterial()[0].visible},init:function(){var g=ka+"mask.glb?nocache="+Date.now();H.fileExists(g)?T.load():T["export"]()},toggleDisplay:function(){var g=!T.isVisible();P.hide(g);
var w=T.getMaterial();w[0].visible=w[1].visible=g;f(g);I.render();I.render()},"export":function(){var g=b();(new THREE.GLTFExporter).parse(g,function(w){return fa.dataServer(w,"save_mask.php?folder="+V,!1,T.load)},{trs:!1,binary:!0})},setFrom:function(g){g.children[0].name="clone";g.children[0].position.set(0,0,0);g.children[0].rotation.copy(X.get().rotation);d=g;g=T.getMesh();g.geometry.addGroup(0,25E3,0);g.geometry.addGroup(0,25E3,1);g.material=[new THREE.MeshStandardMaterial({color:0,opacity:.65,
transparent:!0,side:0,visible:!1}),new THREE.MeshBasicMaterial({wireframe:!0,color:16777215,opacity:.3,transparent:!0,visible:!1})];I.add(d);Q||P.create_all()},load:function(){na.load(ka,"mask.glb",T.setFrom)}}}(),pa=function(){function b(){g.canvas.width=window.innerWidth;g.canvas.height=window.innerHeight}function d(){r?(g.clearRect(0,0,g.canvas.width,g.canvas.height),r=!1):(x.pop(),ma.update())}function f(F){function L(M){var S=document.createElement("input");S.type="button";S.className="btn_brush size"+
(M+1);S.addEventListener("click",function(){D=M;c=I.getCanvas();c.className="paintMode";c.classList.add("size"+(M+1))},!1);v.append(S)}function k(M){var S=document.createElement("input"),ea=["rgb(255,0,0)","rgb(0,255,0)","rgb(0,0,255)","rgb(255,255,0)","rgb(0,0,0)"];S.style.backgroundColor=ea[M];S.className="btn_brush color";S.type="button";S.addEventListener("click",function(){return A=ea[M]},!1);v.append(S)}var v=document.getElementById("context_controls");v.innerHTML="";var E=document.createElement("input");
E.id="btn_delete";E.type="button";E.addEventListener("click",d);if(F){v.append(E);for(F=0;3>F;F++)L(F);for(F=0;5>F;F++)k(F)}else v.innerHTML=""}var g=document.createElement("canvas").getContext("2d"),w=new THREE.TextureLoader,x=[],h=[],q=[3,10,50],u=!1,B=!1,r=!1,t=[],p=[],D=1,A="#000000",G=function(F){var L=I.get().domElement,k={mousedown:W,mousemove:C,mouseup:N,touchstart:W,touchmove:C,touchend:N};L.classList.toggle("paintMode");k=$jscomp.makeIterator(Object.entries(k));for(var v=k.next();!v.done;v=
k.next()){var E=$jscomp.makeIterator(v.value);v=E.next().value;E=E.next().value;F?L.addEventListener(v,E):L.removeEventListener(v,E)}F?document.addEventListener("player_resized",b):document.removeEventListener("player_resized",b)},J=function(){var F={dataURL:"",camera:"",dist:Math.max.apply(Math,$jscomp.arrayFromIterable(t))};F.dataURL=g.canvas.toDataURL();for(var L=U.get().clone(),k=L.children.length-1;0<=k;k--)L.remove(L.children[k]);F.camera=L.toJSON();h.push(F);return F},K=function(F){F=F?F:J();
var L=w.load(F.dataURL,function(){return setTimeout(function(v){return I.render()},50)}),k=(new THREE.ObjectLoader).parse(F.camera);X.get_meshes().forEach(function(v,E){var M=new window.projectedMaterial["default"]({camera:k,texture:L,color:0,transparent:!0,opacity:.9,alphaTest:.1,userData:{DISTANCE:Math.max.apply(Math,$jscomp.arrayFromIterable(t))}});M.uniforms.backgroundOpacity.value=0;v.material=M;M.project(v);x.push(M);ma.update()})},W=function(F){B=!0;F.touches?(F.preventDefault(),p.push({x:F.touches[0].clientX,
y:F.touches[0].clientY})):p.push({x:F.clientX,y:F.clientY})},C=function(F){if(B){t.push(la.getDistance());F.touches?(F.preventDefault(),p.push({x:F.touches[0].clientX,y:F.touches[0].clientY})):p.push({x:F.clientX,y:F.clientY});g.lineWidth=q[D];g.strokeStyle=A;g.lineJoin=g.lineCap="round";F=p[0];var L=p[1];g.beginPath();g.moveTo(F.x,F.y);for(var k=1,v=p.length;k<v;k++)g.quadraticCurveTo(F.x,F.y,F.x+(L.x-F.x)/2,F.y+(L.y-F.y)/2),F=p[k],L=p[k+1];g.lineTo(F.x,F.y);g.stroke()}},N=function(F){r=!0;B=!1;
p.length=0};return{init:function(){if(!Q){var F=H.getJSON();if(F.drawings)for(var L=$jscomp.makeIterator(F.drawings),k=L.next();!k.done;k=L.next())el=k.value,t=[],t.push(el.dist),K(el);F.draw_file&&""!==F.draw_file&&fetch(ka+"user_drawings/"+F.draw_file).then(function(v){return v.json()}).then(function(v){v=$jscomp.makeIterator(v);for(var E=v.next();!E.done;E=v.next())el=E.value,t=[],t.push(el.dist),K(el)})}},toggle:function(F){u=!u;la.stop(u);ba.stop(u);u&&xa.stop(u);ia.toggleState("btn_paint");
f(u);G(u);u?(r=!1,t=[],g.canvas.className="draw",b(),document.body.appendChild(g.canvas)):(r&&K(),g.canvas.remove())},stop:function(){u&&(ba.stop(!1),G(!1),K(),r&&K(),g.canvas.remove(),u=!1)},get_projected:function(){return x.slice()},get_projections:function(){return h.slice()},save_projections:function(){var F=h.slice(),L=Date.now()+"_draw.json";if(0===F.length)return"";fa.dataServer(F,"save_draw.php?folder="+V+"&filename="+L,!0);return L}}}();(function(){return{get_annotations:function(b){b=void 0===
b?void 0:b;for(var d=[],f=0;f<b.annotations.length;f++){var g=new THREE.Vector3(parseFloat(b.annotations[f].x),parseFloat(b.annotations[f].y),parseFloat(b.annotations[f].z)),w=new THREE.Vector3(parseFloat(b.annotations[f].camx),parseFloat(b.annotations[f].camy),parseFloat(b.annotations[f].camz));d.push({position:g,camera:w,name:"annotation"+f,vector:0,distance:0,title:b.annotations[f].title,txt:b.annotations[f].txt,c:b.annotations[f].c})}return d},display_ui:function(){return(void 0).display_ui},
animate:function(){return(void 0).animate},background:function(){return(void 0).background},material:function(){return(void 0).material},wire:function(){return(void 0).wire},rotation_state:function(){return(void 0).rotation},licence:function(){return(void 0).licence},transparent_state:function(){return parseInt((void 0).transparent)},tone_state:function(){return parseInt((void 0).tone)}}})();var la=function(){function b(){B=!1}function d(){B=!0}function f(){if(!B){if(event.changedTouches){event.preventDefault();
var p=event.changedTouches[0].clientX;var D=event.changedTouches[0].clientY}else p=event.clientX,D=event.clientY;if(p=g(new THREE.Vector2(p,D))){D=T.get();var A=U.get().position;p={position:D.worldToLocal(p.point),camera:D.worldToLocal((new THREE.Vector3).copy(A))};r?P.create(p):P.move(p)}}}function g(p){p=H.convert_to_3d(p);h.setFromCamera(p,U.get());return h.intersectObject(T.get(),!0)[0]}function w(){for(var p=I.get(),D=T.getMesh().material[0].visible,A=P.getPointers(),G=$jscomp.makeIterator(A),
J=G.next();!J.done;J=G.next())J.value.material.visible=!0;p.setRenderTarget(q);p.render(I.get_scene(),U.get());p.setRenderTarget(null);if(!1===D)for(p=$jscomp.makeIterator(A),J=p.next();!J.done;J=p.next())J.value.material.visible=!1}function x(p,D){var A=document.getElementById(D).classList;var G=new Float32Array(4);var J=window.innerWidth/2;var K=window.innerHeight/2;var W=p.position_2d.x-J,C=p.position_2d.y-K;I.get().readRenderTargetPixels(q,J+W,K-C,1,1,G);J=G[0].toFixed(3);K=G[1].toFixed(3);G=
G[2].toFixed(3);W=u;J==W.r&&K==W.g&&G==W.b?(p.visible=!0,A.remove("hidden")):(p.visible=!1,A.add("hidden"))}var h=new THREE.Raycaster,q=new THREE.WebGLRenderTarget(window.innerWidth,window.innerHeight),u={r:.847,g:.024,b:.412},B=!1,r=!0,t=!0;h.far=5;q.format=THREE.RGBAFormat;q.type=THREE.FloatType;document.addEventListener("player_resized",function(){q.setSize(window.innerWidth,window.innerHeight)});return{keepCurrentTarget:function(p){return r=p},stop:function(p){if(Q){p=!p;for(var D=I.get().domElement,
A=$jscomp.makeIterator(Object.entries({mousedown:b,mousemove:d,mouseup:f,touchstart:b,touchmove:d,touchend:f})),G=A.next();!G.done;G=A.next()){var J=$jscomp.makeIterator(G.value);G=J.next().value;J=J.next().value;p?D.addEventListener(G,J):D.removeEventListener(G,J)}}},annotations:function(){if(t){t=!1;w();for(var p=P.get(),D=0;D<p.length;D++)x(p[D],D);setTimeout(function(A){return t=!0},250)}},getDistance:function(){if(event.changedTouches){event.preventDefault();var p=event.changedTouches[0].clientX;
var D=event.changedTouches[0].clientY}else p=event.clientX,D=event.clientY;return(p=g(new THREE.Vector2(p,D)))?p.distance:void 0}}}(),ia=function(){var b=[],d,f=function(){return document.body.style.setProperty("--icon_size",Math.floor(H.get_2d_size(d))+"px")};return{create:function(g,w){g.appendChild(document.createElement("DIV"));var x=document.createDocumentFragment(),h={};for(n in w){if("editor"!==w[n].context||Q)if("viewer"!==w[n].context||!Q){b.push(w[n]);h.$jscomp$loop$prop$b$61=w[n];var q=
document.createElement("BUTTON");q.setAttribute("class","JS");q.setAttribute("id",h.$jscomp$loop$prop$b$61.id);q.setAttribute("value",0);q.setAttribute("title",h.$jscomp$loop$prop$b$61.title);q.addEventListener("click",function(B){return function(){var r=B.$jscomp$loop$prop$b$61.states,t=event.target,p=parseInt(t.value)+1;event.target.classList.contains("disable")||(t.value=p<=r-1?p:0)}}(h),!1);q.addEventListener("click",function(B){return function(){var r=B.$jscomp$loop$prop$b$61["function"];event.target.classList.contains("disable")||
r()}}(h),!1);if(!Q){var u=H.getJSON();h.$jscomp$loop$prop$b$61.init&&u[h.$jscomp$loop$prop$b$61.init["var"]]===h.$jscomp$loop$prop$b$61.init.val&&q.click();"true"===u.hide_ui&&q.classList.toggle("off")}x.prepend(q)}h={$jscomp$loop$prop$b$61:h.$jscomp$loop$prop$b$61}}g.firstElementChild.appendChild(x);d=new THREE.Mesh(new THREE.SphereBufferGeometry(.0015,24),new THREE.MeshStandardMaterial({visible:!1}));d.position.z=ta.Camera_POSITION;U.add(d);document.addEventListener("player_resized",f);f()},buton3D:function(){return d},
get:function(){return b},toggleState:function(g){setTimeout(function(){for(var w in b){var x=b[w].id;document.getElementById(x)&&x!==g&&document.getElementById(x).classList.toggle("disable")}},200)}}}(),Ea=function(){var b,d,f=function(){if(void 0!==b){var g=ta.get_position(),w=50*ta.SCALE,x=b.buttons,h=0;for(n in x){var q=H.polar_coordinate(g,205+-30*h,w);"btn_texture"===x[n].id&&(d.position.x=q.x,d.position.y=q.y);q=H.convert_to_2d(q);var u=document.getElementById(x[n].id);u.style.top=q.y+"px";
u.style.left=q.x+"px";h++}}};return{create:function(){b={destination:document.getElementById("editor_controls"),buttons:{display_mask:{id:"btn_mask",title:"Afficher le masque de collision",context:"editor",states:2,"function":T.toggleDisplay},change_texture:{id:"btn_texture",title:"Changer de texture",context:"editor",states:2,"function":ma.toggleMenu},rotate:{id:"btn_rotate",title:"Changer l'orientation",context:"editor",states:2,"function":X.toggleRotation},change_background:{id:"btn_background",
title:"Changer l'arriere plan",context:"editor",states:2,"function":Z.toggleBackground},change_ligthing:{id:"btn_lighting",title:"Augmenter/diminuer la luminosite",context:"editor",states:2,"function":Z.toggle_dark_mode}}};d=ia.buton3D();ia.create(b.destination,b.buttons);document.addEventListener("avatar_moved",f);f()},update_position:f}}(),Fa=function(){var b,d;return{create:function(){b=document.getElementById("player_controls");d={paint:{id:"btn_paint",title:"Dessiner sur le mod\u00e8le",context:"both",
states:2,"function":pa.toggle},display_annotations:{id:"btn_annotations",title:"Afficher/masquer les annotations",context:"both",states:3,"function":P.displayMode},center:{id:"btn_center",title:"Centrer la vue",context:"both",states:1,"function":ba.center},play:{id:"btn_play",title:"Jouer l'animation",context:"both",states:2,"function":xa.toggle,init:{"var":"animate",val:"true"}}};ia.create(b,d)}}}(),Ba=function(){function b(f){f.addEventListener("paste",function(){event.preventDefault();event.target.textContent=
event.clipboardData.getData("text/plain")});f.addEventListener("focus",function(){f.innerHTML="&nbsp;"});f.addEventListener("blur",function(){"&nbsp;"===f.innerHTML&&(f.innerHTML="")})}var d=document.getElementById("title_controls");return{create:function(){var f=document.createElement("div");d.append(f);if(Q)f=document.createElement("span"),f.setAttribute("id","title_edit"),f.setAttribute("data-placeholder","Add a multiline title here"),f.setAttribute("contenteditable",!0),b(f),d.firstChild.append(f);
else{f=H.getJSON();var g=document.createElement("span");f.title&&(g.innerHTML=f.title);d.firstChild.append(g)}},getEdit:function(){var f=document.getElementById("title_edit").innerHTML;return H.cleanString(f)}}}(),Ga=function(){return{create:function(){var b=document.getElementById("tool_controls");ia.create(b,{pdf:{id:"btn_pdf",title:"Cr\u00e9er un rendu pdf",constext:"both",states:1,"function":fa.pdf},screenshot:{id:"btn_screenshot",title:"obtenir une image du mod\u00e8le 3D",constext:"both",states:1,
"function":fa.screenshot},stl:{id:"btn_stl",title:"Exporter un fichier STL pour impression 3D",constext:"both",states:1,"function":fa.stl},attribution:{id:"btn_attribution",title:"Afficher/masquer les informations",context:"both",states:1,"function":ya.toggle}})}}}(),Ha=function(){function b(){x.parentNode.classList.toggle("off");u.classList.toggle("open");q.style.overflowY="auto";H.fadeIn("select_options")}function d(){for(var B=0;B<w.length;B++){var r=w[B];r.addEventListener("click",function(){return event.target.nextSibling.classList.toggle("off")});
r.innerHTML=r.innerHTML.replaceAll("_"," ");for(var t=r.innerHTML.split(" \u2192 "),p=0;p<t.length-1;p++)r.innerHTML=r.innerHTML.replace(t[p],'<span style="opacity:0.6">'+t[p]+"</span>")}if(3>w.length)for(B=$jscomp.makeIterator(w),r=B.next();!r.done;r=B.next())i=r.value,i.nextSibling.classList.toggle("off")}function f(){document.documentElement.style.setProperty("--scrollX",-event.target.children[1].scrollWidth+64+"px")}function g(){V=event.target.getAttribute("data-name");oa=event.target.getAttribute("data-file");
oa.split(".").pop();ja=event.target.getAttribute("data-path");sa=event.target.getAttribute("data-mtl");ua=event.target.getAttribute("data-attribution");ja=R+ja+"/";ka=ca+V+"/";q.style.overflowY="hidden";qa.init()}var w=document.getElementsByClassName("break_title"),x=document.getElementById("select_btn"),h=document.getElementsByClassName("model_item"),q=document.getElementById("background_wrapper"),u=document.getElementById("selection_menu");return{init:function(){x.selectedIndex=0;x.parentNode.addEventListener("click",
b,!1);d();for(var B=0;B<h.length;B++){var r=h[B],t=r.children[1];r.addEventListener("click",g);r.addEventListener("mouseover",f);t.innerHTML=t.innerHTML.replaceAll("_"," ")}H.beautifyConsole()}}}(),qa=function(){function b(){f.addEventListener("click",function(){return qa.go_to(1)});g.addEventListener("click",function(){return qa.go_to(2)});w.addEventListener("click",function(){return qa.go_to(3)})}var d=document.getElementById("navbar"),f=document.getElementById("step1"),g=document.getElementById("step2"),
w=document.getElementById("step3"),x=document.getElementById("screen_1");document.getElementById("screen_2");var h=document.getElementById("screen_3");return{init:function(){f.className="";g.className="active";d.classList.remove("off");x.classList.add("off");b();Ca.load_model()},go_to:function(q){switch(q){case 1:location.reload();break;case 2:x.classList.add("off");h.classList.add("off");g.className="active";w.className="";za.remove();break;case 3:g.className="",w.className="active",pa.stop(),h.classList.remove("off")}}}}(),
za=function(){function b(){return{id:JSON.stringify(q),link:encodeURIComponent(JSON.stringify(f())),date:(new Date).toJSON(),model:V,description:d()}}function d(){return H.cleanString(document.getElementById("context_data").value)}function f(){var B=window.btoa(encodeURIComponent("n="+V+"&id="+q));return new URL("../",document.URL)+"?"+B}function g(){var B=document.getElementsByClassName("inputCopy"),r=document.getElementsByClassName("inputLink"),t=document.getElementById("closeShare"),p=document.getElementById("generate_links");
Array.from(B).forEach(function(D){D.addEventListener("click",function(){return H.copyLink(event.target)},!1)});Array.from(r).forEach(function(D){D.addEventListener("click",function(){return event.target.setSelectionRange(0,event.target.value.length)},!1)});t.addEventListener("click",function(){return qa.go_to(2)},!1);p.addEventListener("click",function(){if(h.data.checked&&""===d())alert('No description provided. \n If you are just testing uncheck the "use in production" box');else{q=Date.now();var D=
document.querySelectorAll(".inputLink"),A=f(),G=!0===h.format.checked?["max-width:840px;max-height:640px","max-width:630px;max-height:480px","max-width:420px;max-height:320px"]:["max-width:640px;max-height:840px","max-width:480px;max-height:630px","max-width:320px;max-height:420px"],J=["overflow: hidden;height:75vmin;margin:auto;position: relative;","display:inline-block;width:100%;overflow: hidden;height:75vmin;margin:auto;position: relative;border:1px solid rgba(0,0,0,0.06);border-radius:1rem;"];
if(!h.data.checked){var K=document.createElement("p");K.innerHTML="/!/ Production link not checked - do not use in important context such as course, examen etc. /!/";K.style.color="yellow";K.style.padding="0.5rem";K.textWeight="bold";x.children[0].after(K)}D[0].value=A;D[1].value='<div class="iframe-container" style="'+J[0]+'"><iframe src="'+A+'" "height: 100%;width: 100%;position:absolute;top:0;left:0;" width="320" height="420" frameborder="0"></iframe></div>';D[2].value='<div class="iframe-container" style="'+
J[1]+G[0]+'"><iframe src="'+A+'"  "height: 100%;width: 100%;position:absolute;top:0;left:0;" width="320" height="420" frameborder="0"></iframe></div>';D[3].value='<div class="iframe-container" style="'+J[1]+G[1]+'"><iframe src="'+A+'"  "height: 100%;width: 100%;position:absolute;top:0;left:0;" width="320" height="420" frameborder="0"></iframe></div>';D[4].value='<div class="iframe-container" style="'+J[1]+G[2]+'"><iframe src="'+A+'"  "height: 100%;width: 100%;position:absolute;top:0;left:0;" width="320" height="420" frameborder="0"></iframe></div>';
w.classList.add("off");x.classList.remove("off");fa.dataServer(u(),"save_json_data.php?folder="+V,!0);h.data.checked&&fa.dataServer(b(),"save_links_data.php",!0)}},!1)}var w=document.getElementById("link_parameter"),x=document.getElementById("link_display"),h={"interface":document.getElementById("interface_checkbox"),animation:document.getElementById("animation_checkbox"),format:document.getElementById("format_checkbox"),data:document.getElementById("data_checkbox")},q;window.addEventListener("DOMContentLoaded",
function(B){Q&&g()});var u=function(){var B={id:JSON.stringify(q),path:encodeURIComponent(JSON.stringify(ja.replace(R,""))),date:(new Date).toJSON(),hide_ui:JSON.stringify(h["interface"].checked),animate:JSON.stringify(h.animation.checked),background:JSON.stringify(Z.color_index()),dark_mode:JSON.stringify(Z.dark_mode()),transparent:JSON.stringify(!Z.background_mode()),material:JSON.stringify(ma.get_index()),rotation:X.get().matrix,licence:ya.getEdit(),title:Ba.getEdit(),draw_file:pa.save_projections()},
r=P.get();if(0<r.length){var t=function(D){return JSON.stringify(parseFloat(D.toFixed(4)))};B.annotations=[];for(var p=0;p<r.length;p++)B.annotations.push({n:JSON.stringify(p),title:P.get_title(p),txt:P.get_subtext(p),x:t(r[p].position.x),y:t(r[p].position.y),z:t(r[p].position.z),camx:t(r[p].camera.x),camy:t(r[p].camera.y),camz:t(r[p].camera.z),c:P.get_color(p)})}return B};return{remove:function(){w.classList.remove("off");x.classList.add("off")},get_link:function(){q=Date.now();fa.dataServer(b(),
"save_json_data.php?folder="+V,!0);return f()}}}(),xa=function(){function b(){q(!0);B?(t=0,B.clipAction(r[t]).play(),x(function(){return B.update(u.getDelta())})):(x(void 0),ba.rotate(B?!1:!0));va=!0}function d(){q(!1);B?(B.stopAllAction(),B.timeScale=.8):ba.rotate(!1);I.get().setAnimationLoop(null);va=!1;I.render()}function f(p){p.traverse(function(D){D.isSkinnedMesh&&D.skeleton.pose()})}function g(){t=t+1<r.length?t+1:0;B.stopAllAction();B.clipAction(r[t]).play()}function w(){t=-1<t-1?t-1:r.length-
1;B.stopAllAction();B.clipAction(r[t]).play()}function x(p){I.get().setAnimationLoop(function(){p&&p();I.render()})}function h(){var p=event.target;p.classList.contains("activated")?B.timeScale=.8:B.timeScale=0;p.classList.toggle("activated")}function q(p){Q&&P.toggleButtonDisplay();var D=document.getElementById("context_controls");D.innerHTML="";var A=document.createElement("input");A.id="btn_pause";A.type="button";A.addEventListener("click",h);var G=document.createElement("input");G.className="arrow right";
G.type="button";G.addEventListener("click",g);var J=document.createElement("input");J.className="arrow left";J.type="button";J.addEventListener("click",w);p&&r&&(1<r.length?(D.append(J),D.append(A),D.append(G)):D.append(A))}var u=new THREE.Clock,B=void 0,r=void 0,t=0;return{set:function(p,D){f(p);r=D;B=new THREE.AnimationMixer(p);B.timeScale=.8},toggle:function(){va?(ia.toggleState("btn_play"),d()):(ia.toggleState("btn_play"),b())},stop:function(p){p?d():b()},get_animations:function(){return r}}}(),
ya=function(){var b=document.getElementById("tool_controls"),d=document.createElement("div"),f=function(){var h=document.getElementById("attribution_edit");return h?H.cleanString(h.innerHTML):""},g=function(){var h=w();if(""!==h){var q=document.createElement("span");q.setAttribute("id","attribution_default");d.appendChild(q);h=$jscomp.makeIterator(h);for(var u=h.next();!u.done;u=h.next())if(file=u.value,u=ja+file,file.endsWith("txt"))fetch(u).then(function(r){return r.text()}).then(function(r){q.prepend(r+
"\n"+f())});else{var B=document.createElement("img");B.src=u;B.height=60;q.append(B)}}},w=function(){var h=ua;if(""===h)return"";h=h.split(";");h.pop();return h},x=function(){var h=document.createElement("span");h.setAttribute("id","attribution_edit");d.appendChild(h);if(Q)h.setAttribute("data-placeholder","Click here to provide additional information"),h.setAttribute("contenteditable",!0),h.addEventListener("paste",function(){event.preventDefault();event.target.textContent=event.clipboardData.getData("text/plain")}),
h.addEventListener("focus",function(){h.innerHTML="&nbsp;"}),h.addEventListener("blur",function(){"&nbsp;"===h.innerHTML&&(h.innerHTML="")});else{var q=H.getJSON();h.innerHTML=q.licence}};return{toggle:function(){""===d.innerHTML&&(d.setAttribute("id","attribution"),d.setAttribute("class","off"),d.innerHTML='<div>\n\t\t\t<svg fill="var(--ui-color)"\n\t\t\tstroke="var(--ui-color)"\n\t\t\tstyle="height:1em;width:1em;vertical-align:bottom"\n\t\t\tversion="1.1" viewBox="0 0 80 80"\n\t\t\txmlns="http://www.w3.org/2000/svg">\n\t\t\t<g transform="translate(-6.6678 -6.9879)">\n\t\t\t<g transform="matrix(2.7406 0 0 2.7406 -350.43 -397.56)">\n\t\t\t<g transform="translate(.91284 .20806)">\n\t\t\t<path d="m138.83 151.13-4.9614 8.8077c0.40173 0.49127 1.1126 1.1146 1.1126 1.7492-1.2e-4\n\t\t\t0.63858-0.71391 1.249-1.1204 1.7415l5.27 9.3834 10.242-0.0563c0.41726-1.0443 1.4283-1.7292\n\t\t\t2.5528-1.7296 0.11056 2.3e-4 0.221 7e-3 0.33073 0.0207l5.316-9.3596-5.0183-8.6651c-0.20594\n\t\t\t0.0486-0.4168 0.0732-0.62839 0.0734-1.2165-7e-5 -2.2884-0.79936-2.6355-1.9652zm1.1085\n\t\t\t2.0361h10.358l4.8638 8.5209-4.8638 8.8511-5.0684-8.8511h-10.247z" stroke="none"/>\n\t\t\t<path d="m153.43 151.14a1.9873 1.9873 0 0 1-1.9873 1.9873 1.9873 1.9873 0 0 1-1.9873-1.9873\n\t\t\t1.9873 1.9873 0 0 1 1.9873-1.9873 1.9873 1.9873 0 0 1 1.9873 1.9873z" fill="#000" fill-opacity=".6" stroke-width=".62505"/>\n\t\t\t<path d="m134.98 161.68 4.9573-8.5209h10.358l-5.0684 8.5209z" fill="#000" fill-opacity=".6" stroke-width=".27676px"/>\n\t\t\t<path d="m153.43 172.86a1.9873 1.9873 0 0 1-1.9873 1.9873 1.9873 1.9873 0 0 1-1.9873-1.9873 1.9873 1.9873 0 0\n\t\t\t1 1.9873-1.9873 1.9873 1.9873 0 0 1 1.9873 1.9873z" fill="#000" fill-opacity=".6" stroke-width=".625"/>\n\t\t\t<path d="m134.68 161.68a1.9873 1.9873 0 0 1-1.9873 1.9873 1.9873 1.9873 0 0 1-1.9873-1.9873 1.9873 1.9873\n\t\t\t 0 0 1 1.9873-1.9873 1.9873 1.9873 0 0 1 1.9873 1.9873z" fill="#000" fill-opacity=".6" stroke-width=".625"/>\n\t\t\t</g></g></g></svg>\n\t\t\t<b> Sketchnote3D</b><br>Copyright 2021 - Universit\u00e9 de Gen\u00e8ve<br>\n\t\t\t</div>',
b.append(d),g(),x());d.className="off"===d.className?"on":"off"},getEdit:f,get_text:function(h){var q=w();""===q&&h(f());q=$jscomp.makeIterator(q);for(var u=q.next();!u.done;u=q.next())file=u.value,u=ja+file,file.endsWith("txt")&&fetch(u).then(function(B){return B.text()}).then(function(B){return h(B+"\n"+f())})}}}(),ma=function(){var b=new THREE.TextureLoader,d={origin:[],normal:[new THREE.MeshNormalMaterial],grey:[new THREE.MeshMatcapMaterial],porcelain:[new THREE.MeshMatcapMaterial],clay:[new THREE.MeshMatcapMaterial],
gold:[new THREE.MeshMatcapMaterial],metal:[new THREE.MeshMatcapMaterial],bone:[new THREE.MeshMatcapMaterial],skin:[new THREE.MeshMatcapMaterial],fabric:[new THREE.MeshMatcapMaterial],greenPaint:[new THREE.MeshMatcapMaterial],redPaint:[new THREE.MeshMatcapMaterial],blueChrome:[new THREE.MeshMatcapMaterial],glass:[new THREE.MeshMatcapMaterial],glass2:[new THREE.MeshMatcapMaterial],wire:[new THREE.MeshStandardMaterial,new THREE.MeshBasicMaterial({wireframe:!0,color:0,opacity:.15,transparent:!0})],gradient:[new THREE.MeshBasicMaterial]},
f={gold:{normalScale:new THREE.Vector2(.7,.7)},metal:{normalScale:new THREE.Vector2(.35,.35)},glass:{transparent:!0,opacity:.99,depthWrite:!0,side:2},glass2:{transparent:!0,opacity:.99,depthWrite:!0,side:2},wire:{color:new THREE.Color(.7,.7,.7)}};TEXTURES={grey:{matcap:"grey.jpg",map:"grayTexture.jpg",repeat:10},porcelain:{matcap:"porcelain.jpg"},skin:{matcap:"skin.jpg",map:"skinTexture.jpg",repeat:16},redPaint:{matcap:"red.jpg"},gold:{matcap:"gold.jpg",map:"goldTexture.jpg",normalMap:"metalNormal.jpg",
repeat:12},blueChrome:{matcap:"blueChrome.jpg"},fabric:{matcap:"softBrown.jpg",map:"fabricTexture.jpg",repeat:8},bone:{matcap:"bone.jpg",map:"boneTexture.jpg",repeat:5},greenPaint:{matcap:"green.jpg"},clay:{matcap:"clay.jpg",map:"clayTexture.jpg",repeat:10},metal:{matcap:"metal.jpg",map:"metalTexture.jpg",normalMap:"metalNormal.jpg",repeat:6},glass:{matcap:"glass.jpg",alphaMap:"glassAlpha.jpg"},glass2:{matcap:"glass2.jpg",alphaMap:"glassAlpha2.jpg"},gradient:{map:"gradient.jpg",repeat:1}};var g=0,
w=function(q){q=parseInt(q);X.get_meshes().forEach(function(u,B){var r=[],t=X.get_meshes(),p=x(q);0===q?r.push(p[B]):p.forEach(function(A){return r.push(A)});p=pa.get_projected();for(var D=B;D<p.length;D+=t.length)r.push(p[D]);u.geometry.clearGroups();r.forEach(function(A,G){return u.geometry.addGroup(0,Infinity,G)});u.material=r});g=q;Q&&T.isVisible()&&T.toggleDisplay();I.render()},x=function(q){return d[Object.keys(d)[q]]},h=function(q){q&&(q.encoding=I.ENCODING)};return{create:function(){for(var q in f){var u=
f[q],B=d[q][0];void 0!==B.envMap&&Z.add_envMap_to(B);B.color.convertSRGBToLinear();for(var r in u)B[r]=u[r];d[q][0]=B}for(var t in TEXTURES){q=TEXTURES[t];for(var p in q)"matcap"!==p&&"repeat"!==p&&"alphaMap"!==p&&(texture=b.load(da+"textures/"+q[p])),"alphaMap"===p&&(texture=b.load(da+"matCaps/"+q[p])),"matcap"===p&&(texture=b.load(da+"matCaps/"+q[p])),"map"!==p&&"matcap"!==p||h(texture),texture.wrapS=texture.wrapT=THREE.RepeatWrapping,texture.repeat.x=texture.repeat.y=q.repeat,u=d[t][0],u[p]=texture,
u.needsUpdate=!0}},set:function(q){w(q)},normalize:function(){var q=d.porcelain;X.get_meshes().forEach(function(u,B){if(u.isMesh){var r=u.material;H.isBlankMaterial(r)&&(r=(new THREE.MeshMatcapMaterial).copy(q[0]));null===r.envMap&&Z.add_envMap_to(r);h(r.map);h(r.envMap);h(r.EmissiveMap);var t=r;t.toneMapped=!1;null===t.map&&t.color&&("converted_from_SRGB"!==t.userData&&t.color.convertSRGBToLinear(),t.toneMapped=!0,t.userData="converted_from_SRGB");if(1===r.opacity)r.transparent=!1,r.side=THREE.FrontSide;
else{t=r.color;var p=r.opacity;r=new THREE.MeshMatcapMaterial;r.copy(d.glass[0]);r.color=t;r.opacity=p}u.geometry.addGroup(0,Infinity,0);u.material=[r];u.material.colorWrite=!1;d.origin.push(r)}})},get_current:function(){return x(g)},update:function(){return w(g)},get_index:function(){return g},toggleMenu:function(){var q=document.createDocumentFragment(),u=document.getElementById("context_controls");ia.toggleState("btn_texture");if(u.firstChild&&"texture"===u.firstChild.className)u.innerHTML="";
else{u.innerHTML="";var B=0,r;for(r in d){var t=document.createElement("INPUT");t.type="button";t.value=B;t.className="texture";t.addEventListener("click",function(){return w(event.target.value)},!1);q.append(t);B++}u.appendChild(q)}}}}(),X=function(){var b=void 0,d=[];_box=void 0;var f=function(){if(void 0===b)console.warn("NO Model : if a model is correctly uploaded call Model.set_from(uploaded) first");else return b};return{get:f,get_meshes:function(){0===d.length&&f().traverse(function(g){g.isMesh&&
d.push(g)});return d},set_from:function(g){b=g;b.name="model uploaded";b=H.scale(b);b=H.center(b);_originMatrix=b.matrix;ma.normalize(b);_box=(new THREE.Box3).setFromObject(b);Q||(g=H.getJSON(),b.applyMatrix4((new THREE.Matrix4).extractRotation(g.rotation)),ma.set(parseInt(g.material)));I.add(b)},toggleRotation:function(){ia.toggleState("btn_rotate");ba.get().reset();ba.stop(!0);var g=document.getElementById("context_controls");document.createElement("br");g.firstChild?(g.innerHTML="",ba.stop(!1)):
(g.innerHTML="",arrowBuild=function(w,x,h){var q=document.createElement("input");q.type="button";q.className=w;q.addEventListener("click",function(){if("vertical"===x){var u=(new THREE.Matrix4).makeRotationX(h*Math.PI/12);b.applyMatrix4(u);T.get().applyMatrix4(u);_box.setFromObject(b);Z.updateGroundPosition(_box.min.y)}else b.applyMatrix4((new THREE.Matrix4).makeRotationY(h*Math.PI/12)),T.get().applyMatrix4((new THREE.Matrix4).makeRotationY(h*Math.PI/12));I.render()},!1);g.append(q)},arrowBuild("arrow up",
"vertical",1),arrowBuild("arrow left","horizontal",-1),arrowBuild("arrow right","horizontal",1),arrowBuild("arrow down","vertical",-1))}}}(),fa=function(){var b=function(d){var f=document.createElement("a"),g=V;d instanceof Blob?(f.href=URL.createObjectURL(d),f.download=g+"-"+Date.now()+".stl"):(f.href=d,f.download=g+"-"+Date.now());document.body.appendChild(f);f.click();document.body.removeChild(f)};return{preview:function(){var d=new Image;d.src=ca+V+"preview.png?nocache="+Date.now();d.onerror=
function(){var f=ra.get(128,"png",void 0,!0);fa.dataServer(f,"save_preview.php?folder="+V,!1);console.warn("No preview image - creating new one");f=ra.get(512,"jpg",void 0);fa.dataServer(f,"save_social_preview.php?folder="+V,!1);console.warn("No Open Graph image - creating new one")}},stl:function(){var d=new THREE.STLExporter,f=I.get_scene(),g=X.get();f.rotation.set(Math.PI/2,0,0);f.updateMatrixWorld();d=d.parse(g,{binary:!0});f.rotation.set(0,0,0);f.updateMatrixWorld();d=new Blob([d],{type:"application/octet-stream"});
b(d)},screenshot:function(){var d=ra.get(1024,"png");b(d)},pdf:function(){return ya.get_text(Ia.create)},dataServer:function(d,f,g,w){var x=g?"application/json":"application/octet-stream";d=!0===g?JSON.stringify(d):d;f=Aa+f;g=new XMLHttpRequest;g.open("POST",f);w&&g.addEventListener("readystatechange",w);g.setRequestHeader("Content-Type",x);g.send(d)}}}(),na=function(){var b=document.getElementById("loader"),d=!1,f=function(x,h){switch(h){case "obj":return x;case "stl":return new THREE.Mesh(x,new THREE.MeshStandardMaterial);
case "glb":return x.scene;case "gltf":return x.scene;case "fbx":return x}},g=function(x){var h=new THREE.LoadingManager;h.addHandler(/\.tga$/i,new THREE.TGALoader);switch(x){case "obj":return new THREE.OBJLoader(h);case "stl":return new THREE.STLLoader;case "glb":return new THREE.GLTFLoader(h);case "gltf":return new THREE.GLTFLoader(h);case "fbx":return new THREE.FBXLoader(h)}h.onLoad=I.render()},w=function(x,h,q){(new THREE.MTLLoader).load(x+h,function(u){u.preload();q.setMaterials(u)})};return{load:function(x,
h,q){var u=H.file_format(h),B=g(u);"obj"===u&&""!==sa&&w(x,sa,B);(function(){B.load(x+h,function(r){var t=f(r,u);r.animations&&0<r.animations.length&&xa.set(t,r.animations);I.render();q(t)},function(r){d&&(r=Math.round(r.loaded/r.total*100),100>r?b.children[0].innerHTML=r+"%":(b.children[0].innerHTML="SETTING UP",H.fileExists(ka+"mask.glb")||(r=document.createElement("SPAN"),r.setAttribute("class","loader_warning"),r.innerHTML="Creating a collision mask, this will not happen next time...<br>(Can take times the first time the model is opened in editor)",
na._DOM_ELEMENT.appendChild(r))))})})()},show:function(){d=!0;b.classList.replace("off","on")},hide:function(){d=!1;b.classList.replace("on","off")},_DOM_ELEMENT:b}}(),Ia=function(){var b=window.jspdf.jsPDF;SPEED=50;IMG_PIXELS=900;IMG_SIZE=110;IMG_SPACE=125;TEXT_SPACE=75;var d,f,g,w=function(){var u=da+"pdf/header.png";d.setFillColor(g);d.setTextColor(255,255,255);d.rect(0,0,210,29,"F");d.rect(0,0,5.9,300,"F");d.addImage(u,"PNG",0,0,210,29);d.setFont("helvetica","normal");d.setFontSize(10);d.textWithLink("sn3d.unige.ch",
183,19,{url:"https://sn3d.unige.ch"});d.setFont("helvetica","bold");d.setFontSize(14);d.text('3D Model - "'+V+'"',6,9);d.setFontSize(11);d.textWithLink("click here to view it online",13,15,{url:Q?za.get_link():window.location.href});d.setFontSize(7);d.text(H.pdfString(f),6,20)},x=function(u){U.get().position.copy(u);I.render()},h=function(){function u(){var B=ra.get(1200,"jpg",null);d.addImage(B,"JPEG",6,60,204,204)}d.setTextColor(g);d.setFont("helvetica","bold");d.setFontSize(20);d.text("Model OVERVIEW",
75,42);d.text("ANNOTATIONS",75,280);d.setFontSize(15);d.textWithLink("Click here to view it online",75,52,{url:Q?za.get_link():window.location.href});ba.get().reset();0===P.get().length?u():setTimeout(function(){return u()},SPEED)},q=function(){var u=P.get(),B=0,r=function(){B>=u.length?d.save(V+"-"+Date.now()):(x(u[B].camera),setTimeout(function(){0===B%2&&(d.addPage(),w());var t=B,p=ra.get(IMG_PIXELS,"jpg",t);d.addImage(p,"JPEG",6,45+t%2*IMG_SPACE,IMG_SIZE,IMG_SIZE);t=B;d.setTextColor(P.get_hex(t));
d.setFont("helvetica","bold");d.setFontSize(14);p=H.pdfString(P.get_title(t));p=d.splitTextToSize(t+1+". "+p,TEXT_SPACE);d.text(p,IMG_SPACE,52+t%2*IMG_SPACE);t=B;p=document.getElementById("annotationImage"+t);var D=document.getElementById("annotationLink"+t),A=H.pdfString(P.get_subtext(t));if(A.startsWith("<img")){D=p.height;A=p.width;var G=p.height/p.width;if(D>TEXT_SPACE||A>TEXT_SPACE)D>A?(D=TEXT_SPACE,A=1/G*D):(A=TEXT_SPACE,D=A*G);d.addImage(p,"JPEG",IMG_SPACE,66+t%2*IMG_SPACE,A,D)}else A.startsWith("<a")?
(d.setTextColor("#248bfb"),d.textWithLink("Click here to view link online",IMG_SPACE,66+t%2*IMG_SPACE,{url:D.href}),d.setTextColor("#333333"),p=d.splitTextToSize(D.href,TEXT_SPACE),d.text(p,IMG_SPACE,72+t%2*IMG_SPACE)):(d.setFontSize(10),d.setTextColor("#333333"),p=d.splitTextToSize(A,TEXT_SPACE),d.text(p,IMG_SPACE,66+t%2*IMG_SPACE));B++;r()},SPEED))};r()};return{create:function(u){d=new b;f=u;Z.background_mode();g=Z.color_hex();w();h();q()}}}(),ra=function(){var b,d,f=document.createElement("canvas").getContext("2d"),
g,w,x,h,q,u,B,r=function(t){return h.children.forEach(function(p){"Mesh"===p.type&&(p.visible=!t)})};return{get:function(t,p,D,A){A=void 0===A?!1:A;g=Z.background_mode();w=I.get();x=I.get_scene();h=U.get();var G=window.innerWidth;B=t<=G?t:G;u=p;q=1;d=b=0;r(!0);t=A;p=Z.color_hex();t?x.background=null:(g&&(x.background=new THREE.Color(p)),g||"jpg"!==u||(x.background=new THREE.Color("#ffffff")));t=window.innerWidth;p=window.innerHeight;A=B;G=q=t>p?A/p:A/t;b=-(t*G-A)/2;d=-(p*G-A)/2;w.render(x,h);f.canvas.width=
f.canvas.height=A;f.drawImage(w.domElement,b,d,t*G,p*G);if(void 0===D)for(D=P.get(),t=0;t<D.length;t++){if(!1!==D[t].visible){f.lineJoin="round";f.lineWidth=20*q;f.fillStyle="rgba(0,0,0, 0.8)";f.strokeStyle="rgba(0,0,0, 0.8)";f.textBaseline="middle";f.font=14.5*q+"px Arial";p=P.get_title(t);var J=f.measureText(p.toUpperCase()).width,K=H.pdfString(P.get_subtext(t)),W=f.measureText(K).width;A=q;G=D[t].position_2d.x*A+b;var C=D[t].position_2d.y*A+d;J=J>W?J:W;350<J&&(J=350);if(K)if(K.startsWith("<img"))K=
document.getElementById("annotationImage"+t),f.strokeRect(G+10*A,C+10*A,20+K.width*A,20*A+K.height*A),f.fillRect(G+10*A,C+10*A,20+K.width*A,20*A+K.height*A),f.drawImage(K,G+15*A,C+30*A,K.width*A,K.height*A);else if(K.startsWith("<a"))for(K=H.wrapCanvasText(f,document.getElementById("annotationLink"+t).href,320),f.strokeRect(G+10*A,C+10*A,J+20*A,15*(K.length+1)*A),f.fillRect(G+10*A,C+10*A,J+20*A,15*(K.length+1)*A),f.fillStyle="rgba(255,255,255, 0.8)",J=0;J<K.length;J++)f.fillText(K[J],G+15*A,C+15*
(J+2)*A);else for(K=H.wrapCanvasText(f,K,320),f.strokeRect(G+10*A,C+10*A,J+20*A,15*(K.length+1)*A),f.fillRect(G+10*A,C+10*A,J+20*A,15*(K.length+1)*A),f.fillStyle="rgba(255,255,255, 0.8)",J=0;J<K.length;J++)f.fillText(K[J],G+15*A,C+15*(J+2)*A);else f.strokeRect(G+10*A,C+10*A,J+20*A,20*A),f.fillRect(G+10*A,C+10*A,J+20*A,20*A);f.fillStyle=P.get_hex(t);f.fillText(p.toUpperCase(),G+15*A,C+15*A);f.beginPath();f.arc(G,C,10*A,0,2*Math.PI);f.fill();f.fillStyle="#222";f.font=15*A+"px Arial";9>t?f.fillText(t+
1,G-4*A,C+1*A):f.fillText(t+1,C-8*A,C+1*A)}}else Number.isInteger(D)&&(A=P.get(),t=q,p=A[D].position_2d.x*t+b,A=A[D].position_2d.y*t+d,f.fillStyle=P.get_hex(D),f.beginPath(),f.arc(p,A,15*t,0,2*Math.PI),f.fill(),f.fillStyle="#222",f.font=20*t+"px Arial",9>D?f.fillText(D+1,p-6*t,A+7*t):f.fillText(D+1,p-12*t,A+7*t));r(!1);x.background=null;I.render();return"jpg"===u?f.canvas.toDataURL("image/jpeg"):f.canvas.toDataURL()}}}(),H=function(){return{getJSON:function(){return JSON.parse(window.sn3d.D.replace(/&quot;/g,
""))},get:function(b){return document.getElementById(b)},toggleClass:function(b,d){return document.getElementById(b).classList.toggle(d)},removeClass:function(b,d){return document.getElementById(b).classList.remove(d)},addClass:function(b,d){return document.getElementById(b).classList.add(d)},get_rem:function(b){return b*parseFloat(getComputedStyle(document.documentElement).fontSize)},scale:function(b){var d=H.get_box(b).size;b.scale.multiplyScalar(1/Math.max(d.x,d.y,d.z));return b},center:function(b){var d=
H.get_box(b).center,f=b.position;f.x+=f.x-d.x;f.y+=f.y-d.y;f.z+=f.z-d.z;return b},get_box:function(b){b=(new THREE.Box3).setFromObject(b);return{center:b.getCenter(new THREE.Vector3),size:b.getSize(new THREE.Vector3),length:b.getSize(new THREE.Vector3).length(),min:b.min,max:b.max}},simplify_geometry:function(b){b=(new THREE.SimplifyModifier).modify((new THREE.Geometry).fromBufferGeometry(b));b.computeFaceNormals();return(new THREE.BufferGeometry).copy(b.toBufferGeometry())},merge_geometries:function(b){var d=
[];b.traverse(function(f){if(f.isMesh){var g=(new THREE.BufferGeometry).copy(f.geometry),w=new THREE.Mesh(g);for(el in w.geometry.attributes)"normal"!==el&&"position"!==el&&g.deleteAttribute(el);w.geometry.morphAttributes={};w.geometry.morphTargetsRelative=!1;w.geometry.applyMatrix4(f.matrixWorld);d.push(w.geometry)}});return THREE.BufferGeometryUtils.mergeBufferGeometries(d,!1)},file_format:function(b){return b.split(".").pop()},show_box:function(b){b=(new THREE.Box3).setFromObject(b);I?I.add(new THREE.Box3Helper(b,
16776960)):console.log("Renderer not defined - cannot display box helped")},display:function(b){el=document.getElementById(b);el.classList.contains("off")?el.classList.replace("off","on"):el.classList.add("on")},fadeIn:function(b){el=document.getElementById(b);el.classList.add("hide");el.classList.contains("off")&&el.classList.toggle("off");setTimeout(function(){el.classList.replace("hide","show")},5)},hide:function(b){el=document.getElementById(b);el.classList.contains("on")?el.classList.replace("on",
"off"):el.classList.add("off")},copyLink:function(b){b=b.previousElementSibling;b.select();b.setSelectionRange(0,99999);document.execCommand("copy")},getId:function(b){return parseInt(b.target.id.replace(/^\D+/g,""),10)},isValidUrl:function(b){try{new URL(b)}catch(d){return!1}return!0},getExtension:function(b){return b.split(".").pop()},isImage:function(b){return"apng avif gif jpg jpeg png svg webp".split(" ").includes(H.getExtension(b))},download_file:function(b,d){d=void 0===d?V:d;var f=document.createElement("a");
b instanceof Blob?(f.href=URL.createObjectURL(b),f.download=d+"-"+Date.now()+".stl"):(f.href=b,f.download=d+"-"+Date.now());document.body.appendChild(f);f.click();document.body.removeChild(f)},convert_to_3d:function(b,d){var f=new THREE.Vector2;d||I.get();f.x=b.x/window.innerWidth*2-1;f.y=2*-(b.y/window.innerHeight)+1;return f},convert_to_2d:function(b,d,f){d||I.get();b=new THREE.Vector3(b.x,b.y,b.z);f=f?f:U.get();b.project(f);b.x=(.5+b.x/2)*window.innerWidth;b.y=(.5-b.y/2)*window.innerHeight;return b},
get_2d_size:function(b){var d=(new THREE.Box3).setFromObject(b);b=H.convert_to_2d(d.min);d=H.convert_to_2d(d.max);return Math.sqrt(Math.pow(d.x-b.x,2)+Math.pow(d.y-b.y,2)+Math.pow(d.z-b.z,2))},polar_coordinate:function(b,d,f){d=2*Math.PI/360*-(d-90);var g=b.x+Math.cos(d)*f;y=b.y+Math.sin(d)*f;z=b.z;return new THREE.Vector3(g,y,z)},waitFor:function(b){var d=function(f){b()?f():setTimeout(function(g){return d(f)},20)};return new Promise(d)},cleanString:function(b){return b.replace(/(\r\n|\n|\r)/gm,
"&#10;&#13;").replace(/'/g,"&apos;").replace(/"/g,"&quot;")},pdfString:function(b){return b.replace(/&#10;&#13;/g,"\n").replace(/&apos;/g,"'").replace(/&quot;/g,'"').replace(/&nbsp;/g," ")},wrapCanvasText:function(b,d,f){var g=d.startsWith("http")?"/":" ";words=d.split(g);lines=[];d=words[0];for(var w=1;w<words.length;w++){var x=words[w];b.measureText(d+g+x).width<f?d+=g+x:(lines.push(d),d=x)}lines.push(d);return lines},cloneAnimated:function(b){var d=new Map,f=b.clone(),g=function(w,x,h){h(w,x);
for(var q=0;q<w.children.length;q++)g(w.children[q],x.children[q],h)};g(b,f,function(w,x){d.set(w,x)});b.traverse(function(w){if(w.isSkinnedMesh){var x=w.skeleton.bones,h=d.get(w);h.skeleton=w.skeleton.clone();w.skeleton.pose();h.skeleton.bones=x.map(function(q){if(!d.has(q))throw Error("THREE.AnimationUtils: Required bones are not descendants of the given object.");return d.get(q)});h.bind(h.skeleton,w.bindMatrix)}});f.position.copy(b.position);return f},fileExists:function(b,d){var f=new XMLHttpRequest;
f.open("HEAD",b,void 0===d?!1:d);f.send();return 404!=f.status},toggle_view:function(b){el=document.getElementById(b);el.className="off"===el.className?"on":"off"},beautifyConsole:function(){},drawCanvasText:function(b,d,f,g,w){b.font=f;b.textBaseline="top";b.fillStyle="#f50";var x=b.measureText(d).width;b.fillRect(g,w,x,parseInt(f,10));b.fillStyle="#000";b.fillText(d,g,w)},getPositionFromColor:function(b,d){for(var f=b.canvas.width,g=b.canvas.height,w=b.getImageData(0,0,f,g).data,x,h=0,q,u;h<g;h++)for(q=
4*h*f,x=0;x<f;x++)if(u=q+4*x,w[u]===d[0]&&w[u+1]===d[1]&&w[u+2]===d[2])return[x,h];return null},get_face_count:function(b){var d=file_format(oa),f;b.traverse(function(g){if(g.isMesh)switch(d){case "obj":case "stl":f=g.geometry.attributes.position.count/3;break;case "gltf":case "glb":f=g.geometry.attributes.position.count}});return f},isBlankMaterial:function(b){var d=b.color;return d.r===d.b&&d.r===d.g&&.6<d.r&&!b.vertexColors&&null==b.map&&null==b.bumpMap&&null==b.normalMap&&1===b.opacity?!0:!1}}}(),
ta=function(){var b=new CustomEvent("avatar_moved",{detail:"event fired from Avatar"}),d,f,g=function(q){q=q.children[0];q.material=new THREE.MeshNormalMaterial;q.scale.set(1.9E-4,1.9E-4,1.9E-4);d=q;d.name="avatar";U.add(d);f=w();f.name="avatar_background";U.add(f);Q||"true"!==H.getJSON().hide_ui||(d.visible=f.visible=!1);h();x()},w=function(){var q=(new THREE.TextureLoader).load(da+"avatar/bg_avatar.png",function(){return I.render()});return new THREE.Mesh(new THREE.CircleBufferGeometry(.0114,64),
new THREE.MeshBasicMaterial({map:q}))},x=function(){if(void 0!==d){var q=ba.get().getPolarAngle(),u=ba.get().getAzimuthalAngle();d.rotation.y=-(u-.25);d.rotation.x=Math.PI/2-(q-.25)}},h=function(){if(void 0!==d){var q=-U.get().getFilmWidth()/1250,u=Q?.029:.033;d.position.set(q,u,-.1);f.position.set(2*q,2*u,-.2);document.dispatchEvent(b)}};return{create:function(){na.load(da,"avatar/avatar.glb",g);document.addEventListener("player_needUpdate",x);document.addEventListener("player_resized",h)},remove:function(){return I.remove(d)},
get_position:function(){return d.getWorldPosition(new THREE.Vector3)},get_pixel_size:function(){return H.get_2d_size(d)},SCALE:1.9E-4,resetRotation:function(){d.rotation.y=0;d.rotation.x=0},Camera_POSITION:-.1}}(),U=function(){var b,d,f=function(){b=new THREE.PerspectiveCamera(fov=45,aspect=2,near=1,far=7);b.position.set(0,0,1);b.name="camera";g();I.add(b)},g=function(){document.addEventListener("player_resized",w);document.addEventListener("player_needUpdate",function(){TWEEN.update()})},w=function(){var h=
X.get();if(void 0!==h){h=H.get_box(h);var q=b.fov/x().getFilmWidth();q*=h.length;var u=new THREE.Vector3;u.subVectors(b.position,h.center).multiply(new THREE.Vector3(0,0,1)).normalize();b.position.copy(u.multiplyScalar(q).add(h.center));b.far=h.length*I.WORLD_SIZE*1.5;b.near=.01;q=I.get().getSize(new THREE.Vector2);b.aspect=q.x/q.y;b.updateProjectionMatrix();b.lookAt(h.center)}},x=function(){void 0===b&&(console.warn("NO Camera, creating new one"),f());return b};return{create:f,resize:w,get:x,add:function(h){try{b.add(h)}catch(q){console.warn("NO PLAYER: "+
h.name+" not added to scene. Call Renderer.create first")}},remove_in:function(h){try{b.remove(h)}catch(q){console.warn(h.name+" undefined: unable to remove it from camera")}},remove_childs:function(){for(var h=b.children.length-1;0<=h;h--)b.remove(b.children[h])},move_to:function(h,q){P.preventNearestDisplay(q+200);var u=P.get();if(0!==u.length){u=(new THREE.Vector3).copy(u[h].camera);u.applyMatrix4((new THREE.Matrix4).extractRotation(X.get().matrix));var B={x:b.position.x,y:b.position.y,z:b.position.z};
u={x:u.x,y:u.y,z:u.z};(new TWEEN.Tween(B)).to(u,q).onUpdate(function(){b.position.set(B.x,B.y,B.z);I.render()}).start();I.render()}},get_origin:function(){return d},set_origin:function(){return d=(new THREE.Vector3).copy(b.position)}}}(),Z=function(){var b=0,d=!0,f=!0,g={r:.8,g:.9,b:1},w={r:1,g:1,b:1},x={world:void 0,lamp:void 0},h=void 0,q=void 0,u=[],B="pink blue green red yellow black".split(" "),r=function(){var C=Number(event.target.value);b=C;W(C)},t=function(){var C=document.getElementById("background_wrapper");
C.classList.contains("none")?C.classList.remove("none"):C.classList.add("none");C=q.material;C.opacity=1===C.opacity?0:1;f=!f;event.target.value=f?1:0;I.render()},p=function(){for(l in x)x[l].intensity=3===x[l].intensity?6:3;I.get().toneMappingExposure=2.25===I.get().toneMappingExposure?4:2.25;X.get_meshes().forEach(function(C){C=$jscomp.makeIterator(C.material);for(var N=C.next();!N.done;N=C.next())m=N.value,m.envmapIntensity=3===m.envmapIntensity?6:3});d=!d;W(b);I.render()},D=function(){return B[b]},
A=function(){return getComputedStyle(document.body).getPropertyValue("--"+D()+"-light")},G=function(){void 0==h&&(h=(new THREE.TextureLoader).load(da+"textures/equirectangular.jpg"),h.mapping=THREE.EquirectangularReflectionMapping)},J=function(){var C=(new THREE.TextureLoader).load(da+"textures/shadow.png",function(){return I.render()});C=new THREE.MeshBasicMaterial({map:C,transparent:!0,alphaTest:.001});geometry=new THREE.CircleBufferGeometry(I.WORLD_SIZE-.5,64);mesh=new THREE.Mesh(geometry,C);mesh.name=
"ground";mesh.material.depthWrite=!0;q=mesh;I.add(mesh)},K=function(C){C=new THREE.Color(C.r,C.g,C.b);I.ENCODING===THREE.sRGBEncoding&&C.convertSRGBToLinear();return C},W=function(C){color=u[C];x.world.groundColor=(new THREE.Color(""+color)).convertSRGBToLinear();I.render();var N=document.documentElement.style;N.setProperty("--main-color",u[C]);N.setProperty("--ui-color",A())};return{create:function(){G();b=Da;for(var C=$jscomp.makeIterator(B),N=C.next();!N.done;N=C.next()){c=N.value;N=u;var F=N.push;
var L=c;L=getComputedStyle(document.body).getPropertyValue("--"+L);F.call(N,L)}C=K(w);x.lamp=new THREE.DirectionalLight(C,3);U.add(x.lamp);C=K(g);N=new THREE.Color(""+u[0]);I.ENCODING===THREE.sRGBEncoding&&N.convertSRGBToLinear();x.world=new THREE.HemisphereLight(C,N,3);U.add(x.world);J();Q||(C=H.getJSON(),"true"===C.transparent&&t(),"false"===C.dark_mode&&p(),W(parseInt(C.background)))},set_from:function(C){C=H.get_box(C);var N=x.lamp,F=q;N.position.set(C.center.x+C.length,C.center.y+C.length,C.center.z+
C.length);var L=C.center,k=new THREE.Object3D;k.name="light_target";k.position.copy(L);U.add(k);N.target=k;F.rotateX(-(Math.PI/2));F.position.x=C.center.x;F.position.z=C.center.z;F.position.y=C.min.y},add_envMap_to:function(C){void 0===h&&(console.warn("NO ENVMAP: creating new one"),G());C.envMap=h;C.envMapIntensity=3;C.reflectivity&&(C.reflectivity=0)},set_envMap_from:function(C){return h=m.envMap},toggle_world_colors:r,toggle_dark_mode:p,toggle_world_display:t,updateGroundPosition:function(C){return q.position.y=
C},color_index:function(){return b},dark_mode:function(){return d},background_mode:function(){return f},color_name:D,color_names:function(){return B.slice()},color_hex:function(){return u[b]},color_ui:A,toggleBackground:function(){var C=document.createDocumentFragment(),N=document.getElementById("context_controls");ia.toggleState("btn_background");if(N.firstChild&&"backgroundColor"===N.firstChild.className)N.innerHTML="";else{N.innerHTML="";for(var F=0,L=$jscomp.makeIterator(u),k=L.next();!k.done;k=
L.next())k=document.createElement("INPUT"),k.type="button",k.value=F,k.className="backgroundColor",k.addEventListener("click",function(){return r()},!1),C.append(k),F++;L=document.createElement("INPUT");L.type="button";L.value=1;L.className="backgroundDisplay";L.addEventListener("click",function(){return t()},!1);C.append(L);F++;N.appendChild(C)}}}}(),ba=function(){var b=void 0,d=!1,f=function(){b=new THREE.OrbitControls(U.get(),I.get().domElement);b.enablePan=!0;b.enableKeys=!1;b.enableDamping=!0;
b.screenSpacePanning=!0;b.autoRotate=!1;b.autoRotateSpeed=3;b.enableRotate=!0;b.rotateSpeed=1.5;b.dampingFactor=.15;b.addEventListener("start",x,!0);b.addEventListener("change",h,!0);document.addEventListener("player_resized",w);document.addEventListener("player_needUpdate",q)},g=function(){void 0===b&&(console.warn("NO ORBIT CONTROLS: creating new one"),f());return b},w=function(){var u=X.get();void 0!==u&&(u=H.get_box(u),b.minDistance=u.length/1.5,b.maxDistance=2.5*u.length)},x=function(){document.activeElement.blur();
window.getSelection().removeAllRanges()},h=function(){I.render()},q=function(){return g().update()};return{create:f,get:g,saveStart:function(){g().saveState();d=!0},reset:function(){d&&g().reset()},rotate:function(u){return g().autoRotate=u},stop:function(u){return g().enabled=!u},center:function(){b.target=H.get_box(X.get()).center;I.render()},update:q}}(),I=function(){function b(){h=new THREE.WebGLRenderer({canvas:f,domElement:f,alpha:!0,antialias:!0});q=new THREE.Scene;U.create();h.physicallyCorrectLights=
!0;h.outputEncoding=THREE.sRGBEncoding;h.toneMapping=THREE.ReinhardToneMapping;h.toneMappingExposure=2.25;h.getContext().getExtension("EXT_float_blend");window.addEventListener("resize",u)}function d(){void 0===h&&(console.warn("NO Renderer, creating new one"),b());return h}var f=document.getElementById("rendering_zone"),g=2<window.devicePixelRatio?.7*window.devicePixelRatio:1,w=THREE.sRGBEncoding,x=new CustomEvent("player_resized",{detail:"event fired from Renderer on windows resize"});EVENT_UPDATE=
new CustomEvent("player_needUpdate",{detail:"event fired from Renderer"});var h,q,u=function(){ba.reset();h.setSize(window.innerWidth,window.innerHeight);h.setPixelRatio(g);document.dispatchEvent(x);t()},B=!1,r=function(){B=!1;document.dispatchEvent(EVENT_UPDATE);h.render(q,U.get())},t=function(){B||(B=!0,requestAnimationFrame(r))};return{create:b,resize:u,render:t,add:function(p){try{q.add(p)}catch(D){console.warn("NO SCENE: "+p.name+" not added to scene. Call Renderer.create first")}},remove_in:function(p){try{q.remove(p)}catch(D){console.warn(p.name+
" undefined: unable to remove it from camera")}},get:d,get_scene:function(){void 0===q&&console.warn("NO SCENE, call Renderer.create first");return q},getCanvas:function(){return d().domElement},WORLD_SIZE:4.5,ENCODING:w,RESOLUTION:g}}(),Ca=function(){function b(f){X.set_from(f);d(X.get())}function d(f){I.resize();U.set_origin();Z.create();Z.set_from(f);T.init();P.init();pa.init();Fa.create();Ga.create();Ba.create();Q&&Ea.create();H.fadeIn("player");I.render();na.hide();ba.saveStart();setTimeout(function(){return fa.preview()},
1500)}window.addEventListener("load",function(){I.create();ba.create();ta.create();Q?Ha.init():(V=window.atob(sn3d.N),ka=window.atob(config.j)+window.atob(config.i)+"/"+window.atob(sn3d.N)+"/",ja=window.atob(config.m)+window.atob(sn3d.P),oa=window.atob(sn3d.F),sa=sn3d.M,ua=sn3d.A,Ca.load_model())});return{load_model:function(){na.show();ma.create();na.load(ja,oa,b)}}}()}();