Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove JS syntax > ECMA 2018 #25172

Merged
merged 4 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/jsm/exporters/GLTFExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions examples/jsm/libs/flow.module.js

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions examples/jsm/loaders/MaterialXLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,11 @@ class MaterialXNode {

let node = this.node;

if ( node !== null ) { return node; }
if ( node !== null ) {

return node;

}

//

Expand Down Expand Up @@ -478,7 +482,9 @@ class MaterialXNode {

getNodeByName( name ) {

return this.getChildByName( name )?.getNode();
const child = this.getChildByName( name );

return child ? child.getNode() : undefined;

}

Expand Down Expand Up @@ -681,7 +687,7 @@ class MaterialX {

}

/*getMaterialXNodeFromXML( xmlNode ) {
/*getMaterialXNodeFromXML( xmlNode ) {

return this.nodesXRefLib.get( xmlNode );

Expand Down
44 changes: 22 additions & 22 deletions examples/jsm/loaders/SVGLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1600,23 +1600,23 @@ 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 );

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();
const mFInvT = tempTransform2.copy( mFInv ).transpose();
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 );

Expand All @@ -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 );
Expand All @@ -1660,7 +1660,7 @@ class SVGLoader extends Loader {

if ( isTransformFlipped( m ) ) {

curve.aClockwise = !curve.aClockwise;
curve.aClockwise = ! curve.aClockwise;

}

Expand Down Expand Up @@ -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;

}

Expand Down Expand Up @@ -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;

}

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -1867,7 +1867,7 @@ class SVGLoader extends Loader {
if ( df > 0 ) {

t = cs;
cs = -sn;
cs = - sn;
sn = t;

}
Expand Down Expand Up @@ -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 = [];
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/misc/GPUComputationRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class GPUComputationRenderer {

const variable = variables[ i ];

variable.initialValueTexture?.dispose();
if ( variable.initialValueTexture ) variable.initialValueTexture.dispose();

const renderTargets = variable.renderTargets;

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/accessors/CubeTextureNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );

Expand Down
10 changes: 5 additions & 5 deletions examples/jsm/nodes/accessors/MaterialNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,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 );
Expand All @@ -79,7 +79,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' ) );

Expand All @@ -93,7 +93,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' ) );

Expand All @@ -107,7 +107,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' ) );

Expand All @@ -121,7 +121,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 ) );

Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/nodes/accessors/TextureNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class TextureNode extends UniformNode {

if ( uvNode === null && builder.context.getUVNode ) {

uvNode = builder.context.getUVNode( this )
uvNode = builder.context.getUVNode( this );

}

Expand Down Expand Up @@ -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' );

Expand Down
9 changes: 7 additions & 2 deletions examples/jsm/nodes/core/InputNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 );

}

Expand Down
12 changes: 6 additions & 6 deletions examples/jsm/nodes/core/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ class Node {

for ( const child of object ) {

if ( child?.isNode === true ) {
if ( child && child.isNode === true ) {

children.push( child );

}

}

} else if ( object?.isNode === true ) {
} else if ( object && object.isNode === true ) {

children.push( object );

Expand All @@ -62,7 +62,7 @@ class Node {

const child = object[ property ];

if ( child?.isNode === true ) {
if ( child && child.isNode === true ) {

children.push( child );

Expand Down Expand Up @@ -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 );

Expand All @@ -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 );

Expand Down Expand Up @@ -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 );

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/nodes/core/NodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class NodeBuilder {

hasGeometryAttribute( name ) {

return this.geometry?.getAttribute( name ) !== undefined;
return this.geometry ? ( this.geometry.getAttribute( name ) !== undefined ) : undefined;
Mugen87 marked this conversation as resolved.
Show resolved Hide resolved

}

Expand Down
Loading