x_ite
Version:
X_ITE X3D Browser — View and Manipulate X3D, VRML, glTF and Other 3D Sources in HTML
2 lines • 16.2 kB
JavaScript
/* X_ITE v15.0.3 */
const e=window[Symbol.for("X_ITE.X3D")];(()=>{var t={n:e=>{var i=e&&e.__esModule?()=>e.default:()=>e;return t.d(i,{a:i}),i},d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const i=e.Components;var s=t.n(i);const n=e.X3DBaseNode;var o=t.n(n);const r=e.X3DConstants;var a=t.n(r);const l=e.Fields;var h=t.n(l);const g=e.Namespace;var c=t.n(g);function d(e){o().call(this,e),this.addChildObjects(a().inputOutput,"dimension",new(h().SFInt32)(40))}Object.setPrototypeOf(d.prototype,o().prototype),Object.defineProperties(d,{typeName:{value:"Arc2DOptions",enumerable:!0}});const p=d,u=c().add("Arc2DOptions",p);function y(e){o().call(this,e),this.addChildObjects(a().inputOutput,"dimension",new(h().SFInt32)(40))}Object.setPrototypeOf(y.prototype,o().prototype),Object.defineProperties(y,{typeName:{value:"ArcClose2DOptions",enumerable:!0}});const m=y,O=c().add("ArcClose2DOptions",m),D=e.IndexedLineSet;var f=t.n(D);const w=e.Coordinate;var b=t.n(w);const _=e.Complex;var P=t.n(_);function S(e){o().call(this,e),this.addChildObjects(a().inputOutput,"dimension",new(h().SFInt32)(40))}Object.assign(Object.setPrototypeOf(S.prototype,o().prototype),{initialize(){o().prototype.initialize.call(this),this.addInterest("eventsProcessed",this)},getGeometry(){return this.geometry||this.build(),this.geometry},createCoordIndex(){const e=this._dimension.getValue(),t=this.geometry._coordIndex;for(let i=0;i<e;++i)t.push(i);t.push(0,-1)},createPoints(){const e=this._dimension.getValue(),t=2*Math.PI/e,i=this.geometry._coord.getValue()._point;for(let s=0;s<e;++s){const e=P().fromPolar(1,t*s);i.push(new(h().SFVec3f)(e.real,e.imag,0))}},build(){this.geometry=new(f())(this.getExecutionContext()),this.geometry._coord=new(b())(this.getExecutionContext()),this.createCoordIndex(),this.createPoints();const e=this.geometry;this.geometry._coord.getValue().setup(),e.setup()},eventsProcessed(){this.geometry=null}}),Object.defineProperties(S,{typeName:{value:"Circle2DOptions",enumerable:!0}});const V=S,v=c().add("Circle2DOptions",V),C=e.X3DGeometryNode;var M=t.n(C);function x(e){o().call(this,e),this.addChildObjects(a().inputOutput,"dimension",new(h().SFInt32)(40)),this.diskTexCoords=M().createArray(),this.diskNormals=M().createArray(),this.diskVertices=M().createArray()}Object.assign(Object.setPrototypeOf(x.prototype,o().prototype),{initialize(){o().prototype.initialize.call(this),this.addInterest("eventsProcessed",this)},getDiskTexCoords(){return this.diskTexCoords.length||this.build(),this.diskTexCoords},getDiskNormals(){return this.diskNormals.length||this.build(),this.diskNormals},getDiskVertices(){return this.diskVertices.length||this.build(),this.diskVertices},build:(()=>{const e=new(P())(.5,.5),t=new(P()),i=new(P()),s=new(P()),n=new(P());return function(){const o=this._dimension.getValue(),r=2*Math.PI/o,a=this.diskTexCoords,l=this.diskNormals,h=this.diskVertices;for(let g=0;g<o;++g){const o=r*g,c=r*(g+1);t.setPolar(.5,o).add(e),i.setPolar(.5,c).add(e),s.setPolar(1,o),n.setPolar(1,c),a.push(.5,.5,0,1,t.real,t.imag,0,1,i.real,i.imag,0,1),l.push(0,0,1,0,0,1,0,0,1),h.push(0,0,0,1,s.real,s.imag,0,1,n.real,n.imag,0,1)}a.shrinkToFit(),l.shrinkToFit(),h.shrinkToFit()}})(),eventsProcessed(){this.diskTexCoords.length=0,this.diskNormals.length=0,this.diskVertices.length=0}}),Object.defineProperties(x,{typeName:{value:"Disk2DOptions",enumerable:!0}});const T=x,F=c().add("Disk2DOptions",T),j=e.IndexedFaceSet;var A=t.n(j);const k=e.TextureCoordinate;var N=t.n(k);function I(e){o().call(this,e)}Object.assign(Object.setPrototypeOf(I.prototype,o().prototype),{getGeometry(){if(this.geometry)return this.geometry;this.geometry=new(A())(this.getExecutionContext()),this.geometry._texCoord=new(N())(this.getExecutionContext()),this.geometry._coord=new(b())(this.getExecutionContext());const e=this.geometry,t=this.geometry._texCoord.getValue(),i=this.geometry._coord.getValue();return t._point=[1,1,0,1,0,0,1,0],i._point=[1,1,0,-1,1,0,-1,-1,0,1,-1,0],e._coordIndex=[0,1,2,3,-1],t.setup(),i.setup(),e.setup(),this.geometry}}),Object.defineProperties(I,{typeName:{value:"Rectangle2DOptions",enumerable:!0}});const G=I,z=c().add("Rectangle2DOptions",G),B=e.PrimitiveQuality;var R=t.n(B);const U=Symbol(),X=Symbol(),E=Symbol(),Q=Symbol(),H=Symbol();function L(){}function q(e,t){return this[e]??=(()=>{const e=new t(this.getPrivateScene());return e.setup(),e})()}Object.assign(L.prototype,{initialize(){this.setPrimitiveQuality2D(this.getBrowserOptions().getPrimitiveQuality())},getArc2DOptions(){return q.call(this,U,u)},getArcClose2DOptions(){return q.call(this,X,O)},getCircle2DOptions(){return q.call(this,E,v)},getDisk2DOptions(){return q.call(this,Q,F)},getRectangle2DOptions(){return q.call(this,H,z)},setPrimitiveQuality2D(e){const t=this.getArc2DOptions(),i=this.getArcClose2DOptions(),s=this.getCircle2DOptions(),n=this.getDisk2DOptions();switch(e){case R().LOW:t._dimension=20,i._dimension=20,s._dimension=20,n._dimension=20;break;case R().MEDIUM:t._dimension=40,i._dimension=40,s._dimension=40,n._dimension=40;break;case R().HIGH:t._dimension=80,i._dimension=80,s._dimension=80,n._dimension=80}}});const W=L,J=c().add("X3DGeometry2DContext",W),K=e.X3DFieldDefinition;var Y=t.n(K);const Z=e.FieldDefinitionArray;var $=t.n(Z);const ee=e.X3DNode;var te=t.n(ee);const ie=e.X3DLineGeometryNode;var se=t.n(ie);const ne=e.Algorithm;var oe=t.n(ne);function re(e){se().call(this,e),this.addType(a().Arc2D),this._startAngle.setUnit("angle"),this._endAngle.setUnit("angle"),this._radius.setUnit("length")}Object.assign(Object.setPrototypeOf(re.prototype,se().prototype),{set_live__(){this.connectOptions(this.getBrowser().getArc2DOptions())},getSweepAngle(){const e=oe().interval(this._startAngle.getValue(),0,2*Math.PI),t=oe().interval(this._endAngle.getValue(),0,2*Math.PI);if(e===t)return 2*Math.PI;const i=Math.abs(t-e);return e>t?2*Math.PI-i:isNaN(i)?0:i},build:(()=>{const e=new(P()),t=new(P());return function(){const i=this.getBrowser().getArc2DOptions()._dimension.getValue(),s=this._startAngle.getValue(),n=Math.abs(this._radius.getValue()),o=this.getSweepAngle(),r=Math.max(3,Math.floor(o*i/(2*Math.PI))),a=this.getVertices();for(let i=0;i<r;++i){const l=s+o*(i/r),h=e.setPolar(n,l),g=s+o*((i+1)/r),c=t.setPolar(n,g);a.push(h.real,h.imag,0,1),a.push(c.real,c.imag,0,1)}this.getMin().set(-n,-n,0),this.getMax().set(n,n,0)}})()}),Object.defineProperties(re,{...te().getStaticProperties("Arc2D","Geometry2D",2,"geometry","3.0"),fieldDefinitions:{value:new($())([new(Y())(a().inputOutput,"metadata",new(h().SFNode)),new(Y())(a().initializeOnly,"startAngle",new(h().SFFloat)),new(Y())(a().initializeOnly,"endAngle",new(h().SFFloat)(1.570796)),new(Y())(a().initializeOnly,"radius",new(h().SFFloat)(1))]),enumerable:!0}});const ae=re,le=c().add("Arc2D",ae);function he(e){M().call(this,e),this.addType(a().ArcClose2D),this.setGeometryType(2),this._startAngle.setUnit("angle"),this._endAngle.setUnit("angle"),this._radius.setUnit("length")}Object.assign(Object.setPrototypeOf(he.prototype,M().prototype),{set_live__(){this.connectOptions(this.getBrowser().getArcClose2DOptions())},getSweepAngle(){const e=oe().interval(this._startAngle.getValue(),0,2*Math.PI),t=oe().interval(this._endAngle.getValue(),0,2*Math.PI);if(e===t)return 2*Math.PI;const i=Math.abs(t-e);return e>t?2*Math.PI-i:isNaN(i)?0:i},build:(()=>{const e=[],t=[],i=new(P())(.5,.5);return function(){const s=this.getBrowser().getArcClose2DOptions(),n="CHORD"===this._closureType.getValue(),o=s._dimension.getValue(),r=this._startAngle.getValue(),a=Math.abs(this._radius.getValue()),l=this.getSweepAngle(),h=Math.max(4,Math.floor(l*o/(2*Math.PI))),g=this.getTexCoords(),c=this.getNormals(),d=this.getVertices();this.getMultiTexCoords().push(g);const p=h-1;for(let s=0;s<h;++s){const n=r+l*(s/p);s>=e.length&&e.push(new(P())),s>=t.length&&t.push(new(P())),e[s].setPolar(.5,n).add(i),t[s].setPolar(a,n)}if(n){const i=e[0],s=t[0];for(let n=1;n<p;++n){const o=e[n],r=e[n+1],a=t[n],l=t[n+1];g.push(i.real,i.imag,0,1,o.real,o.imag,0,1,r.real,r.imag,0,1),c.push(0,0,1,0,0,1,0,0,1),d.push(s.real,s.imag,0,1,a.real,a.imag,0,1,l.real,l.imag,0,1)}}else for(let i=0;i<p;++i){const s=e[i],n=e[i+1],o=t[i],r=t[i+1];g.push(.5,.5,0,1,s.real,s.imag,0,1,n.real,n.imag,0,1),c.push(0,0,1,0,0,1,0,0,1),d.push(0,0,0,1,o.real,o.imag,0,1,r.real,r.imag,0,1)}this.getMin().set(-a,-a,0),this.getMax().set(a,a,0),this.setSolid(this._solid.getValue())}})()}),Object.defineProperties(he,{...te().getStaticProperties("ArcClose2D","Geometry2D",2,"geometry","3.0"),fieldDefinitions:{value:new($())([new(Y())(a().inputOutput,"metadata",new(h().SFNode)),new(Y())(a().initializeOnly,"closureType",new(h().SFString)("PIE")),new(Y())(a().initializeOnly,"startAngle",new(h().SFFloat)),new(Y())(a().initializeOnly,"endAngle",new(h().SFFloat)(1.570796)),new(Y())(a().initializeOnly,"radius",new(h().SFFloat)(1)),new(Y())(a().initializeOnly,"solid",new(h().SFBool))]),enumerable:!0}});const ge=he,ce=c().add("ArcClose2D",ge);function de(e){se().call(this,e),this.addType(a().Circle2D),this._radius.setUnit("length")}Object.assign(Object.setPrototypeOf(de.prototype,se().prototype),{set_live__(){this.connectOptions(this.getBrowser().getCircle2DOptions())},build(){const e=this.getBrowser().getCircle2DOptions().getGeometry(),t=this.getVertices(),i=this._radius.getValue();if(1===i)t.assign(e.getVertices());else{const s=e.getVertices();for(let e=0,n=s.length;e<n;e+=4)t.push(s[e]*i,s[e+1]*i,0,1)}this.getMin().set(-i,-i,0),this.getMax().set(i,i,0)}}),Object.defineProperties(de,{...te().getStaticProperties("Circle2D","Geometry2D",2,"geometry","3.0"),fieldDefinitions:{value:new($())([new(Y())(a().inputOutput,"metadata",new(h().SFNode)),new(Y())(a().initializeOnly,"radius",new(h().SFFloat)(1))]),enumerable:!0}});const pe=de,ue=c().add("Circle2D",pe),ye=e.X3DPointGeometryNode;var me=t.n(ye);function Oe(e){se().call(this,e),this.addType(a().Disk2D),this._innerRadius.setUnit("length"),this._outerRadius.setUnit("length")}Object.assign(Object.setPrototypeOf(Oe.prototype,M().prototype),se().prototype,{set_live__(){this.connectOptions(this.getBrowser().getDisk2DOptions())},build(){const e=this.getBrowser().getDisk2DOptions(),t=Math.min(Math.abs(this._innerRadius.getValue()),Math.abs(this._outerRadius.getValue())),i=Math.max(Math.abs(this._innerRadius.getValue()),Math.abs(this._outerRadius.getValue())),s=this.getVertices();if(t===i){if(0===i)return s.push(0,0,0,1),this.getMin().set(0),this.getMax().set(0),this.setGeometryType(0),this.setTransparent(!0),this.setSolid(!1),void this.setBase(me().prototype);const e=this.getBrowser().getCircle2DOptions().getGeometry();if(1===i)s.assign(e.getVertices());else{const t=e.getVertices();for(let e=0,n=t.length;e<n;e+=4)s.push(t[e]*i,t[e+1]*i,0,1)}return this.getMin().set(-i,-i,0),this.getMax().set(i,i,0),this.setGeometryType(1),this.setTransparent(!1),this.setSolid(!1),void this.setBase(se().prototype)}if(0===t){if(this.getMultiTexCoords().push(e.getDiskTexCoords()),this.getNormals().assign(e.getDiskNormals()),1===i)s.assign(e.getDiskVertices());else{const t=e.getDiskVertices().getValue();for(let e=0,n=t.length;e<n;e+=4)s.push(t[e]*i,t[e+1]*i,0,1)}return this.getMin().set(-i,-i,0),this.getMax().set(i,i,0),this.setGeometryType(2),this.setTransparent(!1),this.setSolid(this._solid.getValue()),void this.setBase(M().prototype)}const n=t/i,o=(1-n)/2,r=e.getDiskTexCoords().getValue(),a=e.getDiskVertices().getValue(),l=this.getTexCoords(),h=this.getNormals();this.getMultiTexCoords().push(l);for(let e=0,g=a.length;e<g;e+=12)l.push(r[e+4]*n+o,r[e+5]*n+o,0,1,r[e+4],r[e+5],0,1,r[e+8],r[e+9],0,1,r[e+4]*n+o,r[e+5]*n+o,0,1,r[e+8],r[e+9],0,1,r[e+8]*n+o,r[e+9]*n+o,0,1),h.push(0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1),s.push(a[e+4]*t,a[e+5]*t,0,1,a[e+4]*i,a[e+5]*i,0,1,a[e+8]*i,a[e+9]*i,0,1,a[e+4]*t,a[e+5]*t,0,1,a[e+8]*i,a[e+9]*i,0,1,a[e+8]*t,a[e+9]*t,0,1);this.getMin().set(-i,-i,0),this.getMax().set(i,i,0),this.setGeometryType(2),this.setTransparent(!1),this.setSolid(this._solid.getValue()),this.setBase(M().prototype)},updateRenderFunctions(){}}),Object.defineProperties(Oe,{...te().getStaticProperties("Disk2D","Geometry2D",2,"geometry","3.0"),fieldDefinitions:{value:new($())([new(Y())(a().inputOutput,"metadata",new(h().SFNode)),new(Y())(a().initializeOnly,"innerRadius",new(h().SFFloat)),new(Y())(a().initializeOnly,"outerRadius",new(h().SFFloat)(1)),new(Y())(a().initializeOnly,"solid",new(h().SFBool))]),enumerable:!0}});const De=Oe,fe=c().add("Disk2D",De);function we(e){se().call(this,e),this.addType(a().Polyline2D),this._lineSegments.setUnit("length")}Object.assign(Object.setPrototypeOf(we.prototype,se().prototype),{build(){const e=this._lineSegments.getValue(),t=this.getVertices();for(let i=0,s=2*(this._lineSegments.length-1);i<s;i+=2)t.push(e[i+0],e[i+1],0,1),t.push(e[i+2],e[i+3],0,1)}}),Object.defineProperties(we,{...te().getStaticProperties("Polyline2D","Geometry2D",1,"geometry","3.0"),fieldDefinitions:{value:new($())([new(Y())(a().inputOutput,"metadata",new(h().SFNode)),new(Y())(a().initializeOnly,"lineSegments",new(h().MFVec2f))]),enumerable:!0}});const be=we,_e=c().add("Polyline2D",be);function Pe(e){me().call(this,e),this.addType(a().Polypoint2D),this._point.setUnit("length")}Object.assign(Object.setPrototypeOf(Pe.prototype,me().prototype),{build(){const e=this._point.getValue(),t=this.getVertices();for(let i=0,s=2*this._point.length;i<s;i+=2)t.push(e[i],e[i+1],0,1)}}),Object.defineProperties(Pe,{...te().getStaticProperties("Polypoint2D","Geometry2D",1,"geometry","3.0"),fieldDefinitions:{value:new($())([new(Y())(a().inputOutput,"metadata",new(h().SFNode)),new(Y())(a().inputOutput,"point",new(h().MFVec2f))]),enumerable:!0}});const Se=Pe,Ve=c().add("Polypoint2D",Se),ve=e.Vector2;var Ce=t.n(ve);function Me(e){M().call(this,e),this.addType(a().Rectangle2D),this.setGeometryType(2),this._size.setUnit("length")}Object.assign(Object.setPrototypeOf(Me.prototype,M().prototype),{build:(()=>{const e=new(Ce())(2);return function(){const t=this.getBrowser().getRectangle2DOptions().getGeometry(),i=this._size.getValue(),s=this.getVertices();if(this.getMultiTexCoords().push(...t.getMultiTexCoords()),this.getTangents().assign(t.getTangents()),this.getNormals().assign(t.getNormals()),i.equals(e))s.assign(t.getVertices()),this.getMin().assign(t.getMin()),this.getMax().assign(t.getMax());else{const e=Math.abs(i.x/2),n=Math.abs(i.y/2),o=t.getVertices();for(let t=0;t<o.length;t+=4)s.push(e*o[t],n*o[t+1],0,1);this.getMin().set(-e,-n,0),this.getMax().set(e,n,0)}this.setSolid(this._solid.getValue())}})()}),Object.defineProperties(Me,{...te().getStaticProperties("Rectangle2D","Geometry2D",1,"geometry","3.0"),fieldDefinitions:{value:new($())([new(Y())(a().inputOutput,"metadata",new(h().SFNode)),new(Y())(a().initializeOnly,"size",new(h().SFVec2f)(2,2)),new(Y())(a().initializeOnly,"solid",new(h().SFBool))]),enumerable:!0}});const xe=Me,Te=c().add("Rectangle2D",xe);function Fe(e){M().call(this,e),this.addType(a().TriangleSet2D),this.setGeometryType(2),this._vertices.setUnit("length")}Object.assign(Object.setPrototypeOf(Fe.prototype,M().prototype),{build(){const e=this._vertices.getValue(),t=this.getNormals(),i=this.getVertices();for(let s=0,n=2*this._vertices.length;s<n;s+=2)t.push(0,0,1),i.push(e[s],e[s+1],0,1);this.setSolid(this._solid.getValue())},generateTexCoords(){const e=this.getTexCoords();if(0===e.length){const t=this.getTexCoordParams(),i=t.min,s=t.Ssize,n=this.getVertices();for(let t=0,o=n.length;t<o;t+=4)e.push((n[t]-i[0])/s,(n[t+1]-i[1])/s,0,1);e.shrinkToFit()}this.getMultiTexCoords().push(e)}}),Object.defineProperties(Fe,{...te().getStaticProperties("TriangleSet2D","Geometry2D",1,"geometry","3.0"),fieldDefinitions:{value:new($())([new(Y())(a().inputOutput,"metadata",new(h().SFNode)),new(Y())(a().inputOutput,"vertices",new(h().MFVec2f)),new(Y())(a().initializeOnly,"solid",new(h().SFBool))]),enumerable:!0}});const je=Fe,Ae=c().add("TriangleSet2D",je);s().add({name:"Geometry2D",concreteNodes:[le,ce,ue,fe,_e,Ve,Te,Ae],abstractNodes:[],browserContext:J});c().add("Geometry2DComponent",void 0)})();