未验证 提交 c4879934 编写于 作者: M Michael Herzog 提交者: GitHub

Material: Use pseudo private variables. (#22443)

* Revert "Build: Transform private class properties in all bundles."

This reverts commit 2aceae6f.

* Revert "Build: transform private class properties in the build script (#22441)"

This reverts commit f69814c1.

* Material: Use pseudo private variables.
上级 efa771f1
......@@ -6,8 +6,6 @@ let materialId = 0;
class Material extends EventDispatcher {
#alphaTest = 0;
constructor() {
super();
......@@ -76,23 +74,25 @@ class Material extends EventDispatcher {
this.version = 0;
this._alphaTest = 0;
}
get alphaTest() {
return this.#alphaTest;
return this._alphaTest;
}
set alphaTest( value ) {
if ( this.#alphaTest > 0 !== value > 0 ) {
if ( this._alphaTest > 0 !== value > 0 ) {
this.version ++;
}
this.#alphaTest = value;
this._alphaTest = value;
}
......
......@@ -34,9 +34,6 @@ import * as MathUtils from '../math/MathUtils.js';
class MeshPhysicalMaterial extends MeshStandardMaterial {
#clearcoat = 0;
#transmission = 0;
constructor( parameters ) {
super();
......@@ -86,43 +83,47 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
this.specularTint = new Color( 1, 1, 1 );
this.specularTintMap = null;
this._clearcoat = 0;
this._transmission = 0;
this.setValues( parameters );
}
get clearcoat() {
return this.#clearcoat;
return this._clearcoat;
}
set clearcoat( value ) {
if ( this.#clearcoat > 0 !== value > 0 ) {
if ( this._clearcoat > 0 !== value > 0 ) {
this.version ++;
}
this.#clearcoat = value;
this._clearcoat = value;
}
get transmission() {
return this.#transmission;
return this._transmission;
}
set transmission( value ) {
if ( this.#transmission > 0 !== value > 0 ) {
if ( this._transmission > 0 !== value > 0 ) {
this.version ++;
}
this.#transmission = value;
this._transmission = value;
}
......
......@@ -277,36 +277,6 @@ ${ code }`;
}
// Transform #properties to _properties until they're supported in bundlers
// https://github.com/mrdoob/three.js/issues/22437
function privateProperties() {
return {
transform( code, id ) {
if ( /\.glsl.js$/.test( id ) === true ) return;
// replace `#property =` with `_property =`
code = code.replace( /#(\w+) =/g, ( match, p1 ) => `_${p1} =` );
// replace `#property;` with `_property;`
code = code.replace( /#(\w+);/g, ( match, p1 ) => `_${p1};` );
// replace `this.#property` with `this._property`
code = code.replace( /this\.#(\w+)/g, ( match, p1 ) => `this._${p1}` );
return {
code: code,
map: null
};
}
};
}
let builds = [
{
input: 'src/Three.js',
......@@ -314,7 +284,6 @@ let builds = [
addons(),
glconstants(),
glsl(),
privateProperties(),
header()
],
output: [
......@@ -329,7 +298,6 @@ let builds = [
plugins: [
addons(),
glsl(),
privateProperties(),
babel( {
babelHelpers: 'bundled',
compact: false,
......@@ -354,7 +322,6 @@ let builds = [
addons(),
glconstants(),
glsl(),
privateProperties(),
babel( {
babelHelpers: 'bundled',
babelrc: false,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册