Skip to content

Nodes: Follow three.js static property style#23562

Closed
sunag wants to merge 1 commit intomrdoob:devfrom
sunag:dev-normalize-static
Closed

Nodes: Follow three.js static property style#23562
sunag wants to merge 1 commit intomrdoob:devfrom
sunag:dev-normalize-static

Conversation

@sunag
Copy link
Collaborator

@sunag sunag commented Feb 23, 2022

Description

The static properties of Three.js don't use all caps by default like POSITION but Position. I think it's good to adapt NodeMaterial as soon as possible for this style?

// before
new NormalNode( NormalNode.LOCAL );
new PositionNode( PositionNode.VIEW_DIRECTION );

// after
new NormalNode( NormalNode.Local );
new PositionNode( PositionNode.ViewDirection );

This contribution is funded by Google via Igalia.

@sunag sunag changed the title Nodes: Follow three.js static name style Nodes: Follow three.js static property style Feb 23, 2022
@mrdoob
Copy link
Owner

mrdoob commented Feb 23, 2022

Hmm, it's up to you... But I think the style you were doing was more readable.

@sunag
Copy link
Collaborator Author

sunag commented Feb 23, 2022

Hmm, it's up to you... But I think the style you were doing was more readable.

I understand... But I think it pays off, maybe then we wouldn't have styles competing with each other?

@mrdoob
Copy link
Owner

mrdoob commented Feb 23, 2022

Hmm... It's mainly because this file, right?
https://github.com/mrdoob/three.js/blob/dev/src/constants.js

@sunag
Copy link
Collaborator Author

sunag commented Feb 23, 2022

Hmm... It's mainly because this file, right?

Yes, yes.. Exactly this and this too:
https://github.com/mrdoob/three.js/blob/dev/examples/jsm/nodes/core/constants.js

@mrdoob
Copy link
Owner

mrdoob commented Feb 23, 2022

I think I still prefer what you had...

For example:

import { Frustum, Matrix4, Vector3, Color, LinearEncoding } from 'three';

It's impossible to tell what is a class and what is a constant.

This is more readable:

import { Frustum, Matrix4, Vector3, Color, LINEAR_ENCODING } from 'three';

But I think what you have done is even better.

For example:

import { Frustum, Matrix4, Vector3, Color, Encoding } from 'three';

texture.encoding = Encoding.LINEAR;

So I vote for keeping the current style in the Nodes system.
And maybe, at some point, we could change the constants style in core to be more like the Nodes one.

@Mugen87 What do you think?

@sunag
Copy link
Collaborator Author

sunag commented Feb 23, 2022

So I vote for keeping the current style in the Nodes system.
And maybe, at some point, we could change the constants style in core to be more like the Nodes one.

@mrdoob Yes, there are strong arguments. I also vote for keeping the current style and change the core constants style soon.

@mrdoob
Copy link
Owner

mrdoob commented Feb 23, 2022

Closing then. We'll update the constants in core some day... 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants