lore-engine
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -23,2 +23,4 @@ var fs = require('fs'); | ||
'src/Core/Effect.js', | ||
'src/Core/Tree.js', | ||
'src/Core/Graph.js', | ||
'src/Controls/ControlsBase.js', | ||
@@ -25,0 +27,0 @@ 'src/Controls/OrbitalControls.js', |
{ | ||
"name": "lore-engine", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A WebGL based 3D data visualization engine.", | ||
@@ -12,9 +12,9 @@ "main": "./dist/lore.js", | ||
}, | ||
"repository": "git+https://github.com/daenuprobst/smilesDrawer.git", | ||
"repository": "git+https://github.com/reymond-group/lore.git", | ||
"author": "Daniel Probst, Reymond Group, University of Bern", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/daenuprobst/lore/issues" | ||
"url": "https://github.com/reymond-group/lore/issues" | ||
}, | ||
"homepage": "https://github.com/daenuprobst/lore#readme", | ||
"homepage": "https://github.com/reymond-group/lore#readme", | ||
"dependencies": {}, | ||
@@ -21,0 +21,0 @@ "devDependencies": { |
![Lore](https://github.com/reymond-group/lore/blob/master/logo.png?raw=true) | ||
If you use this code or application, please cite the original paper published by Bioinformatics: [10.1093/bioinformatics/btx760](http://dx.doi.org/10.1093/bioinformatics/btx760) | ||
# Lore | ||
@@ -17,3 +20,2 @@ Current Version: 1.0.0 ([Starbreaker](https://www.youtube.com/watch?v=nr8pgN195Zw)) | ||
Browsing the SureChEMBL database (containing > 12 million datapoints): [Faerun](http://faerun.gdb.tools). | ||
@@ -23,2 +25,9 @@ | ||
### Installation | ||
You can either download or clone this repository and use the JavaScript file in the dist folder, or you can use yarn to install the package lore-engine: | ||
```bash | ||
yarn add lore-engine | ||
``` | ||
### Building Lore | ||
@@ -25,0 +34,0 @@ If you decide not to use the ready-to-go scripts in `dist`, you can (edit and) build the project by running: |
@@ -81,2 +81,3 @@ /** | ||
viewMatrix.invert(); | ||
console.log(viewMatrix.toString()); | ||
this.viewMatrix = viewMatrix; | ||
@@ -83,0 +84,0 @@ this.isViewMatrixStale = true; |
@@ -51,3 +51,3 @@ /** | ||
let bottom = y - height; | ||
this.projectionMatrix.setOrthographic(left, right, top, bottom, this.near, this.far); | ||
@@ -54,0 +54,0 @@ this.isProjectionMatrixStale = true; |
@@ -14,2 +14,7 @@ /** A class representing an perspective camera. */ | ||
this.type = 'Lore.PerspectiveCamera'; | ||
// TODO: There shouldn't be a zoom here. The problem is, that the orbital controls | ||
// and also the point helper and zoom rely on it. However, for the perspective camera, | ||
// zooming is achieved by adjusting the fov. | ||
this.zoom = 1.0; | ||
this.fov = fov; | ||
@@ -39,4 +44,4 @@ this.aspect = aspect; | ||
updateViewport(width, height) { | ||
this.aspect = width / height; | ||
this.aspect = width / height; | ||
} | ||
} |
@@ -34,3 +34,3 @@ /** | ||
this.scale = 0.95; | ||
this.camera.position = new Lore.Vector3f(radius, radius, radius); | ||
@@ -37,0 +37,0 @@ this.camera.updateProjectionMatrix(); |
@@ -124,2 +124,19 @@ /** | ||
/** | ||
* Converts HSL to RGB. | ||
* | ||
* @static | ||
* @param {Number} h The hue component. | ||
* @param {Number} s The saturation component. | ||
* @param {Number} l The lightness component. | ||
* @returns {String} A hex string representing the color (#RRGGBB). | ||
*/ | ||
static hslToHex(h, s, l) { | ||
let [r, g, b] = Lore.Color.hslToRgb(h, s, l); | ||
return '#' + [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)].map(e => { | ||
const hex = e.toString(16); | ||
return hex.length === 1 ? '0' + hex : hex | ||
}).join('') | ||
} | ||
/** | ||
* Converts RGB to HSL. | ||
@@ -126,0 +143,0 @@ * |
@@ -13,106 +13,106 @@ /** | ||
Lore.Geometry = class Geometry extends Lore.Node { | ||
constructor(name, gl, shader) { | ||
super(); | ||
constructor(name, gl, shader) { | ||
super(); | ||
this.type = 'Lore.Geometry'; | ||
this.name = name; | ||
this.gl = gl; | ||
this.shader = shader; | ||
this.attributes = {}; | ||
this.drawMode = this.gl.POINTS; | ||
this.isVisible = true; | ||
} | ||
this.type = 'Lore.Geometry'; | ||
this.name = name; | ||
this.gl = gl; | ||
this.shader = shader; | ||
this.attributes = {}; | ||
this.drawMode = this.gl.POINTS; | ||
this.isVisible = true; | ||
} | ||
addAttribute(name, data, length) { | ||
this.attributes[name] = new Lore.Attribute(data, length, name); | ||
this.attributes[name].createBuffer(this.gl, this.shader.program); | ||
addAttribute(name, data, length) { | ||
this.attributes[name] = new Lore.Attribute(data, length, name); | ||
this.attributes[name].createBuffer(this.gl, this.shader.program); | ||
return this; | ||
} | ||
return this; | ||
} | ||
updateAttribute(name, data) { | ||
if (data) { | ||
this.attributes[name].data = data; | ||
} | ||
updateAttribute(name, data) { | ||
if (data) { | ||
this.attributes[name].data = data; | ||
} | ||
this.attributes[name].update(this.gl); | ||
this.attributes[name].update(this.gl); | ||
return this; | ||
} | ||
return this; | ||
} | ||
getAttribute(name) { | ||
return this.attributes[name]; | ||
} | ||
getAttribute(name) { | ||
return this.attributes[name]; | ||
} | ||
removeAttribute(name) { | ||
delete this.attributes[name]; | ||
removeAttribute(name) { | ||
delete this.attributes[name]; | ||
return this; | ||
} | ||
return this; | ||
} | ||
setMode(drawMode) { | ||
switch (drawMode) { | ||
case Lore.DrawModes.points: | ||
this.drawMode = this.gl.POINTS; | ||
break; | ||
case Lore.DrawModes.lines: | ||
this.drawMode = this.gl.LINES; | ||
break; | ||
case Lore.DrawModes.lineStrip: | ||
this.drawMode = this.gl.LINE_STRIP; | ||
break; | ||
case Lore.DrawModes.lineLoop: | ||
this.drawMode = this.gl.LINE_LOOP; | ||
break; | ||
case Lore.DrawModes.triangles: | ||
this.drawMode = this.gl.TRIANGLES; | ||
break; | ||
case Lore.DrawModes.triangleStrip: | ||
this.drawMode = this.gl.TRIANGLE_STRIP; | ||
break; | ||
case Lore.DrawModes.triangleFan: | ||
this.drawMode = this.gl.TRIANGLE_FAN; | ||
break; | ||
} | ||
setMode(drawMode) { | ||
switch (drawMode) { | ||
case Lore.DrawModes.points: | ||
this.drawMode = this.gl.POINTS; | ||
break; | ||
case Lore.DrawModes.lines: | ||
this.drawMode = this.gl.LINES; | ||
break; | ||
case Lore.DrawModes.lineStrip: | ||
this.drawMode = this.gl.LINE_STRIP; | ||
break; | ||
case Lore.DrawModes.lineLoop: | ||
this.drawMode = this.gl.LINE_LOOP; | ||
break; | ||
case Lore.DrawModes.triangles: | ||
this.drawMode = this.gl.TRIANGLES; | ||
break; | ||
case Lore.DrawModes.triangleStrip: | ||
this.drawMode = this.gl.TRIANGLE_STRIP; | ||
break; | ||
case Lore.DrawModes.triangleFan: | ||
this.drawMode = this.gl.TRIANGLE_FAN; | ||
break; | ||
} | ||
return this; | ||
} | ||
return this; | ||
} | ||
size() { | ||
// Is this ok? All attributes should have the same length ... | ||
if (Object.keys(this.attributes).length > 0) { | ||
return this.attributes[Object.keys(this.attributes)[0]].size; | ||
} | ||
size() { | ||
// Is this ok? All attributes should have the same length ... | ||
if (Object.keys(this.attributes).length > 0) { | ||
return this.attributes[Object.keys(this.attributes)[0]].size; | ||
} | ||
return 0; | ||
} | ||
return 0; | ||
} | ||
draw(renderer) { | ||
if (!this.isVisible) return; | ||
draw(renderer) { | ||
if (!this.isVisible) return; | ||
for (let prop in this.attributes) | ||
if (this.attributes[prop].stale) this.attributes[prop].update(this.gl); | ||
for (let prop in this.attributes) | ||
if (this.attributes[prop].stale) this.attributes[prop].update(this.gl); | ||
this.shader.use(); | ||
this.shader.use(); | ||
// Update the modelView and projection matrices | ||
if (renderer.camera.isProjectionMatrixStale) { | ||
this.shader.uniforms.projectionMatrix.setValue(renderer.camera.getProjectionMatrix()); | ||
} | ||
// Update the modelView and projection matrices | ||
if (renderer.camera.isProjectionMatrixStale) { | ||
this.shader.uniforms.projectionMatrix.setValue(renderer.camera.getProjectionMatrix()); | ||
} | ||
if (renderer.camera.isViewMatrixStale) { | ||
let modelViewMatrix = Lore.Matrix4f.multiply(renderer.camera.viewMatrix, this.modelMatrix); | ||
this.shader.uniforms.modelViewMatrix.setValue(modelViewMatrix.entries); | ||
} | ||
if (renderer.camera.isViewMatrixStale) { | ||
let modelViewMatrix = Lore.Matrix4f.multiply(renderer.camera.viewMatrix, this.modelMatrix); | ||
this.shader.uniforms.modelViewMatrix.setValue(modelViewMatrix.entries); | ||
} | ||
this.shader.updateUniforms(); | ||
this.shader.updateUniforms(); | ||
// How exactly does the binding work?? | ||
// What will happen if I want to draw a second geometry? | ||
for (let prop in this.attributes) { | ||
this.attributes[prop].bind(this.gl); | ||
} | ||
// How exactly does the binding work?? | ||
// What will happen if I want to draw a second geometry? | ||
for (let prop in this.attributes) { | ||
this.attributes[prop].bind(this.gl); | ||
} | ||
this.gl.drawArrays(this.drawMode, 0, this.size()); | ||
} | ||
this.gl.drawArrays(this.drawMode, 0, this.size()); | ||
} | ||
} |
@@ -36,3 +36,3 @@ /** | ||
this.camera = new Lore.OrthographicCamera(this.getWidth() / -2, this.getWidth() / 2, this.getHeight() / 2, this.getHeight() / -2); | ||
// this.camera = new Lore.PerspectiveCamera(45.0, this.getWidth() / this.getHeight()); | ||
// this.camera = new Lore.PerspectiveCamera(25.0, this.getWidth() / this.getHeight()); | ||
@@ -39,0 +39,0 @@ this.geometries = {}; |
@@ -55,6 +55,2 @@ /** | ||
// Init UI | ||
// var ui = new Lore.UI(canvas); | ||
// Start the 3D stuff | ||
var cc = Lore.Color.fromHex(this.opts.clearColor); | ||
@@ -61,0 +57,0 @@ |
@@ -56,3 +56,3 @@ /** A class representing a projection matrix */ | ||
let range = near - far; | ||
let tanHalfFov = Math.tan(Lore.Utils.DEG2RAD * fov / 2.0); | ||
let tanHalfFov = Math.tan(Lore.Utils.DEG2RAD * 0.5 * fov); | ||
@@ -65,2 +65,5 @@ let top = near * tanHalfFov; | ||
let bottom = top - height; | ||
// let bottom = -top; | ||
// let right = top * aspect; | ||
// let left = -right; | ||
@@ -72,3 +75,3 @@ let x = 2.0 * near / (right - left); | ||
let b = (top + bottom) / (top - bottom); | ||
let c = (far + near) / (far - near); | ||
let c = -(far + near) / (far - near); | ||
let d = -2 * far * near / (far - near); | ||
@@ -75,0 +78,0 @@ |
/** A helper class containing statistics methods. */ | ||
Lore.Statistics = class Statistics { | ||
/** | ||
* Transposes an array of arrays (2d array). | ||
* @param {Array} arr The 2d array to be transposed. | ||
* @returns {Array} The transpose of the 2d array. | ||
*/ | ||
static transpose2dArray(arr) { | ||
return arr[0].map((col, i) => arr.map(row => row[i])); | ||
} | ||
/** | ||
* Returns a normally distributed (pseudo) random number. | ||
@@ -5,0 +15,0 @@ * |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
43895620
176
32262
126