Jelajahi Sumber

LineMaterial: Clean up (#26720)

* LineMaterial: Clean up

* Workaround setting parameters in Material and ShaderMaterial

* Fix
Levi Pesin 1 tahun lalu
induk
melakukan
e6304f3742
1 mengubah file dengan 90 tambahan dan 156 penghapusan
  1. 90 156
      examples/jsm/lines/LineMaterial.js

+ 90 - 156
examples/jsm/lines/LineMaterial.js

@@ -453,247 +453,181 @@ class LineMaterial extends ShaderMaterial {
 
 		this.isLineMaterial = true;
 
-		Object.defineProperties( this, {
-
-			color: {
-
-				enumerable: true,
-
-				get: function () {
-
-					return this.uniforms.diffuse.value;
-
-				},
-
-				set: function ( value ) {
-
-					this.uniforms.diffuse.value = value;
-
-				}
-
-			},
-
-			worldUnits: {
-
-				enumerable: true,
-
-				get: function () {
-
-					return 'WORLD_UNITS' in this.defines;
-
-				},
-
-				set: function ( value ) {
-
-					if ( value === true ) {
-
-						this.defines.WORLD_UNITS = '';
-
-					} else {
-
-						delete this.defines.WORLD_UNITS;
-
-					}
-
-				}
-
-			},
-
-			linewidth: {
-
-				enumerable: true,
-
-				get: function () {
-
-					return this.uniforms.linewidth.value;
-
-				},
-
-				set: function ( value ) {
-
-					this.uniforms.linewidth.value = value;
-
-				}
-
-			},
-
-			dashed: {
-
-				enumerable: true,
+		this.setValues( parameters );
 
-				get: function () {
+	}
 
-					return Boolean( 'USE_DASH' in this.defines );
+	get color() {
 
-				},
+		return this.uniforms.diffuse.value;
 
-				set( value ) {
+	}
 
-					if ( Boolean( value ) !== Boolean( 'USE_DASH' in this.defines ) ) {
+	set color( value ) {
 
-						this.needsUpdate = true;
+		this.uniforms.diffuse.value = value;
 
-					}
+	}
 
-					if ( value === true ) {
+	get worldUnits() {
 
-						this.defines.USE_DASH = '';
+		return 'WORLD_UNITS' in this.defines;
 
-					} else {
+	}
 
-						delete this.defines.USE_DASH;
+	set worldUnits( value ) {
 
-					}
-
-				}
+		if ( value === true ) {
 
-			},
+			this.defines.WORLD_UNITS = '';
 
-			dashScale: {
+		} else {
 
-				enumerable: true,
+			delete this.defines.WORLD_UNITS;
 
-				get: function () {
+		}
 
-					return this.uniforms.dashScale.value;
+	}
 
-				},
+	get linewidth() {
 
-				set: function ( value ) {
+		return this.uniforms.linewidth.value;
 
-					this.uniforms.dashScale.value = value;
+	}
 
-				}
+	set linewidth( value ) {
 
-			},
+		if ( ! this.uniforms.linewidth ) return;
+		this.uniforms.linewidth.value = value;
 
-			dashSize: {
+	}
 
-				enumerable: true,
+	get dashed() {
 
-				get: function () {
+		return 'USE_DASH' in this.defines;
 
-					return this.uniforms.dashSize.value;
+	}
 
-				},
+	set dashed( value ) {
 
-				set: function ( value ) {
+		if ( ( value === true ) !== this.dashed ) {
 
-					this.uniforms.dashSize.value = value;
+			this.needsUpdate = true;
 
-				}
+		}
 
-			},
+		if ( value === true ) {
 
-			dashOffset: {
+			this.defines.USE_DASH = '';
 
-				enumerable: true,
+		} else {
 
-				get: function () {
+			delete this.defines.USE_DASH;
 
-					return this.uniforms.dashOffset.value;
+		}
 
-				},
+	}
 
-				set: function ( value ) {
+	get dashScale() {
 
-					this.uniforms.dashOffset.value = value;
+		return this.uniforms.dashScale.value;
 
-				}
+	}
 
-			},
+	set dashScale( value ) {
 
-			gapSize: {
+		this.uniforms.dashScale.value = value;
 
-				enumerable: true,
+	}
 
-				get: function () {
+	get dashSize() {
 
-					return this.uniforms.gapSize.value;
+		return this.uniforms.dashSize.value;
 
-				},
+	}
 
-				set: function ( value ) {
+	set dashSize( value ) {
 
-					this.uniforms.gapSize.value = value;
+		this.uniforms.dashSize.value = value;
 
-				}
+	}
 
-			},
+	get dashOffset() {
 
-			opacity: {
+		return this.uniforms.dashOffset.value;
 
-				enumerable: true,
+	}
 
-				get: function () {
+	set dashOffset( value ) {
 
-					return this.uniforms.opacity.value;
+		this.uniforms.dashOffset.value = value;
 
-				},
+	}
 
-				set: function ( value ) {
+	get gapSize() {
 
-					this.uniforms.opacity.value = value;
+		return this.uniforms.gapSize.value;
 
-				}
+	}
 
-			},
+	set gapSize( value ) {
 
-			resolution: {
+		this.uniforms.gapSize.value = value;
 
-				enumerable: true,
+	}
 
-				get: function () {
+	get opacity() {
 
-					return this.uniforms.resolution.value;
+		return this.uniforms.opacity.value;
 
-				},
+	}
 
-				set: function ( value ) {
+	set opacity( value ) {
 
-					this.uniforms.resolution.value.copy( value );
+		if ( ! this.uniforms ) return;
+		this.uniforms.opacity.value = value;
 
-				}
+	}
 
-			},
+	get resolution() {
 
-			alphaToCoverage: {
+		return this.uniforms.resolution.value;
 
-				enumerable: true,
+	}
 
-				get: function () {
+	set resolution( value ) {
 
-					return Boolean( 'USE_ALPHA_TO_COVERAGE' in this.defines );
+		this.uniforms.resolution.value.copy( value );
 
-				},
+	}
 
-				set: function ( value ) {
+	get alphaToCoverage() {
 
-					if ( Boolean( value ) !== Boolean( 'USE_ALPHA_TO_COVERAGE' in this.defines ) ) {
+		return 'USE_ALPHA_TO_COVERAGE' in this.defines;
 
-						this.needsUpdate = true;
+	}
 
-					}
+	set alphaToCoverage( value ) {
 
-					if ( value === true ) {
+		if ( ! this.defines ) return;
 
-						this.defines.USE_ALPHA_TO_COVERAGE = '';
-						this.extensions.derivatives = true;
+		if ( ( value === true ) !== this.alphaToCoverage ) {
 
-					} else {
+			this.needsUpdate = true;
 
-						delete this.defines.USE_ALPHA_TO_COVERAGE;
-						this.extensions.derivatives = false;
+		}
 
-					}
+		if ( value === true ) {
 
-				}
+			this.defines.USE_ALPHA_TO_COVERAGE = '';
+			this.extensions.derivatives = true;
 
-			}
+		} else {
 
-		} );
+			delete this.defines.USE_ALPHA_TO_COVERAGE;
+			this.extensions.derivatives = false;
 
-		this.setValues( parameters );
+		}
 
 	}