Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
// Amira Abdel-Rahman
// (c) Massachusetts Institute of Technology 2019
var color1= 0xffffff; /*white*/
var color2= 0x020227; /*kohly*/
var color3= 0x1c5c61; /*teal*/
var color4= "#fa6e70"; //red/orange
var color5="#380152"; //purple
var color6="#696767"; //grey
var color7="#03dbfc"; //blue
///////////globals (in case of hierarichal)/////////////
var camera;
var gui = new dat.GUI();
var clock = new THREE.Clock();
var timeElapsed = clock.getElapsedTime();
var currTimeStep=0;
var increase=true;
var setupEmpty={//empty
nodes: [
],
edges: [
],
//material properties - AISI 1095 Carbon Steel (Spring Steel)
ndofs : 3*6,
animation : {
showDisplacement : false,
exaggeration : 1000,
speed:3.0
},
viz : {
minStress:10e6,
maxStress: -10e6,
colorMaps:[coolwarm,YlGnBu, winter ,jet],
colorMap:0,
},
};
var setup=JSON.parse(JSON.stringify(setupEmpty));
function animate(){
timeElapsed = clock.getElapsedTime();
requestAnimationFrame(animate);
if(increase){
currTimeStep+=setup.animation.speed*setup.animation.speed*2.0; //todo change to globalSetup
}else{
currTimeStep-=setup.animation.speed*setup.animation.speed*2.0; //todo change to globalSetup
}
}
animate();
///////////////////////////////
////////////threejs object and utils//////////////////////
function threejs(setup,containerName,container1Name,static=true,live=false){
// this.line;
this.setup=setup;
this.renderer;
this.scene;
// this.camera;
this.controls;
this.containerName=containerName;
this.container = document.getElementById( this.containerName );
this.container1Name=container1Name;
// this.line1;
this.matLineBasic;
this.matLineDashed;
this.matLineBasicBasic;
this.matLineBasicDashed;
this.static=static;
this.labelRenderer=[];
this.counter=0;
this.numFile=0;
this.live=live;
this.thinLines=false;
this.speed=this.setup.animation.speed;
// viewport
}
threejs.prototype.init=function() {
this.renderer = new THREE.WebGLRenderer( { antialias: true } );
this.renderer.setPixelRatio( window.devicePixelRatio );
this.renderer.setClearColor( color2, 1.0 );
this.renderer.setSize( this.getWidth(), this.getHeight() );
this.container.appendChild( this.renderer.domElement );
this.scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 60, this.getWidth() / this.getHeight(), 1, 10000 );
camera.position.set( - 40, 40, 60 );
camera = new THREE.OrthographicCamera( this.getWidth() / - 2, this.getWidth() / 2, this.getHeight() / 2, this.getHeight() / - 2, 1, 1000 );
camera.position.set( 0, 125, 0 );
this.controls = new THREE.OrbitControls( camera, this.renderer.domElement );
// this.controls.target.set( this.setup.voxelSize/2.0*this.setup.scale, this.setup.voxelSize*2.0*this.setup.scale, this.setup.voxelSize/2.0*this.setup.scale );
this.controls.minDistance = 1;
this.controls.maxDistance = 500;
// this.matLineBasic = new THREE.LineMaterial( {
// color: 0xffffff,
// linewidth: 5, // in pixels
// vertexColors: THREE.VertexColors,
// //resolution: // to be set by renderer, eventually
// dashed: false,
// visible:false
// } );
this.matLineBasic = new THREE.LineMaterial( {
color: 0xffffff,
vertexColors: THREE.VertexColors,
linewidth: 5, // in pixels
//resolution: // to be set by renderer, eventually
dashed: false
} );
this.matLineBasicBasic = new THREE.LineBasicMaterial( {
color: 0xffffff,
vertexColors: THREE.VertexColors,
linewidth: 5, // in pixels
//resolution: // to be set by renderer, eventually
} );
// matLineDashed.defines.USE_DASH = "";
this.matLineDashed = new THREE.LineMaterial( {
color: 0xffffff,
linewidth: 5, // in pixels
vertexColors: THREE.VertexColors,
//resolution: // to be set by renderer, eventually
dashed: false
} );
this.matLineBasicDashed = new THREE.LineBasicMaterial( {
color: 0xffffff,
linewidth: 5, // in pixels
vertexColors: THREE.VertexColors,
} );
var helper = new THREE.GridHelper( 100, 100 );
helper.position.y = 0.0;
helper.material.opacity = 0.5;
helper.material.transparent = true;
helper.scale.x=2.0
helper.scale.z=2.0
this.scene.add( helper );
// this.labelRenderer = new THREE.CSS2DRenderer();
// this.labelRenderer.setSize( this.getWidth(), this.getHeight() );
// this.labelRenderer.domElement.style.position = 'absolute';
// this.labelRenderer.domElement.style.top = 0;
// this.container.appendChild( this.labelRenderer.domElement );
// this.controls = new THREE.OrbitControls( camera, this.labelRenderer.domElement );
// draw forces
// draw degrees of freedom
window.addEventListener( 'resize', onWindowResize, false );
onWindowResize();
this.drawStructure();
this.colorEdges();
this.drawConstraintBoundingBoxes();
if(!this.live){
if(!this.static){//dynamic
// initialize(this.setup);
this.renderEuler();
this.animateEuler()
}else{
this.render();
this.animate();
}
}else{
this.renderLive();
this.animateLive();
}
guiCreate(this);
};
Loading
Loading full blame...