Browse Source

Object.defineProperty()

Rawr 5 years ago
parent
commit
16f7d68563

+ 3 - 2
src/textures/CanvasTexture.js

@@ -5,12 +5,13 @@ class CanvasTexture extends Texture {
 	constructor( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
 
 		super( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
+
+		Object.defineProperty( this, 'isCanvasTexture', { value: true } );
+
 		this.needsUpdate = true;
 
 	}
 
 }
 
-CanvasTexture.prototype.isCanvasTexture = true;
-
 export { CanvasTexture };

+ 3 - 2
src/textures/CompressedTexture.js

@@ -5,6 +5,9 @@ class CompressedTexture extends Texture {
 	constructor( mipmaps, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {
 
 		super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
+
+		Object.defineProperty( this, 'isCompressedTexture', { value: true } );
+
 		this.image = { width: width, height: height };
 		this.mipmaps = mipmaps;
 
@@ -22,6 +25,4 @@ class CompressedTexture extends Texture {
 
 }
 
-CompressedTexture.prototype.isCompressedTexture = true;
-
 export { CompressedTexture };

+ 2 - 2
src/textures/CubeTexture.js

@@ -11,6 +11,8 @@ class CubeTexture extends Texture {
 
 		super( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
 
+		Object.defineProperty( this, 'isCubeTexture', { value: true } );
+
 		this.flipY = false;
 
 	}
@@ -29,6 +31,4 @@ class CubeTexture extends Texture {
 
 }
 
-CubeTexture.prototype.isCubeTexture = true;
-
 export { CubeTexture };

+ 3 - 2
src/textures/DataTexture.js

@@ -6,6 +6,9 @@ class DataTexture extends Texture {
 	constructor( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {
 
 		super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
+
+		Object.defineProperty( this, 'isDataTexture', { value: true } );
+
 		this.image = { data: data || null, width: width || 1, height: height || 1 };
 
 		this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
@@ -21,6 +24,4 @@ class DataTexture extends Texture {
 
 }
 
-DataTexture.prototype.isDataTexture = true;
-
 export { DataTexture };

+ 2 - 2
src/textures/DataTexture2DArray.js

@@ -7,6 +7,8 @@ class DataTexture2DArray extends Texture {
 
 		super( null );
 
+		Object.defineProperty( this, 'isDataTexture2DArray', { value: true } );
+
 		this.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 };
 
 		this.magFilter = NearestFilter;
@@ -23,6 +25,4 @@ class DataTexture2DArray extends Texture {
 
 }
 
-DataTexture2DArray.prototype.isDataTexture2DArray = true;
-
 export { DataTexture2DArray };

+ 2 - 2
src/textures/DataTexture3D.js

@@ -15,6 +15,8 @@ class DataTexture3D extends Texture {
 
 		super( null );
 
+		Object.defineProperty( this, 'isDataTexture3D', { value: true } );
+
 		this.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 };
 
 		this.magFilter = NearestFilter;
@@ -31,6 +33,4 @@ class DataTexture3D extends Texture {
 
 }
 
-DataTexture3D.prototype.isDataTexture3D = true;
-
 export { DataTexture3D };

+ 2 - 2
src/textures/DepthTexture.js

@@ -18,6 +18,8 @@ class DepthTexture extends Texture {
 
 		super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
 
+		Object.defineProperty( this, 'isDepthTexture', { value: true } );
+
 		this.image = { width: width, height: height };
 
 		this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
@@ -31,6 +33,4 @@ class DepthTexture extends Texture {
 
 }
 
-DepthTexture.prototype.isDepthTexture = true;
-
 export { DepthTexture };

+ 3 - 4
src/textures/Texture.js

@@ -24,6 +24,9 @@ class Texture extends EventDispatcher {
 		super();
 
 		Object.defineProperty( this, 'id', { value: textureId ++ } );
+		Object.defineProperty( this, 'isTexture', { value: true } );
+		Object.defineProperty( this, 'DEFAULT_IMAGE', { value: undefined } );
+		Object.defineProperty( this, 'DEFAULT_MAPPING', { value: UVMapping } );
 
 		this.uuid = MathUtils.generateUUID();
 
@@ -317,8 +320,4 @@ class Texture extends EventDispatcher {
 
 }
 
-Texture.prototype.isTexture = true;
-Texture.prototype.DEFAULT_IMAGE = undefined;
-Texture.prototype.DEFAULT_MAPPING = UVMapping;
-
 export { Texture };

+ 2 - 2
src/textures/VideoTexture.js

@@ -7,6 +7,8 @@ class VideoTexture extends Texture {
 
 		super( video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
 
+		Object.defineProperty( this, 'isVideoTexture', { value: true } );
+
 		this.format = format !== undefined ? format : RGBFormat;
 
 		this.minFilter = minFilter !== undefined ? minFilter : LinearFilter;
@@ -46,6 +48,4 @@ class VideoTexture extends Texture {
 
 }
 
-VideoTexture.prototype.isVideoTexture = true;
-
 export { VideoTexture };