fix render glitches
This commit is contained in:
@@ -12,36 +12,29 @@ window.Tessellator = class {
|
||||
}
|
||||
|
||||
startDrawing() {
|
||||
this.verticies = [];
|
||||
this.addedVertices = 0;
|
||||
this.vertices = [];
|
||||
this.uv = [];
|
||||
this.index = [];
|
||||
}
|
||||
|
||||
addVertexWithUV(x, y, z, u, v) {
|
||||
this.addedVertices++;
|
||||
|
||||
// Add vertex
|
||||
this.verticies.push(x);
|
||||
this.verticies.push(y);
|
||||
this.verticies.push(z);
|
||||
this.vertices.push(x);
|
||||
this.vertices.push(y);
|
||||
this.vertices.push(z);
|
||||
|
||||
// Add UV
|
||||
this.uv.push(u);
|
||||
this.uv.push(v);
|
||||
|
||||
// Add index
|
||||
let index = this.index.length / 6;
|
||||
this.index.push(index + 0);
|
||||
this.index.push(index + 2);
|
||||
this.index.push(index + 1);
|
||||
this.index.push(index + 0);
|
||||
this.index.push(index + 3);
|
||||
this.index.push(index + 2);
|
||||
}
|
||||
|
||||
draw(group) {
|
||||
let geometry = new THREE.BufferGeometry();
|
||||
geometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(this.verticies), 3));
|
||||
geometry.setAttribute('position', new THREE.BufferAttribute(new Float32Array(this.vertices), 3));
|
||||
geometry.setAttribute('uv', new THREE.BufferAttribute(new Float32Array(this.uv), 2));
|
||||
geometry.setIndex(new THREE.BufferAttribute(new Uint32Array(this.index), 1));
|
||||
geometry.setIndex(new THREE.BufferAttribute(new Uint32Array([0, 2, 1, 0, 3, 2]), 1));
|
||||
|
||||
let mesh = new THREE.Mesh(geometry, this.material);
|
||||
group.add(mesh);
|
||||
|
||||
Reference in New Issue
Block a user