Browse Source

Remove JS syntax > ECMA 2018 (#25172)

* Remove JS snytax > ECMA2018

* NodeBuilder: Fix hasGeometryAttribute().

* Update NodeBuilder.js

* Remove static fields.
Michael Herzog 2 years ago
parent
commit
197ccfef69
41 changed files with 216 additions and 203 deletions
  1. 4 4
      examples/jsm/exporters/GLTFExporter.js
  2. 0 0
      examples/jsm/libs/flow.module.js
  3. 9 3
      examples/jsm/loaders/MaterialXLoader.js
  4. 22 22
      examples/jsm/loaders/SVGLoader.js
  5. 1 1
      examples/jsm/misc/GPUComputationRenderer.js
  6. 5 5
      examples/jsm/nodes/accessors/BitangentNode.js
  7. 2 2
      examples/jsm/nodes/accessors/CameraNode.js
  8. 1 1
      examples/jsm/nodes/accessors/CubeTextureNode.js
  9. 13 13
      examples/jsm/nodes/accessors/MaterialNode.js
  10. 5 5
      examples/jsm/nodes/accessors/NormalNode.js
  11. 6 6
      examples/jsm/nodes/accessors/Object3DNode.js
  12. 7 7
      examples/jsm/nodes/accessors/PositionNode.js
  13. 5 5
      examples/jsm/nodes/accessors/TangentNode.js
  14. 2 2
      examples/jsm/nodes/accessors/TextureNode.js
  15. 7 2
      examples/jsm/nodes/core/InputNode.js
  16. 6 6
      examples/jsm/nodes/core/Node.js
  17. 1 1
      examples/jsm/nodes/core/NodeBuilder.js
  18. 7 7
      examples/jsm/nodes/core/NodeUtils.js
  19. 5 5
      examples/jsm/nodes/display/BlendModeNode.js
  20. 4 4
      examples/jsm/nodes/display/ColorAdjustmentNode.js
  21. 3 3
      examples/jsm/nodes/display/ColorSpaceNode.js
  22. 7 7
      examples/jsm/nodes/display/ViewportNode.js
  23. 1 1
      examples/jsm/nodes/lighting/DirectionalLightNode.js
  24. 3 3
      examples/jsm/nodes/lighting/LightingContextNode.js
  25. 1 1
      examples/jsm/nodes/lighting/PointLightNode.js
  26. 2 2
      examples/jsm/nodes/lighting/SpotLightNode.js
  27. 7 5
      examples/jsm/nodes/materials/NodeMaterial.js
  28. 1 1
      examples/jsm/nodes/materials/SpriteNodeMaterial.js
  29. 52 52
      examples/jsm/nodes/math/MathNode.js
  30. 1 1
      examples/jsm/nodes/shadernode/ShaderNode.js
  31. 2 2
      examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js
  32. 2 2
      examples/jsm/nodes/utils/MaxMipLevelNode.js
  33. 5 5
      examples/jsm/nodes/utils/OscNode.js
  34. 6 6
      examples/jsm/nodes/utils/TimerNode.js
  35. 3 3
      examples/jsm/objects/GroundProjectedEnv.js
  36. 1 1
      examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js
  37. 1 1
      examples/jsm/renderers/webgpu/WebGPURenderer.js
  38. 2 2
      examples/jsm/renderers/webgpu/WebGPUTextures.js
  39. 1 1
      examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js
  40. 1 1
      examples/webgl_animation_skinning_ik.html
  41. 2 2
      examples/webxr_vr_handinput_pressbutton.html

+ 4 - 4
examples/jsm/exporters/GLTFExporter.js

@@ -746,11 +746,11 @@ class GLTFWriter {
 
 		console.warn( 'THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.' );
 
-		const metalness = metalnessMap?.image;
-		const roughness = roughnessMap?.image;
+		const metalness = metalnessMap ? metalnessMap.image : null;
+		const roughness = roughnessMap ? roughnessMap.image : null;
 
-		const width = Math.max( metalness?.width || 0, roughness?.width || 0 );
-		const height = Math.max( metalness?.height || 0, roughness?.height || 0 );
+		const width = Math.max( metalness ? metalness.width : 0, roughness ? roughness.width : 0 );
+		const height = Math.max( metalness ? metalness.height : 0, roughness ? roughness.height : 0 );
 
 		const canvas = getCanvas();
 		canvas.width = width;

File diff suppressed because it is too large
+ 0 - 0
examples/jsm/libs/flow.module.js


+ 9 - 3
examples/jsm/loaders/MaterialXLoader.js

@@ -340,7 +340,11 @@ class MaterialXNode {
 
 		let node = this.node;
 
-		if ( node !== null ) { return node; }
+		if ( node !== null ) {
+
+			return node;
+
+		}
 
 		//
 
@@ -478,7 +482,9 @@ class MaterialXNode {
 
 	getNodeByName( name ) {
 
-		return this.getChildByName( name )?.getNode();
+		const child = this.getChildByName( name );
+
+		return child ? child.getNode() : undefined;
 
 	}
 
@@ -681,7 +687,7 @@ class MaterialX {
 
 	}
 
-    /*getMaterialXNodeFromXML( xmlNode ) {
+	/*getMaterialXNodeFromXML( xmlNode ) {
 
         return this.nodesXRefLib.get( xmlNode );
 

+ 22 - 22
examples/jsm/loaders/SVGLoader.js

@@ -1600,7 +1600,7 @@ class SVGLoader extends Loader {
 				const sinTheta = Math.sin( curve.aRotation );
 
 				const v1 = new Vector3( a * cosTheta, a * sinTheta, 0 );
-				const v2 = new Vector3( -b * sinTheta, b * cosTheta, 0 );
+				const v2 = new Vector3( - b * sinTheta, b * cosTheta, 0 );
 
 				const f1 = v1.applyMatrix3( m );
 				const f2 = v2.applyMatrix3( m );
@@ -1608,7 +1608,7 @@ class SVGLoader extends Loader {
 				const mF = tempTransform0.set(
 					f1.x, f2.x, 0,
 					f1.y, f2.y, 0,
-					0,    0,    1,
+					0, 0, 1,
 				);
 
 				const mFInv = tempTransform1.copy( mF ).invert();
@@ -1616,7 +1616,7 @@ class SVGLoader extends Loader {
 				const mQ = mFInvT.multiply( mFInv );
 				const mQe = mQ.elements;
 
-				const ed = eigenDecomposition( mQe[0], mQe[1], mQe[4] );
+				const ed = eigenDecomposition( mQe[ 0 ], mQe[ 1 ], mQe[ 4 ] );
 				const rt1sqrt = Math.sqrt( ed.rt1 );
 				const rt2sqrt = Math.sqrt( ed.rt2 );
 
@@ -1630,18 +1630,18 @@ class SVGLoader extends Loader {
 				// Do not touch angles of a full ellipse because after transformation they
 				// would converge to a sinle value effectively removing the whole curve
 
-				if ( !isFullEllipse ) {
+				if ( ! isFullEllipse ) {
 
 					const mDsqrt = tempTransform1.set(
 						rt1sqrt, 0, 0,
 						0, rt2sqrt, 0,
-						0, 0,       1,
+						0, 0, 1,
 					);
 
 					const mRT = tempTransform2.set(
-						ed.cs,  ed.sn, 0,
-						-ed.sn, ed.cs, 0,
-						0,      0,     1,
+						ed.cs, ed.sn, 0,
+						- ed.sn, ed.cs, 0,
+						0, 0, 1,
 					);
 
 					const mDRF = mDsqrt.multiply( mRT ).multiply( mF );
@@ -1660,7 +1660,7 @@ class SVGLoader extends Loader {
 
 					if ( isTransformFlipped( m ) ) {
 
-						curve.aClockwise = !curve.aClockwise;
+						curve.aClockwise = ! curve.aClockwise;
 
 					}
 
@@ -1688,16 +1688,16 @@ class SVGLoader extends Loader {
 				// `sx`, `sy`, or both might be zero.
 				const theta =
 					sx > Number.EPSILON
-					? Math.atan2( m.elements[ 1 ], m.elements[ 0 ] )
-					: Math.atan2( - m.elements[ 3 ], m.elements[ 4 ] );
+						? Math.atan2( m.elements[ 1 ], m.elements[ 0 ] )
+						: Math.atan2( - m.elements[ 3 ], m.elements[ 4 ] );
 
 				curve.aRotation += theta;
 
 				if ( isTransformFlipped( m ) ) {
 
-					curve.aStartAngle *= -1;
-					curve.aEndAngle *= -1;
-					curve.aClockwise = !curve.aClockwise;
+					curve.aStartAngle *= - 1;
+					curve.aEndAngle *= - 1;
+					curve.aClockwise = ! curve.aClockwise;
 
 				}
 
@@ -1829,7 +1829,7 @@ class SVGLoader extends Loader {
 				// This case needs to be treated separately to avoid div by 0
 
 				rt1 = 0.5 * rt;
-				rt2 = -0.5 * rt;
+				rt2 = - 0.5 * rt;
 
 			}
 
@@ -1847,7 +1847,7 @@ class SVGLoader extends Loader {
 
 			if ( Math.abs( cs ) > 2 * Math.abs( B ) ) {
 
-				t = -2 * B / cs;
+				t = - 2 * B / cs;
 				sn = 1 / Math.sqrt( 1 + t * t );
 				cs = t * sn;
 
@@ -1858,7 +1858,7 @@ class SVGLoader extends Loader {
 
 			} else {
 
-				t = -0.5 * cs / B;
+				t = - 0.5 * cs / B;
 				cs = 1 / Math.sqrt( 1 + t * t );
 				sn = t * cs;
 
@@ -1867,7 +1867,7 @@ class SVGLoader extends Loader {
 			if ( df > 0 ) {
 
 				t = cs;
-				cs = -sn;
+				cs = - sn;
 				sn = t;
 
 			}
@@ -2311,20 +2311,20 @@ class SVGLoader extends Loader {
 
 			}
 
-			return { curves: p.curves, points: points, isCW: ShapeUtils.isClockWise( points ), identifier: -1, boundingBox: new Box2( new Vector2( minX, minY ), new Vector2( maxX, maxY ) ) };
+			return { curves: p.curves, points: points, isCW: ShapeUtils.isClockWise( points ), identifier: - 1, boundingBox: new Box2( new Vector2( minX, minY ), new Vector2( maxX, maxY ) ) };
 
 		} );
 
 		simplePaths = simplePaths.filter( sp => sp.points.length > 1 );
 
-		for ( let identifier = 0; identifier < simplePaths.length; identifier++ ) {
+		for ( let identifier = 0; identifier < simplePaths.length; identifier ++ ) {
 
-			simplePaths[identifier].identifier = identifier;
+			simplePaths[ identifier ].identifier = identifier;
 
 		}
 
 		// check if path is solid or a hole
-		const isAHole = simplePaths.map( p => isHoleTo( p, simplePaths, scanlineMinX, scanlineMaxX, shapePath.userData?.style.fillRule ) );
+		const isAHole = simplePaths.map( p => isHoleTo( p, simplePaths, scanlineMinX, scanlineMaxX, ( shapePath.userData ? shapePath.userData.style.fillRule : undefined ) ) );
 
 
 		const shapesToReturn = [];

+ 1 - 1
examples/jsm/misc/GPUComputationRenderer.js

@@ -301,7 +301,7 @@ class GPUComputationRenderer {
 
 				const variable = variables[ i ];
 
-				variable.initialValueTexture?.dispose();
+				if ( variable.initialValueTexture ) variable.initialValueTexture.dispose();
 
 				const renderTargets = variable.renderTargets;
 

+ 5 - 5
examples/jsm/nodes/accessors/BitangentNode.js

@@ -8,11 +8,6 @@ import TangentNode from './TangentNode.js';
 
 class BitangentNode extends Node {
 
-	static GEOMETRY = 'geometry';
-	static LOCAL = 'local';
-	static VIEW = 'view';
-	static WORLD = 'world';
-
 	constructor( scope = BitangentNode.LOCAL ) {
 
 		super( 'vec3' );
@@ -59,4 +54,9 @@ class BitangentNode extends Node {
 
 }
 
+BitangentNode.GEOMETRY = 'geometry';
+BitangentNode.LOCAL = 'local';
+BitangentNode.VIEW = 'view';
+BitangentNode.WORLD = 'world';
+
 export default BitangentNode;

+ 2 - 2
examples/jsm/nodes/accessors/CameraNode.js

@@ -2,8 +2,6 @@ import Object3DNode from './Object3DNode.js';
 
 class CameraNode extends Object3DNode {
 
-	static PROJECTION_MATRIX = 'projectionMatrix';
-
 	constructor( scope = CameraNode.POSITION ) {
 
 		super( scope );
@@ -64,4 +62,6 @@ class CameraNode extends Object3DNode {
 
 }
 
+CameraNode.PROJECTION_MATRIX = 'projectionMatrix';
+
 export default CameraNode;

+ 1 - 1
examples/jsm/nodes/accessors/CubeTextureNode.js

@@ -70,7 +70,7 @@ class CubeTextureNode extends TextureNode {
 
 				let snippet = null;
 
-				if ( levelNode?.isNode === true) {
+				if ( levelNode && levelNode.isNode === true ) {
 
 					const levelSnippet = levelNode.build( builder, 'float' );
 

+ 13 - 13
examples/jsm/nodes/accessors/MaterialNode.js

@@ -6,14 +6,6 @@ import SplitNode from '../utils/SplitNode.js';
 
 class MaterialNode extends Node {
 
-	static ALPHA_TEST = 'alphaTest';
-	static COLOR = 'color';
-	static OPACITY = 'opacity';
-	static ROUGHNESS = 'roughness';
-	static METALNESS = 'metalness';
-	static EMISSIVE = 'emissive';
-	static ROTATION = 'rotation';
-
 	constructor( scope = MaterialNode.COLOR ) {
 
 		super();
@@ -62,7 +54,7 @@ class MaterialNode extends Node {
 
 			const colorNode = new MaterialReferenceNode( 'color', 'color' );
 
-			if ( material.map?.isTexture === true ) {
+			if ( material.map && material.map.isTexture === true ) {
 
 				//new MaterialReferenceNode( 'map', 'texture' )
 				const map = new TextureNode( material.map );
@@ -79,7 +71,7 @@ class MaterialNode extends Node {
 
 			const opacityNode = new MaterialReferenceNode( 'opacity', 'float' );
 
-			if ( material.alphaMap?.isTexture === true ) {
+			if ( material.alphaMap && material.alphaMap.isTexture === true ) {
 
 				node = new OperatorNode( '*', opacityNode, new MaterialReferenceNode( 'alphaMap', 'texture' ) );
 
@@ -93,7 +85,7 @@ class MaterialNode extends Node {
 
 			const roughnessNode = new MaterialReferenceNode( 'roughness', 'float' );
 
-			if ( material.roughnessMap?.isTexture === true ) {
+			if ( material.roughnessMap && material.roughnessMap.isTexture === true ) {
 
 				node = new OperatorNode( '*', roughnessNode, new SplitNode( new TextureNode( material.roughnessMap ), 'g' ) );
 
@@ -107,7 +99,7 @@ class MaterialNode extends Node {
 
 			const metalnessNode = new MaterialReferenceNode( 'metalness', 'float' );
 
-			if ( material.metalnessMap?.isTexture === true ) {
+			if ( material.metalnessMap && material.metalnessMap.isTexture === true ) {
 
 				node = new OperatorNode( '*', metalnessNode, new SplitNode( new TextureNode( material.metalnessMap ), 'b' ) );
 
@@ -121,7 +113,7 @@ class MaterialNode extends Node {
 
 			const emissiveNode = new MaterialReferenceNode( 'emissive', 'color' );
 
-			if ( material.emissiveMap?.isTexture === true ) {
+			if ( material.emissiveMap && material.emissiveMap.isTexture === true ) {
 
 				node = new OperatorNode( '*', emissiveNode, new TextureNode( material.emissiveMap ) );
 
@@ -149,4 +141,12 @@ class MaterialNode extends Node {
 
 }
 
+MaterialNode.ALPHA_TEST = 'alphaTest';
+MaterialNode.COLOR = 'color';
+MaterialNode.OPACITY = 'opacity';
+MaterialNode.ROUGHNESS = 'roughness';
+MaterialNode.METALNESS = 'metalness';
+MaterialNode.EMISSIVE = 'emissive';
+MaterialNode.ROTATION = 'rotation';
+
 export default MaterialNode;

+ 5 - 5
examples/jsm/nodes/accessors/NormalNode.js

@@ -8,11 +8,6 @@ import MathNode from '../math/MathNode.js';
 
 class NormalNode extends Node {
 
-	static GEOMETRY = 'geometry';
-	static LOCAL = 'local';
-	static VIEW = 'view';
-	static WORLD = 'world';
-
 	constructor( scope = NormalNode.LOCAL ) {
 
 		super( 'vec3' );
@@ -82,4 +77,9 @@ class NormalNode extends Node {
 
 }
 
+NormalNode.GEOMETRY = 'geometry';
+NormalNode.LOCAL = 'local';
+NormalNode.VIEW = 'view';
+NormalNode.WORLD = 'world';
+
 export default NormalNode;

+ 6 - 6
examples/jsm/nodes/accessors/Object3DNode.js

@@ -5,12 +5,6 @@ import { NodeUpdateType } from '../core/constants.js';
 
 class Object3DNode extends Node {
 
-	static VIEW_MATRIX = 'viewMatrix';
-	static NORMAL_MATRIX = 'normalMatrix';
-	static WORLD_MATRIX = 'worldMatrix';
-	static POSITION = 'position';
-	static VIEW_POSITION = 'viewPosition';
-
 	constructor( scope = Object3DNode.VIEW_MATRIX, object3d = null ) {
 
 		super();
@@ -119,4 +113,10 @@ class Object3DNode extends Node {
 
 }
 
+Object3DNode.VIEW_MATRIX = 'viewMatrix';
+Object3DNode.NORMAL_MATRIX = 'normalMatrix';
+Object3DNode.WORLD_MATRIX = 'worldMatrix';
+Object3DNode.POSITION = 'position';
+Object3DNode.VIEW_POSITION = 'viewPosition';
+
 export default Object3DNode;

+ 7 - 7
examples/jsm/nodes/accessors/PositionNode.js

@@ -7,13 +7,6 @@ import OperatorNode from '../math/OperatorNode.js';
 
 class PositionNode extends Node {
 
-	static GEOMETRY = 'geometry';
-	static LOCAL = 'local';
-	static WORLD = 'world';
-	static WORLD_DIRECTION = 'worldDirection';
-	static VIEW = 'view';
-	static VIEW_DIRECTION = 'viewDirection';
-
 	constructor( scope = PositionNode.LOCAL ) {
 
 		super( 'vec3' );
@@ -92,4 +85,11 @@ class PositionNode extends Node {
 
 }
 
+PositionNode.GEOMETRY = 'geometry';
+PositionNode.LOCAL = 'local';
+PositionNode.WORLD = 'world';
+PositionNode.WORLD_DIRECTION = 'worldDirection';
+PositionNode.VIEW = 'view';
+PositionNode.VIEW_DIRECTION = 'viewDirection';
+
 export default PositionNode;

+ 5 - 5
examples/jsm/nodes/accessors/TangentNode.js

@@ -9,11 +9,6 @@ import SplitNode from '../utils/SplitNode.js';
 
 class TangentNode extends Node {
 
-	static GEOMETRY = 'geometry';
-	static LOCAL = 'local';
-	static VIEW = 'view';
-	static WORLD = 'world';
-
 	constructor( scope = TangentNode.LOCAL ) {
 
 		super();
@@ -92,4 +87,9 @@ class TangentNode extends Node {
 
 }
 
+TangentNode.GEOMETRY = 'geometry';
+TangentNode.LOCAL = 'local';
+TangentNode.VIEW = 'view';
+TangentNode.WORLD = 'world';
+
 export default TangentNode;

+ 2 - 2
examples/jsm/nodes/accessors/TextureNode.js

@@ -46,7 +46,7 @@ class TextureNode extends UniformNode {
 
 		if ( uvNode === null && builder.context.getUVNode ) {
 
-			uvNode = builder.context.getUVNode( this )
+			uvNode = builder.context.getUVNode( this );
 
 		}
 
@@ -106,7 +106,7 @@ class TextureNode extends UniformNode {
 
 				let snippet = null;
 
-				if ( levelNode?.isNode === true) {
+				if ( levelNode && levelNode.isNode === true ) {
 
 					const levelSnippet = levelNode.build( builder, 'float' );
 

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

@@ -35,7 +35,10 @@ class InputNode extends Node {
 
 		super.serialize( data );
 
-		data.value = this.value?.toArray?.() || this.value;
+		data.value = this.value;
+
+		if ( this.value && this.value.toArray ) data.value = this.value.toArray();
+
 		data.valueType = getValueType( this.value );
 		data.nodeType = this.nodeType;
 
@@ -47,7 +50,9 @@ class InputNode extends Node {
 
 		this.nodeType = data.nodeType;
 		this.value = getValueFromType( data.valueType );
-		this.value = this.value?.fromArray?.( data.value ) || data.value;
+		this.value = data.value;
+
+		if ( this.value && this.value.fromArray ) this.value = this.value.fromArray( data.value );
 
 	}
 

+ 6 - 6
examples/jsm/nodes/core/Node.js

@@ -44,7 +44,7 @@ class Node {
 
 				for ( const child of object ) {
 
-					if ( child?.isNode === true ) {
+					if ( child && child.isNode === true ) {
 
 						children.push( child );
 
@@ -52,7 +52,7 @@ class Node {
 
 				}
 
-			} else if ( object?.isNode === true ) {
+			} else if ( object && object.isNode === true ) {
 
 				children.push( object );
 
@@ -62,7 +62,7 @@ class Node {
 
 					const child = object[ property ];
 
-					if ( child?.isNode === true ) {
+					if ( child && child.isNode === true ) {
 
 						children.push( child );
 
@@ -139,7 +139,7 @@ class Node {
 
 			for ( const childNode of Object.values( nodeProperties ) ) {
 
-				if ( childNode?.isNode === true ) {
+				if ( childNode && childNode.isNode === true ) {
 
 					childNode.build( builder );
 
@@ -155,7 +155,7 @@ class Node {
 
 		const { outputNode } = builder.getNodeProperties( this );
 
-		if ( outputNode?.isNode === true ) {
+		if ( outputNode && outputNode.isNode === true ) {
 
 			return outputNode.build( builder, output );
 
@@ -202,7 +202,7 @@ class Node {
 
 				for ( const childNode of Object.values( properties ) ) {
 
-					if ( childNode?.isNode === true ) {
+					if ( childNode && childNode.isNode === true ) {
 
 						childNode.build( builder );
 

+ 1 - 1
examples/jsm/nodes/core/NodeBuilder.js

@@ -297,7 +297,7 @@ class NodeBuilder {
 
 	hasGeometryAttribute( name ) {
 
-		return this.geometry?.getAttribute( name ) !== undefined;
+		return this.geometry && this.geometry.getAttribute( name ) !== undefined;
 
 	}
 

+ 7 - 7
examples/jsm/nodes/core/NodeUtils.js

@@ -52,27 +52,27 @@ export const getValueType = ( value ) => {
 
 		return 'bool';
 
-	} else if ( value?.isVector2 === true ) {
+	} else if ( value && value.isVector2 === true ) {
 
 		return 'vec2';
 
-	} else if ( value?.isVector3 === true ) {
+	} else if ( value && value.isVector3 === true ) {
 
 		return 'vec3';
 
-	} else if ( value?.isVector4 === true ) {
+	} else if ( value && value.isVector4 === true ) {
 
 		return 'vec4';
 
-	} else if ( value?.isMatrix3 === true ) {
+	} else if ( value && value.isMatrix3 === true ) {
 
 		return 'mat3';
 
-	} else if ( value?.isMatrix4 === true ) {
+	} else if ( value && value.isMatrix4 === true ) {
 
 		return 'mat4';
 
-	} else if ( value?.isColor === true ) {
+	} else if ( value && value.isColor === true ) {
 
 		return 'color';
 
@@ -84,7 +84,7 @@ export const getValueType = ( value ) => {
 
 export const getValueFromType = ( type, ...params ) => {
 
-	const last4 = type?.slice( - 4 );
+	const last4 = type ? type.slice( - 4 ) : undefined;
 
 	if ( type === 'color' ) {
 

+ 5 - 5
examples/jsm/nodes/display/BlendModeNode.js

@@ -35,11 +35,6 @@ export const OverlayNode = new ShaderNode( ( { base, blend } ) => {
 
 class BlendModeNode extends TempNode {
 
-	static BURN = 'burn';
-	static DODGE = 'dodge';
-	static SCREEN = 'screen';
-	static OVERLAY = 'overlay';
-
 	constructor( blendMode, baseNode, blendNode ) {
 
 		super();
@@ -82,4 +77,9 @@ class BlendModeNode extends TempNode {
 
 }
 
+BlendModeNode.BURN = 'burn';
+BlendModeNode.DODGE = 'dodge';
+BlendModeNode.SCREEN = 'screen';
+BlendModeNode.OVERLAY = 'overlay';
+
 export default BlendModeNode;

+ 4 - 4
examples/jsm/nodes/display/ColorAdjustmentNode.js

@@ -34,10 +34,6 @@ const hueNode = new ShaderNode( ( { color, adjustment } ) => {
 
 class ColorAdjustmentNode extends TempNode {
 
-	static SATURATION = 'saturation';
-	static VIBRANCE = 'vibrance';
-	static HUE = 'hue';
-
 	constructor( method, colorNode, adjustmentNode = float( 1 ) ) {
 
 		super( 'vec3' );
@@ -81,4 +77,8 @@ class ColorAdjustmentNode extends TempNode {
 
 }
 
+ColorAdjustmentNode.SATURATION = 'saturation';
+ColorAdjustmentNode.VIBRANCE = 'vibrance';
+ColorAdjustmentNode.HUE = 'hue';
+
 export default ColorAdjustmentNode;

+ 3 - 3
examples/jsm/nodes/display/ColorSpaceNode.js

@@ -32,9 +32,6 @@ const EncodingLib = {
 
 class ColorSpaceNode extends TempNode {
 
-	static LINEAR_TO_LINEAR = 'LinearToLinear';
-	static LINEAR_TO_SRGB = 'LinearTosRGB';
-
 	constructor( method, node ) {
 
 		super( 'vec4' );
@@ -92,4 +89,7 @@ class ColorSpaceNode extends TempNode {
 
 }
 
+ColorSpaceNode.LINEAR_TO_LINEAR = 'LinearToLinear';
+ColorSpaceNode.LINEAR_TO_SRGB = 'LinearTosRGB';
+
 export default ColorSpaceNode;

+ 7 - 7
examples/jsm/nodes/display/ViewportNode.js

@@ -7,13 +7,6 @@ let resolution;
 
 class ViewportNode extends Node {
 
-	static COORDINATE = 'coordinate';
-	static RESOLUTION = 'resolution';
-	static TOP_LEFT = 'topLeft';
-	static BOTTOM_LEFT = 'bottomLeft';
-	static TOP_RIGHT = 'topRight';
-	static BOTTOM_RIGHT = 'bottomRight';
-
 	constructor( scope ) {
 
 		super();
@@ -103,4 +96,11 @@ class ViewportNode extends Node {
 
 }
 
+ViewportNode.COORDINATE = 'coordinate';
+ViewportNode.RESOLUTION = 'resolution';
+ViewportNode.TOP_LEFT = 'topLeft';
+ViewportNode.BOTTOM_LEFT = 'bottomLeft';
+ViewportNode.TOP_RIGHT = 'topRight';
+ViewportNode.BOTTOM_RIGHT = 'bottomRight';
+
 export default ViewportNode;

+ 1 - 1
examples/jsm/nodes/lighting/DirectionalLightNode.js

@@ -31,7 +31,7 @@ class DirectionalLightNode extends AnalyticLightNode {
 		const lightingModelFunctionNode = builder.context.lightingModelNode;
 		const reflectedLight = builder.context.reflectedLight;
 
-		if ( lightingModelFunctionNode?.direct ) {
+		if ( lightingModelFunctionNode && lightingModelFunctionNode.direct ) {
 
 			lightingModelFunctionNode.direct.call( {
 				lightDirection,

+ 3 - 3
examples/jsm/nodes/lighting/LightingContextNode.js

@@ -51,9 +51,9 @@ class LightingContextNode extends ContextNode {
 		context.reflectedLight = reflectedLight;
 		context.lightingModelNode = lightingModelNode || context.lightingModelNode;
 
-		if ( lightingModelNode?.indirectDiffuse ) lightingModelNode.indirectDiffuse.call( context );
-		if ( lightingModelNode?.indirectSpecular ) lightingModelNode.indirectSpecular.call( context );
-		if ( lightingModelNode?.ambientOcclusion ) lightingModelNode.ambientOcclusion.call( context );
+		if ( lightingModelNode && lightingModelNode.indirectDiffuse ) lightingModelNode.indirectDiffuse.call( context );
+		if ( lightingModelNode && lightingModelNode.indirectSpecular ) lightingModelNode.indirectSpecular.call( context );
+		if ( lightingModelNode && lightingModelNode.ambientOcclusion ) lightingModelNode.ambientOcclusion.call( context );
 
 		return super.construct( builder );
 

+ 1 - 1
examples/jsm/nodes/lighting/PointLightNode.js

@@ -47,7 +47,7 @@ class PointLightNode extends AnalyticLightNode {
 		const lightingModelFunctionNode = builder.context.lightingModelNode;
 		const reflectedLight = builder.context.reflectedLight;
 
-		if ( lightingModelFunctionNode?.direct ) {
+		if ( lightingModelFunctionNode && lightingModelFunctionNode.direct ) {
 
 			lightingModelFunctionNode.direct.call( {
 				lightDirection,

+ 2 - 2
examples/jsm/nodes/lighting/SpotLightNode.js

@@ -47,7 +47,7 @@ class SpotLightNode extends AnalyticLightNode {
 		const lVector = objectViewPosition( light ).sub( positionView );
 
 		const lightDirection = lVector.normalize();
-		const angleCos = lightDirection.dot( this.directionNode )
+		const angleCos = lightDirection.dot( this.directionNode );
 		const spotAttenuation = getSpotAttenuation( this.coneCosNode, this.penumbraCosNode, angleCos );
 
 		const lightDistance = lVector.length();
@@ -65,7 +65,7 @@ class SpotLightNode extends AnalyticLightNode {
 		const lightingModelFunctionNode = builder.context.lightingModelNode;
 		const reflectedLight = builder.context.reflectedLight;
 
-		if ( lightingModelFunctionNode?.direct ) {
+		if ( lightingModelFunctionNode && lightingModelFunctionNode.direct ) {
 
 			lightingModelFunctionNode.direct.call( {
 				lightDirection,

+ 7 - 5
examples/jsm/nodes/materials/NodeMaterial.js

@@ -55,7 +55,7 @@ class NodeMaterial extends ShaderMaterial {
 
 		}
 
-		if ( object.instanceMatrix?.isInstancedBufferAttribute === true && builder.isAvailable( 'instance' ) === true ) {
+		if ( ( object.instanceMatrix && object.instanceMatrix.isInstancedBufferAttribute === true ) && builder.isAvailable( 'instance' ) === true ) {
 
 			vertex = bypass( vertex, instance( object ) );
 
@@ -85,7 +85,7 @@ class NodeMaterial extends ShaderMaterial {
 		if ( this.vertexColors === true && builder.geometry.hasAttribute( 'color' ) ) {
 
 			colorNode = vec4( mul( colorNode.xyz, attribute( 'color' ) ), colorNode.a );
-		
+
 		}
 
 		// COLOR
@@ -142,7 +142,7 @@ class NodeMaterial extends ShaderMaterial {
 
 		let fogNode = builder.fogNode;
 
-		if ( fogNode?.isNode !== true && builder.scene.fog ) {
+		if ( ( fogNode && fogNode.isNode !== true ) && builder.scene.fog ) {
 
 			const fog = builder.scene.fog;
 
@@ -159,7 +159,7 @@ class NodeMaterial extends ShaderMaterial {
 				console.error( 'NodeMaterial: Unsupported fog configuration.', fog );
 
 			}
-			
+
 		}
 
 		if ( fogNode ) outputNode = vec4( vec3( fogNode.mix( outputNode ) ), outputNode.w );
@@ -183,7 +183,9 @@ class NodeMaterial extends ShaderMaterial {
 
 			if ( this[ property ] === undefined ) {
 
-				this[ property ] = value?.clone?.() || value;
+				this[ property ] = value;
+
+				if ( value && value.clone ) this[ property ] = value.clone();
 
 			}
 

+ 1 - 1
examples/jsm/nodes/materials/SpriteNodeMaterial.js

@@ -59,7 +59,7 @@ class SpriteNodeMaterial extends NodeMaterial {
 
 		let alignedPosition = vertex.xy;
 
-		if ( builder.object.center?.isVector2 === true ) {
+		if ( builder.object.center && builder.object.center.isVector2 === true ) {
 
 			alignedPosition = sub( alignedPosition, sub( uniform( builder.object.center ), vec2( 0.5 ) ) );
 

+ 52 - 52
examples/jsm/nodes/math/MathNode.js

@@ -5,58 +5,6 @@ import OperatorNode from './OperatorNode.js';
 
 class MathNode extends TempNode {
 
-	// 1 input
-
-	static RADIANS = 'radians';
-	static DEGREES = 'degrees';
-	static EXP = 'exp';
-	static EXP2 = 'exp2';
-	static LOG = 'log';
-	static LOG2 = 'log2';
-	static SQRT = 'sqrt';
-	static INVERSE_SQRT = 'inversesqrt';
-	static FLOOR = 'floor';
-	static CEIL = 'ceil';
-	static NORMALIZE = 'normalize';
-	static FRACT = 'fract';
-	static SIN = 'sin';
-	static COS = 'cos';
-	static TAN = 'tan';
-	static ASIN = 'asin';
-	static ACOS = 'acos';
-	static ATAN = 'atan';
-	static ABS = 'abs';
-	static SIGN = 'sign';
-	static LENGTH = 'length';
-	static NEGATE = 'negate';
-	static INVERT = 'invert';
-	static DFDX = 'dFdx';
-	static DFDY = 'dFdy';
-	static ROUND = 'round';
-	static RECIPROCAL = 'reciprocal';
-
-	// 2 inputs
-
-	static ATAN2 = 'atan2';
-	static MIN = 'min';
-	static MAX = 'max';
-	static MOD = 'mod';
-	static STEP = 'step';
-	static REFLECT = 'reflect';
-	static DISTANCE = 'distance';
-	static DOT = 'dot';
-	static CROSS = 'cross';
-	static POW = 'pow';
-	static TRANSFORM_DIRECTION = 'transformDirection';
-
-	// 3 inputs
-
-	static MIX = 'mix';
-	static CLAMP = 'clamp';
-	static REFRACT = 'refract';
-	static SMOOTHSTEP = 'smoothstep';
-	static FACEFORWARD = 'faceforward';
-
 	constructor( method, aNode, bNode = null, cNode = null ) {
 
 		super();
@@ -245,4 +193,56 @@ class MathNode extends TempNode {
 
 }
 
+// 1 input
+
+MathNode.RADIANS = 'radians';
+MathNode.DEGREES = 'degrees';
+MathNode.EXP = 'exp';
+MathNode.EXP2 = 'exp2';
+MathNode.LOG = 'log';
+MathNode.LOG2 = 'log2';
+MathNode.SQRT = 'sqrt';
+MathNode.INVERSE_SQRT = 'inversesqrt';
+MathNode.FLOOR = 'floor';
+MathNode.CEIL = 'ceil';
+MathNode.NORMALIZE = 'normalize';
+MathNode.FRACT = 'fract';
+MathNode.SIN = 'sin';
+MathNode.COS = 'cos';
+MathNode.TAN = 'tan';
+MathNode.ASIN = 'asin';
+MathNode.ACOS = 'acos';
+MathNode.ATAN = 'atan';
+MathNode.ABS = 'abs';
+MathNode.SIGN = 'sign';
+MathNode.LENGTH = 'length';
+MathNode.NEGATE = 'negate';
+MathNode.INVERT = 'invert';
+MathNode.DFDX = 'dFdx';
+MathNode.DFDY = 'dFdy';
+MathNode.ROUND = 'round';
+MathNode.RECIPROCAL = 'reciprocal';
+
+// 2 inputs
+
+MathNode.ATAN2 = 'atan2';
+MathNode.MIN = 'min';
+MathNode.MAX = 'max';
+MathNode.MOD = 'mod';
+MathNode.STEP = 'step';
+MathNode.REFLECT = 'reflect';
+MathNode.DISTANCE = 'distance';
+MathNode.DOT = 'dot';
+MathNode.CROSS = 'cross';
+MathNode.POW = 'pow';
+MathNode.TRANSFORM_DIRECTION = 'transformDirection';
+
+// 3 inputs
+
+MathNode.MIX = 'mix';
+MathNode.CLAMP = 'clamp';
+MathNode.REFRACT = 'refract';
+MathNode.SMOOTHSTEP = 'smoothstep';
+MathNode.FACEFORWARD = 'faceforward';
+
 export default MathNode;

+ 1 - 1
examples/jsm/nodes/shadernode/ShaderNode.js

@@ -69,7 +69,7 @@ const ShaderNodeObject = function ( obj ) {
 
 	} else if ( type === 'object' ) {
 
-		if ( obj?.isNode === true ) {
+		if ( obj && obj.isNode === true ) {
 
 			let nodeObject = nodeObjectsCacheMap.get( obj );
 

+ 2 - 2
examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js

@@ -97,7 +97,7 @@ export const func = ( code, includes ) => {
 	const node = nodeObject( new FunctionNode( code, includes ) );
 
 	const call = node.call.bind( node );
-	node.call = ( ...params ) => nodeObject( call( params.length > 1 || params[ 0 ]?.isNode === true ? nodeArray( params ) : nodeObjects( params[ 0 ] ) ) );
+	node.call = ( ...params ) => nodeObject( call( params.length > 1 || ( params[ 0 ] && params[ 0 ].isNode === true ) ? nodeArray( params ) : nodeObjects( params[ 0 ] ) ) );
 
 	return node;
 
@@ -108,7 +108,7 @@ export const uniform = ( nodeOrType ) => {
 	const nodeType = getConstNodeType( nodeOrType );
 
 	// @TODO: get ConstNode from .traverse() in the future
-	const value = nodeOrType.isNode === true ? nodeOrType.node?.value || nodeOrType.value : nodeOrType;
+	const value = nodeOrType.isNode === true ? ( nodeOrType.node && nodeOrType.node.value ) || nodeOrType.value : nodeOrType;
 
 	return nodeObject( new UniformNode( value, nodeType ) );
 

+ 2 - 2
examples/jsm/nodes/utils/MaxMipLevelNode.js

@@ -23,9 +23,9 @@ class MaxMipLevelNode extends UniformNode {
 
 		const texture = this.texture;
 		const images = texture.images;
-		const image = ( images && images.length > 0 ) ? ( images[ 0 ]?.image || images[ 0 ] ) : texture.image;
+		const image = ( images && images.length > 0 ) ? ( ( images[ 0 ] && images[ 0 ].image ) || images[ 0 ] ) : texture.image;
 
-		if ( image?.width !== undefined ) {
+		if ( image && image.width !== undefined ) {
 
 			const { width, height } = image;
 

+ 5 - 5
examples/jsm/nodes/utils/OscNode.js

@@ -4,11 +4,6 @@ import { abs, fract, round, sin, add, sub, mul } from '../shadernode/ShaderNodeB
 
 class OscNode extends Node {
 
-	static SINE = 'sine';
-	static SQUARE = 'square';
-	static TRIANGLE = 'triangle';
-	static SAWTOOTH = 'sawtooth';
-
 	constructor( method = OscNode.SINE, timeNode = new TimerNode() ) {
 
 		super();
@@ -71,4 +66,9 @@ class OscNode extends Node {
 
 }
 
+OscNode.SINE = 'sine';
+OscNode.SQUARE = 'square';
+OscNode.TRIANGLE = 'triangle';
+OscNode.SAWTOOTH = 'sawtooth';
+
 export default OscNode;

+ 6 - 6
examples/jsm/nodes/utils/TimerNode.js

@@ -3,11 +3,6 @@ import { NodeUpdateType } from '../core/constants.js';
 
 class TimerNode extends UniformNode {
 
-	static LOCAL = 'local';
-	static GLOBAL = 'global';
-	static DELTA = 'delta';
-	static FRAME = 'frame';
-
 	constructor( scope = TimerNode.LOCAL, scale = 1, value = 0 ) {
 
 		super( value );
@@ -18,7 +13,7 @@ class TimerNode extends UniformNode {
 		this.updateType = NodeUpdateType.FRAME;
 
 	}
-/*
+	/*
 	@TODO:
 	getNodeType( builder ) {
 
@@ -81,4 +76,9 @@ class TimerNode extends UniformNode {
 
 }
 
+TimerNode.LOCAL = 'local';
+TimerNode.GLOBAL = 'global';
+TimerNode.DELTA = 'delta';
+TimerNode.FRAME = 'frame';
+
 export default TimerNode;

+ 3 - 3
examples/jsm/objects/GroundProjectedEnv.js

@@ -6,7 +6,7 @@ import { Mesh, IcosahedronGeometry, ShaderMaterial, DoubleSide } from 'three';
  */
 export class GroundProjectedEnv extends Mesh {
 
-	constructor( texture, options ) {
+	constructor( texture, options = {} ) {
 
 		const isCubeMap = texture.isCubeTexture;
 
@@ -131,8 +131,8 @@ export class GroundProjectedEnv extends Mesh {
 
 		const uniforms = {
 			map: { value: texture },
-			height: { value: options?.height || 15 },
-			radius: { value: options?.radius || 100 },
+			height: { value: options.height || 15 },
+			radius: { value: options.radius || 100 },
 		};
 
 		const geometry = new IcosahedronGeometry( 1, 16 );

+ 1 - 1
examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js

@@ -103,7 +103,7 @@ class WebGLNodeBuilder extends NodeBuilder {
 
 		const { material, renderer } = this;
 
-		if ( renderer.toneMappingNode?.isNode === true ) {
+		if ( renderer.toneMappingNode && renderer.toneMappingNode.isNode === true ) {
 
 			this.addSlot( 'fragment', new SlotNode( {
 				node: material.colorNode,

+ 1 - 1
examples/jsm/renderers/webgpu/WebGPURenderer.js

@@ -590,7 +590,7 @@ class WebGPURenderer {
 
 	clear() {
 
-		this._background?.clear();
+		if ( this._background ) this._background.clear();
 
 	}
 

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

@@ -716,8 +716,8 @@ class WebGPUTextures {
 
 			const faceImage = image.length > 0 ? image[ 0 ].image || image[ 0 ] : null;
 
-			width = faceImage?.width || 1;
-			height = faceImage?.height || 1;
+			width = faceImage ? faceImage.width : 1;
+			height = faceImage ? faceImage.height : 1;
 			depth = 6; // one image for each side of the cube map
 
 		} else if ( image !== null ) {

+ 1 - 1
examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js

@@ -25,7 +25,7 @@ class WebGPUNodes {
 
 			nodeBuilder = new WebGPUNodeBuilder( object, this.renderer );
 			nodeBuilder.lightsNode = lightsNode;
-			nodeBuilder.fogNode = scene?.fogNode;
+			nodeBuilder.fogNode = scene ? scene.fogNode : undefined;
 			nodeBuilder.scene = scene;
 			nodeBuilder.build();
 

+ 1 - 1
examples/webgl_animation_skinning_ik.html

@@ -194,7 +194,7 @@
 
 			if ( conf.ik_solver ) {
 
-				IKSolver?.update();
+				if ( IKSolver ) IKSolver.update();
 
 			}
 

+ 2 - 2
examples/webxr_vr_handinput_pressbutton.html

@@ -123,14 +123,14 @@
 
 					if ( button.currState == 'fully_pressed' && button.prevState != 'fully_pressed' ) {
 
-						button.pressSound?.play();
+						if ( button.pressSound ) button.pressSound.play();
 						button.action();
 
 					}
 
 					if ( button.currState == 'recovering' && button.prevState != 'recovering' ) {
 
-						button.releaseSound?.play();
+						if ( button.releaseSound ) button.releaseSound.play();
 
 					}
 

Some files were not shown because too many files changed in this diff