From d31f8b7fbe2a1500cfb54c494f82ba66912ba78e Mon Sep 17 00:00:00 2001
From: Amanda Ghassaei <amandaghassaei@gmail.com>
Date: Wed, 10 Jun 2015 15:55:17 -0700
Subject: [PATCH] gik part lines up

---
 js/parts/GIKPart.js        | 8 +++++---
 js/parts/GIKPartLowPoly.js | 8 +++++---
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/js/parts/GIKPart.js b/js/parts/GIKPart.js
index a1291d00..25f394be 100644
--- a/js/parts/GIKPart.js
+++ b/js/parts/GIKPart.js
@@ -7,11 +7,13 @@ define(['underscore', 'three', 'part', 'bin!gikPartSTL', 'bin!gikEndPartSTL', 's
 
     var loader = new THREE.STLLoader();
     var unitGeo = preProcessGeo(loader.parse(gikPart));
-    var unitGeoEnd = preProcessGeo(loader.parse(gikEndPart));
+    var unitGeoEnd = preProcessGeo(loader.parse(gikEndPart), true);
 
-    function preProcessGeo(geo){
+    function preProcessGeo(geo, endPart){
         geo.computeBoundingBox();
-        geo.applyMatrix(new THREE.Matrix4().makeTranslation(-(geo.boundingBox.min.x+0.5),
+        if (endPart) geo.applyMatrix(new THREE.Matrix4().makeTranslation(-(geo.boundingBox.min.x+0.5),
+            -(geo.boundingBox.min.y+geo.boundingBox.max.y)/2, -(geo.boundingBox.min.z+geo.boundingBox.max.z)/2));
+        else geo.applyMatrix(new THREE.Matrix4().makeTranslation(-(geo.boundingBox.min.x+geo.boundingBox.max.x)/2,
             -(geo.boundingBox.min.y+geo.boundingBox.max.y)/2, -(geo.boundingBox.min.z+geo.boundingBox.max.z)/2));
         var unitScale = 1/(1.2699999809265137);
         geo.applyMatrix(new THREE.Matrix4().makeRotationX(Math.PI/2));
diff --git a/js/parts/GIKPartLowPoly.js b/js/parts/GIKPartLowPoly.js
index 0aa6ae06..6eed63b9 100644
--- a/js/parts/GIKPartLowPoly.js
+++ b/js/parts/GIKPartLowPoly.js
@@ -8,11 +8,13 @@ define(['underscore', 'three', 'gikPart', 'bin!gikPartLowPolySTL', 'bin!gikEndPa
 
     var loader = new THREE.STLLoader();
     var unitGeo = preProcessGeo(loader.parse(gikPartLowPoly));
-    var unitGeoEnd = preProcessGeo(loader.parse(gikEndPartLowPoly));
+    var unitGeoEnd = preProcessGeo(loader.parse(gikEndPartLowPoly), true);
 
-    function preProcessGeo(geo){
+    function preProcessGeo(geo, endPart){
         geo.computeBoundingBox();
-        geo.applyMatrix(new THREE.Matrix4().makeTranslation(-(geo.boundingBox.min.x+0.5),
+        if (endPart) geo.applyMatrix(new THREE.Matrix4().makeTranslation(-(geo.boundingBox.min.x+0.5),
+            -(geo.boundingBox.min.y+geo.boundingBox.max.y)/2, -(geo.boundingBox.min.z+geo.boundingBox.max.z)/2));
+        else geo.applyMatrix(new THREE.Matrix4().makeTranslation(-(geo.boundingBox.min.x+geo.boundingBox.max.x)/2,
             -(geo.boundingBox.min.y+geo.boundingBox.max.y)/2, -(geo.boundingBox.min.z+geo.boundingBox.max.z)/2));
         var unitScale = 1/(1.2699999809265137);
         geo.applyMatrix(new THREE.Matrix4().makeRotationX(Math.PI/2));
-- 
GitLab