@deck.gl-community/layers 9.1.1 → 9.2.0-beta.3
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/index.cjs +37 -13
- package/dist/index.cjs.map +2 -2
- package/dist/path-outline-layer/path-outline-layer.d.ts +1 -2
- package/dist/path-outline-layer/path-outline-layer.d.ts.map +1 -1
- package/dist/path-outline-layer/path-outline-layer.js +37 -13
- package/dist/path-outline-layer/path-outline-layer.js.map +1 -1
- package/package.json +13 -21
- package/src/path-outline-layer/path-outline-layer.ts +45 -15
package/dist/index.cjs
CHANGED
|
@@ -142,6 +142,22 @@ var VS_CODE = ` outline_setUV(gl_Position);
|
|
|
142
142
|
`;
|
|
143
143
|
var FS_CODE = ` fragColor = outline_filterColor(fragColor);
|
|
144
144
|
`;
|
|
145
|
+
var OUTLINE_SHADOWMAP_PARAMETERS = {
|
|
146
|
+
blend: true,
|
|
147
|
+
blendColorSrcFactor: "one",
|
|
148
|
+
blendColorDstFactor: "one",
|
|
149
|
+
blendColorOperation: "max",
|
|
150
|
+
blendAlphaSrcFactor: "one",
|
|
151
|
+
blendAlphaDstFactor: "one",
|
|
152
|
+
blendAlphaOperation: "max",
|
|
153
|
+
depthWriteEnabled: false,
|
|
154
|
+
depthCompare: "always"
|
|
155
|
+
};
|
|
156
|
+
var OUTLINE_RENDER_PARAMETERS = {
|
|
157
|
+
blend: false,
|
|
158
|
+
depthWriteEnabled: false,
|
|
159
|
+
depthCompare: "always"
|
|
160
|
+
};
|
|
145
161
|
var defaultProps = {
|
|
146
162
|
getZLevel: () => 0
|
|
147
163
|
};
|
|
@@ -159,9 +175,11 @@ var PathOutlineLayer = class extends import_layers.PathLayer {
|
|
|
159
175
|
// @ts-expect-error PathLayer is missing LayerContext arg
|
|
160
176
|
initializeState(context) {
|
|
161
177
|
super.initializeState();
|
|
178
|
+
const outlineFramebuffer = context.device.createFramebuffer({
|
|
179
|
+
colorAttachments: ["rgba8unorm"]
|
|
180
|
+
});
|
|
162
181
|
this.setState({
|
|
163
|
-
outlineFramebuffer
|
|
164
|
-
dummyTexture: context.device.createTexture({})
|
|
182
|
+
outlineFramebuffer
|
|
165
183
|
});
|
|
166
184
|
this.state.attributeManager.addInstanced({
|
|
167
185
|
instanceZLevel: {
|
|
@@ -173,6 +191,7 @@ var PathOutlineLayer = class extends import_layers.PathLayer {
|
|
|
173
191
|
}
|
|
174
192
|
// Override draw to add render module
|
|
175
193
|
draw({ moduleParameters = {}, parameters, uniforms, context }) {
|
|
194
|
+
var _a;
|
|
176
195
|
const { jointRounded, capRounded, billboard, miterLimit, widthUnits, widthScale, widthMinPixels, widthMaxPixels } = this.props;
|
|
177
196
|
uniforms = Object.assign({}, uniforms, {
|
|
178
197
|
jointType: Number(jointRounded),
|
|
@@ -184,28 +203,35 @@ var PathOutlineLayer = class extends import_layers.PathLayer {
|
|
|
184
203
|
widthMinPixels,
|
|
185
204
|
widthMaxPixels
|
|
186
205
|
});
|
|
187
|
-
const { outlineFramebuffer
|
|
206
|
+
const { outlineFramebuffer } = this.state;
|
|
207
|
+
if (context == null ? void 0 : context.viewport) {
|
|
208
|
+
const viewportWidth = Math.max(1, Math.ceil(context.viewport.width));
|
|
209
|
+
const viewportHeight = Math.max(1, Math.ceil(context.viewport.height));
|
|
210
|
+
outlineFramebuffer.resize({ width: viewportWidth, height: viewportHeight });
|
|
211
|
+
} else {
|
|
212
|
+
outlineFramebuffer.resize();
|
|
213
|
+
}
|
|
214
|
+
const shadowmapTexture = (_a = outlineFramebuffer.colorAttachments[0]) == null ? void 0 : _a.texture;
|
|
215
|
+
if (!shadowmapTexture) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
188
218
|
this.state.model.updateModuleSettings({
|
|
189
219
|
outlineEnabled: true,
|
|
190
220
|
outlineRenderShadowmap: true,
|
|
191
|
-
outlineShadowmap:
|
|
221
|
+
outlineShadowmap: shadowmapTexture
|
|
192
222
|
});
|
|
193
223
|
this.state.model.draw({
|
|
194
224
|
uniforms: Object.assign({}, uniforms, {
|
|
195
225
|
jointType: 0,
|
|
196
226
|
widthScale: this.props.widthScale * 1.3
|
|
197
227
|
}),
|
|
198
|
-
parameters:
|
|
199
|
-
depthTest: false,
|
|
200
|
-
// Biggest value needs to go into buffer
|
|
201
|
-
blendEquation: 32776
|
|
202
|
-
},
|
|
228
|
+
parameters: OUTLINE_SHADOWMAP_PARAMETERS,
|
|
203
229
|
framebuffer: outlineFramebuffer
|
|
204
230
|
});
|
|
205
231
|
this.state.model.updateModuleSettings({
|
|
206
232
|
outlineEnabled: true,
|
|
207
233
|
outlineRenderShadowmap: false,
|
|
208
|
-
outlineShadowmap:
|
|
234
|
+
outlineShadowmap: shadowmapTexture
|
|
209
235
|
});
|
|
210
236
|
this.state.model.draw({
|
|
211
237
|
uniforms: Object.assign({}, uniforms, {
|
|
@@ -213,9 +239,7 @@ var PathOutlineLayer = class extends import_layers.PathLayer {
|
|
|
213
239
|
capType: Number(capRounded),
|
|
214
240
|
widthScale: this.props.widthScale
|
|
215
241
|
}),
|
|
216
|
-
parameters:
|
|
217
|
-
depthTest: false
|
|
218
|
-
}
|
|
242
|
+
parameters: OUTLINE_RENDER_PARAMETERS
|
|
219
243
|
});
|
|
220
244
|
}
|
|
221
245
|
};
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/path-outline-layer/path-outline-layer.ts", "../src/path-outline-layer/outline.ts", "../src/path-marker-layer/path-marker-layer.ts", "../src/path-marker-layer/arrow-2d-geometry.ts", "../src/path-marker-layer/create-path-markers.ts", "../src/path-marker-layer/polyline.ts"],
|
|
4
|
-
"sourcesContent": ["// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nexport type {PathOutlineLayerProps} from './path-outline-layer/path-outline-layer';\nexport {PathOutlineLayer} from './path-outline-layer/path-outline-layer';\n\nexport type {PathMarkerLayerProps} from './path-marker-layer/path-marker-layer';\nexport {PathMarkerLayer} from './path-marker-layer/path-marker-layer';\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {PathLayerProps} from '@deck.gl/layers';\nimport {PathLayer} from '@deck.gl/layers';\nimport type {DefaultProps, LayerContext} from '@deck.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {Framebuffer, Texture} from '@luma.gl/core';\nimport {outline} from './outline';\n\n/**\n * Unit literal to shader unit number conversion.\n */\nexport const UNIT = {\n common: 0,\n meters: 1,\n pixels: 2\n};\n\n// TODO - this should be built into assembleShaders\nfunction injectShaderCode({source, code = ''}) {\n const INJECT_CODE = /}[^{}]*$/;\n return source.replace(INJECT_CODE, code.concat('\\n}\\n'));\n}\n\nconst VS_CODE = `\\\n outline_setUV(gl_Position);\n outline_setZLevel(instanceZLevel);\n`;\n\nconst FS_CODE = `\\\n fragColor = outline_filterColor(fragColor);\n`;\n\nexport type PathOutlineLayerProps<DataT> = PathLayerProps<DataT> & {\n dashJustified?: boolean;\n getDashArray?: [number, number] | ((d: DataT) => [number, number] | null);\n getZLevel?: (d: DataT, index: number) => number;\n};\n\nconst defaultProps: DefaultProps<PathOutlineLayerProps<any>> = {\n getZLevel: () => 0\n};\n\nexport class PathOutlineLayer<DataT = any, ExtraPropsT = Record<string, unknown>> extends PathLayer<\n DataT,\n ExtraPropsT & Required<PathOutlineLayerProps<DataT>>\n> {\n static layerName = 'PathOutlineLayer';\n static defaultProps = defaultProps;\n\n state: {\n model?: any;\n pathTesselator: any;\n outlineFramebuffer: Framebuffer;\n dummyTexture: Texture;\n } = undefined!;\n\n // Override getShaders to inject the outline module\n getShaders() {\n const shaders = super.getShaders();\n return Object.assign({}, shaders, {\n modules: shaders.modules.concat([outline]),\n vs: injectShaderCode({source: shaders.vs, code: VS_CODE}),\n fs: injectShaderCode({source: shaders.fs, code: FS_CODE})\n });\n }\n\n // @ts-expect-error PathLayer is missing LayerContext arg\n initializeState(context: LayerContext) {\n super.initializeState();\n\n // Create an outline \"shadow\" map\n // TODO - we should create a single outlineMap for all layers\n this.setState({\n outlineFramebuffer: context.device.createFramebuffer({}),\n dummyTexture: context.device.createTexture({})\n });\n\n // Create an attribute manager\n // @ts-expect-error check whether this.getAttributeManager works here\n this.state.attributeManager.addInstanced({\n instanceZLevel: {\n size: 1,\n type: GL.UNSIGNED_BYTE,\n accessor: 'getZLevel'\n }\n });\n }\n\n // Override draw to add render module\n draw({moduleParameters = {}, parameters, uniforms, context}) {\n // Need to calculate same uniforms as base layer\n const {\n jointRounded,\n capRounded,\n billboard,\n miterLimit,\n widthUnits,\n widthScale,\n widthMinPixels,\n widthMaxPixels\n } = this.props;\n\n uniforms = Object.assign({}, uniforms, {\n jointType: Number(jointRounded),\n capType: Number(capRounded),\n billboard,\n widthUnits: UNIT[widthUnits],\n widthScale,\n miterLimit,\n widthMinPixels,\n widthMaxPixels\n });\n\n // Render the outline shadowmap (based on segment z orders)\n const {outlineFramebuffer, dummyTexture} = this.state;\n // TODO(v9): resize, see 'sf' example.\n // outlineFramebuffer.resize();\n // TODO(v9) clear FBO\n // outlineFramebuffer.clear({ color: true, depth: true, stencil: true });\n\n this.state.model.updateModuleSettings({\n outlineEnabled: true,\n outlineRenderShadowmap: true,\n outlineShadowmap: dummyTexture\n });\n\n this.state.model.draw({\n uniforms: Object.assign({}, uniforms, {\n jointType: 0,\n widthScale: this.props.widthScale * 1.3\n }),\n parameters: {\n depthTest: false,\n // Biggest value needs to go into buffer\n blendEquation: GL.MAX\n },\n framebuffer: outlineFramebuffer\n });\n\n // Now use the outline shadowmap to render the lines (with outlines)\n this.state.model.updateModuleSettings({\n outlineEnabled: true,\n outlineRenderShadowmap: false,\n outlineShadowmap: outlineFramebuffer\n });\n this.state.model.draw({\n uniforms: Object.assign({}, uniforms, {\n jointType: Number(jointRounded),\n capType: Number(capRounded),\n widthScale: this.props.widthScale\n }),\n parameters: {\n depthTest: false\n }\n });\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {ShaderModule} from '@luma.gl/shadertools';\n\n/* eslint-disable camelcase */\nconst INITIAL_STATE: Record<string, any> = {\n outlineEnabled: false,\n outlineRenderShadowmap: false,\n outlineShadowmap: null\n};\n\nfunction getUniforms({outlineEnabled, outlineRenderShadowmap, outlineShadowmap} = INITIAL_STATE) {\n const uniforms: Record<string, any> = {};\n if (outlineEnabled !== undefined) {\n // ? 1.0 : 0.0;\n uniforms.outline_uEnabled = outlineEnabled;\n }\n if (outlineRenderShadowmap !== undefined) {\n // ? 1.0 : 0.0;\n uniforms.outline_uRenderOutlines = outlineRenderShadowmap;\n }\n if (outlineShadowmap !== undefined) {\n uniforms.outline_uShadowmap = outlineShadowmap;\n }\n return uniforms;\n}\n\nconst vs = `\\\n#version 300 es\nin float instanceZLevel;\nout float outline_vzLevel;\nout vec4 outline_vPosition;\n\n// Set the z level for the outline shadowmap rendering\nvoid outline_setZLevel(float zLevel) {\n outline_vzLevel = zLevel;\n}\n\n// Store an adjusted position for texture2DProj\nvoid outline_setUV(vec4 position) {\n // mat4(\n // 0.5, 0.0, 0.0, 0.0,\n // 0.0, 0.5, 0.0, 0.0,\n // 0.0, 0.0, 0.5, 0.0,\n // 0.5, 0.5, 0.5, 1.0\n // ) * position;\n outline_vPosition = vec4(position.xyz * 0.5 + position.w * 0.5, position.w);\n}\n`;\n\nconst fs = `\\\nuniform bool outline_uEnabled;\nuniform bool outline_uRenderOutlines;\nuniform sampler2D outline_uShadowmap;\n\nin float outline_vzLevel;\n// in vec2 outline_vUV;\nin vec4 outline_vPosition;\n\nout vec4 fragColor;\n\nconst float OUTLINE_Z_LEVEL_ERROR = 0.01;\n\n// Return a darker color in shadowmap\nvec4 outline_filterShadowColor(vec4 color) {\n return vec4(outline_vzLevel / 255., outline_vzLevel / 255., outline_vzLevel / 255., 1.);\n}\n\n// Return a darker color if in shadowmap\nvec4 outline_filterDarkenColor(vec4 color) {\n if (outline_uEnabled) {\n float maxZLevel;\n if (outline_vPosition.q > 0.0) {\n maxZLevel = texture2DProj(outline_uShadowmap, outline_vPosition).r * 255.;\n } else {\n discard;\n }\n if (maxZLevel < outline_vzLevel + OUTLINE_Z_LEVEL_ERROR) {\n vec4(color.rgb * 0.5, color.a);\n } else {\n discard;\n }\n }\n return color;\n}\n\n// if enabled and rendering outlines - Render depth to shadowmap\n// if enabled and rendering colors - Return a darker color if in shadowmap\n// if disabled, just return color\nvec4 outline_filterColor(vec4 color) {\n if (outline_uEnabled) {\n return outline_uRenderOutlines ?\n outline_filterShadowColor(color) :\n outline_filterDarkenColor(color);\n }\n return color;\n}\n`;\n\nexport const outline = {\n name: 'outline',\n vs,\n fs,\n getUniforms\n} as const satisfies ShaderModule;\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {DefaultProps} from '@deck.gl/core';\nimport {CompositeLayer, COORDINATE_SYSTEM} from '@deck.gl/core';\nimport {ScatterplotLayer} from '@deck.gl/layers';\nimport {SimpleMeshLayer} from '@deck.gl/mesh-layers';\nimport {PathOutlineLayer, PathOutlineLayerProps} from '../path-outline-layer/path-outline-layer';\nimport {Arrow2DGeometry} from './arrow-2d-geometry';\n\nimport {createPathMarkers} from './create-path-markers';\nimport {getClosestPointOnPolyline} from './polyline';\nimport {Vector3} from '@math.gl/core';\n\nconst DISTANCE_FOR_MULTI_ARROWS = 0.1;\nconst ARROW_HEAD_SIZE = 0.2;\nconst ARROW_TAIL_WIDTH = 0.05;\n// const ARROW_CENTER_ADJUST = -0.8;\n\nconst DEFAULT_MARKER_LAYER = SimpleMeshLayer;\n\nexport type PathMarkerLayerProps<DataT> = PathOutlineLayerProps<DataT> & {\n getDirection?: (x) => any;\n getMarkerColor?: (x) => number[];\n getMarkerPercentages?: (x: any, info: any) => number[];\n highlightPoint?: any;\n highlightIndex?: number;\n MarkerLayer?: any;\n markerLayerProps?: any;\n sizeScale?: number;\n fp64?: boolean;\n nebulaLayer?: any;\n};\n\nconst DEFAULT_MARKER_LAYER_PROPS = {\n mesh: new Arrow2DGeometry({headSize: ARROW_HEAD_SIZE, tailWidth: ARROW_TAIL_WIDTH})\n};\n\nconst defaultProps: DefaultProps<PathMarkerLayerProps<any>> = Object.assign(\n {},\n PathOutlineLayer.defaultProps,\n {\n MarkerLayer: DEFAULT_MARKER_LAYER,\n markerLayerProps: DEFAULT_MARKER_LAYER_PROPS,\n\n sizeScale: 100,\n fp64: false,\n\n highlightIndex: -1,\n highlightPoint: null,\n\n getPath: (x) => x.path,\n getColor: (x) => x.color,\n getMarkerColor: (x) => [0, 0, 0, 255],\n getDirection: (x) => x.direction,\n getMarkerPercentages: (object, {lineLength}) =>\n lineLength > DISTANCE_FOR_MULTI_ARROWS ? [0.25, 0.5, 0.75] : [0.5]\n }\n);\n\nexport class PathMarkerLayer<\n DataT = any,\n ExtraPropsT = Record<string, unknown>\n> extends CompositeLayer<ExtraPropsT & Required<PathMarkerLayerProps<DataT>>> {\n static layerName = 'PathMarkerLayer';\n static defaultProps = defaultProps;\n\n state: {\n closestPoint: Vector3 | null;\n closestPoints?: {position: Vector3}[];\n markers: any[];\n mesh: Arrow2DGeometry;\n } = undefined!;\n\n initializeState() {\n this.state = {\n markers: [],\n mesh: new Arrow2DGeometry({headSize: ARROW_HEAD_SIZE, tailWidth: ARROW_TAIL_WIDTH}),\n closestPoint: null,\n closestPoints: []\n };\n }\n\n projectFlat(xyz, viewport, coordinateSystem, coordinateOrigin) {\n if (coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS) {\n const [dx, dy] = viewport.metersToLngLatDelta(xyz);\n const [x, y] = coordinateOrigin;\n return viewport.projectFlat([x + dx, dy + y]);\n } else if (coordinateSystem === COORDINATE_SYSTEM.LNGLAT_OFFSETS) {\n const [dx, dy] = xyz;\n const [x, y] = coordinateOrigin;\n return viewport.projectFlat([x + dx, dy + y]);\n }\n\n return viewport.projectFlat(xyz);\n }\n\n updateState({props, oldProps, changeFlags}) {\n if (changeFlags.dataChanged || changeFlags.updateTriggersChanged) {\n const {\n data,\n getPath,\n getDirection,\n getMarkerColor,\n getMarkerPercentages,\n coordinateSystem,\n coordinateOrigin\n } = this.props;\n\n const {viewport} = this.context;\n const projectFlat = (o) => this.projectFlat(o, viewport, coordinateSystem, coordinateOrigin);\n this.state.markers = createPathMarkers({\n data,\n getPath,\n getDirection,\n getColor: getMarkerColor,\n getMarkerPercentages,\n projectFlat\n });\n this._recalculateClosestPoint();\n }\n if (changeFlags.propsChanged) {\n if (props.point !== oldProps.point) {\n this._recalculateClosestPoint();\n }\n }\n }\n\n _recalculateClosestPoint() {\n const {highlightPoint, highlightIndex} = this.props;\n if (highlightPoint && highlightIndex >= 0) {\n const object = this.props.data[highlightIndex];\n const points = this.props.getPath(object, null as any);\n const {point} = getClosestPointOnPolyline({points, p: highlightPoint});\n this.state.closestPoints = [{position: point}];\n } else {\n this.state.closestPoints = [];\n }\n }\n\n getPickingInfo({info}) {\n return Object.assign(info, {\n // override object with picked feature\n object: (info.object && info.object.path) || info.object\n });\n }\n\n renderLayers() {\n return [\n new PathOutlineLayer(\n this.props,\n this.getSubLayerProps({\n id: 'paths',\n // Note: data has to be passed explicitly like this to avoid being empty\n data: this.props.data\n })\n ),\n new this.props.MarkerLayer(\n this.getSubLayerProps(\n Object.assign({}, this.props.markerLayerProps, {\n id: 'markers',\n data: this.state.markers,\n getOrientation: (x) => [0, -x.angle, 0],\n getColor: (x) => x.color,\n sizeScale: this.props.sizeScale,\n fp64: this.props.fp64,\n pickable: false,\n parameters: {\n blend: false,\n depthTest: false\n }\n })\n )\n ),\n this.state.closestPoints &&\n new ScatterplotLayer({\n id: `${this.props.id}-highlight`,\n data: this.state.closestPoints,\n fp64: this.props.fp64\n })\n ];\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Geometry} from '@luma.gl/engine';\n\nexport class Arrow2DGeometry extends Geometry {\n constructor(opts = {}) {\n super(\n Object.assign({}, opts, {\n attributes: getArrowAttributes(opts),\n topology: 'triangle-list' as const\n })\n );\n }\n}\n\nfunction getArrowAttributes({length = 1, headSize = 0.2, tailWidth = 0.05, tailStart = 0.05}) {\n const texCoords = [\n // HEAD\n 0.5,\n 1.0,\n 0,\n 0.5 - headSize / 2,\n 1.0 - headSize,\n 0,\n 0.5 + headSize / 2,\n 1.0 - headSize,\n 0,\n 0.5 - tailWidth / 2,\n tailStart,\n 0,\n 0.5 + tailWidth / 2,\n 1.0 - headSize,\n 0,\n 0.5 + tailWidth / 2,\n tailStart,\n 0,\n 0.5 - tailWidth / 2,\n tailStart,\n 0,\n 0.5 - tailWidth / 2,\n 1.0 - headSize,\n 0,\n 0.5 + tailWidth / 2,\n 1.0 - headSize,\n 0\n ];\n\n const normals = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1];\n\n // Center and scale\n const positions = new Array(texCoords.length);\n for (let i = 0; i < texCoords.length / 3; i++) {\n const i3 = i * 3;\n positions[i3 + 0] = (texCoords[i3 + 0] - 0.5) * length;\n positions[i3 + 1] = (texCoords[i3 + 1] - 0.5) * length;\n positions[i3 + 2] = 0;\n }\n return {\n positions: {size: 3, value: new Float32Array(positions)},\n normals: {size: 3, value: new Float32Array(normals)},\n texCoords: {size: 2, value: new Float32Array(texCoords)}\n };\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Vector2} from '@math.gl/core';\n\n/** GeoJSON style position coordinate vector */\nexport type Position = [number, number] | [number, number, number];\n\n/** [red, green, blue, alpha] in premultiplied alpha format */\nexport type Color = [number, number, number, number];\n\nexport interface PathMarker {\n position: Position;\n angle: number;\n color: Color;\n object: unknown;\n}\n\nfunction getLineLength(vPoints) {\n // calculate total length\n let lineLength = 0;\n for (let i = 0; i < vPoints.length - 1; i++) {\n lineLength += vPoints[i].distance(vPoints[i + 1]);\n }\n return lineLength;\n}\n\nconst DEFAULT_COLOR = [0, 0, 0, 255];\nconst DEFAULT_DIRECTION = {forward: true, backward: false};\n\nexport function createPathMarkers({\n data,\n getPath = (x, context) => x.path,\n getDirection = (x) => x.direction,\n getColor = (x) => DEFAULT_COLOR,\n getMarkerPercentages = (x, info) => [0.5],\n projectFlat\n}): PathMarker[] {\n const markers: PathMarker[] = [];\n\n for (const object of data) {\n const path = getPath(object, null);\n const direction = getDirection(object) || DEFAULT_DIRECTION;\n const color = getColor(object);\n\n const vPoints = path.map((p) => new Vector2(p));\n const vPointsReverse = vPoints.slice(0).reverse();\n\n // calculate total length\n const lineLength = getLineLength(vPoints);\n\n // Ask for where to put markers\n const percentages = getMarkerPercentages(object, {lineLength});\n\n // Create the markers\n for (const percentage of percentages) {\n if (direction.forward) {\n const marker = createMarkerAlongPath({\n path: vPoints,\n percentage,\n lineLength,\n color,\n object,\n projectFlat\n });\n markers.push(marker);\n }\n\n if (direction.backward) {\n const marker = createMarkerAlongPath({\n path: vPointsReverse,\n percentage,\n lineLength,\n color,\n object,\n projectFlat\n });\n markers.push(marker);\n }\n }\n }\n\n return markers;\n}\n\nfunction createMarkerAlongPath({\n path,\n percentage,\n lineLength,\n color,\n object,\n projectFlat\n}): PathMarker {\n const distanceAlong = lineLength * percentage;\n let currentDistance = 0;\n let previousDistance = 0;\n let i = 0;\n for (i = 0; i < path.length - 1; i++) {\n currentDistance += path[i].distance(path[i + 1]);\n if (currentDistance > distanceAlong) {\n break;\n }\n previousDistance = currentDistance;\n }\n\n // If reached the end of the loop without exiting early,\n // undo the final increment to avoid a null-pointer exception\n if (i === path.length - 1) {\n i -= 1;\n }\n\n const vDirection = path[i + 1].clone().subtract(path[i]).normalize();\n const along = distanceAlong - previousDistance;\n const vCenter = vDirection.clone().multiply(new Vector2(along, along)).add(path[i]);\n\n const vDirection2 = new Vector2(projectFlat(path[i + 1])).subtract(projectFlat(path[i]));\n\n const angle = (vDirection2.verticalAngle() * 180) / Math.PI;\n\n return {position: [vCenter.x, vCenter.y, 0], angle, color, object};\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Vector3, clamp} from '@math.gl/core';\n\n// Return the closest point on a line segment\nexport function getClosestPointOnLine({p, p1, p2, clampToLine = true}) {\n const lineVector = new Vector3(p2).subtract(p1);\n const pointVector = new Vector3(p).subtract(p1);\n let dotProduct = lineVector.dot(pointVector);\n if (clampToLine) {\n dotProduct = clamp(dotProduct, 0, 1);\n }\n\n return lineVector.lerp(p1, p2, dotProduct);\n}\n\n// Return the closest point on a line segment\nexport function getClosestPointOnPolyline({p, points}) {\n p = new Vector3(p);\n let pClosest: Vector3 | null = null;\n let distanceSquared = Infinity;\n let index = -1;\n for (let i = 0; i < points.length - 1; ++i) {\n const p1 = points[i];\n const p2 = points[i + 1];\n const pClosestOnLine = getClosestPointOnLine({p, p1, p2});\n const distanceToLineSquared = p.distanceSquared(pClosestOnLine);\n if (distanceToLineSquared < distanceSquared) {\n distanceSquared = distanceToLineSquared;\n pClosest = pClosestOnLine;\n index = i;\n }\n }\n return {\n point: pClosest,\n index,\n p1: points[index],\n p2: points[index + 1],\n distanceSquared,\n distance: Math.sqrt(distanceSquared)\n };\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;ACKA,oBAAwB;AAExB,uBAAiB;;;ACAjB,IAAM,gBAAqC;EACzC,gBAAgB;EAChB,wBAAwB;EACxB,kBAAkB;;AAGpB,SAAS,YAAY,EAAC,gBAAgB,wBAAwB,iBAAgB,IAAI,eAAa;AAC7F,QAAM,WAAgC,CAAA;AACtC,MAAI,mBAAmB,QAAW;AAEhC,aAAS,mBAAmB;EAC9B;AACA,MAAI,2BAA2B,QAAW;AAExC,aAAS,0BAA0B;EACrC;AACA,MAAI,qBAAqB,QAAW;AAClC,aAAS,qBAAqB;EAChC;AACA,SAAO;AACT;AAEA,IAAM,KAAK;;;;;;;;;;;;;;;;;;;;;AAuBX,IAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDJ,IAAM,UAAU;EACrB,MAAM;EACN;EACA;EACA;;;;
|
|
4
|
+
"sourcesContent": ["// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nexport type {PathOutlineLayerProps} from './path-outline-layer/path-outline-layer';\nexport {PathOutlineLayer} from './path-outline-layer/path-outline-layer';\n\nexport type {PathMarkerLayerProps} from './path-marker-layer/path-marker-layer';\nexport {PathMarkerLayer} from './path-marker-layer/path-marker-layer';\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {PathLayerProps} from '@deck.gl/layers';\nimport {PathLayer} from '@deck.gl/layers';\nimport type {DefaultProps, LayerContext} from '@deck.gl/core';\nimport {GL} from '@luma.gl/constants';\nimport {Framebuffer} from '@luma.gl/core';\nimport type {RenderPipelineParameters} from '@luma.gl/core';\nimport {outline} from './outline';\n\n/**\n * Unit literal to shader unit number conversion.\n */\nexport const UNIT = {\n common: 0,\n meters: 1,\n pixels: 2\n};\n\n// TODO - this should be built into assembleShaders\nfunction injectShaderCode({source, code = ''}) {\n const INJECT_CODE = /}[^{}]*$/;\n return source.replace(INJECT_CODE, code.concat('\\n}\\n'));\n}\n\nconst VS_CODE = `\\\n outline_setUV(gl_Position);\n outline_setZLevel(instanceZLevel);\n`;\n\nconst FS_CODE = `\\\n fragColor = outline_filterColor(fragColor);\n`;\n\nconst OUTLINE_SHADOWMAP_PARAMETERS: RenderPipelineParameters = {\n blend: true,\n blendColorSrcFactor: 'one',\n blendColorDstFactor: 'one',\n blendColorOperation: 'max',\n blendAlphaSrcFactor: 'one',\n blendAlphaDstFactor: 'one',\n blendAlphaOperation: 'max',\n depthWriteEnabled: false,\n depthCompare: 'always'\n};\n\nconst OUTLINE_RENDER_PARAMETERS: RenderPipelineParameters = {\n blend: false,\n depthWriteEnabled: false,\n depthCompare: 'always'\n};\n\nexport type PathOutlineLayerProps<DataT> = PathLayerProps<DataT> & {\n dashJustified?: boolean;\n getDashArray?: [number, number] | ((d: DataT) => [number, number] | null);\n getZLevel?: (d: DataT, index: number) => number;\n};\n\nconst defaultProps: DefaultProps<PathOutlineLayerProps<any>> = {\n getZLevel: () => 0\n};\n\nexport class PathOutlineLayer<DataT = any, ExtraPropsT = Record<string, unknown>> extends PathLayer<\n DataT,\n ExtraPropsT & Required<PathOutlineLayerProps<DataT>>\n> {\n static layerName = 'PathOutlineLayer';\n static defaultProps = defaultProps;\n\n state: {\n model?: any;\n pathTesselator: any;\n outlineFramebuffer: Framebuffer;\n } = undefined!;\n\n // Override getShaders to inject the outline module\n getShaders() {\n const shaders = super.getShaders();\n return Object.assign({}, shaders, {\n modules: shaders.modules.concat([outline]),\n vs: injectShaderCode({source: shaders.vs, code: VS_CODE}),\n fs: injectShaderCode({source: shaders.fs, code: FS_CODE})\n });\n }\n\n // @ts-expect-error PathLayer is missing LayerContext arg\n initializeState(context: LayerContext) {\n super.initializeState();\n\n // Create an outline \"shadow\" map\n // TODO - we should create a single outlineMap for all layers\n const outlineFramebuffer = context.device.createFramebuffer({\n colorAttachments: ['rgba8unorm']\n });\n\n this.setState({\n outlineFramebuffer\n });\n\n // Create an attribute manager\n // @ts-expect-error check whether this.getAttributeManager works here\n this.state.attributeManager.addInstanced({\n instanceZLevel: {\n size: 1,\n type: GL.UNSIGNED_BYTE,\n accessor: 'getZLevel'\n }\n });\n }\n\n // Override draw to add render module\n draw({moduleParameters = {}, parameters, uniforms, context}) {\n // Need to calculate same uniforms as base layer\n const {\n jointRounded,\n capRounded,\n billboard,\n miterLimit,\n widthUnits,\n widthScale,\n widthMinPixels,\n widthMaxPixels\n } = this.props;\n\n uniforms = Object.assign({}, uniforms, {\n jointType: Number(jointRounded),\n capType: Number(capRounded),\n billboard,\n widthUnits: UNIT[widthUnits],\n widthScale,\n miterLimit,\n widthMinPixels,\n widthMaxPixels\n });\n\n // Render the outline shadowmap (based on segment z orders)\n const {outlineFramebuffer} = this.state;\n\n if (context?.viewport) {\n const viewportWidth = Math.max(1, Math.ceil(context.viewport.width));\n const viewportHeight = Math.max(1, Math.ceil(context.viewport.height));\n\n outlineFramebuffer.resize({width: viewportWidth, height: viewportHeight});\n } else {\n outlineFramebuffer.resize();\n }\n\n const shadowmapTexture = outlineFramebuffer.colorAttachments[0]?.texture;\n\n if (!shadowmapTexture) {\n return;\n }\n // TODO(v9): resize, see 'sf' example.\n // outlineFramebuffer.resize();\n // TODO(v9) clear FBO\n // outlineFramebuffer.clear({ color: true, depth: true, stencil: true });\n\n this.state.model.updateModuleSettings({\n outlineEnabled: true,\n outlineRenderShadowmap: true,\n outlineShadowmap: shadowmapTexture\n });\n\n this.state.model.draw({\n uniforms: Object.assign({}, uniforms, {\n jointType: 0,\n widthScale: this.props.widthScale * 1.3\n }),\n parameters: OUTLINE_SHADOWMAP_PARAMETERS,\n framebuffer: outlineFramebuffer\n });\n\n // Now use the outline shadowmap to render the lines (with outlines)\n this.state.model.updateModuleSettings({\n outlineEnabled: true,\n outlineRenderShadowmap: false,\n outlineShadowmap: shadowmapTexture\n });\n this.state.model.draw({\n uniforms: Object.assign({}, uniforms, {\n jointType: Number(jointRounded),\n capType: Number(capRounded),\n widthScale: this.props.widthScale\n }),\n parameters: OUTLINE_RENDER_PARAMETERS\n });\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {ShaderModule} from '@luma.gl/shadertools';\n\n/* eslint-disable camelcase */\nconst INITIAL_STATE: Record<string, any> = {\n outlineEnabled: false,\n outlineRenderShadowmap: false,\n outlineShadowmap: null\n};\n\nfunction getUniforms({outlineEnabled, outlineRenderShadowmap, outlineShadowmap} = INITIAL_STATE) {\n const uniforms: Record<string, any> = {};\n if (outlineEnabled !== undefined) {\n // ? 1.0 : 0.0;\n uniforms.outline_uEnabled = outlineEnabled;\n }\n if (outlineRenderShadowmap !== undefined) {\n // ? 1.0 : 0.0;\n uniforms.outline_uRenderOutlines = outlineRenderShadowmap;\n }\n if (outlineShadowmap !== undefined) {\n uniforms.outline_uShadowmap = outlineShadowmap;\n }\n return uniforms;\n}\n\nconst vs = `\\\n#version 300 es\nin float instanceZLevel;\nout float outline_vzLevel;\nout vec4 outline_vPosition;\n\n// Set the z level for the outline shadowmap rendering\nvoid outline_setZLevel(float zLevel) {\n outline_vzLevel = zLevel;\n}\n\n// Store an adjusted position for texture2DProj\nvoid outline_setUV(vec4 position) {\n // mat4(\n // 0.5, 0.0, 0.0, 0.0,\n // 0.0, 0.5, 0.0, 0.0,\n // 0.0, 0.0, 0.5, 0.0,\n // 0.5, 0.5, 0.5, 1.0\n // ) * position;\n outline_vPosition = vec4(position.xyz * 0.5 + position.w * 0.5, position.w);\n}\n`;\n\nconst fs = `\\\nuniform bool outline_uEnabled;\nuniform bool outline_uRenderOutlines;\nuniform sampler2D outline_uShadowmap;\n\nin float outline_vzLevel;\n// in vec2 outline_vUV;\nin vec4 outline_vPosition;\n\nout vec4 fragColor;\n\nconst float OUTLINE_Z_LEVEL_ERROR = 0.01;\n\n// Return a darker color in shadowmap\nvec4 outline_filterShadowColor(vec4 color) {\n return vec4(outline_vzLevel / 255., outline_vzLevel / 255., outline_vzLevel / 255., 1.);\n}\n\n// Return a darker color if in shadowmap\nvec4 outline_filterDarkenColor(vec4 color) {\n if (outline_uEnabled) {\n float maxZLevel;\n if (outline_vPosition.q > 0.0) {\n maxZLevel = texture2DProj(outline_uShadowmap, outline_vPosition).r * 255.;\n } else {\n discard;\n }\n if (maxZLevel < outline_vzLevel + OUTLINE_Z_LEVEL_ERROR) {\n vec4(color.rgb * 0.5, color.a);\n } else {\n discard;\n }\n }\n return color;\n}\n\n// if enabled and rendering outlines - Render depth to shadowmap\n// if enabled and rendering colors - Return a darker color if in shadowmap\n// if disabled, just return color\nvec4 outline_filterColor(vec4 color) {\n if (outline_uEnabled) {\n return outline_uRenderOutlines ?\n outline_filterShadowColor(color) :\n outline_filterDarkenColor(color);\n }\n return color;\n}\n`;\n\nexport const outline = {\n name: 'outline',\n vs,\n fs,\n getUniforms\n} as const satisfies ShaderModule;\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {DefaultProps} from '@deck.gl/core';\nimport {CompositeLayer, COORDINATE_SYSTEM} from '@deck.gl/core';\nimport {ScatterplotLayer} from '@deck.gl/layers';\nimport {SimpleMeshLayer} from '@deck.gl/mesh-layers';\nimport {PathOutlineLayer, PathOutlineLayerProps} from '../path-outline-layer/path-outline-layer';\nimport {Arrow2DGeometry} from './arrow-2d-geometry';\n\nimport {createPathMarkers} from './create-path-markers';\nimport {getClosestPointOnPolyline} from './polyline';\nimport {Vector3} from '@math.gl/core';\n\nconst DISTANCE_FOR_MULTI_ARROWS = 0.1;\nconst ARROW_HEAD_SIZE = 0.2;\nconst ARROW_TAIL_WIDTH = 0.05;\n// const ARROW_CENTER_ADJUST = -0.8;\n\nconst DEFAULT_MARKER_LAYER = SimpleMeshLayer;\n\nexport type PathMarkerLayerProps<DataT> = PathOutlineLayerProps<DataT> & {\n getDirection?: (x) => any;\n getMarkerColor?: (x) => number[];\n getMarkerPercentages?: (x: any, info: any) => number[];\n highlightPoint?: any;\n highlightIndex?: number;\n MarkerLayer?: any;\n markerLayerProps?: any;\n sizeScale?: number;\n fp64?: boolean;\n nebulaLayer?: any;\n};\n\nconst DEFAULT_MARKER_LAYER_PROPS = {\n mesh: new Arrow2DGeometry({headSize: ARROW_HEAD_SIZE, tailWidth: ARROW_TAIL_WIDTH})\n};\n\nconst defaultProps: DefaultProps<PathMarkerLayerProps<any>> = Object.assign(\n {},\n PathOutlineLayer.defaultProps,\n {\n MarkerLayer: DEFAULT_MARKER_LAYER,\n markerLayerProps: DEFAULT_MARKER_LAYER_PROPS,\n\n sizeScale: 100,\n fp64: false,\n\n highlightIndex: -1,\n highlightPoint: null,\n\n getPath: (x) => x.path,\n getColor: (x) => x.color,\n getMarkerColor: (x) => [0, 0, 0, 255],\n getDirection: (x) => x.direction,\n getMarkerPercentages: (object, {lineLength}) =>\n lineLength > DISTANCE_FOR_MULTI_ARROWS ? [0.25, 0.5, 0.75] : [0.5]\n }\n);\n\nexport class PathMarkerLayer<\n DataT = any,\n ExtraPropsT = Record<string, unknown>\n> extends CompositeLayer<ExtraPropsT & Required<PathMarkerLayerProps<DataT>>> {\n static layerName = 'PathMarkerLayer';\n static defaultProps = defaultProps;\n\n state: {\n closestPoint: Vector3 | null;\n closestPoints?: {position: Vector3}[];\n markers: any[];\n mesh: Arrow2DGeometry;\n } = undefined!;\n\n initializeState() {\n this.state = {\n markers: [],\n mesh: new Arrow2DGeometry({headSize: ARROW_HEAD_SIZE, tailWidth: ARROW_TAIL_WIDTH}),\n closestPoint: null,\n closestPoints: []\n };\n }\n\n projectFlat(xyz, viewport, coordinateSystem, coordinateOrigin) {\n if (coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS) {\n const [dx, dy] = viewport.metersToLngLatDelta(xyz);\n const [x, y] = coordinateOrigin;\n return viewport.projectFlat([x + dx, dy + y]);\n } else if (coordinateSystem === COORDINATE_SYSTEM.LNGLAT_OFFSETS) {\n const [dx, dy] = xyz;\n const [x, y] = coordinateOrigin;\n return viewport.projectFlat([x + dx, dy + y]);\n }\n\n return viewport.projectFlat(xyz);\n }\n\n updateState({props, oldProps, changeFlags}) {\n if (changeFlags.dataChanged || changeFlags.updateTriggersChanged) {\n const {\n data,\n getPath,\n getDirection,\n getMarkerColor,\n getMarkerPercentages,\n coordinateSystem,\n coordinateOrigin\n } = this.props;\n\n const {viewport} = this.context;\n const projectFlat = (o) => this.projectFlat(o, viewport, coordinateSystem, coordinateOrigin);\n this.state.markers = createPathMarkers({\n data,\n getPath,\n getDirection,\n getColor: getMarkerColor,\n getMarkerPercentages,\n projectFlat\n });\n this._recalculateClosestPoint();\n }\n if (changeFlags.propsChanged) {\n if (props.point !== oldProps.point) {\n this._recalculateClosestPoint();\n }\n }\n }\n\n _recalculateClosestPoint() {\n const {highlightPoint, highlightIndex} = this.props;\n if (highlightPoint && highlightIndex >= 0) {\n const object = this.props.data[highlightIndex];\n const points = this.props.getPath(object, null as any);\n const {point} = getClosestPointOnPolyline({points, p: highlightPoint});\n this.state.closestPoints = [{position: point}];\n } else {\n this.state.closestPoints = [];\n }\n }\n\n getPickingInfo({info}) {\n return Object.assign(info, {\n // override object with picked feature\n object: (info.object && info.object.path) || info.object\n });\n }\n\n renderLayers() {\n return [\n new PathOutlineLayer(\n this.props,\n this.getSubLayerProps({\n id: 'paths',\n // Note: data has to be passed explicitly like this to avoid being empty\n data: this.props.data\n })\n ),\n new this.props.MarkerLayer(\n this.getSubLayerProps(\n Object.assign({}, this.props.markerLayerProps, {\n id: 'markers',\n data: this.state.markers,\n getOrientation: (x) => [0, -x.angle, 0],\n getColor: (x) => x.color,\n sizeScale: this.props.sizeScale,\n fp64: this.props.fp64,\n pickable: false,\n parameters: {\n blend: false,\n depthTest: false\n }\n })\n )\n ),\n this.state.closestPoints &&\n new ScatterplotLayer({\n id: `${this.props.id}-highlight`,\n data: this.state.closestPoints,\n fp64: this.props.fp64\n })\n ];\n }\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Geometry} from '@luma.gl/engine';\n\nexport class Arrow2DGeometry extends Geometry {\n constructor(opts = {}) {\n super(\n Object.assign({}, opts, {\n attributes: getArrowAttributes(opts),\n topology: 'triangle-list' as const\n })\n );\n }\n}\n\nfunction getArrowAttributes({length = 1, headSize = 0.2, tailWidth = 0.05, tailStart = 0.05}) {\n const texCoords = [\n // HEAD\n 0.5,\n 1.0,\n 0,\n 0.5 - headSize / 2,\n 1.0 - headSize,\n 0,\n 0.5 + headSize / 2,\n 1.0 - headSize,\n 0,\n 0.5 - tailWidth / 2,\n tailStart,\n 0,\n 0.5 + tailWidth / 2,\n 1.0 - headSize,\n 0,\n 0.5 + tailWidth / 2,\n tailStart,\n 0,\n 0.5 - tailWidth / 2,\n tailStart,\n 0,\n 0.5 - tailWidth / 2,\n 1.0 - headSize,\n 0,\n 0.5 + tailWidth / 2,\n 1.0 - headSize,\n 0\n ];\n\n const normals = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1];\n\n // Center and scale\n const positions = new Array(texCoords.length);\n for (let i = 0; i < texCoords.length / 3; i++) {\n const i3 = i * 3;\n positions[i3 + 0] = (texCoords[i3 + 0] - 0.5) * length;\n positions[i3 + 1] = (texCoords[i3 + 1] - 0.5) * length;\n positions[i3 + 2] = 0;\n }\n return {\n positions: {size: 3, value: new Float32Array(positions)},\n normals: {size: 3, value: new Float32Array(normals)},\n texCoords: {size: 2, value: new Float32Array(texCoords)}\n };\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Vector2} from '@math.gl/core';\n\n/** GeoJSON style position coordinate vector */\nexport type Position = [number, number] | [number, number, number];\n\n/** [red, green, blue, alpha] in premultiplied alpha format */\nexport type Color = [number, number, number, number];\n\nexport interface PathMarker {\n position: Position;\n angle: number;\n color: Color;\n object: unknown;\n}\n\nfunction getLineLength(vPoints) {\n // calculate total length\n let lineLength = 0;\n for (let i = 0; i < vPoints.length - 1; i++) {\n lineLength += vPoints[i].distance(vPoints[i + 1]);\n }\n return lineLength;\n}\n\nconst DEFAULT_COLOR = [0, 0, 0, 255];\nconst DEFAULT_DIRECTION = {forward: true, backward: false};\n\nexport function createPathMarkers({\n data,\n getPath = (x, context) => x.path,\n getDirection = (x) => x.direction,\n getColor = (x) => DEFAULT_COLOR,\n getMarkerPercentages = (x, info) => [0.5],\n projectFlat\n}): PathMarker[] {\n const markers: PathMarker[] = [];\n\n for (const object of data) {\n const path = getPath(object, null);\n const direction = getDirection(object) || DEFAULT_DIRECTION;\n const color = getColor(object);\n\n const vPoints = path.map((p) => new Vector2(p));\n const vPointsReverse = vPoints.slice(0).reverse();\n\n // calculate total length\n const lineLength = getLineLength(vPoints);\n\n // Ask for where to put markers\n const percentages = getMarkerPercentages(object, {lineLength});\n\n // Create the markers\n for (const percentage of percentages) {\n if (direction.forward) {\n const marker = createMarkerAlongPath({\n path: vPoints,\n percentage,\n lineLength,\n color,\n object,\n projectFlat\n });\n markers.push(marker);\n }\n\n if (direction.backward) {\n const marker = createMarkerAlongPath({\n path: vPointsReverse,\n percentage,\n lineLength,\n color,\n object,\n projectFlat\n });\n markers.push(marker);\n }\n }\n }\n\n return markers;\n}\n\nfunction createMarkerAlongPath({\n path,\n percentage,\n lineLength,\n color,\n object,\n projectFlat\n}): PathMarker {\n const distanceAlong = lineLength * percentage;\n let currentDistance = 0;\n let previousDistance = 0;\n let i = 0;\n for (i = 0; i < path.length - 1; i++) {\n currentDistance += path[i].distance(path[i + 1]);\n if (currentDistance > distanceAlong) {\n break;\n }\n previousDistance = currentDistance;\n }\n\n // If reached the end of the loop without exiting early,\n // undo the final increment to avoid a null-pointer exception\n if (i === path.length - 1) {\n i -= 1;\n }\n\n const vDirection = path[i + 1].clone().subtract(path[i]).normalize();\n const along = distanceAlong - previousDistance;\n const vCenter = vDirection.clone().multiply(new Vector2(along, along)).add(path[i]);\n\n const vDirection2 = new Vector2(projectFlat(path[i + 1])).subtract(projectFlat(path[i]));\n\n const angle = (vDirection2.verticalAngle() * 180) / Math.PI;\n\n return {position: [vCenter.x, vCenter.y, 0], angle, color, object};\n}\n", "// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Vector3, clamp} from '@math.gl/core';\n\n// Return the closest point on a line segment\nexport function getClosestPointOnLine({p, p1, p2, clampToLine = true}) {\n const lineVector = new Vector3(p2).subtract(p1);\n const pointVector = new Vector3(p).subtract(p1);\n let dotProduct = lineVector.dot(pointVector);\n if (clampToLine) {\n dotProduct = clamp(dotProduct, 0, 1);\n }\n\n return lineVector.lerp(p1, p2, dotProduct);\n}\n\n// Return the closest point on a line segment\nexport function getClosestPointOnPolyline({p, points}) {\n p = new Vector3(p);\n let pClosest: Vector3 | null = null;\n let distanceSquared = Infinity;\n let index = -1;\n for (let i = 0; i < points.length - 1; ++i) {\n const p1 = points[i];\n const p2 = points[i + 1];\n const pClosestOnLine = getClosestPointOnLine({p, p1, p2});\n const distanceToLineSquared = p.distanceSquared(pClosestOnLine);\n if (distanceToLineSquared < distanceSquared) {\n distanceSquared = distanceToLineSquared;\n pClosest = pClosestOnLine;\n index = i;\n }\n }\n return {\n point: pClosest,\n index,\n p1: points[index],\n p2: points[index + 1],\n distanceSquared,\n distance: Math.sqrt(distanceSquared)\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;ACKA,oBAAwB;AAExB,uBAAiB;;;ACAjB,IAAM,gBAAqC;EACzC,gBAAgB;EAChB,wBAAwB;EACxB,kBAAkB;;AAGpB,SAAS,YAAY,EAAC,gBAAgB,wBAAwB,iBAAgB,IAAI,eAAa;AAC7F,QAAM,WAAgC,CAAA;AACtC,MAAI,mBAAmB,QAAW;AAEhC,aAAS,mBAAmB;EAC9B;AACA,MAAI,2BAA2B,QAAW;AAExC,aAAS,0BAA0B;EACrC;AACA,MAAI,qBAAqB,QAAW;AAClC,aAAS,qBAAqB;EAChC;AACA,SAAO;AACT;AAEA,IAAM,KAAK;;;;;;;;;;;;;;;;;;;;;AAuBX,IAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDJ,IAAM,UAAU;EACrB,MAAM;EACN;EACA;EACA;;;;AD1FK,IAAM,OAAO;EAClB,QAAQ;EACR,QAAQ;EACR,QAAQ;;AAIV,SAAS,iBAAiB,EAAC,QAAQ,OAAO,GAAE,GAAC;AAC3C,QAAM,cAAc;AACpB,SAAO,OAAO,QAA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YACb,KAAK,iBACH,OAAO,OAAO,CAAA,GAAI,KAAK,MAAM,kBAAkB;QAC7C,IAAI;QACJ,MAAM,KAAK,MAAM;QACjB,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;QACtC,UAAU,CAAC,MAAM,EAAE;QACnB,WAAW,KAAK,MAAM;QACtB,MAAM,KAAK,MAAM;QACjB,UAAU;QACV,YAAY;UACV,OAAO;UACP,WAAW;;OAEd,CAAC,CACH;MAEH,KAAK,MAAM,iBACT,IAAI,gCAAiB;QACnB,IAAI,GAAG,KAAK,MAAM;QAClB,MAAM,KAAK,MAAM;QACjB,MAAM,KAAK,MAAM;OAClB;;EAEP;;AArHA,cAJW,iBAIJ,aAAY;AACnB,cALW,iBAKJ,gBAAeA;",
|
|
6
6
|
"names": ["import_core", "import_layers", "import_core", "defaultProps"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PathLayerProps } from '@deck.gl/layers';
|
|
2
2
|
import { PathLayer } from '@deck.gl/layers';
|
|
3
3
|
import type { DefaultProps, LayerContext } from '@deck.gl/core';
|
|
4
|
-
import { Framebuffer
|
|
4
|
+
import { Framebuffer } from '@luma.gl/core';
|
|
5
5
|
/**
|
|
6
6
|
* Unit literal to shader unit number conversion.
|
|
7
7
|
*/
|
|
@@ -22,7 +22,6 @@ export declare class PathOutlineLayer<DataT = any, ExtraPropsT = Record<string,
|
|
|
22
22
|
model?: any;
|
|
23
23
|
pathTesselator: any;
|
|
24
24
|
outlineFramebuffer: Framebuffer;
|
|
25
|
-
dummyTexture: Texture;
|
|
26
25
|
};
|
|
27
26
|
getShaders(): any;
|
|
28
27
|
initializeState(context: LayerContext): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-outline-layer.d.ts","sourceRoot":"","sources":["../../src/path-outline-layer/path-outline-layer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,iBAA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AG,CAAC;QACpB,kBAAkB,EAAE,WAAW,CAAC;KACjC,CAAc;IAGf,UAAU;IAUV,eAAe,CAAC,OAAO,EAAE,YAAY;IAyBrC,IAAI,CAAC,EAAC,gBAAqB,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAC;;;;;KAAA;CA4E5D"}
|
|
@@ -24,6 +24,22 @@ const VS_CODE = `\
|
|
|
24
24
|
const FS_CODE = `\
|
|
25
25
|
fragColor = outline_filterColor(fragColor);
|
|
26
26
|
`;
|
|
27
|
+
const OUTLINE_SHADOWMAP_PARAMETERS = {
|
|
28
|
+
blend: true,
|
|
29
|
+
blendColorSrcFactor: 'one',
|
|
30
|
+
blendColorDstFactor: 'one',
|
|
31
|
+
blendColorOperation: 'max',
|
|
32
|
+
blendAlphaSrcFactor: 'one',
|
|
33
|
+
blendAlphaDstFactor: 'one',
|
|
34
|
+
blendAlphaOperation: 'max',
|
|
35
|
+
depthWriteEnabled: false,
|
|
36
|
+
depthCompare: 'always'
|
|
37
|
+
};
|
|
38
|
+
const OUTLINE_RENDER_PARAMETERS = {
|
|
39
|
+
blend: false,
|
|
40
|
+
depthWriteEnabled: false,
|
|
41
|
+
depthCompare: 'always'
|
|
42
|
+
};
|
|
27
43
|
const defaultProps = {
|
|
28
44
|
getZLevel: () => 0
|
|
29
45
|
};
|
|
@@ -45,9 +61,11 @@ export class PathOutlineLayer extends PathLayer {
|
|
|
45
61
|
super.initializeState();
|
|
46
62
|
// Create an outline "shadow" map
|
|
47
63
|
// TODO - we should create a single outlineMap for all layers
|
|
64
|
+
const outlineFramebuffer = context.device.createFramebuffer({
|
|
65
|
+
colorAttachments: ['rgba8unorm']
|
|
66
|
+
});
|
|
48
67
|
this.setState({
|
|
49
|
-
outlineFramebuffer
|
|
50
|
-
dummyTexture: context.device.createTexture({})
|
|
68
|
+
outlineFramebuffer
|
|
51
69
|
});
|
|
52
70
|
// Create an attribute manager
|
|
53
71
|
// @ts-expect-error check whether this.getAttributeManager works here
|
|
@@ -74,7 +92,19 @@ export class PathOutlineLayer extends PathLayer {
|
|
|
74
92
|
widthMaxPixels
|
|
75
93
|
});
|
|
76
94
|
// Render the outline shadowmap (based on segment z orders)
|
|
77
|
-
const { outlineFramebuffer
|
|
95
|
+
const { outlineFramebuffer } = this.state;
|
|
96
|
+
if (context?.viewport) {
|
|
97
|
+
const viewportWidth = Math.max(1, Math.ceil(context.viewport.width));
|
|
98
|
+
const viewportHeight = Math.max(1, Math.ceil(context.viewport.height));
|
|
99
|
+
outlineFramebuffer.resize({ width: viewportWidth, height: viewportHeight });
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
outlineFramebuffer.resize();
|
|
103
|
+
}
|
|
104
|
+
const shadowmapTexture = outlineFramebuffer.colorAttachments[0]?.texture;
|
|
105
|
+
if (!shadowmapTexture) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
78
108
|
// TODO(v9): resize, see 'sf' example.
|
|
79
109
|
// outlineFramebuffer.resize();
|
|
80
110
|
// TODO(v9) clear FBO
|
|
@@ -82,25 +112,21 @@ export class PathOutlineLayer extends PathLayer {
|
|
|
82
112
|
this.state.model.updateModuleSettings({
|
|
83
113
|
outlineEnabled: true,
|
|
84
114
|
outlineRenderShadowmap: true,
|
|
85
|
-
outlineShadowmap:
|
|
115
|
+
outlineShadowmap: shadowmapTexture
|
|
86
116
|
});
|
|
87
117
|
this.state.model.draw({
|
|
88
118
|
uniforms: Object.assign({}, uniforms, {
|
|
89
119
|
jointType: 0,
|
|
90
120
|
widthScale: this.props.widthScale * 1.3
|
|
91
121
|
}),
|
|
92
|
-
parameters:
|
|
93
|
-
depthTest: false,
|
|
94
|
-
// Biggest value needs to go into buffer
|
|
95
|
-
blendEquation: 32776
|
|
96
|
-
},
|
|
122
|
+
parameters: OUTLINE_SHADOWMAP_PARAMETERS,
|
|
97
123
|
framebuffer: outlineFramebuffer
|
|
98
124
|
});
|
|
99
125
|
// Now use the outline shadowmap to render the lines (with outlines)
|
|
100
126
|
this.state.model.updateModuleSettings({
|
|
101
127
|
outlineEnabled: true,
|
|
102
128
|
outlineRenderShadowmap: false,
|
|
103
|
-
outlineShadowmap:
|
|
129
|
+
outlineShadowmap: shadowmapTexture
|
|
104
130
|
});
|
|
105
131
|
this.state.model.draw({
|
|
106
132
|
uniforms: Object.assign({}, uniforms, {
|
|
@@ -108,9 +134,7 @@ export class PathOutlineLayer extends PathLayer {
|
|
|
108
134
|
capType: Number(capRounded),
|
|
109
135
|
widthScale: this.props.widthScale
|
|
110
136
|
}),
|
|
111
|
-
parameters:
|
|
112
|
-
depthTest: false
|
|
113
|
-
}
|
|
137
|
+
parameters: OUTLINE_RENDER_PARAMETERS
|
|
114
138
|
});
|
|
115
139
|
}
|
|
116
140
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-outline-layer.js","sourceRoot":"","sources":["../../src/path-outline-layer/path-outline-layer.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"path-outline-layer.js","sourceRoot":"","sources":["../../src/path-outline-layer/path-outline-layer.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAC,EAAE,EAAC,MAAM,oBAAoB,CAAC;AAGtC,OAAO,EAAC,OAAO,EAAC,qBAAkB;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;CACV,CAAC;AAEF,mDAAmD;AACnD,SAAS,gBAAgB,CAAC,EAAC,MAAM,EAAE,IAAI,GAAG,EAAE,EAAC;IAC3C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gB;SACnC,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC;YACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE;gBACpC,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC;gBAC/B,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC;gBAC3B,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU;aAClC,CAAC;YACF,UAAU,EAAE,yBAAyB;SACtC,CAAC,CAAC;IACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deck.gl-community/layers",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.2.0-beta.3",
|
|
4
4
|
"description": "Add-on layers for deck.gl",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -30,27 +30,19 @@
|
|
|
30
30
|
"test-watch": "vitest"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@deck.gl/core": "
|
|
34
|
-
"@deck.gl/
|
|
35
|
-
"@deck.gl/
|
|
36
|
-
"@
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@loaders.gl/loader-utils": "^4.2.0",
|
|
42
|
-
"@loaders.gl/schema": "^4.2.0",
|
|
43
|
-
"@loaders.gl/tiles": "^4.2.0",
|
|
44
|
-
"@luma.gl/constants": "^9.1.0",
|
|
45
|
-
"@luma.gl/core": "^9.1.0",
|
|
46
|
-
"@luma.gl/engine": "^9.1.0",
|
|
47
|
-
"@math.gl/core": "^4.0.0",
|
|
48
|
-
"a5-js": "^0.1.4",
|
|
49
|
-
"h3-js": "^4.2.1"
|
|
33
|
+
"@deck.gl/core": "~9.2.1",
|
|
34
|
+
"@deck.gl/layers": "~9.2.1",
|
|
35
|
+
"@deck.gl/mesh-layers": "~9.2.1",
|
|
36
|
+
"@luma.gl/constants": "~9.2.0",
|
|
37
|
+
"@luma.gl/core": "~9.2.0",
|
|
38
|
+
"@luma.gl/engine": "~9.2.0",
|
|
39
|
+
"@luma.gl/shadertools": "~9.2.0",
|
|
40
|
+
"@math.gl/core": "^4.0.0"
|
|
50
41
|
},
|
|
51
42
|
"devDependencies": {
|
|
52
|
-
"@deck.gl/test-utils": "
|
|
53
|
-
"@luma.gl/webgpu": "
|
|
43
|
+
"@deck.gl/test-utils": "~9.2.1",
|
|
44
|
+
"@luma.gl/webgpu": "~9.2.0",
|
|
45
|
+
"@probe.gl/test-utils": "^4.0.4"
|
|
54
46
|
},
|
|
55
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "6110b774c8be16f199ecdf67723851a2e34901e5"
|
|
56
48
|
}
|
|
@@ -6,7 +6,8 @@ import type {PathLayerProps} from '@deck.gl/layers';
|
|
|
6
6
|
import {PathLayer} from '@deck.gl/layers';
|
|
7
7
|
import type {DefaultProps, LayerContext} from '@deck.gl/core';
|
|
8
8
|
import {GL} from '@luma.gl/constants';
|
|
9
|
-
import {Framebuffer
|
|
9
|
+
import {Framebuffer} from '@luma.gl/core';
|
|
10
|
+
import type {RenderPipelineParameters} from '@luma.gl/core';
|
|
10
11
|
import {outline} from './outline';
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -33,6 +34,24 @@ const FS_CODE = `\
|
|
|
33
34
|
fragColor = outline_filterColor(fragColor);
|
|
34
35
|
`;
|
|
35
36
|
|
|
37
|
+
const OUTLINE_SHADOWMAP_PARAMETERS: RenderPipelineParameters = {
|
|
38
|
+
blend: true,
|
|
39
|
+
blendColorSrcFactor: 'one',
|
|
40
|
+
blendColorDstFactor: 'one',
|
|
41
|
+
blendColorOperation: 'max',
|
|
42
|
+
blendAlphaSrcFactor: 'one',
|
|
43
|
+
blendAlphaDstFactor: 'one',
|
|
44
|
+
blendAlphaOperation: 'max',
|
|
45
|
+
depthWriteEnabled: false,
|
|
46
|
+
depthCompare: 'always'
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const OUTLINE_RENDER_PARAMETERS: RenderPipelineParameters = {
|
|
50
|
+
blend: false,
|
|
51
|
+
depthWriteEnabled: false,
|
|
52
|
+
depthCompare: 'always'
|
|
53
|
+
};
|
|
54
|
+
|
|
36
55
|
export type PathOutlineLayerProps<DataT> = PathLayerProps<DataT> & {
|
|
37
56
|
dashJustified?: boolean;
|
|
38
57
|
getDashArray?: [number, number] | ((d: DataT) => [number, number] | null);
|
|
@@ -54,7 +73,6 @@ export class PathOutlineLayer<DataT = any, ExtraPropsT = Record<string, unknown>
|
|
|
54
73
|
model?: any;
|
|
55
74
|
pathTesselator: any;
|
|
56
75
|
outlineFramebuffer: Framebuffer;
|
|
57
|
-
dummyTexture: Texture;
|
|
58
76
|
} = undefined!;
|
|
59
77
|
|
|
60
78
|
// Override getShaders to inject the outline module
|
|
@@ -73,9 +91,12 @@ export class PathOutlineLayer<DataT = any, ExtraPropsT = Record<string, unknown>
|
|
|
73
91
|
|
|
74
92
|
// Create an outline "shadow" map
|
|
75
93
|
// TODO - we should create a single outlineMap for all layers
|
|
94
|
+
const outlineFramebuffer = context.device.createFramebuffer({
|
|
95
|
+
colorAttachments: ['rgba8unorm']
|
|
96
|
+
});
|
|
97
|
+
|
|
76
98
|
this.setState({
|
|
77
|
-
outlineFramebuffer
|
|
78
|
-
dummyTexture: context.device.createTexture({})
|
|
99
|
+
outlineFramebuffer
|
|
79
100
|
});
|
|
80
101
|
|
|
81
102
|
// Create an attribute manager
|
|
@@ -115,7 +136,22 @@ export class PathOutlineLayer<DataT = any, ExtraPropsT = Record<string, unknown>
|
|
|
115
136
|
});
|
|
116
137
|
|
|
117
138
|
// Render the outline shadowmap (based on segment z orders)
|
|
118
|
-
const {outlineFramebuffer
|
|
139
|
+
const {outlineFramebuffer} = this.state;
|
|
140
|
+
|
|
141
|
+
if (context?.viewport) {
|
|
142
|
+
const viewportWidth = Math.max(1, Math.ceil(context.viewport.width));
|
|
143
|
+
const viewportHeight = Math.max(1, Math.ceil(context.viewport.height));
|
|
144
|
+
|
|
145
|
+
outlineFramebuffer.resize({width: viewportWidth, height: viewportHeight});
|
|
146
|
+
} else {
|
|
147
|
+
outlineFramebuffer.resize();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const shadowmapTexture = outlineFramebuffer.colorAttachments[0]?.texture;
|
|
151
|
+
|
|
152
|
+
if (!shadowmapTexture) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
119
155
|
// TODO(v9): resize, see 'sf' example.
|
|
120
156
|
// outlineFramebuffer.resize();
|
|
121
157
|
// TODO(v9) clear FBO
|
|
@@ -124,7 +160,7 @@ export class PathOutlineLayer<DataT = any, ExtraPropsT = Record<string, unknown>
|
|
|
124
160
|
this.state.model.updateModuleSettings({
|
|
125
161
|
outlineEnabled: true,
|
|
126
162
|
outlineRenderShadowmap: true,
|
|
127
|
-
outlineShadowmap:
|
|
163
|
+
outlineShadowmap: shadowmapTexture
|
|
128
164
|
});
|
|
129
165
|
|
|
130
166
|
this.state.model.draw({
|
|
@@ -132,11 +168,7 @@ export class PathOutlineLayer<DataT = any, ExtraPropsT = Record<string, unknown>
|
|
|
132
168
|
jointType: 0,
|
|
133
169
|
widthScale: this.props.widthScale * 1.3
|
|
134
170
|
}),
|
|
135
|
-
parameters:
|
|
136
|
-
depthTest: false,
|
|
137
|
-
// Biggest value needs to go into buffer
|
|
138
|
-
blendEquation: GL.MAX
|
|
139
|
-
},
|
|
171
|
+
parameters: OUTLINE_SHADOWMAP_PARAMETERS,
|
|
140
172
|
framebuffer: outlineFramebuffer
|
|
141
173
|
});
|
|
142
174
|
|
|
@@ -144,7 +176,7 @@ export class PathOutlineLayer<DataT = any, ExtraPropsT = Record<string, unknown>
|
|
|
144
176
|
this.state.model.updateModuleSettings({
|
|
145
177
|
outlineEnabled: true,
|
|
146
178
|
outlineRenderShadowmap: false,
|
|
147
|
-
outlineShadowmap:
|
|
179
|
+
outlineShadowmap: shadowmapTexture
|
|
148
180
|
});
|
|
149
181
|
this.state.model.draw({
|
|
150
182
|
uniforms: Object.assign({}, uniforms, {
|
|
@@ -152,9 +184,7 @@ export class PathOutlineLayer<DataT = any, ExtraPropsT = Record<string, unknown>
|
|
|
152
184
|
capType: Number(capRounded),
|
|
153
185
|
widthScale: this.props.widthScale
|
|
154
186
|
}),
|
|
155
|
-
parameters:
|
|
156
|
-
depthTest: false
|
|
157
|
-
}
|
|
187
|
+
parameters: OUTLINE_RENDER_PARAMETERS
|
|
158
188
|
});
|
|
159
189
|
}
|
|
160
190
|
}
|