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.

UniformsUtils.clone() is deprecated — but nothing replaces it?

See original GitHub issue

It looks like recent versions of ThreeJS have deprecated UniformsUtils.clone() with a warning message. However, Object.assign (which has replaced it in the examples) is not a real replacement. The reason is that Object.assign doesn’t do a deep clone or clone ThreeJS specific objects, like THREE.Color or THREE.Vector3.

Typical usage:

const baseShaderMaterial = new THREE.ShaderMaterial({ ... });

const redShaderMaterial = baseShaderMaterial.clone();

// we can now mutate the uniforms without affecting the base material!
redShaderMaterial.uniforms.color.value.setStyle('red');

Any particular reason why this function is deprecated? I’ve found it quite useful.

Cheers!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
aardgoosecommented, Dec 15, 2016

I was expecting you to reverse this, given the breakages it was causing. Got me to learn more parts of the code, so not at all wasted.

0reactions
takahiroxcommented, Dec 19, 2016

FYI,

I think the reason why this didn’t cause any problems among non-ShaderMaterials is their uniforms are dynamically updated right before their rendering by copying the data from material parameters to shared uniforms.

Even with ShaderMaterial we can do that by using onBeforeRender() without THREE.UniformsUtils.clone(). Actually OutlineEffect does this and haven’t faced any problems (so far).

Read more comments on GitHub >

github_iconTop Results From Across the Web

three.js - Apple Open Source
Matrix4: the constructor no longer reads arguments. use .set() instead. ... setFromEuler() now expects an Euler rotation rather than a Vector3 and order....
Read more >
UNPKG - @google/model-viewer
toLowerCase() here flattens concatenated strings to save heap memory space. ... LinearEncoding only supported on map, envMap and emissiveMap.
Read more >
ShaderMaterial - Verge3D User Manual - Soft8Soft
Built in attributes and uniforms are passed to the shaders along with your code. If you don't want the WebGLProgram to add anything...
Read more >
Team:Estonia TUIT/modelviewermodulejs - iGEM 2021
setFromEuler() now expects an Euler rotation rather than a Vector3 and order. ... n in i)t[n]=i[n]}return t}var UniformsUtils={clone:cloneUniforms ...
Read more >
DataTexture - OSCHINA - 中文开源技术交流社区
OSCHINA.NET 是目前领先的中文开源技术社区。我们传播开源的理念,推广开源项目,为 IT 开发者提供了一个发现、使用、并交流开源技术的平台.
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