diff --git a/src/VolumeData.ts b/src/VolumeData.ts index 258ca657..beeba1c4 100644 --- a/src/VolumeData.ts +++ b/src/VolumeData.ts @@ -63,7 +63,7 @@ export class VolumeData { str = new TextDecoder("utf-8").decode(inflate(str)); } } catch (err) { - console.log(err); + console.error(err); } } @@ -92,7 +92,6 @@ export class VolumeData { total += diff * diff; //variance is ave of squared difference with mean } var variance = total / this.data.length; - //console.log("Computed variance: "+variance); //now normalize for (let i = 0, n = this.data.length; i < n; i++) { this.data[i] = (this.data[i] - mean) / variance; @@ -180,7 +179,7 @@ export class VolumeData { var natoms = atomicData.length; if (natoms == 0) { - console.log("No good formating of CHG or CHGCAR file, not atomic information provided in the file."); + console.warn("No good formating of CHG or CHGCAR file, not atomic information provided in the file."); this.data = []; return; } @@ -259,15 +258,6 @@ export class VolumeData { } this.data = preConvertedData; - - //console.log(xVec); - //console.log(yVec); - //console.log(zVec); - //console.log(this.unit); - //console.log(this.origin); - //console.log(this.matrix); - //console.log(this.data); - }; // parse dx data - does not support all features of the file format @@ -291,32 +281,32 @@ export class VolumeData { else if ((m = redelta.exec(line))) { var xunit = parseFloat(m[1]); if (parseFloat(m[2]) != 0 || parseFloat(m[3]) != 0) { - console.log("Non-orthogonal delta matrix not currently supported in dx format"); + console.warn("Non-orthogonal delta matrix not currently supported in dx format"); } i += 1; line = lines[i]; m = redelta.exec(line); if (m == null) { - console.log("Parse error in dx delta matrix"); + console.error("Parse error in dx delta matrix"); return; } var yunit = parseFloat(m[2]); if (parseFloat(m[1]) != 0 || parseFloat(m[3]) != 0) { - console.log("Non-orthogonal delta matrix not currently supported in dx format"); + console.warn("Non-orthogonal delta matrix not currently supported in dx format"); } i += 1; line = lines[i]; m = redelta.exec(line); if (m == null) { - console.log("Parse error in dx delta matrix"); + console.error("Parse error in dx delta matrix"); return; } var zunit = parseFloat(m[3]); if (parseFloat(m[1]) != 0 || parseFloat(m[2]) != 0) { - console.log("Non-orthogonal delta matrix not currently supported in dx format"); + console.warn("Non-orthogonal delta matrix not currently supported in dx format"); } this.unit = new Vector3(xunit, yunit, zunit); } @@ -331,7 +321,7 @@ export class VolumeData { } i += 1; if (!this.size || !this.origin || !this.unit || !this.size) { - console.log("Error parsing dx format"); + console.error("Error parsing dx format"); return; } var raw = lines.splice(i).join(" "); @@ -484,7 +474,6 @@ export class VolumeData { // 56 NLABL Number of labels being used // 57-256 LABEL(20,10) 10 80 character text labels (ie. A4 format) - //console.log("Map has min,mean,average,rmsddv: "+header.DMIN+","+header.DMAX+","+header.DMEAN+","+header.ARMS); //create transformation matrix, code mostly copied from ngl var h = header; diff --git a/src/WebGL/Renderer.ts b/src/WebGL/Renderer.ts index 1a6208eb..deed34f1 100644 --- a/src/WebGL/Renderer.ts +++ b/src/WebGL/Renderer.ts @@ -189,14 +189,14 @@ export class Renderer { this._canvas.id = parameters.id; - if(parameters.containerWidth == 0 || parameters.containerHeight == 0) { + if (parameters.containerWidth == 0 || parameters.containerHeight == 0) { return; //start lost } this.initGL(); this.setDefaultGLState(); this.context = this._gl; - if(this.isWebGL1()) { + if (this.isWebGL1()) { this._extInstanced = this._gl.getExtension("ANGLE_instanced_arrays"); } else { //no longer an extension, wrap this._extInstanced = { @@ -228,7 +228,7 @@ export class Renderer { getCanvas() { return this._canvas; } - + isLost() { return this._gl == null || this._gl.isContextLost(); } @@ -240,7 +240,7 @@ export class Renderer { setClearColorHex(hex, alpha) { this._clearColor.setHex(hex); this._clearAlpha = alpha; - if(!this.isLost()) { + if (!this.isLost()) { this._gl.clearColor(this._clearColor.r, this._clearColor.g, this._clearColor.b, this._clearAlpha); } } @@ -273,7 +273,7 @@ export class Renderer { this._viewportWidth = wid; this._viewportHeight = hei; - if(!this.isLost()) { + if (!this.isLost()) { this._gl.enable(this._gl.SCISSOR_TEST); this._gl.scissor(wid * this.col, hei * this.row, wid, hei); this._gl.viewport(wid * this.col, hei * this.row, wid, hei); @@ -314,7 +314,7 @@ export class Renderer { this._canvas.style.width = width + "px"; this._canvas.style.height = height + "px"; - if(!this.isLost()) { + if (!this.isLost()) { this._gl.viewport(0, 0, this._gl.drawingBufferWidth, this._gl.drawingBufferHeight); } } @@ -440,7 +440,7 @@ export class Renderer { // program // Also sets appropriate uniform variables program = this.setProgram(camera, lights, fog, material, object, this); - if(!program) return; + if (!program) return; attributes = program.attributes; @@ -616,7 +616,7 @@ export class Renderer { camera.matrixWorldInverse ); - if(this.isLost()) { + if (this.isLost()) { return; } // update WebGL objects @@ -1264,7 +1264,7 @@ export class Renderer { // Set up new program and compile shaders program = this._gl.createProgram(); - if(program == null) return null; + if (program == null) return null; // set up precision var precision = this._precision; @@ -1290,8 +1290,8 @@ export class Renderer { ); var glVertexShader = this.getShader("vertex", prefix_vertex + vertexShader); - if(glVertexShader != null) this._gl.attachShader(program, glVertexShader); - if(glFragmentShader != null) this._gl.attachShader(program, glFragmentShader); + if (glVertexShader != null) this._gl.attachShader(program, glVertexShader); + if (glFragmentShader != null) this._gl.attachShader(program, glFragmentShader); this._gl.linkProgram(program); @@ -1364,7 +1364,7 @@ export class Renderer { this.initMaterial(material, lights, fog, object); material.needsUpdate = false; } - if( material.program == null) return null; + if (material.program == null) return null; var refreshMaterial = false; @@ -1967,69 +1967,56 @@ export class Renderer { this.setMaterialFaces(material, reflected); this.renderBuffer(camera, lights, fog, material, buffer, object); - if (this._outlineEnabled || material.outline) { + + if ((this._outlineEnabled || material.outline) && + !material.wireframe && + material.shaderID !== "basic" && + material.opacity !== 0.0) { + let outmat: any = this._outlineMaterial; if (material.shaderID == "sphereimposter") { - this.renderBuffer( - camera, - lights, - fog, - this._outlineSphereImposterMaterial, - buffer, - object - ); + outmat = this._outlineSphereImposterMaterial; } else if (material.shaderID == "stickimposter") { - this.renderBuffer( - camera, - lights, - fog, - this._outlineStickImposterMaterial, - buffer, - object - ); - } else if ( - !material.wireframe && - material.shaderID !== "basic" && - material.opacity !== 0.0 - ) { - this.renderBuffer( - camera, - lights, - fog, - this._outlineMaterial, - buffer, - object - ); + outmat = this._outlineStickImposterMaterial; } + + this.renderBuffer( + camera, + lights, + fog, + outmat, + buffer, + object + ); } } } } private renderSprites(scene, camera, inFront) { - // Reset state once regardless - // This should also fix cartoon render bug (after transparent surface - // render) - - this._currentGeometryGroupHash = -1; - this._currentProgram = null; - this._currentCamera = null; - this._oldDepthWrite = -1; - this._oldDepthTest = -1; - this._oldDoubleSided = -1; - this._currentMaterialId = -1; - this._oldFlipSided = -1; - this._lightsNeedUpdate = true; - - this.sprites.render(scene, camera, this._currentWidth, this._currentHeight, inFront); - - // Reset state a - this._currentGeometryGroupHash = -1; - this._currentProgram = null; - this._currentCamera = null; - this._oldDepthWrite = -1; - this._oldDepthTest = -1; - this._oldDoubleSided = -1; - this._currentMaterialId = -1; - this._oldFlipSided = -1; - } + // Reset state once regardless + // This should also fix cartoon render bug (after transparent surface + // render) + + this._currentGeometryGroupHash = -1; + this._currentProgram = null; + this._currentCamera = null; + this._oldDepthWrite = -1; + this._oldDepthTest = -1; + this._oldDoubleSided = -1; + this._currentMaterialId = -1; + this._oldFlipSided = -1; + this._lightsNeedUpdate = true; + + this.sprites.render(scene, camera, this._currentWidth, this._currentHeight, inFront); + + // Reset state a + this._currentGeometryGroupHash = -1; + this._currentProgram = null; + this._currentCamera = null; + this._oldDepthWrite = -1; + this._oldDepthTest = -1; + this._oldDoubleSided = -1; + this._currentMaterialId = -1; + this._oldFlipSided = -1; +} } diff --git a/src/utilities.ts b/src/utilities.ts index da1cc70e..49266a36 100644 --- a/src/utilities.ts +++ b/src/utilities.ts @@ -420,7 +420,7 @@ export function download(query, viewer, options, callback?) { } } if (query.substring(0,5) == 'mmtf:') { - console.log('WARNING: MMTF now deprecated. Reverting to bcif.'); + console.warn('WARNING: MMTF now deprecated. Reverting to bcif.'); query = 'bcif:' + query.slice(5); } if (query.substring(0, 5) === 'bcif:') { @@ -437,7 +437,7 @@ export function download(query, viewer, options, callback?) { viewer.zoomTo(); viewer.render(); resolve(m); - }, function () { console.log("fetch of " + uri + " failed."); }); + }, function () { console.error("fetch of " + uri + " failed."); }); }); } else { @@ -493,14 +493,14 @@ export function download(query, viewer, options, callback?) { pdbUri = options && options.pdbUri ? options.pdbUri : "https://files.rcsb.org/view/"; uri = pdbUri + query + ".pdb"; type = "pdb"; - console.log("falling back to pdb format"); + console.warn("falling back to pdb format"); get(uri).then(function (data) { handler(data); resolve(m); }).catch(function (e) { handler(""); resolve(m); - console.log("fetch of " + uri + " failed: " + e.statusText); + console.error("fetch of " + uri + " failed: " + e.statusText); }); }); //an error msg has already been printed } @@ -511,7 +511,7 @@ export function download(query, viewer, options, callback?) { }).catch(function (e) { handler(""); resolve(m); - console.log("fetch of " + uri + " failed: " + e.statusText); + console.error("fetch of " + uri + " failed: " + e.statusText); }); } }); @@ -591,7 +591,7 @@ export function getColorFromStyle(atom, style): Color { //actual color scheme provided color = style.colorscheme[atom.elem]; } else { - console.log("Could not interpret colorscheme " + scheme); + console.warn("Could not interpret colorscheme " + scheme); } } else if (typeof style.colorfunc != "undefined") { //this is a user provided function for turning an atom into a color