Pārlūkot izejas kodu

Material: Added needsUpdate getter/setter.

Mr.doob 10 gadi atpakaļ
vecāks
revīzija
7f1069069d
1 mainītis faili ar 21 papildinājumiem un 1 dzēšanām
  1. 21 1
      src/materials/Material.js

+ 21 - 1
src/materials/Material.js

@@ -39,7 +39,7 @@ THREE.Material = function () {
 
 	this.visible = true;
 
-	this.needsUpdate = true;
+	this._needsUpdate = true;
 
 };
 
@@ -47,6 +47,20 @@ THREE.Material.prototype = {
 
 	constructor: THREE.Material,
 
+	get needsUpdate () {
+
+		return this._needsUpdate;
+
+	},
+
+	set needsUpdate ( value ) {
+
+		if ( value === true ) this.update();
+
+		this._needsUpdate = value;
+
+	},
+
 	setValues: function ( values ) {
 
 		if ( values === undefined ) return;
@@ -198,6 +212,12 @@ THREE.Material.prototype = {
 
 	},
 
+	update: function () {
+
+		this.dispatchEvent( { type: 'update' } );
+
+	},
+
 	dispose: function () {
 
 		this.dispatchEvent( { type: 'dispose' } );