Переглянути джерело

Merge pull request #21378 from linbingquan/dev-jsm-prototype

JSM: Revert to *.prototype.is* = true
Mr.doob 4 роки тому
батько
коміт
6f08c48be9

+ 2 - 2
examples/jsm/renderers/nodes/core/InputNode.js

@@ -8,8 +8,6 @@ class InputNode extends Node {
 
 		this.constant = false;
 
-		Object.defineProperty( this, 'isInputNode', { value: true } );
-
 	}
 
 	setConst( value ) {
@@ -53,4 +51,6 @@ class InputNode extends Node {
 
 }
 
+InputNode.prototype.isInputNode = true;
+
 export default InputNode;

+ 8 - 8
examples/jsm/renderers/nodes/core/Node.js

@@ -8,8 +8,6 @@ class Node {
 
 		this.updateType = NodeUpdateType.None;
 
-		Object.defineProperty( this, 'isNode', { value: true } );
-
 	}
 
 	getUpdateType( /*builder*/ ) {
@@ -37,17 +35,17 @@ class Node {
 	}
 
 	buildStage( builder, shaderStage, output = null ) {
-		
+
 		const oldShaderStage = builder.shaderStage;
-		
+
 		builder.shaderStage = shaderStage;
-		
+
 		const snippet = this.build( builder, output );
-		
+
 		builder.shaderStage = oldShaderStage;
-		
+
 		return snippet;
-		
+
 	}
 
 	build( builder, output = null ) {
@@ -60,4 +58,6 @@ class Node {
 
 }
 
+Node.prototype.isNode = true;
+
 export default Node;

+ 2 - 2
examples/jsm/renderers/nodes/core/NodeAttribute.js

@@ -5,10 +5,10 @@ class NodeAttribute {
 		this.name = name;
 		this.type = type;
 
-		Object.defineProperty( this, 'isNodeAttribute', { value: true } );
-
 	}
 
 }
 
+NodeAttribute.prototype.isNodeAttribute = true;
+
 export default NodeAttribute;

+ 2 - 2
examples/jsm/renderers/nodes/core/NodeUniform.js

@@ -7,8 +7,6 @@ class NodeUniform {
 		this.node = node;
 		this.needsUpdate = needsUpdate;
 
-		Object.defineProperty( this, 'isNodeUniform', { value: true } );
-
 	}
 
 	get value() {
@@ -25,4 +23,6 @@ class NodeUniform {
 
 }
 
+NodeUniform.prototype.isNodeUniform = true;
+
 export default NodeUniform;

+ 2 - 2
examples/jsm/renderers/nodes/core/NodeVary.js

@@ -6,10 +6,10 @@ class NodeVary {
 		this.type = type;
 		this.snippet = snippet;
 
-		Object.defineProperty( this, 'isNodeVary', { value: true } );
-
 	}
 
 }
 
+NodeVary.prototype.isNodeVary = true;
+
 export default NodeVary;

+ 2 - 2
examples/jsm/renderers/nodes/inputs/ColorNode.js

@@ -9,10 +9,10 @@ class ColorNode extends InputNode {
 
 		this.value = value;
 
-		Object.defineProperty( this, 'isColorNode', { value: true } );
-
 	}
 
 }
 
+ColorNode.prototype.isColorNode = true;
+
 export default ColorNode;

+ 2 - 2
examples/jsm/renderers/nodes/inputs/FloatNode.js

@@ -8,10 +8,10 @@ class FloatNode extends InputNode {
 
 		this.value = value;
 
-		Object.defineProperty( this, 'isFloatNode', { value: true } );
-
 	}
 
 }
 
+FloatNode.prototype.isFloatNode = true;
+
 export default FloatNode;

+ 2 - 2
examples/jsm/renderers/nodes/inputs/Matrix3Node.js

@@ -9,10 +9,10 @@ class Matrix3Node extends InputNode {
 
 		this.value = value;
 
-		Object.defineProperty( this, 'isMatrix3Node', { value: true } );
-
 	}
 
 }
 
+Matrix3Node.prototype.isMatrix3Node = true;
+
 export default Matrix3Node;

+ 2 - 2
examples/jsm/renderers/nodes/inputs/Matrix4Node.js

@@ -9,10 +9,10 @@ class Matrix4Node extends InputNode {
 
 		this.value = value;
 
-		Object.defineProperty( this, 'isMatrix4Node', { value: true } );
-
 	}
 
 }
 
