forked from uber/nebula.gl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pickingLineWidthExtraPixels prop (uber#694)
- Loading branch information
1 parent
c8d9c03
commit 7f2f94d
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { PathLayer, PathLayerProps } from '@deck.gl/layers'; | ||
|
||
import { insertBefore } from '../utils'; | ||
|
||
interface EditablePathLayerProps extends PathLayerProps<any> { | ||
pickingLineWidthExtraPixels?: number; | ||
} | ||
|
||
const defaultProps = { | ||
...PathLayer.defaultProps, | ||
pickingLineWidthExtraPixels: { type: 'number', min: 0, value: Number.MAX_SAFE_INTEGER }, | ||
}; | ||
|
||
export default class EditablePathLayer extends PathLayer<any, EditablePathLayerProps> { | ||
getShaders() { | ||
const shaders = super.getShaders(); | ||
|
||
shaders.vs = insertBefore( | ||
shaders.vs, | ||
'vec3 width;', | ||
` | ||
if(picking_uActive){ | ||
widthPixels.xy += pickingLineWidthExtraPixels; | ||
} | ||
` | ||
); | ||
|
||
return { | ||
...shaders, | ||
inject: { | ||
...(shaders.inject || {}), | ||
'vs:#decl': (shaders.inject?.['vs:#decl'] || '').concat( | ||
`uniform float pickingLineWidthExtraPixels;` | ||
), | ||
}, | ||
}; | ||
} | ||
|
||
draw(props) { | ||
super.draw({ | ||
...props, | ||
uniforms: { | ||
...props.uniforms, | ||
pickingLineWidthExtraPixels: this.props.pickingLineWidthExtraPixels, | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
EditablePathLayer.defaultProps = defaultProps; | ||
EditablePathLayer.layerName = 'EditablePathLayer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters