Comparing version 1.0.0 to 1.0.1
34
cone.js
@@ -158,5 +158,13 @@ "use strict"; | ||
if (vectorfield.positions.length === 0) { | ||
if (bounds) { | ||
bounds[0] = [0,0,0]; | ||
bounds[1] = [0,0,0]; | ||
} | ||
return geo; | ||
} | ||
// Compute bounding box for the dataset. | ||
// Compute maximum velocity for the dataset to use for scaling the cones. | ||
var maxLen = 0; | ||
var maxNorm = 0; | ||
var minX = 1/0, maxX = -1/0; | ||
@@ -182,4 +190,4 @@ var minY = 1/0, maxY = -1/0; | ||
} | ||
if (V.length(u) > maxLen) { | ||
maxLen = V.length(u); | ||
if (V.length(u) > maxNorm) { | ||
maxNorm = V.length(u); | ||
} | ||
@@ -201,7 +209,17 @@ if (v2) { | ||
} | ||
var scaleV = V.subtract(vec3(), maxV, minV); | ||
var imaxLen = 1 / maxLen; | ||
if (maxNorm === 0) { | ||
maxNorm = 1; | ||
} | ||
// Inverted max norm would map vector with norm maxNorm to 1 coord space units in length | ||
var invertedMaxNorm = 1 / maxNorm; | ||
geo.vectorScale = imaxLen * minSeparation; | ||
if (!isFinite(minSeparation) || isNaN(minSeparation)) { | ||
minSeparation = 1.0; | ||
} | ||
// 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); | ||
@@ -212,3 +230,3 @@ | ||
if (vectorfield.absoluteConeSize) { | ||
coneScale = vectorfield.absoluteConeSize * imaxLen; | ||
coneScale = vectorfield.absoluteConeSize * invertedMaxNorm; | ||
} | ||
@@ -223,3 +241,3 @@ | ||
var d = positionVectors[i]; | ||
var intensity = V.length(d) * imaxLen; | ||
var intensity = V.length(d) * invertedMaxNorm; | ||
for (var k = 0, l = 8; k < l; k++) { | ||
@@ -226,0 +244,0 @@ geo.positions.push([x, y, z, j++]); |
@@ -37,3 +37,3 @@ var createCamera = require('3d-view-controls') | ||
var tickSpacing = 1; | ||
var ticks = bounds[0].map((v,i) => { | ||
var ticks = bounds[0].map(function(v,i) { | ||
var arr = []; | ||
@@ -40,0 +40,0 @@ var firstTick = 0; //Math.ceil(bounds[0][i] / tickSpacing) * tickSpacing; |
@@ -59,3 +59,3 @@ var createCamera = require('3d-view-controls') | ||
var camera = createCamera(canvas, { | ||
eye: bounds[0], | ||
eye: [100,100,100], | ||
center: [0.5*(bounds[0][0]+bounds[1][0]), | ||
@@ -73,3 +73,3 @@ 0.5*(bounds[0][1]+bounds[1][1]), | ||
var tickSpacing = 5; | ||
var ticks = bounds[0].map((v,i) => { | ||
var ticks = bounds[0].map(function(v,i) { | ||
var arr = []; | ||
@@ -76,0 +76,0 @@ var firstTick = Math.ceil(bounds[0][i] / tickSpacing) * tickSpacing; |
@@ -47,3 +47,3 @@ var createCamera = require('3d-view-controls') | ||
var tickSpacing = 5; | ||
var ticks = bounds[0].map((v,i) => { | ||
var ticks = bounds[0].map(function(v,i) { | ||
var arr = []; | ||
@@ -50,0 +50,0 @@ var firstTick = Math.ceil(bounds[0][i] / tickSpacing) * tickSpacing; |
@@ -262,9 +262,9 @@ 'use strict' | ||
if ('vectorScale' in params) { | ||
if (params.vectorScale !== undefined) { | ||
this.vectorScale = params.vectorScale; | ||
} | ||
if ('coneScale' in params) { | ||
if (params.coneScale !== undefined) { | ||
this.coneScale = params.coneScale; | ||
} | ||
if ('coneOffset' in params) { | ||
if (params.coneOffset !== undefined) { | ||
this.coneOffset = params.coneOffset; | ||
@@ -271,0 +271,0 @@ } |
{ | ||
"name": "gl-cone3d", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "3D cone plot", | ||
@@ -26,3 +26,3 @@ "main": "cone.js", | ||
"scripts": { | ||
"build-example": "browserify -o build/example.js example/cone.js && browserify -o build/example_sparse.js example/cone_sparse.js && browserify -o build/example_minimal.js example/cone_minimal.js", | ||
"build-example": "browserify -o build/example.js example/cone.js && browserify -o build/example_sparse.js example/cone_sparse.js && browserify -o build/example_minimal.js example/cone_minimal.js && browserify -o build/example_single.js example/cone_single.js", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
@@ -29,0 +29,0 @@ }, |
@@ -9,4 +9,5 @@ gl-cone3d | ||
var createScene = require('gl-plot3d') | ||
var createMesh = require('gl-mesh3d') | ||
var createConePlot = require('gl-cone3d') | ||
var createMesh = createConePlot.createConeMesh | ||
var wind = require('dataset-wind') | ||
@@ -13,0 +14,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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
6280343
25
120726
59
10
64