+Matrix4Node.prototype.isMatrix4Node = true;
+
 export default Matrix4Node;

+ 2 - 2
examples/jsm/renderers/nodes/inputs/TextureNode.js

@@ -10,8 +10,6 @@ class TextureNode extends InputNode {
 		this.value = value;
 		this.uv = uv;
 
-		Object.defineProperty( this, 'isTextureNode', { value: true } );
-
 	}
 
 	generate( builder, output ) {
@@ -29,4 +27,6 @@ class TextureNode extends InputNode {
 
 }
 
+TextureNode.prototype.isTextureNode = true;
+
 export default TextureNode;

+ 2 - 2
examples/jsm/renderers/nodes/inputs/Vector2Node.js

@@ -9,10 +9,10 @@ class Vector2Node extends InputNode {
 
 		this.value = value;
 
-		Object.defineProperty( this, 'isVector2Node', { value: true } );
-
 	}
 
 }
 
+Vector2Node.prototype.isVector2Node = true;
+
 export default Vector2Node;

+ 2 - 2
examples/jsm/renderers/nodes/inputs/Vector3Node.js

@@ -9,10 +9,10 @@ class Vector3Node extends InputNode {
 
 		this.value = value;
 
-		Object.defineProperty( this, 'isVector3Node', { value: true } );
-
 	}
 
 }
 
+Vector3Node.prototype.isVector3Node = true;
+
 export default Vector3Node;

+ 2 - 2
examples/jsm/renderers/nodes/inputs/Vector4Node.js

@@ -9,10 +9,10 @@ class Vector4Node extends InputNode {
 
 		this.value = value;
 
-		Object.defineProperty( this, 'isVector4Node', { value: true } );
-
 	}
 
 }
 
+Vector4Node.prototype.isVector4Node = true;
+
 export default Vector4Node;

+ 8 - 9
examples/jsm/renderers/webgpu/WebGPUSampledTexture.js

@@ -16,13 +16,12 @@ class WebGPUSampledTexture extends WebGPUBinding {
 
 		this.textureGPU = null; // set by the renderer
 
-		Object.defineProperty( this, 'isSampledTexture', { value: true } );
-
 	}
 
-
 }
 
+WebGPUSampledTexture.prototype.isSampledTexture = true;
+
 class WebGPUSampledArrayTexture extends WebGPUSampledTexture {
 
 	constructor( name ) {
@@ -31,12 +30,12 @@ class WebGPUSampledArrayTexture extends WebGPUSampledTexture {
 
 		this.dimension = GPUTextureViewDimension.TwoDArray;
 
-		Object.defineProperty( this, 'isSampledArrayTexture', { value: true } );
-
 	}
 
 }
 
+WebGPUSampledArrayTexture.prototype.isSampledArrayTexture = true;
+
 class WebGPUSampled3DTexture extends WebGPUSampledTexture {
 
 	constructor( name ) {
@@ -45,12 +44,12 @@ class WebGPUSampled3DTexture extends WebGPUSampledTexture {
 
 		this.dimension = GPUTextureViewDimension.ThreeD;
 
-		Object.defineProperty( this, 'isSampled3DTexture', { value: true } );
-
 	}
 
 }
 
+WebGPUSampled3DTexture.prototype.isSampled3DTexture = true;
+
 class WebGPUSampledCubeTexture extends WebGPUSampledTexture {
 
 	constructor( name ) {
@@ -59,10 +58,10 @@ class WebGPUSampledCubeTexture extends WebGPUSampledTexture {
 
 		this.dimension = GPUTextureViewDimension.Cube;
 
-		Object.defineProperty( this, 'isSampledCubeTexture', { value: true } );
-
 	}
 
 }
 
+WebGPUSampledCubeTexture.prototype.isSampledCubeTexture = true;
+
 export { WebGPUSampledTexture, WebGPUSampledArrayTexture, WebGPUSampled3DTexture, WebGPUSampledCubeTexture };

+ 2 - 2
examples/jsm/renderers/webgpu/WebGPUSampler.js

@@ -14,10 +14,10 @@ class WebGPUSampler extends WebGPUBinding {
 
 		this.samplerGPU = null; // set by the renderer
 
-		Object.defineProperty( this, 'isSampler', { value: true } );
-
 	}
 
 }
 
+WebGPUSampler.prototype.isSampler = true;
+
 export default WebGPUSampler;

+ 2 - 2
examples/jsm/renderers/webgpu/WebGPUStorageBuffer.js

@@ -14,10 +14,10 @@ class WebGPUStorageBuffer extends WebGPUBinding {
 		this.attribute = attribute;
 		this.bufferGPU = null; // set by the renderer
 
-		Object.defineProperty( this, 'isStorageBuffer', { value: true } );
-
 	}
 
 }
 
+WebGPUStorageBuffer.prototype.isStorageBuffer = true;
+
 export default WebGPUStorageBuffer;

+ 14 - 14
examples/jsm/renderers/webgpu/WebGPUUniform.js

@@ -37,12 +37,12 @@ class FloatUniform extends WebGPUUniform {
 		this.boundary = 4;
 		this.itemSize = 1;
 
-		Object.defineProperty( this, 'isFloatUniform', { value: true } );
-
 	}
 
 }
 
