suyiScreen/public/htWeb/lib/plugin/ht-webview3d.js

1 line
3.8 KiB
JavaScript

!function(m){"use strict";function q(x){var T,p,B,A,g,O,z,l=[],m=0;T=Y.createDiv(!0);var c=x.getView();c.insertBefore(T,x.getCanvas()),p=P.Default.createDiv(),p.style.WebkitTransformStyle="preserve-3d",p.style.MozTransformStyle="preserve-3d",p.style.transformStyle="preserve-3d",T.appendChild(p),[{event:"mousedown",style:"none"},{event:"mouseup",style:"auto"},{event:"touchstart",style:"none"},{event:"touchend",style:"auto"}].forEach(function(e){var A=e.style;E.addEventListener(c,e.event,function(){x.isDragProtectForWebView()&&(T.style.pointerEvents=A)})}),this.updateWebView=function(){if(x.getWidth()&&x.getHeight()){var R=x.getCanvas(),i=1*R.style.width.slice(0,-2),f=1*R.style.height.slice(0,-2);(l[0]!==i||l[1]!==f)&&(l[0]=i,l[1]=f,T.style.width=i+"px",T.style.height=f+"px",p.style.width=i+"px",p.style.height=f+"px");var c=x._projectMatrix[5]*l[1]/2;c!==B&&(B=c,T.style.WebkitPerspective=B+"px",T.style.MozPerspective=B+"px",T.style.perspective=B+"px"),O="translateZ("+B+"px)"+y(x._viewMatrix);var F=O+"translate("+l[0]/2+"px,"+l[1]/2+"px)";A===F||g||(p.style.WebkitTransform=F,p.style.MozTransform=F,p.style.transform=F,A=F),m++,z=!1,x.dm().each(function(M){M.isWebView&&S(M)});for(var b,w=p.children,v=[],u=0,X=w.length;X>u;u++)b=w[u],b._isHtWebView&&b._renderCookie!==m&&v.push(b);v.length&&v.forEach(function(H){p.removeChild(H)})}};var _=new Array(16),S=function(e){var H=e.getAttach();if(H){var y=x.isVisible(e);if(y&&H.parentNode!==p?p.appendChild(H):!y&&H.parentNode&&Y.removeHTML(H),y){H._renderCookie=m,z=!0;var u=e.getFinalScale3d(),V=e._prefrenceSize;V&&V[0]?V[1]||(V[1]=V[0]/u[0]*u[1]):V=[u[0],u[1]],H.style.width=V[0]+"px",H.style.height=V[1]+"px";var N=1/V[0],f=1/V[1],j=1,T=e.mat;_[0]=T[0]*N,_[1]=T[1]*N,_[2]=T[2]*N,_[3]=T[3]*N,_[4]=T[4]*f,_[5]=T[5]*f,_[6]=T[6]*f,_[7]=T[7]*f,_[8]=T[8]*j,_[9]=T[9]*j,_[10]=T[10]*j,_[11]=T[11]*j,_[12]=T[12],_[13]=T[13],_[14]=T[14],_[15]=T[15];var U=R(_,g?"translate("+l[0]/2+"px,"+l[1]/2+"px)"+O:""),b=H.$a2;b!==U&&(H.$a2=U,H.style.WebkitTransform=U,H.style.MozTransform=U,H.style.transform=U)}}}}function n(R){return Math.abs(R)<1e-10?0:R}function y(L){var $=L;return"matrix3d("+n($[0])+","+n(-$[1])+","+n($[2])+","+n($[3])+","+n($[4])+","+n(-$[5])+","+n($[6])+","+n($[7])+","+n($[8])+","+n(-$[9])+","+n($[10])+","+n($[11])+","+n($[12])+","+n(-$[13])+","+n($[14])+","+n($[15])+")"}function R(E,f){var Y=E,Z="matrix3d("+n(Y[0])+","+n(Y[1])+","+n(Y[2])+","+n(Y[3])+","+n(-Y[4])+","+n(-Y[5])+","+n(-Y[6])+","+n(-Y[7])+","+n(Y[8])+","+n(Y[9])+","+n(Y[10])+","+n(Y[11])+","+n(Y[12])+","+n(Y[13])+","+n(Y[14])+","+n(Y[15])+")";return"translate(-50%,-50%)"+(f||"")+Z}var T="ht",P=m[T],Y=P.Default,E=Y.getInternal(),g=E.superCall,o=P.graph3d.Graph3dView,M=o.prototype.validateImpl;o.prototype.validateImpl=function(){M.call(this);var W=this._webViewRenderer;W||(W=this._webViewRenderer=new q(this)),W.updateWebView()},o.prototype.isDragProtectForWebView=function(){return this._dragProtectForWebView},o.prototype.setDragProtectForWebView=function(m){this._dragProtectForWebView=m};var z=P.WebView3d=function(){var m=this;g(z,m),m.s({shape3d:"billboard","shape3d.reverse.flip":!0})},t=[1,1,1,1],S=[0,0,0,0];Y.def(T+"."+"WebView3d",P.Node,{ms_ac:["attach"],isWebView:!0,attachDOM:function(Y,d,$){if(!Y)return this.detachDOM();if("string"==typeof Y){var I=document.createElement("iframe");I.src=Y,Y=I}var q=Y.style;q.position="absolute",q.border=0,q.outline=0,q.padding=0,q.margin=0,Y._isHtWebView=!0,this.setAttach(Y),this._prefrenceSize=[d,$],this.s("shape3d.blend",S)},detachDOM:function(){this.setAttach(null),this.s("shape3d.blend",this.getBgColor())},setBgColor:function(S){this.a("defaultBgColor",S),this.getAttach()||this.s("shape3d.blend",S)},getBgColor:function(){return this.a("defaultBgColor")||t}})}("undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:(0,eval)("this"),Object);