File tree Expand file tree Collapse file tree 9 files changed +29
-30
lines changed
packages/vt/src/layer/plugins/painters Expand file tree Collapse file tree 9 files changed +29
-30
lines changed Original file line number Diff line number Diff line change @@ -603,14 +603,16 @@ class FillPainter extends BasicPainter {
603603
604604 if ( this . pickingFBO ) {
605605 const projViewModelMatrix = [ ] ;
606- const isVectorTile = this . layer instanceof maptalks . TileLayer ;
606+ const isVectorTile = this . layer . isVectorTileLayer ;
607+ const defines = { 'PICKING_MODE' : 1 } ;
608+ this . appendWGSLPositionType ( defines ) ;
607609 this . picking = [ new reshader . FBORayPicking (
608610 this . renderer ,
609611 {
610612 name : 'fill-picking' ,
611613 vert : pickingVert ,
612614 wgslVert : pickingWgsl ,
613- defines : { 'PICKING_MODE' : 1 } ,
615+ defines,
614616 uniforms : [
615617 {
616618 name : 'projViewModelMatrix' ,
@@ -647,13 +649,11 @@ class FillPainter extends BasicPainter {
647649 const defines = { } ;
648650 this . fillIncludes ( defines , uniforms , context ) ;
649651
650- const isVectorTile = this . layer instanceof maptalks . TileLayer ;
651- const TYPE_CONSTS = `#define POSITION_TYPE ${ isVectorTile ? 'vec2i' : 'vec2f' }
652- ` ;
652+ this . appendWGSLPositionType ( defines ) ;
653653 this . shader = new reshader . MeshShader ( {
654654 name : 'vt-fill' ,
655655 vert, frag,
656- wgslVert : TYPE_CONSTS + wgslVert ,
656+ wgslVert : wgslVert ,
657657 wgslFrag,
658658 uniforms,
659659 defines,
Original file line number Diff line number Diff line change @@ -730,9 +730,7 @@ class IconPainter extends CollisionPainter {
730730 } ;
731731 const defines = this . _shaderDefines || { } ;
732732
733- const isVectorTile = this . layer . isVectorTileLayer ;
734- defines [ 'POSITION_TYPE_2' ] = isVectorTile ? 'vec2i' : 'vec2f' ;
735- defines [ 'POSITION_TYPE_3' ] = isVectorTile ? 'vec4i' : 'vec3f' ;
733+ this . appendWGSLPositionType ( defines ) ;
736734 this . shader = new reshader . MeshShader ( {
737735 name : 'marker' ,
738736 vert, frag,
Original file line number Diff line number Diff line change @@ -450,16 +450,16 @@ class LinePainter extends BasicPainter {
450450
451451 if ( this . pickingFBO ) {
452452 const isVectorTile = this . layer instanceof maptalks . TileLayer ;
453- const TYPE_CONSTS = `#define POSITION_TYPE ${ isVectorTile ? 'vec2i' : 'vec2f' }
454- #define LINESOFAR_TYPE ${ isVectorTile ? 'u32' : 'f32' }
455- ` ;
453+ const defines = { 'PICKING_MODE' : 1 } ;
454+ this . appendWGSLPositionType ( defines ) ;
455+ defines [ 'LINESOFAR_TYPE' ] = isVectorTile ? 'u32' : 'f32' ;
456456 this . picking = [ new reshader . FBORayPicking (
457457 this . renderer ,
458458 {
459459 name : 'line-picking' ,
460460 vert : pickingVert ,
461- wgslVert : TYPE_CONSTS + wgslVert ,
462- defines : { 'PICKING_MODE' : 1 } ,
461+ wgslVert : wgslVert ,
462+ defines,
463463 uniforms : [
464464 {
465465 name : 'projViewModelMatrix' ,
@@ -500,15 +500,14 @@ class LinePainter extends BasicPainter {
500500 }
501501 ) ;
502502
503- const isVectorTile = this . layer instanceof maptalks . TileLayer ;
504- const TYPE_CONSTS = `#define POSITION_TYPE ${ isVectorTile ? 'vec2i' : 'vec2f' }
505- #define LINESOFAR_TYPE ${ isVectorTile ? 'u32' : 'f32' }
506- ` ;
503+ const isVectorTile = this . layer . isVectorTileLayer ;
504+ this . appendWGSLPositionType ( defines ) ;
505+ defines [ 'LINESOFAR_TYPE' ] = isVectorTile ? 'u32' : 'f32' ;
507506 this . shader = new reshader . MeshShader ( {
508507 name : 'vt-line' ,
509508 vert,
510509 frag,
511- wgslVert : TYPE_CONSTS + wgslVert ,
510+ wgslVert,
512511 wgslFrag,
513512 uniforms,
514513 defines,
Original file line number Diff line number Diff line change @@ -1417,6 +1417,12 @@ class Painter {
14171417 shouldDrawParentTile ( ) {
14181418 return true ;
14191419 }
1420+
1421+ appendWGSLPositionType ( defines ) {
1422+ const isVectorTile = this . layer . isVectorTileLayer ;
1423+ defines [ 'POSITION_TYPE_2' ] = isVectorTile ? 'vec2i' : 'vec2f' ;
1424+ defines [ 'POSITION_TYPE_3' ] = isVectorTile ? 'vec4i' : 'vec3f' ;
1425+ }
14201426}
14211427
14221428export default Painter ;
Original file line number Diff line number Diff line change @@ -94,8 +94,6 @@ class TerrainFlatMaskPainter extends BasicPainter {
9494 } ,
9595 ] ;
9696
97- // const TYPE_CONSTS = `#define POSITION_TYPE vec2i
98- // `;
9997 this . shader = new reshader . MeshShader ( {
10098 name : 'vt-terrain-flat-mask' ,
10199 vert, frag,
Original file line number Diff line number Diff line change @@ -925,10 +925,8 @@ export default class TextPainter extends CollisionPainter {
925925 } ;
926926
927927 extraCommandProps . viewport = viewport ;
928- const isVectorTile = this . layer . isVectorTileLayer ;
929928 const defines = { } ;
930- defines [ 'POSITION_TYPE_2' ] = isVectorTile ? 'vec2i' : 'vec2f' ;
931- defines [ 'POSITION_TYPE_3' ] = isVectorTile ? 'vec4i' : 'vec3f' ;
929+ this . appendWGSLPositionType ( defines ) ;
932930 this . shader = new reshader . MeshShader ( {
933931 name : 'text' ,
934932 // vert: vertAlongLine, frag,
Original file line number Diff line number Diff line change 11struct VertexInput {
22#ifdef HAS_ALTITUDE
3- @location ($i ) aPosition : vec2i ,
3+ @location ($i ) aPosition : POSITION_TYPE_2 ,
44 @location ($i ) aAltitude : f32 ,
55#else
6- @location ($i ) aPosition : vec4i ,
6+ @location ($i ) aPosition : POSITION_TYPE_3 ,
77#endif
88}
99
Original file line number Diff line number Diff line change 11#define SHADER_NAME FILL
22struct VertexInput {
33#ifdef HAS_ALTITUDE
4- @location ($i ) aPosition : POSITION_TYPE ,
4+ @location ($i ) aPosition : POSITION_TYPE_2 ,
55 @location ($i ) aAltitude : f32 ,
66#else
7- @location ($i ) aPosition : vec4i ,
7+ @location ($i ) aPosition : POSITION_TYPE_3 ,
88#endif
99#ifdef HAS_COLOR
1010 @location ($i ) aColor : vec4u ,
Original file line number Diff line number Diff line change @@ -35,10 +35,10 @@ struct ShaderUniforms {
3535
3636struct VertexInput {
3737#ifdef HAS_ALTITUDE
38- @location ($i ) aPosition : POSITION_TYPE ,
38+ @location ($i ) aPosition : POSITION_TYPE_2 ,
3939 @location ($i ) aAltitude : f32 ,
4040#else
41- @location ($i ) aPosition : vec4i ,
41+ @location ($i ) aPosition : POSITION_TYPE_3 ,
4242#endif
4343
4444@location ($i ) aExtrude : vec4i ,
You can’t perform that action at this time.
0 commit comments