From f61b75077559243af199166f71f6bb17fd6735d4 Mon Sep 17 00:00:00 2001 From: howard Date: Wed, 7 Apr 2021 21:39:00 -0700 Subject: [PATCH] add dimension to origin --- src/Sketch.js | 2 +- src/patch.js | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/Sketch.js b/src/Sketch.js index d019f06..1a04494 100644 --- a/src/Sketch.js +++ b/src/Sketch.js @@ -49,7 +49,7 @@ class Sketch { this.constraints = new Map() this.c_id = 1; - this.obj3d.add(new THREE.Group().add(new AxesHelper(0.5))); + this.obj3d.add(new THREE.Group().add(new AxesHelper(1))); this.obj3d.add(new THREE.Group()); this.obj3d.add(new THREE.Group()); diff --git a/src/patch.js b/src/patch.js index 75e9d99..68b149a 100644 --- a/src/patch.js +++ b/src/patch.js @@ -12,14 +12,26 @@ class Patch extends THREE.Mesh { constructor(s = 1) { + + + const positions = [ - 0.5 * s, 0, 0, - 0.3 * s, 0.08*s, 0, - 0.3 * s, -0.08*s, 0 + 0.5, 0, + 0.3, 0.08, + 0.3, -0.08, ]; - const geometry = new BufferGeometry(); - geometry.setAttribute('position', new Float32BufferAttribute(positions, 3)); + const shape = new THREE.Shape() + + shape.moveTo(positions[0], positions[1]) + + for (let i = 2; i < positions.length; i += 2) { + shape.lineTo(positions[i], positions[i+1]) + } + + console.log(shape) + + const geometry = new THREE.ShapeGeometry( shape );; super( @@ -34,6 +46,7 @@ class Patch extends THREE.Mesh { }) ) + this.scale.set( 1, 1, 1 ); return this; }