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

@deck.gl/layers

Package Overview
Dependencies
Maintainers
6
Versions
469
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@deck.gl/layers - npm Package Compare versions

Comparing version 9.0.0-beta.5 to 9.0.0-beta.6

18

dist/arc-layer/arc-layer-fragment.glsl.js

@@ -23,21 +23,15 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

#define SHADER_NAME arc-layer-fragment-shader
precision highp float;
in vec4 vColor;
in vec2 uv;
in float isValid;
out vec4 fragColor;
void main(void) {
if (isValid == 0.0) {
discard;
}
fragColor = vColor;
geometry.uv = uv;
DECKGL_FILTER_COLOR(fragColor, geometry);
if (isValid == 0.0) {
discard;
}
fragColor = vColor;
geometry.uv = uv;
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;

@@ -23,3 +23,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

#define SHADER_NAME arc-layer-vertex-shader
in vec3 positions;

@@ -36,3 +35,2 @@ in vec4 instanceSourceColors;

in float instanceTilts;
uniform bool greatCircle;

@@ -46,214 +44,151 @@ uniform bool useShortestPath;

uniform int widthUnits;
out vec4 vColor;
out vec2 uv;
out float isValid;
float paraboloid(float distance, float sourceZ, float targetZ, float ratio) {
// d: distance on the xy plane
// r: ratio of the current point
// p: ratio of the peak of the arc
// h: height multiplier
// z = f(r) = sqrt(r * (p * 2 - r)) * d * h
// f(0) = 0
// f(1) = dz
float deltaZ = targetZ - sourceZ;
float dh = distance * instanceHeights;
if (dh == 0.0) {
return sourceZ + deltaZ * ratio;
}
float unitZ = deltaZ / dh;
float p2 = unitZ * unitZ + 1.0;
// sqrt does not deal with negative values, manually flip source and target if delta.z < 0
float dir = step(deltaZ, 0.0);
float z0 = mix(sourceZ, targetZ, dir);
float r = mix(ratio, 1.0 - ratio, dir);
return sqrt(r * (p2 - r)) * dh + z0;
float deltaZ = targetZ - sourceZ;
float dh = distance * instanceHeights;
if (dh == 0.0) {
return sourceZ + deltaZ * ratio;
}
// offset vector by strokeWidth pixels
// offset_direction is -1 (left) or 1 (right)
float unitZ = deltaZ / dh;
float p2 = unitZ * unitZ + 1.0;
float dir = step(deltaZ, 0.0);
float z0 = mix(sourceZ, targetZ, dir);
float r = mix(ratio, 1.0 - ratio, dir);
return sqrt(r * (p2 - r)) * dh + z0;
}
vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) {
// normalized direction of the line
vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize);
// rotate by 90 degrees
dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);
return dir_screenspace * offset_direction * width / 2.0;
vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize);
dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);
return dir_screenspace * offset_direction * width / 2.0;
}
float getSegmentRatio(float index) {
return smoothstep(0.0, 1.0, index / (numSegments - 1.0));
return smoothstep(0.0, 1.0, index / (numSegments - 1.0));
}
vec3 interpolateFlat(vec3 source, vec3 target, float segmentRatio) {
float distance = length(source.xy - target.xy);
float z = paraboloid(distance, source.z, target.z, segmentRatio);
float tiltAngle = radians(instanceTilts);
vec2 tiltDirection = normalize(target.xy - source.xy);
vec2 tilt = vec2(-tiltDirection.y, tiltDirection.x) * z * sin(tiltAngle);
return vec3(
mix(source.xy, target.xy, segmentRatio) + tilt,
z * cos(tiltAngle)
);
float distance = length(source.xy - target.xy);
float z = paraboloid(distance, source.z, target.z, segmentRatio);
float tiltAngle = radians(instanceTilts);
vec2 tiltDirection = normalize(target.xy - source.xy);
vec2 tilt = vec2(-tiltDirection.y, tiltDirection.x) * z * sin(tiltAngle);
return vec3(
mix(source.xy, target.xy, segmentRatio) + tilt,
z * cos(tiltAngle)
);
}
/* Great circle interpolation
* http://www.movable-type.co.uk/scripts/latlong.html
*/
float getAngularDist (vec2 source, vec2 target) {
vec2 sourceRadians = radians(source);
vec2 targetRadians = radians(target);
vec2 sin_half_delta = sin((sourceRadians - targetRadians) / 2.0);
vec2 shd_sq = sin_half_delta * sin_half_delta;
float a = shd_sq.y + cos(sourceRadians.y) * cos(targetRadians.y) * shd_sq.x;
return 2.0 * asin(sqrt(a));
vec2 sourceRadians = radians(source);
vec2 targetRadians = radians(target);
vec2 sin_half_delta = sin((sourceRadians - targetRadians) / 2.0);
vec2 shd_sq = sin_half_delta * sin_half_delta;
float a = shd_sq.y + cos(sourceRadians.y) * cos(targetRadians.y) * shd_sq.x;
return 2.0 * asin(sqrt(a));
}
vec3 interpolateGreatCircle(vec3 source, vec3 target, vec3 source3D, vec3 target3D, float angularDist, float t) {
vec2 lngLat;
// if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation
if(abs(angularDist - PI) < 0.001) {
lngLat = (1.0 - t) * source.xy + t * target.xy;
} else {
float a = sin((1.0 - t) * angularDist);
float b = sin(t * angularDist);
vec3 p = source3D.yxz * a + target3D.yxz * b;
lngLat = degrees(vec2(atan(p.y, -p.x), atan(p.z, length(p.xy))));
}
float z = paraboloid(angularDist * EARTH_RADIUS, source.z, target.z, t);
return vec3(lngLat, z);
vec2 lngLat;
if(abs(angularDist - PI) < 0.001) {
lngLat = (1.0 - t) * source.xy + t * target.xy;
} else {
float a = sin((1.0 - t) * angularDist);
float b = sin(t * angularDist);
vec3 p = source3D.yxz * a + target3D.yxz * b;
lngLat = degrees(vec2(atan(p.y, -p.x), atan(p.z, length(p.xy))));
}
/* END GREAT CIRCLE */
float z = paraboloid(angularDist * EARTH_RADIUS, source.z, target.z, t);
return vec3(lngLat, z);
}
void main(void) {
geometry.worldPosition = instanceSourcePositions;
geometry.worldPositionAlt = instanceTargetPositions;
float segmentIndex = positions.x;
float segmentRatio = getSegmentRatio(segmentIndex);
float prevSegmentRatio = getSegmentRatio(max(0.0, segmentIndex - 1.0));
float nextSegmentRatio = getSegmentRatio(min(numSegments - 1.0, segmentIndex + 1.0));
// if it's the first point, use next - current as direction
// otherwise use current - prev
float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));
isValid = 1.0;
uv = vec2(segmentRatio, positions.y);
geometry.uv = uv;
geometry.pickingColor = instancePickingColors;
vec4 curr;
vec4 next;
vec3 source;
vec3 target;
if ((greatCircle || project_uProjectionMode == PROJECTION_MODE_GLOBE) && project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
source = project_globe_(vec3(instanceSourcePositions.xy, 0.0));
target = project_globe_(vec3(instanceTargetPositions.xy, 0.0));
float angularDist = getAngularDist(instanceSourcePositions.xy, instanceTargetPositions.xy);
vec3 prevPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, prevSegmentRatio);
vec3 currPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, segmentRatio);
vec3 nextPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, nextSegmentRatio);
if (abs(currPos.x - prevPos.x) > 180.0) {
indexDir = -1.0;
isValid = 0.0;
} else if (abs(currPos.x - nextPos.x) > 180.0) {
indexDir = 1.0;
isValid = 0.0;
}
nextPos = indexDir < 0.0 ? prevPos : nextPos;
nextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio;
if (isValid == 0.0) {
// split at the 180th meridian
nextPos.x += nextPos.x > 0.0 ? -360.0 : 360.0;
float t = ((currPos.x > 0.0 ? 180.0 : -180.0) - currPos.x) / (nextPos.x - currPos.x);
currPos = mix(currPos, nextPos, t);
segmentRatio = mix(segmentRatio, nextSegmentRatio, t);
}
vec3 currPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, segmentRatio);
vec3 nextPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, nextSegmentRatio);
curr = project_position_to_clipspace(currPos, currPos64Low, vec3(0.0), geometry.position);
next = project_position_to_clipspace(nextPos, nextPos64Low, vec3(0.0));
} else {
vec3 source_world = instanceSourcePositions;
vec3 target_world = instanceTargetPositions;
if (useShortestPath) {
source_world.x = mod(source_world.x + 180., 360.0) - 180.;
target_world.x = mod(target_world.x + 180., 360.0) - 180.;
float deltaLng = target_world.x - source_world.x;
if (deltaLng > 180.) target_world.x -= 360.;
if (deltaLng < -180.) source_world.x -= 360.;
}
source = project_position(source_world, instanceSourcePositions64Low);
target = project_position(target_world, instanceTargetPositions64Low);
// common x at longitude=-180
float antiMeridianX = 0.0;
if (useShortestPath) {
if (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {
antiMeridianX = -(project_uCoordinateOrigin.x + 180.) / 360. * TILE_SIZE;
}
float thresholdRatio = (antiMeridianX - source.x) / (target.x - source.x);
if (prevSegmentRatio <= thresholdRatio && nextSegmentRatio > thresholdRatio) {
isValid = 0.0;
indexDir = sign(segmentRatio - thresholdRatio);
segmentRatio = thresholdRatio;
}
}
nextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio;
vec3 currPos = interpolateFlat(source, target, segmentRatio);
vec3 nextPos = interpolateFlat(source, target, nextSegmentRatio);
if (useShortestPath) {
if (nextPos.x < antiMeridianX) {
currPos.x += TILE_SIZE;
nextPos.x += TILE_SIZE;
}
}
curr = project_common_position_to_clipspace(vec4(currPos, 1.0));
next = project_common_position_to_clipspace(vec4(nextPos, 1.0));
geometry.position = vec4(currPos, 1.0);
}
// Multiply out width and clamp to limits
// mercator pixels are interpreted as screen pixels
float widthPixels = clamp(
project_size_to_pixel(instanceWidths * widthScale, widthUnits),
widthMinPixels, widthMaxPixels
);
// extrude
vec3 offset = vec3(
getExtrusionOffset((next.xy - curr.xy) * indexDir, positions.y, widthPixels),
0.0);
DECKGL_FILTER_SIZE(offset, geometry);
DECKGL_FILTER_GL_POSITION(curr, geometry);
gl_Position = curr + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0);
vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio);
vColor = vec4(color.rgb, color.a * opacity);
DECKGL_FILTER_COLOR(vColor, geometry);
geometry.worldPosition = instanceSourcePositions;
geometry.worldPositionAlt = instanceTargetPositions;
float segmentIndex = positions.x;
float segmentRatio = getSegmentRatio(segmentIndex);
float prevSegmentRatio = getSegmentRatio(max(0.0, segmentIndex - 1.0));
float nextSegmentRatio = getSegmentRatio(min(numSegments - 1.0, segmentIndex + 1.0));
float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));
isValid = 1.0;
uv = vec2(segmentRatio, positions.y);
geometry.uv = uv;
geometry.pickingColor = instancePickingColors;
vec4 curr;
vec4 next;
vec3 source;
vec3 target;
if ((greatCircle || project_uProjectionMode == PROJECTION_MODE_GLOBE) && project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {
source = project_globe_(vec3(instanceSourcePositions.xy, 0.0));
target = project_globe_(vec3(instanceTargetPositions.xy, 0.0));
float angularDist = getAngularDist(instanceSourcePositions.xy, instanceTargetPositions.xy);
vec3 prevPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, prevSegmentRatio);
vec3 currPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, segmentRatio);
vec3 nextPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, nextSegmentRatio);
if (abs(currPos.x - prevPos.x) > 180.0) {
indexDir = -1.0;
isValid = 0.0;
} else if (abs(currPos.x - nextPos.x) > 180.0) {
indexDir = 1.0;
isValid = 0.0;
}
nextPos = indexDir < 0.0 ? prevPos : nextPos;
nextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio;
if (isValid == 0.0) {
nextPos.x += nextPos.x > 0.0 ? -360.0 : 360.0;
float t = ((currPos.x > 0.0 ? 180.0 : -180.0) - currPos.x) / (nextPos.x - currPos.x);
currPos = mix(currPos, nextPos, t);
segmentRatio = mix(segmentRatio, nextSegmentRatio, t);
}
vec3 currPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, segmentRatio);
vec3 nextPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, nextSegmentRatio);
curr = project_position_to_clipspace(currPos, currPos64Low, vec3(0.0), geometry.position);
next = project_position_to_clipspace(nextPos, nextPos64Low, vec3(0.0));
} else {
vec3 source_world = instanceSourcePositions;
vec3 target_world = instanceTargetPositions;
if (useShortestPath) {
source_world.x = mod(source_world.x + 180., 360.0) - 180.;
target_world.x = mod(target_world.x + 180., 360.0) - 180.;
float deltaLng = target_world.x - source_world.x;
if (deltaLng > 180.) target_world.x -= 360.;
if (deltaLng < -180.) source_world.x -= 360.;
}
source = project_position(source_world, instanceSourcePositions64Low);
target = project_position(target_world, instanceTargetPositions64Low);
float antiMeridianX = 0.0;
if (useShortestPath) {
if (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {
antiMeridianX = -(project_uCoordinateOrigin.x + 180.) / 360. * TILE_SIZE;
}
float thresholdRatio = (antiMeridianX - source.x) / (target.x - source.x);
if (prevSegmentRatio <= thresholdRatio && nextSegmentRatio > thresholdRatio) {
isValid = 0.0;
indexDir = sign(segmentRatio - thresholdRatio);
segmentRatio = thresholdRatio;
}
}
nextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio;
vec3 currPos = interpolateFlat(source, target, segmentRatio);
vec3 nextPos = interpolateFlat(source, target, nextSegmentRatio);
if (useShortestPath) {
if (nextPos.x < antiMeridianX) {
currPos.x += TILE_SIZE;
nextPos.x += TILE_SIZE;
}
}
curr = project_common_position_to_clipspace(vec4(currPos, 1.0));
next = project_common_position_to_clipspace(vec4(nextPos, 1.0));
geometry.position = vec4(currPos, 1.0);
}
float widthPixels = clamp(
project_size_to_pixel(instanceWidths * widthScale, widthUnits),
widthMinPixels, widthMaxPixels
);
vec3 offset = vec3(
getExtrusionOffset((next.xy - curr.xy) * indexDir, positions.y, widthPixels),
0.0);
DECKGL_FILTER_SIZE(offset, geometry);
DECKGL_FILTER_GL_POSITION(curr, geometry);
gl_Position = curr + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0);
vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio);
vColor = vec4(color.rgb, color.a * opacity);
DECKGL_FILTER_COLOR(vColor, geometry);
}
`;

@@ -23,3 +23,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

import { Model } from '@luma.gl/engine';
import { GL } from '@luma.gl/constants';
import vs from "./arc-layer-vertex.glsl.js";

@@ -66,3 +65,3 @@ import fs from "./arc-layer-fragment.glsl.js";

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -74,3 +73,3 @@ transition: true,

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -82,4 +81,3 @@ transition: true,

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
transition: true,

@@ -91,4 +89,3 @@ accessor: 'getSourceColor',

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
transition: true,

@@ -95,0 +92,0 @@ accessor: 'getTargetColor',

@@ -22,3 +22,2 @@ // Copyright (c) 2015 Uber Technologies, Inc.

import { Model } from '@luma.gl/engine';
import { GL } from '@luma.gl/constants';
import { lngLatToWorld } from '@math.gl/web-mercator';

@@ -60,3 +59,3 @@ import createMesh from "./create-mesh.js";

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -63,0 +62,0 @@ update: attribute => (attribute.value = this.state.mesh.positions),

import { log } from '@deck.gl/core';
import { uid } from '@luma.gl/core';
import { Geometry } from '@luma.gl/engine';

@@ -7,7 +6,5 @@ import { modifyPolygonWindingDirection, WINDING } from '@math.gl/polygon';

constructor(props) {
const { id = uid('column-geometry') } = props;
const { indices, attributes } = tesselateColumn(props);
super({
...props,
id,
indices,

@@ -14,0 +11,0 @@ // @ts-expect-error

@@ -22,11 +22,7 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

#define SHADER_NAME column-layer-fragment-shader
precision highp float;
uniform vec3 project_uCameraPosition;
uniform bool extruded;
uniform bool isStroke;
out vec4 fragColor;
in vec4 vColor;

@@ -36,13 +32,12 @@ #ifdef FLAT_SHADING

#endif
void main(void) {
fragColor = vColor;
fragColor = vColor;
#ifdef FLAT_SHADING
if (extruded && !isStroke && !bool(picking.isActive)) {
vec3 normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
fragColor.rgb = lighting_getLightColor(vColor.rgb, project_uCameraPosition, position_commonspace.xyz, normal);
}
if (extruded && !isStroke && !bool(picking.isActive)) {
vec3 normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
fragColor.rgb = lighting_getLightColor(vColor.rgb, project_uCameraPosition, position_commonspace.xyz, normal);
}
#endif
DECKGL_FILTER_COLOR(fragColor, geometry);
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;

@@ -21,8 +21,5 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

export default `#version 300 es
#define SHADER_NAME column-layer-vertex-shader
in vec3 positions;
in vec3 normals;
in vec3 instancePositions;

