Преглед изворни кода

Added size parameter to AxisHelper as suggested in fda0a0a80ff7e547736a9245b8cb4baeecc2077d

Mr.doob пре 13 година
родитељ
комит
74717a1fa2

+ 2 - 1
build/three.min.js

@@ -716,7 +716,8 @@ q,o]);g.push([q,p,o])}else{e.push(new THREE.Face4(a,f,j,l));g.push([m,q,p,o])}}t
 THREE.ConvexGeometry=function(a){function b(a){var b=a.length();return new THREE.UV(a.x/b,a.y/b)}THREE.Geometry.call(this);for(var c=[[0,1,2],[0,2,1]],d=3;d<a.length;d++){var f=d,e=a[f].clone(),g=e.length();e.x=e.x+g*(Math.random()-0.5)*2E-6;e.y=e.y+g*(Math.random()-0.5)*2E-6;e.z=e.z+g*(Math.random()-0.5)*2E-6;for(var g=[],h=0;h<c.length;){var i=c[h],j=e,l=a[i[0]],n;n=l;var m=a[i[1]],q=a[i[2]],o=new THREE.Vector3,p=new THREE.Vector3;o.sub(q,m);p.sub(n,m);o.crossSelf(p);o.isZero()||o.normalize();n=
 THREE.ConvexGeometry=function(a){function b(a){var b=a.length();return new THREE.UV(a.x/b,a.y/b)}THREE.Geometry.call(this);for(var c=[[0,1,2],[0,2,1]],d=3;d<a.length;d++){var f=d,e=a[f].clone(),g=e.length();e.x=e.x+g*(Math.random()-0.5)*2E-6;e.y=e.y+g*(Math.random()-0.5)*2E-6;e.z=e.z+g*(Math.random()-0.5)*2E-6;for(var g=[],h=0;h<c.length;){var i=c[h],j=e,l=a[i[0]],n;n=l;var m=a[i[1]],q=a[i[2]],o=new THREE.Vector3,p=new THREE.Vector3;o.sub(q,m);p.sub(n,m);o.crossSelf(p);o.isZero()||o.normalize();n=
 o;l=n.dot(l);if(n.dot(j)>=l){for(j=0;j<3;j++){l=[i[j],i[(j+1)%3]];n=true;for(m=0;m<g.length;m++)if(g[m][0]===l[1]&&g[m][1]===l[0]){g[m]=g[g.length-1];g.pop();n=false;break}n&&g.push(l)}c[h]=c[c.length-1];c.pop()}else h++}for(m=0;m<g.length;m++)c.push([g[m][0],g[m][1],f])}f=0;e=Array(a.length);for(d=0;d<c.length;d++){g=c[d];for(h=0;h<3;h++){if(e[g[h]]===void 0){e[g[h]]=f++;this.vertices.push(a[g[h]])}g[h]=e[g[h]]}}for(d=0;d<c.length;d++)this.faces.push(new THREE.Face3(c[d][0],c[d][1],c[d][2]));for(d=
 o;l=n.dot(l);if(n.dot(j)>=l){for(j=0;j<3;j++){l=[i[j],i[(j+1)%3]];n=true;for(m=0;m<g.length;m++)if(g[m][0]===l[1]&&g[m][1]===l[0]){g[m]=g[g.length-1];g.pop();n=false;break}n&&g.push(l)}c[h]=c[c.length-1];c.pop()}else h++}for(m=0;m<g.length;m++)c.push([g[m][0],g[m][1],f])}f=0;e=Array(a.length);for(d=0;d<c.length;d++){g=c[d];for(h=0;h<3;h++){if(e[g[h]]===void 0){e[g[h]]=f++;this.vertices.push(a[g[h]])}g[h]=e[g[h]]}}for(d=0;d<c.length;d++)this.faces.push(new THREE.Face3(c[d][0],c[d][1],c[d][2]));for(d=
 0;d<this.faces.length;d++){g=this.faces[d];this.faceVertexUvs[0].push([b(this.vertices[g.a]),b(this.vertices[g.b]),b(this.vertices[g.c])])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.ConvexGeometry.prototype=Object.create(THREE.Geometry.prototype);
 0;d<this.faces.length;d++){g=this.faces[d];this.faceVertexUvs[0].push([b(this.vertices[g.a]),b(this.vertices[g.b]),b(this.vertices[g.c])])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.ConvexGeometry.prototype=Object.create(THREE.Geometry.prototype);
-THREE.AxisHelper=function(){var a=new THREE.Geometry;a.vertices.push(new THREE.Vector3,new THREE.Vector3(1,0,0),new THREE.Vector3,new THREE.Vector3(0,1,0),new THREE.Vector3,new THREE.Vector3(0,0,1));a.colors.push(new THREE.Color(16711680),new THREE.Color(16755200),new THREE.Color(65280),new THREE.Color(11206400),new THREE.Color(255),new THREE.Color(43775));var b=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors});THREE.Line.call(this,a,b,THREE.LinePieces)};THREE.AxisHelper.prototype=Object.create(THREE.Line.prototype);
+THREE.AxisHelper=function(a){var b=new THREE.Geometry;b.vertices.push(new THREE.Vector3,new THREE.Vector3(a||1,0,0),new THREE.Vector3,new THREE.Vector3(0,a||1,0),new THREE.Vector3,new THREE.Vector3(0,0,a||1));b.colors.push(new THREE.Color(16711680),new THREE.Color(16755200),new THREE.Color(65280),new THREE.Color(11206400),new THREE.Color(255),new THREE.Color(43775));a=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors});THREE.Line.call(this,b,a,THREE.LinePieces)};
+THREE.AxisHelper.prototype=Object.create(THREE.Line.prototype);
 THREE.ArrowHelper=function(a,b,c,d){THREE.Object3D.call(this);d===void 0&&(d=16776960);c===void 0&&(c=20);var f=new THREE.Geometry;f.vertices.push(new THREE.Vector3(0,0,0));f.vertices.push(new THREE.Vector3(0,1,0));this.line=new THREE.Line(f,new THREE.LineBasicMaterial({color:d}));this.add(this.line);f=new THREE.CylinderGeometry(0,0.05,0.25,5,1);this.cone=new THREE.Mesh(f,new THREE.MeshBasicMaterial({color:d}));this.cone.position.set(0,1,0);this.add(this.cone);if(b instanceof THREE.Vector3)this.position=
 THREE.ArrowHelper=function(a,b,c,d){THREE.Object3D.call(this);d===void 0&&(d=16776960);c===void 0&&(c=20);var f=new THREE.Geometry;f.vertices.push(new THREE.Vector3(0,0,0));f.vertices.push(new THREE.Vector3(0,1,0));this.line=new THREE.Line(f,new THREE.LineBasicMaterial({color:d}));this.add(this.line);f=new THREE.CylinderGeometry(0,0.05,0.25,5,1);this.cone=new THREE.Mesh(f,new THREE.MeshBasicMaterial({color:d}));this.cone.position.set(0,1,0);this.add(this.cone);if(b instanceof THREE.Vector3)this.position=
 b;this.setDirection(a);this.setLength(c)};THREE.ArrowHelper.prototype=Object.create(THREE.Object3D.prototype);THREE.ArrowHelper.prototype.setDirection=function(a){var b=(new THREE.Vector3(0,1,0)).crossSelf(a),a=Math.acos((new THREE.Vector3(0,1,0)).dot(a.clone().normalize()));this.matrix=(new THREE.Matrix4).makeRotationAxis(b.normalize(),a);this.rotation.setEulerFromRotationMatrix(this.matrix,this.eulerOrder)};THREE.ArrowHelper.prototype.setLength=function(a){this.scale.set(a,a,a)};
 b;this.setDirection(a);this.setLength(c)};THREE.ArrowHelper.prototype=Object.create(THREE.Object3D.prototype);THREE.ArrowHelper.prototype.setDirection=function(a){var b=(new THREE.Vector3(0,1,0)).crossSelf(a),a=Math.acos((new THREE.Vector3(0,1,0)).dot(a.clone().normalize()));this.matrix=(new THREE.Matrix4).makeRotationAxis(b.normalize(),a);this.rotation.setEulerFromRotationMatrix(this.matrix,this.eulerOrder)};THREE.ArrowHelper.prototype.setLength=function(a){this.scale.set(a,a,a)};
 THREE.ArrowHelper.prototype.setColor=function(a){this.line.material.color.setHex(a);this.cone.material.color.setHex(a)};
 THREE.ArrowHelper.prototype.setColor=function(a){this.line.material.color.setHex(a);this.cone.material.color.setHex(a)};

