Skip to content

Commit 09f4dd3

Browse files
committed
handle typed arrays in scatter3d
1 parent 54005b9 commit 09f4dd3

File tree

3 files changed

+35
-24
lines changed

3 files changed

+35
-24
lines changed

stackgl_modules/index.js

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21678,6 +21678,17 @@ var IDENTITY = [1,0,0,0,
2167821678
0,0,1,0,
2167921679
0,0,0,1]
2168021680

21681+
var ab = ArrayBuffer
21682+
var dv = DataView
21683+
21684+
function isTypedArray(a) {
21685+
return ab.isView(a) && !(a instanceof dv)
21686+
}
21687+
21688+
function isArrayOrTypedArray(a) {
21689+
return Array.isArray(a) || isTypedArray(a)
21690+
}
21691+
2168121692
module.exports = createPointCloud
2168221693

2168321694
function transformMat4(x, m) {
@@ -22065,7 +22076,7 @@ function get_glyphData(glyphs, index, font, pixelRatio) {
2206522076
var str
2206622077

2206722078
// use the data if presented in an array
22068-
if(Array.isArray(glyphs)) {
22079+
if(isArrayOrTypedArray(glyphs)) {
2206922080
if(index < glyphs.length) {
2207022081
str = glyphs[index]
2207122082
} else {
@@ -22086,19 +22097,19 @@ function get_glyphData(glyphs, index, font, pixelRatio) {
2208622097
if(!font) font = {}
2208722098

2208822099
var family = font.family
22089-
if(Array.isArray(family)) family = family[index]
22100+
if(isArrayOrTypedArray(family)) family = family[index]
2209022101
if(!family) family = "normal"
2209122102

2209222103
var weight = font.weight
22093-
if(Array.isArray(weight)) weight = weight[index]
22104+
if(isArrayOrTypedArray(weight)) weight = weight[index]
2209422105
if(!weight) weight = "normal"
2209522106

2209622107
var style = font.style
22097-
if(Array.isArray(style)) style = style[index]
22108+
if(isArrayOrTypedArray(style)) style = style[index]
2209822109
if(!style) style = "normal"
2209922110

2210022111
var variant = font.variant
22101-
if(Array.isArray(variant)) variant = variant[index]
22112+
if(isArrayOrTypedArray(variant)) variant = variant[index]
2210222113
if(!variant) variant = "normal"
2210322114

2210422115
var glyph = getGlyph(str, {
@@ -22133,15 +22144,15 @@ proto.update = function(options) {
2213322144
this.lineWidth = options.lineWidth
2213422145
}
2213522146
if('project' in options) {
22136-
if(Array.isArray(options.project)) {
22147+
if(isArrayOrTypedArray(options.project)) {
2213722148
this.axesProject = options.project
2213822149
} else {
2213922150
var v = !!options.project
2214022151
this.axesProject = [v,v,v]
2214122152
}
2214222153
}
2214322154
if('projectScale' in options) {
22144-
if(Array.isArray(options.projectScale)) {
22155+
if(isArrayOrTypedArray(options.projectScale)) {
2214522156
this.projectScale = options.projectScale.slice()
2214622157
} else {
2214722158
var s = +options.projectScale
@@ -22151,7 +22162,7 @@ proto.update = function(options) {
2215122162

2215222163
this.projectHasAlpha = false // default to no transparent draw
2215322164
if('projectOpacity' in options) {
22154-
if(Array.isArray(options.projectOpacity)) {
22165+
if(isArrayOrTypedArray(options.projectOpacity)) {
2215522166
this.projectOpacity = options.projectOpacity.slice()
2215622167
} else {
2215722168
var s = +options.projectOpacity
@@ -22262,8 +22273,8 @@ proto.update = function(options) {
2226222273
var color = [0,0,0,1]
2226322274
var lineColor = [0,0,0,1]
2226422275

22265-
var isColorArray = Array.isArray(colors) && Array.isArray(colors[0])
22266-
var isLineColorArray = Array.isArray(lineColors) && Array.isArray(lineColors[0])
22276+
var isColorArray = isArrayOrTypedArray(colors) && isArrayOrTypedArray(colors[0])
22277+
var isLineColorArray = isArrayOrTypedArray(lineColors) && isArrayOrTypedArray(lineColors[0])
2226722278

2226822279
fill_loop:
2226922280
for(var i=0; i<numPoints; ++i) {
@@ -22289,7 +22300,7 @@ proto.update = function(options) {
2228922300

2229022301
//Get color
2229122302
if(!glyphVisible) color = [1,1,1,0]
22292-
else if(Array.isArray(colors)) {
22303+
else if(isArrayOrTypedArray(colors)) {
2229322304
var c
2229422305
if(isColorArray) {
2229522306
if(i < colors.length) {
@@ -22320,7 +22331,7 @@ proto.update = function(options) {
2232022331

2232122332
//Get lineColor
2232222333
if(!glyphVisible) lineColor = [1,1,1,0]
22323-
else if(Array.isArray(lineColors)) {
22334+
else if(isArrayOrTypedArray(lineColors)) {
2232422335
var c
2232522336
if(isLineColorArray) {
2232622337
if(i < lineColors.length) {
@@ -22351,7 +22362,7 @@ proto.update = function(options) {
2235122362

2235222363
var size = 0.5
2235322364
if(!glyphVisible) size = 0.0
22354-
else if(Array.isArray(sizes)) {
22365+
else if(isArrayOrTypedArray(sizes)) {
2235522366
if(i < sizes.length) {
2235622367
size = +sizes[i]
2235722368
} else {
@@ -22365,7 +22376,7 @@ proto.update = function(options) {
2236522376

2236622377

2236722378
var angle = 0
22368-
if(Array.isArray(angles)) {
22379+
if(isArrayOrTypedArray(angles)) {
2236922380
if(i < angles.length) {
2237022381
angle = +angles[i]
2237122382
} else {
@@ -22390,7 +22401,7 @@ proto.update = function(options) {
2239022401
var textOffsetY = alignmentY
2239122402

2239222403
var textOffsetX = 0
22393-
if(Array.isArray(alignmentX)) {
22404+
if(isArrayOrTypedArray(alignmentX)) {
2239422405
if(i < alignmentX.length) {
2239522406
textOffsetX = alignmentX[i]
2239622407
} else {
@@ -22401,7 +22412,7 @@ proto.update = function(options) {
2240122412
}
2240222413

2240322414
var textOffsetY = 0
22404-
if(Array.isArray(alignmentY)) {
22415+
if(isArrayOrTypedArray(alignmentY)) {
2240522416
if(i < alignmentY.length) {
2240622417
textOffsetY = alignmentY[i]
2240722418
} else {

stackgl_modules/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

stackgl_modules/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"gl-plot2d": "^1.5.0",
2323
"gl-plot3d": "^2.4.7",
2424
"gl-pointcloud2d": "^1.0.3",
25-
"gl-scatter3d": "^1.3.0",
25+
"gl-scatter3d": "github:gl-vis/gl-scatter3d#52e58adea4141c86b019f25d781725b54fb2f07c",
2626
"gl-select-box": "^1.0.4",
2727
"gl-shader": "4.3.1",
2828
"gl-spikes2d": "^1.0.2",

0 commit comments

Comments
 (0)