From 869de4cea209297acbffe6e1f3572fc904f5f87e Mon Sep 17 00:00:00 2001
From: Kevin Lee <kevin@infinite-lee.com>
Date: Tue, 7 Aug 2018 18:54:39 -0700
Subject: [PATCH] cleanup sharedbuffergeometry

---
 src/utils/sharedbuffergeometry.js | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/src/utils/sharedbuffergeometry.js b/src/utils/sharedbuffergeometry.js
index a98f5bf22..189176ffd 100644
--- a/src/utils/sharedbuffergeometry.js
+++ b/src/utils/sharedbuffergeometry.js
@@ -20,15 +20,14 @@ export default class SharedBufferGeometry {
 
       this.idx.color++;
       this.idx.normal++;
-      this.idx.uv++;
     }
   }
 
   remove(prevIdx, idx) {
-    // Loop through all the attributes: position, color, uv, normal,...
+    // Loop through all the attributes: position, color, normal,...
     if (this.idx.position > idx.position) {
-      for (let key in this.idx) {
-        const componentSize = key === "uv" ? 2 : 3;
+      for (const key in this.idx) {
+        const componentSize = 3;
         let pos = prevIdx[key] * componentSize;
         const start = (idx[key] + 1) * componentSize;
         const end = this.idx[key] * componentSize;
@@ -39,7 +38,7 @@ export default class SharedBufferGeometry {
         this.idx[key] -= diff;
       }
     } else {
-      for (let key in this.idx) {
+      for (const key in this.idx) {
         const diff = idx[key] - prevIdx[key];
         this.idx[key] -= diff;
       }
@@ -54,12 +53,10 @@ export default class SharedBufferGeometry {
   }
 
   addBuffer(copyLast) {
-    console.log("addBuffer", copyLast);
     const geometry = new THREE.BufferGeometry();
 
     const vertices = new Float32Array(this.maxBufferSize * 3);
     const normals = new Float32Array(this.maxBufferSize * 3);
-    const uvs = new Float32Array(this.maxBufferSize * 2);
     const colors = new Float32Array(this.maxBufferSize * 3);
 
     const mesh = new THREE.Mesh(geometry, this.material);
@@ -75,7 +72,6 @@ export default class SharedBufferGeometry {
 
     geometry.setDrawRange(0, 0);
     geometry.addAttribute("position", new THREE.BufferAttribute(vertices, 3).setDynamic(true));
-    geometry.addAttribute("uv", new THREE.BufferAttribute(uvs, 2).setDynamic(true));
     geometry.addAttribute("normal", new THREE.BufferAttribute(normals, 3).setDynamic(true));
     geometry.addAttribute("color", new THREE.BufferAttribute(colors, 3).setDynamic(true));
 
@@ -86,7 +82,6 @@ export default class SharedBufferGeometry {
 
     this.idx = {
       position: 0,
-      uv: 0,
       normal: 0,
       color: 0
     };
@@ -97,7 +92,6 @@ export default class SharedBufferGeometry {
     if (this.previous && copyLast) {
       let prev = (this.maxBufferSize - 2) * 3;
       let col = (this.maxBufferSize - 2) * 3;
-      const uv = (this.maxBufferSize - 2) * 2;
       let norm = (this.maxBufferSize - 2) * 3;
 
       const position = this.previous.attributes.position.array;
@@ -111,8 +105,6 @@ export default class SharedBufferGeometry {
       const color = this.previous.attributes.color.array;
       this.addColor(color[col++], color[col++], color[col++]);
       this.addColor(color[col++], color[col++], color[col++]);
-
-      const uvs = this.previous.attributes.uv.array;
     }
   }
 
@@ -133,16 +125,11 @@ export default class SharedBufferGeometry {
     buffer.setXYZ(this.idx.position++, x, y, z);
   }
 
-  addUV(u, v) {
-    this.current.attributes.uv.setXY(this.idx.uv++, u, v);
-  }
-
   update() {
     this.current.setDrawRange(0, this.idx.position);
 
     this.current.attributes.color.needsUpdate = true;
     this.current.attributes.normal.needsUpdate = true;
     this.current.attributes.position.needsUpdate = true;
-    this.current.attributes.uv.needsUpdate = true;
   }
 }
-- 
GitLab