+ 1 - 2
editor/js/ui/Viewport.js

@@ -36,8 +36,7 @@ var Viewport = function ( signals ) {
 	selectionBox.visible = false;
 	selectionBox.visible = false;
 	sceneHelpers.add( selectionBox );
 	sceneHelpers.add( selectionBox );
 
 
-	var selectionAxis = new THREE.AxisHelper();
-	selectionAxis.geometry.applyMatrix( new THREE.Matrix4().makeScale( 100, 100, 100 ) );
+	var selectionAxis = new THREE.AxisHelper( 100 );
 	selectionAxis.material.depthTest = false;
 	selectionAxis.material.depthTest = false;
 	selectionAxis.material.transparent = true;
 	selectionAxis.material.transparent = true;
 	selectionAxis.matrixAutoUpdate = false;
 	selectionAxis.matrixAutoUpdate = false;

+ 1 - 2
examples/webgl_geometries.html

@@ -111,9 +111,8 @@
 				object.position.set( 0, 0, -200 );
 				object.position.set( 0, 0, -200 );
 				scene.add( object );
 				scene.add( object );
 
 
-				object = new THREE.AxisHelper();
+				object = new THREE.AxisHelper( 50 );
 				object.position.set( 200, 0, -200 );
 				object.position.set( 200, 0, -200 );
-				object.scale.x = object.scale.y = object.scale.z = 50;
 				scene.add( object );
 				scene.add( object );
 
 
 				object = new THREE.ArrowHelper( new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 0 ), 50 );
 				object = new THREE.ArrowHelper( new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 0 ), 50 );

