xzw 2 months ago
parent
commit
21404b3a22
2 changed files with 10 additions and 10 deletions
  1. 1 1
      src/loader/BinaryLoader.js
  2. 9 9
      src/workers/BinaryDecoderWorker.js

+ 1 - 1
src/loader/BinaryLoader.js

@@ -86,7 +86,7 @@ export class BinaryLoader{
 				if (property === "POSITION_CARTESIAN") {
 					geometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(buffer), 3)); 
                 } else if (property === "centersFloat") {//add
-					geometry.setAttribute("centersFloat", new THREE.BufferAttribute(new Float32Array(buffer), 4 ));
+					geometry.setAttribute("centersFloat", new THREE.BufferAttribute(new Float32Array(buffer), 3 ));
 				} else if (property === "centersInt") {//add
 					geometry.setAttribute("centersInt", new THREE.BufferAttribute(new Int32Array(buffer), 4 ));
 				} else if (property === "rgba") {

+ 9 - 9
src/workers/BinaryDecoderWorker.js

@@ -520,21 +520,21 @@ onmessage = function (event) {
             
             if(hasGS3D){//add 
                 let buff2 = new ArrayBuffer(numPoints * 4 * 4);
-                let buff3 = new ArrayBuffer(numPoints * 4 * 4);
+                let buff3 = new ArrayBuffer(numPoints * 4 * 3);
                 let centersInt = new Int32Array(buff2);
                 let centersFloat = new Float32Array(buff3);
                 for(let i=0;i<numPoints;i++){
-                    centersFloat[4 * i + 0] = positions[3 * i + 0] + pos[0]
-                    centersFloat[4 * i + 1] = positions[3 * i + 1] + pos[1]
-                    centersFloat[4 * i + 2] = positions[3 * i + 2] + pos[2]
-                    centersFloat[4 * i + 3] = 1;
-                    centersInt[4 * i + 0] = centersFloat[4 * i + 0] * 1000
-                    centersInt[4 * i + 1] = centersFloat[4 * i + 1] * 1000
-                    centersInt[4 * i + 2] = centersFloat[4 * i + 2] * 1000
+                    centersFloat[3 * i + 0] = positions[3 * i + 0] + pos[0]
+                    centersFloat[3 * i + 1] = positions[3 * i + 1] + pos[1]
+                    centersFloat[3 * i + 2] = positions[3 * i + 2] + pos[2]
+                    //centersFloat[4 * i + 3] = 1;
+                    centersInt[4 * i + 0] = centersFloat[3 * i + 0] * 1000
+                    centersInt[4 * i + 1] = centersFloat[3 * i + 1] * 1000
+                    centersInt[4 * i + 2] = centersFloat[3 * i + 2] * 1000
                     centersInt[4 * i + 3] = 1000
                 }
                 attributeBuffers['centersInt'] = { buffer: buff2, attribute: pointAttribute };
-                attributeBuffers['centersFloat'] = { buffer: buff3, attribute: pointAttribute }; //暂时必须4位,以后再改cpp改为3位
+                attributeBuffers['centersFloat'] = { buffer: buff3, attribute: pointAttribute };  
             }
             
 		} else if (pointAttribute.name === "rgba") {