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,439 lines (1,438 loc) • 459 kB
JSON
{
"type": "File",
"start": 0,
"end": 3616,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 131,
"column": 28
}
},
"program": {
"type": "Program",
"start": 0,
"end": 3616,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 131,
"column": 28
}
},
"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": 79,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 46
}
},
"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": "GameObject"
},
"name": "GameObject"
}
}
],
"source": {
"type": "StringLiteral",
"start": 56,
"end": 78,
"loc": {
"start": {
"line": 2,
"column": 23
},
"end": {
"line": 2,
"column": 45
}
},
"extra": {
"rawValue": "../object/GameObject",
"raw": "'../object/GameObject'"
},
"value": "../object/GameObject"
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * A manager which manages all scenes and passes commands to the current scene.\n * \n * Manages scenes on a stack, pausing scenes below them (stopping rendering), and managing\n * the top scene for triggering updates on all objects on the scene.\n * \n * GameObjects, components, or anything else can use the SceneManager to reference the\n * current active scene. There are also wrapper functions for passing SceneObjects and\n * Viewports to the current scene for registration with that scene.\n ",
"start": 81,
"end": 578,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 13,
"column": 3
}
}
}
]
},
{
"type": "ExportNamedDeclaration",
"start": 579,
"end": 3491,
"loc": {
"start": {
"line": 14,
"column": 0
},
"end": {
"line": 125,
"column": 1
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "ClassDeclaration",
"start": 586,
"end": 3491,
"loc": {
"start": {
"line": 14,
"column": 7
},
"end": {
"line": 125,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 592,
"end": 605,
"loc": {
"start": {
"line": 14,
"column": 13
},
"end": {
"line": 14,
"column": 26
},
"identifierName": "_SceneManager"
},
"name": "_SceneManager",
"leadingComments": null
},
"superClass": {
"type": "Identifier",
"start": 614,
"end": 621,
"loc": {
"start": {
"line": 14,
"column": 35
},
"end": {
"line": 14,
"column": 42
},
"identifierName": "Manager"
},
"name": "Manager"
},
"body": {
"type": "ClassBody",
"start": 622,
"end": 3491,
"loc": {
"start": {
"line": 14,
"column": 43
},
"end": {
"line": 125,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 628,
"end": 692,
"loc": {
"start": {
"line": 15,
"column": 4
},
"end": {
"line": 18,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 628,
"end": 639,
"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": 642,
"end": 692,
"loc": {
"start": {
"line": 15,
"column": 18
},
"end": {
"line": 18,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 652,
"end": 660,
"loc": {
"start": {
"line": 16,
"column": 8
},
"end": {
"line": 16,
"column": 16
}
},
"expression": {
"type": "CallExpression",
"start": 652,
"end": 659,
"loc": {
"start": {
"line": 16,
"column": 8
},
"end": {
"line": 16,
"column": 15
}
},
"callee": {
"type": "Super",
"start": 652,
"end": 657,
"loc": {
"start": {
"line": 16,
"column": 8
},
"end": {
"line": 16,
"column": 13
}
}
},
"arguments": []
}
},
{
"type": "ExpressionStatement",
"start": 669,
"end": 686,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 25
}
},
"expression": {
"type": "AssignmentExpression",
"start": 669,
"end": 685,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 24
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 669,
"end": 680,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 19
}
},
"object": {
"type": "ThisExpression",
"start": 669,
"end": 673,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 674,
"end": 680,
"loc": {
"start": {
"line": 17,
"column": 13
},
"end": {
"line": 17,
"column": 19
},
"identifierName": "scenes"
},
"name": "scenes"
},
"computed": false
},
"right": {
"type": "ArrayExpression",
"start": 683,
"end": 685,
"loc": {
"start": {
"line": 17,
"column": 22
},
"end": {
"line": 17,
"column": 24
}
},
"elements": []
}
}
}
],
"directives": [],
"trailingComments": null
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Adds a SceneObject to the current scene on the stack. The scene will hold \n * reference and manage the SceneObject.\n * \n * @param {SceneObject} sceneObject The SceneObject that is being registered.\n ",
"start": 698,
"end": 926,
"loc": {
"start": {
"line": 20,
"column": 4
},
"end": {
"line": 25,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 931,
"end": 1143,
"loc": {
"start": {
"line": 26,
"column": 4
},
"end": {
"line": 32,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 931,
"end": 950,
"loc": {
"start": {
"line": 26,
"column": 4
},
"end": {
"line": 26,
"column": 23
},
"identifierName": "registerSceneObject"
},
"name": "registerSceneObject",
"leadingComments": null
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 951,
"end": 962,
"loc": {
"start": {
"line": 26,
"column": 24
},
"end": {
"line": 26,
"column": 35
},
"identifierName": "sceneObject"
},
"name": "sceneObject"
}
],
"body": {
"type": "BlockStatement",
"start": 964,
"end": 1143,
"loc": {
"start": {
"line": 26,
"column": 37
},
"end": {
"line": 32,
"column": 5
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 974,
"end": 1009,
"loc": {
"start": {
"line": 27,
"column": 8
},
"end": {
"line": 27,
"column": 43
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 978,
"end": 1008,
"loc": {
"start": {
"line": 27,
"column": 12
},
"end": {
"line": 27,
"column": 42
}
},
"id": {
"type": "Identifier",
"start": 978,
"end": 983,
"loc": {
"start": {
"line": 27,
"column": 12
},
"end": {
"line": 27,
"column": 17
},
"identifierName": "scene"
},
"name": "scene"
},
"init": {
"type": "CallExpression",
"start": 986,
"end": 1008,
"loc": {
"start": {
"line": 27,
"column": 20
},
"end": {
"line": 27,
"column": 42
}
},
"callee": {
"type": "MemberExpression",
"start": 986,
"end": 1006,
"loc": {
"start": {
"line": 27,
"column": 20
},
"end": {
"line": 27,
"column": 40
}
},
"object": {
"type": "ThisExpression",
"start": 986,
"end": 990,
"loc": {
"start": {
"line": 27,
"column": 20
},
"end": {
"line": 27,
"column": 24
}
}
},
"property": {
"type": "Identifier",
"start": 991,
"end": 1006,
"loc": {
"start": {
"line": 27,
"column": 25
},
"end": {
"line": 27,
"column": 40
},
"identifierName": "getCurrentScene"
},
"name": "getCurrentScene"
},
"computed": false
},
"arguments": []
}
}
],
"kind": "let"
},
{
"type": "IfStatement",
"start": 1018,
"end": 1137,
"loc": {
"start": {
"line": 28,
"column": 8
},
"end": {
"line": 31,
"column": 28
}
},
"test": {
"type": "BinaryExpression",
"start": 1022,
"end": 1035,
"loc": {
"start": {
"line": 28,
"column": 12
},
"end": {
"line": 28,
"column": 25
}
},
"left": {
"type": "Identifier",
"start": 1022,
"end": 1027,
"loc": {
"start": {
"line": 28,
"column": 12
},
"end": {
"line": 28,
"column": 17
},
"identifierName": "scene"
},
"name": "scene"
},
"operator": "!=",
"right": {
"type": "NullLiteral",
"start": 1031,
"end": 1035,
"loc": {
"start": {
"line": 28,
"column": 21
},
"end": {
"line": 28,
"column": 25
}
}
}
},
"consequent": {
"type": "ReturnStatement",
"start": 1049,
"end": 1095,
"loc": {
"start": {
"line": 29,
"column": 12
},
"end": {
"line": 29,
"column": 58
}
},
"argument": {
"type": "CallExpression",
"start": 1056,
"end": 1094,
"loc": {
"start": {
"line": 29,
"column": 19
},
"end": {
"line": 29,
"column": 57
}
},
"callee": {
"type": "MemberExpression",
"start": 1056,
"end": 1081,
"loc": {
"start": {
"line": 29,
"column": 19
},
"end": {
"line": 29,
"column": 44
}
},
"object": {
"type": "Identifier",
"start": 1056,
"end": 1061,
"loc": {
"start": {
"line": 29,
"column": 19
},
"end": {
"line": 29,
"column": 24
},
"identifierName": "scene"
},
"name": "scene"
},
"property": {
"type": "Identifier",
"start": 1062,
"end": 1081,
"loc": {
"start": {
"line": 29,
"column": 25
},
"end": {
"line": 29,
"column": 44
},
"identifierName": "registerSceneObject"
},
"name": "registerSceneObject"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 1082,
"end": 1093,
"loc": {
"start": {
"line": 29,
"column": 45
},
"end": {
"line": 29,
"column": 56
},
"identifierName": "sceneObject"
},
"name": "sceneObject"
}
]
}
},
"alternate": {
"type": "ReturnStatement",
"start": 1121,
"end": 1137,
"loc": {
"start": {
"line": 31,
"column": 12
},
"end": {
"line": 31,
"column": 28
}
},
"argument": {
"type": "ArrowFunctionExpression",
"start": 1128,
"end": 1136,
"loc": {
"start": {
"line": 31,
"column": 19
},
"end": {
"line": 31,
"column": 27
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 1134,
"end": 1136,
"loc": {
"start": {
"line": 31,
"column": 25
},
"end": {
"line": 31,
"column": 27
}
},
"body": [],
"directives": []
}
}
}
}
],
"directives": [],
"trailingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Adds a SceneObject to the current scene on the stack. The scene will hold \n * reference and manage the SceneObject.\n * \n * @param {SceneObject} sceneObject The SceneObject that is being registered.\n ",
"start": 698,
"end": 926,
"loc": {
"start": {
"line": 20,
"column": 4
},
"end": {
"line": 25,
"column": 7
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Addsa viewport to the current scene on the stack. The scene will hold reference\n * to the viewport.\n * \n * @param {viewport} viewport The Viewport that is being registered.\n ",
"start": 1149,
"end": 1352,
"loc": {
"start": {
"line": 34,
"column": 4
},
"end": {
"line": 39,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 1357,
"end": 1515,
"loc": {
"start": {
"line": 40,
"column": 4
},
"end": {
"line": 44,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 1357,
"end": 1373,
"loc": {
"start": {
"line": 40,
"column": 4
},
"end": {
"line": 40,
"column": 20
},
"identifierName": "registerViewport"
},
"name": "registerViewport",
"leadingComments": null
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 1374,
"end": 1382,
"loc": {
"start": {
"line": 40,
"column": 21
},
"end": {
"line": 40,
"column": 29
},
"identifierName": "viewport"
},
"name": "viewport"
}
],
"body": {
"type": "BlockStatement",
"start": 1384,
"end": 1515,
"loc": {
"start": {
"line": 40,
"column": 31
},
"end": {
"line": 44,
"column": 5
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 1394,
"end": 1429,
"loc": {
"start": {
"line": 41,
"column": 8
},
"end": {
"line": 41,
"column": 43
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 1398,
"end": 1428,
"loc": {
"start": {
"line": 41,
"column": 12
},
"end": {
"line": 41,
"column": 42
}
},
"id": {
"type": "Identifier",
"start": 1398,
"end": 1403,
"loc": {
"start": {
"line": 41,
"column": 12
},
"end": {
"line": 41,
"column": 17
},
"identifierName": "scene"
},
"name": "scene"
},
"init": {
"type": "CallExpression",
"start": 1406,
"end": 1428,
"loc": {
"start": {
"line": 41,
"column": 20
},
"end": {
"line": 41,
"column": 42
}
},
"callee": {
"type": "MemberExpression",
"start": 1406,
"end": 1426,
"loc": {
"start": {
"line": 41,
"column": 20
},
"end": {
"line": 41,
"column": 40
}
},
"object": {
"type": "ThisExpression",
"start": 1406,
"end": 1410,
"loc": {
"start": {
"line": 41,
"column": 20
},
"end": {
"line": 41,
"column": 24
}
}
},
"property": {
"type": "Identifier",
"start": 1411,
"end": 1426,
"loc": {
"start": {
"line": 41,
"column": 25
},
"end": {
"line": 41,
"column": 40
},
"identifierName": "getCurrentScene"
},
"name": "getCurrentScene"
},
"computed": false
},
"arguments": []
}
}
],
"kind": "let"
},
{
"type": "IfStatement",
"start": 1438,
"end": 1509,
"loc": {
"start": {
"line": 42,
"column": 8
},
"end": {
"line": 43,
"column": 52
}
},
"test": {
"type": "BinaryExpression",
"start": 1442,
"end": 1455,
"loc": {
"start": {
"line": 42,
"column": 12
},
"end": {
"line": 42,
"column": 25
}
},
"left": {
"type": "Identifier",
"start": 1442,
"end": 1447,
"loc": {
"start": {
"line": 42,
"column": 12
},
"end": {
"line": 42,
"column": 17
},
"identifierName": "scene"
},
"name": "scene"
},
"operator": "!=",
"right": {
"type": "NullLiteral",
"start": 1451,
"end": 1455,
"loc": {
"start": {
"line": 42,
"column": 21
},
"end": {
"line": 42,
"column": 25
}
}
}
},
"consequent": {
"type": "ReturnStatement",
"start": 1469,
"end": 1509,
"loc": {
"start": {
"line": 43,
"column": 12
},
"end": {
"line": 43,
"column": 52
}
},
"argument": {
"type": "CallExpression",
"start": 1476,
"end": 1508,
"loc": {
"start": {
"line": 43,
"column": 19
},
"end": {
"line": 43,
"column": 51
}
},
"callee": {
"type": "MemberExpression",
"start": 1476,
"end": 1498,
"loc": {
"start": {
"line": 43,
"column": 19
},
"end": {
"line": 43,
"column": 41
}
},
"object": {
"type": "Identifier",
"start": 1476,
"end": 1481,
"loc": {
"start": {
"line": 43,
"column": 19
},
"end": {
"line": 43,
"column": 24
},
"identifierName": "scene"
},
"name": "scene"
},
"property": {
"type": "Identifier",
"start": 1482,
"end": 1498,
"loc": {
"start": {
"line": 43,
"column": 25
},
"end": {
"line": 43,
"column": 41
},
"identifierName": "registerViewport"
},
"name": "registerViewport"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 1499,
"end": 1507,
"loc": {
"start": {
"line": 43,
"column": 42
},
"end": {
"line": 43,
"column": 50
},
"identifierName": "viewport"
},
"name": "viewport"
}
]
}
},
"alternate": null
}
],
"directives": [],
"trailingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Addsa viewport to the current scene on the stack. The scene will hold reference\n * to the viewport.\n * \n * @param {viewport} viewport The Viewport that is being registered.\n ",
"start": 1149,
"end": 1352,
"loc": {
"start": {
"line": 34,
"column": 4
},
"end": {
"line": 39,
"column": 7
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Gets the current scene on the stack. This scene will be the one currently\n * used in the update loop.\n ",
"start": 1521,
"end": 1645,
"loc": {
"start": {
"line": 46,
"column": 4
},
"end": {
"line": 49,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 1650,
"end": 1788,
"loc": {
"start": {
"line": 50,
"column": 4
},
"end": {
"line": 54,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 1650,
"end": 1665,
"loc": {
"start": {
"line": 50,
"column": 4
},
"end": {
"line": 50,
"column": 19
},
"identifierName": "getCurrentScene"
},
"name": "getCurrentScene",
"leadingComments": null
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 1668,
"end": 1788,
"loc": {
"start": {
"line": 50,
"column": 22
},
"end": {
"line": 54,
"column": 5
}
},
"body": [
{
"type": "IfStatement",
"start": 1678,
"end": 1761,
"loc": {
"start": {
"line": 51,
"column": 8
},
"end": {
"line": 52,
"column": 55
}
},
"test": {
"type": "BinaryExpression",
"start": 1682,
"end": 1704,
"loc": {
"start": {
"line": 51,
"column": 12
},
"end": {
"line": 51,
"column": 34
}
},
"left": {
"type": "MemberExpression",
"start": 1682,
"end": 1700,
"loc": {
"start": {
"line": 51,
"column": 12
},
"end": {
"line": 51,
"column": 30
}
},
"object": {
"type": "MemberExpression",
"start": 1682,
"end": 1693,
"loc": {
"start": {
"line": 51,
"column": 12
},
"end": {
"line": 51,
"column": 23
}
},
"object": {
"type": "ThisExpression",
"start": 1682,
"end": 1686,
"loc": {
"start": {
"line": 51,
"column": 12
},
"end": {