+FloatUniform.prototype.isFloatUniform = true;
+
 class Vector2Uniform extends WebGPUUniform {
 
 	constructor( name, value = new Vector2() ) {
@@ -52,12 +52,12 @@ class Vector2Uniform extends WebGPUUniform {
 		this.boundary = 8;
 		this.itemSize = 2;
 
-		Object.defineProperty( this, 'isVector2Uniform', { value: true } );
-
 	}
 
 }
 
+Vector2Uniform.prototype.isVector2Uniform = true;
+
 class Vector3Uniform extends WebGPUUniform {
 
 	constructor( name, value = new Vector3() ) {
@@ -67,12 +67,12 @@ class Vector3Uniform extends WebGPUUniform {
 		this.boundary = 16;
 		this.itemSize = 3;
 
-		Object.defineProperty( this, 'isVector3Uniform', { value: true } );
-
 	}
 
 }
 
+Vector3Uniform.prototype.isVector3Uniform = true;
+
 class Vector4Uniform extends WebGPUUniform {
 
 	constructor( name, value = new Vector4() ) {
@@ -82,12 +82,12 @@ class Vector4Uniform extends WebGPUUniform {
 		this.boundary = 16;
 		this.itemSize = 4;
 
-		Object.defineProperty( this, 'isVector4Uniform', { value: true } );
-
 	}
 
 }
 
+Vector4Uniform.prototype.isVector4Uniform = true;
+
 class ColorUniform extends WebGPUUniform {
 
 	constructor( name, value = new Color() ) {
@@ -97,12 +97,12 @@ class ColorUniform extends WebGPUUniform {
 		this.boundary = 16;
 		this.itemSize = 3;
 
-		Object.defineProperty( this, 'isColorUniform', { value: true } );
-
 	}
 
 }
 
+ColorUniform.prototype.isColorUniform = true;
+
 class Matrix3Uniform extends WebGPUUniform {
 
 	constructor( name, value = new Matrix3() ) {
@@ -112,12 +112,12 @@ class Matrix3Uniform extends WebGPUUniform {
 		this.boundary = 48;
 		this.itemSize = 12;
 
-		Object.defineProperty( this, 'isMatrix3Uniform', { value: true } );
-
 	}
 
 }
 
+Matrix3Uniform.prototype.isMatrix3Uniform = true;
+
 class Matrix4Uniform extends WebGPUUniform {
 
 	constructor( name, value = new Matrix4() ) {
@@ -127,10 +127,10 @@ class Matrix4Uniform extends WebGPUUniform {
 		this.boundary = 64;
 		this.itemSize = 16;
 
-		Object.defineProperty( this, 'isMatrix4Uniform', { value: true } );
-
 	}
 
 }
 
+Matrix4Uniform.prototype.isMatrix4Uniform = true;
+
 export { FloatUniform, Vector2Uniform, Vector3Uniform, Vector4Uniform, ColorUniform, Matrix3Uniform, Matrix4Uniform };

+ 2 - 2
examples/jsm/renderers/webgpu/WebGPUUniformsGroup.js

@@ -22,8 +22,6 @@ class WebGPUUniformsGroup extends WebGPUBinding {
 		this.array = null; // set by the renderer
 		this.bufferGPU = null; // set by the renderer
 
-		Object.defineProperty( this, 'isUniformsGroup', { value: true } );
-
 	}
 
 	addUniform( uniform ) {
@@ -292,4 +290,6 @@ function arraysEqual( a, b, offset ) {
 
 }
 
+WebGPUUniformsGroup.prototype.isUniformsGroup = true;
+
 export default WebGPUUniformsGroup;