Browse Source

Added .setGeometry() and .setMaterial() to Mesh.

Mr.doob 12 years ago
parent
commit
ef4841a757
1 changed files with 27 additions and 4 deletions
  1. 27 4
      src/objects/Mesh.js

+ 27 - 4
src/objects/Mesh.js

@@ -9,10 +9,21 @@ THREE.Mesh = function ( geometry, material ) {
 
 	THREE.Object3D.call( this );
 
-	this.geometry = geometry;
-	this.material = ( material !== undefined ) ? material : new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, wireframe: true } );
+	this.geometry = null;
+	this.material = null;
 
-	if ( this.geometry !== undefined ) {
+	this.setGeometry( geometry );
+	this.setMaterial( material );
+
+};
+
+THREE.Mesh.prototype = Object.create( THREE.Object3D.prototype );
+
+THREE.Mesh.prototype.setGeometry = function ( geometry ) {
+
+	if ( geometry !== undefined ) {
+
+		this.geometry = geometry;
 
 		if ( this.geometry.boundingSphere === null ) {
 
@@ -26,7 +37,19 @@ THREE.Mesh = function ( geometry, material ) {
 
 };
 
-THREE.Mesh.prototype = Object.create( THREE.Object3D.prototype );
+THREE.Mesh.prototype.setMaterial = function ( material ) {
+
+	if ( material !== undefined ) {
+
+		this.material = material;
+
+	} else {
+
+		this.material = new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff, wireframe: true } );
+
+	}
+
+};
 
 THREE.Mesh.prototype.updateMorphTargets = function () {