@deck.gl/layers
Advanced tools
Comparing version 6.0.2 to 6.0.3
@@ -26,4 +26,4 @@ "use strict"; | ||
// THE SOFTWARE. | ||
var _default = "#define SHADER_NAME arc-layer-vertex-shader\n\nattribute vec3 positions;\nattribute vec4 instanceSourceColors;\nattribute vec4 instanceTargetColors;\nattribute vec4 instancePositions;\nattribute vec3 instancePickingColors;\nattribute float instanceWidths;\n\nuniform float numSegments;\nuniform float opacity;\n\nvarying vec4 vColor;\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\n// offset vector by strokeWidth pixels\n// offset_direction is -1 (left) or 1 (right)\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n\n vec2 offset_screenspace = dir_screenspace * offset_direction * instanceWidths / 2.0;\n vec2 offset_clipspace = project_pixel_to_clipspace(offset_screenspace).xy;\n\n return offset_clipspace;\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (numSegments - 1.0));\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\n\nvoid main(void) {\n vec2 source = project_position(instancePositions.xy);\n vec2 target = project_position(instancePositions.zw);\n\n float segmentIndex = positions.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n // if it's the first point, use next - current as direction\n // otherwise use current - prev\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n\n vec3 currPos = getPos(source, target, segmentRatio);\n vec3 nextPos = getPos(source, target, nextSegmentRatio);\n vec4 curr = project_to_clipspace(vec4(currPos, 1.0));\n vec4 next = project_to_clipspace(vec4(nextPos, 1.0));\n\n // extrude\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, positions.y);\n gl_Position = curr + vec4(offset, 0.0, 0.0);\n\n vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio) / 255.;\n vColor = vec4(color.rgb, color.a * opacity);\n\n // Set color to be rendered to picking fbo (also used to check for selection highlight).\n picking_setPickingColor(instancePickingColors);\n}\n"; | ||
var _default = "#define SHADER_NAME arc-layer-vertex-shader\n\nattribute vec3 positions;\nattribute vec4 instanceSourceColors;\nattribute vec4 instanceTargetColors;\nattribute vec4 instancePositions;\nattribute vec4 instancePositions64Low;\nattribute vec3 instancePickingColors;\nattribute float instanceWidths;\n\nuniform float numSegments;\nuniform float opacity;\n\nvarying vec4 vColor;\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\n// offset vector by strokeWidth pixels\n// offset_direction is -1 (left) or 1 (right)\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n\n vec2 offset_screenspace = dir_screenspace * offset_direction * instanceWidths / 2.0;\n vec2 offset_clipspace = project_pixel_to_clipspace(offset_screenspace).xy;\n\n return offset_clipspace;\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (numSegments - 1.0));\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\n\nvoid main(void) {\n vec2 source = project_position(vec3(instancePositions.xy, 0.0), instancePositions64Low.xy).xy;\n vec2 target = project_position(vec3(instancePositions.zw, 0.0), instancePositions64Low.zw).xy;\n\n float segmentIndex = positions.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n // if it's the first point, use next - current as direction\n // otherwise use current - prev\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n\n vec3 currPos = getPos(source, target, segmentRatio);\n vec3 nextPos = getPos(source, target, nextSegmentRatio);\n vec4 curr = project_to_clipspace(vec4(currPos, 1.0));\n vec4 next = project_to_clipspace(vec4(nextPos, 1.0));\n\n // extrude\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, positions.y);\n gl_Position = curr + vec4(offset, 0.0, 0.0);\n\n vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio) / 255.;\n vColor = vec4(color.rgb, color.a * opacity);\n\n // Set color to be rendered to picking fbo (also used to check for selection highlight).\n picking_setPickingColor(instancePickingColors);\n}\n"; | ||
exports.default = _default; | ||
//# sourceMappingURL=arc-layer-vertex.glsl.js.map |
@@ -108,2 +108,7 @@ "use strict"; | ||
}, | ||
instancePositions64Low: { | ||
size: 4, | ||
accessor: ['getSourcePosition', 'getTargetPosition'], | ||
update: this.calculateInstancePositions64Low | ||
}, | ||
instanceSourceColors: { | ||
@@ -133,4 +138,4 @@ size: 4, | ||
}, { | ||
key: "updateAttribute", | ||
value: function updateAttribute(_ref) { | ||
key: "updateState", | ||
value: function updateState(_ref) { | ||
var props = _ref.props, | ||
@@ -140,26 +145,2 @@ oldProps = _ref.oldProps, | ||
if (props.fp64 !== oldProps.fp64) { | ||
var attributeManager = this.getAttributeManager(); | ||
attributeManager.invalidateAll(); | ||
if (props.fp64 && props.coordinateSystem === _core.COORDINATE_SYSTEM.LNGLAT) { | ||
attributeManager.addInstanced({ | ||
instancePositions64Low: { | ||
size: 4, | ||
accessor: ['getSourcePosition', 'getTargetPosition'], | ||
update: this.calculateInstancePositions64Low | ||
} | ||
}); | ||
} else { | ||
attributeManager.remove(['instancePositions64Low']); | ||
} | ||
} | ||
} | ||
}, { | ||
key: "updateState", | ||
value: function updateState(_ref2) { | ||
var props = _ref2.props, | ||
oldProps = _ref2.oldProps, | ||
changeFlags = _ref2.changeFlags; | ||
_get(ArcLayer.prototype.__proto__ || Object.getPrototypeOf(ArcLayer.prototype), "updateState", this).call(this, { | ||
@@ -182,9 +163,4 @@ props: props, | ||
}); | ||
this.getAttributeManager().invalidateAll(); | ||
} | ||
this.updateAttribute({ | ||
props: props, | ||
oldProps: oldProps, | ||
changeFlags: changeFlags | ||
}); | ||
} | ||
@@ -267,2 +243,10 @@ }, { | ||
value: function calculateInstancePositions64Low(attribute) { | ||
var isFP64 = this.use64bitPositions(); | ||
attribute.constant = !isFP64; | ||
if (!isFP64) { | ||
attribute.value = new Float32Array(4); | ||
return; | ||
} | ||
var _this$props2 = this.props, | ||
@@ -269,0 +253,0 @@ data = _this$props2.data, |
@@ -26,4 +26,4 @@ "use strict"; | ||
// THE SOFTWARE. | ||
var _default = "#define SHADER_NAME path-layer-vertex-shader-64\n\nattribute vec3 positions;\n\nattribute vec3 instanceStartPositions;\nattribute vec3 instanceEndPositions;\nattribute vec3 instanceLeftDeltas;\nattribute vec3 instanceRightDeltas;\nattribute float instanceStrokeWidths;\nattribute vec4 instanceColors;\nattribute vec3 instancePickingColors;\nattribute vec2 instanceDashArrays;\n\nuniform float widthScale;\nuniform float widthMinPixels;\nuniform float widthMaxPixels;\nuniform float jointType;\nuniform float miterLimit;\n\nuniform float opacity;\n\nvarying vec4 vColor;\nvarying vec2 vCornerOffset;\nvarying float vMiterLength;\nvarying vec2 vDashArray;\nvarying float vPathPosition;\nvarying float vPathLength;\n\nconst float EPSILON = 0.001;\nconst float PIXEL_EPSILON = 0.1;\n\nfloat flipIfTrue(bool flag) {\n return -(float(flag) * 2. - 1.);\n}\n\n// calculate line join positions\nvec3 lineJoin(\n vec3 prevPoint, vec3 currPoint, vec3 nextPoint,\n float relativePosition, bool isEnd, bool isJoint,\n float width\n) {\n vec2 deltaA = currPoint.xy - prevPoint.xy;\n vec2 deltaB = nextPoint.xy - currPoint.xy;\n\n float lenA = length(deltaA);\n float lenB = length(deltaB);\n\n // when two points are closer than PIXEL_EPSILON in pixels,\n // assume they are the same point to avoid precision issue\n lenA = lenA > PIXEL_EPSILON ? lenA : 0.0;\n lenB = lenB > PIXEL_EPSILON ? lenB : 0.0;\n\n vec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0);\n vec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0);\n\n vec2 perpA = vec2(-dirA.y, dirA.x);\n vec2 perpB = vec2(-dirB.y, dirB.x);\n\n // tangent of the corner\n vec2 tangent = vec2(dirA + dirB);\n tangent = length(tangent) > 0. ? normalize(tangent) : perpA;\n // direction of the corner\n vec2 miterVec = vec2(-tangent.y, tangent.x);\n // width offset from current position\n vec2 perp = isEnd ? perpA : perpB;\n float L = isEnd ? lenA : lenB;\n\n // cap super sharp angles\n float sinHalfA = abs(dot(miterVec, perp));\n float cosHalfA = abs(dot(dirA, miterVec));\n\n bool turnsRight = dirA.x * dirB.y > dirA.y * dirB.x;\n\n float offsetScale = 1.0 / max(sinHalfA, EPSILON);\n\n float cornerPosition = isJoint ?\n 0.0 :\n flipIfTrue(turnsRight == (relativePosition > 0.0));\n\n // do not bevel if line segment is too short\n cornerPosition *=\n float(cornerPosition <= 0.0 || sinHalfA < min(lenA, lenB) / width * cosHalfA);\n\n // trim if inside corner extends further than the line segment\n if (cornerPosition < 0.0) {\n offsetScale = min(offsetScale, L / width / max(cosHalfA, EPSILON));\n }\n\n vMiterLength = cornerPosition >= 0.0 ?\n mix(offsetScale, 0.0, cornerPosition) :\n offsetScale * cornerPosition;\n vMiterLength -= sinHalfA * jointType;\n\n float offsetDirection = mix(\n positions.y,\n mix(\n flipIfTrue(turnsRight),\n positions.y * flipIfTrue(turnsRight == (positions.x == 1.)),\n cornerPosition\n ),\n step(0.0, cornerPosition)\n );\n\n vec2 offsetVec = mix(miterVec, -tangent, step(0.5, cornerPosition));\n offsetScale = mix(offsetScale, 1.0 / max(cosHalfA, 0.001), step(0.5, cornerPosition));\n\n // special treatment for start cap and end cap\n // TODO - This has an issue. len is always positive because it is length.\n // Step returns zero if -lenA<0, so practically this is a comparison of\n // lenA with zero, with lots of problems because of the -lenA. Can we use EPSILON?\n bool isStartCap = step(0.0, -lenA) > 0.5;\n bool isEndCap = step(0.0, -lenB) > 0.5;\n bool isCap = isStartCap || isEndCap;\n\n // 0: center, 1: side\n cornerPosition = isCap ? (1.0 - positions.z) : 0.;\n\n // start of path: use next - curr\n if (isStartCap) {\n offsetVec = mix(dirB, perpB, cornerPosition);\n }\n\n // end of path: use curr - prev\n if (isEndCap) {\n offsetVec = mix(dirA, perpA, cornerPosition);\n }\n\n // extend out a triangle to envelope the round cap\n if (isCap) {\n offsetScale = mix(4.0 * jointType, 1.0, cornerPosition);\n vMiterLength = 1.0 - cornerPosition;\n offsetDirection = mix(flipIfTrue(isStartCap), positions.y, cornerPosition);\n }\n\n vCornerOffset = offsetVec * offsetDirection * offsetScale;\n\n // Generate variables for dash calculation\n vDashArray = instanceDashArrays;\n vPathLength = L / width;\n // vec2 offsetFromStartOfPath = isEnd ? vCornerOffset + deltaA / width : vCornerOffset;\n vec2 offsetFromStartOfPath = vCornerOffset;\n if (isEnd) {\n offsetFromStartOfPath += deltaA / width;\n }\n vec2 dir = isEnd ? dirA : dirB;\n vPathPosition = dot(offsetFromStartOfPath, dir);\n\n return currPoint + vec3(vCornerOffset * width, 0.0);\n}\n\n// calculate line join positions\n// extract params from attributes and uniforms\nvec3 lineJoin(vec3 prevPoint, vec3 currPoint, vec3 nextPoint) {\n\n // relative position to the corner:\n // -1: inside (smaller side of the angle)\n // 0: center\n // 1: outside (bigger side of the angle)\n\n float relativePosition = positions.y;\n bool isEnd = positions.x > EPSILON;\n bool isJoint = positions.z > EPSILON;\n\n float width = clamp(project_scale(instanceStrokeWidths * widthScale),\n widthMinPixels, widthMaxPixels) / 2.0;\n\n return lineJoin(\n prevPoint, currPoint, nextPoint,\n relativePosition, isEnd, isJoint,\n width\n );\n}\n\nvoid main() {\n vColor = vec4(instanceColors.rgb, instanceColors.a * opacity) / 255.;\n\n // Set color to be rendered to picking fbo (also used to check for selection highlight).\n picking_setPickingColor(instancePickingColors);\n\n float isEnd = positions.x;\n\n vec3 prevPosition = mix(-instanceLeftDeltas, vec3(0.0), isEnd) + instanceStartPositions;\n prevPosition = project_position(prevPosition);\n\n vec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd);\n currPosition = project_position(currPosition);\n\n vec3 nextPosition = mix(vec3(0.0), instanceRightDeltas, isEnd) + instanceEndPositions;\n nextPosition = project_position(nextPosition);\n\n vec3 pos = lineJoin(prevPosition, currPosition, nextPosition);\n\n gl_Position = project_to_clipspace(vec4(pos, 1.0));\n}\n"; | ||
var _default = "#define SHADER_NAME path-layer-vertex-shader-64\n\nattribute vec3 positions;\n\nattribute vec3 instanceStartPositions;\nattribute vec3 instanceEndPositions;\nattribute vec4 instanceStartEndPositions64xyLow;\nattribute vec3 instanceLeftDeltas;\nattribute vec3 instanceRightDeltas;\nattribute float instanceStrokeWidths;\nattribute vec4 instanceColors;\nattribute vec3 instancePickingColors;\nattribute vec2 instanceDashArrays;\n\nuniform float widthScale;\nuniform float widthMinPixels;\nuniform float widthMaxPixels;\nuniform float jointType;\nuniform float miterLimit;\n\nuniform float opacity;\n\nvarying vec4 vColor;\nvarying vec2 vCornerOffset;\nvarying float vMiterLength;\nvarying vec2 vDashArray;\nvarying float vPathPosition;\nvarying float vPathLength;\n\nconst float EPSILON = 0.001;\nconst float PIXEL_EPSILON = 0.1;\n\nfloat flipIfTrue(bool flag) {\n return -(float(flag) * 2. - 1.);\n}\n\n// calculate line join positions\nvec3 lineJoin(\n vec3 prevPoint, vec3 currPoint, vec3 nextPoint,\n float relativePosition, bool isEnd, bool isJoint,\n float width\n) {\n vec2 deltaA = currPoint.xy - prevPoint.xy;\n vec2 deltaB = nextPoint.xy - currPoint.xy;\n\n float lenA = length(deltaA);\n float lenB = length(deltaB);\n\n // when two points are closer than PIXEL_EPSILON in pixels,\n // assume they are the same point to avoid precision issue\n lenA = lenA > PIXEL_EPSILON ? lenA : 0.0;\n lenB = lenB > PIXEL_EPSILON ? lenB : 0.0;\n\n vec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0);\n vec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0);\n\n vec2 perpA = vec2(-dirA.y, dirA.x);\n vec2 perpB = vec2(-dirB.y, dirB.x);\n\n // tangent of the corner\n vec2 tangent = vec2(dirA + dirB);\n tangent = length(tangent) > 0. ? normalize(tangent) : perpA;\n // direction of the corner\n vec2 miterVec = vec2(-tangent.y, tangent.x);\n // width offset from current position\n vec2 perp = isEnd ? perpA : perpB;\n float L = isEnd ? lenA : lenB;\n\n // cap super sharp angles\n float sinHalfA = abs(dot(miterVec, perp));\n float cosHalfA = abs(dot(dirA, miterVec));\n\n bool turnsRight = dirA.x * dirB.y > dirA.y * dirB.x;\n\n float offsetScale = 1.0 / max(sinHalfA, EPSILON);\n\n float cornerPosition = isJoint ?\n 0.0 :\n flipIfTrue(turnsRight == (relativePosition > 0.0));\n\n // do not bevel if line segment is too short\n cornerPosition *=\n float(cornerPosition <= 0.0 || sinHalfA < min(lenA, lenB) / width * cosHalfA);\n\n // trim if inside corner extends further than the line segment\n if (cornerPosition < 0.0) {\n offsetScale = min(offsetScale, L / width / max(cosHalfA, EPSILON));\n }\n\n vMiterLength = cornerPosition >= 0.0 ?\n mix(offsetScale, 0.0, cornerPosition) :\n offsetScale * cornerPosition;\n vMiterLength -= sinHalfA * jointType;\n\n float offsetDirection = mix(\n positions.y,\n mix(\n flipIfTrue(turnsRight),\n positions.y * flipIfTrue(turnsRight == (positions.x == 1.)),\n cornerPosition\n ),\n step(0.0, cornerPosition)\n );\n\n vec2 offsetVec = mix(miterVec, -tangent, step(0.5, cornerPosition));\n offsetScale = mix(offsetScale, 1.0 / max(cosHalfA, 0.001), step(0.5, cornerPosition));\n\n // special treatment for start cap and end cap\n // TODO - This has an issue. len is always positive because it is length.\n // Step returns zero if -lenA<0, so practically this is a comparison of\n // lenA with zero, with lots of problems because of the -lenA. Can we use EPSILON?\n bool isStartCap = step(0.0, -lenA) > 0.5;\n bool isEndCap = step(0.0, -lenB) > 0.5;\n bool isCap = isStartCap || isEndCap;\n\n // 0: center, 1: side\n cornerPosition = isCap ? (1.0 - positions.z) : 0.;\n\n // start of path: use next - curr\n if (isStartCap) {\n offsetVec = mix(dirB, perpB, cornerPosition);\n }\n\n // end of path: use curr - prev\n if (isEndCap) {\n offsetVec = mix(dirA, perpA, cornerPosition);\n }\n\n // extend out a triangle to envelope the round cap\n if (isCap) {\n offsetScale = mix(4.0 * jointType, 1.0, cornerPosition);\n vMiterLength = 1.0 - cornerPosition;\n offsetDirection = mix(flipIfTrue(isStartCap), positions.y, cornerPosition);\n }\n\n vCornerOffset = offsetVec * offsetDirection * offsetScale;\n\n // Generate variables for dash calculation\n vDashArray = instanceDashArrays;\n vPathLength = L / width;\n // vec2 offsetFromStartOfPath = isEnd ? vCornerOffset + deltaA / width : vCornerOffset;\n vec2 offsetFromStartOfPath = vCornerOffset;\n if (isEnd) {\n offsetFromStartOfPath += deltaA / width;\n }\n vec2 dir = isEnd ? dirA : dirB;\n vPathPosition = dot(offsetFromStartOfPath, dir);\n\n return currPoint + vec3(vCornerOffset * width, 0.0);\n}\n\n// calculate line join positions\n// extract params from attributes and uniforms\nvec3 lineJoin(vec3 prevPoint, vec3 currPoint, vec3 nextPoint) {\n\n // relative position to the corner:\n // -1: inside (smaller side of the angle)\n // 0: center\n // 1: outside (bigger side of the angle)\n\n float relativePosition = positions.y;\n bool isEnd = positions.x > EPSILON;\n bool isJoint = positions.z > EPSILON;\n\n float width = clamp(project_scale(instanceStrokeWidths * widthScale),\n widthMinPixels, widthMaxPixels) / 2.0;\n\n return lineJoin(\n prevPoint, currPoint, nextPoint,\n relativePosition, isEnd, isJoint,\n width\n );\n}\n\nvoid main() {\n vColor = vec4(instanceColors.rgb, instanceColors.a * opacity) / 255.;\n\n // Set color to be rendered to picking fbo (also used to check for selection highlight).\n picking_setPickingColor(instancePickingColors);\n\n float isEnd = positions.x;\n\n vec3 prevPosition = mix(-instanceLeftDeltas, vec3(0.0), isEnd) + instanceStartPositions;\n vec2 prevPosition64xyLow = instanceStartEndPositions64xyLow.xy;\n prevPosition = project_position(prevPosition, prevPosition64xyLow);\n\n vec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd);\n vec2 currPosition64xyLow = mix(instanceStartEndPositions64xyLow.xy, instanceStartEndPositions64xyLow.zw, isEnd);\n currPosition = project_position(currPosition, currPosition64xyLow);\n\n vec3 nextPosition = mix(vec3(0.0), instanceRightDeltas, isEnd) + instanceEndPositions;\n vec2 nextPosition64xyLow = instanceStartEndPositions64xyLow.zw;\n nextPosition = project_position(nextPosition, nextPosition64xyLow);\n\n vec3 pos = lineJoin(prevPosition, currPosition, nextPosition);\n\n gl_Position = project_to_clipspace(vec4(pos, 1.0));\n}\n"; | ||
exports.default = _default; | ||
//# sourceMappingURL=path-layer-vertex.glsl.js.map |
@@ -122,2 +122,6 @@ "use strict"; | ||
}, | ||
instanceStartEndPositions64xyLow: { | ||
size: 4, | ||
update: this.calculateInstanceStartEndPositions64xyLow | ||
}, | ||
instanceLeftDeltas: { | ||
@@ -160,31 +164,8 @@ size: 3, | ||
}, { | ||
key: "updateAttribute", | ||
value: function updateAttribute(_ref) { | ||
var props = _ref.props, | ||
oldProps = _ref.oldProps, | ||
key: "updateState", | ||
value: function updateState(_ref) { | ||
var oldProps = _ref.oldProps, | ||
props = _ref.props, | ||
changeFlags = _ref.changeFlags; | ||
if (props.fp64 !== oldProps.fp64) { | ||
var attributeManager = this.getAttributeManager(); | ||
attributeManager.invalidateAll(); | ||
if (props.fp64 && props.coordinateSystem === _core.COORDINATE_SYSTEM.LNGLAT) { | ||
attributeManager.addInstanced({ | ||
instanceStartEndPositions64xyLow: { | ||
size: 4, | ||
update: this.calculateInstanceStartEndPositions64xyLow | ||
} | ||
}); | ||
} else { | ||
attributeManager.remove(['instanceStartEndPositions64xyLow']); | ||
} | ||
} | ||
} | ||
}, { | ||
key: "updateState", | ||
value: function updateState(_ref2) { | ||
var oldProps = _ref2.oldProps, | ||
props = _ref2.props, | ||
changeFlags = _ref2.changeFlags; | ||
_get(PathLayer.prototype.__proto__ || Object.getPrototypeOf(PathLayer.prototype), "updateState", this).call(this, { | ||
@@ -209,9 +190,5 @@ props: props, | ||
}); | ||
attributeManager.invalidateAll(); | ||
} | ||
this.updateAttribute({ | ||
props: props, | ||
oldProps: oldProps, | ||
changeFlags: changeFlags | ||
}); | ||
var geometryChanged = changeFlags.dataChanged || changeFlags.updateTriggersChanged && (changeFlags.updateTriggersChanged.all || changeFlags.updateTriggersChanged.getPath); | ||
@@ -238,4 +215,4 @@ | ||
key: "draw", | ||
value: function draw(_ref3) { | ||
var uniforms = _ref3.uniforms; | ||
value: function draw(_ref2) { | ||
var uniforms = _ref2.uniforms; | ||
var _this$props = this.props, | ||
@@ -348,2 +325,10 @@ rounded = _this$props.rounded, | ||
value: function calculateInstanceStartEndPositions64xyLow(attribute) { | ||
var isFP64 = this.use64bitPositions(); | ||
attribute.constant = !isFP64; | ||
if (!isFP64) { | ||
attribute.value = new Float32Array(4); | ||
return; | ||
} | ||
var paths = this.state.paths; | ||
@@ -350,0 +335,0 @@ var value = attribute.value; |
@@ -27,2 +27,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc. | ||
attribute vec4 instancePositions; | ||
attribute vec4 instancePositions64Low; | ||
attribute vec3 instancePickingColors; | ||
@@ -74,4 +75,4 @@ attribute float instanceWidths; | ||
void main(void) { | ||
vec2 source = project_position(instancePositions.xy); | ||
vec2 target = project_position(instancePositions.zw); | ||
vec2 source = project_position(vec3(instancePositions.xy, 0.0), instancePositions64Low.xy).xy; | ||
vec2 target = project_position(vec3(instancePositions.zw, 0.0), instancePositions64Low.zw).xy; | ||
@@ -78,0 +79,0 @@ float segmentIndex = positions.x; |
@@ -20,3 +20,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc. | ||
// THE SOFTWARE. | ||
import { COORDINATE_SYSTEM, Layer, log } from '@deck.gl/core'; | ||
import { Layer, log } from '@deck.gl/core'; | ||
import GL from 'luma.gl/constants'; | ||
@@ -74,2 +74,7 @@ import { Model, Geometry, fp64 } from 'luma.gl'; | ||
}, | ||
instancePositions64Low: { | ||
size: 4, | ||
accessor: ['getSourcePosition', 'getTargetPosition'], | ||
update: this.calculateInstancePositions64Low | ||
}, | ||
instanceSourceColors: { | ||
@@ -99,25 +104,2 @@ size: 4, | ||
updateAttribute({ | ||
props, | ||
oldProps, | ||
changeFlags | ||
}) { | ||
if (props.fp64 !== oldProps.fp64) { | ||
const attributeManager = this.getAttributeManager(); | ||
attributeManager.invalidateAll(); | ||
if (props.fp64 && props.coordinateSystem === COORDINATE_SYSTEM.LNGLAT) { | ||
attributeManager.addInstanced({ | ||
instancePositions64Low: { | ||
size: 4, | ||
accessor: ['getSourcePosition', 'getTargetPosition'], | ||
update: this.calculateInstancePositions64Low | ||
} | ||
}); | ||
} else { | ||
attributeManager.remove(['instancePositions64Low']); | ||
} | ||
} | ||
} | ||
updateState({ | ||
@@ -144,9 +126,4 @@ props, | ||
}); | ||
this.getAttributeManager().invalidateAll(); | ||
} | ||
this.updateAttribute({ | ||
props, | ||
oldProps, | ||
changeFlags | ||
}); | ||
} | ||
@@ -207,2 +184,10 @@ | ||
calculateInstancePositions64Low(attribute) { | ||
const isFP64 = this.use64bitPositions(); | ||
attribute.constant = !isFP64; | ||
if (!isFP64) { | ||
attribute.value = new Float32Array(4); | ||
return; | ||
} | ||
const _this$props2 = this.props, | ||
@@ -209,0 +194,0 @@ data = _this$props2.data, |
@@ -27,2 +27,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc. | ||
attribute vec3 instanceEndPositions; | ||
attribute vec4 instanceStartEndPositions64xyLow; | ||
attribute vec3 instanceLeftDeltas; | ||
@@ -204,9 +205,12 @@ attribute vec3 instanceRightDeltas; | ||
vec3 prevPosition = mix(-instanceLeftDeltas, vec3(0.0), isEnd) + instanceStartPositions; | ||
prevPosition = project_position(prevPosition); | ||
vec2 prevPosition64xyLow = instanceStartEndPositions64xyLow.xy; | ||
prevPosition = project_position(prevPosition, prevPosition64xyLow); | ||
vec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd); | ||
currPosition = project_position(currPosition); | ||
vec2 currPosition64xyLow = mix(instanceStartEndPositions64xyLow.xy, instanceStartEndPositions64xyLow.zw, isEnd); | ||
currPosition = project_position(currPosition, currPosition64xyLow); | ||
vec3 nextPosition = mix(vec3(0.0), instanceRightDeltas, isEnd) + instanceEndPositions; | ||
nextPosition = project_position(nextPosition); | ||
vec2 nextPosition64xyLow = instanceStartEndPositions64xyLow.zw; | ||
nextPosition = project_position(nextPosition, nextPosition64xyLow); | ||
@@ -213,0 +217,0 @@ vec3 pos = lineJoin(prevPosition, currPosition, nextPosition); |
@@ -20,3 +20,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc. | ||
// THE SOFTWARE. | ||
import { COORDINATE_SYSTEM, Layer } from '@deck.gl/core'; | ||
import { Layer } from '@deck.gl/core'; | ||
import GL from 'luma.gl/constants'; | ||
@@ -87,2 +87,6 @@ import { Model, Geometry, fp64 } from 'luma.gl'; | ||
}, | ||
instanceStartEndPositions64xyLow: { | ||
size: 4, | ||
update: this.calculateInstanceStartEndPositions64xyLow | ||
}, | ||
instanceLeftDeltas: { | ||
@@ -125,24 +129,2 @@ size: 3, | ||
updateAttribute({ | ||
props, | ||
oldProps, | ||
changeFlags | ||
}) { | ||
if (props.fp64 !== oldProps.fp64) { | ||
const attributeManager = this.getAttributeManager(); | ||
attributeManager.invalidateAll(); | ||
if (props.fp64 && props.coordinateSystem === COORDINATE_SYSTEM.LNGLAT) { | ||
attributeManager.addInstanced({ | ||
instanceStartEndPositions64xyLow: { | ||
size: 4, | ||
update: this.calculateInstanceStartEndPositions64xyLow | ||
} | ||
}); | ||
} else { | ||
attributeManager.remove(['instanceStartEndPositions64xyLow']); | ||
} | ||
} | ||
} | ||
updateState({ | ||
@@ -171,9 +153,5 @@ oldProps, | ||
}); | ||
attributeManager.invalidateAll(); | ||
} | ||
this.updateAttribute({ | ||
props, | ||
oldProps, | ||
changeFlags | ||
}); | ||
const geometryChanged = changeFlags.dataChanged || changeFlags.updateTriggersChanged && (changeFlags.updateTriggersChanged.all || changeFlags.updateTriggersChanged.getPath); | ||
@@ -300,2 +278,10 @@ | ||
calculateInstanceStartEndPositions64xyLow(attribute) { | ||
const isFP64 = this.use64bitPositions(); | ||
attribute.constant = !isFP64; | ||
if (!isFP64) { | ||
attribute.value = new Float32Array(4); | ||
return; | ||
} | ||
const paths = this.state.paths; | ||
@@ -302,0 +288,0 @@ const value = attribute.value; |
@@ -20,3 +20,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc. | ||
// THE SOFTWARE. | ||
export default "#define SHADER_NAME arc-layer-vertex-shader\n\nattribute vec3 positions;\nattribute vec4 instanceSourceColors;\nattribute vec4 instanceTargetColors;\nattribute vec4 instancePositions;\nattribute vec3 instancePickingColors;\nattribute float instanceWidths;\n\nuniform float numSegments;\nuniform float opacity;\n\nvarying vec4 vColor;\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\n// offset vector by strokeWidth pixels\n// offset_direction is -1 (left) or 1 (right)\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n\n vec2 offset_screenspace = dir_screenspace * offset_direction * instanceWidths / 2.0;\n vec2 offset_clipspace = project_pixel_to_clipspace(offset_screenspace).xy;\n\n return offset_clipspace;\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (numSegments - 1.0));\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\n\nvoid main(void) {\n vec2 source = project_position(instancePositions.xy);\n vec2 target = project_position(instancePositions.zw);\n\n float segmentIndex = positions.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n // if it's the first point, use next - current as direction\n // otherwise use current - prev\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n\n vec3 currPos = getPos(source, target, segmentRatio);\n vec3 nextPos = getPos(source, target, nextSegmentRatio);\n vec4 curr = project_to_clipspace(vec4(currPos, 1.0));\n vec4 next = project_to_clipspace(vec4(nextPos, 1.0));\n\n // extrude\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, positions.y);\n gl_Position = curr + vec4(offset, 0.0, 0.0);\n\n vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio) / 255.;\n vColor = vec4(color.rgb, color.a * opacity);\n\n // Set color to be rendered to picking fbo (also used to check for selection highlight).\n picking_setPickingColor(instancePickingColors);\n}\n"; | ||
export default "#define SHADER_NAME arc-layer-vertex-shader\n\nattribute vec3 positions;\nattribute vec4 instanceSourceColors;\nattribute vec4 instanceTargetColors;\nattribute vec4 instancePositions;\nattribute vec4 instancePositions64Low;\nattribute vec3 instancePickingColors;\nattribute float instanceWidths;\n\nuniform float numSegments;\nuniform float opacity;\n\nvarying vec4 vColor;\n\nfloat paraboloid(vec2 source, vec2 target, float ratio) {\n\n vec2 x = mix(source, target, ratio);\n vec2 center = mix(source, target, 0.5);\n\n float dSourceCenter = distance(source, center);\n float dXCenter = distance(x, center);\n return (dSourceCenter + dXCenter) * (dSourceCenter - dXCenter);\n}\n\n// offset vector by strokeWidth pixels\n// offset_direction is -1 (left) or 1 (right)\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n\n vec2 offset_screenspace = dir_screenspace * offset_direction * instanceWidths / 2.0;\n vec2 offset_clipspace = project_pixel_to_clipspace(offset_screenspace).xy;\n\n return offset_clipspace;\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (numSegments - 1.0));\n}\n\nvec3 getPos(vec2 source, vec2 target, float segmentRatio) {\n float vertex_height = paraboloid(source, target, segmentRatio);\n\n return vec3(\n mix(source, target, segmentRatio),\n sqrt(max(0.0, vertex_height))\n );\n}\n\nvoid main(void) {\n vec2 source = project_position(vec3(instancePositions.xy, 0.0), instancePositions64Low.xy).xy;\n vec2 target = project_position(vec3(instancePositions.zw, 0.0), instancePositions64Low.zw).xy;\n\n float segmentIndex = positions.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n // if it's the first point, use next - current as direction\n // otherwise use current - prev\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n\n vec3 currPos = getPos(source, target, segmentRatio);\n vec3 nextPos = getPos(source, target, nextSegmentRatio);\n vec4 curr = project_to_clipspace(vec4(currPos, 1.0));\n vec4 next = project_to_clipspace(vec4(nextPos, 1.0));\n\n // extrude\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, positions.y);\n gl_Position = curr + vec4(offset, 0.0, 0.0);\n\n vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio) / 255.;\n vColor = vec4(color.rgb, color.a * opacity);\n\n // Set color to be rendered to picking fbo (also used to check for selection highlight).\n picking_setPickingColor(instancePickingColors);\n}\n"; | ||
//# sourceMappingURL=arc-layer-vertex.glsl.js.map |
@@ -44,3 +44,3 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } } | ||
// THE SOFTWARE. | ||
import { COORDINATE_SYSTEM, Layer, log } from '@deck.gl/core'; | ||
import { Layer, log } from '@deck.gl/core'; | ||
import GL from 'luma.gl/constants'; | ||
@@ -112,2 +112,7 @@ import { Model, Geometry, fp64 } from 'luma.gl'; | ||
}, | ||
instancePositions64Low: { | ||
size: 4, | ||
accessor: ['getSourcePosition', 'getTargetPosition'], | ||
update: this.calculateInstancePositions64Low | ||
}, | ||
instanceSourceColors: { | ||
@@ -137,4 +142,4 @@ size: 4, | ||
}, { | ||
key: "updateAttribute", | ||
value: function updateAttribute(_ref) { | ||
key: "updateState", | ||
value: function updateState(_ref) { | ||
var props = _ref.props, | ||
@@ -144,26 +149,2 @@ oldProps = _ref.oldProps, | ||
if (props.fp64 !== oldProps.fp64) { | ||
var attributeManager = this.getAttributeManager(); | ||
attributeManager.invalidateAll(); | ||
if (props.fp64 && props.coordinateSystem === COORDINATE_SYSTEM.LNGLAT) { | ||
attributeManager.addInstanced({ | ||
instancePositions64Low: { | ||
size: 4, | ||
accessor: ['getSourcePosition', 'getTargetPosition'], | ||
update: this.calculateInstancePositions64Low | ||
} | ||
}); | ||
} else { | ||
attributeManager.remove(['instancePositions64Low']); | ||
} | ||
} | ||
} | ||
}, { | ||
key: "updateState", | ||
value: function updateState(_ref2) { | ||
var props = _ref2.props, | ||
oldProps = _ref2.oldProps, | ||
changeFlags = _ref2.changeFlags; | ||
_get(ArcLayer.prototype.__proto__ || Object.getPrototypeOf(ArcLayer.prototype), "updateState", this).call(this, { | ||
@@ -186,9 +167,4 @@ props: props, | ||
}); | ||
this.getAttributeManager().invalidateAll(); | ||
} | ||
this.updateAttribute({ | ||
props: props, | ||
oldProps: oldProps, | ||
changeFlags: changeFlags | ||
}); | ||
} | ||
@@ -271,2 +247,10 @@ }, { | ||
value: function calculateInstancePositions64Low(attribute) { | ||
var isFP64 = this.use64bitPositions(); | ||
attribute.constant = !isFP64; | ||
if (!isFP64) { | ||
attribute.value = new Float32Array(4); | ||
return; | ||
} | ||
var _this$props2 = this.props, | ||
@@ -273,0 +257,0 @@ data = _this$props2.data, |
@@ -20,3 +20,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc. | ||
// THE SOFTWARE. | ||
export default "#define SHADER_NAME path-layer-vertex-shader-64\n\nattribute vec3 positions;\n\nattribute vec3 instanceStartPositions;\nattribute vec3 instanceEndPositions;\nattribute vec3 instanceLeftDeltas;\nattribute vec3 instanceRightDeltas;\nattribute float instanceStrokeWidths;\nattribute vec4 instanceColors;\nattribute vec3 instancePickingColors;\nattribute vec2 instanceDashArrays;\n\nuniform float widthScale;\nuniform float widthMinPixels;\nuniform float widthMaxPixels;\nuniform float jointType;\nuniform float miterLimit;\n\nuniform float opacity;\n\nvarying vec4 vColor;\nvarying vec2 vCornerOffset;\nvarying float vMiterLength;\nvarying vec2 vDashArray;\nvarying float vPathPosition;\nvarying float vPathLength;\n\nconst float EPSILON = 0.001;\nconst float PIXEL_EPSILON = 0.1;\n\nfloat flipIfTrue(bool flag) {\n return -(float(flag) * 2. - 1.);\n}\n\n// calculate line join positions\nvec3 lineJoin(\n vec3 prevPoint, vec3 currPoint, vec3 nextPoint,\n float relativePosition, bool isEnd, bool isJoint,\n float width\n) {\n vec2 deltaA = currPoint.xy - prevPoint.xy;\n vec2 deltaB = nextPoint.xy - currPoint.xy;\n\n float lenA = length(deltaA);\n float lenB = length(deltaB);\n\n // when two points are closer than PIXEL_EPSILON in pixels,\n // assume they are the same point to avoid precision issue\n lenA = lenA > PIXEL_EPSILON ? lenA : 0.0;\n lenB = lenB > PIXEL_EPSILON ? lenB : 0.0;\n\n vec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0);\n vec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0);\n\n vec2 perpA = vec2(-dirA.y, dirA.x);\n vec2 perpB = vec2(-dirB.y, dirB.x);\n\n // tangent of the corner\n vec2 tangent = vec2(dirA + dirB);\n tangent = length(tangent) > 0. ? normalize(tangent) : perpA;\n // direction of the corner\n vec2 miterVec = vec2(-tangent.y, tangent.x);\n // width offset from current position\n vec2 perp = isEnd ? perpA : perpB;\n float L = isEnd ? lenA : lenB;\n\n // cap super sharp angles\n float sinHalfA = abs(dot(miterVec, perp));\n float cosHalfA = abs(dot(dirA, miterVec));\n\n bool turnsRight = dirA.x * dirB.y > dirA.y * dirB.x;\n\n float offsetScale = 1.0 / max(sinHalfA, EPSILON);\n\n float cornerPosition = isJoint ?\n 0.0 :\n flipIfTrue(turnsRight == (relativePosition > 0.0));\n\n // do not bevel if line segment is too short\n cornerPosition *=\n float(cornerPosition <= 0.0 || sinHalfA < min(lenA, lenB) / width * cosHalfA);\n\n // trim if inside corner extends further than the line segment\n if (cornerPosition < 0.0) {\n offsetScale = min(offsetScale, L / width / max(cosHalfA, EPSILON));\n }\n\n vMiterLength = cornerPosition >= 0.0 ?\n mix(offsetScale, 0.0, cornerPosition) :\n offsetScale * cornerPosition;\n vMiterLength -= sinHalfA * jointType;\n\n float offsetDirection = mix(\n positions.y,\n mix(\n flipIfTrue(turnsRight),\n positions.y * flipIfTrue(turnsRight == (positions.x == 1.)),\n cornerPosition\n ),\n step(0.0, cornerPosition)\n );\n\n vec2 offsetVec = mix(miterVec, -tangent, step(0.5, cornerPosition));\n offsetScale = mix(offsetScale, 1.0 / max(cosHalfA, 0.001), step(0.5, cornerPosition));\n\n // special treatment for start cap and end cap\n // TODO - This has an issue. len is always positive because it is length.\n // Step returns zero if -lenA<0, so practically this is a comparison of\n // lenA with zero, with lots of problems because of the -lenA. Can we use EPSILON?\n bool isStartCap = step(0.0, -lenA) > 0.5;\n bool isEndCap = step(0.0, -lenB) > 0.5;\n bool isCap = isStartCap || isEndCap;\n\n // 0: center, 1: side\n cornerPosition = isCap ? (1.0 - positions.z) : 0.;\n\n // start of path: use next - curr\n if (isStartCap) {\n offsetVec = mix(dirB, perpB, cornerPosition);\n }\n\n // end of path: use curr - prev\n if (isEndCap) {\n offsetVec = mix(dirA, perpA, cornerPosition);\n }\n\n // extend out a triangle to envelope the round cap\n if (isCap) {\n offsetScale = mix(4.0 * jointType, 1.0, cornerPosition);\n vMiterLength = 1.0 - cornerPosition;\n offsetDirection = mix(flipIfTrue(isStartCap), positions.y, cornerPosition);\n }\n\n vCornerOffset = offsetVec * offsetDirection * offsetScale;\n\n // Generate variables for dash calculation\n vDashArray = instanceDashArrays;\n vPathLength = L / width;\n // vec2 offsetFromStartOfPath = isEnd ? vCornerOffset + deltaA / width : vCornerOffset;\n vec2 offsetFromStartOfPath = vCornerOffset;\n if (isEnd) {\n offsetFromStartOfPath += deltaA / width;\n }\n vec2 dir = isEnd ? dirA : dirB;\n vPathPosition = dot(offsetFromStartOfPath, dir);\n\n return currPoint + vec3(vCornerOffset * width, 0.0);\n}\n\n// calculate line join positions\n// extract params from attributes and uniforms\nvec3 lineJoin(vec3 prevPoint, vec3 currPoint, vec3 nextPoint) {\n\n // relative position to the corner:\n // -1: inside (smaller side of the angle)\n // 0: center\n // 1: outside (bigger side of the angle)\n\n float relativePosition = positions.y;\n bool isEnd = positions.x > EPSILON;\n bool isJoint = positions.z > EPSILON;\n\n float width = clamp(project_scale(instanceStrokeWidths * widthScale),\n widthMinPixels, widthMaxPixels) / 2.0;\n\n return lineJoin(\n prevPoint, currPoint, nextPoint,\n relativePosition, isEnd, isJoint,\n width\n );\n}\n\nvoid main() {\n vColor = vec4(instanceColors.rgb, instanceColors.a * opacity) / 255.;\n\n // Set color to be rendered to picking fbo (also used to check for selection highlight).\n picking_setPickingColor(instancePickingColors);\n\n float isEnd = positions.x;\n\n vec3 prevPosition = mix(-instanceLeftDeltas, vec3(0.0), isEnd) + instanceStartPositions;\n prevPosition = project_position(prevPosition);\n\n vec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd);\n currPosition = project_position(currPosition);\n\n vec3 nextPosition = mix(vec3(0.0), instanceRightDeltas, isEnd) + instanceEndPositions;\n nextPosition = project_position(nextPosition);\n\n vec3 pos = lineJoin(prevPosition, currPosition, nextPosition);\n\n gl_Position = project_to_clipspace(vec4(pos, 1.0));\n}\n"; | ||
export default "#define SHADER_NAME path-layer-vertex-shader-64\n\nattribute vec3 positions;\n\nattribute vec3 instanceStartPositions;\nattribute vec3 instanceEndPositions;\nattribute vec4 instanceStartEndPositions64xyLow;\nattribute vec3 instanceLeftDeltas;\nattribute vec3 instanceRightDeltas;\nattribute float instanceStrokeWidths;\nattribute vec4 instanceColors;\nattribute vec3 instancePickingColors;\nattribute vec2 instanceDashArrays;\n\nuniform float widthScale;\nuniform float widthMinPixels;\nuniform float widthMaxPixels;\nuniform float jointType;\nuniform float miterLimit;\n\nuniform float opacity;\n\nvarying vec4 vColor;\nvarying vec2 vCornerOffset;\nvarying float vMiterLength;\nvarying vec2 vDashArray;\nvarying float vPathPosition;\nvarying float vPathLength;\n\nconst float EPSILON = 0.001;\nconst float PIXEL_EPSILON = 0.1;\n\nfloat flipIfTrue(bool flag) {\n return -(float(flag) * 2. - 1.);\n}\n\n// calculate line join positions\nvec3 lineJoin(\n vec3 prevPoint, vec3 currPoint, vec3 nextPoint,\n float relativePosition, bool isEnd, bool isJoint,\n float width\n) {\n vec2 deltaA = currPoint.xy - prevPoint.xy;\n vec2 deltaB = nextPoint.xy - currPoint.xy;\n\n float lenA = length(deltaA);\n float lenB = length(deltaB);\n\n // when two points are closer than PIXEL_EPSILON in pixels,\n // assume they are the same point to avoid precision issue\n lenA = lenA > PIXEL_EPSILON ? lenA : 0.0;\n lenB = lenB > PIXEL_EPSILON ? lenB : 0.0;\n\n vec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0);\n vec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0);\n\n vec2 perpA = vec2(-dirA.y, dirA.x);\n vec2 perpB = vec2(-dirB.y, dirB.x);\n\n // tangent of the corner\n vec2 tangent = vec2(dirA + dirB);\n tangent = length(tangent) > 0. ? normalize(tangent) : perpA;\n // direction of the corner\n vec2 miterVec = vec2(-tangent.y, tangent.x);\n // width offset from current position\n vec2 perp = isEnd ? perpA : perpB;\n float L = isEnd ? lenA : lenB;\n\n // cap super sharp angles\n float sinHalfA = abs(dot(miterVec, perp));\n float cosHalfA = abs(dot(dirA, miterVec));\n\n bool turnsRight = dirA.x * dirB.y > dirA.y * dirB.x;\n\n float offsetScale = 1.0 / max(sinHalfA, EPSILON);\n\n float cornerPosition = isJoint ?\n 0.0 :\n flipIfTrue(turnsRight == (relativePosition > 0.0));\n\n // do not bevel if line segment is too short\n cornerPosition *=\n float(cornerPosition <= 0.0 || sinHalfA < min(lenA, lenB) / width * cosHalfA);\n\n // trim if inside corner extends further than the line segment\n if (cornerPosition < 0.0) {\n offsetScale = min(offsetScale, L / width / max(cosHalfA, EPSILON));\n }\n\n vMiterLength = cornerPosition >= 0.0 ?\n mix(offsetScale, 0.0, cornerPosition) :\n offsetScale * cornerPosition;\n vMiterLength -= sinHalfA * jointType;\n\n float offsetDirection = mix(\n positions.y,\n mix(\n flipIfTrue(turnsRight),\n positions.y * flipIfTrue(turnsRight == (positions.x == 1.)),\n cornerPosition\n ),\n step(0.0, cornerPosition)\n );\n\n vec2 offsetVec = mix(miterVec, -tangent, step(0.5, cornerPosition));\n offsetScale = mix(offsetScale, 1.0 / max(cosHalfA, 0.001), step(0.5, cornerPosition));\n\n // special treatment for start cap and end cap\n // TODO - This has an issue. len is always positive because it is length.\n // Step returns zero if -lenA<0, so practically this is a comparison of\n // lenA with zero, with lots of problems because of the -lenA. Can we use EPSILON?\n bool isStartCap = step(0.0, -lenA) > 0.5;\n bool isEndCap = step(0.0, -lenB) > 0.5;\n bool isCap = isStartCap || isEndCap;\n\n // 0: center, 1: side\n cornerPosition = isCap ? (1.0 - positions.z) : 0.;\n\n // start of path: use next - curr\n if (isStartCap) {\n offsetVec = mix(dirB, perpB, cornerPosition);\n }\n\n // end of path: use curr - prev\n if (isEndCap) {\n offsetVec = mix(dirA, perpA, cornerPosition);\n }\n\n // extend out a triangle to envelope the round cap\n if (isCap) {\n offsetScale = mix(4.0 * jointType, 1.0, cornerPosition);\n vMiterLength = 1.0 - cornerPosition;\n offsetDirection = mix(flipIfTrue(isStartCap), positions.y, cornerPosition);\n }\n\n vCornerOffset = offsetVec * offsetDirection * offsetScale;\n\n // Generate variables for dash calculation\n vDashArray = instanceDashArrays;\n vPathLength = L / width;\n // vec2 offsetFromStartOfPath = isEnd ? vCornerOffset + deltaA / width : vCornerOffset;\n vec2 offsetFromStartOfPath = vCornerOffset;\n if (isEnd) {\n offsetFromStartOfPath += deltaA / width;\n }\n vec2 dir = isEnd ? dirA : dirB;\n vPathPosition = dot(offsetFromStartOfPath, dir);\n\n return currPoint + vec3(vCornerOffset * width, 0.0);\n}\n\n// calculate line join positions\n// extract params from attributes and uniforms\nvec3 lineJoin(vec3 prevPoint, vec3 currPoint, vec3 nextPoint) {\n\n // relative position to the corner:\n // -1: inside (smaller side of the angle)\n // 0: center\n // 1: outside (bigger side of the angle)\n\n float relativePosition = positions.y;\n bool isEnd = positions.x > EPSILON;\n bool isJoint = positions.z > EPSILON;\n\n float width = clamp(project_scale(instanceStrokeWidths * widthScale),\n widthMinPixels, widthMaxPixels) / 2.0;\n\n return lineJoin(\n prevPoint, currPoint, nextPoint,\n relativePosition, isEnd, isJoint,\n width\n );\n}\n\nvoid main() {\n vColor = vec4(instanceColors.rgb, instanceColors.a * opacity) / 255.;\n\n // Set color to be rendered to picking fbo (also used to check for selection highlight).\n picking_setPickingColor(instancePickingColors);\n\n float isEnd = positions.x;\n\n vec3 prevPosition = mix(-instanceLeftDeltas, vec3(0.0), isEnd) + instanceStartPositions;\n vec2 prevPosition64xyLow = instanceStartEndPositions64xyLow.xy;\n prevPosition = project_position(prevPosition, prevPosition64xyLow);\n\n vec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd);\n vec2 currPosition64xyLow = mix(instanceStartEndPositions64xyLow.xy, instanceStartEndPositions64xyLow.zw, isEnd);\n currPosition = project_position(currPosition, currPosition64xyLow);\n\n vec3 nextPosition = mix(vec3(0.0), instanceRightDeltas, isEnd) + instanceEndPositions;\n vec2 nextPosition64xyLow = instanceStartEndPositions64xyLow.zw;\n nextPosition = project_position(nextPosition, nextPosition64xyLow);\n\n vec3 pos = lineJoin(prevPosition, currPosition, nextPosition);\n\n gl_Position = project_to_clipspace(vec4(pos, 1.0));\n}\n"; | ||
//# sourceMappingURL=path-layer-vertex.glsl.js.map |
@@ -44,3 +44,3 @@ function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } } | ||
// THE SOFTWARE. | ||
import { COORDINATE_SYSTEM, Layer } from '@deck.gl/core'; | ||
import { Layer } from '@deck.gl/core'; | ||
import GL from 'luma.gl/constants'; | ||
@@ -127,2 +127,6 @@ import { Model, Geometry, fp64 } from 'luma.gl'; | ||
}, | ||
instanceStartEndPositions64xyLow: { | ||
size: 4, | ||
update: this.calculateInstanceStartEndPositions64xyLow | ||
}, | ||
instanceLeftDeltas: { | ||
@@ -165,31 +169,8 @@ size: 3, | ||
}, { | ||
key: "updateAttribute", | ||
value: function updateAttribute(_ref) { | ||
var props = _ref.props, | ||
oldProps = _ref.oldProps, | ||
key: "updateState", | ||
value: function updateState(_ref) { | ||
var oldProps = _ref.oldProps, | ||
props = _ref.props, | ||
changeFlags = _ref.changeFlags; | ||
if (props.fp64 !== oldProps.fp64) { | ||
var attributeManager = this.getAttributeManager(); | ||
attributeManager.invalidateAll(); | ||
if (props.fp64 && props.coordinateSystem === COORDINATE_SYSTEM.LNGLAT) { | ||
attributeManager.addInstanced({ | ||
instanceStartEndPositions64xyLow: { | ||
size: 4, | ||
update: this.calculateInstanceStartEndPositions64xyLow | ||
} | ||
}); | ||
} else { | ||
attributeManager.remove(['instanceStartEndPositions64xyLow']); | ||
} | ||
} | ||
} | ||
}, { | ||
key: "updateState", | ||
value: function updateState(_ref2) { | ||
var oldProps = _ref2.oldProps, | ||
props = _ref2.props, | ||
changeFlags = _ref2.changeFlags; | ||
_get(PathLayer.prototype.__proto__ || Object.getPrototypeOf(PathLayer.prototype), "updateState", this).call(this, { | ||
@@ -214,9 +195,5 @@ props: props, | ||
}); | ||
attributeManager.invalidateAll(); | ||
} | ||
this.updateAttribute({ | ||
props: props, | ||
oldProps: oldProps, | ||
changeFlags: changeFlags | ||
}); | ||
var geometryChanged = changeFlags.dataChanged || changeFlags.updateTriggersChanged && (changeFlags.updateTriggersChanged.all || changeFlags.updateTriggersChanged.getPath); | ||
@@ -243,4 +220,4 @@ | ||
key: "draw", | ||
value: function draw(_ref3) { | ||
var uniforms = _ref3.uniforms; | ||
value: function draw(_ref2) { | ||
var uniforms = _ref2.uniforms; | ||
var _this$props = this.props, | ||
@@ -353,2 +330,10 @@ rounded = _this$props.rounded, | ||
value: function calculateInstanceStartEndPositions64xyLow(attribute) { | ||
var isFP64 = this.use64bitPositions(); | ||
attribute.constant = !isFP64; | ||
if (!isFP64) { | ||
attribute.value = new Float32Array(4); | ||
return; | ||
} | ||
var paths = this.state.paths; | ||
@@ -355,0 +340,0 @@ var value = attribute.value; |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "6.0.2", | ||
"version": "6.0.3", | ||
"publishConfig": { | ||
@@ -35,3 +35,3 @@ "access": "public" | ||
"dependencies": { | ||
"@deck.gl/core": "^6.0.2", | ||
"@deck.gl/core": "^6.0.3", | ||
"d3-hexbin": "^0.2.1", | ||
@@ -38,0 +38,0 @@ "earcut": "^2.0.6" |
@@ -28,2 +28,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc. | ||
attribute vec4 instancePositions; | ||
attribute vec4 instancePositions64Low; | ||
attribute vec3 instancePickingColors; | ||
@@ -75,4 +76,4 @@ attribute float instanceWidths; | ||
void main(void) { | ||
vec2 source = project_position(instancePositions.xy); | ||
vec2 target = project_position(instancePositions.zw); | ||
vec2 source = project_position(vec3(instancePositions.xy, 0.0), instancePositions64Low.xy).xy; | ||
vec2 target = project_position(vec3(instancePositions.zw, 0.0), instancePositions64Low.zw).xy; | ||
@@ -79,0 +80,0 @@ float segmentIndex = positions.x; |
@@ -21,3 +21,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc. | ||
import {COORDINATE_SYSTEM, Layer, log} from '@deck.gl/core'; | ||
import {Layer, log} from '@deck.gl/core'; | ||
@@ -73,2 +73,7 @@ import GL from 'luma.gl/constants'; | ||
}, | ||
instancePositions64Low: { | ||
size: 4, | ||
accessor: ['getSourcePosition', 'getTargetPosition'], | ||
update: this.calculateInstancePositions64Low | ||
}, | ||
instanceSourceColors: { | ||
@@ -98,21 +103,2 @@ size: 4, | ||
updateAttribute({props, oldProps, changeFlags}) { | ||
if (props.fp64 !== oldProps.fp64) { | ||
const attributeManager = this.getAttributeManager(); | ||
attributeManager.invalidateAll(); | ||
if (props.fp64 && props.coordinateSystem === COORDINATE_SYSTEM.LNGLAT) { | ||
attributeManager.addInstanced({ | ||
instancePositions64Low: { | ||
size: 4, | ||
accessor: ['getSourcePosition', 'getTargetPosition'], | ||
update: this.calculateInstancePositions64Low | ||
} | ||
}); | ||
} else { | ||
attributeManager.remove(['instancePositions64Low']); | ||
} | ||
} | ||
} | ||
updateState({props, oldProps, changeFlags}) { | ||
@@ -127,4 +113,4 @@ super.updateState({props, oldProps, changeFlags}); | ||
this.setState({model: this._getModel(gl)}); | ||
this.getAttributeManager().invalidateAll(); | ||
} | ||
this.updateAttribute({props, oldProps, changeFlags}); | ||
} | ||
@@ -182,2 +168,10 @@ | ||
calculateInstancePositions64Low(attribute) { | ||
const isFP64 = this.use64bitPositions(); | ||
attribute.constant = !isFP64; | ||
if (!isFP64) { | ||
attribute.value = new Float32Array(4); | ||
return; | ||
} | ||
const {data, getSourcePosition, getTargetPosition} = this.props; | ||
@@ -184,0 +178,0 @@ const {value, size} = attribute; |
@@ -28,2 +28,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc. | ||
attribute vec3 instanceEndPositions; | ||
attribute vec4 instanceStartEndPositions64xyLow; | ||
attribute vec3 instanceLeftDeltas; | ||
@@ -205,9 +206,12 @@ attribute vec3 instanceRightDeltas; | ||
vec3 prevPosition = mix(-instanceLeftDeltas, vec3(0.0), isEnd) + instanceStartPositions; | ||
prevPosition = project_position(prevPosition); | ||
vec2 prevPosition64xyLow = instanceStartEndPositions64xyLow.xy; | ||
prevPosition = project_position(prevPosition, prevPosition64xyLow); | ||
vec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd); | ||
currPosition = project_position(currPosition); | ||
vec2 currPosition64xyLow = mix(instanceStartEndPositions64xyLow.xy, instanceStartEndPositions64xyLow.zw, isEnd); | ||
currPosition = project_position(currPosition, currPosition64xyLow); | ||
vec3 nextPosition = mix(vec3(0.0), instanceRightDeltas, isEnd) + instanceEndPositions; | ||
nextPosition = project_position(nextPosition); | ||
vec2 nextPosition64xyLow = instanceStartEndPositions64xyLow.zw; | ||
nextPosition = project_position(nextPosition, nextPosition64xyLow); | ||
@@ -214,0 +218,0 @@ vec3 pos = lineJoin(prevPosition, currPosition, nextPosition); |
@@ -21,3 +21,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc. | ||
import {COORDINATE_SYSTEM, Layer} from '@deck.gl/core'; | ||
import {Layer} from '@deck.gl/core'; | ||
import GL from 'luma.gl/constants'; | ||
@@ -87,2 +87,6 @@ import {Model, Geometry, fp64} from 'luma.gl'; | ||
}, | ||
instanceStartEndPositions64xyLow: { | ||
size: 4, | ||
update: this.calculateInstanceStartEndPositions64xyLow | ||
}, | ||
instanceLeftDeltas: {size: 3, update: this.calculateLeftDeltas}, | ||
@@ -111,20 +115,2 @@ instanceRightDeltas: {size: 3, update: this.calculateRightDeltas}, | ||
updateAttribute({props, oldProps, changeFlags}) { | ||
if (props.fp64 !== oldProps.fp64) { | ||
const attributeManager = this.getAttributeManager(); | ||
attributeManager.invalidateAll(); | ||
if (props.fp64 && props.coordinateSystem === COORDINATE_SYSTEM.LNGLAT) { | ||
attributeManager.addInstanced({ | ||
instanceStartEndPositions64xyLow: { | ||
size: 4, | ||
update: this.calculateInstanceStartEndPositions64xyLow | ||
} | ||
}); | ||
} else { | ||
attributeManager.remove(['instanceStartEndPositions64xyLow']); | ||
} | ||
} | ||
} | ||
updateState({oldProps, props, changeFlags}) { | ||
@@ -141,4 +127,4 @@ super.updateState({props, oldProps, changeFlags}); | ||
this.setState({model: this._getModel(gl)}); | ||
attributeManager.invalidateAll(); | ||
} | ||
this.updateAttribute({props, oldProps, changeFlags}); | ||
@@ -309,2 +295,10 @@ const geometryChanged = | ||
calculateInstanceStartEndPositions64xyLow(attribute) { | ||
const isFP64 = this.use64bitPositions(); | ||
attribute.constant = !isFP64; | ||
if (!isFP64) { | ||
attribute.value = new Float32Array(4); | ||
return; | ||
} | ||
const {paths} = this.state; | ||
@@ -311,0 +305,0 @@ const {value} = attribute; |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2271512
25647
Updated@deck.gl/core@^6.0.3