+ 1 - 2
examples/webgl_geometries2.html

@@ -157,9 +157,8 @@
 				// object.position.set( -200, 100, 0 );
 				// object.position.set( -200, 100, 0 );
 				// scene.add( object );
 				// scene.add( object );
 
 
-				object = new THREE.AxisHelper();
+				object = new THREE.AxisHelper( 50 );
 				object.position.set( 200, 0, -200 );
 				object.position.set( 200, 0, -200 );
-				object.scale.x = object.scale.y = object.scale.z = 50;
 				scene.add( object );
 				scene.add( object );
 
 
 				object = new THREE.ArrowHelper( new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 0 ), 50 );
 				object = new THREE.ArrowHelper( new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 0 ), 50 );

+ 1 - 2
examples/webgl_geometry_convex.html

@@ -102,9 +102,8 @@
 				scene.add( object );
 				scene.add( object );
 
 
 
 
-				object = new THREE.AxisHelper();
+				object = new THREE.AxisHelper( 50 );
 				object.position.set( 200, 0, -200 );
 				object.position.set( 200, 0, -200 );
-				object.scale.x = object.scale.y = object.scale.z = 50;
 				scene.add( object );
 				scene.add( object );
 
 
 				object = new THREE.ArrowHelper( new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 0 ), 50 );
 				object = new THREE.ArrowHelper( new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 0 ), 50 );

+ 4 - 4
src/extras/helpers/AxisHelper.js

@@ -3,14 +3,14 @@
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  */
  */
 
 
-THREE.AxisHelper = function () {
+THREE.AxisHelper = function ( size ) {
 
 
 	var geometry = new THREE.Geometry();
 	var geometry = new THREE.Geometry();
 
 
 	geometry.vertices.push(
 	geometry.vertices.push(
-		new THREE.Vector3(), new THREE.Vector3( 1, 0, 0 ),
-		new THREE.Vector3(), new THREE.Vector3( 0, 1, 0 ),
-		new THREE.Vector3(), new THREE.Vector3( 0, 0, 1 )
+		new THREE.Vector3(), new THREE.Vector3( size || 1, 0, 0 ),
+		new THREE.Vector3(), new THREE.Vector3( 0, size || 1, 0 ),
+		new THREE.Vector3(), new THREE.Vector3( 0, 0, size || 1 )
 	);
 	);
 
 
 	geometry.colors.push(
 	geometry.colors.push(