@@ -34,6 +31,3 @@ in float instanceElevations;

in float instanceStrokeWidths;
in vec3 instancePickingColors;
// Custom uniforms
uniform float opacity;

@@ -54,4 +48,2 @@ uniform float radius;

uniform int widthUnits;
// Result
out vec4 vColor;

@@ -61,64 +53,48 @@ #ifdef FLAT_SHADING

#endif
void main(void) {
geometry.worldPosition = instancePositions;
vec4 color = isStroke ? instanceLineColors : instanceFillColors;
// rotate primitive position and normal
mat2 rotationMatrix = mat2(cos(angle), sin(angle), -sin(angle), cos(angle));
// calculate elevation, if 3d not enabled set to 0
// cylindar gemoetry height are between -1.0 to 1.0, transform it to between 0, 1
float elevation = 0.0;
// calculate stroke offset
float strokeOffsetRatio = 1.0;
if (extruded) {
elevation = instanceElevations * (positions.z + 1.0) / 2.0 * elevationScale;
} else if (stroked) {
float widthPixels = clamp(
project_size_to_pixel(instanceStrokeWidths * widthScale, widthUnits),
widthMinPixels, widthMaxPixels) / 2.0;
float halfOffset = project_pixel_size(widthPixels) / project_size(edgeDistance * coverage * radius);
if (isStroke) {
strokeOffsetRatio -= sign(positions.z) * halfOffset;
} else {
strokeOffsetRatio -= halfOffset;
}
}
// if alpha == 0.0 or z < 0.0, do not render element
float shouldRender = float(color.a > 0.0 && instanceElevations >= 0.0);
float dotRadius = radius * coverage * shouldRender;
geometry.pickingColor = instancePickingColors;
// project center of column
vec3 centroidPosition = vec3(instancePositions.xy, instancePositions.z + elevation);
vec3 centroidPosition64Low = instancePositions64Low;
vec2 offset = (rotationMatrix * positions.xy * strokeOffsetRatio + offset) * dotRadius;
if (radiusUnits == UNIT_METERS) {
offset = project_size(offset);
}
vec3 pos = vec3(offset, 0.);
DECKGL_FILTER_SIZE(pos, geometry);
gl_Position = project_position_to_clipspace(centroidPosition, centroidPosition64Low, pos, geometry.position);
geometry.normal = project_normal(vec3(rotationMatrix * normals.xy, normals.z));
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
// Light calculations
if (extruded && !isStroke) {
geometry.worldPosition = instancePositions;
vec4 color = isStroke ? instanceLineColors : instanceFillColors;
mat2 rotationMatrix = mat2(cos(angle), sin(angle), -sin(angle), cos(angle));
float elevation = 0.0;
float strokeOffsetRatio = 1.0;
if (extruded) {
elevation = instanceElevations * (positions.z + 1.0) / 2.0 * elevationScale;
} else if (stroked) {
float widthPixels = clamp(
project_size_to_pixel(instanceStrokeWidths * widthScale, widthUnits),
widthMinPixels, widthMaxPixels) / 2.0;
float halfOffset = project_pixel_size(widthPixels) / project_size(edgeDistance * coverage * radius);
if (isStroke) {
strokeOffsetRatio -= sign(positions.z) * halfOffset;
} else {
strokeOffsetRatio -= halfOffset;
}
}
float shouldRender = float(color.a > 0.0 && instanceElevations >= 0.0);
float dotRadius = radius * coverage * shouldRender;
geometry.pickingColor = instancePickingColors;
vec3 centroidPosition = vec3(instancePositions.xy, instancePositions.z + elevation);
vec3 centroidPosition64Low = instancePositions64Low;
vec2 offset = (rotationMatrix * positions.xy * strokeOffsetRatio + offset) * dotRadius;
if (radiusUnits == UNIT_METERS) {
offset = project_size(offset);
}
vec3 pos = vec3(offset, 0.);
DECKGL_FILTER_SIZE(pos, geometry);
gl_Position = project_position_to_clipspace(centroidPosition, centroidPosition64Low, pos, geometry.position);
geometry.normal = project_normal(vec3(rotationMatrix * normals.xy, normals.z));
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
if (extruded && !isStroke) {
#ifdef FLAT_SHADING
position_commonspace = geometry.position;
vColor = vec4(color.rgb, color.a * opacity);
position_commonspace = geometry.position;
vColor = vec4(color.rgb, color.a * opacity);
#else
vec3 lightColor = lighting_getLightColor(color.rgb, project_uCameraPosition, geometry.position.xyz, geometry.normal);
vColor = vec4(lightColor, color.a * opacity);
vec3 lightColor = lighting_getLightColor(color.rgb, project_uCameraPosition, geometry.position.xyz, geometry.normal);
vColor = vec4(lightColor, color.a * opacity);
#endif
} else {
vColor = vec4(color.rgb, color.a * opacity);
}
DECKGL_FILTER_COLOR(vColor, geometry);
} else {
vColor = vec4(color.rgb, color.a * opacity);
}
DECKGL_FILTER_COLOR(vColor, geometry);
}
`;

@@ -22,3 +22,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

import { Model } from '@luma.gl/engine';
import { GL } from '@luma.gl/constants';
import ColumnGeometry from "./column-geometry.js";

@@ -60,6 +59,5 @@ import vs from "./column-layer-vertex.glsl.js";

const { device } = this.context;
const transpileToGLSL100 = device.info.type !== 'webgl2';
const defines = {};
const useDerivatives = this.props.flatShading && device.features.has('glsl-derivatives');
if (useDerivatives) {
const { flatShading } = this.props;
if (flatShading) {
defines.FLAT_SHADING = 1;

@@ -71,4 +69,3 @@ }

defines,
transpileToGLSL100,
modules: [project32, useDerivatives ? phongLighting : gouraudLighting, picking]
modules: [project32, flatShading ? phongLighting : gouraudLighting, picking]
});

@@ -86,3 +83,3 @@ }

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -99,4 +96,3 @@ transition: true,

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
transition: true,

@@ -108,4 +104,3 @@ accessor: 'getFillColor',

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
transition: true,

@@ -112,0 +107,0 @@ accessor: 'getLineColor',

@@ -23,9 +23,6 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

#define SHADER_NAME icon-layer-fragment-shader
precision highp float;
uniform float opacity;
uniform sampler2D iconsTexture;
uniform float alphaCutoff;
in float vColorMode;

@@ -35,23 +32,14 @@ in vec4 vColor;

in vec2 uv;
out vec4 fragColor;
void main(void) {
geometry.uv = uv;
vec4 texColor = texture(iconsTexture, vTextureCoords);
// if colorMode == 0, use pixel color from the texture
// if colorMode == 1 or rendering picking buffer, use texture as transparency mask
vec3 color = mix(texColor.rgb, vColor.rgb, vColorMode);
// Take the global opacity and the alpha from vColor into account for the alpha component
float a = texColor.a * opacity * vColor.a;
if (a < alphaCutoff) {
discard;
}
fragColor = vec4(color, a);
DECKGL_FILTER_COLOR(fragColor, geometry);
geometry.uv = uv;
vec4 texColor = texture(iconsTexture, vTextureCoords);
vec3 color = mix(texColor.rgb, vColor.rgb, vColorMode);
float a = texColor.a * opacity * vColor.a;
if (a < alphaCutoff) {
discard;
}
fragColor = vec4(color, a);
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;

@@ -23,5 +23,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

#define SHADER_NAME icon-layer-vertex-shader
in vec2 positions;
in vec3 instancePositions;

@@ -37,3 +35,2 @@ in vec3 instancePositions64Low;

in vec2 instancePixelOffset;
uniform float sizeScale;

@@ -45,3 +42,2 @@ uniform vec2 iconsTextureDim;

uniform int sizeUnits;
out float vColorMode;

@@ -51,60 +47,45 @@ out vec4 vColor;

out vec2 uv;
vec2 rotate_by_angle(vec2 vertex, float angle) {
float angle_radian = angle * PI / 180.0;
float cos_angle = cos(angle_radian);
float sin_angle = sin(angle_radian);
mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);
return rotationMatrix * vertex;
float angle_radian = angle * PI / 180.0;
float cos_angle = cos(angle_radian);
float sin_angle = sin(angle_radian);
mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);
return rotationMatrix * vertex;
}
void main(void) {
geometry.worldPosition = instancePositions;
geometry.uv = positions;
geometry.pickingColor = instancePickingColors;
uv = positions;
vec2 iconSize = instanceIconFrames.zw;
// convert size in meters to pixels, then scaled and clamp
// project meters to pixels and clamp to limits
float sizePixels = clamp(
project_size_to_pixel(instanceSizes * sizeScale, sizeUnits),
sizeMinPixels, sizeMaxPixels
);
// scale icon height to match instanceSize
float instanceScale = iconSize.y == 0.0 ? 0.0 : sizePixels / iconSize.y;
// scale and rotate vertex in "pixel" value and convert back to fraction in clipspace
vec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets;
pixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale;
pixelOffset += instancePixelOffset;
pixelOffset.y *= -1.0;
if (billboard) {
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
vec3 offset = vec3(pixelOffset, 0.0);
DECKGL_FILTER_SIZE(offset, geometry);
gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
} else {
vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);
DECKGL_FILTER_SIZE(offset_common, geometry);
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
}
vTextureCoords = mix(
instanceIconFrames.xy,
instanceIconFrames.xy + iconSize,
(positions.xy + 1.0) / 2.0
) / iconsTextureDim;
vColor = instanceColors;
DECKGL_FILTER_COLOR(vColor, geometry);
vColorMode = instanceColorModes;
geometry.worldPosition = instancePositions;
geometry.uv = positions;
geometry.pickingColor = instancePickingColors;
uv = positions;
vec2 iconSize = instanceIconFrames.zw;
float sizePixels = clamp(
project_size_to_pixel(instanceSizes * sizeScale, sizeUnits),
sizeMinPixels, sizeMaxPixels
);
float instanceScale = iconSize.y == 0.0 ? 0.0 : sizePixels / iconSize.y;
vec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets;
pixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale;
pixelOffset += instancePixelOffset;
pixelOffset.y *= -1.0;
if (billboard) {
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
vec3 offset = vec3(pixelOffset, 0.0);
DECKGL_FILTER_SIZE(offset, geometry);
gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
} else {
vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);
DECKGL_FILTER_SIZE(offset_common, geometry);
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
}
vTextureCoords = mix(
instanceIconFrames.xy,
instanceIconFrames.xy + iconSize,
(positions.xy + 1.0) / 2.0
) / iconsTextureDim;
vColor = instanceColors;
DECKGL_FILTER_COLOR(vColor, geometry);
vColorMode = instanceColorModes;
}
`;

