提交 41aa5e35 编写于 作者: M Mr.doob

Updated HemisphereLightHelper using new MeshFaceMaterial.

上级 6f8eec68
......@@ -32217,9 +32217,6 @@ THREE.HemisphereLightHelper = function ( light, sphereSize, arrowLength, domeSiz
var bulbSkyMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false } );
var bulbGroundMaterial = new THREE.MeshBasicMaterial( { color: hexColorGround, fog: false } );
bulbGeometry.materials[ 0 ] = bulbSkyMaterial;
bulbGroundGeometry.materials[ 0 ] = bulbGroundMaterial;
for ( var i = 0, il = bulbGeometry.faces.length; i < il; i ++ ) {
bulbGeometry.faces[ i ].materialIndex = 0;
......@@ -32228,13 +32225,13 @@ THREE.HemisphereLightHelper = function ( light, sphereSize, arrowLength, domeSiz
for ( var i = 0, il = bulbGroundGeometry.faces.length; i < il; i ++ ) {
bulbGroundGeometry.faces[ i ].materialIndex = 0;
bulbGroundGeometry.faces[ i ].materialIndex = 1;
}
THREE.GeometryUtils.merge( bulbGeometry, bulbGroundGeometry );
this.lightSphere = new THREE.Mesh( bulbGeometry, new THREE.MeshFaceMaterial() );
this.lightSphere = new THREE.Mesh( bulbGeometry, new THREE.MeshFaceMaterial( [ bulbSkyMaterial, bulbGroundMaterial ] ) );
// arrows for sky and ground light directions
......@@ -32288,8 +32285,8 @@ THREE.HemisphereLightHelper.prototype.update = function () {
this.groundColor.g *= intensity;
this.groundColor.b *= intensity;
this.lightSphere.geometry.materials[ 0 ].color.copy( this.color );
this.lightSphere.geometry.materials[ 1 ].color.copy( this.groundColor );
this.lightSphere.material.materials[ 0 ].color.copy( this.color );
this.lightSphere.material.materials[ 1 ].color.copy( this.groundColor );
this.lightArrow.setColor( this.color.getHex() );
this.lightArrowGround.setColor( this.groundColor.getHex() );
......
......@@ -278,8 +278,8 @@ j.vertexColors===THREE.FaceColors&&(R.r*=i.color.r,R.g*=i.color.g,R.b*=i.color.b
(R.r=gc(i.normalWorld.x),R.g=gc(i.normalWorld.y),R.b=gc(i.normalWorld.z),!0===j.wireframe?t(R,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):w(R))}function q(a,b,c,d,e,f){s.beginPath();s.moveTo(a,b);s.lineTo(c,d);s.lineTo(e,f);s.closePath()}function r(a,b,c,d,e,f,g,h){s.beginPath();s.moveTo(a,b);s.lineTo(c,d);s.lineTo(e,f);s.lineTo(g,h);s.closePath()}function t(a,b,c,e){z!==b&&(z=s.lineWidth=b);v!==c&&(v=s.lineCap=c);u!==e&&(u=s.lineJoin=e);d(a.getContextStyle());s.stroke();La.inflate(2*
b)}function w(a){e(a.getContextStyle());s.fill()}function A(a,b,c,d,f,g,h,k,i,j,l,n,oa){if(!(oa instanceof THREE.DataTexture||void 0===oa.image||0==oa.image.width)){if(!0===oa.needsUpdate){var m=oa.wrapS==THREE.RepeatWrapping,o=oa.wrapT==THREE.RepeatWrapping;Aa[oa.id]=s.createPattern(oa.image,!0===m&&!0===o?"repeat":!0===m&&!1===o?"repeat-x":!1===m&&!0===o?"repeat-y":"no-repeat");oa.needsUpdate=!1}void 0===Aa[oa.id]?e("rgba(0,0,0,1)"):e(Aa[oa.id]);var m=oa.offset.x/oa.repeat.x,o=oa.offset.y/oa.repeat.y,
Cb=oa.image.width*oa.repeat.x,p=oa.image.height*oa.repeat.y,h=(h+m)*Cb,k=(1-k+o)*p,c=c-a,d=d-b,f=f-a,g=g-b,i=(i+m)*Cb-h,j=(1-j+o)*p-k,l=(l+m)*Cb-h,n=(1-n+o)*p-k,m=i*n-l*j;0===m?(void 0===ua[oa.id]&&(b=document.createElement("canvas"),b.width=oa.image.width,b.height=oa.image.height,b=b.getContext("2d"),b.drawImage(oa.image,0,0),ua[oa.id]=b.getImageData(0,0,oa.image.width,oa.image.height).data),b=ua[oa.id],h=4*(Math.floor(h)+Math.floor(k)*oa.image.width),R.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255),w(R)):
(m=1/m,oa=(n*c-j*f)*m,j=(n*d-j*g)*m,c=(i*f-l*c)*m,d=(i*g-l*d)*m,a=a-oa*h-c*k,h=b-j*h-d*k,s.save(),s.transform(oa,j,c,d,a,h),s.fill(),s.restore())}}function oa(a,b,c,d,e,f,g,h,k,i,j,oa,l){var n,m;n=l.width-1;m=l.height-1;g*=n;h*=m;c-=a;d-=b;e-=a;f-=b;k=k*n-g;i=i*m-h;j=j*n-g;oa=oa*m-h;m=1/(k*oa-j*i);n=(oa*c-i*e)*m;i=(oa*d-i*f)*m;c=(k*e-j*c)*m;d=(k*f-j*d)*m;a=a-n*g-c*h;b=b-i*g-d*h;s.save();s.transform(n,i,c,d,a,b);s.clip();s.drawImage(l,0,0);s.restore()}function wc(a,b,c,d){ta[0]=255*a.r|0;ta[1]=255*
a.g|0;ta[2]=255*a.b|0;ta[4]=255*b.r|0;ta[5]=255*b.g|0;ta[6]=255*b.b|0;ta[8]=255*c.r|0;ta[9]=255*c.g|0;ta[10]=255*c.b|0;ta[12]=255*d.r|0;ta[13]=255*d.g|0;ta[14]=255*d.b|0;ab.putImageData(nb,0,0);qb.drawImage($a,0,0);return hb}function Cb(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function gc(a){a=0.5*(a+1);return 0>a?0:1<a?1:a}function Xb(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;0!==e&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}if(!1===l instanceof THREE.Camera)console.error("THREE.CanvasRenderer.render: camera is not an instance of THREE.Camera.");
(m=1/m,oa=(n*c-j*f)*m,j=(n*d-j*g)*m,c=(i*f-l*c)*m,d=(i*g-l*d)*m,a=a-oa*h-c*k,h=b-j*h-d*k,s.save(),s.transform(oa,j,c,d,a,h),s.fill(),s.restore())}}function oa(a,b,c,d,e,f,g,h,k,i,j,l,oa){var n,m;n=oa.width-1;m=oa.height-1;g*=n;h*=m;c-=a;d-=b;e-=a;f-=b;k=k*n-g;i=i*m-h;j=j*n-g;l=l*m-h;m=1/(k*l-j*i);n=(l*c-i*e)*m;i=(l*d-i*f)*m;c=(k*e-j*c)*m;d=(k*f-j*d)*m;a=a-n*g-c*h;b=b-i*g-d*h;s.save();s.transform(n,i,c,d,a,b);s.clip();s.drawImage(oa,0,0);s.restore()}function wc(a,b,c,d){ta[0]=255*a.r|0;ta[1]=255*a.g|
0;ta[2]=255*a.b|0;ta[4]=255*b.r|0;ta[5]=255*b.g|0;ta[6]=255*b.b|0;ta[8]=255*c.r|0;ta[9]=255*c.g|0;ta[10]=255*c.b|0;ta[12]=255*d.r|0;ta[13]=255*d.g|0;ta[14]=255*d.b|0;ab.putImageData(nb,0,0);qb.drawImage($a,0,0);return hb}function Cb(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function gc(a){a=0.5*(a+1);return 0>a?0:1<a?1:a}function Xb(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;0!==e&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}if(!1===l instanceof THREE.Camera)console.error("THREE.CanvasRenderer.render: camera is not an instance of THREE.Camera.");
else{var Yb,xc,ma,da;!0===this.autoClear?this.clear():s.setTransform(1,0,0,-1,p,o);f.info.render.vertices=0;f.info.render.faces=0;g=j.projectScene(a,l,this.sortObjects,this.sortElements);h=g.elements;i=g.lights;mb=0<i.length;if(!0===mb){Na.setRGB(0,0,0);Za.setRGB(0,0,0);eb.setRGB(0,0,0);Yb=0;for(xc=i.length;Yb<xc;Yb++){da=i[Yb];var na=da.color;da instanceof THREE.AmbientLight?(Na.r+=na.r,Na.g+=na.g,Na.b+=na.b):da instanceof THREE.DirectionalLight?(Za.r+=na.r,Za.g+=na.g,Za.b+=na.b):da instanceof THREE.PointLight&&
(eb.r+=na.r,eb.g+=na.g,eb.b+=na.b)}}Yb=0;for(xc=h.length;Yb<xc;Yb++)if(ma=h[Yb],da=ma.material,!(void 0===da||!1===da.visible)){La.empty();if(ma instanceof THREE.RenderableParticle){D=ma;D.x*=p;D.y*=o;var na=D,bb=ma;b(da.opacity);c(da.blending);var E=void 0,zb=void 0,rb=void 0,sb=void 0,hc=ma=void 0,Pc=void 0;da instanceof THREE.ParticleBasicMaterial?null===da.map?(rb=bb.object.scale.x,sb=bb.object.scale.y,rb*=bb.scale.x*p,sb*=bb.scale.y*o,La.set(na.x-rb,na.y-sb,na.x+rb,na.y+sb),!1!==fb.intersects(La)&&
(e(da.color.getContextStyle()),s.save(),s.translate(na.x,na.y),s.rotate(-bb.rotation),s.scale(rb,sb),s.fillRect(-1,-1,2,2),s.restore())):(ma=da.map.image,hc=ma.width>>1,Pc=ma.height>>1,rb=bb.scale.x*p,sb=bb.scale.y*o,E=rb*hc,zb=sb*Pc,La.set(na.x-E,na.y-zb,na.x+E,na.y+zb),!1!==fb.intersects(La)&&(s.save(),s.translate(na.x,na.y),s.rotate(-bb.rotation),s.scale(rb,-sb),s.translate(-hc,-Pc),s.drawImage(ma,0,0),s.restore())):da instanceof THREE.ParticleCanvasMaterial&&(E=bb.scale.x*p,zb=bb.scale.y*o,La.set(na.x-
......@@ -689,10 +689,10 @@ this.lightArrow=new THREE.ArrowHelper(this.direction,null,c,d);this.lightSphere=
d.computeLineDistances(),this.targetLine=new THREE.Line(d,a),this.targetLine.properties.isGizmo=!0);this.properties.isGizmo=!0};THREE.DirectionalLightHelper.prototype=Object.create(THREE.Object3D.prototype);
THREE.DirectionalLightHelper.prototype.update=function(){this.direction.sub(this.light.target.position,this.light.position);this.lightArrow.setDirection(this.direction);this.color.copy(this.light.color);var a=THREE.Math.clamp(this.light.intensity,0,1);this.color.r*=a;this.color.g*=a;this.color.b*=a;this.lightArrow.setColor(this.color.getHex());this.lightSphere.material.color.copy(this.color);this.lightRays.material.color.copy(this.color);this.targetSphere.material.color.copy(this.color);this.targetLine.material.color.copy(this.color);
this.targetLine.geometry.vertices[0].copy(this.light.position);this.targetLine.geometry.vertices[1].copy(this.light.target.position);this.targetLine.geometry.computeLineDistances();this.targetLine.geometry.verticesNeedUpdate=!0};
THREE.HemisphereLightHelper=function(a,b,c){THREE.Object3D.call(this);this.light=a;this.position=a.position;var d=THREE.Math.clamp(a.intensity,0,1);this.color=a.color.clone();this.color.r*=d;this.color.g*=d;this.color.b*=d;var e=this.color.getHex();this.groundColor=a.groundColor.clone();this.groundColor.r*=d;this.groundColor.g*=d;this.groundColor.b*=d;var d=this.groundColor.getHex(),f=new THREE.SphereGeometry(b,16,8,0,2*Math.PI,0,0.5*Math.PI),g=new THREE.SphereGeometry(b,16,8,0,2*Math.PI,0.5*Math.PI,
Math.PI),h=new THREE.MeshBasicMaterial({color:e,fog:!1}),i=new THREE.MeshBasicMaterial({color:d,fog:!1});f.materials[0]=h;g.materials[0]=i;h=0;for(i=f.faces.length;h<i;h++)f.faces[h].materialIndex=0;h=0;for(i=g.faces.length;h<i;h++)g.faces[h].materialIndex=0;THREE.GeometryUtils.merge(f,g);this.lightSphere=new THREE.Mesh(f,new THREE.MeshFaceMaterial);this.lightArrow=new THREE.ArrowHelper(new THREE.Vector3(0,1,0),new THREE.Vector3(0,1.1*(b+c),0),c,e);this.lightArrow.rotation.x=Math.PI;this.lightArrowGround=
new THREE.ArrowHelper(new THREE.Vector3(0,1,0),new THREE.Vector3(0,-1.1*(b+c),0),c,d);b=new THREE.Object3D;b.rotation.x=0.5*-Math.PI;b.add(this.lightSphere);b.add(this.lightArrow);b.add(this.lightArrowGround);this.add(b);this.lightSphere.properties.isGizmo=!0;this.lightSphere.properties.gizmoSubject=a;this.lightSphere.properties.gizmoRoot=this;this.properties.isGizmo=!0;this.target=new THREE.Vector3;this.lookAt(this.target)};THREE.HemisphereLightHelper.prototype=Object.create(THREE.Object3D.prototype);
THREE.HemisphereLightHelper.prototype.update=function(){var a=THREE.Math.clamp(this.light.intensity,0,1);this.color.copy(this.light.color);this.groundColor.copy(this.light.groundColor);this.color.r*=a;this.color.g*=a;this.color.b*=a;this.groundColor.r*=a;this.groundColor.g*=a;this.groundColor.b*=a;this.lightSphere.geometry.materials[0].color.copy(this.color);this.lightSphere.geometry.materials[1].color.copy(this.groundColor);this.lightArrow.setColor(this.color.getHex());this.lightArrowGround.setColor(this.groundColor.getHex());
THREE.HemisphereLightHelper=function(a,b,c){THREE.Object3D.call(this);this.light=a;this.position=a.position;var d=THREE.Math.clamp(a.intensity,0,1);this.color=a.color.clone();this.color.r*=d;this.color.g*=d;this.color.b*=d;var e=this.color.getHex();this.groundColor=a.groundColor.clone();this.groundColor.r*=d;this.groundColor.g*=d;this.groundColor.b*=d;for(var d=this.groundColor.getHex(),f=new THREE.SphereGeometry(b,16,8,0,2*Math.PI,0,0.5*Math.PI),g=new THREE.SphereGeometry(b,16,8,0,2*Math.PI,0.5*
Math.PI,Math.PI),h=new THREE.MeshBasicMaterial({color:e,fog:!1}),i=new THREE.MeshBasicMaterial({color:d,fog:!1}),j=0,l=f.faces.length;j<l;j++)f.faces[j].materialIndex=0;j=0;for(l=g.faces.length;j<l;j++)g.faces[j].materialIndex=1;THREE.GeometryUtils.merge(f,g);this.lightSphere=new THREE.Mesh(f,new THREE.MeshFaceMaterial([h,i]));this.lightArrow=new THREE.ArrowHelper(new THREE.Vector3(0,1,0),new THREE.Vector3(0,1.1*(b+c),0),c,e);this.lightArrow.rotation.x=Math.PI;this.lightArrowGround=new THREE.ArrowHelper(new THREE.Vector3(0,
1,0),new THREE.Vector3(0,-1.1*(b+c),0),c,d);b=new THREE.Object3D;b.rotation.x=0.5*-Math.PI;b.add(this.lightSphere);b.add(this.lightArrow);b.add(this.lightArrowGround);this.add(b);this.lightSphere.properties.isGizmo=!0;this.lightSphere.properties.gizmoSubject=a;this.lightSphere.properties.gizmoRoot=this;this.properties.isGizmo=!0;this.target=new THREE.Vector3;this.lookAt(this.target)};THREE.HemisphereLightHelper.prototype=Object.create(THREE.Object3D.prototype);
THREE.HemisphereLightHelper.prototype.update=function(){var a=THREE.Math.clamp(this.light.intensity,0,1);this.color.copy(this.light.color);this.groundColor.copy(this.light.groundColor);this.color.r*=a;this.color.g*=a;this.color.b*=a;this.groundColor.r*=a;this.groundColor.g*=a;this.groundColor.b*=a;this.lightSphere.material.materials[0].color.copy(this.color);this.lightSphere.material.materials[1].color.copy(this.groundColor);this.lightArrow.setColor(this.color.getHex());this.lightArrowGround.setColor(this.groundColor.getHex());
this.lookAt(this.target)};
THREE.PointLightHelper=function(a,b){THREE.Object3D.call(this);this.light=a;this.position=a.position;this.color=a.color.clone();var c=THREE.Math.clamp(a.intensity,0,1);this.color.r*=c;this.color.g*=c;this.color.b*=c;var d=this.color.getHex(),c=new THREE.SphereGeometry(b,16,8),e=new THREE.AsteriskGeometry(1.25*b,2.25*b),f=new THREE.IcosahedronGeometry(1,2),g=new THREE.MeshBasicMaterial({color:d,fog:!1}),h=new THREE.LineBasicMaterial({color:d,fog:!1}),d=new THREE.MeshBasicMaterial({color:d,fog:!1,wireframe:!0,
opacity:0.1,transparent:!0});this.lightSphere=new THREE.Mesh(c,g);this.lightRays=new THREE.Line(e,h,THREE.LinePieces);this.lightDistance=new THREE.Mesh(f,d);c=a.distance;0===c?this.lightDistance.visible=!1:this.lightDistance.scale.set(c,c,c);this.add(this.lightSphere);this.add(this.lightRays);this.add(this.lightDistance);this.lightSphere.properties.isGizmo=!0;this.lightSphere.properties.gizmoSubject=a;this.lightSphere.properties.gizmoRoot=this;this.properties.isGizmo=!0};
......
......@@ -46,9 +46,6 @@ THREE.HemisphereLightHelper = function ( light, sphereSize, arrowLength, domeSiz
var bulbSkyMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false } );
var bulbGroundMaterial = new THREE.MeshBasicMaterial( { color: hexColorGround, fog: false } );
bulbGeometry.materials[ 0 ] = bulbSkyMaterial;
bulbGroundGeometry.materials[ 0 ] = bulbGroundMaterial;
for ( var i = 0, il = bulbGeometry.faces.length; i < il; i ++ ) {
bulbGeometry.faces[ i ].materialIndex = 0;
......@@ -57,13 +54,13 @@ THREE.HemisphereLightHelper = function ( light, sphereSize, arrowLength, domeSiz
for ( var i = 0, il = bulbGroundGeometry.faces.length; i < il; i ++ ) {
bulbGroundGeometry.faces[ i ].materialIndex = 0;
bulbGroundGeometry.faces[ i ].materialIndex = 1;
}
THREE.GeometryUtils.merge( bulbGeometry, bulbGroundGeometry );
this.lightSphere = new THREE.Mesh( bulbGeometry, new THREE.MeshFaceMaterial() );
this.lightSphere = new THREE.Mesh( bulbGeometry, new THREE.MeshFaceMaterial( [ bulbSkyMaterial, bulbGroundMaterial ] ) );
// arrows for sky and ground light directions
......@@ -117,8 +114,8 @@ THREE.HemisphereLightHelper.prototype.update = function () {
this.groundColor.g *= intensity;
this.groundColor.b *= intensity;
this.lightSphere.geometry.materials[ 0 ].color.copy( this.color );
this.lightSphere.geometry.materials[ 1 ].color.copy( this.groundColor );
this.lightSphere.material.materials[ 0 ].color.copy( this.color );
this.lightSphere.material.materials[ 1 ].color.copy( this.groundColor );
this.lightArrow.setColor( this.color.getHex() );
this.lightArrowGround.setColor( this.groundColor.getHex() );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册