gl-scatter3d
Advanced tools
Comparing version 1.1.1 to 1.1.2
{ | ||
"name": "gl-scatter3d", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "3D scatter plot", | ||
@@ -5,0 +5,0 @@ "main": "pointcloud.js", |
@@ -50,2 +50,10 @@ 'use strict' | ||
var MAX_OPACITY = 1 | ||
function fixOpacity(a) { | ||
if(a === true) return MAX_OPACITY | ||
if(a > MAX_OPACITY) return MAX_OPACITY | ||
return a | ||
} | ||
function PointCloud( | ||
@@ -81,7 +89,7 @@ gl, | ||
this.opacity = 1.0 | ||
this.opacity = MAX_OPACITY | ||
this.lineWidth = 0 | ||
this.projectScale = [2.0/3.0, 2.0/3.0, 2.0/3.0] | ||
this.projectOpacity = [1,1,1] | ||
this.projectOpacity = [MAX_OPACITY, MAX_OPACITY, MAX_OPACITY] | ||
@@ -123,7 +131,7 @@ this.pickId = 0 | ||
proto.isTransparent = function() { | ||
if(this.opacity < 1) { | ||
if(this.opacity < MAX_OPACITY) { | ||
return true | ||
} | ||
for(var i=0; i<3; ++i) { | ||
if(this.axesProject[i] && this.projectOpacity[i] < 1) { | ||
if(this.axesProject[i] && this.projectOpacity[i] < MAX_OPACITY) { | ||
return true | ||
@@ -136,7 +144,7 @@ } | ||
proto.isOpaque = function() { | ||
if(this.opacity >= 1) { | ||
if(this.opacity >= MAX_OPACITY) { | ||
return true | ||
} | ||
for(var i=0; i<3; ++i) { | ||
if(this.axesProject[i] && this.projectOpacity[i] >= 1) { | ||
if(this.axesProject[i] && this.projectOpacity[i] >= MAX_OPACITY) { | ||
return true | ||
@@ -188,3 +196,3 @@ } | ||
function drawProject(shader, points, camera, transparent, forceDraw) { | ||
function drawProject(shader, points, camera) { | ||
var axesProject = points.axesProject | ||
@@ -224,5 +232,2 @@ | ||
} | ||
if((points.projectOpacity[i] < 1) !== transparent) { | ||
continue | ||
} | ||
@@ -292,2 +297,4 @@ uniforms.scale = points.projectScale[i] | ||
points.vao.bind() | ||
//Draw interior | ||
@@ -301,2 +308,4 @@ points.vao.draw(gl.TRIANGLES, points.vertexCount) | ||
} | ||
points.vao.unbind() | ||
} | ||
@@ -313,5 +322,10 @@ } | ||
points.vao.bind() | ||
if(transparent === (points.opacity < 1) || forceDraw) { | ||
if(transparent === (points.projectOpacity < MAX_OPACITY) || forceDraw) { | ||
drawProject(pshader, points, camera) | ||
} | ||
if(transparent === (points.opacity < MAX_OPACITY) || forceDraw) { | ||
shader.bind() | ||
@@ -339,2 +353,4 @@ var uniforms = shader.uniforms | ||
points.vao.bind() | ||
//Draw interior | ||
@@ -348,7 +364,7 @@ points.vao.draw(gl.TRIANGLES, points.vertexCount) | ||
} | ||
points.vao.unbind() | ||
} | ||
drawProject(pshader, points, camera, transparent, forceDraw) | ||
points.vao.unbind() | ||
} | ||
@@ -368,3 +384,3 @@ | ||
var shader = this.useOrtho ? this.pickOrthoShader : this.pickPerspectiveShader | ||
drawFull(shader, this.pickProjectShader, this, camera, false, true) | ||
drawFull(shader, this.pickProjectShader, this, camera, true, true) | ||
} | ||
@@ -474,5 +490,8 @@ | ||
} | ||
for(var i=0; i<3; ++i) { | ||
this.projectOpacity[i] = fixOpacity(this.projectOpacity[i]); | ||
} | ||
} | ||
if('opacity' in options) { | ||
this.opacity = options.opacity | ||
this.opacity = fixOpacity(options.opacity) | ||
} | ||
@@ -479,0 +498,0 @@ |
471453
931
20
62689