Skip to content

Commit

Permalink
Modeling template
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonsturges committed Nov 26, 2024
1 parent 7085143 commit d58b19f
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions examples/templates/modeling.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
super();

const vertices = [
0, 0, 0,
1, 0, 0,
1, 1, 0,
0, 1, 0,
0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0,
];

// Counter clockwise: a, b, d b, c, d
const indices = [
0, 1, 3, 1, 2, 3,
];

const normals = [
Expand All @@ -41,22 +43,16 @@
0, 0, 1, 0, 1, 1, 0, 1,
];

const indices = [
0, 1, 2, 0, 2, 3,
];

const positions = new Float32Array(vertices);
const normalArray = new Float32Array(normals);
const uvArray = new Float32Array(uvs);
const indexArray = new Uint16Array(indices);

const geometry = new THREE.BufferGeometry();
geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
geometry.setAttribute('normal', new THREE.BufferAttribute(normalArray, 3));
geometry.setAttribute('uv', new THREE.BufferAttribute(uvArray, 2));
geometry.setIndex(new THREE.BufferAttribute(indexArray, 1));
this.setAttribute('position', new THREE.BufferAttribute(positions, 3));
this.setAttribute('normal', new THREE.BufferAttribute(normalArray, 3));
this.setAttribute('uv', new THREE.BufferAttribute(uvArray, 2));
this.setIndex(indices);

this.copy(mergeGeometries([geometry], false));
this.addGroup(0, 6, 0);
}
}

Expand Down

0 comments on commit d58b19f

Please sign in to comment.