From 66d1ea46b84558e0340dd9c91b79c99d3f8320a8 Mon Sep 17 00:00:00 2001 From: amandaghassaei <amandaghassaei@gmail.com> Date: Sun, 30 Apr 2017 02:06:28 -0400 Subject: [PATCH] dynamic model working again --- index.html | 2 +- js/dynamic/dynamicModel.js | 6 +++--- js/globals.js | 2 +- js/main.js | 2 +- js/model.js | 16 ++++++++-------- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/index.html b/index.html index d3a0bbb..9d42f2f 100644 --- a/index.html +++ b/index.html @@ -180,7 +180,7 @@ if (creaseMeta2[3] < 0.0){//crease reaction float nodeNum = creaseMeta2[2]; - //node #1 + //node #1 float normalIndex1D = thetas[2]; vec2 normalsIndex = vec2(mod(normalIndex1D, u_textureDimFaces.x)+0.5, floor(normalIndex1D/u_textureDimFaces.x)+0.5); vec2 scaledNormalsIndex = normalsIndex/u_textureDimFaces; diff --git a/js/dynamic/dynamicModel.js b/js/dynamic/dynamicModel.js index 5eb9721..c4a4f4a 100644 --- a/js/dynamic/dynamicModel.js +++ b/js/dynamic/dynamicModel.js @@ -370,9 +370,9 @@ function initDynamicModel(globals){ for (var i=0;i<creases.length;i++){ var rgbaIndex = i*4; var vector = creases[i].getVector(); - creaseVectors[rgbaIndex] = vector.x; - creaseVectors[rgbaIndex+1] = vector.y; - creaseVectors[rgbaIndex+2] = vector.z; + creaseVectors[rgbaIndex] = -vector.x; + creaseVectors[rgbaIndex+1] = -vector.y; + creaseVectors[rgbaIndex+2] = -vector.z; } globals.gpuMath.initTextureFromData("u_creaseVectors", textureDimCreases, textureDimCreases, "FLOAT", creaseVectors, true); } diff --git a/js/globals.js b/js/globals.js index 9d03085..0c67219 100644 --- a/js/globals.js +++ b/js/globals.js @@ -25,7 +25,7 @@ function initGlobals(){ //sim settings creasePercent: 0, axialStiffness: 100, - creaseStiffness: 10, + creaseStiffness: 30, panelStiffness: 1, //dynamic sim settings diff --git a/js/main.js b/js/main.js index 368b84d..9d248fb 100644 --- a/js/main.js +++ b/js/main.js @@ -120,7 +120,7 @@ $(function() { globals = initGlobals(); globals.model = initModel(globals); globals.staticSolver = initStaticSolver(globals); - globals.dynamicSolver = initDynamicModel(globals); + globals.dynamicModel = initDynamicModel(globals); // globals.staticSolver.syncNodesAndEdges(); globals.pattern = initPattern(globals); globals.threeView.render(); diff --git a/js/model.js b/js/model.js index 5d57083..56aeeff 100644 --- a/js/model.js +++ b/js/model.js @@ -12,10 +12,10 @@ function initModel(globals){ nodes.push(new Node(new THREE.Vector3(0,0,10), nodes.length)); nodes.push(new Node(new THREE.Vector3(10,0,0), nodes.length)); nodes.push(new Node(new THREE.Vector3(0,0,-10), nodes.length)); - // nodes.push(new Node(new THREE.Vector3(10,0,-10), nodes.length)); - nodes[0].setFixed(true); - nodes[1].setFixed(true); - nodes[2].setFixed(true); + nodes.push(new Node(new THREE.Vector3(10,0,-10), nodes.length)); + // nodes[0].setFixed(true); + // nodes[1].setFixed(true); + // nodes[2].setFixed(true); var edges = []; edges.push(new Beam([nodes[0], nodes[1]])); @@ -23,17 +23,17 @@ function initModel(globals){ edges.push(new Beam([nodes[2], nodes[0]])); edges.push(new Beam([nodes[3], nodes[0]])); edges.push(new Beam([nodes[3], nodes[2]])); - // edges.push(new Beam([nodes[3], nodes[4]])); - // edges.push(new Beam([nodes[2], nodes[4]])); + edges.push(new Beam([nodes[3], nodes[4]])); + edges.push(new Beam([nodes[2], nodes[4]])); var faces = []; faces.push(new THREE.Face3(0,1,2)); faces.push(new THREE.Face3(0,2,3)); - // faces.push(new THREE.Face3(4,3,2)); + faces.push(new THREE.Face3(4,3,2)); var creases = []; creases.push(new Crease(edges[2], 0, 1, Math.PI-0.001, 1, nodes[1], nodes[3], 0)); - // creases.push(new Crease(edges[4], 2, 1, -(Math.PI-0.001), 1, nodes[4], nodes[0], 1)); + creases.push(new Crease(edges[4], 2, 1, -(Math.PI-0.001), 1, nodes[4], nodes[0], 1)); var _allNodeObject3Ds = []; _.each(nodes, function(node){ -- GitLab