Commit 7d54496e authored by Amanda Ghassaei's avatar Amanda Ghassaei

memory fixes

parent 1b583022
assets/attrib.txt
.idea/
todo.rtf
\ No newline at end of file
......@@ -39,9 +39,10 @@ function initGPUMath(){
GPUMath.prototype.createProgram = function(programName, vertexShader, fragmentShader){
var programs = this.programs;
var program = programs[name];
var program = programs[programName];
if (program) {
console.warn("already a program with the name " + programName);
gl.useProgram(program.program);
// console.warn("already a program with the name " + programName);
return;
}
program = glBoilerplate.createProgramFromSource(gl, vertexShader, fragmentShader);
......@@ -55,10 +56,14 @@ function initGPUMath(){
GPUMath.prototype.initTextureFromData = function(name, width, height, typeName, data, shouldReplace){
var texture = this.textures[name];
if (!shouldReplace && texture) {
if (texture){
if (!shouldReplace) {
console.warn("already a texture with the name " + name);
return;
}
gl.deleteTexture(texture);
}
texture = glBoilerplate.makeTexture(gl, width, height, gl[typeName], data);
this.textures[name] = texture;
};
......@@ -67,10 +72,13 @@ function initGPUMath(){
GPUMath.prototype.initFrameBufferForTexture = function(textureName, shouldReplace){
var framebuffer = this.frameBuffers[textureName];
if (framebuffer && (shouldReplace === undefined || !shouldReplace)) {
if (framebuffer){
if (!shouldReplace) {
console.warn("framebuffer already exists for texture " + textureName);
return;
}
gl.deleteFramebuffer(framebuffer);
}
var texture = this.textures[textureName];
if (!texture){
console.warn("texture " + textureName + " does not exist");
......
......@@ -121,7 +121,7 @@ function initDynamicSolver(globals){
globals.shouldCenterGeo = false;
}
if (_numSteps == undefined) _numSteps = globals.numSteps;
if (_numSteps === undefined) _numSteps = globals.numSteps;
for (var j=0;j<_numSteps;j++){
solveStep();
}
......
......@@ -32,16 +32,23 @@ function initModel(globals){
setMeshMaterial();
function clearGeometries(){
if (geometry) geometry.dispose();
geometry = new THREE.BufferGeometry();
if (geometry) {
// geometry.dispose();
} else geometry = new THREE.BufferGeometry();
geometry.verticesNeedUpdate = true;
geometry.dynamic = true;
frontside.geometry = geometry;
backside.geometry = geometry;
_.each(lines, function(line){
if (line.geometry) line.geometry.dispose();
var lineGeometry = new THREE.BufferGeometry();
var lineGeometry = line.geometry;
if (lineGeometry) {
// line.geometry.dispose();
} else lineGeometry = new THREE.BufferGeometry();
lineGeometry.verticesNeedUpdate = true;
lineGeometry.dynamic = true;
line.geometry = lineGeometry;
});
......
......@@ -141,7 +141,9 @@ function initThreeView(globals) {
}
function sceneClearModel(){
modelWrapper.children = [];
for (var i=0;i<modelWrapper.children.length;i++){
modelWrapper.remove(modelWrapper.children[i]);
}
}
function onWindowResize() {
......
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