Commit 1a29f450 authored by amandaghassaei's avatar amandaghassaei
Browse files

curved txt

parent ba920a74
This diff is collapsed.
......@@ -392,7 +392,8 @@
<li><a href="#" class="demo" data-url="Tessellations/squaretwistManyAngles.svg">Square Twist (many angles)</a></li>
<li><a href="#" class="demo" data-url="Tessellations/reschtritessellation.svg">Resch Triangle Tessellation</a></li>
<li><a href="#" class="demo" data-url="Origami/hypar.svg">Hypar (not fully working yet)</a></li>
<li class="divider"></li>
<li><a href="#" class="demo" data-url="Curved/creaseMesh.txt">Curved Crease 1</a></li>
</ul>
</li>
<li><a class="loadFile" href="#">Import .txt...</a></li>
......
......@@ -97,7 +97,14 @@ function initControls(globals){
setLink(".demo", function(e){
var url = $(e.target).data("url");
if (url) {
globals.pattern.loadSVG("assets/" + url);
var extension = url.split(".");
extension = extension[extension.length-1];
if (extension == "txt"){
$.getJSON( "assets/"+url, function( json ) {
parseTXTjson(json);
});
} else globals.pattern.loadSVG("assets/" + url);
}
});
......@@ -118,7 +125,25 @@ function initControls(globals){
reader.onload = function(){
return function(e) {
if (!reader.result) return;
var json = JSON.parse(reader.result);
parseTXTjson(JSON.parse(reader.result));
}
}(file);
reader.readAsText(file);
} else if (extension == "svg"){
reader.onload = function(){
return function(e) {
globals.pattern.loadSVG(e.target.result);
}
}(file);
reader.readAsDataURL(file);
} else {
console.warn("unknown extension: " + extension);
return null;
}
});
function parseTXTjson(json){
_.each(json.faceNodeIndices, function(face, i){
json.faceNodeIndices[i] = new THREE.Face3(face[0], face[1], face[2]);
......@@ -190,21 +215,6 @@ function initControls(globals){
});
globals.model.buildModel(faces, json.nodes, json.edges, allCreaseParams);
}
}(file);
reader.readAsText(file);
} else if (extension == "svg"){
reader.onload = function(){
return function(e) {
globals.pattern.loadSVG(e.target.result);
}
}(file);
reader.readAsDataURL(file);
} else {
console.warn("unknown extension: " + extension);
return null;
}
});
setCheckbox("#ambientOcclusion", globals.ambientOcclusion, function(val){
globals.ambientOcclusion = val;
......
Supports Markdown
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