@@ -22,3 +22,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

import { Model, Geometry } from '@luma.gl/engine';
import { GL } from '@luma.gl/constants';
import vs from "./icon-layer-vertex.glsl.js";

@@ -65,3 +64,3 @@ import fs from "./icon-layer-fragment.glsl.js";

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -91,3 +90,3 @@ transition: true,

size: 1,
type: GL.UNSIGNED_BYTE,
type: 'uint8',
accessor: 'getIcon',

@@ -99,4 +98,3 @@ // eslint-disable-next-line @typescript-eslint/unbound-method

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
transition: true,

@@ -103,0 +101,0 @@ accessor: 'getColor',

@@ -23,17 +23,11 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

#define SHADER_NAME line-layer-fragment-shader
precision highp float;
in vec4 vColor;
in vec2 uv;
out vec4 fragColor;
void main(void) {
geometry.uv = uv;
fragColor = vColor;
DECKGL_FILTER_COLOR(fragColor, geometry);
geometry.uv = uv;
fragColor = vColor;
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;

@@ -23,3 +23,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

#define SHADER_NAME line-layer-vertex-shader
in vec3 positions;

@@ -33,3 +32,2 @@ in vec3 instanceSourcePositions;

in float instanceWidths;
uniform float opacity;

@@ -41,83 +39,60 @@ uniform float widthScale;

uniform int widthUnits;
out vec4 vColor;
out vec2 uv;
// offset vector by strokeWidth pixels
// offset_direction is -1 (left) or 1 (right)
vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) {
// normalized direction of the line
vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize);
// rotate by 90 degrees
dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);
return dir_screenspace * offset_direction * width / 2.0;
vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize);
dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);
return dir_screenspace * offset_direction * width / 2.0;
}
vec3 splitLine(vec3 a, vec3 b, float x) {
float t = (x - a.x) / (b.x - a.x);
return vec3(x, mix(a.yz, b.yz, t));
float t = (x - a.x) / (b.x - a.x);
return vec3(x, mix(a.yz, b.yz, t));
}
void main(void) {
geometry.worldPosition = instanceSourcePositions;
geometry.worldPositionAlt = instanceTargetPositions;
vec3 source_world = instanceSourcePositions;
vec3 target_world = instanceTargetPositions;
vec3 source_world_64low = instanceSourcePositions64Low;
vec3 target_world_64low = instanceTargetPositions64Low;
if (useShortestPath > 0.5 || useShortestPath < -0.5) {
source_world.x = mod(source_world.x + 180., 360.0) - 180.;
target_world.x = mod(target_world.x + 180., 360.0) - 180.;
float deltaLng = target_world.x - source_world.x;
if (deltaLng * useShortestPath > 180.) {
source_world.x += 360. * useShortestPath;
source_world = splitLine(source_world, target_world, 180. * useShortestPath);
source_world_64low = vec3(0.0);
} else if (deltaLng * useShortestPath < -180.) {
target_world.x += 360. * useShortestPath;
target_world = splitLine(source_world, target_world, 180. * useShortestPath);
target_world_64low = vec3(0.0);
} else if (useShortestPath < 0.) {
// Line is not split, abort
gl_Position = vec4(0.);
return;
}
}
// Position
vec4 source_commonspace;
vec4 target_commonspace;
vec4 source = project_position_to_clipspace(source_world, source_world_64low, vec3(0.), source_commonspace);
vec4 target = project_position_to_clipspace(target_world, target_world_64low, vec3(0.), target_commonspace);
// linear interpolation of source & target to pick right coord
float segmentIndex = positions.x;
vec4 p = mix(source, target, segmentIndex);
geometry.position = mix(source_commonspace, target_commonspace, segmentIndex);
uv = positions.xy;
geometry.uv = uv;
geometry.pickingColor = instancePickingColors;
// Multiply out width and clamp to limits
float widthPixels = clamp(
project_size_to_pixel(instanceWidths * widthScale, widthUnits),
widthMinPixels, widthMaxPixels
);
// extrude
vec3 offset = vec3(
getExtrusionOffset(target.xy - source.xy, positions.y, widthPixels),
0.0);
DECKGL_FILTER_SIZE(offset, geometry);
DECKGL_FILTER_GL_POSITION(p, geometry);
gl_Position = p + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0);
// Color
vColor = vec4(instanceColors.rgb, instanceColors.a * opacity);
DECKGL_FILTER_COLOR(vColor, geometry);
geometry.worldPosition = instanceSourcePositions;
geometry.worldPositionAlt = instanceTargetPositions;
vec3 source_world = instanceSourcePositions;
vec3 target_world = instanceTargetPositions;
vec3 source_world_64low = instanceSourcePositions64Low;
vec3 target_world_64low = instanceTargetPositions64Low;
if (useShortestPath > 0.5 || useShortestPath < -0.5) {
source_world.x = mod(source_world.x + 180., 360.0) - 180.;
target_world.x = mod(target_world.x + 180., 360.0) - 180.;
float deltaLng = target_world.x - source_world.x;
if (deltaLng * useShortestPath > 180.) {
source_world.x += 360. * useShortestPath;
source_world = splitLine(source_world, target_world, 180. * useShortestPath);
source_world_64low = vec3(0.0);
} else if (deltaLng * useShortestPath < -180.) {
target_world.x += 360. * useShortestPath;
target_world = splitLine(source_world, target_world, 180. * useShortestPath);
target_world_64low = vec3(0.0);
} else if (useShortestPath < 0.) {
gl_Position = vec4(0.);
return;
}
}
vec4 source_commonspace;
vec4 target_commonspace;
vec4 source = project_position_to_clipspace(source_world, source_world_64low, vec3(0.), source_commonspace);
vec4 target = project_position_to_clipspace(target_world, target_world_64low, vec3(0.), target_commonspace);
float segmentIndex = positions.x;
vec4 p = mix(source, target, segmentIndex);
geometry.position = mix(source_commonspace, target_commonspace, segmentIndex);
uv = positions.xy;
geometry.uv = uv;
geometry.pickingColor = instancePickingColors;
float widthPixels = clamp(
project_size_to_pixel(instanceWidths * widthScale, widthUnits),
widthMinPixels, widthMaxPixels
);
vec3 offset = vec3(
getExtrusionOffset(target.xy - source.xy, positions.y, widthPixels),
0.0);
DECKGL_FILTER_SIZE(offset, geometry);
DECKGL_FILTER_GL_POSITION(p, geometry);
gl_Position = p + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0);
vColor = vec4(instanceColors.rgb, instanceColors.a * opacity);
DECKGL_FILTER_COLOR(vColor, geometry);
}
`;

@@ -23,3 +23,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

import { Model } from '@luma.gl/engine';
import { GL } from '@luma.gl/constants';
import vs from "./line-layer-vertex.glsl.js";

@@ -63,3 +62,3 @@ import fs from "./line-layer-fragment.glsl.js";

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -71,3 +70,3 @@ transition: true,

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -79,4 +78,3 @@ transition: true,

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
transition: true,

@@ -83,0 +81,0 @@ accessor: 'getColor',

@@ -23,38 +23,24 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

#define SHADER_NAME path-layer-fragment-shader
precision highp float;
uniform float miterLimit;
in vec4 vColor;
in vec2 vCornerOffset;
in float vMiterLength;
/*
* vPathPosition represents the relative coordinates of the current fragment on the path segment.
* vPathPosition.x - position along the width of the path, between [-1, 1]. 0 is the center line.
* vPathPosition.y - position along the length of the path, between [0, L / width].
*/
in vec2 vPathPosition;
in float vPathLength;
in float vJointType;
out vec4 fragColor;
void main(void) {
geometry.uv = vPathPosition;
if (vPathPosition.y < 0.0 || vPathPosition.y > vPathLength) {
// if joint is rounded, test distance from the corner
if (vJointType > 0.5 && length(vCornerOffset) > 1.0) {
discard;
}
// trim miter
if (vJointType < 0.5 && vMiterLength > miterLimit + 1.0) {
discard;
}
}
fragColor = vColor;
DECKGL_FILTER_COLOR(fragColor, geometry);
geometry.uv = vPathPosition;
if (vPathPosition.y < 0.0 || vPathPosition.y > vPathLength) {
if (vJointType > 0.5 && length(vCornerOffset) > 1.0) {
discard;
}
if (vJointType < 0.5 && vMiterLength > miterLimit + 1.0) {
discard;
}
}
fragColor = vColor;
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;

@@ -23,5 +23,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

#define SHADER_NAME path-layer-vertex-shader
in vec2 positions;
in float instanceTypes;

@@ -39,3 +37,2 @@ in vec3 instanceStartPositions;

in vec3 instancePickingColors;
uniform float widthScale;

@@ -49,5 +46,3 @@ uniform float widthMinPixels;

uniform int widthUnits;
uniform float opacity;
out vec4 vColor;

@@ -59,180 +54,125 @@ out vec2 vCornerOffset;

out float vJointType;
const float EPSILON = 0.001;
const vec3 ZERO_OFFSET = vec3(0.0);
float flipIfTrue(bool flag) {
return -(float(flag) * 2. - 1.);
return -(float(flag) * 2. - 1.);
}
// calculate line join positions
vec3 getLineJoinOffset(
vec3 prevPoint, vec3 currPoint, vec3 nextPoint,
vec2 width
vec3 prevPoint, vec3 currPoint, vec3 nextPoint,
vec2 width
) {
bool isEnd = positions.x > 0.0;
// side of the segment - -1: left, 0: center, 1: right
float sideOfPath = positions.y;
float isJoint = float(sideOfPath == 0.0);
vec3 deltaA3 = (currPoint - prevPoint);
vec3 deltaB3 = (nextPoint - currPoint);
mat3 rotationMatrix;
bool needsRotation = !billboard && project_needs_rotation(currPoint, rotationMatrix);
if (needsRotation) {
deltaA3 = deltaA3 * rotationMatrix;
deltaB3 = deltaB3 * rotationMatrix;
}
vec2 deltaA = deltaA3.xy / width;
vec2 deltaB = deltaB3.xy / width;
float lenA = length(deltaA);
float lenB = length(deltaB);
vec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0);
vec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0);
vec2 perpA = vec2(-dirA.y, dirA.x);
vec2 perpB = vec2(-dirB.y, dirB.x);
// tangent of the corner
vec2 tangent = dirA + dirB;
tangent = length(tangent) > 0. ? normalize(tangent) : perpA;
// direction of the corner
vec2 miterVec = vec2(-tangent.y, tangent.x);
// direction of the segment
vec2 dir = isEnd ? dirA : dirB;
// direction of the extrusion
vec2 perp = isEnd ? perpA : perpB;
// length of the segment
float L = isEnd ? lenA : lenB;
// A = angle of the corner
float sinHalfA = abs(dot(miterVec, perp));
float cosHalfA = abs(dot(dirA, miterVec));
// -1: right, 1: left
float turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x);
// relative position to the corner:
// -1: inside (smaller side of the angle)
// 0: center
// 1: outside (bigger side of the angle)
float cornerPosition = sideOfPath * turnDirection;
float miterSize = 1.0 / max(sinHalfA, EPSILON);
// trim if inside corner extends further than the line segment
miterSize = mix(
min(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)),
miterSize,
step(0.0, cornerPosition)
);
vec2 offsetVec = mix(miterVec * miterSize, perp, step(0.5, cornerPosition))
* (sideOfPath + isJoint * turnDirection);
// special treatment for start cap and end cap
bool isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0));
bool isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0));
bool isCap = isStartCap || isEndCap;
// extend out a triangle to envelope the round cap
if (isCap) {
offsetVec = mix(perp * sideOfPath, dir * capType * 4.0 * flipIfTrue(isStartCap), isJoint);
vJointType = capType;
} else {
vJointType = jointType;
}
// Generate variables for fragment shader
vPathLength = L;
vCornerOffset = offsetVec;
vMiterLength = dot(vCornerOffset, miterVec * turnDirection);
vMiterLength = isCap ? isJoint : vMiterLength;
vec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd);
vPathPosition = vec2(
dot(offsetFromStartOfPath, perp),
dot(offsetFromStartOfPath, dir)
);
geometry.uv = vPathPosition;
float isValid = step(instanceTypes, 3.5);
vec3 offset = vec3(offsetVec * width * isValid, 0.0);
if (needsRotation) {
offset = rotationMatrix * offset;
}
return offset;
bool isEnd = positions.x > 0.0;
float sideOfPath = positions.y;
float isJoint = float(sideOfPath == 0.0);
vec3 deltaA3 = (currPoint - prevPoint);
vec3 deltaB3 = (nextPoint - currPoint);
mat3 rotationMatrix;
bool needsRotation = !billboard && project_needs_rotation(currPoint, rotationMatrix);
if (needsRotation) {
deltaA3 = deltaA3 * rotationMatrix;
deltaB3 = deltaB3 * rotationMatrix;
}
// In clipspace extrusion, if a line extends behind the camera, clip it to avoid visual artifacts
vec2 deltaA = deltaA3.xy / width;
vec2 deltaB = deltaB3.xy / width;
float lenA = length(deltaA);
float lenB = length(deltaB);
vec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0);
vec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0);
vec2 perpA = vec2(-dirA.y, dirA.x);
vec2 perpB = vec2(-dirB.y, dirB.x);
vec2 tangent = dirA + dirB;
tangent = length(tangent) > 0. ? normalize(tangent) : perpA;
vec2 miterVec = vec2(-tangent.y, tangent.x);
vec2 dir = isEnd ? dirA : dirB;
vec2 perp = isEnd ? perpA : perpB;
float L = isEnd ? lenA : lenB;
float sinHalfA = abs(dot(miterVec, perp));
float cosHalfA = abs(dot(dirA, miterVec));
float turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x);
float cornerPosition = sideOfPath * turnDirection;
float miterSize = 1.0 / max(sinHalfA, EPSILON);
miterSize = mix(
min(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)),
miterSize,
step(0.0, cornerPosition)
);
vec2 offsetVec = mix(miterVec * miterSize, perp, step(0.5, cornerPosition))
* (sideOfPath + isJoint * turnDirection);
bool isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0));
bool isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0));
bool isCap = isStartCap || isEndCap;
if (isCap) {
offsetVec = mix(perp * sideOfPath, dir * capType * 4.0 * flipIfTrue(isStartCap), isJoint);
vJointType = capType;
} else {
vJointType = jointType;
}
vPathLength = L;
vCornerOffset = offsetVec;
vMiterLength = dot(vCornerOffset, miterVec * turnDirection);
vMiterLength = isCap ? isJoint : vMiterLength;
vec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd);
vPathPosition = vec2(
dot(offsetFromStartOfPath, perp),
dot(offsetFromStartOfPath, dir)
);
geometry.uv = vPathPosition;
float isValid = step(instanceTypes, 3.5);
vec3 offset = vec3(offsetVec * width * isValid, 0.0);
if (needsRotation) {
offset = rotationMatrix * offset;
}
return offset;
}
void clipLine(inout vec4 position, vec4 refPosition) {
if (position.w < EPSILON) {
float r = (EPSILON - refPosition.w) / (position.w - refPosition.w);
position = refPosition + (position - refPosition) * r;
}
if (position.w < EPSILON) {
float r = (EPSILON - refPosition.w) / (position.w - refPosition.w);
position = refPosition + (position - refPosition) * r;
}
}
void main() {
geometry.pickingColor = instancePickingColors;
vColor = vec4(instanceColors.rgb, instanceColors.a * opacity);
float isEnd = positions.x;
vec3 prevPosition = mix(instanceLeftPositions, instanceStartPositions, isEnd);
vec3 prevPosition64Low = mix(instanceLeftPositions64Low, instanceStartPositions64Low, isEnd);
vec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd);
vec3 currPosition64Low = mix(instanceStartPositions64Low, instanceEndPositions64Low, isEnd);
vec3 nextPosition = mix(instanceEndPositions, instanceRightPositions, isEnd);
vec3 nextPosition64Low = mix(instanceEndPositions64Low, instanceRightPositions64Low, isEnd);
geometry.worldPosition = currPosition;
vec2 widthPixels = vec2(clamp(
project_size_to_pixel(instanceStrokeWidths * widthScale, widthUnits),
widthMinPixels, widthMaxPixels) / 2.0);
vec3 width;
if (billboard) {
// Extrude in clipspace
vec4 prevPositionScreen = project_position_to_clipspace(prevPosition, prevPosition64Low, ZERO_OFFSET);
vec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position);
vec4 nextPositionScreen = project_position_to_clipspace(nextPosition, nextPosition64Low, ZERO_OFFSET);
clipLine(prevPositionScreen, currPositionScreen);
clipLine(nextPositionScreen, currPositionScreen);
clipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd));
width = vec3(widthPixels, 0.0);
DECKGL_FILTER_SIZE(width, geometry);
vec3 offset = getLineJoinOffset(
prevPositionScreen.xyz / prevPositionScreen.w,
currPositionScreen.xyz / currPositionScreen.w,
nextPositionScreen.xyz / nextPositionScreen.w,
project_pixel_size_to_clipspace(width.xy)
);
DECKGL_FILTER_GL_POSITION(currPositionScreen, geometry);
gl_Position = vec4(currPositionScreen.xyz + offset * currPositionScreen.w, currPositionScreen.w);
} else {
// Extrude in commonspace
prevPosition = project_position(prevPosition, prevPosition64Low);
currPosition = project_position(currPosition, currPosition64Low);
nextPosition = project_position(nextPosition, nextPosition64Low);
width = vec3(project_pixel_size(widthPixels), 0.0);
DECKGL_FILTER_SIZE(width, geometry);
vec3 offset = getLineJoinOffset(prevPosition, currPosition, nextPosition, width.xy);
geometry.position = vec4(currPosition + offset, 1.0);
gl_Position = project_common_position_to_clipspace(geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
}
DECKGL_FILTER_COLOR(vColor, geometry);
geometry.pickingColor = instancePickingColors;
vColor = vec4(instanceColors.rgb, instanceColors.a * opacity);
float isEnd = positions.x;
vec3 prevPosition = mix(instanceLeftPositions, instanceStartPositions, isEnd);
vec3 prevPosition64Low = mix(instanceLeftPositions64Low, instanceStartPositions64Low, isEnd);
vec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd);
vec3 currPosition64Low = mix(instanceStartPositions64Low, instanceEndPositions64Low, isEnd);
vec3 nextPosition = mix(instanceEndPositions, instanceRightPositions, isEnd);
vec3 nextPosition64Low = mix(instanceEndPositions64Low, instanceRightPositions64Low, isEnd);
geometry.worldPosition = currPosition;
vec2 widthPixels = vec2(clamp(
project_size_to_pixel(instanceStrokeWidths * widthScale, widthUnits),
widthMinPixels, widthMaxPixels) / 2.0);
vec3 width;
if (billboard) {
vec4 prevPositionScreen = project_position_to_clipspace(prevPosition, prevPosition64Low, ZERO_OFFSET);
vec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position);
vec4 nextPositionScreen = project_position_to_clipspace(nextPosition, nextPosition64Low, ZERO_OFFSET);
clipLine(prevPositionScreen, currPositionScreen);
clipLine(nextPositionScreen, currPositionScreen);
clipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd));
width = vec3(widthPixels, 0.0);
DECKGL_FILTER_SIZE(width, geometry);
vec3 offset = getLineJoinOffset(
prevPositionScreen.xyz / prevPositionScreen.w,
currPositionScreen.xyz / currPositionScreen.w,
nextPositionScreen.xyz / nextPositionScreen.w,
project_pixel_size_to_clipspace(width.xy)
);
DECKGL_FILTER_GL_POSITION(currPositionScreen, geometry);
gl_Position = vec4(currPositionScreen.xyz + offset * currPositionScreen.w, currPositionScreen.w);
} else {
prevPosition = project_position(prevPosition, prevPosition64Low);
currPosition = project_position(currPosition, currPosition64Low);
nextPosition = project_position(nextPosition, nextPosition64Low);
width = vec3(project_pixel_size(widthPixels), 0.0);
DECKGL_FILTER_SIZE(width, geometry);
vec3 offset = getLineJoinOffset(prevPosition, currPosition, nextPosition, width.xy);
geometry.position = vec4(currPosition + offset, 1.0);
gl_Position = project_common_position_to_clipspace(geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
}
DECKGL_FILTER_COLOR(vColor, geometry);
}
`;

