Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gl-scatter-plot

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gl-scatter-plot - npm Package Compare versions

Comparing version 5.2.0 to 5.3.0

43

lib/glyphs.js

@@ -9,19 +9,38 @@ "use strict"

function getGlyph(symbol) {
if(symbol in GLYPH_CACHE) {
return GLYPH_CACHE[symbol]
function getGlyph(symbol, font) {
var fontCache = GLYPH_CACHE[font]
if(!fontCache) {
fontCache = GLYPH_CACHE[font] = {}
}
return GLYPH_CACHE[symbol] = [
vectorizeText(symbol, {
triangles: true,
if(symbol in fontCache) {
return fontCache[symbol]
}
//Get line and triangle meshes for glyph
var lineSymbol = vectorizeText(symbol, {
textAlign: "center",
textBaseline: "middle",
lineHeight: 1.0
}),
vectorizeText(symbol, {
lineHeight: 1.0,
font: font
})
var triSymbol = vectorizeText(symbol, {
triangles: true,
textAlign: "center",
textBaseline: "middle",
lineHeight: 1.0
})
]
lineHeight: 1.0,
font: font
})
//Calculate bounding box
var bounds = [[Infinity,Infinity], [-Infinity,-Infinity]]
for(var i=0; i<lineSymbol.positions.length; ++i) {
var p = lineSymbol.positions[i]
for(var j=0; j<2; ++j) {
bounds[0][j] = Math.min(bounds[0][j], p[j])
bounds[1][j] = Math.max(bounds[1][j], p[j])
}
}
//Save cached symbol
return fontCache[symbol] = [triSymbol, lineSymbol, bounds]
}
{
"name": "gl-scatter-plot",
"version": "5.2.0",
"version": "5.3.0",
"description": "3D scatter plot",

@@ -5,0 +5,0 @@ "main": "pointcloud.js",

@@ -189,2 +189,6 @@ 'use strict'

//Text font
var font = options.font || 'normal'
var alignment = options.alignment || [0,0]
//Drawing geometry

@@ -214,2 +218,3 @@ var pointArray = []

var sizes = options.size
var angles = options.angle
var lineColors = options.lineColor

@@ -226,4 +231,9 @@

cells,
positions) {
positions,
offset,
angle) {
var cos = Math.cos(angle)
var sin = Math.sin(angle)
//Compute pick index for point

@@ -237,5 +247,4 @@ for(var j=0; j<cells.length; ++j) {

var x = positions[c[k]]
for(var l=0; l<2; ++l) {
glyphBuf.push(size * x[l])
}
glyphBuf.push(size * (cos*x[0]-sin*x[1]+offset[0]),
size * (sin*x[0]+cos*x[1]+offset[1]))
}

@@ -248,10 +257,11 @@ }

if(Array.isArray(glyphs)) {
glyphData = getGlyph(glyphs[i])
glyphData = getGlyph(glyphs[i], font)
} else if(glyphs) {
glyphData = getGlyph(glyphs)
glyphData = getGlyph(glyphs, font)
} else {
glyphData = getGlyph('●')
glyphData = getGlyph('●', font)
}
var glyphMesh = glyphData[0]
var glyphLines = glyphData[1]
var glyphBounds = glyphData[2]

@@ -292,5 +302,14 @@ var color

} else {
size = 0.1
size = this.useOrtho ? 12 : 0.1
}
var angle
if(Array.isArray(angles)) {
angle = angles[i]
} else if(angles) {
angle = angles
} else {
angle = 0
}
var x = points[i]

@@ -303,2 +322,10 @@ for(var j=0; j<3; ++j) {

//Calculate text offset
var textOffset = [0,alignment[1]]
if(alignment[0] < 0) {
textOffset[0] = alignment[0] * glyphBounds[1][0]
} else if(alignment[0] > 0) {
textOffset[0] = -alignment[0] * glyphBounds[0][0]
}
appendMarker(

@@ -313,3 +340,5 @@ pointArray,

glyphMesh.cells,
glyphMesh.positions)
glyphMesh.positions,
textOffset,
angle)

@@ -325,3 +354,5 @@ appendMarker(

glyphLines.edges,
glyphLines.positions)
glyphLines.positions,
textOffset,
angle)

@@ -328,0 +359,0 @@ //Increment pickCounter

@@ -140,2 +140,5 @@ gl-scatter-plot

* `lineColor` the color of the outline for each marker
* `font` the font used for drawing the glyphs (default `normal`)
* `angle` an angle to rotate the glyphs by in radians (default `0`)
* `alignment` a 2d vector to offset text drawing by (default `[0,0]`)

@@ -142,0 +145,0 @@ #### `points.draw(camera)`

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc