Skip to content

Commit

Permalink
Improve destroy calls on scaffold viewer and organs renderer.
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-wu committed May 16, 2019
1 parent e7a4f6b commit e733ca7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
6 changes: 6 additions & 0 deletions src/modules/ScaffoldViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,12 @@ var ScaffoldViewer = function(typeAtStartUp) {
csg.setMessageFunction(functionIn);
}

this.destroy = function() {
if (csg)
csg.clear();
(require('./RendererModule').RendererModule).prototype.destroy.call( _this );
}

/**
* Initialise the {@link PJP.BodyViewer}, it will create a detached renderer until
* a display area is passed in as an argument on intialiseRenderer.
Expand Down
7 changes: 1 addition & 6 deletions src/modules/organsRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -883,16 +883,11 @@ var OrgansViewer = function(ModelsLoaderIn) {
}

this.destroy = function() {
if (_this.zincRenderer) {
_this.zincRenderer.dispose();
_this.zincRenderer.getThreeJSRenderer().dispose();
_this.zincRenderer = undefined;
}
if (secondaryRenderer) {
secondaryRenderer.dispose();
secondaryRenderer = null;
}
(require('./BaseModule').BaseModule).prototype.destroy.call( _this );
(require('./RendererModule').RendererModule).prototype.destroy.call( _this );
}

/**
Expand Down
25 changes: 15 additions & 10 deletions src/utilities/csg.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ exports.csg = function(sceneIn, zincRendererIn) {
var originalGlyphs = undefined;
var zincRenderer = zincRendererIn;
var preRenderCallbackId = -1;
var _this = this;

var getCentroid = function() {
if (currentGeometry) {
Expand Down Expand Up @@ -404,17 +405,21 @@ exports.csg = function(sceneIn, zincRendererIn) {
}
}

this.clear = function() {
csgScene.clearAll();
if (zincCSG)
zincCSG.terminateWorker();
zincCSG = undefined;
boxGeometry = undefined;
currentGeometry = undefined;
if (scene)
scene.removeObject(planeHelper);
planeHelper = undefined;
}

this.reset = function() {
csgScene.clearAll();
if (zincCSG)
zincCSG.terminateWorker();
zincCSG = undefined;
boxGeometry = undefined;
currentGeometry = undefined;
if (scene)
scene.removeObject(planeHelper);
planeHelper = undefined;
createCube(1, 1, 0.0005);
_this.clear();
createCube(1, 1, 0.0005);
}

this.updatePlane = function() {
Expand Down

0 comments on commit e733ca7

Please sign in to comment.