Commit 3fc66b45 authored by amandaghassaei's avatar amandaghassaei
Browse files

buffergeometry

parent e8504634
......@@ -460,7 +460,7 @@
<a href="#" class="dropdown-toggle" data-toggle="dropdown">File <b class="caret"></b></a>
<span class="dropdown-arrow"></span>
<ul class="dropdown-menu">
<li><a class="loadFile" href="#">Import... (SVG / FOLD / txt)</a></li>
<li><a class="loadFile" href="#">Import... (SVG / FOLD)</a></li>
<li><a id="tips" href="#">File Import Tips</a></li>
<li class="divider"></li>
<li><a id="exportFOLD" href="#">Save Simulation as FOLD...</a></li>
......@@ -604,7 +604,7 @@
<div class="fullWidth">
<a href="#" class="seeMore closed" data-id="errorInfo"><span class="fui-triangle-down"></span><b>Error:</b></a><a class="about" href="#" id="aboutError"><span class="fui-question-circle"></span></a><br/>
<div id="errorInfo" class="hide smallTxt doubleIndent">
<label>Average node error: <span id="globalError"></span></label>
<label>Average vertex error: <span id="globalError"></span></label>
</div>
</div><br/>
......@@ -763,7 +763,7 @@
<li>The final fold angle of a mountain or valley fold is set by its opacity. For example, 1.0 = 180&deg;
(fully folded), 0.5 = 90&deg;, 0 = 0&deg; (flat). Any fold angle between 0&deg; and 180&deg; may be used.</li>
<li>This tool should be able to automatically clean files of slightly misaligned vertices, stray vertices,
duplicate lines (coming), and extra vertices falling in the middle of an edge (coming),
duplicate lines, and extra vertices falling in the middle of an edge,
but it is recommended to remove these errors yourself in order to avoid problems.</li>
<li>If your simulation is not working, check that the pattern looks correct by clicking on the "Pattern" view in the top nav bar.</li>
</ul><br/>
......@@ -798,7 +798,7 @@
<br/><br/>
When you open this page with the appropriate browser and a Vive connected through Steam VR, you will see a button that says "Enter VR". Clicking this will
put the app in an interactive VR mode. The hand controllers will allow you to grab the origami mesh and pull on it.
This is especially cool if you set the <b>Mesh Material</b> to <b>Strain Visualization</b> so you can see how your interactions
This is especially interesting if you set the <b>Mesh Material</b> to <b>Strain Visualization</b> so you can see how your interactions
change the internal strains in the material.
<br/><br/>
If the simulation looks choppy, consider lowering the <b>Num simulation steps per render</b> setting under <b>Animation Settings</b> in the right hand menu.
......@@ -815,9 +815,9 @@
<span aria-hidden="true">&times;</span>
</button>
<p><b>Animation Settings</b><br/><br/>
The dynamic simulation is calculated by moving time forward in small <b>&Delta;t</b> steps, solving the system, and moving the
vertices of the origami incrementally. The time step size for this animation is calculated automatically
based on the material stiffnesses set in the <b>Stiffness Settings</b> section: more stiff settings
The dynamic simulation is calculated by solving for all the forces in the system, moving time forward in small <b>&Delta;t</b> steps,
and updating the vertices of the origami incrementally. The time step size for this animation is calculated automatically
based on the material stiffnesses set in the <b>Simulation Settings</b> section: more stiff settings
require shorter time steps to solve and will slow down the simulation.<br/>
<br/>
<b>Num simulation steps per render</b> allows you to control the number of tiny time steps forward to take on each
......@@ -954,17 +954,17 @@
<span aria-hidden="true">&times;</span>
</button>
<p><b>Simulation Error</b><br/><br/>
<b>Average node error</b> gives a sense of how much the distance constraints in the
origami pattern are being violated. The error at each node is evaluated by averaging the
percent deviation of all its distance constraints with adjacent nodes. This error is
<b>Average vertex error</b> gives a sense of how much the distance constraints in the
origami pattern are being violated (i.e. how much the sheet is being stretched). The error at each vertex is evaluated by averaging the
percent deviation of all its distance constraints with adjacent vertices. This error is
reported as a percent of the total length of the distance constraint to remove scaling effects.
<br/><br/>
This measurement is equivalent to <a href="https://en.wikipedia.org/wiki/Deformation_(mechanics)#Engineering_strain" target="_blank">
Cauchy strain or engineering strain</a> of the axial constraints on this system.
Cauchy strain or engineering strain</a> of the distance constraints on this system.
Increasing the <b>Axial Stiffness</b> will tighten these constraints and
lower the error in the simulation.<br/>
<br/>
To visualize the error of each node graphically, select <b>Strain Visualization</b> under <b>Mesh Material</b>
To visualize the error of each vertex graphically, select <b>Strain Visualization</b> under <b>Mesh Material</b>
in the left menu.
</p>
</div>
......
......@@ -15,17 +15,33 @@ function initModel(globals){
backside.visible = false;
setMeshMaterial();
var lineGeometries = [];
for (var i=0;i<5;i++){
var lineGeometry = new THREE.BufferGeometry();
lineGeometry.dynamic = true;
lineGeometries.push(lineGeometry);
}
var lineMaterial = new THREE.LineBasicMaterial({color: 0x000000, linewidth: 1});
var mountainLines = new THREE.LineSegments(geometry);
var valleyLines = new THREE.LineSegments(geometry);
var facetLines = new THREE.LineSegments(geometry);
var hingeLines = new THREE.LineSegments(geometry);
var cutLines = new THREE.LineSegments(geometry);
var hingeLines = new THREE.LineSegments(lineGeometries[0], lineMaterial);
var mountainLines = new THREE.LineSegments(lineGeometries[1], lineMaterial);
var valleyLines = new THREE.LineSegments(lineGeometries[2], lineMaterial);
var cutLines = new THREE.LineSegments(lineGeometries[3], lineMaterial);
var facetLines = new THREE.LineSegments(lineGeometries[4], lineMaterial);
var allTypes;//place to store line types
// var borderLines = new THREE.LineSegments(geometry);
globals.threeView.sceneAddModel(frontside);
globals.threeView.sceneAddModel(backside);
globals.threeView.sceneAddModel(mountainLines);
globals.threeView.sceneAddModel(valleyLines);
globals.threeView.sceneAddModel(facetLines);
globals.threeView.sceneAddModel(hingeLines);
globals.threeView.sceneAddModel(cutLines);
var positions;//place to store buffer geo vertex data
var colors;//place to store buffer geo vertex colors
var indices;
var indices, lineIndices;
var nodes = [];
var faces = [];
var edges = [];
......@@ -80,16 +96,11 @@ function initModel(globals){
}
function updateEdgeVisibility(){
for (var i=0;i<edges.length;i++){
edges[i].setVisibility(false);
}
if (!globals.edgesVisible) return;
for (var i=0;i<edges.length;i++){
edges[i].setVisibility(globals.passiveEdgesVisible);
}
for (var i=0;i<creases.length;i++){
creases[i].setVisibility();
}
mountainLines.visible = globals.edgesVisible && globals.mtnsVisible;
valleyLines.visible = globals.edgesVisible && globals.valleysVisible;
facetLines.visible = globals.edgesVisible && globals.panelsVisible;
hingeLines.visible = globals.edgesVisible && globals.passiveEdgesVisible;
cutLines.visible = false;
}
function updateMeshVisibility(){
......@@ -153,7 +164,9 @@ function initModel(globals){
function buildModel(_faces, _vertices, _allEdges, allCreaseParams){
function buildModel(_faces, _vertices, _allEdges, allCreaseParams, _allTypes){
allTypes = _allTypes;
if (_vertices.length == 0) {
console.warn("no vertices");
......@@ -204,16 +217,6 @@ function initModel(globals){
function sync(){
globals.threeView.sceneClearModel();
// _.each(_nodes, function(node){
// var obj3D = node.getObject3D();
// globals.threeView.sceneAddModel(obj3D);
// });
_.each(nextEdges, function(edge){
globals.threeView.sceneAddModel(edge.getObject3D());
});
for (var i=0;i<nodes.length;i++){
nodes[i].destroy();
}
......@@ -247,6 +250,7 @@ function initModel(globals){
positions = new Float32Array(vertices.length*3);
colors = new Float32Array(vertices.length*3);
indices = new Uint16Array(faces.length*3);
lineIndices = new Uint16Array(edges.length*2);
for (var i=0;i<vertices.length;i++){
positions[3*i] = vertices[i].x;
......@@ -259,25 +263,34 @@ function initModel(globals){
indices[3*i+1] = face[1];
indices[3*i+2] = face[2];
}
for (var i=0;i<edges.length;i++){
var edge = edges[i];
lineIndices[2*i] = edge.nodes[0].getIndex();
lineIndices[2*i+1] = edge.nodes[1].getIndex();
}
geometry = new THREE.BufferGeometry();
geometry.dynamic = true;
geometry.addAttribute('position', new THREE.BufferAttribute(positions, 3));
var positionsAttribute = new THREE.BufferAttribute(positions, 3);
geometry.addAttribute('position', positionsAttribute);
geometry.addAttribute('color', new THREE.BufferAttribute(colors, 3));
geometry.setIndex(new THREE.BufferAttribute(indices, 1));
geometry.computeVertexNormals();
geometry.computeBoundingBox();
geometry.computeBoundingSphere();
geometry.center();
_.each(lineGeometries, function(lineGeometry){
lineGeometry.addAttribute('position', positionsAttribute);
lineGeometry.setIndex(new THREE.BufferAttribute(lineIndices, 1));
lineGeometry.computeBoundingBox();
lineGeometry.computeBoundingSphere();
lineGeometry.center();
});
var scale = 1/geometry.boundingSphere.radius;
globals.scale = scale;
backside.geometry = geometry;
frontside.geometry.dispose();
frontside.geometry = geometry;
//scale geometry
for (var i=0;i<positions.length;i++){
......@@ -295,8 +308,12 @@ function initModel(globals){
edges[i].recalcOriginalLength();
}
globals.threeView.sceneAddModel(frontside);
globals.threeView.sceneAddModel(backside);
console.log(allTypes[4]);
hingeLines.geometry.setDrawRange(0, allTypes[0]*2);
mountainLines.geometry.setDrawRange(allTypes[0]*2, allTypes[1]*2);
valleyLines.geometry.setDrawRange((allTypes[0]+allTypes[1])*2, allTypes[2]*2);
cutLines.geometry.setDrawRange((allTypes[0]+allTypes[1]+allTypes[2])*2, allTypes[3]*2);
facetLines.geometry.setDrawRange((allTypes[0]+allTypes[1]+allTypes[2]+allTypes[3])*2, Infinity);
updateEdgeVisibility();
updateMeshVisibility();
......
......@@ -238,7 +238,10 @@ function initPattern(globals){
$("#numPassive").html("(" + outlines.length + ")");
var allCreaseParams = getFacesAndVerticesForEdges(faces, allEdges);
globals.model.buildModel(faces, vertices, allEdges, allCreaseParams);
var allTypes = [outlines.length, mountains.length, valleys.length, cuts.length];
globals.model.buildModel(faces, vertices, allEdges, allCreaseParams, allTypes);
}
function removeNullEdges(allEdges){
......
......@@ -125,7 +125,7 @@ function initThreeView(globals) {
_render();
}
function sceneAddModel(object){//beams and nodes
function sceneAddModel(object){
modelWrapper.add(object);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment