Skip to content

Commit c487993

Browse files
authored
Material: Use pseudo private variables. (#22443)
* Revert "Build: Transform private class properties in all bundles." This reverts commit 2aceae6. * Revert "Build: transform private class properties in the build script (#22441)" This reverts commit f69814c. * Material: Use pseudo private variables.
1 parent efa771f commit c487993

File tree

3 files changed

+15
-47
lines changed

3 files changed

+15
-47
lines changed

src/materials/Material.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ let materialId = 0;
66

77
class Material extends EventDispatcher {
88

9-
#alphaTest = 0;
10-
119
constructor() {
1210

1311
super();
@@ -76,23 +74,25 @@ class Material extends EventDispatcher {
7674

7775
this.version = 0;
7876

77+
this._alphaTest = 0;
78+
7979
}
8080

8181
get alphaTest() {
8282

83-
return this.#alphaTest;
83+
return this._alphaTest;
8484

8585
}
8686

8787
set alphaTest( value ) {
8888

89-
if ( this.#alphaTest > 0 !== value > 0 ) {
89+
if ( this._alphaTest > 0 !== value > 0 ) {
9090

9191
this.version ++;
9292

9393
}
9494

95-
this.#alphaTest = value;
95+
this._alphaTest = value;
9696

9797
}
9898

src/materials/MeshPhysicalMaterial.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ import * as MathUtils from '../math/MathUtils.js';
3434

3535
class MeshPhysicalMaterial extends MeshStandardMaterial {
3636

37-
#clearcoat = 0;
38-
#transmission = 0;
39-
4037
constructor( parameters ) {
4138

4239
super();
@@ -86,43 +83,47 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
8683
this.specularTint = new Color( 1, 1, 1 );
8784
this.specularTintMap = null;
8885

86+
this._clearcoat = 0;
87+
this._transmission = 0;
88+
89+
8990
this.setValues( parameters );
9091

9192
}
9293

9394
get clearcoat() {
9495

95-
return this.#clearcoat;
96+
return this._clearcoat;
9697

9798
}
9899

99100
set clearcoat( value ) {
100101

101-
if ( this.#clearcoat > 0 !== value > 0 ) {
102+
if ( this._clearcoat > 0 !== value > 0 ) {
102103

103104
this.version ++;
104105

105106
}
106107

107-
this.#clearcoat = value;
108+
this._clearcoat = value;
108109

109110
}
110111

111112
get transmission() {
112113

113-
return this.#transmission;
114+
return this._transmission;
114115

115116
}
116117

117118
set transmission( value ) {
118119

119-
if ( this.#transmission > 0 !== value > 0 ) {
120+
if ( this._transmission > 0 !== value > 0 ) {
120121

121122
this.version ++;
122123

123124
}
124125

125-
this.#transmission = value;
126+
this._transmission = value;
126127

127128
}
128129

utils/build/rollup.config.js

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -277,44 +277,13 @@ ${ code }`;
277277

278278
}
279279

280-
// Transform #properties to _properties until they're supported in bundlers
281-
// https://github.com/mrdoob/three.js/issues/22437
282-
function privateProperties() {
283-
284-
return {
285-
286-
transform( code, id ) {
287-
288-
if ( /\.glsl.js$/.test( id ) === true ) return;
289-
290-
// replace `#property =` with `_property =`
291-
code = code.replace( /#(\w+) =/g, ( match, p1 ) => `_${p1} =` );
292-
293-
// replace `#property;` with `_property;`
294-
code = code.replace( /#(\w+);/g, ( match, p1 ) => `_${p1};` );
295-
296-
// replace `this.#property` with `this._property`
297-
code = code.replace( /this\.#(\w+)/g, ( match, p1 ) => `this._${p1}` );
298-
299-
return {
300-
code: code,
301-
map: null
302-
};
303-
304-
}
305-
306-
};
307-
308-
}
309-
310280
let builds = [
311281
{
312282
input: 'src/Three.js',
313283
plugins: [
314284
addons(),
315285
glconstants(),
316286
glsl(),
317-
privateProperties(),
318287
header()
319288
],
320289
output: [
@@ -329,7 +298,6 @@ let builds = [
329298
plugins: [
330299
addons(),
331300
glsl(),
332-
privateProperties(),
333301
babel( {
334302
babelHelpers: 'bundled',
335303
compact: false,
@@ -354,7 +322,6 @@ let builds = [
354322
addons(),
355323
glconstants(),
356324
glsl(),
357-
privateProperties(),
358325
babel( {
359326
babelHelpers: 'bundled',
360327
babelrc: false,

0 commit comments

Comments
 (0)