Commit 6204f95e authored by amandaghassaei's avatar amandaghassaei
Browse files

drag node

parent ba32867c
......@@ -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;
}
......
......@@ -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].getRelativePosition();
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){
......
......@@ -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);
......
......@@ -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.getRelativePosition = function(){
return this.object3D.position.clone().sub(this._originalPosition);
};
......
......@@ -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, -10000, 10000);//-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 = 4000;
camera.position.y = 4000;
camera.position.z = 4000;
controls = new THREE.OrbitControls(camera, container.get(0));
controls.addEventListener('change', render);
......
Markdown is supported
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