lingo3d-vanilla
Version:
Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor
1 lines • 6.36 kB
JavaScript
;(self.webpackChunklingo3d_vanilla=self.webpackChunklingo3d_vanilla||[]).push([[512],{9512:(e,t,o)=>{o.r(t),o.d(t,{HTMLMesh:()=>s,HTMLSprite:()=>r});var n=o(7002),i=o(5602);class s extends n.Kj0{constructor(e){const t=new l(e),o=new n._12(t.image.width*i.uh,t.image.height*i.uh),s=new n.vBJ({map:t,toneMapped:!1,transparent:!0});function r(e){s.map.dispatchDOMEvent(e)}super(o,s),this.addEventListener("mousedown",r),this.addEventListener("mousemove",r),this.addEventListener("mouseup",r),this.addEventListener("click",r),this.dispose=function(){o.dispose(),s.dispose(),s.map.dispose(),this.removeEventListener("mousedown",r),this.removeEventListener("mousemove",r),this.removeEventListener("mouseup",r),this.removeEventListener("click",r)},this.update=()=>t.update()}}class r extends n.jyi{constructor(e){const t=new l(e),o=new n.xeV({map:t,toneMapped:!1,transparent:!0});function s(e){o.map.dispatchDOMEvent(e)}super(o),this.scale.set(t.image.width*i.uh,t.image.height*i.uh,0),this.addEventListener("mousedown",s),this.addEventListener("mousemove",s),this.addEventListener("mouseup",s),this.addEventListener("click",s),this.dispose=function(){o.dispose(),o.map.dispose(),this.removeEventListener("mousedown",s),this.removeEventListener("mousemove",s),this.removeEventListener("mouseup",s),this.removeEventListener("click",s)},this.update=()=>t.update()}}class l extends n.ROQ{constructor(e){super(a(e)),this.dom=e,this.anisotropy=16,this.minFilter=n.wem,this.magFilter=n.wem;const t=new MutationObserver((()=>{this.update()}));t.observe(e,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),this.observer=t}dispatchDOMEvent(e){e.data&&function(e,t,o,n){const i={clientX:o*e.offsetWidth+e.offsetLeft,clientY:n*e.offsetHeight+e.offsetTop,view:e.ownerDocument.defaultView};window.dispatchEvent(new MouseEvent(t,i));const s=e.getBoundingClientRect();function r(e){if(e.nodeType!==Node.TEXT_NODE&&e.nodeType!==Node.COMMENT_NODE){const s=e.getBoundingClientRect();if(o>s.left&&o<s.right&&n>s.top&&n<s.bottom&&(e.dispatchEvent(new MouseEvent(t,i)),e instanceof HTMLInputElement&&"range"===e.type&&("mousedown"===t||"click"===t))){const[t,n]=["min","max"].map((t=>parseFloat(e[t]))),i=s.width,r=(o-s.x)/i;e.value=t+(n-t)*r,e.dispatchEvent(new InputEvent("input",{bubbles:!0}))}for(let t=0;t<e.childNodes.length;t++)r(e.childNodes[t])}}o=o*s.width+s.left,n=n*s.height+s.top,r(e)}(this.dom,e.type,e.data.x,e.data.y)}update(){this.image=a(this.dom),this.needsUpdate=!0}dispose(){this.observer&&this.observer.disconnect(),super.dispose()}}const d=new WeakMap;function a(e){const t=document.createRange(),o=new n.Ilk;function i(e,t,o,n){""!==n&&("uppercase"===e.textTransform&&(n=n.toUpperCase()),h.font=e.fontWeight+" "+e.fontSize+" "+e.fontFamily,h.textBaseline="top",h.fillStyle=e.color,h.fillText(n,t,o+.1*parseFloat(e.fontSize)))}function s(e,t,o,n,i){o<2*i&&(i=o/2),n<2*i&&(i=n/2),h.beginPath(),h.moveTo(e+i,t),h.arcTo(e+o,t,e+o,t+n,i),h.arcTo(e+o,t+n,e,t+n,i),h.arcTo(e,t+n,e,t,i),h.arcTo(e,t,e+o,t,i),h.closePath()}function r(e,t,o,n,i,s){const r=e[t+"Width"],l=e[t+"Style"],d=e[t+"Color"];"0px"!==r&&"none"!==l&&"transparent"!==d&&"rgba(0, 0, 0, 0)"!==d&&(h.strokeStyle=d,h.lineWidth=parseFloat(r),h.beginPath(),h.moveTo(o,n),h.lineTo(o+i,n+s),h.stroke())}const l=e.getBoundingClientRect();let a;d.has(e)?a=d.get(e):(a=document.createElement("canvas"),a.width=l.width,a.height=l.height);const h=a.getContext("2d"),c=new function(e){const t=[];let o=!1;function n(){if(o&&(o=!1,e.restore()),0===t.length)return;let n=-1/0,i=-1/0,s=1/0,r=1/0;for(let e=0;e<t.length;e++){const o=t[e];n=Math.max(n,o.x),i=Math.max(i,o.y),s=Math.min(s,o.x+o.width),r=Math.min(r,o.y+o.height)}e.save(),e.beginPath(),e.rect(n,i,s-n,r-i),e.clip(),o=!0}return{add:function(e){t.push(e),n()},remove:function(){t.pop(),n()}}}(h);return function e(n,d){let a=0,p=0,u=0,f=0;if(n.nodeType===Node.TEXT_NODE){t.selectNode(n);const e=t.getBoundingClientRect();a=e.left-l.left-.5,p=e.top-l.top-.5,u=e.width,f=e.height,i(d,a,p,n.nodeValue.trim())}else{if(n.nodeType===Node.COMMENT_NODE)return;if(n instanceof HTMLCanvasElement){if("none"===n.style.display)return;h.save();const e=window.devicePixelRatio;h.scale(1/e,1/e),h.drawImage(n,0,0),h.restore()}else{if("none"===n.style.display)return;const e=n.getBoundingClientRect();a=e.left-l.left-.5,p=e.top-l.top-.5,u=e.width,f=e.height,d=window.getComputedStyle(n),s(a,p,u,f,parseFloat(d.borderRadius));const t=d.backgroundColor;"transparent"!==t&&"rgba(0, 0, 0, 0)"!==t&&(h.fillStyle=t,h.fill());const m=["borderTop","borderLeft","borderBottom","borderRight"];let v=!0,g=null;for(const o of m){if(null!==g&&(v=d[o+"Width"]===d[g+"Width"]&&d[o+"Color"]===d[g+"Color"]&&d[o+"Style"]===d[g+"Style"]),!1===v)break;g=o}if(!0===v){const e=parseFloat(d.borderTopWidth);"0px"!==d.borderTopWidth&&"none"!==d.borderTopStyle&&"transparent"!==d.borderTopColor&&"rgba(0, 0, 0, 0)"!==d.borderTopColor&&(h.strokeStyle=d.borderTopColor,h.lineWidth=e,h.stroke())}else r(d,"borderTop",a,p,u,0),r(d,"borderLeft",a,p,0,f),r(d,"borderBottom",a,p+f,u,0),r(d,"borderRight",a+u,p,0,f);if(n instanceof HTMLInputElement){let e=d.accentColor;void 0!==e&&"auto"!==e||(e=d.color),o.set(e);const t=Math.sqrt(.299*o.r**2+.587*o.g**2+.114*o.b**2)<.5?"white":"#111111";if("radio"===n.type&&(s(a,p,u,f,f),h.fillStyle="white",h.strokeStyle=e,h.lineWidth=1,h.fill(),h.stroke(),n.checked&&(s(a+2,p+2,u-4,f-4,f),h.fillStyle=e,h.strokeStyle=t,h.lineWidth=2,h.fill(),h.stroke())),"checkbox"===n.type&&(s(a,p,u,f,2),h.fillStyle=n.checked?e:"white",h.strokeStyle=n.checked?t:e,h.lineWidth=1,h.stroke(),h.fill(),n.checked)){const e=h.textAlign;h.textAlign="center";i({color:t,fontFamily:d.fontFamily,fontSize:f+"px",fontWeight:"bold"},a+u/2,p,"✔"),h.textAlign=e}if("range"===n.type){const[o,i,r]=["min","max","value"].map((e=>parseFloat(n[e]))),l=(r-o)/(i-o)*(u-f);s(a,p+f/4,u,f/2,f/4),h.fillStyle=t,h.strokeStyle=e,h.lineWidth=1,h.fill(),h.stroke(),s(a,p+f/4,l+f/2,f/2,f/4),h.fillStyle=e,h.fill(),s(a+l,p,f,f,f/2),h.fillStyle=e,h.fill()}"color"!==n.type&&"text"!==n.type&&"number"!==n.type||(c.add({x:a,y:p,width:u,height:f}),i(d,a+parseInt(d.paddingLeft),p+parseInt(d.paddingTop),n.value),c.remove())}}}const m="auto"===d.overflow||"hidden"===d.overflow;m&&c.add({x:a,y:p,width:u,height:f});for(let t=0;t<n.childNodes.length;t++)e(n.childNodes[t],d);m&&c.remove()}(e),a}}}]);