@@ -23,3 +23,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

import { Model } from '@luma.gl/engine';
import { GL } from '@luma.gl/constants';
import PathTesselator from "./path-tesselator.js";

@@ -72,3 +71,3 @@ import vs from "./path-layer-vertex.glsl.js";

vertexOffset: 1,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -97,3 +96,3 @@ transition: ATTRIBUTE_TRANSITION,

size: 1,
type: GL.UNSIGNED_BYTE,
type: 'uint8',
// eslint-disable-next-line @typescript-eslint/unbound-method

@@ -111,4 +110,3 @@ update: this.calculateSegmentTypes,

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
accessor: 'getColor',

@@ -120,3 +118,3 @@ transition: ATTRIBUTE_TRANSITION,

size: 4,
type: GL.UNSIGNED_BYTE,
type: 'uint8',
accessor: (object, { index, target: value }) => this.encodePickingColor(object && object.__source ? object.__source.index : index, value)

@@ -123,0 +121,0 @@ }

@@ -23,22 +23,15 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

#define SHADER_NAME point-cloud-layer-fragment-shader
precision highp float;
in vec4 vColor;
in vec2 unitPosition;
out vec4 fragColor;
void main(void) {
geometry.uv = unitPosition;
float distToCenter = length(unitPosition);
if (distToCenter > 1.0) {
discard;
}
fragColor = vColor;
DECKGL_FILTER_COLOR(fragColor, geometry);
geometry.uv = unitPosition;
float distToCenter = length(unitPosition);
if (distToCenter > 1.0) {
discard;
}
fragColor = vColor;
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;

@@ -23,3 +23,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

#define SHADER_NAME point-cloud-layer-vertex-shader
in vec3 positions;

@@ -31,34 +30,22 @@ in vec3 instanceNormals;

in vec3 instancePickingColors;
uniform float opacity;
uniform float radiusPixels;
uniform int sizeUnits;
out vec4 vColor;
out vec2 unitPosition;
void main(void) {
geometry.worldPosition = instancePositions;
geometry.normal = project_normal(instanceNormals);
// position on the containing square in [-1, 1] space
unitPosition = positions.xy;
geometry.uv = unitPosition;
geometry.pickingColor = instancePickingColors;
// Find the center of the point and add the current vertex
vec3 offset = vec3(positions.xy * project_size_to_pixel(radiusPixels, sizeUnits), 0.0);
DECKGL_FILTER_SIZE(offset, geometry);
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.), geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
// Apply lighting
vec3 lightColor = lighting_getLightColor(instanceColors.rgb, project_uCameraPosition, geometry.position.xyz, geometry.normal);
// Apply opacity to instance color, or return instance picking color
vColor = vec4(lightColor, instanceColors.a * opacity);
DECKGL_FILTER_COLOR(vColor, geometry);
geometry.worldPosition = instancePositions;
geometry.normal = project_normal(instanceNormals);
unitPosition = positions.xy;
geometry.uv = unitPosition;
geometry.pickingColor = instancePickingColors;
vec3 offset = vec3(positions.xy * project_size_to_pixel(radiusPixels, sizeUnits), 0.0);
DECKGL_FILTER_SIZE(offset, geometry);
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.), geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
vec3 lightColor = lighting_getLightColor(instanceColors.rgb, project_uCameraPosition, geometry.position.xyz, geometry.normal);
vColor = vec4(lightColor, instanceColors.a * opacity);
DECKGL_FILTER_COLOR(vColor, geometry);
}
`;

@@ -22,3 +22,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

import { Model, Geometry } from '@luma.gl/engine';
import { GL } from '@luma.gl/constants';
import vs from "./point-cloud-layer-vertex.glsl.js";

@@ -66,3 +65,3 @@ import fs from "./point-cloud-layer-fragment.glsl.js";

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -80,4 +79,3 @@ transition: true,

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
transition: true,

@@ -84,0 +82,0 @@ accessor: 'getColor',

@@ -23,9 +23,6 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

#define SHADER_NAME scatterplot-layer-fragment-shader
precision highp float;
uniform bool filled;
uniform float stroked;
uniform bool antialiasing;
in vec4 vFillColor;

@@ -36,39 +33,32 @@ in vec4 vLineColor;

in float outerRadiusPixels;
out vec4 fragColor;
void main(void) {
geometry.uv = unitPosition;
float distToCenter = length(unitPosition) * outerRadiusPixels;
float inCircle = antialiasing ?
smoothedge(distToCenter, outerRadiusPixels) :
step(distToCenter, outerRadiusPixels);
if (inCircle == 0.0) {
discard;
}
if (stroked > 0.5) {
float isLine = antialiasing ?
smoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) :
step(innerUnitRadius * outerRadiusPixels, distToCenter);
if (filled) {
fragColor = mix(vFillColor, vLineColor, isLine);
} else {
if (isLine == 0.0) {
discard;
}
fragColor = vec4(vLineColor.rgb, vLineColor.a * isLine);
}
} else if (!filled) {
discard;
} else {
fragColor = vFillColor;
}
fragColor.a *= inCircle;
DECKGL_FILTER_COLOR(fragColor, geometry);
geometry.uv = unitPosition;
float distToCenter = length(unitPosition) * outerRadiusPixels;
float inCircle = antialiasing ?
smoothedge(distToCenter, outerRadiusPixels) :
step(distToCenter, outerRadiusPixels);
if (inCircle == 0.0) {
discard;
}
if (stroked > 0.5) {
float isLine = antialiasing ?
smoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) :
step(innerUnitRadius * outerRadiusPixels, distToCenter);
if (filled) {
fragColor = mix(vFillColor, vLineColor, isLine);
} else {
if (isLine == 0.0) {
discard;
}
fragColor = vec4(vLineColor.rgb, vLineColor.a * isLine);
}
} else if (!filled) {
discard;
} else {
fragColor = vFillColor;
}
fragColor.a *= inCircle;
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;

@@ -23,5 +23,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

#define SHADER_NAME scatterplot-layer-vertex-shader
in vec3 positions;
in vec3 instancePositions;

@@ -34,3 +32,2 @@ in vec3 instancePositions64Low;

in vec3 instancePickingColors;
uniform float opacity;

@@ -49,3 +46,2 @@ uniform float radiusScale;

uniform int lineWidthUnits;
out vec4 vFillColor;

@@ -56,51 +52,35 @@ out vec4 vLineColor;

out float outerRadiusPixels;
void main(void) {
geometry.worldPosition = instancePositions;
// Multiply out radius and clamp to limits
outerRadiusPixels = clamp(
project_size_to_pixel(radiusScale * instanceRadius, radiusUnits),
radiusMinPixels, radiusMaxPixels
);
// Multiply out line width and clamp to limits
float lineWidthPixels = clamp(
project_size_to_pixel(lineWidthScale * instanceLineWidths, lineWidthUnits),
lineWidthMinPixels, lineWidthMaxPixels
);
// outer radius needs to offset by half stroke width
outerRadiusPixels += stroked * lineWidthPixels / 2.0;
// Expand geometry to accomodate edge smoothing
float edgePadding = antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0;
// position on the containing square in [-1, 1] space
unitPosition = edgePadding * positions.xy;
geometry.uv = unitPosition;
geometry.pickingColor = instancePickingColors;
innerUnitRadius = 1.0 - stroked * lineWidthPixels / outerRadiusPixels;
if (billboard) {
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
vec3 offset = edgePadding * positions * outerRadiusPixels;
DECKGL_FILTER_SIZE(offset, geometry);
gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
} else {
vec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels);
DECKGL_FILTER_SIZE(offset, geometry);
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
}
// Apply opacity to instance color, or return instance picking color
vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * opacity);
DECKGL_FILTER_COLOR(vFillColor, geometry);
vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * opacity);
DECKGL_FILTER_COLOR(vLineColor, geometry);
geometry.worldPosition = instancePositions;
outerRadiusPixels = clamp(
project_size_to_pixel(radiusScale * instanceRadius, radiusUnits),
radiusMinPixels, radiusMaxPixels
);
float lineWidthPixels = clamp(
project_size_to_pixel(lineWidthScale * instanceLineWidths, lineWidthUnits),
lineWidthMinPixels, lineWidthMaxPixels
);
outerRadiusPixels += stroked * lineWidthPixels / 2.0;
float edgePadding = antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0;
unitPosition = edgePadding * positions.xy;
geometry.uv = unitPosition;
geometry.pickingColor = instancePickingColors;
innerUnitRadius = 1.0 - stroked * lineWidthPixels / outerRadiusPixels;
if (billboard) {
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
vec3 offset = edgePadding * positions * outerRadiusPixels;
DECKGL_FILTER_SIZE(offset, geometry);
gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
} else {
vec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels);
DECKGL_FILTER_SIZE(offset, geometry);
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
}
vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * opacity);
DECKGL_FILTER_COLOR(vFillColor, geometry);
vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * opacity);
DECKGL_FILTER_COLOR(vLineColor, geometry);
}
`;

