lore-engine
Advanced tools
Comparing version 1.0.19 to 1.0.20
{ | ||
"name": "lore-engine", | ||
"version": "1.0.19", | ||
"version": "1.0.20", | ||
"description": "A WebGL based 3D data visualization engine.", | ||
@@ -5,0 +5,0 @@ "main": "./app.js", |
@@ -34,3 +34,9 @@ //@ts-check | ||
clone() { | ||
return new Shader(this.name, this.glVersion, this.uniforms, this.vertexShader, this.fragmentShader); | ||
let uniforms = {}; | ||
for (let key in this.uniforms) { | ||
uniforms[key] = this.uniforms[key].clone(); | ||
} | ||
return new Shader(this.name, this.glVersion, uniforms, this.vertexShader, this.fragmentShader); | ||
} | ||
@@ -37,0 +43,0 @@ |
@@ -26,2 +26,11 @@ //@ts-check | ||
/** | ||
* Create and return a new instance of this uniform. | ||
* | ||
* @returns {Uniform} A clone of this uniform. | ||
*/ | ||
clone() { | ||
return new Uniform(this.name, this.value, this.type); | ||
} | ||
/** | ||
* Set the value of this uniform. | ||
@@ -28,0 +37,0 @@ * |
@@ -50,6 +50,9 @@ //@ts-check | ||
this.octree = this.target.octree; | ||
this.raycaster = new Raycaster(); | ||
this.raycaster = new Raycaster(1.0); | ||
this.hovered = null; | ||
this.selected = []; | ||
// Register this octreeHelper with the pointHelper | ||
this.target.octreeHelper = this; | ||
let that = this; | ||
@@ -105,8 +108,2 @@ | ||
this._zoomchangedHandler = function (zoom) { | ||
that.setPointSizeFromZoom(zoom); | ||
}; | ||
renderer.controls.addEventListener('zoomchanged', this._zoomchangedHandler); | ||
this._updatedHandler = function () { | ||
@@ -140,18 +137,5 @@ for (let i = 0; i < that.selected.length; i++) { | ||
} | ||
this.setPointSizeFromZoom(1.0); | ||
} | ||
/** | ||
* Sets the point size of the associated Lore.PointHelper object as well as the threshold for the associated raycaster used for vertex picking. | ||
* | ||
* @param {Number} zoom The current zoom value of the orthographic view. | ||
*/ | ||
setPointSizeFromZoom(zoom) { | ||
let threshold = this.target.setPointSize(zoom + 0.1); | ||
this.setThreshold(threshold); | ||
} | ||
/** | ||
* Get the screen position of a vertex by its index. | ||
@@ -372,2 +356,22 @@ * | ||
/** | ||
* Adds a hoveredchanged event to multiple octrees and merges the event property e. | ||
* | ||
* @param {OctreeHelper[]} octreeHelpers An array of octree helpers to join. | ||
* @param {Function} eventListener A event listener for hoveredchanged. | ||
*/ | ||
static joinHoveredChanged(octreeHelpers, eventListener) { | ||
for (let i = 0; i < octreeHelpers.length; i++) { | ||
octreeHelpers[i].addEventListener('hoveredchanged', function(e) { | ||
let result = { e: null, source: null }; | ||
for (let j = 0; j < octreeHelpers.length; j++) { | ||
if (octreeHelpers[j].hovered !== null) { | ||
result = { e: octreeHelpers[j].hovered, source: j }; | ||
} | ||
} | ||
eventListener(result); | ||
}); | ||
} | ||
} | ||
/** | ||
* Draw the centers of the axis-aligned bounding boxes of this octree. | ||
@@ -576,3 +580,2 @@ */ | ||
this.renderer.controls.removeEventListener('mousemove', this._mousemoveHandler); | ||
this.renderer.controls.removeEventListener('zoomchanged', this._zoomchangedHandler); | ||
this.renderer.controls.removeEventListener('updated', this._updatedHandler); | ||
@@ -579,0 +582,0 @@ } |
@@ -18,2 +18,3 @@ //@ts-check | ||
* @property {Octree} octree The octree associated with the point cloud. | ||
* @property {OctreeHelper} octreeHelper The octreeHelper associated with the pointHelper. | ||
* @property {Object} filters A map mapping filter names to Lore.Filter instances associated with this helper class. | ||
@@ -47,2 +48,3 @@ * @property {Number} pointSize The scaled and constrained point size of this data. | ||
this.octree = null; | ||
this.octreeHelper = null; | ||
this.geometry.setMode(DrawModes.points); | ||
@@ -59,2 +61,12 @@ this.initPointSize(); | ||
}; | ||
let that = this; | ||
this._zoomchangedHandler = function (zoom) { | ||
let threshold = that.setPointSize(zoom + 0.1); | ||
if (that.octreeHelper) { | ||
that.octreeHelper.setThreshold(threshold); | ||
} | ||
}; | ||
renderer.controls.addEventListener('zoomchanged', this._zoomchangedHandler); | ||
} | ||
@@ -771,4 +783,11 @@ | ||
} | ||
/** | ||
* Remove eventhandlers from associated controls. | ||
*/ | ||
destruct() { | ||
this.renderer.controls.removeEventListener('zoomchanged', this._zoomchangedHandler); | ||
} | ||
} | ||
module.exports = PointHelper |
@@ -12,8 +12,8 @@ //@ts-check | ||
* Creates an instance of Ray. | ||
* @param {Vector3f} source The source of the ray. | ||
* @param {Vector3f} direction The direction of the ray. | ||
* @param {Vector3f} [source = new Vector3f(0.0, 0.0, 0.0)] The source of the ray. | ||
* @param {Vector3f} [direction = new Vector3f(0.0, 0.0, 0.0)] The direction of the ray. | ||
*/ | ||
constructor(source, direction) { | ||
this.source = source || new Vector3f(0.0, 0.0, 0.0); | ||
this.direction = direction || new Vector3f(0.0, 0.0, 0.0); | ||
constructor(source = new Vector3f(0.0, 0.0, 0.0), direction = new Vector3f(0.0, 0.0, 0.0)) { | ||
this.source = source; | ||
this.direction = direction; | ||
} | ||
@@ -20,0 +20,0 @@ |
@@ -8,7 +8,12 @@ //@ts-check | ||
class Raycaster { | ||
constructor() { | ||
/** | ||
* Creates an instance of Raycaster. | ||
* | ||
* @param {Number} [threshold=0.1] Data to be sent to the listening functions. | ||
*/ | ||
constructor(threshold = 0.1) { | ||
this.ray = new Ray(); | ||
this.near = 0; | ||
this.far = 1000; | ||
this.threshold = 0.1; | ||
this.threshold = threshold; | ||
} | ||
@@ -15,0 +20,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 not supported yet
Sorry, the diff of this file is not supported yet
42296587
20527