UNPKG

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.

1,431 lines 816 kB
{ "type": "File", "start": 0, "end": 6675, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 168, "column": 30 } }, "program": { "type": "Program", "start": 0, "end": 6675, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 168, "column": 30 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 32, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 32 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 14, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 14 } }, "local": { "type": "Identifier", "start": 7, "end": 14, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 14 }, "identifierName": "Manager" }, "name": "Manager" } } ], "source": { "type": "StringLiteral", "start": 20, "end": 31, "loc": { "start": { "line": 1, "column": 20 }, "end": { "line": 1, "column": 31 } }, "extra": { "rawValue": "./Manager", "raw": "'./Manager'" }, "value": "./Manager" } }, { "type": "ImportDeclaration", "start": 33, "end": 71, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 38 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 40, "end": 50, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 17 } }, "local": { "type": "Identifier", "start": 40, "end": 50, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 17 }, "identifierName": "DOMManager" }, "name": "DOMManager" } } ], "source": { "type": "StringLiteral", "start": 56, "end": 70, "loc": { "start": { "line": 2, "column": 23 }, "end": { "line": 2, "column": 37 } }, "extra": { "rawValue": "./DOMManager", "raw": "'./DOMManager'" }, "value": "./DOMManager" } }, { "type": "ImportDeclaration", "start": 72, "end": 126, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 54 } }, "specifiers": [ { "type": "ImportNamespaceSpecifier", "start": 79, "end": 96, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 24 } }, "local": { "type": "Identifier", "start": 84, "end": 96, "loc": { "start": { "line": 3, "column": 12 }, "end": { "line": 3, "column": 24 }, "identifierName": "VertexShader" }, "name": "VertexShader" } } ], "source": { "type": "StringLiteral", "start": 102, "end": 125, "loc": { "start": { "line": 3, "column": 30 }, "end": { "line": 3, "column": 53 } }, "extra": { "rawValue": "../const/VertexShader", "raw": "'../const/VertexShader'" }, "value": "../const/VertexShader" } }, { "type": "ImportDeclaration", "start": 127, "end": 185, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 58 } }, "specifiers": [ { "type": "ImportNamespaceSpecifier", "start": 134, "end": 153, "loc": { "start": { "line": 4, "column": 7 }, "end": { "line": 4, "column": 26 } }, "local": { "type": "Identifier", "start": 139, "end": 153, "loc": { "start": { "line": 4, "column": 12 }, "end": { "line": 4, "column": 26 }, "identifierName": "FragmentShader" }, "name": "FragmentShader" } } ], "source": { "type": "StringLiteral", "start": 159, "end": 184, "loc": { "start": { "line": 4, "column": 32 }, "end": { "line": 4, "column": 57 } }, "extra": { "rawValue": "../const/FragmentShader", "raw": "'../const/FragmentShader'" }, "value": "../const/FragmentShader" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Manages WebGL Programs so that they only need to be created once across the engine\n * allowing multiple objects to still share the same reference.\n * \n * Elliminates the need for the programmer to compile shaders and create programs, and eases \n * on-the-fly Shader compiling.\n ", "start": 188, "end": 475, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 13, "column": 3 } } } ] }, { "type": "ExportNamedDeclaration", "start": 476, "end": 6536, "loc": { "start": { "line": 14, "column": 0 }, "end": { "line": 162, "column": 1 } }, "specifiers": [], "source": null, "declaration": { "type": "ClassDeclaration", "start": 483, "end": 6536, "loc": { "start": { "line": 14, "column": 7 }, "end": { "line": 162, "column": 1 } }, "id": { "type": "Identifier", "start": 489, "end": 504, "loc": { "start": { "line": 14, "column": 13 }, "end": { "line": 14, "column": 28 }, "identifierName": "_ProgramManager" }, "name": "_ProgramManager", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 513, "end": 520, "loc": { "start": { "line": 14, "column": 37 }, "end": { "line": 14, "column": 44 }, "identifierName": "Manager" }, "name": "Manager" }, "body": { "type": "ClassBody", "start": 521, "end": 6536, "loc": { "start": { "line": 14, "column": 45 }, "end": { "line": 162, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 527, "end": 628, "loc": { "start": { "line": 15, "column": 4 }, "end": { "line": 19, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 527, "end": 538, "loc": { "start": { "line": 15, "column": 4 }, "end": { "line": 15, "column": 15 }, "identifierName": "constructor" }, "name": "constructor" }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 541, "end": 628, "loc": { "start": { "line": 15, "column": 18 }, "end": { "line": 19, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 551, "end": 559, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 16 } }, "expression": { "type": "CallExpression", "start": 551, "end": 558, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 15 } }, "callee": { "type": "Super", "start": 551, "end": 556, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 13 } } }, "arguments": [] } }, { "type": "ExpressionStatement", "start": 568, "end": 594, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 34 } }, "expression": { "type": "AssignmentExpression", "start": 568, "end": 593, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 33 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 568, "end": 589, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 29 } }, "object": { "type": "ThisExpression", "start": 568, "end": 572, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 12 } } }, "property": { "type": "Identifier", "start": 573, "end": 589, "loc": { "start": { "line": 17, "column": 13 }, "end": { "line": 17, "column": 29 }, "identifierName": "programIDCounter" }, "name": "programIDCounter" }, "computed": false }, "right": { "type": "NumericLiteral", "start": 592, "end": 593, "loc": { "start": { "line": 17, "column": 32 }, "end": { "line": 17, "column": 33 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 } } }, { "type": "ExpressionStatement", "start": 603, "end": 622, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 27 } }, "expression": { "type": "AssignmentExpression", "start": 603, "end": 621, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 26 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 603, "end": 616, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 21 } }, "object": { "type": "ThisExpression", "start": 603, "end": 607, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 12 } } }, "property": { "type": "Identifier", "start": 608, "end": 616, "loc": { "start": { "line": 18, "column": 13 }, "end": { "line": 18, "column": 21 }, "identifierName": "programs" }, "name": "programs" }, "computed": false }, "right": { "type": "ObjectExpression", "start": 619, "end": 621, "loc": { "start": { "line": 18, "column": 24 }, "end": { "line": 18, "column": 26 } }, "properties": [] } } } ], "directives": [], "trailingComments": null }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Creates default programs for easy reference later on.\n ", "start": 634, "end": 706, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 23, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 711, "end": 1421, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 42, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 711, "end": 716, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 9 }, "identifierName": "start" }, "name": "start", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 719, "end": 1421, "loc": { "start": { "line": 24, "column": 12 }, "end": { "line": 42, "column": 5 } }, "body": [ { "type": "IfStatement", "start": 729, "end": 775, "loc": { "start": { "line": 25, "column": 8 }, "end": { "line": 26, "column": 19 } }, "test": { "type": "BinaryExpression", "start": 733, "end": 754, "loc": { "start": { "line": 25, "column": 12 }, "end": { "line": 25, "column": 33 } }, "left": { "type": "MemberExpression", "start": 733, "end": 746, "loc": { "start": { "line": 25, "column": 12 }, "end": { "line": 25, "column": 25 } }, "object": { "type": "Identifier", "start": 733, "end": 743, "loc": { "start": { "line": 25, "column": 12 }, "end": { "line": 25, "column": 22 }, "identifierName": "DOMManager" }, "name": "DOMManager" }, "property": { "type": "Identifier", "start": 744, "end": 746, "loc": { "start": { "line": 25, "column": 23 }, "end": { "line": 25, "column": 25 }, "identifierName": "GL" }, "name": "GL" }, "computed": false }, "operator": "==", "right": { "type": "NullLiteral", "start": 750, "end": 754, "loc": { "start": { "line": 25, "column": 29 }, "end": { "line": 25, "column": 33 } } } }, "consequent": { "type": "ReturnStatement", "start": 768, "end": 775, "loc": { "start": { "line": 26, "column": 12 }, "end": { "line": 26, "column": 19 } }, "argument": null }, "alternate": null }, { "type": "ExpressionStatement", "start": 784, "end": 1072, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 33, "column": 11 } }, "expression": { "type": "CallExpression", "start": 784, "end": 1071, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 33, "column": 10 } }, "callee": { "type": "MemberExpression", "start": 784, "end": 799, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 27, "column": 23 } }, "object": { "type": "ThisExpression", "start": 784, "end": 788, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 27, "column": 12 } } }, "property": { "type": "Identifier", "start": 789, "end": 799, "loc": { "start": { "line": 27, "column": 13 }, "end": { "line": 27, "column": 23 }, "identifierName": "addProgram" }, "name": "addProgram" }, "computed": false }, "arguments": [ { "type": "StringLiteral", "start": 800, "end": 809, "loc": { "start": { "line": 27, "column": 24 }, "end": { "line": 27, "column": 33 } }, "extra": { "rawValue": "Default", "raw": "'Default'" }, "value": "Default" }, { "type": "MemberExpression", "start": 811, "end": 833, "loc": { "start": { "line": 27, "column": 35 }, "end": { "line": 27, "column": 57 } }, "object": { "type": "Identifier", "start": 811, "end": 823, "loc": { "start": { "line": 27, "column": 35 }, "end": { "line": 27, "column": 47 }, "identifierName": "VertexShader" }, "name": "VertexShader" }, "property": { "type": "Identifier", "start": 824, "end": 833, "loc": { "start": { "line": 27, "column": 48 }, "end": { "line": 27, "column": 57 }, "identifierName": "DEFAULT_V" }, "name": "DEFAULT_V" }, "computed": false }, { "type": "MemberExpression", "start": 835, "end": 859, "loc": { "start": { "line": 27, "column": 59 }, "end": { "line": 27, "column": 83 } }, "object": { "type": "Identifier", "start": 835, "end": 849, "loc": { "start": { "line": 27, "column": 59 }, "end": { "line": 27, "column": 73 }, "identifierName": "FragmentShader" }, "name": "FragmentShader" }, "property": { "type": "Identifier", "start": 850, "end": 859, "loc": { "start": { "line": 27, "column": 74 }, "end": { "line": 27, "column": 83 }, "identifierName": "DEFAULT_F" }, "name": "DEFAULT_F" }, "computed": false }, { "type": "ObjectExpression", "start": 861, "end": 1070, "loc": { "start": { "line": 27, "column": 85 }, "end": { "line": 33, "column": 9 } }, "properties": [ { "type": "ObjectProperty", "start": 875, "end": 898, "loc": { "start": { "line": 28, "column": 12 }, "end": { "line": 28, "column": 35 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "StringLiteral", "start": 875, "end": 884, "loc": { "start": { "line": 28, "column": 12 }, "end": { "line": 28, "column": 21 } }, "extra": { "rawValue": "u_color", "raw": "'u_color'" }, "value": "u_color" }, "value": { "type": "StringLiteral", "start": 886, "end": 898, "loc": { "start": { "line": 28, "column": 23 }, "end": { "line": 28, "column": 35 } }, "extra": { "rawValue": "uniform4fv", "raw": "'uniform4fv'" }, "value": "uniform4fv" } }, { "type": "ObjectProperty", "start": 912, "end": 942, "loc": { "start": { "line": 29, "column": 12 }, "end": { "line": 29, "column": 42 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "StringLiteral", "start": 912, "end": 922, "loc": { "start": { "line": 29, "column": 12 }, "end": { "line": 29, "column": 22 } }, "extra": { "rawValue": "u_matrix", "raw": "'u_matrix'" }, "value": "u_matrix" }, "value": { "type": "StringLiteral", "start": 924, "end": 942, "loc": { "start": { "line": 29, "column": 24 }, "end": { "line": 29, "column": 42 } }, "extra": { "rawValue": "uniformMatrix3fv", "raw": "'uniformMatrix3fv'" }, "value": "uniformMatrix3fv" } }, { "type": "ObjectProperty", "start": 956, "end": 978, "loc": { "start": { "line": 30, "column": 12 }, "end": { "line": 30, "column": 34 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "StringLiteral", "start": 956, "end": 965, "loc": { "start": { "line": 30, "column": 12 }, "end": { "line": 30, "column": 21 } }, "extra": { "rawValue": "u_depth", "raw": "'u_depth'" }, "value": "u_depth" }, "value": { "type": "StringLiteral", "start": 967, "end": 978, "loc": { "start": { "line": 30, "column": 23 }, "end": { "line": 30, "column": 34 } }, "extra": { "rawValue": "uniform1f", "raw": "'uniform1f'" }, "value": "uniform1f" } }, { "type": "ObjectProperty", "start": 992, "end": 1016, "loc": { "start": { "line": 31, "column": 12 }, "end": { "line": 31, "column": 36 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "StringLiteral", "start": 992, "end": 1003, "loc": { "start": { "line": 31, "column": 12 }, "end": { "line": 31, "column": 23 } }, "extra": { "rawValue": "u_texture", "raw": "'u_texture'" }, "value": "u_texture" }, "value": { "type": "StringLiteral", "start": 1005, "end": 1016, "loc": { "start": { "line": 31, "column": 25 }, "end": { "line": 31, "column": 36 } }, "extra": { "rawValue": "uniform1i", "raw": "'uniform1i'" }, "value": "uniform1i" } }, { "type": "ObjectProperty", "start": 1030, "end": 1059, "loc": { "start": { "line": 32, "column": 12 }, "end": { "line": 32, "column": 41 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "StringLiteral", "start": 1030, "end": 1045, "loc": { "start": { "line": 32, "column": 12 }, "end": { "line": 32, "column": 27 } }, "extra": { "rawValue": "u_subTexcoord", "raw": "'u_subTexcoord'" }, "value": "u_subTexcoord" }, "value": { "type": "StringLiteral", "start": 1047, "end": 1059, "loc": { "start": { "line": 32, "column": 29 }, "end": { "line": 32, "column": 41 } }, "extra": { "rawValue": "uniform4fv", "raw": "'uniform4fv'" }, "value": "uniform4fv" } } ] } ] } }, { "type": "ExpressionStatement", "start": 1081, "end": 1415, "loc": { "start": { "line": 34, "column": 8 }, "end": { "line": 41, "column": 11 } }, "expression": { "type": "CallExpression", "start": 1081, "end": 1414, "loc": { "start": { "line": 34, "column": 8 }, "end": { "line": 41, "column": 10 } }, "callee": { "type": "MemberExpression", "start": 1081, "end": 1096, "loc": { "start": { "line": 34,