@@ -23,3 +23,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

import { Model } from '@luma.gl/engine';
import { GL } from '@luma.gl/constants';
import vs from "./scatterplot-layer-vertex.glsl.js";

@@ -62,3 +61,3 @@ import fs from "./scatterplot-layer-fragment.glsl.js";

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -77,4 +76,3 @@ transition: true,

transition: true,
normalized: true,
type: GL.UNSIGNED_BYTE,
type: 'unorm8',
accessor: 'getFillColor',

@@ -86,4 +84,3 @@ defaultValue: [0, 0, 0, 255]

transition: true,
normalized: true,
type: GL.UNSIGNED_BYTE,
type: 'unorm8',
accessor: 'getLineColor',

@@ -90,0 +87,0 @@ defaultValue: [0, 0, 0, 255]

@@ -23,14 +23,9 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

#define SHADER_NAME solid-polygon-layer-fragment-shader
precision highp float;
in vec4 vColor;
out vec4 fragColor;
void main(void) {
fragColor = vColor;
DECKGL_FILTER_COLOR(fragColor, geometry);
fragColor = vColor;
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;

@@ -21,3 +21,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

export default `\
uniform bool extruded;

@@ -27,49 +26,40 @@ uniform bool isWireframe;

uniform float opacity;
out vec4 vColor;
struct PolygonProps {
vec4 fillColors;
vec4 lineColors;
vec3 positions;
vec3 positions64Low;
vec3 pickingColors;
vec3 normal;
float elevations;
vec4 fillColors;
vec4 lineColors;
vec3 positions;
vec3 positions64Low;
vec3 pickingColors;
vec3 normal;
float elevations;
};
vec3 project_offset_normal(vec3 vector) {
if (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) {
// normals generated by the polygon tesselator are in lnglat offsets instead of meters
return normalize(vector * project_uCommonUnitsPerWorldUnit);
}
return project_normal(vector);
if (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||
project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) {
return normalize(vector * project_uCommonUnitsPerWorldUnit);
}
return project_normal(vector);
}
void calculatePosition(PolygonProps props) {
vec3 pos = props.positions;
vec3 pos64Low = props.positions64Low;
vec3 normal;
vec4 colors = isWireframe ? props.lineColors : props.fillColors;
geometry.worldPosition = props.positions;
geometry.pickingColor = props.pickingColors;
if (extruded) {
pos.z += props.elevations * elevationScale;
}
gl_Position = project_position_to_clipspace(pos, pos64Low, vec3(0.), geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
if (extruded) {
geometry.normal = props.normal;
vec3 lightColor = lighting_getLightColor(colors.rgb, project_uCameraPosition, geometry.position.xyz, geometry.normal);
vColor = vec4(lightColor, colors.a * opacity);
} else {
vColor = vec4(colors.rgb, colors.a * opacity);
}
DECKGL_FILTER_COLOR(vColor, geometry);
vec3 pos = props.positions;
vec3 pos64Low = props.positions64Low;
vec3 normal;
vec4 colors = isWireframe ? props.lineColors : props.fillColors;
geometry.worldPosition = props.positions;
geometry.pickingColor = props.pickingColors;
if (extruded) {
pos.z += props.elevations * elevationScale;
}
gl_Position = project_position_to_clipspace(pos, pos64Low, vec3(0.), geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
if (extruded) {
geometry.normal = props.normal;
vec3 lightColor = lighting_getLightColor(colors.rgb, project_uCameraPosition, geometry.position.xyz, geometry.normal);
vColor = vec4(lightColor, colors.a * opacity);
} else {
vColor = vec4(colors.rgb, colors.a * opacity);
}
DECKGL_FILTER_COLOR(vColor, geometry);
}
`;

@@ -24,5 +24,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

#define SHADER_NAME solid-polygon-layer-vertex-shader-side
in vec2 positions;
in vec3 instancePositions;

@@ -37,46 +35,37 @@ in vec3 instanceNextPositions;

in float instanceVertexValid;
${main}
void main(void) {
if(instanceVertexValid < 0.5){
gl_Position = vec4(0.);
return;
}
PolygonProps props;
vec3 pos;
vec3 pos64Low;
vec3 nextPos;
vec3 nextPos64Low;
#if RING_WINDING_ORDER_CW == 1
pos = instancePositions;
pos64Low = instancePositions64Low;
nextPos = instanceNextPositions;
nextPos64Low = instanceNextPositions64Low;
#else
pos = instanceNextPositions;
pos64Low = instanceNextPositions64Low;
nextPos = instancePositions;
nextPos64Low = instancePositions64Low;
#endif
props.positions = mix(pos, nextPos, positions.x);
props.positions64Low = mix(pos64Low, nextPos64Low, positions.x);
vec3 normal = vec3(
pos.y - nextPos.y + (pos64Low.y - nextPos64Low.y),
nextPos.x - pos.x + (nextPos64Low.x - pos64Low.x),
0.0);
props.normal = project_offset_normal(normal);
props.elevations = instanceElevations * positions.y;
props.fillColors = instanceFillColors;
props.lineColors = instanceLineColors;
props.pickingColors = instancePickingColors;
calculatePosition(props);
if(instanceVertexValid < 0.5){
gl_Position = vec4(0.);
return;
}
PolygonProps props;
vec3 pos;
vec3 pos64Low;
vec3 nextPos;
vec3 nextPos64Low;
#if RING_WINDING_ORDER_CW == 1
pos = instancePositions;
pos64Low = instancePositions64Low;
nextPos = instanceNextPositions;
nextPos64Low = instanceNextPositions64Low;
#else
pos = instanceNextPositions;
pos64Low = instanceNextPositions64Low;
nextPos = instancePositions;
nextPos64Low = instancePositions64Low;
#endif
props.positions = mix(pos, nextPos, positions.x);
props.positions64Low = mix(pos64Low, nextPos64Low, positions.x);
vec3 normal = vec3(
pos.y - nextPos.y + (pos64Low.y - nextPos64Low.y),
nextPos.x - pos.x + (nextPos64Low.x - pos64Low.x),
0.0);
props.normal = project_offset_normal(normal);
props.elevations = instanceElevations * positions.y;
props.fillColors = instanceFillColors;
props.lineColors = instanceLineColors;
props.pickingColors = instancePickingColors;
calculatePosition(props);
}
`;

@@ -24,3 +24,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

#define SHADER_NAME solid-polygon-layer-vertex-shader
in vec3 vertexPositions;

@@ -32,18 +31,14 @@ in vec3 vertexPositions64Low;

in vec3 pickingColors;
${main}
void main(void) {
PolygonProps props;
props.positions = vertexPositions;
props.positions64Low = vertexPositions64Low;
props.elevations = elevations;
props.fillColors = fillColors;
props.lineColors = lineColors;
props.pickingColors = pickingColors;
props.normal = project_normal(vec3(0.0, 0.0, 1.0));
calculatePosition(props);
PolygonProps props;
props.positions = vertexPositions;
props.positions64Low = vertexPositions64Low;
props.elevations = elevations;
props.fillColors = fillColors;
props.lineColors = lineColors;
props.pickingColors = pickingColors;
props.normal = project_normal(vec3(0.0, 0.0, 1.0));
calculatePosition(props);
}
`;

@@ -22,3 +22,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

import { Model, Geometry } from '@luma.gl/engine';
import { GL } from '@luma.gl/constants';
// Polygon geometry generation is managed by the polygon tesselator

@@ -91,3 +90,3 @@ import PolygonTesselator from "./polygon-tesselator.js";

fp64: this.use64bitPositions(),
IndexType: !device || device.features.has('index-uint32-webgl1') ? Uint32Array : Uint16Array
IndexType: Uint32Array
})

