From d58b19f5a1e12e832e7aacc5ab61e353e597ad11 Mon Sep 17 00:00:00 2001 From: Jason Sturges Date: Tue, 26 Nov 2024 00:02:33 -0600 Subject: [PATCH] Modeling template --- examples/templates/modeling.html | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/examples/templates/modeling.html b/examples/templates/modeling.html index d9d0d16..a84614e 100644 --- a/examples/templates/modeling.html +++ b/examples/templates/modeling.html @@ -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 = [ @@ -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); } }