<p dir="auto">I saw several issues regarding this from a few years ago (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="248276540" data-permission-text="Title is private" data-url="https://github.com/mrdoob/three.js/issues/11898" data-hovercard-type="issue" data-hovercard-url="/mrdoob/three.js/issues/11898/hovercard" href="https://github.com/mrdoob/three.js/issues/11898">#11898</a>, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="60186495" data-permission-text="Title is private" data-url="https://github.com/mrdoob/three.js/issues/6191" data-hovercard-type="issue" data-hovercard-url="/mrdoob/three.js/issues/6191/hovercard" href="https://github.com/mrdoob/three.js/issues/6191">#6191</a>, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="143198603" data-permission-text="Title is private" data-url="https://github.com/mrdoob/three.js/issues/8458" data-hovercard-type="issue" data-hovercard-url="/mrdoob/three.js/issues/8458/hovercard" href="https://github.com/mrdoob/three.js/issues/8458">#8458</a>), but I did not understand why didn't this go anywhere. The oldest one is still opened, but no activity since 2016?</p>
<p dir="auto">The problem is that when I create a <code class="notranslate">BufferGeometry</code> from <code class="notranslate">Geometry</code>, there are a lot of duplicated vertices. Now, I know what you are thinking: normals are different, there are UV seams etc. Alas this is not the case (as far as I can tell).</p>
<p dir="auto">For example, if I convert a <code class="notranslate">Sphere(Buffer)Geometry</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="var geometry1 = new THREE.SphereBufferGeometry( 0.7, 10, 10 );
var geometry2 = new THREE.Geometry().fromBufferGeometry(geometry1);
var geometry3 = new THREE.BufferGeometry().fromGeometry(geometry2);"><pre class="notranslate"><code class="notranslate">var geometry1 = new THREE.SphereBufferGeometry( 0.7, 10, 10 );
var geometry2 = new THREE.Geometry().fromBufferGeometry(geometry1);
var geometry3 = new THREE.BufferGeometry().fromGeometry(geometry2);
</code></pre></div>
<p dir="auto">Then there are 4+ (!) times as many vertices in geometry3 than in geometry1.</p>
<p dir="auto">What I actually want is the position-based merge function (<code class="notranslate">.mergeVertices</code>) in the regular <code class="notranslate">Geometry</code> class. I started converting all my code to use <code class="notranslate">BufferGeometry</code>, but some functionality is not available there (like the merge). So I now want to convert my BufferGeometry to Geometry, parse it, and get it back to BufferGeometry for rendering. But this happens with the vertex count:</p>
<table role="table">
<thead>
<tr>
<th>Shape</th>
<th>Original BG</th>
<th>Converted G</th>
<th>Converted BG</th>
<th>Indexed and merged BG</th>
</tr>
</thead>
<tbody>
<tr>
<td>Plane</td>
<td>4</td>
<td>4</td>
<td><strong>6</strong></td>
<td>4</td>
</tr>
<tr>
<td>Box</td>
<td>24</td>
<td>24</td>
<td><strong>36</strong></td>
<td>24</td>
</tr>
<tr>
<td>Sphere</td>
<td>121</td>
<td>121</td>
<td><strong>540</strong></td>
<td>119</td>
</tr>
</tbody>
</table>
<p dir="auto">In the last column is the result from a merging and indexing function I created. That function checks all the attributes from the vertices of an un-indexed BG, removes duplicates and indexes it.</p>
<p dir="auto">Live: <a href="http://tume-maailm.pri.ee/ylikool/muu/threejs/indexedBG/" rel="nofollow">http://tume-maailm.pri.ee/ylikool/muu/threejs/indexedBG/</a><br>
(counts are in the Console)</p>
<p dir="auto">I don't know, maybe there are some models where the resulting BufferGeometry cannot be indexed like that. But perhaps automatic indexing could be at least some option somewhere?</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=""> r106</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> ...</li>
</ul>
<p dir="auto">Sometimes? Most of the times? In fact, it could be done even in case with face normals - if the model has enough neighbour faces with the same normal, it could even make sense :) File it under suggestions.</p>