@@ -109,3 +108,3 @@ });

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -130,3 +129,3 @@ transition: ATTRIBUTE_TRANSITION,

size: 1,
type: GL.UNSIGNED_SHORT,
type: 'uint16',
divisor: 1,

@@ -149,4 +148,3 @@ // eslint-disable-next-line @typescript-eslint/unbound-method

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
transition: ATTRIBUTE_TRANSITION,

@@ -163,4 +161,3 @@ accessor: 'getFillColor',

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
transition: ATTRIBUTE_TRANSITION,

@@ -177,3 +174,3 @@ accessor: 'getLineColor',

size: 4,
type: GL.UNSIGNED_BYTE,
type: 'uint8',
accessor: (object, { index, target: value }) => this.encodePickingColor(object && object.__source ? object.__source.index : index, value),

@@ -334,2 +331,12 @@ shaderAttributes: {

});
const geometry = new Geometry({
topology: 'line-strip',
attributes: {
// top right - top left - bottom left - bottom right
positions: {
size: 2,
value: new Float32Array([1, 0, 0, 0, 0, 1, 1, 1])
}
}
});
wireframeModel = new Model(this.context.device, {

@@ -339,15 +346,7 @@ ...this.getShaders('side'),

bufferLayout,
topology: 'line-strip',
uniforms: {
isWireframe: true
},
geometry: new Geometry({
topology: 'line-strip',
attributes: {
// top right - top left - bottom left - bottom right
positions: {
size: 2,
value: new Float32Array([1, 0, 0, 0, 0, 1, 1, 1])
}
}
}),
// geometry, // TODO(v9) investigate why `setGeometry()` is needed
isInstanced: 1,

@@ -358,2 +357,3 @@ userData: {

});
wireframeModel.setGeometry(geometry);
}

