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 all commits
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
10 changes: 5 additions & 5 deletions examples/jsm/nodes/accessors/BitangentNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -59,4 +54,9 @@ class BitangentNode extends Node {

}

BitangentNode.GEOMETRY = 'geometry';
BitangentNode.LOCAL = 'local';
BitangentNode.VIEW = 'view';
BitangentNode.WORLD = 'world';

export default BitangentNode;
4 changes: 2 additions & 2 deletions examples/jsm/nodes/accessors/CameraNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import Object3DNode from './Object3DNode.js';

class CameraNode extends Object3DNode {

static PROJECTION_MATRIX = 'projectionMatrix';

constructor( scope = CameraNode.POSITION ) {

super( scope );
Expand Down Expand Up @@ -64,4 +62,6 @@ class CameraNode extends Object3DNode {

}

CameraNode.PROJECTION_MATRIX = 'projectionMatrix';

export default CameraNode;
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
26 changes: 13 additions & 13 deletions examples/jsm/nodes/accessors/MaterialNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 );
Expand All @@ -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' ) );

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

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

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

Expand Down Expand Up @@ -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;
10 changes: 5 additions & 5 deletions examples/jsm/nodes/accessors/NormalNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -82,4 +77,9 @@ class NormalNode extends Node {

}

NormalNode.GEOMETRY = 'geometry';
NormalNode.LOCAL = 'local';
NormalNode.VIEW = 'view';
NormalNode.WORLD = 'world';

export default NormalNode;
12 changes: 6 additions & 6 deletions examples/jsm/nodes/accessors/Object3DNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
14 changes: 7 additions & 7 deletions examples/jsm/nodes/accessors/PositionNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -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;
Loading