<h5 dir="auto">Description of the problem</h5>
<p dir="auto">InstancedMesh instancing breaks if the supplied material has been already been used.</p>
<p dir="auto">If a .clone() of the material is passed into the InstancedMesh, it works.</p>
<p dir="auto">Repro showing the issue...   remove the .clone() operation to see instancing break.</p>
<p dir="auto"><a href="https://jsfiddle.net/4u1aox7j/" rel="nofollow">https://jsfiddle.net/4u1aox7j/</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" checked=""> Dev</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> r117</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> ...</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" checked=""> All of them</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> 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" checked=""> All of them</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> 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>
<h5 dir="auto">Description of the problem</h5>
<p dir="auto">I'm having a problem where the InstancedMesh method <code class="notranslate">setMatrixAt</code> seems to fail (the matrix positions doesn't change visually) whenever I add another object with the same material object (not a clone) in the scene. No log/warning/errors are emitted.</p>
<p dir="auto">The following briefly illustrates:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    var geometry = new THREE.BoxBufferGeometry();
    var material = new THREE.MeshStandardMaterial( { roughness: 0, envMap: texture });
    var mesh1 = new THREE.Mesh( geometry, material );
    mesh1.position.set(0, 1, 0);
    scene.add( mesh1 ); // removing this line makes the instanced mesh work as intended
    mesh = new THREE.InstancedMesh( geometry, material, 9 ); // same material usage
    scene.add( mesh ); // This works and I can see both meshes in the scene.
    
    var dummy = new THREE.Object3D();
    dummy.position.set( 1, 5, 1 );
    dummy.updateMatrix();
    mesh.setMatrixAt( 0, dummy.matrix ); // Nope, doesn't work, it just stays where it's at.
    mesh.setMatrixAt( 1, dummy.matrix ); // Rotation seems to be applied, but position doesn't.
    // It looks like every instance is at the same place, but I don't know."><pre class="notranslate">    <span class="pl-k">var</span> <span class="pl-s1">geometry</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">BoxBufferGeometry</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">var</span> <span class="pl-s1">material</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">MeshStandardMaterial</span><span class="pl-kos">(</span> <span class="pl-kos">{</span> <span class="pl-c1">roughness</span>: <span class="pl-c1">0</span><span class="pl-kos">,</span> <span class="pl-c1">envMap</span>: <span class="pl-s1">texture</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">var</span> <span class="pl-s1">mesh1</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">Mesh</span><span class="pl-kos">(</span> <span class="pl-s1">geometry</span><span class="pl-kos">,</span> <span class="pl-s1">material</span> <span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">mesh1</span><span class="pl-kos">.</span><span class="pl-c1">position</span><span class="pl-kos">.</span><span class="pl-en">set</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-c1">0</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">scene</span><span class="pl-kos">.</span><span class="pl-en">add</span><span class="pl-kos">(</span> <span class="pl-s1">mesh1</span> <span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// removing this line makes the instanced mesh work as intended</span>
    <span class="pl-s1">mesh</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">InstancedMesh</span><span class="pl-kos">(</span> <span class="pl-s1">geometry</span><span class="pl-kos">,</span> <span class="pl-s1">material</span><span class="pl-kos">,</span> <span class="pl-c1">9</span> <span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// same material usage</span>
    <span class="pl-s1">scene</span><span class="pl-kos">.</span><span class="pl-en">add</span><span class="pl-kos">(</span> <span class="pl-s1">mesh</span> <span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// This works and I can see both meshes in the scene.</span>
    
    <span class="pl-k">var</span> <span class="pl-s1">dummy</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">Object3D</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">dummy</span><span class="pl-kos">.</span><span class="pl-c1">position</span><span class="pl-kos">.</span><span class="pl-en">set</span><span class="pl-kos">(</span> <span class="pl-c1">1</span><span class="pl-kos">,</span> <span class="pl-c1">5</span><span class="pl-kos">,</span> <span class="pl-c1">1</span> <span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">dummy</span><span class="pl-kos">.</span><span class="pl-en">updateMatrix</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">mesh</span><span class="pl-kos">.</span><span class="pl-en">setMatrixAt</span><span class="pl-kos">(</span> <span class="pl-c1">0</span><span class="pl-kos">,</span> <span class="pl-s1">dummy</span><span class="pl-kos">.</span><span class="pl-c1">matrix</span> <span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// Nope, doesn't work, it just stays where it's at.</span>
    <span class="pl-s1">mesh</span><span class="pl-kos">.</span><span class="pl-en">setMatrixAt</span><span class="pl-kos">(</span> <span class="pl-c1">1</span><span class="pl-kos">,</span> <span class="pl-s1">dummy</span><span class="pl-kos">.</span><span class="pl-c1">matrix</span> <span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// Rotation seems to be applied, but position doesn't.</span>
    <span class="pl-c">// It looks like every instance is at the same place, but I don't know.</span></pre></div>
<p dir="auto">Note that if I use material.clone() at the instanced mesh declaration, the problem also goes away / is fixed, but now I have two materials, and I intend to have one for performance reasons.</p>
<p dir="auto">A live example is available here:</p>
<ul dir="auto">
<li><a href="https://jsfiddle.net/ghmrdk4z/4/" rel="nofollow">jsfiddle</a> (The problem is that you should see multiple boxes, but only 1 or 2 are visible, remove line 41 to fix)</li>
</ul>
<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" checked=""> Dev</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> r109</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> r108</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" checked=""> 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>
<p dir="auto">(Not applicable, as far as I know)</p>