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
6204f95e
Commit
6204f95e
authored
Mar 04, 2017
by
amandaghassaei
Browse files
drag node
parent
ba32867c
Changes
5
Show whitespace changes
Inline
Side-by-side
index.html
View file @
6204f95e
...
...
@@ -83,13 +83,14 @@
vec2
fragCoord
=
gl_FragCoord
.
xy
;
vec2
scaledFragCoord
=
fragCoord
/
u_textureDim
;
vec3
lastPosition
=
texture2D
(
u_lastPosition
,
scaledFragCoord
).
xyz
;
float
isFixed
=
texture2D
(
u_mass
,
scaledFragCoord
).
y
;
if
(
isFixed
==
1.0
){
gl_FragColor
=
vec4
(
0.0
);
gl_FragColor
=
vec4
(
lastPosition
,
0.0
);
return
;
}
vec3
lastPosition
=
texture2D
(
u_lastPosition
,
scaledFragCoord
).
xyz
;
vec3
velocity
=
texture2D
(
u_velocity
,
scaledFragCoord
).
xyz
;
vec3
position
=
velocity
*
u_dt
+
lastPosition
;
gl_FragColor
=
vec4
(
position
,
0.0
);
...
...
@@ -122,7 +123,7 @@
vec2
scaledFragCoord
=
fragCoord
/
u_textureDim
;
vec2
mass
=
texture2D
(
u_mass
,
scaledFragCoord
).
xy
;
if
(
mass
.
y
==
1.0
){
//fixed
if
(
mass
[
1
]
==
1.0
){
//fixed
gl_FragColor
=
vec4
(
0.0
);
return
;
}
...
...
js/dynamicModel.js
View file @
6204f95e
...
...
@@ -382,12 +382,13 @@ function initDynamicModel(globals){
function
updateLastPosition
(){
for
(
var
i
=
0
;
i
<
nodes
.
length
;
i
++
){
var
_position
=
nodes
[
i
].
getRelativePositon
();
var
_position
=
nodes
[
i
].
getRelativePosit
i
on
();
lastPosition
[
4
*
i
]
=
_position
.
x
;
lastPosition
[
4
*
i
+
1
]
=
_position
.
y
;
lastPosition
[
4
*
i
+
2
]
=
_position
.
z
;
}
globals
.
gpuMath
.
initTextureFromData
(
"
u_lastPosition
"
,
textureDim
,
textureDim
,
"
FLOAT
"
,
lastPosition
,
true
);
globals
.
gpuMath
.
initFrameBufferForTexture
(
"
u_lastPosition
"
,
true
);
}
function
setCreasePercent
(
percent
){
...
...
js/main.js
View file @
6204f95e
...
...
@@ -115,16 +115,6 @@ $(function() {
return
_highlightedObj
;
}
function
dragNode
(
e
){
globals
.
threeView
.
enableControls
(
false
);
highlightedObj
.
highlight
();
raycasterPlane
.
set
(
raycasterPlane
.
normal
,
-
highlightedObj
.
getPosition
().
z
);
var
intersection
=
new
THREE
.
Vector3
();
raycaster
.
ray
.
intersectPlane
(
raycasterPlane
,
intersection
);
// globals.dynamicModel.updateFixedHeights();
// globals.dynamicModel.updateOriginalPosition();
}
globals
=
initGlobals
();
globals
.
model
=
initModel
(
globals
);
globals
.
dynamicModel
=
initDynamicModel
(
globals
);
...
...
js/node.js
View file @
6204f95e
...
...
@@ -145,7 +145,7 @@ Node.prototype.hide = function(){
};
Node
.
prototype
.
render
=
function
(
position
){
if
(
this
.
fixed
)
return
;
//
if (this.fixed) return;
position
.
add
(
this
.
getOriginalPosition
());
this
.
object3D
.
position
.
set
(
position
.
x
,
position
.
y
,
position
.
z
);
};
...
...
@@ -167,7 +167,7 @@ Node.prototype.getPosition = function(){
return
this
.
object3D
.
position
;
};
Node
.
prototype
.
getRelativePositon
=
function
(){
Node
.
prototype
.
getRelativePosit
i
on
=
function
(){
return
this
.
object3D
.
position
.
clone
().
sub
(
this
.
_originalPosition
);
};
...
...
js/threeView.js
View file @
6204f95e
...
...
@@ -8,7 +8,7 @@ function initThreeView(globals) {
var
wrapper
=
new
THREE
.
Object3D
();
var
patternWrapper
=
new
THREE
.
Object3D
();
var
modelWrapper
=
new
THREE
.
Object3D
();
var
camera
=
new
THREE
.
OrthographicCamera
(
window
.
innerWidth
/
-
2
,
window
.
innerWidth
/
2
,
window
.
innerHeight
/
2
,
window
.
innerHeight
/
-
2
,
-
1000
,
1000
);
//-40, 40);
var
camera
=
new
THREE
.
OrthographicCamera
(
window
.
innerWidth
/
-
2
,
window
.
innerWidth
/
2
,
window
.
innerHeight
/
2
,
window
.
innerHeight
/
-
2
,
-
1000
0
,
1000
0
);
//-40, 40);
var
renderer
=
new
THREE
.
WebGLRenderer
({
antialias
:
true
});
var
controls
;
...
...
@@ -45,9 +45,9 @@ function initThreeView(globals) {
camera
.
zoom
=
1
;
camera
.
updateProjectionMatrix
();
camera
.
position
.
x
=
40
;
camera
.
position
.
y
=
40
;
camera
.
position
.
z
=
40
;
camera
.
position
.
x
=
40
00
;
camera
.
position
.
y
=
40
00
;
camera
.
position
.
z
=
40
00
;
controls
=
new
THREE
.
OrbitControls
(
camera
,
container
.
get
(
0
));
controls
.
addEventListener
(
'
change
'
,
render
);
...
...
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