@webviz/subsurface-viewer 1.11.0 → 1.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Map.js +1 -1
- package/dist/components/Map.js.map +1 -1
- package/dist/extensions/side-projection-extension.d.ts +41 -6
- package/dist/extensions/side-projection-extension.js +33 -27
- package/dist/extensions/side-projection-extension.js.map +1 -1
- package/dist/layers/axes/axes-fragment.glsl.d.ts +1 -1
- package/dist/layers/axes/axes-fragment.glsl.js +1 -1
- package/dist/layers/axes/grid-vertex.glsl.d.ts +1 -1
- package/dist/layers/axes/grid-vertex.glsl.js +1 -1
- package/dist/layers/axes2d/axes2DLayer.d.ts +7 -7
- package/dist/layers/axes2d/axes2DLayer.js +62 -14
- package/dist/layers/axes2d/axes2DLayer.js.map +1 -1
- package/dist/layers/axes2d/label-fragment.glsl.d.ts +1 -1
- package/dist/layers/axes2d/label-fragment.glsl.js +7 -10
- package/dist/layers/axes2d/label-fragment.glsl.js.map +1 -1
- package/dist/layers/axes2d/label-vertex.glsl.d.ts +1 -1
- package/dist/layers/axes2d/label-vertex.glsl.js +1 -1
- package/dist/layers/axes2d/line-fragment.glsl.d.ts +1 -1
- package/dist/layers/axes2d/line-fragment.glsl.js +2 -4
- package/dist/layers/axes2d/line-fragment.glsl.js.map +1 -1
- package/dist/layers/axes2d/line-vertex.glsl.d.ts +1 -1
- package/dist/layers/axes2d/line-vertex.glsl.js +2 -4
- package/dist/layers/axes2d/line-vertex.glsl.js.map +1 -1
- package/dist/layers/colormap/colormap.fs.glsl.d.ts +1 -1
- package/dist/layers/colormap/colormap.fs.glsl.js +2 -5
- package/dist/layers/colormap/colormap.fs.glsl.js.map +1 -1
- package/dist/layers/colormap/colormapLayer.d.ts +3 -2
- package/dist/layers/colormap/colormapLayer.js +81 -25
- package/dist/layers/colormap/colormapLayer.js.map +1 -1
- package/dist/layers/grid3d/cellProperty.fs.glsl.d.ts +1 -1
- package/dist/layers/grid3d/cellProperty.fs.glsl.js +14 -27
- package/dist/layers/grid3d/cellProperty.fs.glsl.js.map +1 -1
- package/dist/layers/grid3d/cellProperty.vs.glsl.d.ts +1 -1
- package/dist/layers/grid3d/cellProperty.vs.glsl.js +2 -4
- package/dist/layers/grid3d/cellProperty.vs.glsl.js.map +1 -1
- package/dist/layers/grid3d/fragment_lines.glsl.d.ts +1 -1
- package/dist/layers/grid3d/fragment_lines.glsl.js +1 -1
- package/dist/layers/grid3d/grid3dLayer.js +2 -0
- package/dist/layers/grid3d/grid3dLayer.js.map +1 -1
- package/dist/layers/grid3d/nodeProperty.fs.glsl.d.ts +1 -1
- package/dist/layers/grid3d/nodeProperty.fs.glsl.js +5 -13
- package/dist/layers/grid3d/nodeProperty.fs.glsl.js.map +1 -1
- package/dist/layers/grid3d/nodeProperty.vs.glsl.d.ts +1 -1
- package/dist/layers/grid3d/nodeProperty.vs.glsl.js +3 -7
- package/dist/layers/grid3d/nodeProperty.vs.glsl.js.map +1 -1
- package/dist/layers/grid3d/privateGrid3dLayer.d.ts +26 -5
- package/dist/layers/grid3d/privateGrid3dLayer.js +60 -22
- package/dist/layers/grid3d/privateGrid3dLayer.js.map +1 -1
- package/dist/layers/grid3d/vertex_lines.glsl.d.ts +1 -1
- package/dist/layers/grid3d/vertex_lines.glsl.js +2 -4
- package/dist/layers/grid3d/vertex_lines.glsl.js.map +1 -1
- package/dist/layers/hillshading2d/hillshading2d.fs.glsl.d.ts +1 -1
- package/dist/layers/hillshading2d/hillshading2d.fs.glsl.js +8 -15
- package/dist/layers/hillshading2d/hillshading2d.fs.glsl.js.map +1 -1
- package/dist/layers/hillshading2d/hillshading2dLayer.d.ts +4 -3
- package/dist/layers/hillshading2d/hillshading2dLayer.js +109 -33
- package/dist/layers/hillshading2d/hillshading2dLayer.js.map +1 -1
- package/dist/layers/map/fragment.glsl.d.ts +2 -0
- package/dist/layers/map/{fragment.fs.glsl.js → fragment.glsl.js} +15 -27
- package/dist/layers/map/fragment.glsl.js.map +1 -0
- package/dist/layers/map/fragment_lines.glsl.d.ts +1 -1
- package/dist/layers/map/fragment_lines.glsl.js +1 -1
- package/dist/layers/map/mapLayer.d.ts +1 -1
- package/dist/layers/map/mapLayer.js +2 -0
- package/dist/layers/map/mapLayer.js.map +1 -1
- package/dist/layers/map/privateMapLayer.d.ts +7 -9
- package/dist/layers/map/privateMapLayer.js +85 -17
- package/dist/layers/map/privateMapLayer.js.map +1 -1
- package/dist/layers/map/vertex.glsl.d.ts +1 -1
- package/dist/layers/map/vertex.glsl.js +3 -5
- package/dist/layers/map/vertex.glsl.js.map +1 -1
- package/dist/layers/map/vertex_lines.glsl.d.ts +1 -1
- package/dist/layers/map/vertex_lines.glsl.js +3 -2
- package/dist/layers/map/vertex_lines.glsl.js.map +1 -1
- package/dist/layers/northarrow/northArrow3DLayer.d.ts +1 -1
- package/dist/layers/northarrow/northArrow3DLayer.js +3 -3
- package/dist/layers/northarrow/northArrow3DLayer.js.map +1 -1
- package/dist/layers/northarrow/northarrow-fragment.glsl.d.ts +1 -1
- package/dist/layers/northarrow/northarrow-fragment.glsl.js +1 -1
- package/dist/layers/northarrow/northarrow-vertex.glsl.d.ts +1 -1
- package/dist/layers/northarrow/northarrow-vertex.glsl.js +1 -1
- package/dist/layers/piechart/fragment.glsl.d.ts +1 -1
- package/dist/layers/piechart/fragment.glsl.js +1 -1
- package/dist/layers/piechart/vertex.glsl.d.ts +1 -1
- package/dist/layers/piechart/vertex.glsl.js +1 -1
- package/dist/layers/points/privatePointsLayer.d.ts +1 -9
- package/dist/layers/points/privatePointsLayer.js +32 -5
- package/dist/layers/points/privatePointsLayer.js.map +1 -1
- package/dist/layers/points/vertex.glsl.d.ts +1 -1
- package/dist/layers/points/vertex.glsl.js +13 -28
- package/dist/layers/points/vertex.glsl.js.map +1 -1
- package/dist/layers/polylines/path-layer-fragment.glsl.d.ts +1 -1
- package/dist/layers/polylines/path-layer-fragment.glsl.js +2 -4
- package/dist/layers/polylines/path-layer-fragment.glsl.js.map +1 -1
- package/dist/layers/polylines/path-layer-vertex.glsl.d.ts +1 -1
- package/dist/layers/polylines/path-layer-vertex.glsl.js +10 -22
- package/dist/layers/polylines/path-layer-vertex.glsl.js.map +1 -1
- package/dist/layers/polylines/privatePolylinesLayer.d.ts +2 -44
- package/dist/layers/polylines/privatePolylinesLayer.js +34 -4
- package/dist/layers/polylines/privatePolylinesLayer.js.map +1 -1
- package/dist/layers/shader_modules/index.d.ts +1 -1
- package/dist/layers/shader_modules/index.js +1 -1
- package/dist/layers/shader_modules/index.js.map +1 -1
- package/dist/layers/shader_modules/phong-lighting/phong-material.d.ts +11 -0
- package/dist/layers/shader_modules/phong-lighting/phong-material.js +38 -0
- package/dist/layers/shader_modules/phong-lighting/phong-material.js.map +1 -0
- package/dist/layers/shader_modules/phong-lighting/phong-shaders-glsl.d.ts +2 -0
- package/dist/layers/shader_modules/phong-lighting/phong-shaders-glsl.js +59 -0
- package/dist/layers/shader_modules/phong-lighting/phong-shaders-glsl.js.map +1 -0
- package/dist/layers/triangle/fragment.fs.glsl.d.ts +1 -1
- package/dist/layers/triangle/fragment.fs.glsl.js +7 -14
- package/dist/layers/triangle/fragment.fs.glsl.js.map +1 -1
- package/dist/layers/triangle/fragment_lines.glsl.d.ts +1 -1
- package/dist/layers/triangle/fragment_lines.glsl.js +1 -1
- package/dist/layers/triangle/privateTriangleLayer.d.ts +9 -14
- package/dist/layers/triangle/privateTriangleLayer.js +75 -26
- package/dist/layers/triangle/privateTriangleLayer.js.map +1 -1
- package/dist/layers/triangle/triangleLayer.d.ts +1 -1
- package/dist/layers/triangle/triangleLayer.js +2 -0
- package/dist/layers/triangle/triangleLayer.js.map +1 -1
- package/dist/layers/triangle/vertex.glsl.d.ts +1 -1
- package/dist/layers/triangle/vertex.glsl.js +3 -5
- package/dist/layers/triangle/vertex.glsl.js.map +1 -1
- package/dist/layers/triangle/vertex_lines.glsl.d.ts +1 -1
- package/dist/layers/triangle/vertex_lines.glsl.js +2 -4
- package/dist/layers/triangle/vertex_lines.glsl.js.map +1 -1
- package/dist/layers/utils/layerTools.d.ts +1 -1
- package/dist/layers/utils/layerTools.js +1 -1
- package/dist/layers/utils/layerTools.js.map +1 -1
- package/dist/layers/well_markers/vertex.glsl.d.ts +1 -1
- package/dist/layers/well_markers/vertex.glsl.js +3 -7
- package/dist/layers/well_markers/vertex.glsl.js.map +1 -1
- package/dist/layers/well_markers/wellMarkersLayer.d.ts +3 -8
- package/dist/layers/well_markers/wellMarkersLayer.js +49 -16
- package/dist/layers/well_markers/wellMarkersLayer.js.map +1 -1
- package/dist/views/intersectionView.d.ts +3 -3
- package/dist/views/intersectionView.js +5 -0
- package/dist/views/intersectionView.js.map +1 -1
- package/package.json +11 -11
- package/dist/layers/map/fragment.fs.glsl.d.ts +0 -2
- package/dist/layers/map/fragment.fs.glsl.js.map +0 -1
- package/dist/layers/shader_modules/lighting.fs.glsl.d.ts +0 -1
- package/dist/layers/shader_modules/lighting.fs.glsl.js +0 -45
- package/dist/layers/shader_modules/lighting.fs.glsl.js.map +0 -1
- package/dist/layers/shader_modules/localPhongLighting.d.ts +0 -23
- package/dist/layers/shader_modules/localPhongLighting.js +0 -8
- package/dist/layers/shader_modules/localPhongLighting.js.map +0 -1
@@ -19,12 +19,10 @@
|
|
19
19
|
// THE SOFTWARE.
|
20
20
|
export default `\
|
21
21
|
#version 300 es
|
22
|
-
#define SHADER_NAME
|
22
|
+
#define SHADER_NAME polylines-fragment-shader
|
23
23
|
|
24
24
|
precision highp float;
|
25
25
|
|
26
|
-
uniform float miterLimit;
|
27
|
-
|
28
26
|
in vec4 vColor;
|
29
27
|
in vec2 vCornerOffset;
|
30
28
|
in float vMiterLength;
|
@@ -48,7 +46,7 @@ void main(void) {
|
|
48
46
|
discard;
|
49
47
|
}
|
50
48
|
// trim miter
|
51
|
-
if (vJointType < 0.5 && vMiterLength > miterLimit + 1.0) {
|
49
|
+
if (vJointType < 0.5 && vMiterLength > path.miterLimit + 1.0) {
|
52
50
|
discard;
|
53
51
|
}
|
54
52
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"path-layer-fragment.glsl.js","sourceRoot":"","sources":["../../../src/layers/polylines/path-layer-fragment.glsl.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAC3D,EAAE;AACF,6EAA6E;AAC7E,sDAAsD;AACtD,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,4EAA4E;AAC5E,gBAAgB;AAEhB,eAAe
|
1
|
+
{"version":3,"file":"path-layer-fragment.glsl.js","sourceRoot":"","sources":["../../../src/layers/polylines/path-layer-fragment.glsl.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAC3D,EAAE;AACF,6EAA6E;AAC7E,sDAAsD;AACtD,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,4EAA4E;AAC5E,gBAAgB;AAEhB,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCd,CAAC"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
declare const _default: "#version 300 es\n#define SHADER_NAME
|
1
|
+
declare const _default: "#version 300 es\n#define SHADER_NAME polylines-vertex-shader\n\nin vec2 positions;\n\nin float instanceTypes;\nin vec3 instanceStartPositions;\nin vec3 instanceEndPositions;\nin vec3 instanceLeftPositions;\nin vec3 instanceRightPositions;\nin vec3 instanceLeftPositions64Low;\nin vec3 instanceStartPositions64Low;\nin vec3 instanceEndPositions64Low;\nin vec3 instanceRightPositions64Low;\nin float instanceStrokeWidths;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\n\nout vec4 vColor;\nout vec2 vCornerOffset;\nout float vMiterLength;\nout vec2 vPathPosition;\nout float vPathLength;\nout float vJointType;\n\nconst float EPSILON = 0.001;\nconst vec3 ZERO_OFFSET = vec3(0.0);\n\nfloat flipIfTrue(bool flag) {\n return -(float(flag) * 2. - 1.);\n}\n\n// calculate line join positions\nvec3 getLineJoinOffset(\n vec3 prevPoint, vec3 currPoint, vec3 nextPoint,\n vec2 width\n) {\n bool isEnd = positions.x > 0.0;\n // side of the segment - -1: left, 0: center, 1: right\n float sideOfPath = positions.y;\n float isJoint = float(sideOfPath == 0.0);\n\n vec3 deltaA3 = (currPoint - prevPoint);\n vec3 deltaB3 = (nextPoint - currPoint);\n\n mat3 rotationMatrix;\n bool needsRotation = !path.billboard && project_needs_rotation(currPoint, rotationMatrix);\n if (needsRotation) {\n deltaA3 = deltaA3 * rotationMatrix;\n deltaB3 = deltaB3 * rotationMatrix;\n }\n vec2 deltaA = deltaA3.xy / width;\n vec2 deltaB = deltaB3.xy / width;\n\n float lenA = length(deltaA);\n float lenB = length(deltaB);\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 = dirA + dirB;\n tangent = length(tangent) > 0. ? normalize(tangent) : perpA;\n // direction of the corner\n vec2 miterVec = vec2(-tangent.y, tangent.x);\n // direction of the segment\n vec2 dir = isEnd ? dirA : dirB;\n // direction of the extrusion\n vec2 perp = isEnd ? perpA : perpB;\n // length of the segment\n float L = isEnd ? lenA : lenB;\n\n // A = angle of the corner\n float sinHalfA = abs(dot(miterVec, perp));\n float cosHalfA = abs(dot(dirA, miterVec));\n\n // -1: right, 1: left\n float turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x);\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 float cornerPosition = sideOfPath * turnDirection;\n\n float miterSize = 1.0 / max(sinHalfA, EPSILON);\n // trim if inside corner extends further than the line segment\n miterSize = mix(\n min(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)),\n miterSize,\n step(0.0, cornerPosition)\n );\n\n vec2 offsetVec = mix(miterVec * miterSize, perp, step(0.5, cornerPosition))\n * (sideOfPath + isJoint * turnDirection);\n\n // special treatment for start cap and end cap\n bool isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0));\n bool isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0));\n bool isCap = isStartCap || isEndCap;\n\n // extend out a triangle to envelope the round cap\n if (isCap) {\n offsetVec = mix(perp * sideOfPath, dir * path.capType * 4.0 * flipIfTrue(isStartCap), isJoint);\n vJointType = path.capType;\n } else {\n vJointType = path.jointType;\n }\n\n // Generate variables for fragment shader\n vPathLength = L;\n vCornerOffset = offsetVec;\n vMiterLength = dot(vCornerOffset, miterVec * turnDirection);\n vMiterLength = isCap ? isJoint : vMiterLength;\n\n vec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd);\n vPathPosition = vec2(\n dot(offsetFromStartOfPath, perp),\n dot(offsetFromStartOfPath, dir)\n );\n geometry.uv = vPathPosition;\n\n float isValid = step(instanceTypes, 3.5);\n vec3 offset = vec3(offsetVec * width * isValid, 0.0);\n\n if (needsRotation) {\n offset = rotationMatrix * offset;\n }\n return offset;\n}\n\n// In clipspace extrusion, if a line extends behind the camera, clip it to avoid visual artifacts\nvoid clipLine(inout vec4 position, vec4 refPosition) {\n if (position.w < EPSILON) {\n float r = (EPSILON - refPosition.w) / (position.w - refPosition.w);\n position = refPosition + (position - refPosition) * r;\n }\n}\n\nvoid main() {\n geometry.pickingColor = instancePickingColors;\n\n vColor = vec4(instanceColors.rgb, instanceColors.a * polylines.opacity);\n vec3 leftPosition = instanceLeftPositions;\n vec3 startPosition = instanceStartPositions;\n vec3 leftPos64Low = instanceLeftPositions64Low;\n vec3 startPos64Low = instanceStartPositions64Low;\n\n vec3 rightposition = instanceRightPositions;\n vec3 endPosition = instanceEndPositions;\n vec3 rightPos64Low = instanceRightPositions64Low;\n vec3 endPos64Low = instanceEndPositions64Low;\n\n if(polylines.ZIncreasingDownwards) {\n leftPosition.z *= -1.0;\n startPosition.z *= -1.0;\n leftPos64Low.z *= -1.0;\n startPos64Low.z *= -1.0;\n rightposition.z *= -1.0;\n endPosition.z *= -1.0;\n rightPos64Low.z *= -1.0;\n endPos64Low.z *= -1.0; \n }\n\n float isEnd = positions.x;\n\n vec3 prevPosition = mix(leftPosition, startPosition, isEnd);\n vec3 prevPosition64Low = mix(leftPos64Low, startPos64Low, isEnd);\n\n vec3 currPosition = mix(startPosition, endPosition, isEnd);\n vec3 currPosition64Low = mix(startPos64Low, endPos64Low, isEnd);\n\n vec3 nextPosition = mix(endPosition, rightposition, isEnd);\n vec3 nextPosition64Low = mix(endPos64Low, rightPos64Low, isEnd);\n\n geometry.worldPosition = currPosition;\n vec2 widthPixels = vec2(clamp(\n project_size_to_pixel(instanceStrokeWidths * path.widthScale, path.widthUnits),\n path.widthMinPixels, path.widthMaxPixels) / 2.0);\n vec3 width;\n\n if (path.billboard) {\n // Extrude in clipspace\n vec4 prevPositionScreen = project_position_to_clipspace(prevPosition, prevPosition64Low, ZERO_OFFSET);\n vec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position);\n vec4 nextPositionScreen = project_position_to_clipspace(nextPosition, nextPosition64Low, ZERO_OFFSET);\n\n clipLine(prevPositionScreen, currPositionScreen);\n clipLine(nextPositionScreen, currPositionScreen);\n clipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd));\n\n width = vec3(widthPixels, 0.0);\n DECKGL_FILTER_SIZE(width, geometry);\n\n vec3 offset = getLineJoinOffset(\n prevPositionScreen.xyz / prevPositionScreen.w,\n currPositionScreen.xyz / currPositionScreen.w,\n nextPositionScreen.xyz / nextPositionScreen.w,\n project_pixel_size_to_clipspace(width.xy)\n );\n\n DECKGL_FILTER_GL_POSITION(currPositionScreen, geometry);\n gl_Position = vec4(currPositionScreen.xyz + offset * currPositionScreen.w, currPositionScreen.w);\n } else {\n // Extrude in commonspace\n prevPosition = project_position(prevPosition, prevPosition64Low);\n currPosition = project_position(currPosition, currPosition64Low);\n nextPosition = project_position(nextPosition, nextPosition64Low);\n\n width = vec3(project_pixel_size(widthPixels), 0.0);\n DECKGL_FILTER_SIZE(width, geometry);\n\n vec3 offset = getLineJoinOffset(prevPosition, currPosition, nextPosition, width.xy);\n geometry.position = vec4(currPosition + offset, 1.0);\n gl_Position = project_common_position_to_clipspace(geometry.position);\n DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n }\n DECKGL_FILTER_COLOR(vColor, geometry);\n}\n";
|
2
2
|
export default _default;
|
@@ -19,7 +19,7 @@
|
|
19
19
|
// THE SOFTWARE.
|
20
20
|
export default `\
|
21
21
|
#version 300 es
|
22
|
-
#define SHADER_NAME
|
22
|
+
#define SHADER_NAME polylines-vertex-shader
|
23
23
|
|
24
24
|
in vec2 positions;
|
25
25
|
|
@@ -36,18 +36,6 @@ in float instanceStrokeWidths;
|
|
36
36
|
in vec4 instanceColors;
|
37
37
|
in vec3 instancePickingColors;
|
38
38
|
|
39
|
-
uniform float widthScale;
|
40
|
-
uniform float widthMinPixels;
|
41
|
-
uniform float widthMaxPixels;
|
42
|
-
uniform float jointType;
|
43
|
-
uniform float capType;
|
44
|
-
uniform float miterLimit;
|
45
|
-
uniform bool billboard;
|
46
|
-
uniform int widthUnits;
|
47
|
-
|
48
|
-
uniform float opacity;
|
49
|
-
uniform bool ZIncreasingDownwards;
|
50
|
-
|
51
39
|
out vec4 vColor;
|
52
40
|
out vec2 vCornerOffset;
|
53
41
|
out float vMiterLength;
|
@@ -76,7 +64,7 @@ vec3 getLineJoinOffset(
|
|
76
64
|
vec3 deltaB3 = (nextPoint - currPoint);
|
77
65
|
|
78
66
|
mat3 rotationMatrix;
|
79
|
-
bool needsRotation = !billboard && project_needs_rotation(currPoint, rotationMatrix);
|
67
|
+
bool needsRotation = !path.billboard && project_needs_rotation(currPoint, rotationMatrix);
|
80
68
|
if (needsRotation) {
|
81
69
|
deltaA3 = deltaA3 * rotationMatrix;
|
82
70
|
deltaB3 = deltaB3 * rotationMatrix;
|
@@ -136,10 +124,10 @@ vec3 getLineJoinOffset(
|
|
136
124
|
|
137
125
|
// extend out a triangle to envelope the round cap
|
138
126
|
if (isCap) {
|
139
|
-
offsetVec = mix(perp * sideOfPath, dir * capType * 4.0 * flipIfTrue(isStartCap), isJoint);
|
140
|
-
vJointType = capType;
|
127
|
+
offsetVec = mix(perp * sideOfPath, dir * path.capType * 4.0 * flipIfTrue(isStartCap), isJoint);
|
128
|
+
vJointType = path.capType;
|
141
129
|
} else {
|
142
|
-
vJointType = jointType;
|
130
|
+
vJointType = path.jointType;
|
143
131
|
}
|
144
132
|
|
145
133
|
// Generate variables for fragment shader
|
@@ -175,7 +163,7 @@ void clipLine(inout vec4 position, vec4 refPosition) {
|
|
175
163
|
void main() {
|
176
164
|
geometry.pickingColor = instancePickingColors;
|
177
165
|
|
178
|
-
vColor = vec4(instanceColors.rgb, instanceColors.a * opacity);
|
166
|
+
vColor = vec4(instanceColors.rgb, instanceColors.a * polylines.opacity);
|
179
167
|
vec3 leftPosition = instanceLeftPositions;
|
180
168
|
vec3 startPosition = instanceStartPositions;
|
181
169
|
vec3 leftPos64Low = instanceLeftPositions64Low;
|
@@ -186,7 +174,7 @@ void main() {
|
|
186
174
|
vec3 rightPos64Low = instanceRightPositions64Low;
|
187
175
|
vec3 endPos64Low = instanceEndPositions64Low;
|
188
176
|
|
189
|
-
if(ZIncreasingDownwards) {
|
177
|
+
if(polylines.ZIncreasingDownwards) {
|
190
178
|
leftPosition.z *= -1.0;
|
191
179
|
startPosition.z *= -1.0;
|
192
180
|
leftPos64Low.z *= -1.0;
|
@@ -210,11 +198,11 @@ void main() {
|
|
210
198
|
|
211
199
|
geometry.worldPosition = currPosition;
|
212
200
|
vec2 widthPixels = vec2(clamp(
|
213
|
-
project_size_to_pixel(instanceStrokeWidths * widthScale, widthUnits),
|
214
|
-
widthMinPixels, widthMaxPixels) / 2.0);
|
201
|
+
project_size_to_pixel(instanceStrokeWidths * path.widthScale, path.widthUnits),
|
202
|
+
path.widthMinPixels, path.widthMaxPixels) / 2.0);
|
215
203
|
vec3 width;
|
216
204
|
|
217
|
-
if (billboard) {
|
205
|
+
if (path.billboard) {
|
218
206
|
// Extrude in clipspace
|
219
207
|
vec4 prevPositionScreen = project_position_to_clipspace(prevPosition, prevPosition64Low, ZERO_OFFSET);
|
220
208
|
vec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"path-layer-vertex.glsl.js","sourceRoot":"","sources":["../../../src/layers/polylines/path-layer-vertex.glsl.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAC3D,EAAE;AACF,6EAA6E;AAC7E,sDAAsD;AACtD,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,4EAA4E;AAC5E,gBAAgB;AAEhB,eAAe
|
1
|
+
{"version":3,"file":"path-layer-vertex.glsl.js","sourceRoot":"","sources":["../../../src/layers/polylines/path-layer-vertex.glsl.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAC3D,EAAE;AACF,6EAA6E;AAC7E,sDAAsD;AACtD,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,4EAA4E;AAC5E,gBAAgB;AAEhB,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+Nd,CAAC"}
|
@@ -1,53 +1,11 @@
|
|
1
1
|
import type { PathLayerProps } from "@deck.gl/layers";
|
2
2
|
import { PathLayer } from "@deck.gl/layers";
|
3
|
-
import type { NumericArray } from "@math.gl/types";
|
4
|
-
import type { LayerContext } from "@deck.gl/core";
|
5
|
-
type UniformValue = number | boolean | Readonly<NumericArray>;
|
6
3
|
export interface ExtendedPathLayerProps {
|
7
4
|
depthTest?: boolean;
|
8
5
|
ZIncreasingDownwards: boolean;
|
9
6
|
}
|
10
7
|
export declare class PrivatePolylinesLayer extends PathLayer<unknown, ExtendedPathLayerProps> {
|
11
8
|
constructor(props: PathLayerProps);
|
12
|
-
getShaders():
|
13
|
-
|
14
|
-
fs: string;
|
15
|
-
modules: (import("@luma.gl/shadertools").ShaderModule | {
|
16
|
-
defaultUniforms: {
|
17
|
-
useFloatColors: boolean;
|
18
|
-
isActive?: boolean | undefined;
|
19
|
-
isAttribute?: boolean | undefined;
|
20
|
-
isHighlightActive?: boolean | undefined;
|
21
|
-
highlightedObjectColor?: import("@luma.gl/shadertools/dist/lib/utils/uniform-types").NumberArray3 | undefined;
|
22
|
-
highlightColor?: import("@luma.gl/shadertools/dist/lib/utils/uniform-types").NumberArray4 | undefined;
|
23
|
-
};
|
24
|
-
inject: {
|
25
|
-
'vs:DECKGL_FILTER_GL_POSITION': string;
|
26
|
-
'vs:DECKGL_FILTER_COLOR': string;
|
27
|
-
'fs:DECKGL_FILTER_COLOR': {
|
28
|
-
order: number;
|
29
|
-
injection: string;
|
30
|
-
};
|
31
|
-
};
|
32
|
-
props?: Required<import("@luma.gl/shadertools").PickingProps> | undefined;
|
33
|
-
uniforms?: import("@luma.gl/shadertools/dist/modules/engine/picking/picking").PickingUniforms | undefined;
|
34
|
-
bindings?: import("@luma.gl/shadertools/dist/lib/shader-module/shader-module").PickBindings<import("@luma.gl/shadertools").PickingProps> | undefined;
|
35
|
-
name: string;
|
36
|
-
fs?: string | undefined;
|
37
|
-
vs?: string | undefined;
|
38
|
-
uniformTypes?: Required<import("@luma.gl/shadertools/dist/lib/utils/uniform-types").UniformTypes<import("@luma.gl/shadertools/dist/modules/engine/picking/picking").PickingUniforms>> | undefined;
|
39
|
-
uniformPropTypes?: Record<keyof import("@luma.gl/shadertools/dist/modules/engine/picking/picking").PickingUniforms, import("@luma.gl/shadertools/dist/lib/shader-module/shader-module").UniformInfo> | undefined;
|
40
|
-
getUniforms?: ((props?: Partial<import("@luma.gl/shadertools").PickingProps> | undefined, prevUniforms?: import("@luma.gl/shadertools/dist/modules/engine/picking/picking").PickingUniforms | undefined) => Partial<import("@luma.gl/shadertools/dist/modules/engine/picking/picking").PickingUniforms & import("@luma.gl/shadertools/dist/lib/shader-module/shader-module").PickBindings<import("@luma.gl/shadertools").PickingProps>>) | undefined;
|
41
|
-
defines?: Record<string, string | number> | undefined;
|
42
|
-
dependencies?: import("@luma.gl/shadertools").ShaderModule<any, any, import("@luma.gl/shadertools/dist/lib/shader-module/shader-module").PickBindings<any>>[] | undefined;
|
43
|
-
deprecations?: import("@luma.gl/shadertools/dist/lib/shader-module/shader-module").ShaderModuleDeprecation[] | undefined;
|
44
|
-
normalized?: boolean | undefined;
|
45
|
-
})[];
|
46
|
-
};
|
47
|
-
draw(args: {
|
48
|
-
moduleParameters?: unknown;
|
49
|
-
uniforms: Record<string, UniformValue>;
|
50
|
-
context: LayerContext;
|
51
|
-
}): void;
|
9
|
+
getShaders(): any;
|
10
|
+
draw(args: any): void;
|
52
11
|
}
|
53
|
-
export {};
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { PathLayer } from "@deck.gl/layers";
|
2
|
-
import { picking, project32 } from "@deck.gl/core";
|
3
2
|
import fs from "./path-layer-fragment.glsl";
|
4
3
|
import vs from "./path-layer-vertex.glsl";
|
5
4
|
export class PrivatePolylinesLayer extends PathLayer {
|
@@ -7,10 +6,18 @@ export class PrivatePolylinesLayer extends PathLayer {
|
|
7
6
|
super(props);
|
8
7
|
}
|
9
8
|
getShaders() {
|
10
|
-
|
9
|
+
const superShaders = super.getShaders();
|
10
|
+
// use object.assign to make sure we don't overwrite existing fields like `vs`, `modules`...
|
11
|
+
return Object.assign({}, superShaders, {
|
12
|
+
vs: vs,
|
13
|
+
fs: fs,
|
14
|
+
modules: [...superShaders.modules, polylinesUniforms],
|
15
|
+
});
|
11
16
|
}
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
12
18
|
draw(args) {
|
13
|
-
|
19
|
+
var _a;
|
20
|
+
//conf g = context.device.getDefaultCanvasContext();
|
14
21
|
const { gl } = this.context;
|
15
22
|
let restoreDepthTest = false;
|
16
23
|
if (typeof this.props.depthTest === "boolean" &&
|
@@ -18,11 +25,34 @@ export class PrivatePolylinesLayer extends PathLayer {
|
|
18
25
|
restoreDepthTest = true;
|
19
26
|
gl.disable(gl.DEPTH_TEST);
|
20
27
|
}
|
21
|
-
|
28
|
+
// inject the local uniforms into the shader
|
29
|
+
(_a = this.state.model) === null || _a === void 0 ? void 0 : _a.shaderInputs.setProps({
|
30
|
+
polylines: {
|
31
|
+
opacity: this.props.opacity,
|
32
|
+
ZIncreasingDownwards: this.props.ZIncreasingDownwards,
|
33
|
+
},
|
34
|
+
});
|
35
|
+
super.draw(args.uniforms);
|
22
36
|
if (restoreDepthTest) {
|
23
37
|
gl.enable(gl.DEPTH_TEST);
|
24
38
|
}
|
25
39
|
}
|
26
40
|
}
|
27
41
|
PrivatePolylinesLayer.layerName = "PrivatePolylinesLayer";
|
42
|
+
const polylinesUniformsBlock = /*glsl*/ `\
|
43
|
+
uniform polylinesUniforms {
|
44
|
+
float opacity;
|
45
|
+
bool ZIncreasingDownwards;
|
46
|
+
} polylines;
|
47
|
+
`;
|
48
|
+
// NOTE: this must exactly the same name than in the uniform block
|
49
|
+
const polylinesUniforms = {
|
50
|
+
name: "polylines",
|
51
|
+
vs: polylinesUniformsBlock,
|
52
|
+
fs: undefined,
|
53
|
+
uniformTypes: {
|
54
|
+
opacity: "f32",
|
55
|
+
ZIncreasingDownwards: "u32",
|
56
|
+
},
|
57
|
+
};
|
28
58
|
//# sourceMappingURL=privatePolylinesLayer.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"privatePolylinesLayer.js","sourceRoot":"","sources":["../../../src/layers/polylines/privatePolylinesLayer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5C,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"privatePolylinesLayer.js","sourceRoot":"","sources":["../../../src/layers/polylines/privatePolylinesLayer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5C,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAC5C,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAO1C,MAAM,OAAO,qBAAsB,SAAQ,SAG1C;IACG,YAAY,KAAqB;QAC7B,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED,UAAU;QACN,MAAM,YAAY,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC;QACxC,4FAA4F;QAC5F,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,YAAY,EAAE;YACnC,EAAE,EAAE,EAAE;YACN,EAAE,EAAE,EAAE;YACN,OAAO,EAAE,CAAC,GAAG,YAAY,CAAC,OAAO,EAAE,iBAAiB,CAAC;SACxD,CAAC,CAAC;IACP,CAAC;IAED,8DAA8D;IAC9D,IAAI,CAAC,IAAS;;QACV,oDAAoD;QACpD,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAE5B,IAAI,gBAAgB,GAAG,KAAK,CAAC;QAC7B,IACI,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS;YACzC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,EACvB,CAAC;YACC,gBAAgB,GAAG,IAAI,CAAC;YACxB,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;QAC9B,CAAC;QACD,4CAA4C;QAC5C,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,0CAAE,YAAY,CAAC,QAAQ,CAAC;YACpC,SAAS,EAAE;gBACP,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;gBAC3B,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,oBAAoB;aACxD;SACJ,CAAC,CAAC;QACH,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1B,IAAI,gBAAgB,EAAE,CAAC;YACnB,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;QAC7B,CAAC;IACL,CAAC;CACJ;AAED,qBAAqB,CAAC,SAAS,GAAG,uBAAuB,CAAC;AAE1D,MAAM,sBAAsB,GAAG,QAAQ,CAAC;;;;;CAKvC,CAAC;AAOF,kEAAkE;AAClE,MAAM,iBAAiB,GAAG;IACtB,IAAI,EAAE,WAAW;IACjB,EAAE,EAAE,sBAAsB;IAC1B,EAAE,EAAE,SAAS;IACb,YAAY,EAAE;QACV,OAAO,EAAE,KAAK;QACd,oBAAoB,EAAE,KAAK;KAC9B;CAC+D,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/layers/shader_modules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/layers/shader_modules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import type { NumberArray3 } from "@math.gl/types";
|
2
|
+
import type { ShaderModule } from "@luma.gl/shadertools";
|
3
|
+
export type PhongMaterialProps = {
|
4
|
+
ambient?: number;
|
5
|
+
diffuse?: number;
|
6
|
+
/** Specularity exponent */
|
7
|
+
shininess?: number;
|
8
|
+
specularColor?: NumberArray3;
|
9
|
+
};
|
10
|
+
/** In Phong shading, the normal vector is linearly interpolated across the surface of the polygon from the polygon's vertex normals. */
|
11
|
+
export declare const phongMaterial: ShaderModule<PhongMaterialProps>;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
// luma.gl
|
2
|
+
// SPDX-License-Identifier: MIT
|
3
|
+
// Copyright (c) vis.gl contributors
|
4
|
+
import { lighting } from "@luma.gl/shadertools";
|
5
|
+
import { PHONG_VS, PHONG_FS } from "./phong-shaders-glsl";
|
6
|
+
/** In Phong shading, the normal vector is linearly interpolated across the surface of the polygon from the polygon's vertex normals. */
|
7
|
+
export const phongMaterial = {
|
8
|
+
name: "phongMaterial",
|
9
|
+
dependencies: [lighting],
|
10
|
+
// Note these are switched between phong and gouraud
|
11
|
+
vs: PHONG_VS,
|
12
|
+
fs: PHONG_FS,
|
13
|
+
defines: {
|
14
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
15
|
+
// @ts-expect-error
|
16
|
+
LIGHTING_FRAGMENT: true,
|
17
|
+
},
|
18
|
+
uniformTypes: {
|
19
|
+
ambient: "f32",
|
20
|
+
diffuse: "f32",
|
21
|
+
shininess: "f32",
|
22
|
+
specularColor: "vec3<f32>",
|
23
|
+
},
|
24
|
+
defaultUniforms: {
|
25
|
+
ambient: 0.35,
|
26
|
+
diffuse: 0.6,
|
27
|
+
shininess: 32,
|
28
|
+
specularColor: [0.15, 0.15, 0.15],
|
29
|
+
},
|
30
|
+
getUniforms(props) {
|
31
|
+
const uniforms = Object.assign({}, props);
|
32
|
+
if (uniforms.specularColor) {
|
33
|
+
uniforms.specularColor = uniforms.specularColor.map((x) => x / 255);
|
34
|
+
}
|
35
|
+
return Object.assign(Object.assign({}, phongMaterial.defaultUniforms), uniforms);
|
36
|
+
},
|
37
|
+
};
|
38
|
+
//# sourceMappingURL=phong-material.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"phong-material.js","sourceRoot":"","sources":["../../../../src/layers/shader_modules/phong-lighting/phong-material.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AASpC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAU1D,wIAAwI;AACxI,MAAM,CAAC,MAAM,aAAa,GAAqC;IAC3D,IAAI,EAAE,eAAe;IACrB,YAAY,EAAE,CAAC,QAAQ,CAAC;IACxB,oDAAoD;IACpD,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,QAAQ;IACZ,OAAO,EAAE;QACL,6DAA6D;QAC7D,mBAAmB;QACnB,iBAAiB,EAAE,IAAI;KAC1B;IACD,YAAY,EAAE;QACV,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,KAAK;QAChB,aAAa,EAAE,WAAW;KAC7B;IACD,eAAe,EAAE;QACb,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,GAAG;QACZ,SAAS,EAAE,EAAE;QACb,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;KACpC;IACD,WAAW,CAAC,KAA0B;QAClC,MAAM,QAAQ,qBAAQ,KAAK,CAAE,CAAC;QAC9B,IAAI,QAAQ,CAAC,aAAa,EAAE,CAAC;YACzB,QAAQ,CAAC,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAC/C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,CACD,CAAC;QACtB,CAAC;QACD,uCAAY,aAAa,CAAC,eAAe,GAAK,QAAQ,EAAG;IAC7D,CAAC;CACJ,CAAC"}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
export declare const PHONG_VS = "uniform phongMaterialUniforms {\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n";
|
2
|
+
export declare const PHONG_FS = "\nuniform phongMaterialUniforms {\n uniform float ambient;\n uniform float diffuse;\n uniform float shininess;\n uniform vec3 specularColor;\n} material;\n\n// Note modified for two sided lighing.\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\n vec3 halfway_direction = normalize(light_direction + view_direction); \n\n float lambertian = abs(dot(light_direction, normal_worldspace));\n float specular_angle = abs(dot(normal_worldspace, halfway_direction));\n\n float specular = pow(specular_angle, material.shininess); \n return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;\n}\n\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\n vec3 lightColor = surfaceColor;\n\n if (lighting.enabled == 0) {\n return lightColor;\n }\n\n vec3 view_direction = normalize(cameraPosition - position_worldspace);\n lightColor = material.ambient * surfaceColor * lighting.ambientColor;\n\n for (int i = 0; i < lighting.pointLightCount; i++) {\n PointLight pointLight = lighting_getPointLight(i);\n vec3 light_position_worldspace = pointLight.position;\n vec3 light_direction = normalize(light_position_worldspace - position_worldspace);\n float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace));\n lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);\n }\n\n int totalLights = min(MAX_LIGHTS, lighting.pointLightCount + lighting.directionalLightCount);\n for (int i = lighting.pointLightCount; i < totalLights; i++) {\n DirectionalLight directionalLight = lighting_getDirectionalLight(i);\n lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n }\n \n return lightColor;\n}\n";
|
@@ -0,0 +1,59 @@
|
|
1
|
+
// luma.gl
|
2
|
+
// SPDX-License-Identifier: MIT
|
3
|
+
// Copyright (c) vis.gl contributors
|
4
|
+
export const PHONG_VS = /* glsl */ `\
|
5
|
+
uniform phongMaterialUniforms {
|
6
|
+
uniform float ambient;
|
7
|
+
uniform float diffuse;
|
8
|
+
uniform float shininess;
|
9
|
+
uniform vec3 specularColor;
|
10
|
+
} material;
|
11
|
+
`;
|
12
|
+
export const PHONG_FS = /* glsl */ `\
|
13
|
+
|
14
|
+
uniform phongMaterialUniforms {
|
15
|
+
uniform float ambient;
|
16
|
+
uniform float diffuse;
|
17
|
+
uniform float shininess;
|
18
|
+
uniform vec3 specularColor;
|
19
|
+
} material;
|
20
|
+
|
21
|
+
// Note modified for two sided lighing.
|
22
|
+
vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {
|
23
|
+
vec3 halfway_direction = normalize(light_direction + view_direction);
|
24
|
+
|
25
|
+
float lambertian = abs(dot(light_direction, normal_worldspace));
|
26
|
+
float specular_angle = abs(dot(normal_worldspace, halfway_direction));
|
27
|
+
|
28
|
+
float specular = pow(specular_angle, material.shininess);
|
29
|
+
return (lambertian * material.diffuse * surfaceColor + specular * material.specularColor) * color;
|
30
|
+
}
|
31
|
+
|
32
|
+
vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {
|
33
|
+
vec3 lightColor = surfaceColor;
|
34
|
+
|
35
|
+
if (lighting.enabled == 0) {
|
36
|
+
return lightColor;
|
37
|
+
}
|
38
|
+
|
39
|
+
vec3 view_direction = normalize(cameraPosition - position_worldspace);
|
40
|
+
lightColor = material.ambient * surfaceColor * lighting.ambientColor;
|
41
|
+
|
42
|
+
for (int i = 0; i < lighting.pointLightCount; i++) {
|
43
|
+
PointLight pointLight = lighting_getPointLight(i);
|
44
|
+
vec3 light_position_worldspace = pointLight.position;
|
45
|
+
vec3 light_direction = normalize(light_position_worldspace - position_worldspace);
|
46
|
+
float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace));
|
47
|
+
lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation);
|
48
|
+
}
|
49
|
+
|
50
|
+
int totalLights = min(MAX_LIGHTS, lighting.pointLightCount + lighting.directionalLightCount);
|
51
|
+
for (int i = lighting.pointLightCount; i < totalLights; i++) {
|
52
|
+
DirectionalLight directionalLight = lighting_getDirectionalLight(i);
|
53
|
+
lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);
|
54
|
+
}
|
55
|
+
|
56
|
+
return lightColor;
|
57
|
+
}
|
58
|
+
`;
|
59
|
+
//# sourceMappingURL=phong-shaders-glsl.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"phong-shaders-glsl.js","sourceRoot":"","sources":["../../../../src/layers/shader_modules/phong-lighting/phong-shaders-glsl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;;;;;;;CAOlC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8ClC,CAAC"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
declare const fsShader = "#version 300 es\n#define SHADER_NAME
|
1
|
+
declare const fsShader = "#version 300 es\n#define SHADER_NAME triangle-fragment-shader\n\nprecision highp float;\n\nin vec2 vTexCoord;\nin vec3 cameraPosition;\nin vec3 normals_commonspace;\nin vec4 position_commonspace;\nin vec3 worldPos;\nin float property;\n\nout vec4 fragColor;\n\nvoid main(void) {\n vec3 normal = normals_commonspace;\n\n if (!triangles.smoothShading) {\n normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\n } \n\n vec4 color = triangles.uColor;\n bool is_contours = triangles.contourReferencePoint != -1.0 && triangles.contourInterval != -1.0;\n if (is_contours) {\n // Contours are made of either depths or properties.\n float val = (abs(worldPos.z) - triangles.contourReferencePoint) / triangles.contourInterval;\n\n float f = fract(val);\n float df = fwidth(val);\n\n // keep: float c = smoothstep(df * 1.0, df * 2.0, f); // smoothstep from/to no of pixels distance from contour line.\n float c = smoothstep(0.0, df * 2.0, f);\n\n color = color * vec4(c, c, c, 1.0);\n }\n\n // Use two sided phong lighting. This has no effect if \"material\" property is not set.\n vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);\n fragColor = vec4(lightColor, 1.0);\n DECKGL_FILTER_COLOR(fragColor, geometry);\n}\n";
|
2
2
|
export default fsShader;
|
@@ -1,12 +1,8 @@
|
|
1
1
|
const fsShader = `#version 300 es
|
2
|
-
#define SHADER_NAME
|
2
|
+
#define SHADER_NAME triangle-fragment-shader
|
3
3
|
|
4
4
|
precision highp float;
|
5
5
|
|
6
|
-
uniform bool isContoursDepth;
|
7
|
-
uniform float contourReferencePoint;
|
8
|
-
uniform float contourInterval;
|
9
|
-
|
10
6
|
in vec2 vTexCoord;
|
11
7
|
in vec3 cameraPosition;
|
12
8
|
in vec3 normals_commonspace;
|
@@ -14,35 +10,32 @@ in vec4 position_commonspace;
|
|
14
10
|
in vec3 worldPos;
|
15
11
|
in float property;
|
16
12
|
|
17
|
-
uniform vec4 uColor;
|
18
|
-
uniform bool smoothShading;
|
19
|
-
|
20
13
|
out vec4 fragColor;
|
21
14
|
|
22
15
|
void main(void) {
|
23
16
|
vec3 normal = normals_commonspace;
|
24
17
|
|
25
|
-
if (!smoothShading) {
|
18
|
+
if (!triangles.smoothShading) {
|
26
19
|
normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
|
27
20
|
}
|
28
21
|
|
29
|
-
vec4 color = uColor;
|
30
|
-
bool is_contours = contourReferencePoint != -1.0 && contourInterval != -1.0;
|
22
|
+
vec4 color = triangles.uColor;
|
23
|
+
bool is_contours = triangles.contourReferencePoint != -1.0 && triangles.contourInterval != -1.0;
|
31
24
|
if (is_contours) {
|
32
25
|
// Contours are made of either depths or properties.
|
33
|
-
float val = (abs(worldPos.z) - contourReferencePoint) / contourInterval;
|
26
|
+
float val = (abs(worldPos.z) - triangles.contourReferencePoint) / triangles.contourInterval;
|
34
27
|
|
35
28
|
float f = fract(val);
|
36
29
|
float df = fwidth(val);
|
37
30
|
|
38
|
-
// keep: float c = smoothstep(df * 1.0, df * 2.0, f); //
|
31
|
+
// keep: float c = smoothstep(df * 1.0, df * 2.0, f); // smoothstep from/to no of pixels distance from contour line.
|
39
32
|
float c = smoothstep(0.0, df * 2.0, f);
|
40
33
|
|
41
34
|
color = color * vec4(c, c, c, 1.0);
|
42
35
|
}
|
43
36
|
|
44
37
|
// Use two sided phong lighting. This has no effect if "material" property is not set.
|
45
|
-
vec3 lightColor =
|
38
|
+
vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);
|
46
39
|
fragColor = vec4(lightColor, 1.0);
|
47
40
|
DECKGL_FILTER_COLOR(fragColor, geometry);
|
48
41
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fragment.fs.glsl.js","sourceRoot":"","sources":["../../../src/layers/triangle/fragment.fs.glsl.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG
|
1
|
+
{"version":3,"file":"fragment.fs.glsl.js","sourceRoot":"","sources":["../../../src/layers/triangle/fragment.fs.glsl.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyChB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
declare const fragmentShader = "#version 300 es\n#define SHADER_NAME
|
1
|
+
declare const fragmentShader = "#version 300 es\n#define SHADER_NAME triangle-lines-fragment-shader\n\nprecision highp float;\n\nout vec4 fragColor;\n\nvoid main(void) {\n\n // Picking pass.\n if (picking.isActive > 0.5) {\n discard;\n return;\n }\n\n fragColor = vec4(0.0, 0.0, 0.0, 1.0);\n}\n";
|
2
2
|
export default fragmentShader;
|
@@ -1,7 +1,8 @@
|
|
1
|
-
import type {
|
1
|
+
import type { PickingInfo, UpdateParameters } from "@deck.gl/core";
|
2
2
|
import { Layer } from "@deck.gl/core";
|
3
3
|
import type { GeometryProps } from "@luma.gl/engine";
|
4
|
-
import
|
4
|
+
import { Model } from "@luma.gl/engine";
|
5
|
+
import type { Device } from "@luma.gl/core";
|
5
6
|
import type { DeckGLLayerContext } from "../../components/Map";
|
6
7
|
import type { ExtendedLayerProps, LayerPickInfo } from "../utils/layerTools";
|
7
8
|
export type GeometryTriangles = {
|
@@ -40,12 +41,6 @@ export type GeometryLines = {
|
|
40
41
|
};
|
41
42
|
vertexCount: number;
|
42
43
|
};
|
43
|
-
export type Material = {
|
44
|
-
ambient: number;
|
45
|
-
diffuse: number;
|
46
|
-
shininess: number;
|
47
|
-
specularColor: [number, number, number];
|
48
|
-
} | boolean;
|
49
44
|
export interface PrivateTriangleLayerProps extends ExtendedLayerProps {
|
50
45
|
geometryTriangles: GeometryTriangles;
|
51
46
|
geometryLines: GeometryLines;
|
@@ -55,18 +50,18 @@ export interface PrivateTriangleLayerProps extends ExtendedLayerProps {
|
|
55
50
|
smoothShading: boolean;
|
56
51
|
depthTest: boolean;
|
57
52
|
ZIncreasingDownwards: boolean;
|
53
|
+
enableLighting: boolean;
|
58
54
|
}
|
59
55
|
export default class PrivateTriangleLayer extends Layer<PrivateTriangleLayerProps> {
|
60
56
|
get isLoaded(): boolean;
|
57
|
+
setShaderModuleProps(args: Partial<{
|
58
|
+
[x: string]: Partial<Record<string, unknown> | undefined>;
|
59
|
+
}>): void;
|
61
60
|
initializeState(context: DeckGLLayerContext): void;
|
62
61
|
shouldUpdateState({ props, oldProps, context, changeFlags, }: UpdateParameters<this>): boolean;
|
63
62
|
updateState({ context }: UpdateParameters<this>): void;
|
64
|
-
_getModels(device: Device): [
|
65
|
-
draw(args:
|
66
|
-
moduleParameters?: unknown;
|
67
|
-
uniforms: UniformValue;
|
68
|
-
context: LayerContext;
|
69
|
-
}): void;
|
63
|
+
_getModels(device: Device): [Model, Model];
|
64
|
+
draw(args: any): void;
|
70
65
|
decodePickingColor(): number;
|
71
66
|
getPickingInfo({ info }: {
|
72
67
|
info: PickingInfo;
|