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

Update glb-parser #5219

Merged
merged 33 commits into from
Mar 31, 2023
Merged

Update glb-parser #5219

merged 33 commits into from
Mar 31, 2023

Conversation

slimbuck
Copy link
Member

This PR modernises glb-parser.js by converting functions to arrow functions and replacing instances of options && options.foo && options.foo.bar with options?.foo?.bar.

@slimbuck slimbuck requested a review from a team March 31, 2023 09:23
@slimbuck slimbuck self-assigned this Mar 31, 2023
const process = options && options.camera && options.camera.process || createCamera;
const postprocess = options && options.camera && options.camera.postprocess;
const preprocess = options?.camera?.preprocess;
const process = options?.camera?.process || createCamera;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to standardize on ?? instead of || for these kinds of use cases? Which means 'if the left side is null or undefined, use the right side' (rather than a logical op).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah updating to ?? would make sense. I have a followup PR already which is based on this one and will update to ?? there (since some have been removed).

const preprocess = options && options.camera && options.camera.preprocess;
const process = options && options.camera && options.camera.process || createCamera;
const postprocess = options && options.camera && options.camera.postprocess;
const preprocess = options?.camera?.preprocess;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if we should prescribe a set coding style for options objects. In my code, I've been using a default parameter (empty object) for options objects. But, of course, that will allocate on every call potentially. Whereas using ?. everywhere is a bit more verbose and might transpile to more code via Babel?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how that would work here. Could you give a code snippet?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, you'd still need the second ?. regardless. TBH, it's not a big deal.

@slimbuck slimbuck merged commit 89a4bc8 into playcanvas:main Mar 31, 2023
@slimbuck slimbuck deleted the glb-parser-cleanup branch March 31, 2023 10:59
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.

3 participants