question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GLTFLoader: minor optimization

See original GitHub issue
Description of the problem

https://github.com/mrdoob/three.js/blob/d3bff25fc38c6143665b7ef482f2ebef3073b3af/examples/js/loaders/GLTFLoader.js#L1049-L1052

can be slightly optimized. Also see https://github.com/KhronosGroup/glTF/issues/1411#issuecomment-410356033

Rearranging to

                var s2 = - 2 * ppp + 3 * pp;
		var s3 = ppp - pp;
                var s0 = 1 - s2;
		var s1 = s3 - pp + p;

saves three multiplications during each cubicspline animation frame. Still, not sure if worth it as this may not make a measurable difference.

Three.js version
  • Dev
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
takahiroxcommented, Dec 22, 2018

I think this type of optimization should be done by JavaScript Engine. We don’t need to do manually. We should just keep the code simple and readable as much as possible.

Weird that Chrome becomes faster with this change. I know micro benchmark test framework sometimes doesn’t fairly compare the performance. I’ll write the test by myself and share the result.

1reaction
donmccurdycommented, Nov 19, 2018

Tested in Chrome, Firefox, and Safari. It wasn’t consistent across multiple runs. Running the same test in Firefox repeatedly sometimes showed one or the other as faster. Safari was more consistent, with code block 2 being slightly faster. Overall the trend appears to be slightly faster, and intuitively that makes sense, so I’m happy with the PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

glTF model rendering optimization - Questions - three.js forum
My question is how to optimize the model in order for it to be able to run ... I have another question though,...
Read more >
How to Import GLTF Models in Three.js - YouTube
In this coding tutorial, we go over importing GLTF models in Three JS. We start off by learning when it is useful to...
Read more >
How to Load a 3D model in Three.js - YouTube
How to Load a 3D model in Three.js | GLTF/GLB Model | GLTFLoader ... I may receive a small commission for purchases made...
Read more >
loaders.gl - Yarn
loaders.gl. loaders.gl is a framework in the vis.gl framework suite that provides a collection of framework-independent loaders focused on geospatial, ...
Read more >
Three.js Multiple Canvases Multiple Scenes
The code above works but there is one minor issue. If your scenes are complicated or if for whatever reason it takes too...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found