UniformsUtils.clone() is deprecated — but nothing replaces it?
See original GitHub issueIt 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:
- Created 7 years ago
- Comments:13 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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.
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
ShaderMaterialwe can do that by usingonBeforeRender()withoutTHREE.UniformsUtils.clone(). ActuallyOutlineEffectdoes this and haven’t faced any problems (so far).