@@ -360,0 +360,0 @@ return {

@@ -23,5 +23,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

#define SHADER_NAME multi-icon-layer-fragment-shader
precision highp float;
uniform float opacity;

@@ -35,41 +33,29 @@ uniform sampler2D iconsTexture;

uniform vec4 outlineColor;
in vec4 vColor;
in vec2 vTextureCoords;
in vec2 uv;
out vec4 fragColor;
void main(void) {
geometry.uv = uv;
if (!bool(picking.isActive)) {
float alpha = texture(iconsTexture, vTextureCoords).a;
vec4 color = vColor;
// if enable sdf (signed distance fields)
if (sdf) {
float distance = alpha;
alpha = smoothstep(sdfBuffer - gamma, sdfBuffer + gamma, distance);
if (outlineBuffer > 0.0) {
float inFill = alpha;
float inBorder = smoothstep(outlineBuffer - gamma, outlineBuffer + gamma, distance);
color = mix(outlineColor, vColor, inFill);
alpha = inBorder;
}
}
// Take the global opacity and the alpha from color into account for the alpha component
float a = alpha * color.a;
if (a < alphaCutoff) {
discard;
}
fragColor = vec4(color.rgb, a * opacity);
}
DECKGL_FILTER_COLOR(fragColor, geometry);
geometry.uv = uv;
if (!bool(picking.isActive)) {
float alpha = texture(iconsTexture, vTextureCoords).a;
vec4 color = vColor;
if (sdf) {
float distance = alpha;
alpha = smoothstep(sdfBuffer - gamma, sdfBuffer + gamma, distance);
if (outlineBuffer > 0.0) {
float inFill = alpha;
float inBorder = smoothstep(outlineBuffer - gamma, outlineBuffer + gamma, distance);
color = mix(outlineColor, vColor, inFill);
alpha = inBorder;
}
}
float a = alpha * color.a;
if (a < alphaCutoff) {
discard;
}
fragColor = vec4(color.rgb, a * opacity);
}
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;

@@ -20,3 +20,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

// THE SOFTWARE.
import { GL } from '@luma.gl/constants';
import { log } from '@deck.gl/core';

@@ -50,3 +49,3 @@ import IconLayer from "../../icon-layer/icon-layer.js";

instancePickingColors: {
type: GL.UNSIGNED_BYTE,
type: 'uint8',
size: 3,

@@ -53,0 +52,0 @@ accessor: (object, { index, target: value }) => this.encodePickingColor(index, value)

export default `\
#version 300 es
#define SHADER_NAME text-background-layer-fragment-shader
precision highp float;
uniform bool stroked;
in vec4 vFillColor;

@@ -14,22 +11,18 @@ in vec4 vLineColor;

in vec2 dimensions;
out vec4 fragColor;
void main(void) {
geometry.uv = uv;
vec2 pixelPosition = uv * dimensions;
if (stroked) {
float distToEdge = min(
min(pixelPosition.x, dimensions.x - pixelPosition.x),
min(pixelPosition.y, dimensions.y - pixelPosition.y)
);
float isBorder = smoothedge(distToEdge, vLineWidth);
fragColor = mix(vFillColor, vLineColor, isBorder);
} else {
fragColor = vFillColor;
}
DECKGL_FILTER_COLOR(fragColor, geometry);
geometry.uv = uv;
vec2 pixelPosition = uv * dimensions;
if (stroked) {
float distToEdge = min(
min(pixelPosition.x, dimensions.x - pixelPosition.x),
min(pixelPosition.y, dimensions.y - pixelPosition.y)
);
float isBorder = smoothedge(distToEdge, vLineWidth);
fragColor = mix(vFillColor, vLineColor, isBorder);
} else {
fragColor = vFillColor;
}
DECKGL_FILTER_COLOR(fragColor, geometry);
}
`;
export default `\
#version 300 es
#define SHADER_NAME text-background-layer-vertex-shader
in vec2 positions;
in vec3 instancePositions;

@@ -17,3 +15,2 @@ in vec3 instancePositions64Low;

in vec3 instancePickingColors;
uniform bool billboard;

@@ -26,3 +23,2 @@ uniform float opacity;

uniform int sizeUnits;
out vec4 vFillColor;

@@ -33,52 +29,41 @@ out vec4 vLineColor;

out vec2 dimensions;
vec2 rotate_by_angle(vec2 vertex, float angle) {
float angle_radian = radians(angle);
float cos_angle = cos(angle_radian);
float sin_angle = sin(angle_radian);
mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);
return rotationMatrix * vertex;
float angle_radian = radians(angle);
float cos_angle = cos(angle_radian);
float sin_angle = sin(angle_radian);
mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);
return rotationMatrix * vertex;
}
void main(void) {
geometry.worldPosition = instancePositions;
geometry.uv = positions;
geometry.pickingColor = instancePickingColors;
uv = positions;
vLineWidth = instanceLineWidths;
// convert size in meters to pixels, then scaled and clamp
// project meters to pixels and clamp to limits
float sizePixels = clamp(
project_size_to_pixel(instanceSizes * sizeScale, sizeUnits),
sizeMinPixels, sizeMaxPixels
);
dimensions = instanceRects.zw * sizePixels + padding.xy + padding.zw;
vec2 pixelOffset = (positions * instanceRects.zw + instanceRects.xy) * sizePixels + mix(-padding.xy, padding.zw, positions);
pixelOffset = rotate_by_angle(pixelOffset, instanceAngles);
pixelOffset += instancePixelOffsets;
pixelOffset.y *= -1.0;
if (billboard) {
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
vec3 offset = vec3(pixelOffset, 0.0);
DECKGL_FILTER_SIZE(offset, geometry);
gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
} else {
vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);
DECKGL_FILTER_SIZE(offset_common, geometry);
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
}
// Apply opacity to instance color, or return instance picking color
vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * opacity);
DECKGL_FILTER_COLOR(vFillColor, geometry);
vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * opacity);
DECKGL_FILTER_COLOR(vLineColor, geometry);
geometry.worldPosition = instancePositions;
geometry.uv = positions;
geometry.pickingColor = instancePickingColors;
uv = positions;
vLineWidth = instanceLineWidths;
float sizePixels = clamp(
project_size_to_pixel(instanceSizes * sizeScale, sizeUnits),
sizeMinPixels, sizeMaxPixels
);
dimensions = instanceRects.zw * sizePixels + padding.xy + padding.zw;
vec2 pixelOffset = (positions * instanceRects.zw + instanceRects.xy) * sizePixels + mix(-padding.xy, padding.zw, positions);
pixelOffset = rotate_by_angle(pixelOffset, instanceAngles);
pixelOffset += instancePixelOffsets;
pixelOffset.y *= -1.0;
if (billboard) {
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
vec3 offset = vec3(pixelOffset, 0.0);
DECKGL_FILTER_SIZE(offset, geometry);
gl_Position.xy += project_pixel_size_to_clipspace(offset.xy);
} else {
vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);
DECKGL_FILTER_SIZE(offset_common, geometry);
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
}
vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * opacity);
DECKGL_FILTER_COLOR(vFillColor, geometry);
vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * opacity);
DECKGL_FILTER_COLOR(vLineColor, geometry);
}
`;
import { Layer, project32, picking, UNIT } from '@deck.gl/core';
import { Geometry } from '@luma.gl/engine';
import { Model } from '@luma.gl/engine';
import { GL } from '@luma.gl/constants';
import vs from "./text-background-layer-vertex.glsl.js";

@@ -33,3 +32,3 @@ import fs from "./text-background-layer-fragment.glsl.js";

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -62,4 +61,3 @@ transition: true,

transition: true,
normalized: true,
type: GL.UNSIGNED_BYTE,
type: 'unorm8',
accessor: 'getFillColor',

@@ -71,4 +69,3 @@ defaultValue: [0, 0, 0, 255]

transition: true,
normalized: true,
type: GL.UNSIGNED_BYTE,
type: 'unorm8',
accessor: 'getLineColor',

@@ -75,0 +72,0 @@ defaultValue: [0, 0, 0, 255]

@@ -6,3 +6,3 @@ {

"type": "module",
"version": "9.0.0-beta.5",
"version": "9.0.0-beta.6",
"publishConfig": {

@@ -44,6 +44,6 @@ "access": "public"

"@loaders.gl/schema": "^4.1.0",
"@luma.gl/constants": "9.0.0-beta.4",
"@luma.gl/core": "9.0.0-beta.4",
"@luma.gl/engine": "9.0.0-beta.4",
"@luma.gl/shadertools": "9.0.0-beta.4",
"@luma.gl/constants": "9.0.0-beta.6",
"@luma.gl/core": "9.0.0-beta.6",
"@luma.gl/engine": "9.0.0-beta.6",
"@luma.gl/shadertools": "9.0.0-beta.6",
"@mapbox/tiny-sdf": "^2.0.5",

@@ -58,7 +58,7 @@ "@math.gl/core": "^4.0.0",

"@loaders.gl/core": "^4.1.0",
"@luma.gl/core": "9.0.0-beta.4",
"@luma.gl/engine": "9.0.0-beta.4",
"@luma.gl/shadertools": "9.0.0-beta.4"
"@luma.gl/core": "9.0.0-beta.6",
"@luma.gl/engine": "9.0.0-beta.6",
"@luma.gl/shadertools": "9.0.0-beta.6"
},
"gitHead": "02588aba7cbf25d48cec20b30a686bba9be32bff"
"gitHead": "373729308eb3fdec4b7c8b5842ddeff4f2d70338"
}

@@ -39,3 +39,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

import {Model} from '@luma.gl/engine';
import {GL} from '@luma.gl/constants';

@@ -184,3 +183,3 @@ import vs from './arc-layer-vertex.glsl';

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -192,3 +191,3 @@ transition: true,

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -200,4 +199,3 @@ transition: true,

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
transition: true,

@@ -209,4 +207,3 @@ accessor: 'getSourceColor',

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
transition: true,

@@ -213,0 +210,0 @@ accessor: 'getTargetColor',

@@ -38,3 +38,2 @@ // Copyright (c) 2015 Uber Technologies, Inc.

import type {SamplerProps, Texture} from '@luma.gl/core';
import {GL} from '@luma.gl/constants';
import {lngLatToWorld} from '@math.gl/web-mercator';

@@ -151,3 +150,3 @@

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -154,0 +153,0 @@ update: attribute => (attribute.value = this.state.mesh.positions),

import {log, BinaryAttribute} from '@deck.gl/core';
import {uid} from '@luma.gl/core';
import {Geometry} from '@luma.gl/engine';

@@ -17,7 +16,5 @@

constructor(props: ColumnGeometryProps) {
const {id = uid('column-geometry')} = props;
const {indices, attributes} = tesselateColumn(props);
super({
...props,
id,
indices,

@@ -24,0 +21,0 @@ // @ts-expect-error

@@ -40,3 +40,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

import {Model} from '@luma.gl/engine';
import {GL} from '@luma.gl/constants';
import ColumnGeometry from './column-geometry';

@@ -249,7 +248,6 @@

const {device} = this.context;
const transpileToGLSL100 = device.info.type !== 'webgl2';
const defines: Record<string, any> = {};
const useDerivatives = this.props.flatShading && device.features.has('glsl-derivatives');
if (useDerivatives) {
const {flatShading} = this.props;
if (flatShading) {
defines.FLAT_SHADING = 1;

@@ -261,4 +259,3 @@ }

defines,
transpileToGLSL100,
modules: [project32, useDerivatives ? phongLighting : gouraudLighting, picking]
modules: [project32, flatShading ? phongLighting : gouraudLighting, picking]
});

@@ -277,3 +274,3 @@ }

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -290,4 +287,3 @@ transition: true,

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
transition: true,

@@ -299,4 +295,3 @@ accessor: 'getFillColor',

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
transition: true,

@@ -303,0 +298,0 @@ accessor: 'getLineColor',

@@ -23,3 +23,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

import {Model, Geometry} from '@luma.gl/engine';
import {GL} from '@luma.gl/constants';

@@ -169,3 +168,3 @@ import vs from './icon-layer-vertex.glsl';

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -195,3 +194,3 @@ transition: true,

size: 1,
type: GL.UNSIGNED_BYTE,
type: 'uint8',
accessor: 'getIcon',

@@ -203,4 +202,3 @@ // eslint-disable-next-line @typescript-eslint/unbound-method

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
transition: true,

@@ -207,0 +205,0 @@ accessor: 'getColor',

@@ -37,3 +37,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

import {Model} from '@luma.gl/engine';
import {GL} from '@luma.gl/constants';

@@ -148,3 +147,3 @@ import vs from './line-layer-vertex.glsl';

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -156,3 +155,3 @@ transition: true,

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -164,4 +163,3 @@ transition: true,

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
transition: true,

@@ -168,0 +166,0 @@ accessor: 'getColor',

@@ -24,3 +24,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

import {Model} from '@luma.gl/engine';
import {GL} from '@luma.gl/constants';
import PathTesselator from './path-tesselator';

@@ -175,3 +174,3 @@

vertexOffset: 1,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -200,3 +199,3 @@ transition: ATTRIBUTE_TRANSITION,

size: 1,
type: GL.UNSIGNED_BYTE,
type: 'uint8',
// eslint-disable-next-line @typescript-eslint/unbound-method

@@ -214,4 +213,3 @@ update: this.calculateSegmentTypes,

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
accessor: 'getColor',

@@ -223,3 +221,3 @@ transition: ATTRIBUTE_TRANSITION,

size: 4,
type: GL.UNSIGNED_BYTE,
type: 'uint8',
accessor: (object, {index, target: value}) =>

@@ -226,0 +224,0 @@ this.encodePickingColor(object && object.__source ? object.__source.index : index, value)

@@ -39,3 +39,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

import {Model, Geometry} from '@luma.gl/engine';
import {GL} from '@luma.gl/constants';

@@ -151,3 +150,3 @@ import vs from './point-cloud-layer-vertex.glsl';

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -165,4 +164,3 @@ transition: true,

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
transition: true,

@@ -169,0 +167,0 @@ accessor: 'getColor',

@@ -24,3 +24,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

import {Model} from '@luma.gl/engine';
import {GL} from '@luma.gl/constants';

@@ -197,3 +196,3 @@ import vs from './scatterplot-layer-vertex.glsl';

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -212,4 +211,3 @@ transition: true,

transition: true,
normalized: true,
type: GL.UNSIGNED_BYTE,
type: 'unorm8',
accessor: 'getFillColor',

@@ -221,4 +219,3 @@ defaultValue: [0, 0, 0, 255]

transition: true,
normalized: true,
type: GL.UNSIGNED_BYTE,
type: 'unorm8',
accessor: 'getLineColor',

@@ -225,0 +222,0 @@ defaultValue: [0, 0, 0, 255]

@@ -23,3 +23,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

import {Model, Geometry} from '@luma.gl/engine';
import {GL} from '@luma.gl/constants';

@@ -196,3 +195,3 @@ // Polygon geometry generation is managed by the polygon tesselator

fp64: this.use64bitPositions(),
IndexType: !device || device.features.has('index-uint32-webgl1') ? Uint32Array : Uint16Array
IndexType: Uint32Array
})

@@ -217,3 +216,3 @@ });

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -238,3 +237,3 @@ transition: ATTRIBUTE_TRANSITION,

