x_ite
Version:
X_ITE X3D Browser — View and Manipulate X3D, VRML, glTF and Other 3D Sources in HTML
2 lines • 17.6 kB
JavaScript
/* X_ITE v15.0.3 */
const t=window[Symbol.for("X_ITE.X3D")];(()=>{var e={n:t=>{var i=t&&t.__esModule?()=>t.default:()=>t;return e.d(i,{a:i}),i},d:(t,i)=>{for(var s in i)e.o(i,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const i=t.Components;var s=e.n(i);const n=t.TextureProperties;var o=e.n(n);const a=t.Vector3;var r=e.n(a);const l=t.Matrix4;var u=e.n(l);const h=t.ViewVolume;var c=e.n(h);const p=t.Namespace;var d=e.n(p);const g=Symbol();function y(){}Object.assign(y.prototype,{getScreenTextureProperties(){return this[g]??=(()=>{const t=new(o())(this.getPrivateScene());return t._boundaryModeS="CLAMP_TO_EDGE",t._boundaryModeT="CLAMP_TO_EDGE",t._boundaryModeR="CLAMP_TO_EDGE",t._minificationFilter="NEAREST_PIXEL",t._magnificationFilter="NEAREST_PIXEL",t._generateMipMaps=!1,t._textureCompression="DEFAULT",t.setup(),t})()},getScreenScaleMatrix:(()=>{const t=new(r()),e=new(r()),i=new(u());return function(s,n,o,a){const l=s.getModelViewMatrix().get(),u=s.getProjectionMatrix().get(),h=s.getViewVolumes().at(-1).getViewport();s.getViewpoint().getScreenScale(l.origin,h,t);const p=l.xAxis.normalize().multiply(t.x*o),d=l.yAxis.normalize().multiply(t.y*o),g=l.zAxis.normalize().multiply(t.x*o);i.set(...p,0,...d,0,...g,0,l[12],l[13],l[14],1),a&&(c().projectPoint(r().ZERO,i,u,h,e),e.x=Math.round(e.x),e.y=Math.round(e.y),c().unProjectPoint(e.x,e.y,e.z,i,u,h,e),e.z=0,i.translate(e)),n.assign(l).inverse().multLeft(i)}})()});const w=y,x=d().add("X3DLayoutContext",w),f=t.Fields;var _=e.n(f);const S=t.X3DFieldDefinition;var M=e.n(S);const O=t.FieldDefinitionArray;var b=e.n(O);const z=t.X3DNode;var m=e.n(z);const v=t.X3DChildNode;var F=e.n(v);const N=t.X3DConstants;var X=e.n(N);function T(t){F().call(this,t),this.addType(X().X3DLayoutNode)}Object.setPrototypeOf(T.prototype,F().prototype),Object.defineProperties(T,m().getStaticProperties("X3DLayoutNode","Layout",1));const B=T,P=d().add("X3DLayoutNode",B),L=t.Vector2;var U=e.n(L);const C=t.Vector4;var E=e.n(C);const D=t.Rotation4;var Y=e.n(D);const V=t.ObjectCache;const R=e.n(V)()(E());let I=0;const j=I++,A=I++,k=I++,G=I++,W=I++,H=I++,q=I++,Z=I++,K=I++,Q=I++;function J(t){P.call(this,t),this.addType(X().Layout)}Object.assign(Object.setPrototypeOf(J.prototype,P.prototype),{initialize(){P.prototype.initialize.call(this),this._align.addInterest("set_align__",this),this._offsetUnits.addInterest("set_offsetUnits__",this),this._offset.addInterest("set_offset__",this),this._sizeUnits.addInterest("set_sizeUnits__",this),this._size.addInterest("set_size__",this),this._scaleMode.addInterest("set_scaleMode__",this),this.set_align__(),this.set_offsetUnits__(),this.set_offset__(),this.set_sizeUnits__(),this.set_size__(),this.set_scaleMode__()},set_align__(){"LEFT"===this._align[0]?this.alignX=j:"RIGHT"===this._align[0]?this.alignX=k:this.alignX=A,"BOTTOM"===this._align[1]?this.alignY=G:"TOP"===this._align[1]?this.alignY=W:this.alignY=A},set_offsetUnits__(){"FRACTION"===this._offsetUnits[0]?this.offsetUnitX=q:"PIXEL"===this._offsetUnits[0]?this.offsetUnitX=Z:this.offsetUnitX=H,this._offsetUnits.length>1?"FRACTION"===this._offsetUnits[1]?this.offsetUnitY=q:"PIXEL"===this._offsetUnits[1]?this.offsetUnitY=Z:this.offsetUnitY=H:this.offsetUnitY=this.offsetUnitX},set_offset__(){this.offsetX=this._offset[0]??0,this.offsetY=this._offset[1]??this.offsetX},set_sizeUnits__(){"FRACTION"===this._sizeUnits[0]?this.sizeUnitX=q:"PIXEL"===this._sizeUnits[0]?this.sizeUnitX=Z:this.sizeUnitX=H,this._sizeUnits.length>1?"FRACTION"===this._sizeUnits[1]?this.sizeUnitY=q:"PIXEL"===this._sizeUnits[1]?this.sizeUnitY=Z:this.sizeUnitY=H:this.sizeUnitY=this.sizeUnitX},set_size__(){this.sizeX=this._size[0]??0,this.sizeY=this._size[1]??this.sizeX},set_scaleMode__(){"FRACTION"===this._scaleMode[0]?this.scaleModeX=q:"PIXEL"===this._scaleMode[0]?this.scaleModeX=Z:"STRETCH"===this._scaleMode[0]?this.scaleModeX=Q:this.scaleModeX=K,this._scaleMode.length>1?"FRACTION"===this._scaleMode[1]?this.scaleModeY=q:"PIXEL"===this._scaleMode[1]?this.scaleModeY=Z:"STRETCH"===this._scaleMode[1]?this.scaleModeY=Q:this.scaleModeY=K:this.scaleModeY=this.scaleModeX},getAlignX(){return this.alignX},getAlignY(){return this.alignY},getOffsetUnitX(t,e){return this.offsetUnitX===H?t[e]?.getOffsetUnitX(t,e-1)??q:this.offsetUnitX},getOffsetUnitY(t,e){return this.offsetUnitY===H?t[e]?.getOffsetUnitY(t,e-1)??q:this.offsetUnitY},getOffsetX(){return this.offsetX},getOffsetY(){return this.offsetY},getSizeUnitX(t,e){return this.sizeUnitX===H?t[e]?.getSizeUnitX(t,e-1)??q:this.sizeUnitX},getSizeUnitY(t,e){return this.sizeUnitY===H?t[e]?.getSizeUnitY(t,e-1)??q:this.sizeUnitY},getSizeX(){return this.sizeX},getSizeY(){return this.sizeY},getScaleModeX(t){return t?this.scaleModeX:this.scaleModeX===K?q:this.scaleModeX},getScaleModeY(t){return t?this.scaleModeY:this.scaleModeY===K?q:this.scaleModeY},push:(()=>{const t=new(E()),e=new(U()),i=new(U()),s=new(r()),n=new(r()),o=new(r()),a=new(r()),l=new(Y()),h=new(r()),c=new(u());return function(r,u){const p=u.getLayouts(),d=p.length-1,g=this.getBrowser().getRenderingProperty("ContentScale"),y=u.getNavigationInfo(),w=u.getViewpoint(),x=w.getNearDistance(y),f=u.getViewVolumes().at(-1).getViewport(),_=w.getViewportSize(f,x),S=R.pop(),M=u.getLayoutRectangles().at(-1)??t.set(0,0,..._),O=u.getModelViewMatrix();e.set(f[2],f[3]).divide(g),i.assign(_).divVec(e);const b=this.getSizeUnitX(p,d),z=this.getSizeUnitY(p,d);switch(b){case q:S.z=this.sizeX*M.z;break;case Z:S.z=this.sizeX*i.x}switch(z){case q:S.w=this.sizeY*M.w;break;case Z:S.w=this.sizeY*i.y}switch(s.set(0),this.getAlignX()){case j:s.x=-(M.z-S.z)/2;break;case A:b===Z&&1&e.x&&(s.x=-i.x/2);break;case k:s.x=(M.z-S.z)/2}switch(this.getAlignY()){case G:s.y=-(M.w-S.w)/2;break;case A:b===Z&&1&e.y&&(s.y=-i.y/2);break;case W:s.y=(M.w-S.w)/2}switch(n.set(0),this.getOffsetUnitX(p,d)){case q:n.x=this.offsetX*M.z;break;case Z:n.x=this.offsetX*_.x/e.x}switch(this.getOffsetUnitY(p,d)){case q:n.y=this.offsetY*M.w;break;case Z:n.y=this.offsetY*_.y/e.y}const m=this.getScaleModeX(p[d]),v=this.getScaleModeY(p[d]);switch(o.set(1),O.get().getTransform(a,l,h),m){case K:o.x=h.x;break;case q:o.x=S.z;break;case Q:break;case Z:o.x=_.x/e.x}switch(v){case K:o.y=h.y;break;case q:o.y=S.w;break;case Q:break;case Z:o.y=_.y/e.y}m===Q?v===Q?S.z>S.w?(o.x=S.z,o.y=o.x):(o.y=S.w,o.x=o.y):o.x=o.y:v===Q&&(o.y=o.x),s.add(n),S.x=s.x,S.y=s.y,c.setTransform(a,l).translate(s).scale(o),O.push(c),u.getLayouts().push(this),u.getLayoutRectangles().push(S)}})(),pop(t,e){const i=e.getModelViewMatrix();R.push(e.getLayoutRectangles().pop()),e.getLayouts().pop(),i.pop()}}),Object.defineProperties(J,{...m().getStaticProperties("Layout","Layout",1,"layout","3.2"),fieldDefinitions:{value:new(b())([new(M())(X().inputOutput,"metadata",new(_().SFNode)),new(M())(X().inputOutput,"align",new(_().MFString)("CENTER","CENTER")),new(M())(X().inputOutput,"offsetUnits",new(_().MFString)("WORLD","WORLD")),new(M())(X().inputOutput,"offset",new(_().MFFloat)(0,0)),new(M())(X().inputOutput,"sizeUnits",new(_().MFString)("WORLD","WORLD")),new(M())(X().inputOutput,"size",new(_().MFFloat)(1,1)),new(M())(X().inputOutput,"scaleMode",new(_().MFString)("NONE","NONE"))]),enumerable:!0}});const $=J,tt=d().add("Layout",$),et=t.X3DGroupingNode;var it=e.n(et);const st=t.X3DCast;var nt=e.n(st);function ot(t){it().call(this,t),this.addType(X().LayoutGroup),this.setCollisionObject(!1),this.matrix=new(u()),this.modelViewMatrix=new(u()),this.screenMatrix=new(u())}Object.assign(Object.setPrototypeOf(ot.prototype,it().prototype),{initialize(){it().prototype.initialize.call(this),this._viewport.addInterest("set_viewport__",this),this._layout.addInterest("set_layout__",this),this.set_viewport__(),this.set_layout__()},set_viewport__(){this.viewportNode=nt()(X().X3DViewportNode,this._viewport)},set_layout__(){this.layoutNode=nt()(X().X3DLayoutNode,this._layout)},set_collisionObjects__(){},getBBox(t,e){return this.isDefaultBBoxSize()?this.getSubBBox(t,e).multRight(this.getMatrix()):t.set(this._bboxSize.getValue(),this._bboxCenter.getValue())},getMatrix(){return this.layoutNode?this.matrix.assign(this.modelViewMatrix).inverse().multLeft(this.screenMatrix):this.matrix.set()},traverse(t,e){if(this.viewportNode?.push(e),this.layoutNode){const i=e.getModelViewMatrix();this.modelViewMatrix.assign(i.get()),this.layoutNode.push(t,e),this.screenMatrix.assign(i.get()),it().prototype.traverse.call(this,t,e),this.layoutNode.pop(t,e)}else it().prototype.traverse.call(this,t,e);this.viewportNode?.pop(e)}}),Object.defineProperties(ot,{...m().getStaticProperties("LayoutGroup","Layout",1,"children","3.2"),fieldDefinitions:{value:new(b())([new(M())(X().inputOutput,"metadata",new(_().SFNode)),new(M())(X().inputOutput,"layout",new(_().SFNode)),new(M())(X().inputOutput,"viewport",new(_().SFNode)),new(M())(X().inputOutput,"visible",new(_().SFBool)(!0)),new(M())(X().inputOutput,"bboxDisplay",new(_().SFBool)),new(M())(X().initializeOnly,"bboxSize",new(_().SFVec3f)(-1,-1,-1)),new(M())(X().initializeOnly,"bboxCenter",new(_().SFVec3f)),new(M())(X().inputOnly,"addChildren",new(_().MFNode)),new(M())(X().inputOnly,"removeChildren",new(_().MFNode)),new(M())(X().inputOutput,"children",new(_().MFNode))]),enumerable:!0}});const at=ot,rt=d().add("LayoutGroup",at),lt=t.X3DLayerNode;var ut=e.n(lt);const ht=t.OrthoViewpoint;var ct=e.n(ht);function pt(t){ut().call(this,t,new(ct())(t),new rt(t)),this.addType(X().LayoutLayer)}Object.assign(Object.setPrototypeOf(pt.prototype,ut().prototype),{initialize(){const t=this.getGroup();this._layout.addFieldInterest(t._layout),t._layout=this._layout,ut().prototype.initialize.call(this)}}),Object.defineProperties(pt,{...m().getStaticProperties("LayoutLayer","Layout",1,"layers","3.2"),fieldDefinitions:{value:new(b())([new(M())(X().inputOutput,"metadata",new(_().SFNode)),new(M())(X().inputOutput,"pickable",new(_().SFBool)(!0)),new(M())(X().inputOutput,"objectType",new(_().MFString)("ALL")),new(M())(X().inputOutput,"pointerEvents",new(_().SFBool)(!0)),new(M())(X().inputOutput,"visible",new(_().SFBool)(!0)),new(M())(X().inputOutput,"layout",new(_().SFNode)),new(M())(X().inputOutput,"viewport",new(_().SFNode)),new(M())(X().inputOnly,"addChildren",new(_().MFNode)),new(M())(X().inputOnly,"removeChildren",new(_().MFNode)),new(M())(X().inputOutput,"children",new(_().MFNode))]),enumerable:!0}});const dt=pt,gt=d().add("LayoutLayer",dt),yt=t.X3DFontStyleNode;var wt=e.n(yt);const xt=t.X3DTextGeometry;var ft=e.n(xt);const _t=t.TextAlignment;var St=e.n(_t);const Mt=t.PixelTexture;var Ot=e.n(Mt);const bt=t.Box3;var zt=e.n(bt);function mt(t,e){ft().call(this,t,e),t.setTransparent(!0),this.textureNode=new(Ot())(t.getExecutionContext()),this.context=document.createElement("canvas").getContext("2d",{willReadFrequently:!0}),this.matrix=new(u()),this.textureNode._textureProperties=e.getBrowser().getScreenTextureProperties(),this.textureNode.setup()}Object.assign(Object.setPrototypeOf(mt.prototype,ft().prototype),{getMatrix(){return this.matrix},getTextureNode(){return this.textureNode},configure:(()=>{const t=new(r()),e=new(r());return function(){ft().prototype.configure.call(this);const i=this.getFontStyle(),s=this.getText(),n=i.getContentScale();switch(s._textBounds.x=Math.ceil(s._textBounds.x)+1,s._textBounds.y=Math.ceil(s._textBounds.y)+1,this.getBBox().getExtents(t,e),t.x-=1,t.y-=1,i.getMajorAlignment()){case St().BEGIN:case St().FIRST:t.x=Math.floor(t.x),e.x=t.x+s._textBounds.x;break;case St().MIDDLE:t.x=Math.round(t.x),e.x=t.x+s._textBounds.x;break;case St().END:e.x=Math.ceil(e.x),t.x=e.x-s._textBounds.x}switch(i.getMinorAlignment()){case St().BEGIN:case St().FIRST:e.y=Math.ceil(e.y),t.y=e.y-s._textBounds.y;break;case St().MIDDLE:e.y=Math.round(e.y),t.y=e.y-s._textBounds.y;break;case St().END:t.y=Math.floor(t.y),e.y=t.y+s._textBounds.y}this.getBBox().setExtents(t,e),this.matrix.assign(u().ZERO),s._origin.x=t.x/n,s._origin.y=e.y/n,s._textBounds.x/=n,s._textBounds.y/=n;for(const t of s._lineBounds)t.x/=n,t.y/=n}})(),build:(()=>{const t=new(r()),e=new(r());return function(){const i=this.getFontStyle(),s=i.getFont();if(!s)return;const n=this.getText(),o=this.getGlyphs(),a=this.getMinorAlignment(),r=this.getTranslations(),l=this.getCharSpacings(),u=this.getScales(),h=i.getScale(),c=h/s.unitsPerEm,p=n.getTexCoords(),d=n.getNormals(),g=n.getVertices(),y=i.getContentScale(),w=this.context.canvas,x=this.context;n.getMultiTexCoords().push(p),this.getBBox().getExtents(t,e),p.push(0,0,0,1,1,0,0,1,1,1,0,1,0,0,0,1,1,1,0,1,0,1,0,1),d.push(0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1),g.push(t.x,t.y,0,1,e.x,t.y,0,1,e.x,e.y,0,1,t.x,t.y,0,1,e.x,e.y,0,1,t.x,e.y,0,1);const[f,_]=n._textBounds;if(w.width=f*y,w.height=_*y,x.fillStyle="rgba(255,255,255,0)",x.fillRect(0,0,w.width,w.height),x.fillStyle="rgba(255,255,255,1)",x.save(),x.translate(0,w.height),x.scale(1,-1),i._horizontal.getValue()){const i=o.length;for(let n=0;n<i;++n){const i=o[n],p=r[n],d=l[n],g=u[n],y=i.length;let w=0;for(let n=0;n<y;++n){const o=i[n],r=a.x+p.x+w*g+n*d-t.x,l=a.y+p.y-e.y;x.save(),x.translate(r,-l),x.scale(g,1),this.drawGlyph(x,s,o,h),x.restore();let u=0;n+1<i.length&&(u=s.getKerningValue(o,i[n+1])),w+=(o.advanceWidth+u)*c}}}else{const c=i._leftToRight.getValue(),p=i._topToBottom.getValue(),d=c?0:n._string.length-1,g=c?n._string.length:-1,y=c?1:-1;for(let i=d,n=0;i!==g;i+=y){const c=o[i],d=c.length,g=p?0:d-1,y=p?d:-1,w=p?1:-1,f=l[i],_=u[i];for(let i=g;i!==y;i+=w,++n){const o=r[n],l=p?i:d-i-1,u=a.x+o.x-t.x,g=a.y+o.y*_-l*f-e.y;x.save(),x.translate(u,-g),x.scale(1,_),this.drawGlyph(x,s,c[i],h),x.restore()}}}x.restore();const S=x.getImageData(0,0,w.width,w.height);S?this.textureNode.setTextureData(w.width,w.height,!0,!0,new Uint8Array(S.data.buffer)):this.textureNode.clear()}})(),drawGlyph(t,e,i,s){const n=i.getPath(0,0,s),o=n.commands;t.beginPath();for(const e of o)switch(e.type){case"M":t.moveTo(e.x,e.y);continue;case"Z":t.closePath();continue;case"L":t.lineTo(e.x,e.y);continue;case"Q":t.quadraticCurveTo(e.x1,e.y1,e.x,e.y);continue;case"C":t.bezierCurveTo(e.x1,e.y1,e.x2,e.y2,e.x,e.y);continue}n.fill&&t.fill(),n.stroke&&(t.lineWidth=n.strokeWidth,t.stroke())},getGlyphExtents(t,e,i,s,n){const o=t.unitsPerEm;s.set((e.xMin||0)/o,(e.yMin||0)/o,0),n.set((e.xMax||0)/o,(e.yMax||0)/o,0)},traverseBefore:(()=>{const t=new(zt()),e=new(u());return function(i,s,n){this.getBrowser().getScreenScaleMatrix(s,e,1,!0);const o=s.getModelViewMatrix();o.push(),o.multLeft(e),e.equals(this.matrix)||(this.matrix.assign(e),t.assign(this.getBBox()).multRight(this.matrix),this.getText().setBBox(t),n.set_bbox__())}})(),traverseAfter(t,e){e.getModelViewMatrix().pop()}});const vt=mt,Ft=d().add("ScreenText",vt);function Nt(t){wt().call(this,t),this.addType(X().ScreenFontStyle)}Object.assign(Object.setPrototypeOf(Nt.prototype,wt().prototype),{initialize(){wt().prototype.initialize.call(this),this.getBrowser().getRenderingProperties()._ContentScale.addInterest("addNodeEvent",this)},createTextGeometry(t){return new Ft(t,this)},getScale(){return this._pointSize.getValue()*this.getBrowser().getRenderingProperty("PixelsPerPoint")*this.getContentScale()},getContentScale(){return this.getBrowser().getRenderingProperty("ContentScale")}}),Object.defineProperties(Nt,{...m().getStaticProperties("ScreenFontStyle","Layout",2,"fontStyle","3.2"),fieldDefinitions:{value:new(b())([new(M())(X().inputOutput,"metadata",new(_().SFNode)),new(M())(X().inputOutput,"language",new(_().SFString)),new(M())(X().inputOutput,"family",new(_().MFString)("SERIF")),new(M())(X().inputOutput,"style",new(_().SFString)("PLAIN")),new(M())(X().inputOutput,"pointSize",new(_().SFFloat)(12)),new(M())(X().inputOutput,"spacing",new(_().SFFloat)(1)),new(M())(X().inputOutput,"horizontal",new(_().SFBool)(!0)),new(M())(X().inputOutput,"leftToRight",new(_().SFBool)(!0)),new(M())(X().inputOutput,"topToBottom",new(_().SFBool)(!0)),new(M())(X().inputOutput,"justify",new(_().MFString)("BEGIN"))]),enumerable:!0}});const Xt=Nt,Tt=d().add("ScreenFontStyle",Xt),Bt=t.TraverseType;var Pt=e.n(Bt);const Lt=t.X3DProtoDeclaration;var Ut=e.n(Lt);function Ct(t){it().call(this,t),this.addType(X().ScreenGroup),t.getOuterNode()instanceof Ut()?this.matrix=new(u()):this.matrix=new(u())(0)}Object.assign(Object.setPrototypeOf(Ct.prototype,it().prototype),{getBBox(t,e){return this.isDefaultBBoxSize()?this.getSubBBox(t,e).multRight(this.matrix):t.set(this._bboxSize.getValue(),this._bboxCenter.getValue())},getMatrix(){return this.matrix},traverse(t,e){switch(t){case Pt().CAMERA:case Pt().PICKING:case Pt().DEPTH:case Pt().SHADOW:break;default:{const t=this.getBrowser();t.getScreenScaleMatrix(e,this.matrix,t.getRenderingProperty("ContentScale"),!1);break}}const i=e.getModelViewMatrix();i.push(),i.multLeft(this.matrix),it().prototype.traverse.call(this,t,e),i.pop()}}),Object.defineProperties(Ct,{...m().getStaticProperties("ScreenGroup","Layout",2,"children","3.2"),fieldDefinitions:{value:new(b())([new(M())(X().inputOutput,"metadata",new(_().SFNode)),new(M())(X().inputOutput,"visible",new(_().SFBool)(!0)),new(M())(X().inputOutput,"bboxDisplay",new(_().SFBool)),new(M())(X().initializeOnly,"bboxSize",new(_().SFVec3f)(-1,-1,-1)),new(M())(X().initializeOnly,"bboxCenter",new(_().SFVec3f)),new(M())(X().inputOnly,"addChildren",new(_().MFNode)),new(M())(X().inputOnly,"removeChildren",new(_().MFNode)),new(M())(X().inputOutput,"children",new(_().MFNode))]),enumerable:!0}});const Et=Ct,Dt=d().add("ScreenGroup",Et);s().add({name:"Layout",concreteNodes:[tt,rt,gt,Tt,Dt],abstractNodes:[P],browserContext:x});d().add("LayoutComponent",void 0)})();