<p dir="auto"><strong>Describe the bug</strong></p>
<p dir="auto">When you use the copy method from the InstancedBufferGeometry the instanceCount attribute is copied by defualt. This could lead to errors, since the copy method accepts any kind of geometry and for this reason the instanceCount could be set to undefined.</p>
<p dir="auto"><strong>To Reproduce</strong></p>
<p dir="auto">call InstancedBufferGeometry .copy passing a BufferGeometry of a Geometry and the instanceCount  will be set to undefined</p>
<p dir="auto"><strong>Expected behavior</strong></p>
<p dir="auto">The copy method should check the type of the geometry passed as input and only if it is an InstancedBufferGeometry the instanceCount should be copied.</p>
<p dir="auto"><strong>Platform:</strong></p>
<ul dir="auto">
<li>All</li>
<li>Three.js version: [master]</li>
</ul>
<p dir="auto"><strong>Describe the bug</strong></p>
<p dir="auto">In r117 (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="599967027" data-permission-text="Title is private" data-url="https://github.com/mrdoob/three.js/issues/19135" data-hovercard-type="pull_request" data-hovercard-url="/mrdoob/three.js/pull/19135/hovercard" href="https://github.com/mrdoob/three.js/pull/19135">#19135</a>) you renamed <code class="notranslate">maxInstancedCount</code> to <code class="notranslate">instanceCount</code> AND changed the default value from <code class="notranslate">undefined</code> to <code class="notranslate">Infinity</code>. However, there is a rare case when it still becomes undefined: copying from a non-instanced geometry.</p>
<p dir="auto"><strong>To Reproduce</strong></p>
<p dir="auto">If you call <code class="notranslate">instancedGeo.copy(simpleGeo);</code> it overwrites <code class="notranslate">Infinity</code> with <code class="notranslate">undefined</code>. Then, during rendering, it is converted to <code class="notranslate">NaN</code> and passed to <code class="notranslate">drawElementsInstancedANGLE</code>.</p>
<p dir="auto">See <a href="https://github.com/mrdoob/three.js/pull/19135/files">the changes</a>:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/11373544/126136677-d47c1c44-b0b3-404f-8fab-201ff21150d1.png"><img src="https://user-images.githubusercontent.com/11373544/126136677-d47c1c44-b0b3-404f-8fab-201ff21150d1.png" alt="20210719-121610" style="max-width: 100%;"></a></p>
<p dir="auto">In r116 this undefined value perfectly worked, so we have a regression here.</p>
<p dir="auto">I cannot provide a small working example yet, just a code review.</p>
<p dir="auto"><strong>Expected behavior</strong></p>
<p dir="auto"><code class="notranslate">InstancedBufferGeometry.copy()</code> should be able to copy from any <code class="notranslate">BufferGeometry</code>, instanced or not.</p>
<p dir="auto"><strong>Platform:</strong></p>
<ul dir="auto">
<li>Device: any</li>
<li>OS: any</li>
<li>Browser: any</li>
<li>Three.js version: r117 and up</li>
</ul>