浏览代码

Made id property immutable.
I'm seeing people modifying it :(

Mr.doob 11 年之前
父节点
当前提交
d2cfb5ec37
共有 5 个文件被更改,包括 10 次插入5 次删除
  1. 2 1
      src/core/BufferGeometry.js
  2. 2 1
      src/core/Geometry.js
  3. 2 1
      src/core/Object3D.js
  4. 2 1
      src/materials/Material.js
  5. 2 1
      src/textures/Texture.js

+ 2 - 1
src/core/BufferGeometry.js

@@ -5,7 +5,8 @@
 
 THREE.BufferGeometry = function () {
 
-	this.id = THREE.GeometryIdCount ++;
+	Object.defineProperty( this, 'id', { value: THREE.GeometryIdCount ++ } );
+
 	this.uuid = THREE.Math.generateUUID();
 
 	this.name = '';

+ 2 - 1
src/core/Geometry.js

@@ -9,7 +9,8 @@
 
 THREE.Geometry = function () {
 
-	this.id = THREE.GeometryIdCount ++;
+	Object.defineProperty( this, 'id', { value: THREE.GeometryIdCount ++ } );
+
 	this.uuid = THREE.Math.generateUUID();
 
 	this.name = '';

+ 2 - 1
src/core/Object3D.js

@@ -7,7 +7,8 @@
 
 THREE.Object3D = function () {
 
-	this.id = THREE.Object3DIdCount ++;
+	Object.defineProperty( this, 'id', { value: THREE.Object3DIdCount ++ } );
+
 	this.uuid = THREE.Math.generateUUID();
 
 	this.name = '';

+ 2 - 1
src/materials/Material.js

@@ -5,7 +5,8 @@
 
 THREE.Material = function () {
 
-	this.id = THREE.MaterialIdCount ++;
+	Object.defineProperty( this, 'id', { value: THREE.MaterialIdCount ++ } );
+
 	this.uuid = THREE.Math.generateUUID();
 
 	this.name = '';

+ 2 - 1
src/textures/Texture.js

@@ -6,7 +6,8 @@
 
 THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
 
-	this.id = THREE.TextureIdCount ++;
+	Object.defineProperty( this, 'id', { value: THREE.TextureIdCount ++ } );
+
 	this.uuid = THREE.Math.generateUUID();
 
 	this.name = '';