seed-engine
Version:
A Lightweight 2D game engine using WebGL2. The engine is designed on the focus of creating a bridge between creating and publishing games to the Seed Network as modules.
875 lines • 26.4 kB
JSON
{
"type": "File",
"start": 0,
"end": 2431,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 110,
"column": 2
}
},
"program": {
"type": "Program",
"start": 0,
"end": 2431,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 110,
"column": 2
}
},
"sourceType": "module",
"body": [
{
"type": "ExportNamedDeclaration",
"start": 91,
"end": 593,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 33,
"column": 2
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "VariableDeclaration",
"start": 98,
"end": 593,
"loc": {
"start": {
"line": 5,
"column": 7
},
"end": {
"line": 33,
"column": 2
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 104,
"end": 592,
"loc": {
"start": {
"line": 5,
"column": 13
},
"end": {
"line": 33,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 104,
"end": 113,
"loc": {
"start": {
"line": 5,
"column": 13
},
"end": {
"line": 5,
"column": 22
},
"identifierName": "DEFAULT_F"
},
"name": "DEFAULT_F",
"leadingComments": null
},
"init": {
"type": "TemplateLiteral",
"start": 116,
"end": 592,
"loc": {
"start": {
"line": 5,
"column": 25
},
"end": {
"line": 33,
"column": 1
}
},
"expressions": [],
"quasis": [
{
"type": "TemplateElement",
"start": 117,
"end": 591,
"loc": {
"start": {
"line": 5,
"column": 26
},
"end": {
"line": 33,
"column": 0
}
},
"value": {
"raw": "#version 300 es\n\nprecision mediump float;\n\n//in\nin vec2 v_texcoord;\nuniform vec4 u_color;\nuniform vec4 u_subTexcoord;\n\n//local\nuniform sampler2D u_texture;\nvec2 subTexcoord;\n\n//out\nout vec4 outColor;\n\nvoid main() {\n subTexcoord = v_texcoord;\n subTexcoord.xy -= u_subTexcoord.xy;\n subTexcoord.xy *= u_subTexcoord.zw;\n vec4 fragColor = texture(u_texture, subTexcoord) * u_color;\n\n if(fragColor.a < 0.25) {\n discard;\n }\n\n outColor = vec4(fragColor.rgb, u_color.a);\n}\n",
"cooked": "#version 300 es\n\nprecision mediump float;\n\n//in\nin vec2 v_texcoord;\nuniform vec4 u_color;\nuniform vec4 u_subTexcoord;\n\n//local\nuniform sampler2D u_texture;\nvec2 subTexcoord;\n\n//out\nout vec4 outColor;\n\nvoid main() {\n subTexcoord = v_texcoord;\n subTexcoord.xy -= u_subTexcoord.xy;\n subTexcoord.xy *= u_subTexcoord.zw;\n vec4 fragColor = texture(u_texture, subTexcoord) * u_color;\n\n if(fragColor.a < 0.25) {\n discard;\n }\n\n outColor = vec4(fragColor.rgb, u_color.a);\n}\n"
},
"tail": true
}
]
},
"leadingComments": null
}
],
"kind": "const",
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Default fragment shader which handles single colors and Texture sprite sheets.\n ",
"start": 0,
"end": 89,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 3
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Fragment shader which takes parameters to draw tile maps.\n ",
"start": 595,
"end": 663,
"loc": {
"start": {
"line": 35,
"column": 0
},
"end": {
"line": 37,
"column": 3
}
}
}
]
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Default fragment shader which handles single colors and Texture sprite sheets.\n ",
"start": 0,
"end": 89,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 3
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Fragment shader which takes parameters to draw tile maps.\n ",
"start": 595,
"end": 663,
"loc": {
"start": {
"line": 35,
"column": 0
},
"end": {
"line": 37,
"column": 3
}
}
}
]
},
{
"type": "ExportNamedDeclaration",
"start": 665,
"end": 2431,
"loc": {
"start": {
"line": 39,
"column": 0
},
"end": {
"line": 110,
"column": 2
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "VariableDeclaration",
"start": 672,
"end": 2431,
"loc": {
"start": {
"line": 39,
"column": 7
},
"end": {
"line": 110,
"column": 2
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 678,
"end": 2430,
"loc": {
"start": {
"line": 39,
"column": 13
},
"end": {
"line": 110,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 678,
"end": 687,
"loc": {
"start": {
"line": 39,
"column": 13
},
"end": {
"line": 39,
"column": 22
},
"identifierName": "TILEMAP_F"
},
"name": "TILEMAP_F",
"leadingComments": null
},
"init": {
"type": "TemplateLiteral",
"start": 690,
"end": 2430,
"loc": {
"start": {
"line": 39,
"column": 25
},
"end": {
"line": 110,
"column": 1
}
},
"expressions": [],
"quasis": [
{
"type": "TemplateElement",
"start": 691,
"end": 2429,
"loc": {
"start": {
"line": 39,
"column": 26
},
"end": {
"line": 110,
"column": 0
}
},
"value": {
"raw": "#version 300 es\n\nprecision highp float;\n\n//in\nin vec2 v_texcoord;\nuniform vec4 u_color;\n\n/*\n[0][0] = 0 = Map data tiles width.\n[0][1] = 1 = Map data tiles height.\n[0][2] = 2 = Map tiles in the texture width.\n[0][3] = 3 = Map tiles in the texture height.\n\n[1][0] = 4 = Map viewport width.\n[1][1] = 5 = Map viewport height.\n[1][2] = 6 = Map viewport x1.\n[1][3] = 7 = Map viewport y1.\n\n[2][0] = 8 = TileSize width normalized.\n[2][1] = 9 = TileSize height normalized. \n*/\nuniform mat4 u_tileData;\nuniform mediump usampler2D u_mapDataTexture;\nuniform sampler2D u_texture;\n\n//local\n\n//texture tile image coordinates\nvec2 subTexcoord;\n\n//map data tile position.\nvec2 mapTilecoord;\n\n//Drawing coordinate.\nvec2 drawCoord;\n\n//out\nout vec4 outColor;\n\nvoid main() {\n\n //get this tile xy coordinate to obtain the tile ID.\n mapTilecoord.x = floor(u_tileData[1][2] + (v_texcoord.x * u_tileData[1][0])) / (u_tileData[0][0] - 1.0f);\n mapTilecoord.y = floor(u_tileData[1][3] + (v_texcoord.y * u_tileData[1][1])) / (u_tileData[0][1] - 1.0f);\n\n //get the tile ID from the texture.\n float tileID = float(texture(u_mapDataTexture, mapTilecoord).r);\n\n //get xy positions of texture from the ID, normalized.\n subTexcoord.x = -mod(tileID, u_tileData[0][2]) / u_tileData[0][2];\n subTexcoord.y = (-floor(tileID / u_tileData[0][2]) / u_tileData[0][3]);\n\n\n drawCoord.x = fract(v_texcoord.x * u_tileData[1][0]);\n drawCoord.y = fract(v_texcoord.y * u_tileData[1][1]);\n\n drawCoord.x /= u_tileData[0][2];\n drawCoord.y /= u_tileData[0][3];\n\n drawCoord.x -= subTexcoord.x;\n drawCoord.y -= subTexcoord.y;\n\n vec4 fragColor = texture(u_texture , drawCoord) * u_color;\n\n if (fragColor.a < 0.6) {\n discard;\n }\n\n outColor = vec4(fragColor.rgb, u_color.a);\n}\n",
"cooked": "#version 300 es\n\nprecision highp float;\n\n//in\nin vec2 v_texcoord;\nuniform vec4 u_color;\n\n/*\n[0][0] = 0 = Map data tiles width.\n[0][1] = 1 = Map data tiles height.\n[0][2] = 2 = Map tiles in the texture width.\n[0][3] = 3 = Map tiles in the texture height.\n\n[1][0] = 4 = Map viewport width.\n[1][1] = 5 = Map viewport height.\n[1][2] = 6 = Map viewport x1.\n[1][3] = 7 = Map viewport y1.\n\n[2][0] = 8 = TileSize width normalized.\n[2][1] = 9 = TileSize height normalized. \n*/\nuniform mat4 u_tileData;\nuniform mediump usampler2D u_mapDataTexture;\nuniform sampler2D u_texture;\n\n//local\n\n//texture tile image coordinates\nvec2 subTexcoord;\n\n//map data tile position.\nvec2 mapTilecoord;\n\n//Drawing coordinate.\nvec2 drawCoord;\n\n//out\nout vec4 outColor;\n\nvoid main() {\n\n //get this tile xy coordinate to obtain the tile ID.\n mapTilecoord.x = floor(u_tileData[1][2] + (v_texcoord.x * u_tileData[1][0])) / (u_tileData[0][0] - 1.0f);\n mapTilecoord.y = floor(u_tileData[1][3] + (v_texcoord.y * u_tileData[1][1])) / (u_tileData[0][1] - 1.0f);\n\n //get the tile ID from the texture.\n float tileID = float(texture(u_mapDataTexture, mapTilecoord).r);\n\n //get xy positions of texture from the ID, normalized.\n subTexcoord.x = -mod(tileID, u_tileData[0][2]) / u_tileData[0][2];\n subTexcoord.y = (-floor(tileID / u_tileData[0][2]) / u_tileData[0][3]);\n\n\n drawCoord.x = fract(v_texcoord.x * u_tileData[1][0]);\n drawCoord.y = fract(v_texcoord.y * u_tileData[1][1]);\n\n drawCoord.x /= u_tileData[0][2];\n drawCoord.y /= u_tileData[0][3];\n\n drawCoord.x -= subTexcoord.x;\n drawCoord.y -= subTexcoord.y;\n\n vec4 fragColor = texture(u_texture , drawCoord) * u_color;\n\n if (fragColor.a < 0.6) {\n discard;\n }\n\n outColor = vec4(fragColor.rgb, u_color.a);\n}\n"
},
"tail": true
}
]
},
"leadingComments": null
}
],
"kind": "const",
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Fragment shader which takes parameters to draw tile maps.\n ",
"start": 595,
"end": 663,
"loc": {
"start": {
"line": 35,
"column": 0
},
"end": {
"line": 37,
"column": 3
}
}
}
],
"trailingComments": []
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Fragment shader which takes parameters to draw tile maps.\n ",
"start": 595,
"end": 663,
"loc": {
"start": {
"line": 35,
"column": 0
},
"end": {
"line": 37,
"column": 3
}
}
}
]
}
],
"directives": []
},
"comments": [
{
"type": "CommentBlock",
"value": "*\n * Default fragment shader which handles single colors and Texture sprite sheets.\n ",
"start": 0,
"end": 89,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 3
}
}
},
{
"type": "CommentBlock",
"value": "*\n * Fragment shader which takes parameters to draw tile maps.\n ",
"start": 595,
"end": 663,
"loc": {
"start": {
"line": 35,
"column": 0
},
"end": {
"line": 37,
"column": 3
}
}
}
],
"tokens": [
{
"type": "CommentBlock",
"value": "*\n * Default fragment shader which handles single colors and Texture sprite sheets.\n ",
"start": 0,
"end": 89,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 3
}
}
},
{
"type": {
"label": "export",
"keyword": "export",
"beforeExpr": false,
"startsExpr": false,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null,
"updateContext": null
},
"value": "export",
"start": 91,
"end": 97,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 6
}
}
},
{
"type": {
"label": "const",
"keyword": "const",
"beforeExpr": false,
"startsExpr": false,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null,
"updateContext": null
},
"value": "const",
"start": 98,
"end": 103,
"loc": {
"start": {
"line": 5,
"column": 7
},
"end": {
"line": 5,
"column": 12
}
}
},
{
"type": {
"label": "name",
"beforeExpr": false,
"startsExpr": true,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null
},
"value": "DEFAULT_F",
"start": 104,
"end": 113,
"loc": {
"start": {
"line": 5,
"column": 13
},
"end": {
"line": 5,
"column": 22
}
}
},
{
"type": {
"label": "=",
"beforeExpr": true,
"startsExpr": false,
"rightAssociative": false,
"isLoop": false,
"isAssign": true,
"prefix": false,
"postfix": false,
"binop": null,
"updateContext": null
},
"value": "=",
"start": 114,
"end": 115,
"loc": {
"start": {
"line": 5,
"column": 23
},
"end": {
"line": 5,
"column": 24
}
}
},
{
"type": {
"label": "`",
"beforeExpr": false,
"startsExpr": true,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null
},
"start": 116,
"end": 117,
"loc": {
"start": {
"line": 5,
"column": 25
},
"end": {
"line": 5,
"column": 26
}
}
},
{
"type": {
"label": "template",
"beforeExpr": false,
"startsExpr": false,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null,
"updateContext": null
},
"value": "#version 300 es\n\nprecision mediump float;\n\n//in\nin vec2 v_texcoord;\nuniform vec4 u_color;\nuniform vec4 u_subTexcoord;\n\n//local\nuniform sampler2D u_texture;\nvec2 subTexcoord;\n\n//out\nout vec4 outColor;\n\nvoid main() {\n subTexcoord = v_texcoord;\n subTexcoord.xy -= u_subTexcoord.xy;\n subTexcoord.xy *= u_subTexcoord.zw;\n vec4 fragColor = texture(u_texture, subTexcoord) * u_color;\n\n if(fragColor.a < 0.25) {\n discard;\n }\n\n outColor = vec4(fragColor.rgb, u_color.a);\n}\n",
"start": 117,
"end": 591,
"loc": {
"start": {
"line": 5,
"column": 26
},
"end": {
"line": 33,
"column": 0
}
}
},
{
"type": {
"label": "`",
"beforeExpr": false,
"startsExpr": true,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null
},
"start": 591,
"end": 592,
"loc": {
"start": {
"line": 33,
"column": 0
},
"end": {
"line": 33,
"column": 1
}
}
},
{
"type": {
"label": ";",
"beforeExpr": true,
"startsExpr": false,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null,
"updateContext": null
},
"start": 592,
"end": 593,
"loc": {
"start": {
"line": 33,
"column": 1
},
"end": {
"line": 33,
"column": 2
}
}
},
{
"type": "CommentBlock",
"value": "*\n * Fragment shader which takes parameters to draw tile maps.\n ",
"start": 595,
"end": 663,
"loc": {
"start": {
"line": 35,
"column": 0
},
"end": {
"line": 37,
"column": 3
}
}
},
{
"type": {
"label": "export",
"keyword": "export",
"beforeExpr": false,
"startsExpr": false,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null,
"updateContext": null
},
"value": "export",
"start": 665,
"end": 671,
"loc": {
"start": {
"line": 39,
"column": 0
},
"end": {
"line": 39,
"column": 6
}
}
},
{
"type": {
"label": "const",
"keyword": "const",
"beforeExpr": false,
"startsExpr": false,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null,
"updateContext": null
},
"value": "const",
"start": 672,
"end": 677,
"loc": {
"start": {
"line": 39,
"column": 7
},
"end": {
"line": 39,
"column": 12
}
}
},
{
"type": {
"label": "name",
"beforeExpr": false,
"startsExpr": true,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null
},
"value": "TILEMAP_F",
"start": 678,
"end": 687,
"loc": {
"start": {
"line": 39,
"column": 13
},
"end": {
"line": 39,
"column": 22
}
}
},
{
"type": {
"label": "=",
"beforeExpr": true,
"startsExpr": false,
"rightAssociative": false,
"isLoop": false,
"isAssign": true,
"prefix": false,
"postfix": false,
"binop": null,
"updateContext": null
},
"value": "=",
"start": 688,
"end": 689,
"loc": {
"start": {
"line": 39,
"column": 23
},
"end": {
"line": 39,
"column": 24
}
}
},
{
"type": {
"label": "`",
"beforeExpr": false,
"startsExpr": true,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null
},
"start": 690,
"end": 691,
"loc": {
"start": {
"line": 39,
"column": 25
},
"end": {
"line": 39,
"column": 26
}
}
},
{
"type": {
"label": "template",
"beforeExpr": false,
"startsExpr": false,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null,
"updateContext": null
},
"value": "#version 300 es\n\nprecision highp float;\n\n//in\nin vec2 v_texcoord;\nuniform vec4 u_color;\n\n/*\n[0][0] = 0 = Map data tiles width.\n[0][1] = 1 = Map data tiles height.\n[0][2] = 2 = Map tiles in the texture width.\n[0][3] = 3 = Map tiles in the texture height.\n\n[1][0] = 4 = Map viewport width.\n[1][1] = 5 = Map viewport height.\n[1][2] = 6 = Map viewport x1.\n[1][3] = 7 = Map viewport y1.\n\n[2][0] = 8 = TileSize width normalized.\n[2][1] = 9 = TileSize height normalized. \n*/\nuniform mat4 u_tileData;\nuniform mediump usampler2D u_mapDataTexture;\nuniform sampler2D u_texture;\n\n//local\n\n//texture tile image coordinates\nvec2 subTexcoord;\n\n//map data tile position.\nvec2 mapTilecoord;\n\n//Drawing coordinate.\nvec2 drawCoord;\n\n//out\nout vec4 outColor;\n\nvoid main() {\n\n //get this tile xy coordinate to obtain the tile ID.\n mapTilecoord.x = floor(u_tileData[1][2] + (v_texcoord.x * u_tileData[1][0])) / (u_tileData[0][0] - 1.0f);\n mapTilecoord.y = floor(u_tileData[1][3] + (v_texcoord.y * u_tileData[1][1])) / (u_tileData[0][1] - 1.0f);\n\n //get the tile ID from the texture.\n float tileID = float(texture(u_mapDataTexture, mapTilecoord).r);\n\n //get xy positions of texture from the ID, normalized.\n subTexcoord.x = -mod(tileID, u_tileData[0][2]) / u_tileData[0][2];\n subTexcoord.y = (-floor(tileID / u_tileData[0][2]) / u_tileData[0][3]);\n\n\n drawCoord.x = fract(v_texcoord.x * u_tileData[1][0]);\n drawCoord.y = fract(v_texcoord.y * u_tileData[1][1]);\n\n drawCoord.x /= u_tileData[0][2];\n drawCoord.y /= u_tileData[0][3];\n\n drawCoord.x -= subTexcoord.x;\n drawCoord.y -= subTexcoord.y;\n\n vec4 fragColor = texture(u_texture , drawCoord) * u_color;\n\n if (fragColor.a < 0.6) {\n discard;\n }\n\n outColor = vec4(fragColor.rgb, u_color.a);\n}\n",
"start": 691,
"end": 2429,
"loc": {
"start": {
"line": 39,
"column": 26
},
"end": {
"line": 110,
"column": 0
}
}
},
{
"type": {
"label": "`",
"beforeExpr": false,
"startsExpr": true,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null
},
"start": 2429,
"end": 2430,
"loc": {
"start": {
"line": 110,
"column": 0
},
"end": {
"line": 110,
"column": 1
}
}
},
{
"type": {
"label": ";",
"beforeExpr": true,
"startsExpr": false,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null,
"updateContext": null
},
"start": 2430,
"end": 2431,
"loc": {
"start": {
"line": 110,
"column": 1
},
"end": {
"line": 110,
"column": 2
}
}
},
{
"type": {
"label": "eof",
"beforeExpr": false,
"startsExpr": false,
"rightAssociative": false,
"isLoop": false,
"isAssign": false,
"prefix": false,
"postfix": false,
"binop": null,
"updateContext": null
},
"start": 2431,
"end": 2431,
"loc": {
"start": {
"line": 110,
"column": 2
},
"end": {
"line": 110,
"column": 2
}
}
}
]
}