size: 1,
type: GL.UNSIGNED_SHORT,
type: 'uint16',
divisor: 1,

@@ -257,4 +256,3 @@ // eslint-disable-next-line @typescript-eslint/unbound-method

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
transition: ATTRIBUTE_TRANSITION,

@@ -271,4 +269,3 @@ accessor: 'getFillColor',

size: this.props.colorFormat.length,
type: GL.UNSIGNED_BYTE,
normalized: true,
type: 'unorm8',
transition: ATTRIBUTE_TRANSITION,

@@ -285,3 +282,3 @@ accessor: 'getLineColor',

size: 4,
type: GL.UNSIGNED_BYTE,
type: 'uint8',
accessor: (object, {index, target: value}) =>

@@ -469,2 +466,12 @@ this.encodePickingColor(object && object.__source ? object.__source.index : index, value),

const geometry = new Geometry({
topology: 'line-strip',
attributes: {
// top right - top left - bottom left - bottom right
positions: {
size: 2,
value: new Float32Array([1, 0, 0, 0, 0, 1, 1, 1])
}
}
});
wireframeModel = new Model(this.context.device, {

@@ -474,15 +481,7 @@ ...this.getShaders('side'),

bufferLayout,
topology: 'line-strip',
uniforms: {
isWireframe: true
},
geometry: new Geometry({
topology: 'line-strip',
attributes: {
// top right - top left - bottom left - bottom right
positions: {
size: 2,
value: new Float32Array([1, 0, 0, 0, 0, 1, 1, 1])
}
}
}),
// geometry, // TODO(v9) investigate why `setGeometry()` is needed
isInstanced: 1,

@@ -493,2 +492,3 @@ userData: {

});
wireframeModel.setGeometry(geometry);
}

@@ -495,0 +495,0 @@

@@ -21,3 +21,2 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

import {GL} from '@luma.gl/constants';
import {log} from '@deck.gl/core';

@@ -79,3 +78,3 @@ import IconLayer from '../../icon-layer/icon-layer';

instancePickingColors: {
type: GL.UNSIGNED_BYTE,
type: 'uint8',
size: 3,

@@ -82,0 +81,0 @@ accessor: (object, {index, target: value}) => this.encodePickingColor(index, value)

import {Layer, project32, picking, UNIT} from '@deck.gl/core';
import {Geometry} from '@luma.gl/engine';
import {Model} from '@luma.gl/engine';
import {GL} from '@luma.gl/constants';

@@ -80,3 +79,3 @@ import vs from './text-background-layer-vertex.glsl';

size: 3,
type: GL.DOUBLE,
type: 'float64',
fp64: this.use64bitPositions(),

@@ -109,4 +108,3 @@ transition: true,

transition: true,
normalized: true,
type: GL.UNSIGNED_BYTE,
type: 'unorm8',
accessor: 'getFillColor',

@@ -118,4 +116,3 @@ defaultValue: [0, 0, 0, 255]

transition: true,
normalized: true,
type: GL.UNSIGNED_BYTE,
type: 'unorm8',
accessor: 'getLineColor',

@@ -122,0 +119,0 @@ defaultValue: [0, 0, 0, 255]

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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