Skip to content

Commit

Permalink
update bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Aug 21, 2020
1 parent fd1db24 commit 758b06f
Showing 1 changed file with 41 additions and 28 deletions.
69 changes: 41 additions & 28 deletions bundle.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
'use strict';

function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}

function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}

function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];

return arr2;
}
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}

function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}

function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
}

function _iterableToArrayLimit(arr, i) {
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
var _arr = [];
var _n = true;
var _d = false;
Expand All @@ -50,12 +47,29 @@ function _iterableToArrayLimit(arr, i) {
return _arr;
}

function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}

function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;

for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];

return arr2;
}

function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}

function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}

var rgba = require('color-normalize');
Expand Down Expand Up @@ -259,9 +273,9 @@ function Scatter(regl, options) {
elements: regl.prop('elements'),
count: regl.prop('count'),
offset: regl.prop('offset'),
primitive: 'points' // draw sdf-marker
primitive: 'points'
}; // draw sdf-marker

};
var markerOptions = extend({}, shaderOptions);
markerOptions.frag = glslify(["precision highp float;\n#define GLSLIFY 1\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragWidth, fragBorderColorLevel, fragColorLevel;\n\nuniform sampler2D marker;\nuniform float opacity;\n\nfloat smoothStep(float x, float y) {\n return 1.0 / (1.0 + exp(50.0*(x - y)));\n}\n\nvoid main() {\n float dist = texture2D(marker, gl_PointCoord).r, delta = fragWidth;\n\n // max-distance alpha\n if (dist < 0.003) discard;\n\n // null-border case\n if (fragBorderColorLevel == fragColorLevel || fragBorderColor.a == 0.) {\n float colorAmt = smoothstep(.5 - delta, .5 + delta, dist);\n gl_FragColor = vec4(fragColor.rgb, colorAmt * fragColor.a * opacity);\n }\n else {\n float borderColorAmt = smoothstep(fragBorderColorLevel - delta, fragBorderColorLevel + delta, dist);\n float colorAmt = smoothstep(fragColorLevel - delta, fragColorLevel + delta, dist);\n\n vec4 color = fragBorderColor;\n color.a *= borderColorAmt;\n color = mix(color, fragColor, colorAmt);\n color.a *= opacity;\n\n gl_FragColor = color;\n }\n\n}\n"]);
markerOptions.vert = glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute float x, y, xFract, yFract;\nattribute float size, borderSize;\nattribute vec4 colorId, borderColorId;\nattribute float isActive;\n\nuniform vec2 scale, scaleFract, translate, translateFract, paletteSize;\nuniform float pixelRatio;\nuniform bool constPointSize;\nuniform sampler2D palette;\n\nconst float maxSize = 100.;\nconst float borderLevel = .5;\n\nvarying vec4 fragColor, fragBorderColor;\nvarying float fragPointSize, fragBorderRadius, fragWidth, fragBorderColorLevel, fragColorLevel;\n\nfloat pointSizeScale = (constPointSize) ? 2. : pixelRatio;\n\nbool isDirect = (paletteSize.x < 1.);\n\nvec4 getColor(vec4 id) {\n return isDirect ? id / 255. : texture2D(palette,\n vec2(\n (id.x + .5) / paletteSize.x,\n (id.y + .5) / paletteSize.y\n )\n );\n}\n\nvoid main() {\n // ignore inactive points\n if (isActive == 0.) return;\n\n vec2 position = vec2(x, y);\n vec2 positionFract = vec2(xFract, yFract);\n\n vec4 color = getColor(colorId);\n vec4 borderColor = getColor(borderColorId);\n\n float size = size * maxSize / 255.;\n float borderSize = borderSize * maxSize / 255.;\n\n gl_PointSize = 2. * size * pointSizeScale;\n fragPointSize = size * pixelRatio;\n\n vec2 pos = (position + translate) * scale\n + (positionFract + translateFract) * scale\n + (position + translate) * scaleFract\n + (positionFract + translateFract) * scaleFract;\n\n gl_Position = vec4(pos * 2. - 1., 0., 1.);\n\n fragColor = color;\n fragBorderColor = borderColor;\n fragWidth = 1. / gl_PointSize;\n\n fragBorderColorLevel = clamp(borderLevel - borderLevel * borderSize / size, 0., 1.);\n fragColorLevel = clamp(borderLevel + (1. - borderLevel) * borderSize / size, 0., 1.);\n}"]);
Expand Down Expand Up @@ -294,9 +308,8 @@ Scatter.defaults = {
offset: 0,
bounds: null,
positions: [],
snap: 1e4 // update & redraw

};
snap: 1e4
}; // update & redraw

Scatter.prototype.render = function () {
if (arguments.length) {
Expand Down Expand Up @@ -464,9 +477,9 @@ Scatter.prototype.update = function () {
};else if (typeof options === 'function') options = {
ondraw: options
};else if (typeof options[0] === 'number') options = {
positions: options // copy options to avoid mutation & handle aliases
positions: options
}; // copy options to avoid mutation & handle aliases

};
options = pick(options, {
positions: 'positions data points',
snap: 'snap cluster lod tree',
Expand Down Expand Up @@ -948,20 +961,20 @@ Scatter.prototype.destroy = function () {
var extend$1 = require('object-assign');

var reglScatter2d = function reglScatter2d(regl, options) {
var scatter$$1 = new scatter(regl, options);
var render = scatter$$1.render.bind(scatter$$1); // expose API
var scatter$1 = new scatter(regl, options);
var render = scatter$1.render.bind(scatter$1); // expose API

extend$1(render, {
render: render,
update: scatter$$1.update.bind(scatter$$1),
draw: scatter$$1.draw.bind(scatter$$1),
destroy: scatter$$1.destroy.bind(scatter$$1),
regl: scatter$$1.regl,
gl: scatter$$1.gl,
canvas: scatter$$1.gl.canvas,
groups: scatter$$1.groups,
markers: scatter$$1.markerCache,
palette: scatter$$1.palette
update: scatter$1.update.bind(scatter$1),
draw: scatter$1.draw.bind(scatter$1),
destroy: scatter$1.destroy.bind(scatter$1),
regl: scatter$1.regl,
gl: scatter$1.gl,
canvas: scatter$1.gl.canvas,
groups: scatter$1.groups,
markers: scatter$1.markerCache,
palette: scatter$1.palette
});
return render;
};
Expand Down

0 comments on commit 758b06f

Please sign in to comment.