-
Notifications
You must be signed in to change notification settings - Fork 10
/
canvas_lines.min.js
2 lines (2 loc) · 22 KB
/
canvas_lines.min.js
1
2
THREE.SpriteCanvasMaterial=function(e){THREE.Material.call(this),this.type="SpriteCanvasMaterial",this.color=new THREE.Color(16777215),this.program=function(e,t){},this.setValues(e)},THREE.SpriteCanvasMaterial.prototype=Object.create(THREE.Material.prototype),THREE.SpriteCanvasMaterial.prototype.constructor=THREE.SpriteCanvasMaterial,THREE.SpriteCanvasMaterial.prototype.clone=function(){var e=new THREE.SpriteCanvasMaterial;return e.copy(this),e.color.copy(this.color),e.program=this.program,e},THREE.CanvasRenderer=function(e){console.log("THREE.CanvasRenderer",THREE.REVISION),e=e||{};var s,l,c,p,E,d,h,f,u,m,v,x,R,y,T,w,H,g,S,M=this,b=new THREE.Projector,r=void 0!==e.canvas?e.canvas:document.createElement("canvas"),C=r.width,z=r.height,V=Math.floor(C/2),j=Math.floor(z/2),L=0,O=0,B=C,W=z,n=1,P=r.getContext("2d",{alpha:!0===e.alpha}),i=new THREE.Color(0),o=!0===e.alpha?0:1,a=1,k=0,N=null,F=null,A=null,I=null,D=null,t=[],G=(new THREE.RenderableVertex,new THREE.RenderableVertex,new THREE.Color),U=(new THREE.Color,new THREE.Color,new THREE.Color,new THREE.Color,new THREE.Color),q=new THREE.Color,X=new THREE.Color,J={},Y=new THREE.Box2,$=new THREE.Box2,K=new THREE.Box2,Q=new THREE.Color,Z=new THREE.Color,_=new THREE.Color,ee=new THREE.Vector3,te=new THREE.Vector3,ie=new THREE.Vector3,re=new THREE.Matrix3;function ne(e,t,i){de(i.opacity),he(i.blending);var r=t.scale.x*V,n=t.scale.y*j,o=.5*Math.sqrt(r*r+n*n);if(K.min.set(e.x-o,e.y-o),K.max.set(e.x+o,e.y+o),i instanceof THREE.SpriteMaterial){var a=i.map;if(null!==a){var s=J[a.id];if(void 0!==s&&s.version===a.version||(s=ce(a),J[a.id]=s),void 0!==s.canvas){xe(s.canvas);var l=a.image,c=l.width*a.offset.x,p=l.height*a.offset.y,E=l.width*a.repeat.x,d=l.height*a.repeat.y,h=r/E,f=n/d;P.save(),P.translate(e.x,e.y),0!==i.rotation&&P.rotate(i.rotation),P.translate(-r/2,-n/2),P.scale(h,f),P.translate(-c,-p),P.fillRect(c,p,E,d),P.restore()}}else xe(i.color.getStyle()),P.save(),P.translate(e.x,e.y),0!==i.rotation&&P.rotate(i.rotation),P.scale(r,-n),P.fillRect(-.5,-.5,1,1),P.restore()}else i instanceof THREE.SpriteCanvasMaterial&&(ve(i.color.getStyle()),xe(i.color.getStyle()),P.save(),P.translate(e.x,e.y),0!==i.rotation&&P.rotate(i.rotation),P.scale(r,n),i.program(P),P.restore())}function oe(e,t,i,r){if(de(r.opacity),he(r.blending),P.beginPath(),P.moveTo(e.positionScreen.x,e.positionScreen.y),P.lineTo(t.positionScreen.x,t.positionScreen.y),r instanceof THREE.LineBasicMaterial){if(fe(r.linewidth),ue(r.linecap),me(r.linejoin),r.vertexColors!==THREE.VertexColors)ve(r.color.getStyle());else{var n=i.vertexColors[0].getStyle(),o=i.vertexColors[1].getStyle();if(n===o)ve(n);else{try{var a=P.createLinearGradient(e.positionScreen.x,e.positionScreen.y,t.positionScreen.x,t.positionScreen.y);a.addColorStop(0,n),a.addColorStop(1,o)}catch(e){a=n}ve(a)}}P.stroke(),K.expandByScalar(2*r.linewidth)}else r instanceof THREE.LineDashedMaterial&&(fe(r.linewidth),ue(r.linecap),me(r.linejoin),ve(r.color.getStyle()),Re([r.dashSize,r.gapSize]),P.stroke(),K.expandByScalar(2*r.linewidth),Re([]))}function ae(e,t,i,r,n,o,a,s){if(M.info.render.vertices+=3,M.info.render.faces++,de(s.opacity),he(s.blending),h=e.positionScreen.x,f=e.positionScreen.y,u=t.positionScreen.x,m=t.positionScreen.y,v=i.positionScreen.x,x=i.positionScreen.y,function(e,t,i,r,n,o){P.beginPath(),P.moveTo(e,t),P.lineTo(i,r),P.lineTo(n,o),P.closePath()}(h,f,u,m,v,x),(s instanceof THREE.MeshLambertMaterial||s instanceof THREE.MeshPhongMaterial)&&null===s.map)U.copy(s.color),q.copy(s.emissive),s.vertexColors===THREE.FaceColors&&U.multiply(a.color),G.copy(Q),te.copy(e.positionWorld).add(t.positionWorld).add(i.positionWorld).divideScalar(3),function(e,t,i){for(var r=0,n=c.length;r<n;r++){var o=c[r];if(X.copy(o.color),o instanceof THREE.DirectionalLight){var a=ee.setFromMatrixPosition(o.matrixWorld).normalize();if((s=t.dot(a))<=0)continue;s*=o.intensity,i.add(X.multiplyScalar(s))}else if(o instanceof THREE.PointLight){var s;a=ee.setFromMatrixPosition(o.matrixWorld);if((s=t.dot(ee.subVectors(a,e).normalize()))<=0)continue;if(0==(s*=0==o.distance?1:1-Math.min(e.distanceTo(a)/o.distance,1)))continue;s*=o.intensity,i.add(X.multiplyScalar(s))}}}(te,a.normalModel,G),G.multiply(U).add(q),!0===s.wireframe?se(G,s.wireframeLinewidth,s.wireframeLinecap,s.wireframeLinejoin):le(G);else if(s instanceof THREE.MeshBasicMaterial||s instanceof THREE.MeshLambertMaterial||s instanceof THREE.MeshPhongMaterial){if(null!==s.map)s.map.mapping===THREE.UVMapping&&(R=a.uvs,pe(h,f,u,m,v,x,R[r].x,R[r].y,R[n].x,R[n].y,R[o].x,R[o].y,s.map));else null!==s.envMap?s.envMap.mapping===THREE.SphericalReflectionMapping&&(ie.copy(a.vertexNormalsModel[r]).applyMatrix3(re),y=.5*ie.x+.5,T=.5*ie.y+.5,ie.copy(a.vertexNormalsModel[n]).applyMatrix3(re),w=.5*ie.x+.5,H=.5*ie.y+.5,ie.copy(a.vertexNormalsModel[o]).applyMatrix3(re),g=.5*ie.x+.5,S=.5*ie.y+.5,pe(h,f,u,m,v,x,y,T,w,H,g,S,s.envMap)):(G.copy(s.color),s.vertexColors===THREE.FaceColors&&G.multiply(a.color),!0===s.wireframe?se(G,s.wireframeLinewidth,s.wireframeLinecap,s.wireframeLinejoin):le(G))}else s instanceof THREE.MeshNormalMaterial?(ie.copy(a.normalModel).applyMatrix3(re),G.setRGB(ie.x,ie.y,ie.z).multiplyScalar(.5).addScalar(.5)):G.setRGB(1,1,1),!0===s.wireframe?se(G,s.wireframeLinewidth,s.wireframeLinecap,s.wireframeLinejoin):le(G)}function se(e,t,i,r){fe(t),ue(i),me(r),ve(e.getStyle()),P.stroke(),K.expandByScalar(2*t)}function le(e){xe(e.getStyle()),P.fill()}function ce(e){if(0===e.version||e instanceof THREE.CompressedTexture||e instanceof THREE.DataTexture)return{canvas:void 0,version:e.version};var t=e.image;if(!1===t.complete)return{canvas:void 0,version:0};var i=e.wrapS===THREE.RepeatWrapping||e.wrapS===THREE.MirroredRepeatWrapping,r=e.wrapT===THREE.RepeatWrapping||e.wrapT===THREE.MirroredRepeatWrapping,n=e.wrapS===THREE.MirroredRepeatWrapping,o=e.wrapT===THREE.MirroredRepeatWrapping,a=document.createElement("canvas");a.width=t.width*(n?2:1),a.height=t.height*(o?2:1);var s=a.getContext("2d");s.setTransform(1,0,0,-1,0,t.height),s.drawImage(t,0,0),!0==n&&(s.setTransform(-1,0,0,-1,t.width,t.height),s.drawImage(t,-t.width,0)),!0==o&&(s.setTransform(1,0,0,1,0,0),s.drawImage(t,0,t.height)),!0==n&&!0==o&&(s.setTransform(-1,0,0,1,t.width,0),s.drawImage(t,-t.width,t.height));var l="no-repeat";!0==i&&!0==r?l="repeat":!0==i?l="repeat-x":!0==r&&(l="repeat-y");var c=P.createPattern(a,l);return e.onUpdate&&e.onUpdate(e),{canvas:c,version:e.version}}function pe(e,t,i,r,n,o,a,s,l,c,p,E,d){var h=J[d.id];if(void 0!==h&&h.version===d.version||(h=ce(d),J[d.id]=h),void 0===h.canvas)return xe("rgba( 0, 0, 0, 1)"),void P.fill();xe(h.canvas);var f,u,m,v,x,R,y,T,w=d.offset.x/d.repeat.x,H=d.offset.y/d.repeat.y,g=d.image.width*d.repeat.x,S=d.image.height*d.repeat.y;l=(l+w)*g,c=(c+H)*S,p=(p+w)*g,E=(E+H)*S,i-=e,r-=t,n-=e,o-=t,0!=(y=(l-=a=(a+w)*g)*(E-=s=(s+H)*S)-(p-=a)*(c-=s))&&(x=e-(f=(E*i-c*n)*(T=1/y))*a-(m=(l*n-p*i)*T)*s,R=t-(u=(E*r-c*o)*T)*a-(v=(l*o-p*r)*T)*s,P.save(),P.transform(f,u,m,v,x,R),P.fill(),P.restore())}function Ee(e,t,i){var r,n=t.x-e.x,o=t.y-e.y,a=n*n+o*o;0!=a&&(n*=r=i/Math.sqrt(a),o*=r,t.x+=n,t.y+=o,e.x-=n,e.y-=o)}function de(e){a!==e&&(P.globalAlpha=e,a=e)}function he(e){k!==e&&(e===THREE.NormalBlending?P.globalCompositeOperation="source-over":e===THREE.AdditiveBlending?P.globalCompositeOperation="lighter":e===THREE.SubtractiveBlending?P.globalCompositeOperation="darker":e===THREE.MultiplyBlending&&(P.globalCompositeOperation="multiply"),k=e)}function fe(e){A!==e&&(P.lineWidth=e,A=e)}function ue(e){I!==e&&(P.lineCap=e,I=e)}function me(e){D!==e&&(P.lineJoin=e,D=e)}function ve(e){N!==e&&(P.strokeStyle=e,N=e)}function xe(e){F!==e&&(P.fillStyle=e,F=e)}function Re(e){t.length!==e.length&&(P.setLineDash(e),t=e)}void 0===P.setLineDash&&(P.setLineDash=function(){}),this.domElement=r,this.autoClear=!0,this.sortObjects=!0,this.sortElements=!0,this.info={render:{vertices:0,faces:0}},this.supportsVertexTextures=function(){},this.setFaceCulling=function(){},this.getContext=function(){return P},this.getContextAttributes=function(){return P.getContextAttributes()},this.getPixelRatio=function(){return n},this.setPixelRatio=function(e){void 0!==e&&(n=e)},this.setSize=function(e,t,i){C=e*n,z=t*n,r.width=C,r.height=z,V=Math.floor(C/2),j=Math.floor(z/2),!1!==i&&(r.style.width=e+"px",r.style.height=t+"px"),Y.min.set(-V,-j),Y.max.set(V,j),$.min.set(-V,-j),$.max.set(V,j),a=1,k=0,D=I=A=F=N=null,this.setViewport(0,0,e,t)},this.setViewport=function(e,t,i,r){L=e*n,O=t*n,B=i*n,W=r*n},this.setScissor=function(){},this.setScissorTest=function(){},this.setClearColor=function(e,t){i.set(e),o=void 0!==t?t:1,$.min.set(-V,-j),$.max.set(V,j)},this.setClearColorHex=function(e,t){console.warn("THREE.CanvasRenderer: .setClearColorHex() is being removed. Use .setClearColor() instead."),this.setClearColor(e,t)},this.getClearColor=function(){return i},this.getClearAlpha=function(){return o},this.getMaxAnisotropy=function(){return 0},this.clear=function(){!1===$.isEmpty()&&($.intersect(Y),$.expandByScalar(2),$.min.x=$.min.x+V,$.min.y=-$.min.y+j,$.max.x=$.max.x+V,$.max.y=-$.max.y+j,o<1&&P.clearRect(0|$.min.x,0|$.max.y,$.max.x-$.min.x|0,$.min.y-$.max.y|0),0<o&&(he(THREE.NormalBlending),de(1),xe("rgba("+Math.floor(255*i.r)+","+Math.floor(255*i.g)+","+Math.floor(255*i.b)+","+o+")"),P.fillRect(0|$.min.x,0|$.max.y,$.max.x-$.min.x|0,$.min.y-$.max.y|0)),$.makeEmpty())},this.clearColor=function(){},this.clearDepth=function(){},this.clearStencil=function(){},this.render=function(e,t){if(t instanceof THREE.Camera!=!1){var i=e.background;i&&i.isColor?(xe("rgb("+Math.floor(255*i.r)+","+Math.floor(255*i.g)+","+Math.floor(255*i.b)+")"),P.fillRect(0,0,C,z)):!0===this.autoClear&&this.clear(),M.info.render.vertices=0,M.info.render.faces=0,P.setTransform(B/C,0,0,-W/z,L,z-O),P.translate(V,j),s=b.projectScene(e,t,this.sortObjects,this.sortElements),l=s.elements,c=s.lights,t,re.getNormalMatrix(t.matrixWorldInverse),function(){Q.setRGB(0,0,0),Z.setRGB(0,0,0),_.setRGB(0,0,0);for(var e=0,t=c.length;e<t;e++){var i=c[e],r=i.color;i instanceof THREE.AmbientLight?Q.add(r):i instanceof THREE.DirectionalLight?Z.add(r):i instanceof THREE.PointLight&&_.add(r)}}();for(var r=0,n=l.length;r<n;r++){var o=l[r],a=o.material;if(void 0!==a&&0!==a.opacity){if(K.makeEmpty(),o instanceof THREE.RenderableSprite)(p=o).x*=V,p.y*=j,ne(p,o,a);else if(o instanceof THREE.RenderableLine)p=o.v1,E=o.v2,p.positionScreen.x*=V,p.positionScreen.y*=j,E.positionScreen.x*=V,E.positionScreen.y*=j,K.setFromPoints([p.positionScreen,E.positionScreen]),!0===Y.intersectsBox(K)&&oe(p,E,o,a);else if(o instanceof THREE.RenderableFace){if(p=o.v1,E=o.v2,d=o.v3,p.positionScreen.z<-1||1<p.positionScreen.z)continue;if(E.positionScreen.z<-1||1<E.positionScreen.z)continue;if(d.positionScreen.z<-1||1<d.positionScreen.z)continue;p.positionScreen.x*=V,p.positionScreen.y*=j,E.positionScreen.x*=V,E.positionScreen.y*=j,d.positionScreen.x*=V,d.positionScreen.y*=j,0<a.overdraw&&(Ee(p.positionScreen,E.positionScreen,a.overdraw),Ee(E.positionScreen,d.positionScreen,a.overdraw),Ee(d.positionScreen,p.positionScreen,a.overdraw)),K.setFromPoints([p.positionScreen,E.positionScreen,d.positionScreen]),!0===Y.intersectsBox(K)&&ae(p,E,d,0,1,2,o,a)}$.union(K)}}P.setTransform(1,0,0,1,0,0)}else console.error("THREE.CanvasRenderer.render: camera is not an instance of THREE.Camera.")}},THREE.RenderableObject=function(){this.id=0,this.object=null,this.z=0,this.renderOrder=0},THREE.RenderableFace=function(){this.id=0,this.v1=new THREE.RenderableVertex,this.v2=new THREE.RenderableVertex,this.v3=new THREE.RenderableVertex,this.normalModel=new THREE.Vector3,this.vertexNormalsModel=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3],this.vertexNormalsLength=0,this.color=new THREE.Color,this.material=null,this.uvs=[new THREE.Vector2,new THREE.Vector2,new THREE.Vector2],this.z=0,this.renderOrder=0},THREE.RenderableVertex=function(){this.position=new THREE.Vector3,this.positionWorld=new THREE.Vector3,this.positionScreen=new THREE.Vector4,this.visible=!0},THREE.RenderableVertex.prototype.copy=function(e){this.positionWorld.copy(e.positionWorld),this.positionScreen.copy(e.positionScreen)},THREE.RenderableLine=function(){this.id=0,this.v1=new THREE.RenderableVertex,this.v2=new THREE.RenderableVertex,this.vertexColors=[new THREE.Color,new THREE.Color],this.material=null,this.z=0,this.renderOrder=0},THREE.RenderableSprite=function(){this.id=0,this.object=null,this.x=0,this.y=0,this.z=0,this.rotation=0,this.scale=new THREE.Vector2,this.material=null,this.renderOrder=0},THREE.Projector=function(){var K,Q,n,Z,_,ee,te,ie,re,ne,oe,ae=[],se=0,le=[],t=0,i=[],r=0,o=[],a=0,s=[],l=0,ce={objects:[],lights:[],elements:[]},pe=new THREE.Vector3,Ee=new THREE.Vector4,u=new THREE.Box3(new THREE.Vector3(-1,-1,-1),new THREE.Vector3(1,1,1)),m=new THREE.Box3,v=new Array(3),de=(new Array(4),new THREE.Matrix4),he=new THREE.Matrix4,fe=new THREE.Matrix4,ue=new THREE.Matrix3,me=new THREE.Frustum,ve=new THREE.Vector4,xe=new THREE.Vector4;this.projectVector=function(e,t){console.warn("THREE.Projector: .projectVector() is now vector.project()."),e.project(t)},this.unprojectVector=function(e,t){console.warn("THREE.Projector: .unprojectVector() is now vector.unproject()."),e.unproject(t)},this.pickingRay=function(e,t){console.error("THREE.Projector: .pickingRay() is now raycaster.setFromCamera().")};var Re=new function(){var l=[],c=[],p=null,E=null,d=new THREE.Matrix3;function r(e){var t=e.position,i=e.positionWorld,r=e.positionScreen;i.copy(t).applyMatrix4(oe),r.copy(i).applyMatrix4(he);var n=1/r.w;r.x*=n,r.y*=n,r.z*=n,e.visible=-1<=r.x&&r.x<=1&&-1<=r.y&&r.y<=1&&-1<=r.z&&r.z<=1}function h(e,t,i){return!0===e.visible||!0===t.visible||!0===i.visible||(v[0]=e.positionScreen,v[1]=t.positionScreen,v[2]=i.positionScreen,u.intersectsBox(m.setFromPoints(v)))}function f(e,t,i){return(i.positionScreen.x-e.positionScreen.x)*(t.positionScreen.y-e.positionScreen.y)-(i.positionScreen.y-e.positionScreen.y)*(t.positionScreen.x-e.positionScreen.x)<0}return{setObject:function(e){E=(p=e).material,d.getNormalMatrix(p.matrixWorld),l.length=0,c.length=0},projectVertex:r,checkTriangleVisibility:h,checkBackfaceCulling:f,pushVertex:function(e,t,i){(n=ye()).position.set(e,t,i),r(n)},pushNormal:function(e,t,i){l.push(e,t,i)},pushUv:function(e,t){c.push(e,t)},pushLine:function(e,t){var i=le[e],r=le[t];(te=we()).id=p.id,te.v1.copy(i),te.v2.copy(r),te.z=(i.positionScreen.z+r.positionScreen.z)/2,te.renderOrder=p.renderOrder,te.material=p.material,ce.elements.push(te)},pushTriangle:function(e,t,i){var r=le[e],n=le[t],o=le[i];if(!1!==h(r,n,o)&&(E.side===THREE.DoubleSide||!0===f(r,n,o))){(_=Te()).id=p.id,_.v1.copy(r),_.v2.copy(n),_.v3.copy(o),_.z=(r.positionScreen.z+n.positionScreen.z+o.positionScreen.z)/3,_.renderOrder=p.renderOrder,_.normalModel.fromArray(l,3*e),_.normalModel.applyMatrix3(d).normalize();for(var a=0;a<3;a++){var s=_.vertexNormalsModel[a];s.fromArray(l,3*arguments[a]),s.applyMatrix3(d).normalize(),_.uvs[a].fromArray(c,2*arguments[a])}_.vertexNormalsLength=3,_.material=p.material,ce.elements.push(_)}}}};function ye(){if(Z!==t)return le[Z++];var e=new THREE.RenderableVertex;return le.push(e),t++,Z++,e}function Te(){if(ee!==r)return i[ee++];var e=new THREE.RenderableFace;return i.push(e),r++,ee++,e}function we(){if(ie!==a)return o[ie++];var e=new THREE.RenderableLine;return o.push(e),a++,ie++,e}function He(){if(ne!==l)return s[ne++];var e=new THREE.RenderableSprite;return s.push(e),l++,ne++,e}function ge(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id!==t.id?e.id-t.id:0}function Se(e,t){var i=0,r=1,n=e.z+e.w,o=t.z+t.w,a=-e.z+e.w,s=-t.z+t.w;return 0<=n&&0<=o&&0<=a&&0<=s||!(n<0&&o<0||a<0&&s<0)&&(n<0?i=Math.max(i,n/(n-o)):o<0&&(r=Math.min(r,n/(n-o))),a<0?i=Math.max(i,a/(a-s)):s<0&&(r=Math.min(r,a/(a-s))),!(r<i)&&(e.lerp(t,i),t.lerp(e,1-r),!0))}this.projectScene=function(e,t,i,r){function n(e){(K=function(){if(Q!==se)return ae[Q++];var e=new THREE.RenderableObject;return ae.push(e),se++,Q++,e}()).id=e.id,K.object=e,pe.setFromMatrixPosition(e.matrixWorld),pe.applyMatrix4(he),K.z=pe.z,K.renderOrder=e.renderOrder,ce.objects.push(K)}ne=ie=ee=0,!(ce.elements.length=0)===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),de.copy(t.matrixWorldInverse.getInverse(t.matrixWorld)),he.multiplyMatrices(t.projectionMatrix,de),me.setFromMatrix(he),Q=0,ce.objects.length=0,ce.lights.length=0,e.traverseVisible(function(e){if(e instanceof THREE.Light)ce.lights.push(e);else if(e instanceof THREE.Mesh||e instanceof THREE.Line){if(!1===e.material.visible)return;if(!0===e.frustumCulled&&!1===me.intersectsObject(e))return;n(e)}else if(e instanceof THREE.Sprite){if(!1===e.material.visible)return;if(!0===e.frustumCulled&&!1===me.intersectsSprite(e))return;n(e)}}),!0===i&&ce.objects.sort(ge);for(var o=0,a=ce.objects.length;o<a;o++){var s=ce.objects[o].object,l=s.geometry;if(Re.setObject(s),oe=s.matrixWorld,Z=0,s instanceof THREE.Mesh){if(l instanceof THREE.BufferGeometry){var c=l.attributes,p=l.groups;if(void 0===c.position)continue;for(var E=0,d=(J=c.position.array).length;E<d;E+=3)Re.pushVertex(J[E],J[E+1],J[E+2]);if(void 0!==c.normal){var h=c.normal.array;for(E=0,d=h.length;E<d;E+=3)Re.pushNormal(h[E],h[E+1],h[E+2])}if(void 0!==c.uv){var f=c.uv.array;for(E=0,d=f.length;E<d;E+=2)Re.pushUv(f[E],f[E+1])}if(null!==l.index){var u=l.index.array;if(0<p.length)for(var m=0;m<p.length;m++){var v=p[m];for(E=v.start,d=v.start+v.count;E<d;E+=3)Re.pushTriangle(u[E],u[E+1],u[E+2])}else for(E=0,d=u.length;E<d;E+=3)Re.pushTriangle(u[E],u[E+1],u[E+2])}else for(E=0,d=J.length/3;E<d;E+=3)Re.pushTriangle(E,E+1,E+2)}else if(l instanceof THREE.Geometry){var x=l.vertices,R=l.faces,y=l.faceVertexUvs[0];ue.getNormalMatrix(oe);for(var T=s.material,w=T instanceof THREE.MultiMaterial,H=!0==w?s.material:null,g=0,S=x.length;g<S;g++){var M=x[g];if(pe.copy(M),!0===T.morphTargets)for(var b=l.morphTargets,C=s.morphTargetInfluences,z=0,V=b.length;z<V;z++){var j=C[z];if(0!==j){var L=b[z].vertices[g];pe.x+=(L.x-M.x)*j,pe.y+=(L.y-M.y)*j,pe.z+=(L.z-M.z)*j}}Re.pushVertex(pe.x,pe.y,pe.z)}for(var O=0,B=R.length;O<B;O++){var W=R[O];if(void 0!==(T=!0==w?H.materials[W.materialIndex]:s.material)){var P=T.side,k=le[W.a],N=le[W.b],F=le[W.c];if(!1!==Re.checkTriangleVisibility(k,N,F)){var A=Re.checkBackfaceCulling(k,N,F);if(P!==THREE.DoubleSide){if(P===THREE.FrontSide&&!1===A)continue;if(P===THREE.BackSide&&!0===A)continue}(_=Te()).id=s.id,_.v1.copy(k),_.v2.copy(N),_.v3.copy(F),_.normalModel.copy(W.normal),!1!==A||P!==THREE.BackSide&&P!==THREE.DoubleSide||_.normalModel.negate(),_.normalModel.applyMatrix3(ue).normalize();for(var I=W.vertexNormals,D=0,G=Math.min(I.length,3);D<G;D++){var U=_.vertexNormalsModel[D];U.copy(I[D]),!1!==A||P!==THREE.BackSide&&P!==THREE.DoubleSide||U.negate(),U.applyMatrix3(ue).normalize()}_.vertexNormalsLength=I.length;var q=y[O];if(void 0!==q)for(var X=0;X<3;X++)_.uvs[X].copy(q[X]);_.color=W.color,_.material=T,_.z=(k.positionScreen.z+N.positionScreen.z+F.positionScreen.z)/3,_.renderOrder=s.renderOrder,ce.elements.push(_)}}}}}else if(s instanceof THREE.Line){if(l instanceof THREE.BufferGeometry){if(void 0!==(c=l.attributes).position){var J;for(E=0,d=(J=c.position.array).length;E<d;E+=3)Re.pushVertex(J[E],J[E+1],J[E+2]);if(null!==l.index)for(E=0,d=(u=l.index.array).length;E<d;E+=2)Re.pushLine(u[E],u[E+1]);else{var Y=s instanceof THREE.LineSegments?2:1;for(E=0,d=J.length/3-1;E<d;E+=Y)Re.pushLine(E,E+1)}}}else if(l instanceof THREE.Geometry){if(fe.multiplyMatrices(he,oe),0===(x=s.geometry.vertices).length)continue;(k=ye()).positionScreen.copy(x[0]).applyMatrix4(fe);for(Y=s instanceof THREE.LineSegments?2:1,g=1,S=x.length;g<S;g++)(k=ye()).positionScreen.copy(x[g]).applyMatrix4(fe),0<(g+1)%Y||(N=le[Z-2],ve.copy(k.positionScreen),xe.copy(N.positionScreen),!0===Se(ve,xe)&&(ve.multiplyScalar(1/ve.w),xe.multiplyScalar(1/xe.w),(te=we()).id=s.id,te.v1.positionScreen.copy(ve),te.v2.positionScreen.copy(xe),te.z=Math.max(ve.z,xe.z),te.renderOrder=s.renderOrder,te.material=s.material,s.material.vertexColors===THREE.VertexColors&&(te.vertexColors[0].copy(s.geometry.colors[g]),te.vertexColors[1].copy(s.geometry.colors[g-1])),ce.elements.push(te)))}}else if(s instanceof THREE.Sprite){Ee.set(oe.elements[12],oe.elements[13],oe.elements[14],1),Ee.applyMatrix4(he);var $=1/Ee.w;Ee.z*=$,-1<=Ee.z&&Ee.z<=1&&((re=He()).id=s.id,re.x=Ee.x*$,re.y=Ee.y*$,re.z=Ee.z,re.renderOrder=s.renderOrder,re.object=s,re.rotation=s.rotation,re.scale.x=s.scale.x*Math.abs(re.x-(Ee.x+t.projectionMatrix.elements[0])/(Ee.w+t.projectionMatrix.elements[12])),re.scale.y=s.scale.y*Math.abs(re.y-(Ee.y+t.projectionMatrix.elements[5])/(Ee.w+t.projectionMatrix.elements[13])),re.material=s.material,ce.elements.push(re))}}return!0===r&&ce.elements.sort(ge),ce}};
(function(){var s,l,c,t=0,i=0,r=window.innerWidth/2,n=window.innerHeight/2;function p(){r=window.innerWidth/2,n=window.innerHeight/2,s.aspect=window.innerWidth/window.innerHeight,s.updateProjectionMatrix(),c.setSize(window.innerWidth,window.innerHeight)}function E(e){t=e.clientX-r,i=e.clientY-n}function d(e){1<e.touches.length&&(t=e.touches[0].pageX-r)}function h(e){1==e.touches.length&&(t=e.touches[0].pageX-r)}function o(){s.position.x+=.05*(t-s.position.x),s.position.y+=.05*(200-i-s.position.y),s.lookAt(l.position),c.render(l,s)}!function(){var e,t;(e=document.createElement("div")).style.position="fixed",e.style.top="0px",e.style.left="0px",e.style.zIndex="-1",e.style.opacity="0.5",document.body.appendChild(e),(s=new THREE.PerspectiveCamera(75,window.innerWidth/window.innerHeight,1,1e4)).position.z=100,l=new THREE.Scene,(c=new THREE.CanvasRenderer({alpha:!0})).setPixelRatio(window.devicePixelRatio),c.setSize(window.innerWidth,window.innerHeight),e.appendChild(c.domElement);for(var i=2*Math.PI,r=new THREE.SpriteCanvasMaterial({color:10263708,program:function(e){e.beginPath(),e.arc(0,0,.5,0,i,!0),e.fill()}}),n=new THREE.Geometry,o=0;o<100;o++)(t=new THREE.Sprite(r)).position.x=2*Math.random()-1,t.position.y=2*Math.random()-1,t.position.z=2*Math.random()-1,t.position.normalize(),t.position.multiplyScalar(10*Math.random()+450),t.scale.x=t.scale.y=10,l.add(t),n.vertices.push(t.position);var a=new THREE.Line(n,new THREE.LineBasicMaterial({color:10263708,opacity:.5}));l.add(a),document.addEventListener("mousemove",E,!1),document.addEventListener("touchstart",d,!1),document.addEventListener("touchmove",h,!1),window.addEventListener("resize",p,!1)}(),function e(){requestAnimationFrame(e);o()}()})();