Comparing version 1.0.1 to 1.1.0
49
cone.js
@@ -172,16 +172,17 @@ "use strict"; | ||
var minZ = 1/0, maxZ = -1/0; | ||
var v2 = null; | ||
var p2 = null; | ||
var u2 = null; | ||
var positionVectors = []; | ||
var minSeparation = 1/0; | ||
var vectorScale = 1/0; | ||
for (var i = 0; i < positions.length; i++) { | ||
var v1 = positions[i]; | ||
minX = Math.min(v1[0], minX); | ||
maxX = Math.max(v1[0], maxX); | ||
minY = Math.min(v1[1], minY); | ||
maxY = Math.max(v1[1], maxY); | ||
minZ = Math.min(v1[2], minZ); | ||
maxZ = Math.max(v1[2], maxZ); | ||
var p = positions[i]; | ||
minX = Math.min(p[0], minX); | ||
maxX = Math.max(p[0], maxX); | ||
minY = Math.min(p[1], minY); | ||
maxY = Math.max(p[1], maxY); | ||
minZ = Math.min(p[2], minZ); | ||
maxZ = Math.max(p[2], maxZ); | ||
var u; | ||
if (meshgrid) { | ||
u = sampleMeshgrid(v1, vectors, meshgrid, true); | ||
u = sampleMeshgrid(p, vectors, meshgrid, true); | ||
} else { | ||
@@ -193,9 +194,14 @@ u = vectors[i]; | ||
} | ||
if (v2) { | ||
var separation = V.distance(v1, v2); | ||
if (separation < minSeparation) { | ||
minSeparation = separation; | ||
} | ||
if (i) { | ||
// Find vector scale [w/ units of time] using "successive" positions | ||
// (not "adjacent" with would be O(n^2)), | ||
// | ||
// The vector scale corresponds to the minimum "time" to travel across two | ||
// two adjacent positions at the average velocity of those two adjacent positions | ||
vectorScale = Math.min(vectorScale, | ||
2 * V.distance(p2, p) / (V.length(u2) + V.length(u)) | ||
); | ||
} | ||
v2 = v1; | ||
p2 = p; | ||
u2 = u; | ||
positionVectors.push(u); | ||
@@ -212,14 +218,11 @@ } | ||
} | ||
// Inverted max norm would map vector with norm maxNorm to 1 coord space units in length | ||
var invertedMaxNorm = 1 / maxNorm; | ||
if (!isFinite(minSeparation) || isNaN(minSeparation)) { | ||
minSeparation = 1.0; | ||
if (!isFinite(vectorScale) || isNaN(vectorScale)) { | ||
vectorScale = 1.0; | ||
} | ||
geo.vectorScale = vectorScale; | ||
// Inverted max norm multiplied scaled by smallest found vector position distance: | ||
// Maps a vector with norm maxNorm to minSeparation coord space units in length. | ||
// In practice, scales maxNorm vectors so that they are just long enough to reach the adjacent vector position. | ||
geo.vectorScale = invertedMaxNorm * minSeparation; | ||
var nml = vec3(0,1,0); | ||
@@ -226,0 +229,0 @@ |
@@ -790,39 +790,9 @@ 'use strict' | ||
var cell = this.cells[cellId] | ||
var positions = this.positions | ||
var pos = this.positions[cell[1]].slice(0, 3) | ||
var simplex = new Array(cell.length) | ||
for(var i=0; i<cell.length; ++i) { | ||
simplex[i] = positions[cell[i]] | ||
} | ||
var data = closestPoint( | ||
simplex, | ||
[pickData.coord[0], this._resolution[1]-pickData.coord[1]], | ||
this._model, | ||
this._view, | ||
this._projection, | ||
this._resolution) | ||
if(!data) { | ||
return null | ||
} | ||
var weights = data[2] | ||
var interpIntensity = 0.0 | ||
for(var i=0; i<cell.length; ++i) { | ||
interpIntensity += weights[i] * this.intensity[cell[i]] | ||
} | ||
return { | ||
position: data[1], | ||
index: cell[data[0]], | ||
cell: cell, | ||
cellId: cellId, | ||
intensity: interpIntensity, | ||
vectorScale: this.vectorScale, | ||
coneScale: this.coneScale, | ||
coneOffset: this.coneOffset, | ||
dataCoordinate: this.positions[cell[data[0]]] | ||
// corresponding to input indices | ||
index: Math.floor(cell[1] / 48), | ||
position: pos, | ||
dataCoordinate: pos | ||
} | ||
@@ -896,5 +866,6 @@ } | ||
function createPickShader(gl) { | ||
var shader = createShader(gl, pickShader.vertex, pickShader.fragment) | ||
var shader = createShader(gl, pickShader.vertex, pickShader.fragment, null, pickShader.attributes) | ||
shader.attributes.position.location = 0 | ||
shader.attributes.id.location = 1 | ||
shader.attributes.vector.location = 5 | ||
return shader | ||
@@ -901,0 +872,0 @@ } |
@@ -23,5 +23,6 @@ var glslify = require('glslify') | ||
attributes: [ | ||
{name: 'position', type: 'vec3'}, | ||
{name: 'id', type: 'vec4'} | ||
{name: 'position', type: 'vec4'}, | ||
{name: 'id', type: 'vec4'}, | ||
{name: 'vector', type: 'vec3'} | ||
] | ||
} |
{ | ||
"name": "gl-cone3d", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "3D cone plot", | ||
@@ -5,0 +5,0 @@ "main": "cone.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
6351447
28
124550