From 503e10ef9eaae2f43460d8c098a5b81e6b206916 Mon Sep 17 00:00:00 2001 From: Rawr Date: Tue, 4 Aug 2020 18:45:32 +1200 Subject: [PATCH 01/13] move to es6 classes --- src/textures/CanvasTexture.js | 13 ++-- src/textures/CompressedTexture.js | 28 ++++---- src/textures/CubeTexture.js | 30 ++++---- src/textures/DataTexture.js | 27 ++++---- src/textures/DataTexture2DArray.js | 27 ++++---- src/textures/DataTexture3D.js | 40 ++++++----- src/textures/DepthTexture.js | 36 +++++----- src/textures/Texture.js | 108 ++++++++++++++--------------- src/textures/VideoTexture.js | 40 +++++------ 9 files changed, 174 insertions(+), 175 deletions(-) diff --git a/src/textures/CanvasTexture.js b/src/textures/CanvasTexture.js index 31d92d54b4dbf8..46685eb998d6a8 100644 --- a/src/textures/CanvasTexture.js +++ b/src/textures/CanvasTexture.js @@ -1,15 +1,16 @@ import { Texture } from './Texture.js'; -function CanvasTexture( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) { +class CanvasTexture extends Texture { - Texture.call( this, canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ); + constructor( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) { - this.needsUpdate = true; + super( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ); + this.needsUpdate = true; + this.isCanvasTexture = true; + + } } -CanvasTexture.prototype = Object.create( Texture.prototype ); -CanvasTexture.prototype.constructor = CanvasTexture; -CanvasTexture.prototype.isCanvasTexture = true; export { CanvasTexture }; diff --git a/src/textures/CompressedTexture.js b/src/textures/CompressedTexture.js index 223491079fbc90..27368d8297f055 100644 --- a/src/textures/CompressedTexture.js +++ b/src/textures/CompressedTexture.js @@ -1,28 +1,28 @@ import { Texture } from './Texture.js'; -function CompressedTexture( mipmaps, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) { +class CompressedTexture extends Texture { - Texture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ); + constructor( mipmaps, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) { - this.image = { width: width, height: height }; - this.mipmaps = mipmaps; + super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ); + this.image = { width: width, height: height }; + this.mipmaps = mipmaps; - // no flipping for cube textures - // (also flipping doesn't work for compressed textures ) + // no flipping for cube textures + // (also flipping doesn't work for compressed textures ) - this.flipY = false; + this.flipY = false; - // can't generate mipmaps for compressed textures - // mips must be embedded in DDS files + // can't generate mipmaps for compressed textures + // mips must be embedded in DDS files - this.generateMipmaps = false; + this.generateMipmaps = false; -} + this.isCompressedTexture = true; -CompressedTexture.prototype = Object.create( Texture.prototype ); -CompressedTexture.prototype.constructor = CompressedTexture; + } -CompressedTexture.prototype.isCompressedTexture = true; +} export { CompressedTexture }; diff --git a/src/textures/CubeTexture.js b/src/textures/CubeTexture.js index 084ac560f08af5..3678d08310c092 100644 --- a/src/textures/CubeTexture.js +++ b/src/textures/CubeTexture.js @@ -1,38 +1,34 @@ import { Texture } from './Texture.js'; import { CubeReflectionMapping, RGBFormat } from '../constants.js'; -function CubeTexture( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) { +class CubeTexture extends Texture { - images = images !== undefined ? images : []; - mapping = mapping !== undefined ? mapping : CubeReflectionMapping; - format = format !== undefined ? format : RGBFormat; + constructor( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) { - Texture.call( this, images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ); + images = images !== undefined ? images : []; + mapping = mapping !== undefined ? mapping : CubeReflectionMapping; + format = format !== undefined ? format : RGBFormat; - this.flipY = false; + super( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ); -} - -CubeTexture.prototype = Object.create( Texture.prototype ); -CubeTexture.prototype.constructor = CubeTexture; - -CubeTexture.prototype.isCubeTexture = true; + this.flipY = false; + this.isCubeTexture = true; -Object.defineProperty( CubeTexture.prototype, 'images', { + } - get: function () { + get images() { return this.image; - }, + } - set: function ( value ) { + set images( value ) { this.image = value; } -} ); +} export { CubeTexture }; diff --git a/src/textures/DataTexture.js b/src/textures/DataTexture.js index 7b5ce5395e2836..960b4d3fb3bbb9 100644 --- a/src/textures/DataTexture.js +++ b/src/textures/DataTexture.js @@ -1,27 +1,26 @@ import { Texture } from './Texture.js'; import { NearestFilter } from '../constants.js'; -function DataTexture( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) { +class DataTexture extends Texture { - Texture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ); + constructor( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) { - this.image = { data: data || null, width: width || 1, height: height || 1 }; + super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ); + this.image = { data: data || null, width: width || 1, height: height || 1 }; - this.magFilter = magFilter !== undefined ? magFilter : NearestFilter; - this.minFilter = minFilter !== undefined ? minFilter : NearestFilter; + this.magFilter = magFilter !== undefined ? magFilter : NearestFilter; + this.minFilter = minFilter !== undefined ? minFilter : NearestFilter; - this.generateMipmaps = false; - this.flipY = false; - this.unpackAlignment = 1; + this.generateMipmaps = false; + this.flipY = false; + this.unpackAlignment = 1; - this.needsUpdate = true; + this.needsUpdate = true; + this.isDataTexture = true; -} - -DataTexture.prototype = Object.create( Texture.prototype ); -DataTexture.prototype.constructor = DataTexture; + } -DataTexture.prototype.isDataTexture = true; +} export { DataTexture }; diff --git a/src/textures/DataTexture2DArray.js b/src/textures/DataTexture2DArray.js index 5d016e0912e759..27c863fbee88dd 100644 --- a/src/textures/DataTexture2DArray.js +++ b/src/textures/DataTexture2DArray.js @@ -1,26 +1,29 @@ import { Texture } from './Texture.js'; import { ClampToEdgeWrapping, NearestFilter } from '../constants.js'; -function DataTexture2DArray( data, width, height, depth ) { +class DataTexture2DArray extends Texture { - Texture.call( this, null ); + constructor( data, width, height, depth ) { - this.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 }; + super( null ); - this.magFilter = NearestFilter; - this.minFilter = NearestFilter; + this.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 }; - this.wrapR = ClampToEdgeWrapping; + this.magFilter = NearestFilter; + this.minFilter = NearestFilter; - this.generateMipmaps = false; - this.flipY = false; + this.wrapR = ClampToEdgeWrapping; - this.needsUpdate = true; + this.generateMipmaps = false; + this.flipY = false; + + this.needsUpdate = true; + + this.isDataTexture2DArray = true; + + } } -DataTexture2DArray.prototype = Object.create( Texture.prototype ); -DataTexture2DArray.prototype.constructor = DataTexture2DArray; -DataTexture2DArray.prototype.isDataTexture2DArray = true; export { DataTexture2DArray }; diff --git a/src/textures/DataTexture3D.js b/src/textures/DataTexture3D.js index 53fa1d84b94dd6..8a04ba9630cfab 100644 --- a/src/textures/DataTexture3D.js +++ b/src/textures/DataTexture3D.js @@ -1,35 +1,37 @@ import { Texture } from './Texture.js'; import { ClampToEdgeWrapping, NearestFilter } from '../constants.js'; -function DataTexture3D( data, width, height, depth ) { +class DataTexture3D extends Texture { - // We're going to add .setXXX() methods for setting properties later. - // Users can still set in DataTexture3D directly. - // - // const texture = new THREE.DataTexture3D( data, width, height, depth ); - // texture.anisotropy = 16; - // - // See #14839 + constructor( data, width, height, depth ) { - Texture.call( this, null ); + // We're going to add .setXXX() methods for setting properties later. + // Users can still set in DataTexture3D directly. + // + // const texture = new THREE.DataTexture3D( data, width, height, depth ); + // texture.anisotropy = 16; + // + // See #14839 - this.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 }; + super( null ); - this.magFilter = NearestFilter; - this.minFilter = NearestFilter; + this.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 }; - this.wrapR = ClampToEdgeWrapping; + this.magFilter = NearestFilter; + this.minFilter = NearestFilter; - this.generateMipmaps = false; - this.flipY = false; + this.wrapR = ClampToEdgeWrapping; - this.needsUpdate = true; + this.generateMipmaps = false; + this.flipY = false; + this.needsUpdate = true; + + this.isDataTexture3D = true; + + } } -DataTexture3D.prototype = Object.create( Texture.prototype ); -DataTexture3D.prototype.constructor = DataTexture3D; -DataTexture3D.prototype.isDataTexture3D = true; export { DataTexture3D }; diff --git a/src/textures/DepthTexture.js b/src/textures/DepthTexture.js index 609772c6060e40..8fc9876ab5174c 100644 --- a/src/textures/DepthTexture.js +++ b/src/textures/DepthTexture.js @@ -1,33 +1,37 @@ import { Texture } from './Texture.js'; import { NearestFilter, UnsignedShortType, UnsignedInt248Type, DepthFormat, DepthStencilFormat } from '../constants.js'; -function DepthTexture( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) { +class DepthTexture extends Texture { - format = format !== undefined ? format : DepthFormat; + constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) { - if ( format !== DepthFormat && format !== DepthStencilFormat ) { + format = format !== undefined ? format : DepthFormat; - throw new Error( 'DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat' ); + if ( format !== DepthFormat && format !== DepthStencilFormat ) { - } + throw new Error( 'DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat' ); + + } + + if ( type === undefined && format === DepthFormat ) type = UnsignedShortType; + if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type; - if ( type === undefined && format === DepthFormat ) type = UnsignedShortType; - if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type; + super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ); - Texture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ); + this.image = { width: width, height: height }; - this.image = { width: width, height: height }; + this.magFilter = magFilter !== undefined ? magFilter : NearestFilter; + this.minFilter = minFilter !== undefined ? minFilter : NearestFilter; - this.magFilter = magFilter !== undefined ? magFilter : NearestFilter; - this.minFilter = minFilter !== undefined ? minFilter : NearestFilter; + this.flipY = false; + this.generateMipmaps = false; + + this.isDepthTexture = true; + + } - this.flipY = false; - this.generateMipmaps = false; } -DepthTexture.prototype = Object.create( Texture.prototype ); -DepthTexture.prototype.constructor = DepthTexture; -DepthTexture.prototype.isDepthTexture = true; export { DepthTexture }; diff --git a/src/textures/Texture.js b/src/textures/Texture.js index 417c7f542734ad..da7f1032bad6b8 100644 --- a/src/textures/Texture.js +++ b/src/textures/Texture.js @@ -17,77 +17,77 @@ import { ImageUtils } from '../extras/ImageUtils.js'; let textureId = 0; -function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) { +class Texture extends EventDispatcher { - Object.defineProperty( this, 'id', { value: textureId ++ } ); + constructor( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) { - this.uuid = MathUtils.generateUUID(); + super(); + // Object.defineProperty( this, 'id', { value: textureId ++ } ); + this.id = textureId ++; - this.name = ''; + this.uuid = MathUtils.generateUUID(); - this.image = image !== undefined ? image : Texture.DEFAULT_IMAGE; - this.mipmaps = []; + this.name = ''; - this.mapping = mapping !== undefined ? mapping : Texture.DEFAULT_MAPPING; + this.image = image !== undefined ? image : Texture.DEFAULT_IMAGE; + this.mipmaps = []; - this.wrapS = wrapS !== undefined ? wrapS : ClampToEdgeWrapping; - this.wrapT = wrapT !== undefined ? wrapT : ClampToEdgeWrapping; + this.mapping = mapping !== undefined ? mapping : Texture.DEFAULT_MAPPING; - this.magFilter = magFilter !== undefined ? magFilter : LinearFilter; - this.minFilter = minFilter !== undefined ? minFilter : LinearMipmapLinearFilter; + this.wrapS = wrapS !== undefined ? wrapS : ClampToEdgeWrapping; + this.wrapT = wrapT !== undefined ? wrapT : ClampToEdgeWrapping; - this.anisotropy = anisotropy !== undefined ? anisotropy : 1; + this.magFilter = magFilter !== undefined ? magFilter : LinearFilter; + this.minFilter = minFilter !== undefined ? minFilter : LinearMipmapLinearFilter; - this.format = format !== undefined ? format : RGBAFormat; - this.internalFormat = null; - this.type = type !== undefined ? type : UnsignedByteType; + this.anisotropy = anisotropy !== undefined ? anisotropy : 1; - this.offset = new Vector2( 0, 0 ); - this.repeat = new Vector2( 1, 1 ); - this.center = new Vector2( 0, 0 ); - this.rotation = 0; + this.format = format !== undefined ? format : RGBAFormat; + this.internalFormat = null; + this.type = type !== undefined ? type : UnsignedByteType; - this.matrixAutoUpdate = true; - this.matrix = new Matrix3(); + this.offset = new Vector2( 0, 0 ); + this.repeat = new Vector2( 1, 1 ); + this.center = new Vector2( 0, 0 ); + this.rotation = 0; - this.generateMipmaps = true; - this.premultiplyAlpha = false; - this.flipY = true; - this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml) + this.matrixAutoUpdate = true; + this.matrix = new Matrix3(); - // Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap. - // - // Also changing the encoding after already used by a Material will not automatically make the Material - // update. You need to explicitly call Material.needsUpdate to trigger it to recompile. - this.encoding = encoding !== undefined ? encoding : LinearEncoding; + this.generateMipmaps = true; + this.premultiplyAlpha = false; + this.flipY = true; + this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml) - this.version = 0; - this.onUpdate = null; + // Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap. + // + // Also changing the encoding after already used by a Material will not automatically make the Material + // update. You need to explicitly call Material.needsUpdate to trigger it to recompile. + this.encoding = encoding !== undefined ? encoding : LinearEncoding; -} - -Texture.DEFAULT_IMAGE = undefined; -Texture.DEFAULT_MAPPING = UVMapping; + this.version = 0; + this.onUpdate = null; -Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), { + this.DEFAULT_IMAGE = undefined; + this.DEFAULT_MAPPING = UVMapping; - constructor: Texture, + this.isTexture = true; - isTexture: true, + } - updateMatrix: function () { + updateMatrix() { this.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y ); - }, + } - clone: function () { + clone() { return new this.constructor().copy( this ); - }, + } - copy: function ( source ) { + copy( source ) { this.name = source.name; @@ -124,9 +124,9 @@ Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), { return this; - }, + } - toJSON: function ( meta ) { + toJSON( meta ) { const isRootObject = ( meta === undefined || typeof meta === 'string' ); @@ -226,15 +226,15 @@ Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), { return output; - }, + } - dispose: function () { + dispose() { this.dispatchEvent( { type: 'dispose' } ); - }, + } - transformUv: function ( uv ) { + transformUv( uv ) { if ( this.mapping !== UVMapping ) return uv; @@ -314,17 +314,13 @@ Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), { } -} ); - -Object.defineProperty( Texture.prototype, "needsUpdate", { - - set: function ( value ) { + set needsUpdate( value ) { if ( value === true ) this.version ++; } -} ); +} export { Texture }; diff --git a/src/textures/VideoTexture.js b/src/textures/VideoTexture.js index 46ec804bbd9c3b..38a2965fe3701c 100644 --- a/src/textures/VideoTexture.js +++ b/src/textures/VideoTexture.js @@ -1,41 +1,39 @@ import { RGBFormat, LinearFilter } from '../constants.js'; import { Texture } from './Texture.js'; -function VideoTexture( video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) { +class VideoTexture extends Texture { - Texture.call( this, video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ); + constructor( video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) { - this.format = format !== undefined ? format : RGBFormat; + super( video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ); - this.minFilter = minFilter !== undefined ? minFilter : LinearFilter; - this.magFilter = magFilter !== undefined ? magFilter : LinearFilter; + this.format = format !== undefined ? format : RGBFormat; - this.generateMipmaps = false; + this.minFilter = minFilter !== undefined ? minFilter : LinearFilter; + this.magFilter = magFilter !== undefined ? magFilter : LinearFilter; - const scope = this; + this.generateMipmaps = false; - function updateVideo() { + const scope = this; - scope.needsUpdate = true; - video.requestVideoFrameCallback( updateVideo ); + function updateVideo() { - } - - if ( 'requestVideoFrameCallback' in video ) { + scope.needsUpdate = true; + video.requestVideoFrameCallback( updateVideo ); - video.requestVideoFrameCallback( updateVideo ); + } - } + if ( 'requestVideoFrameCallback' in video ) { -} + video.requestVideoFrameCallback( updateVideo ); -VideoTexture.prototype = Object.assign( Object.create( Texture.prototype ), { + } - constructor: VideoTexture, + this.isVideoTexture = true; - isVideoTexture: true, + } - update: function () { + update() { const video = this.image; const hasVideoFrameCallback = 'requestVideoFrameCallback' in video; @@ -48,7 +46,7 @@ VideoTexture.prototype = Object.assign( Object.create( Texture.prototype ), { } -} ); +} export { VideoTexture }; From 65cf52e12f592929615b78749cc2164b34a74e26 Mon Sep 17 00:00:00 2001 From: Rawr Date: Sat, 15 Aug 2020 13:23:03 +1200 Subject: [PATCH 02/13] is* adjustment --- src/textures/CanvasTexture.js | 2 +- src/textures/CompressedTexture.js | 3 +-- src/textures/CubeTexture.js | 2 +- src/textures/DataTexture.js | 2 +- src/textures/DataTexture2DArray.js | 3 +-- src/textures/DataTexture3D.js | 3 +-- src/textures/DepthTexture.js | 3 +-- src/textures/Texture.js | 3 +-- src/textures/VideoTexture.js | 3 +-- 9 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/textures/CanvasTexture.js b/src/textures/CanvasTexture.js index 46685eb998d6a8..cdeb35213c5312 100644 --- a/src/textures/CanvasTexture.js +++ b/src/textures/CanvasTexture.js @@ -6,11 +6,11 @@ class CanvasTexture extends Texture { super( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ); this.needsUpdate = true; - this.isCanvasTexture = true; } } +CanvasTexture.prototype.isCanvasTexture = true; export { CanvasTexture }; diff --git a/src/textures/CompressedTexture.js b/src/textures/CompressedTexture.js index 27368d8297f055..a050455ba48cc5 100644 --- a/src/textures/CompressedTexture.js +++ b/src/textures/CompressedTexture.js @@ -18,11 +18,10 @@ class CompressedTexture extends Texture { this.generateMipmaps = false; - this.isCompressedTexture = true; - } } +CompressedTexture.prototype.isCompressedTexture = true; export { CompressedTexture }; diff --git a/src/textures/CubeTexture.js b/src/textures/CubeTexture.js index 3678d08310c092..8cb64a1692fdbb 100644 --- a/src/textures/CubeTexture.js +++ b/src/textures/CubeTexture.js @@ -12,7 +12,6 @@ class CubeTexture extends Texture { super( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ); this.flipY = false; - this.isCubeTexture = true; } @@ -30,5 +29,6 @@ class CubeTexture extends Texture { } +CubeTexture.prototype.isCubeTexture = true; export { CubeTexture }; diff --git a/src/textures/DataTexture.js b/src/textures/DataTexture.js index 960b4d3fb3bbb9..87961bc5669b0a 100644 --- a/src/textures/DataTexture.js +++ b/src/textures/DataTexture.js @@ -16,11 +16,11 @@ class DataTexture extends Texture { this.unpackAlignment = 1; this.needsUpdate = true; - this.isDataTexture = true; } } +DataTexture.prototype.isDataTexture = true; export { DataTexture }; diff --git a/src/textures/DataTexture2DArray.js b/src/textures/DataTexture2DArray.js index 27c863fbee88dd..e3eb2d4e66b6fc 100644 --- a/src/textures/DataTexture2DArray.js +++ b/src/textures/DataTexture2DArray.js @@ -19,11 +19,10 @@ class DataTexture2DArray extends Texture { this.needsUpdate = true; - this.isDataTexture2DArray = true; - } } +DataTexture2DArray.prototype.isDataTexture2DArray = true; export { DataTexture2DArray }; diff --git a/src/textures/DataTexture3D.js b/src/textures/DataTexture3D.js index 8a04ba9630cfab..277daefc51069b 100644 --- a/src/textures/DataTexture3D.js +++ b/src/textures/DataTexture3D.js @@ -27,11 +27,10 @@ class DataTexture3D extends Texture { this.needsUpdate = true; - this.isDataTexture3D = true; - } } +DataTexture3D.prototype.isDataTexture3D = true; export { DataTexture3D }; diff --git a/src/textures/DepthTexture.js b/src/textures/DepthTexture.js index 8fc9876ab5174c..79cb16e3c02c2c 100644 --- a/src/textures/DepthTexture.js +++ b/src/textures/DepthTexture.js @@ -26,12 +26,11 @@ class DepthTexture extends Texture { this.flipY = false; this.generateMipmaps = false; - this.isDepthTexture = true; - } } +DepthTexture.prototype.isDepthTexture = true; export { DepthTexture }; diff --git a/src/textures/Texture.js b/src/textures/Texture.js index da7f1032bad6b8..bb231c504f67a1 100644 --- a/src/textures/Texture.js +++ b/src/textures/Texture.js @@ -71,8 +71,6 @@ class Texture extends EventDispatcher { this.DEFAULT_IMAGE = undefined; this.DEFAULT_MAPPING = UVMapping; - this.isTexture = true; - } updateMatrix() { @@ -322,5 +320,6 @@ class Texture extends EventDispatcher { } +Texture.prototype.isTexture = true; export { Texture }; diff --git a/src/textures/VideoTexture.js b/src/textures/VideoTexture.js index 38a2965fe3701c..0e79ff6b403b37 100644 --- a/src/textures/VideoTexture.js +++ b/src/textures/VideoTexture.js @@ -29,8 +29,6 @@ class VideoTexture extends Texture { } - this.isVideoTexture = true; - } update() { @@ -48,5 +46,6 @@ class VideoTexture extends Texture { } +VideoTexture.prototype.isVideoTexture = true; export { VideoTexture }; From d661009dc08e8354eb6a2c11bc2178e24605e913 Mon Sep 17 00:00:00 2001 From: Rawr Date: Tue, 18 Aug 2020 15:20:59 +1200 Subject: [PATCH 03/13] id update & static props --- src/textures/Texture.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/textures/Texture.js b/src/textures/Texture.js index bb231c504f67a1..da57465484db9c 100644 --- a/src/textures/Texture.js +++ b/src/textures/Texture.js @@ -22,8 +22,8 @@ class Texture extends EventDispatcher { constructor( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) { super(); - // Object.defineProperty( this, 'id', { value: textureId ++ } ); - this.id = textureId ++; + + Object.defineProperty( this, 'id', { value: textureId ++ } ); this.uuid = MathUtils.generateUUID(); @@ -68,9 +68,6 @@ class Texture extends EventDispatcher { this.version = 0; this.onUpdate = null; - this.DEFAULT_IMAGE = undefined; - this.DEFAULT_MAPPING = UVMapping; - } updateMatrix() { @@ -321,5 +318,7 @@ class Texture extends EventDispatcher { } Texture.prototype.isTexture = true; +Texture.prototype.DEFAULT_IMAGE = undefined; +Texture.prototype.DEFAULT_MAPPING = UVMapping; export { Texture }; From e098de529e3f6ffd75d4449e96e4de90ebe12740 Mon Sep 17 00:00:00 2001 From: Rawr Date: Tue, 18 Aug 2020 15:24:22 +1200 Subject: [PATCH 04/13] linting update --- src/textures/Texture.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/textures/Texture.js b/src/textures/Texture.js index da57465484db9c..778268050d5d11 100644 --- a/src/textures/Texture.js +++ b/src/textures/Texture.js @@ -22,7 +22,7 @@ class Texture extends EventDispatcher { constructor( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) { super(); - + Object.defineProperty( this, 'id', { value: textureId ++ } ); this.uuid = MathUtils.generateUUID(); From 16f7d685632fb1c44fb8c7e2b28b8b8866e97a77 Mon Sep 17 00:00:00 2001 From: Rawr Date: Wed, 19 Aug 2020 16:37:00 +1200 Subject: [PATCH 05/13] Object.defineProperty() --- src/textures/CanvasTexture.js | 5 +++-- src/textures/CompressedTexture.js | 5 +++-- src/textures/CubeTexture.js | 4 ++-- src/textures/DataTexture.js | 5 +++-- src/textures/DataTexture2DArray.js | 4 ++-- src/textures/DataTexture3D.js | 4 ++-- src/textures/DepthTexture.js | 4 ++-- src/textures/Texture.js | 7 +++---- src/textures/VideoTexture.js | 4 ++-- 9 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/textures/CanvasTexture.js b/src/textures/CanvasTexture.js index cdeb35213c5312..0612248ecf5ec9 100644 --- a/src/textures/CanvasTexture.js +++ b/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 }; diff --git a/src/textures/CompressedTexture.js b/src/textures/CompressedTexture.js index a050455ba48cc5..6a7c1db9958240 100644 --- a/src/textures/CompressedTexture.js +++ b/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 }; diff --git a/src/textures/CubeTexture.js b/src/textures/CubeTexture.js index 8cb64a1692fdbb..c1202678cbc7d9 100644 --- a/src/textures/CubeTexture.js +++ b/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 }; diff --git a/src/textures/DataTexture.js b/src/textures/DataTexture.js index 87961bc5669b0a..3335bc90cf542d 100644 --- a/src/textures/DataTexture.js +++ b/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 }; diff --git a/src/textures/DataTexture2DArray.js b/src/textures/DataTexture2DArray.js index e3eb2d4e66b6fc..1ec5d51d8569f3 100644 --- a/src/textures/DataTexture2DArray.js +++ b/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 }; diff --git a/src/textures/DataTexture3D.js b/src/textures/DataTexture3D.js index 277daefc51069b..a502d55f0c8956 100644 --- a/src/textures/DataTexture3D.js +++ b/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 }; diff --git a/src/textures/DepthTexture.js b/src/textures/DepthTexture.js index 79cb16e3c02c2c..4f43f8bd570a95 100644 --- a/src/textures/DepthTexture.js +++ b/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 }; diff --git a/src/textures/Texture.js b/src/textures/Texture.js index 778268050d5d11..16bda7a0101538 100644 --- a/src/textures/Texture.js +++ b/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 }; diff --git a/src/textures/VideoTexture.js b/src/textures/VideoTexture.js index 0e79ff6b403b37..1c878f422e5a07 100644 --- a/src/textures/VideoTexture.js +++ b/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 }; From da12e00d36e5d54fb3e4dd15b4fe867e4d72309a Mon Sep 17 00:00:00 2001 From: DefinitelyMaybe Date: Mon, 9 Nov 2020 21:20:20 +1300 Subject: [PATCH 06/13] linting fix --- src/textures/CubeTexture.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/textures/CubeTexture.js b/src/textures/CubeTexture.js index da6d950e1b1a4d..786672645b6b4a 100644 --- a/src/textures/CubeTexture.js +++ b/src/textures/CubeTexture.js @@ -13,17 +13,17 @@ class CubeTexture extends Texture { Object.defineProperty( this, 'isCubeTexture', { value: true } ); - // Why CubeTexture._needsFlipEnvMap is necessary: - // - // By convention -- likely based on the RenderMan spec from the 1990's -- cube maps are specified by WebGL (and three.js) - // in a coordinate system in which positive-x is to the right when looking up the positive-z axis -- in other words, - // in a left-handed coordinate system. By continuing this convention, preexisting cube maps continued to render correctly. + // Why CubeTexture._needsFlipEnvMap is necessary: + // + // By convention -- likely based on the RenderMan spec from the 1990's -- cube maps are specified by WebGL (and three.js) + // in a coordinate system in which positive-x is to the right when looking up the positive-z axis -- in other words, + // in a left-handed coordinate system. By continuing this convention, preexisting cube maps continued to render correctly. - // three.js uses a right-handed coordinate system. So environment maps used in three.js appear to have px and nx swapped - // and the flag _needsFlipEnvMap controls this conversion. The flip is not required (and thus _needsFlipEnvMap is set to false) - // when using WebGLCubeRenderTarget.texture as a cube texture. + // three.js uses a right-handed coordinate system. So environment maps used in three.js appear to have px and nx swapped + // and the flag _needsFlipEnvMap controls this conversion. The flip is not required (and thus _needsFlipEnvMap is set to false) + // when using WebGLCubeRenderTarget.texture as a cube texture. - this._needsFlipEnvMap = true; + this._needsFlipEnvMap = true; this.flipY = false; From b263538738d4d46b523052058a0e859bbae91789 Mon Sep 17 00:00:00 2001 From: DefinitelyMaybe Date: Thu, 4 Feb 2021 14:04:29 +1300 Subject: [PATCH 07/13] lint fix --- src/textures/Texture.js | 49 +++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/src/textures/Texture.js b/src/textures/Texture.js index 1bb2d2d7843068..11dadc02f89e9a 100644 --- a/src/textures/Texture.js +++ b/src/textures/Texture.js @@ -57,11 +57,11 @@ class Texture extends EventDispatcher { this.matrixAutoUpdate = true; this.matrix = new Matrix3(); - // Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap. - // - // Also changing the encoding after already used by a Material will not automatically make the Material - // update. You need to explicitly call Material.needsUpdate to trigger it to recompile. - this.encoding = encoding; + // Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap. + // + // Also changing the encoding after already used by a Material will not automatically make the Material + // update. You need to explicitly call Material.needsUpdate to trigger it to recompile. + this.encoding = encoding; this.generateMipmaps = true; this.premultiplyAlpha = false; @@ -334,39 +334,40 @@ class Texture extends EventDispatcher { } - serializeImage( image ) { + serializeImage( image ) { - if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) || + if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) || ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) || ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) { - // default images + // default images - return ImageUtils.getDataURL( image ); + return ImageUtils.getDataURL( image ); - } else { + } else { - if ( image.data ) { + if ( image.data ) { - // images of DataTexture + // images of DataTexture - return { - data: Array.prototype.slice.call( image.data ), - width: image.width, - height: image.height, - type: image.data.constructor.name - }; + return { + data: Array.prototype.slice.call( image.data ), + width: image.width, + height: image.height, + type: image.data.constructor.name + }; - } else { + } else { - console.warn( 'THREE.Texture: Unable to serialize Texture.' ); - return {}; + console.warn( 'THREE.Texture: Unable to serialize Texture.' ); + return {}; - } + } + + } - } + } - } } export { Texture }; From 6298c074deca86393d331d233dc7c505c8759304 Mon Sep 17 00:00:00 2001 From: DefinitelyMaybe Date: Fri, 5 Feb 2021 08:13:53 +1300 Subject: [PATCH 08/13] serializeImage -> this.serializeImage --- src/textures/Texture.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/textures/Texture.js b/src/textures/Texture.js index 11dadc02f89e9a..18de37d9517ddb 100644 --- a/src/textures/Texture.js +++ b/src/textures/Texture.js @@ -203,11 +203,11 @@ class Texture extends EventDispatcher { if ( image[ i ].isDataTexture ) { - url.push( serializeImage( image[ i ].image ) ); + url.push( this.serializeImage( image[ i ].image ) ); } else { - url.push( serializeImage( image[ i ] ) ); + url.push( this.serializeImage( image[ i ] ) ); } @@ -217,7 +217,7 @@ class Texture extends EventDispatcher { // process single image - url = serializeImage( image ); + url = this.serializeImage( image ); } From a3475bdce63cb2896b6aa49b98fa12fc97801efc Mon Sep 17 00:00:00 2001 From: DefinitelyMaybe Date: Tue, 9 Feb 2021 11:17:06 +1300 Subject: [PATCH 09/13] move to static variables --- src/textures/Texture.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/textures/Texture.js b/src/textures/Texture.js index 11dadc02f89e9a..09591fd38e838b 100644 --- a/src/textures/Texture.js +++ b/src/textures/Texture.js @@ -19,14 +19,15 @@ let textureId = 0; class Texture extends EventDispatcher { + static DEFAULT_IMAGE = undefined; + static DEFAULT_MAPPING = UVMapping; + constructor( image = Texture.DEFAULT_IMAGE, mapping = Texture.DEFAULT_MAPPING, wrapS = ClampToEdgeWrapping, wrapT = ClampToEdgeWrapping, magFilter = LinearFilter, minFilter = LinearMipmapLinearFilter, format = RGBAFormat, type = UnsignedByteType, anisotropy = 1, encoding = LinearEncoding ) { 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(); From 921c087845a22508c30ec4166408658f1d072890 Mon Sep 17 00:00:00 2001 From: DefinitelyMaybe Date: Tue, 9 Feb 2021 11:34:21 +1300 Subject: [PATCH 10/13] back to static and catches on serializeImage --- src/textures/Texture.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/textures/Texture.js b/src/textures/Texture.js index 09591fd38e838b..797070e8129d43 100644 --- a/src/textures/Texture.js +++ b/src/textures/Texture.js @@ -19,9 +19,6 @@ let textureId = 0; class Texture extends EventDispatcher { - static DEFAULT_IMAGE = undefined; - static DEFAULT_MAPPING = UVMapping; - constructor( image = Texture.DEFAULT_IMAGE, mapping = Texture.DEFAULT_MAPPING, wrapS = ClampToEdgeWrapping, wrapT = ClampToEdgeWrapping, magFilter = LinearFilter, minFilter = LinearMipmapLinearFilter, format = RGBAFormat, type = UnsignedByteType, anisotropy = 1, encoding = LinearEncoding ) { super(); @@ -204,11 +201,11 @@ class Texture extends EventDispatcher { if ( image[ i ].isDataTexture ) { - url.push( serializeImage( image[ i ].image ) ); + url.push( this.serializeImage( image[ i ].image ) ); } else { - url.push( serializeImage( image[ i ] ) ); + url.push( this.serializeImage( image[ i ] ) ); } @@ -218,7 +215,7 @@ class Texture extends EventDispatcher { // process single image - url = serializeImage( image ); + url = this.serializeImage( image ); } @@ -371,4 +368,7 @@ class Texture extends EventDispatcher { } +Texture.DEFAULT_IMAGE = undefined; +Texture.DEFAULT_MAPPING = UVMapping; + export { Texture }; From 2d31d48e8dc0863e057eb4e4eea479bbbc89fc63 Mon Sep 17 00:00:00 2001 From: DefinitelyMaybe Date: Thu, 18 Feb 2021 12:34:25 +1300 Subject: [PATCH 11/13] using static class properties again --- src/textures/Texture.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/textures/Texture.js b/src/textures/Texture.js index 797070e8129d43..0c61a44b858518 100644 --- a/src/textures/Texture.js +++ b/src/textures/Texture.js @@ -19,12 +19,14 @@ let textureId = 0; class Texture extends EventDispatcher { + static DEFAULT_IMAGE = undefined; + static DEFAULT_MAPPING = UVMapping; + constructor( image = Texture.DEFAULT_IMAGE, mapping = Texture.DEFAULT_MAPPING, wrapS = ClampToEdgeWrapping, wrapT = ClampToEdgeWrapping, magFilter = LinearFilter, minFilter = LinearMipmapLinearFilter, format = RGBAFormat, type = UnsignedByteType, anisotropy = 1, encoding = LinearEncoding ) { super(); Object.defineProperty( this, 'id', { value: textureId ++ } ); - Object.defineProperty( this, 'isTexture', { value: true } ); this.uuid = MathUtils.generateUUID(); @@ -368,7 +370,6 @@ class Texture extends EventDispatcher { } -Texture.DEFAULT_IMAGE = undefined; -Texture.DEFAULT_MAPPING = UVMapping; +Texture.prototype.isTexture = true; export { Texture }; From e90d0bd51a354e65a1fc2a3e9b55cd2088587ea1 Mon Sep 17 00:00:00 2001 From: DefinitelyMaybe Date: Fri, 19 Feb 2021 08:57:30 +1300 Subject: [PATCH 12/13] serializeImage back to internal helper function --- src/textures/Texture.js | 48 ++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/textures/Texture.js b/src/textures/Texture.js index 0c61a44b858518..a69c083b9d9d43 100644 --- a/src/textures/Texture.js +++ b/src/textures/Texture.js @@ -203,11 +203,11 @@ class Texture extends EventDispatcher { if ( image[ i ].isDataTexture ) { - url.push( this.serializeImage( image[ i ].image ) ); + url.push( serializeImage( image[ i ].image ) ); } else { - url.push( this.serializeImage( image[ i ] ) ); + url.push( serializeImage( image[ i ] ) ); } @@ -217,7 +217,7 @@ class Texture extends EventDispatcher { // process single image - url = this.serializeImage( image ); + url = serializeImage( image ); } @@ -334,35 +334,37 @@ class Texture extends EventDispatcher { } - serializeImage( image ) { +} - if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) || - ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) || - ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) { +Texture.prototype.isTexture = true; - // default images +function serializeImage( image ) { - return ImageUtils.getDataURL( image ); + if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) || + ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) || + ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) { - } else { + // default images - if ( image.data ) { + return ImageUtils.getDataURL( image ); - // images of DataTexture + } else { - return { - data: Array.prototype.slice.call( image.data ), - width: image.width, - height: image.height, - type: image.data.constructor.name - }; + if ( image.data ) { - } else { + // images of DataTexture - console.warn( 'THREE.Texture: Unable to serialize Texture.' ); - return {}; + return { + data: Array.prototype.slice.call( image.data ), + width: image.width, + height: image.height, + type: image.data.constructor.name + }; - } + } else { + + console.warn( 'THREE.Texture: Unable to serialize Texture.' ); + return {}; } @@ -370,6 +372,4 @@ class Texture extends EventDispatcher { } -Texture.prototype.isTexture = true; - export { Texture }; From a45af3159bad2c06a3cc0fea129b87222aa06901 Mon Sep 17 00:00:00 2001 From: DefinitelyMaybe Date: Fri, 19 Feb 2021 14:00:24 +1300 Subject: [PATCH 13/13] reintroduce class.prototype.is* properties --- src/textures/CanvasTexture.js | 4 ++-- src/textures/CompressedTexture.js | 4 ++-- src/textures/CubeTexture.js | 4 ++-- src/textures/DataTexture.js | 4 ++-- src/textures/DataTexture2DArray.js | 4 ++-- src/textures/DataTexture3D.js | 4 ++-- src/textures/DepthTexture.js | 4 ++-- src/textures/VideoTexture.js | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/textures/CanvasTexture.js b/src/textures/CanvasTexture.js index 0612248ecf5ec9..35511ff133c82c 100644 --- a/src/textures/CanvasTexture.js +++ b/src/textures/CanvasTexture.js @@ -6,12 +6,12 @@ class CanvasTexture extends Texture { 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 }; diff --git a/src/textures/CompressedTexture.js b/src/textures/CompressedTexture.js index 6a7c1db9958240..cf0e37d017bd2e 100644 --- a/src/textures/CompressedTexture.js +++ b/src/textures/CompressedTexture.js @@ -6,8 +6,6 @@ class CompressedTexture extends Texture { 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; @@ -25,4 +23,6 @@ class CompressedTexture extends Texture { } +CompressedTexture.prototype.isCompressedTexture = true; + export { CompressedTexture }; diff --git a/src/textures/CubeTexture.js b/src/textures/CubeTexture.js index 786672645b6b4a..f214911d437316 100644 --- a/src/textures/CubeTexture.js +++ b/src/textures/CubeTexture.js @@ -11,8 +11,6 @@ class CubeTexture extends Texture { super( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ); - Object.defineProperty( this, 'isCubeTexture', { value: true } ); - // Why CubeTexture._needsFlipEnvMap is necessary: // // By convention -- likely based on the RenderMan spec from the 1990's -- cube maps are specified by WebGL (and three.js) @@ -43,4 +41,6 @@ class CubeTexture extends Texture { } +CubeTexture.prototype.isCubeTexture = true; + export { CubeTexture }; diff --git a/src/textures/DataTexture.js b/src/textures/DataTexture.js index 3335bc90cf542d..acd56f830a2b74 100644 --- a/src/textures/DataTexture.js +++ b/src/textures/DataTexture.js @@ -7,8 +7,6 @@ class DataTexture extends Texture { 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; @@ -24,4 +22,6 @@ class DataTexture extends Texture { } +DataTexture.prototype.isDataTexture = true; + export { DataTexture }; diff --git a/src/textures/DataTexture2DArray.js b/src/textures/DataTexture2DArray.js index 7dc584e5f0fad0..bd67e111830aba 100644 --- a/src/textures/DataTexture2DArray.js +++ b/src/textures/DataTexture2DArray.js @@ -7,8 +7,6 @@ class DataTexture2DArray extends Texture { super( null ); - Object.defineProperty( this, 'isDataTexture2DArray', { value: true } ); - this.image = { data, width, height, depth }; this.magFilter = NearestFilter; @@ -25,4 +23,6 @@ class DataTexture2DArray extends Texture { } +DataTexture2DArray.prototype.isDataTexture2DArray = true; + export { DataTexture2DArray }; diff --git a/src/textures/DataTexture3D.js b/src/textures/DataTexture3D.js index 3928583c59f27e..f4a936e2a89525 100644 --- a/src/textures/DataTexture3D.js +++ b/src/textures/DataTexture3D.js @@ -15,8 +15,6 @@ class DataTexture3D extends Texture { super( null ); - Object.defineProperty( this, 'isDataTexture3D', { value: true } ); - this.image = { data, width, height, depth }; this.magFilter = NearestFilter; @@ -33,4 +31,6 @@ class DataTexture3D extends Texture { } +DataTexture3D.prototype.isDataTexture3D = true; + export { DataTexture3D }; diff --git a/src/textures/DepthTexture.js b/src/textures/DepthTexture.js index 4f43f8bd570a95..79cb16e3c02c2c 100644 --- a/src/textures/DepthTexture.js +++ b/src/textures/DepthTexture.js @@ -18,8 +18,6 @@ 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; @@ -33,4 +31,6 @@ class DepthTexture extends Texture { } +DepthTexture.prototype.isDepthTexture = true; + export { DepthTexture }; diff --git a/src/textures/VideoTexture.js b/src/textures/VideoTexture.js index 5cc8212b656c48..f074f290548588 100644 --- a/src/textures/VideoTexture.js +++ b/src/textures/VideoTexture.js @@ -7,8 +7,6 @@ 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; @@ -54,4 +52,6 @@ class VideoTexture extends Texture { } +VideoTexture.prototype.isVideoTexture = true; + export { VideoTexture };