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
5f39910a
Commit
5f39910a
authored
May 02, 2017
by
amandaghassaei
Browse files
small changes
parent
3e50d17b
Changes
1
Hide whitespace changes
Inline
Side-by-side
js/dynamic/dynamicModel.js
View file @
5f39910a
...
@@ -30,15 +30,14 @@ function initDynamicModel(globals){
...
@@ -30,15 +30,14 @@ function initDynamicModel(globals){
var
theta
;
//[theta, w, normalIndex1, normalIndex2]
var
theta
;
//[theta, w, normalIndex1, normalIndex2]
var
lastTheta
;
//[theta, w, normalIndex1, normalIndex2]
var
lastTheta
;
//[theta, w, normalIndex1, normalIndex2]
function
syncNodesAndEdges
(
firstTime
){
function
syncNodesAndEdges
(){
nodes
=
globals
.
model
.
getNodes
();
nodes
=
globals
.
model
.
getNodes
();
edges
=
globals
.
model
.
getEdges
();
edges
=
globals
.
model
.
getEdges
();
faces
=
globals
.
model
.
getFaces
();
faces
=
globals
.
model
.
getFaces
();
creases
=
globals
.
model
.
getCreases
();
creases
=
globals
.
model
.
getCreases
();
initTypedArrays
();
initTypedArrays
();
if
(
firstTime
===
undefined
)
firstTime
=
false
;
initTexturesAndPrograms
(
globals
.
gpuMath
);
initTexturesAndPrograms
(
globals
.
gpuMath
,
firstTime
);
steps
=
parseInt
(
setSolveParams
());
steps
=
parseInt
(
setSolveParams
());
}
}
...
@@ -65,7 +64,7 @@ function initDynamicModel(globals){
...
@@ -65,7 +64,7 @@ function initDynamicModel(globals){
function
solve
(){
function
solve
(){
if
(
globals
.
shouldSyncWithModel
){
if
(
globals
.
shouldSyncWithModel
){
syncNodesAndEdges
(
true
);
syncNodesAndEdges
();
// reset();
// reset();
globals
.
shouldSyncWithModel
=
false
;
globals
.
shouldSyncWithModel
=
false
;
}
else
{
}
else
{
...
@@ -201,25 +200,25 @@ function initDynamicModel(globals){
...
@@ -201,25 +200,25 @@ function initDynamicModel(globals){
return
(
1
/
(
2
*
Math
.
PI
*
maxFreqNat
))
*
0.9
;
//0.9 of max delta t for good measure
return
(
1
/
(
2
*
Math
.
PI
*
maxFreqNat
))
*
0.9
;
//0.9 of max delta t for good measure
}
}
function
initTexturesAndPrograms
(
gpuMath
,
firstTime
){
function
initTexturesAndPrograms
(
gpuMath
){
var
vertexShader
=
document
.
getElementById
(
"
vertexShader
"
).
text
;
var
vertexShader
=
document
.
getElementById
(
"
vertexShader
"
).
text
;
gpuMath
.
initTextureFromData
(
"
u_position
"
,
textureDim
,
textureDim
,
"
FLOAT
"
,
position
,
!
firstTim
e
);
gpuMath
.
initTextureFromData
(
"
u_position
"
,
textureDim
,
textureDim
,
"
FLOAT
"
,
position
,
tru
e
);
gpuMath
.
initTextureFromData
(
"
u_lastPosition
"
,
textureDim
,
textureDim
,
"
FLOAT
"
,
lastPosition
,
!
firstTim
e
);
gpuMath
.
initTextureFromData
(
"
u_lastPosition
"
,
textureDim
,
textureDim
,
"
FLOAT
"
,
lastPosition
,
tru
e
);
gpuMath
.
initTextureFromData
(
"
u_velocity
"
,
textureDim
,
textureDim
,
"
FLOAT
"
,
velocity
,
!
firstTim
e
);
gpuMath
.
initTextureFromData
(
"
u_velocity
"
,
textureDim
,
textureDim
,
"
FLOAT
"
,
velocity
,
tru
e
);
gpuMath
.
initTextureFromData
(
"
u_lastVelocity
"
,
textureDim
,
textureDim
,
"
FLOAT
"
,
lastVelocity
,
!
firstTim
e
);
gpuMath
.
initTextureFromData
(
"
u_lastVelocity
"
,
textureDim
,
textureDim
,
"
FLOAT
"
,
lastVelocity
,
tru
e
);
gpuMath
.
initTextureFromData
(
"
u_theta
"
,
textureDimCreases
,
textureDimCreases
,
"
FLOAT
"
,
theta
,
!
firstTim
e
);
gpuMath
.
initTextureFromData
(
"
u_theta
"
,
textureDimCreases
,
textureDimCreases
,
"
FLOAT
"
,
theta
,
tru
e
);
gpuMath
.
initTextureFromData
(
"
u_lastTheta
"
,
textureDimCreases
,
textureDimCreases
,
"
FLOAT
"
,
lastTheta
,
!
firstTim
e
);
gpuMath
.
initTextureFromData
(
"
u_lastTheta
"
,
textureDimCreases
,
textureDimCreases
,
"
FLOAT
"
,
lastTheta
,
tru
e
);
gpuMath
.
initTextureFromData
(
"
u_normals
"
,
textureDimFaces
,
textureDimFaces
,
"
FLOAT
"
,
normals
,
!
firstTim
e
);
gpuMath
.
initTextureFromData
(
"
u_normals
"
,
textureDimFaces
,
textureDimFaces
,
"
FLOAT
"
,
normals
,
tru
e
);
gpuMath
.
initFrameBufferForTexture
(
"
u_position
"
,
!
firstTim
e
);
gpuMath
.
initFrameBufferForTexture
(
"
u_position
"
,
tru
e
);
gpuMath
.
initFrameBufferForTexture
(
"
u_lastPosition
"
,
!
firstTim
e
);
gpuMath
.
initFrameBufferForTexture
(
"
u_lastPosition
"
,
tru
e
);
gpuMath
.
initFrameBufferForTexture
(
"
u_velocity
"
,
!
firstTim
e
);
gpuMath
.
initFrameBufferForTexture
(
"
u_velocity
"
,
tru
e
);
gpuMath
.
initFrameBufferForTexture
(
"
u_lastVelocity
"
,
!
firstTim
e
);
gpuMath
.
initFrameBufferForTexture
(
"
u_lastVelocity
"
,
tru
e
);
gpuMath
.
initFrameBufferForTexture
(
"
u_theta
"
,
!
firstTim
e
);
gpuMath
.
initFrameBufferForTexture
(
"
u_theta
"
,
tru
e
);
gpuMath
.
initFrameBufferForTexture
(
"
u_lastTheta
"
,
!
firstTim
e
);
gpuMath
.
initFrameBufferForTexture
(
"
u_lastTheta
"
,
tru
e
);
gpuMath
.
initFrameBufferForTexture
(
"
u_normals
"
,
!
firstTim
e
);
gpuMath
.
initFrameBufferForTexture
(
"
u_normals
"
,
tru
e
);
gpuMath
.
initTextureFromData
(
"
u_meta
"
,
textureDim
,
textureDim
,
"
FLOAT
"
,
meta
,
true
);
gpuMath
.
initTextureFromData
(
"
u_meta
"
,
textureDim
,
textureDim
,
"
FLOAT
"
,
meta
,
true
);
gpuMath
.
initTextureFromData
(
"
u_creaseMeta2
"
,
textureDimNodeCreases
,
textureDimNodeCreases
,
"
FLOAT
"
,
creaseMeta2
,
true
);
gpuMath
.
initTextureFromData
(
"
u_creaseMeta2
"
,
textureDimNodeCreases
,
textureDimNodeCreases
,
"
FLOAT
"
,
creaseMeta2
,
true
);
...
@@ -268,8 +267,8 @@ function initDynamicModel(globals){
...
@@ -268,8 +267,8 @@ function initDynamicModel(globals){
gpuMath
.
setUniformForProgram
(
"
normalCalc
"
,
"
u_textureDimFaces
"
,
[
textureDimFaces
,
textureDimFaces
],
"
2f
"
);
gpuMath
.
setUniformForProgram
(
"
normalCalc
"
,
"
u_textureDimFaces
"
,
[
textureDimFaces
,
textureDimFaces
],
"
2f
"
);
gpuMath
.
createProgram
(
"
packToBytes
"
,
vertexShader
,
document
.
getElementById
(
"
packToBytesShader
"
).
text
);
gpuMath
.
createProgram
(
"
packToBytes
"
,
vertexShader
,
document
.
getElementById
(
"
packToBytesShader
"
).
text
);
gpuMath
.
initTextureFromData
(
"
outputBytes
"
,
textureDim
*
4
,
textureDim
,
"
UNSIGNED_BYTE
"
,
null
,
!
firstTim
e
);
gpuMath
.
initTextureFromData
(
"
outputBytes
"
,
textureDim
*
4
,
textureDim
,
"
UNSIGNED_BYTE
"
,
null
,
tru
e
);
gpuMath
.
initFrameBufferForTexture
(
"
outputBytes
"
,
!
firstTim
e
);
gpuMath
.
initFrameBufferForTexture
(
"
outputBytes
"
,
tru
e
);
gpuMath
.
setUniformForProgram
(
"
packToBytes
"
,
"
u_floatTextureDim
"
,
[
textureDim
,
textureDim
],
"
2f
"
);
gpuMath
.
setUniformForProgram
(
"
packToBytes
"
,
"
u_floatTextureDim
"
,
[
textureDim
,
textureDim
],
"
2f
"
);
gpuMath
.
setUniformForProgram
(
"
packToBytes
"
,
"
u_floatTexture
"
,
0
,
"
1i
"
);
gpuMath
.
setUniformForProgram
(
"
packToBytes
"
,
"
u_floatTexture
"
,
0
,
"
1i
"
);
...
...
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