<p dir="auto">Lets say i have shader material, and some property that makes the same shader appear as either plastic, metal, or wood...</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
//magic parameter 
var _staticUniform = {
  type:'f',
  value: 1
};

var myPlasticRecipe = new THREE.ShaderMaterial({
  uniforms:{
    uniqueColor:{type:'c', value: new THREE.Color()},
    staticMaterialProperty: _staticUniform
  },
  vertexShader: someVShader,
  fragmentShader: someFShader
}

var redPlasticMaterial = myPlasticRecipe.clone();
redPlasticMaterial.uniforms.uniqueColor.value.setRGB(1,0,0);

var bluePlasticMaterial = myPlasticRecipe.clone();
bluePlasticMaterial.uniforms.uniqueColor.value.setRGB(0,0,1);"><pre class="notranslate"><span class="pl-c">//magic parameter </span>
<span class="pl-k">var</span> <span class="pl-s1">_staticUniform</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
  <span class="pl-c1">type</span>:<span class="pl-s">'f'</span><span class="pl-kos">,</span>
  <span class="pl-c1">value</span>: <span class="pl-c1">1</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span>

<span class="pl-k">var</span> <span class="pl-s1">myPlasticRecipe</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-c1">THREE</span><span class="pl-kos">.</span><span class="pl-c1">ShaderMaterial</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
  <span class="pl-c1">uniforms</span>:<span class="pl-kos">{</span>
    <span class="pl-c1">uniqueColor</span>:<span class="pl-kos">{</span><span class="pl-c1">type</span>:<span class="pl-s">'c'</span><span class="pl-kos">,</span> <span class="pl-c1">value</span>: <span class="pl-k">new</span> <span class="pl-c1">THREE</span><span class="pl-kos">.</span><span class="pl-c1">Color</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-c1">staticMaterialProperty</span>: <span class="pl-s1">_staticUniform</span>
  <span class="pl-kos">}</span><span class="pl-kos">,</span>
  <span class="pl-c1">vertexShader</span>: <span class="pl-s1">someVShader</span><span class="pl-kos">,</span>
  <span class="pl-c1">fragmentShader</span>: <span class="pl-s1">someFShader</span>
<span class="pl-kos">}</span>

<span class="pl-s1">var</span> <span class="pl-s1">redPlasticMaterial</span> <span class="pl-c1">=</span> <span class="pl-s1">myPlasticRecipe</span><span class="pl-kos">.</span><span class="pl-en">clone</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos"></span><span class="pl-kos">;</span>
<span class="pl-s1">redPlasticMaterial</span><span class="pl-kos">.</span><span class="pl-c1">uniforms</span><span class="pl-kos">.</span><span class="pl-c1">uniqueColor</span><span class="pl-kos">.</span><span class="pl-c1">value</span><span class="pl-kos">.</span><span class="pl-en">setRGB</span><span class="pl-kos">(</span><span class="pl-c1">1</span><span class="pl-kos">,</span><span class="pl-c1">0</span><span class="pl-kos">,</span><span class="pl-c1">0</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">var</span> <span class="pl-s1">bluePlasticMaterial</span> <span class="pl-c1">=</span> <span class="pl-s1">myPlasticRecipe</span><span class="pl-kos">.</span><span class="pl-en">clone</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">bluePlasticMaterial</span><span class="pl-kos">.</span><span class="pl-c1">uniforms</span><span class="pl-kos">.</span><span class="pl-c1">uniqueColor</span><span class="pl-kos">.</span><span class="pl-c1">value</span><span class="pl-kos">.</span><span class="pl-en">setRGB</span><span class="pl-kos">(</span><span class="pl-c1">0</span><span class="pl-kos">,</span><span class="pl-c1">0</span><span class="pl-kos">,</span><span class="pl-c1">1</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">I'd like to change the magic parameter and affect all the materials without manually keeping track of everything, but since material.clone() calls uniformsUtils.clone() and does a deep copy the reference to the static uniform is lost.</p>
<p dir="auto">Not sure if this would be useful to anyone else, but having uniformsUtil look up a (optional) type and then decide wether to copy or make a reference could be helpful. Sometimes textures can be shared etc. Any thoughts?</p>
<p dir="auto">Hello,</p>
<p dir="auto">I experience a weird problem when rotating some models in three.js. Under certain angles of view some parts of a model become invisible. The problem is definetely has nothing to do with <code class="notranslate">material.side</code>.</p>
<p dir="auto">Front view:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/20855725/48829741-d805c680-ed94-11e8-9184-daa97fe15420.png"><img src="https://user-images.githubusercontent.com/20855725/48829741-d805c680-ed94-11e8-9184-daa97fe15420.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">Back view ('good' angle):<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/20855725/48829806-02f01a80-ed95-11e8-8ab2-22eccc15f767.png"><img src="https://user-images.githubusercontent.com/20855725/48829806-02f01a80-ed95-11e8-8ab2-22eccc15f767.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">Back view ('bad' angle):<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/20855725/48829886-2ca94180-ed95-11e8-98d7-757df462ca58.png"><img src="https://user-images.githubusercontent.com/20855725/48829886-2ca94180-ed95-11e8-98d7-757df462ca58.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">Sample model:<br>
<a href="https://github.com/mrdoob/three.js/files/2603453/Sample_GLTF.zip">Sample_GLTF.zip</a></p>
<h5 dir="auto">Three.js version</h5>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Dev</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> r98</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> ...</li>
</ul>
<h5 dir="auto">Browser</h5>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> All of them</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Chrome</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Firefox</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Internet Explorer</li>
</ul>
<h5 dir="auto">OS</h5>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> All of them</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Windows</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> macOS</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Linux</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Android</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> iOS</li>
</ul>
<h5 dir="auto">Hardware Requirements (graphics card, VR Device, ...)</h5>