Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Amanda Ghassaei
OrigamiSimulator
Commits
1a29f450
Commit
1a29f450
authored
May 03, 2017
by
amandaghassaei
Browse files
curved txt
parent
ba920a74
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
assets/Curved/creaseMesh.txt
0 → 100644
View file @
1a29f450
This diff is collapsed.
Click to expand it.
index.html
View file @
1a29f450
...
...
@@ -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>
...
...
js/controls.js
View file @
1a29f450
...
...
@@ -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,77 +125,7 @@ function initControls(globals){
reader
.
onload
=
function
(){
return
function
(
e
)
{
if
(
!
reader
.
result
)
return
;
var
json
=
JSON
.
parse
(
reader
.
result
);
_
.
each
(
json
.
faceNodeIndices
,
function
(
face
,
i
){
json
.
faceNodeIndices
[
i
]
=
new
THREE
.
Face3
(
face
[
0
],
face
[
1
],
face
[
2
]);
});
var
faces
=
json
.
faceNodeIndices
;
var
allCreaseParams
=
[];
for
(
var
i
=
0
;
i
<
json
.
edges
.
length
;
i
++
){
var
v1
=
json
.
edges
[
i
].
vertices
[
0
];
var
v2
=
json
.
edges
[
i
].
vertices
[
1
];
var
creaseParams
=
[];
for
(
var
j
=
0
;
j
<
faces
.
length
;
j
++
){
var
face
=
faces
[
j
];
var
faceVerts
=
[
face
.
a
,
face
.
b
,
face
.
c
];
var
v1Index
=
faceVerts
.
indexOf
(
v1
);
if
(
v1Index
>=
0
){
var
v2Index
=
faceVerts
.
indexOf
(
v2
);
if
(
v2Index
>=
0
){
creaseParams
.
push
(
j
);
if
(
v2Index
>
v1Index
)
{
//remove larger index first
faceVerts
.
splice
(
v2Index
,
1
);
faceVerts
.
splice
(
v1Index
,
1
);
}
else
{
faceVerts
.
splice
(
v1Index
,
1
);
faceVerts
.
splice
(
v2Index
,
1
);
}
creaseParams
.
push
(
faceVerts
[
0
]);
if
(
creaseParams
.
length
==
4
)
{
if
(
v2Index
-
v1Index
==
1
||
v2Index
-
v1Index
==
-
2
)
{
creaseParams
=
[
creaseParams
[
2
],
creaseParams
[
3
],
creaseParams
[
0
],
creaseParams
[
1
]];
}
creaseParams
.
push
(
i
);
var
shouldSkip
=
false
;
switch
(
json
.
edges
[
i
].
type
){
case
0
:
//rule lines
shouldSkip
=
true
;
break
;
case
1
:
//quad panels
creaseParams
.
push
(
0
);
break
;
case
3
:
//outline
shouldSkip
=
true
;
break
;
case
2
:
//crease
creaseParams
.
push
(
Math
.
PI
);
break
;
}
if
(
!
shouldSkip
)
allCreaseParams
.
push
(
creaseParams
);
break
;
}
}
}
}
}
_
.
each
(
json
.
nodes
,
function
(
node
,
i
){
json
.
nodes
[
i
]
=
new
THREE
.
Vector3
(
node
.
x
,
node
.
y
,
node
.
z
);
});
_
.
each
(
json
.
edges
,
function
(
edge
,
i
){
json
.
edges
[
i
]
=
[
edge
.
vertices
[
0
],
edge
.
vertices
[
1
]];
});
globals
.
model
.
buildModel
(
faces
,
json
.
nodes
,
json
.
edges
,
allCreaseParams
);
parseTXTjson
(
JSON
.
parse
(
reader
.
result
));
}
}(
file
);
reader
.
readAsText
(
file
);
...
...
@@ -206,6 +143,79 @@ function initControls(globals){
});
function
parseTXTjson
(
json
){
_
.
each
(
json
.
faceNodeIndices
,
function
(
face
,
i
){
json
.
faceNodeIndices
[
i
]
=
new
THREE
.
Face3
(
face
[
0
],
face
[
1
],
face
[
2
]);
});
var
faces
=
json
.
faceNodeIndices
;
var
allCreaseParams
=
[];
for
(
var
i
=
0
;
i
<
json
.
edges
.
length
;
i
++
){
var
v1
=
json
.
edges
[
i
].
vertices
[
0
];
var
v2
=
json
.
edges
[
i
].
vertices
[
1
];
var
creaseParams
=
[];
for
(
var
j
=
0
;
j
<
faces
.
length
;
j
++
){
var
face
=
faces
[
j
];
var
faceVerts
=
[
face
.
a
,
face
.
b
,
face
.
c
];
var
v1Index
=
faceVerts
.
indexOf
(
v1
);
if
(
v1Index
>=
0
){
var
v2Index
=
faceVerts
.
indexOf
(
v2
);
if
(
v2Index
>=
0
){
creaseParams
.
push
(
j
);
if
(
v2Index
>
v1Index
)
{
//remove larger index first
faceVerts
.
splice
(
v2Index
,
1
);
faceVerts
.
splice
(
v1Index
,
1
);
}
else
{
faceVerts
.
splice
(
v1Index
,
1
);
faceVerts
.
splice
(
v2Index
,
1
);
}
creaseParams
.
push
(
faceVerts
[
0
]);
if
(
creaseParams
.
length
==
4
)
{
if
(
v2Index
-
v1Index
==
1
||
v2Index
-
v1Index
==
-
2
)
{
creaseParams
=
[
creaseParams
[
2
],
creaseParams
[
3
],
creaseParams
[
0
],
creaseParams
[
1
]];
}
creaseParams
.
push
(
i
);
var
shouldSkip
=
false
;
switch
(
json
.
edges
[
i
].
type
){
case
0
:
//rule lines
shouldSkip
=
true
;
break
;
case
1
:
//quad panels
creaseParams
.
push
(
0
);
break
;
case
3
:
//outline
shouldSkip
=
true
;
break
;
case
2
:
//crease
creaseParams
.
push
(
Math
.
PI
);
break
;
}
if
(
!
shouldSkip
)
allCreaseParams
.
push
(
creaseParams
);
break
;
}
}
}
}
}
_
.
each
(
json
.
nodes
,
function
(
node
,
i
){
json
.
nodes
[
i
]
=
new
THREE
.
Vector3
(
node
.
x
,
node
.
y
,
node
.
z
);
});
_
.
each
(
json
.
edges
,
function
(
edge
,
i
){
json
.
edges
[
i
]
=
[
edge
.
vertices
[
0
],
edge
.
vertices
[
1
]];
});
globals
.
model
.
buildModel
(
faces
,
json
.
nodes
,
json
.
edges
,
allCreaseParams
);
}
setCheckbox
(
"
#ambientOcclusion
"
,
globals
.
ambientOcclusion
,
function
(
val
){
globals
.
ambientOcclusion
=
val
;
});
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment