Commit 0ca9c8a7 authored by amandaghassaei's avatar amandaghassaei
Browse files

fixed webgl error

parent 8da8f6bb
......@@ -226,7 +226,6 @@ function initModel(globals){
for (var i=0;i<nodes.length;i++){
vertices.push(nodes[i].getPosition());
}
console.log(vertices.length);
positions = new Float32Array(vertices.length*3);
colors = new Float32Array(vertices.length*3);
......@@ -247,10 +246,11 @@ function initModel(globals){
indices[3*i+2] = face[2];
}
geometry = new THREE.BufferGeometry();
geometry.dynamic = true;
geometry.addAttribute('position', new THREE.BufferAttribute(positions, 3));
geometry.addAttribute('color', new THREE.BufferAttribute(colors, 3));
geometry.attributes.position.needsUpdate = true;
geometry.attributes.color.needsUpdate = true;
geometry.setIndex(new THREE.BufferAttribute(indices, 1));
geometry.computeVertexNormals();
......@@ -258,6 +258,10 @@ function initModel(globals){
geometry.computeBoundingSphere();
geometry.center();
object3D.geometry.dispose();
object3D.geometry = geometry;
object3D2.geometry = geometry;
//update vertices
for (var i=0;i<vertices.length;i++){
nodes[i].setOriginalPosition(positions[3*i], positions[3*i+1], positions[3*i+2]);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment