|
@@ -277,6 +277,35 @@ ${ code }`;
|
|
|
|
|
|
}
|
|
|
|
|
|
+// Transform #properties to _properties until they're supported in bundlers
|
|
|
+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
|
|
|
+ };
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
export default [
|
|
|
{
|
|
|
input: 'src/Three.js',
|
|
@@ -284,6 +313,7 @@ export default [
|
|
|
addons(),
|
|
|
glconstants(),
|
|
|
glsl(),
|
|
|
+ privateProperties(),
|
|
|
header()
|
|
|
],
|
|
|
output: [
|