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,487 lines 115 kB
{ "type": "File", "start": 0, "end": 1302, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 43, "column": 1 } }, "program": { "type": "Program", "start": 0, "end": 1302, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 43, "column": 1 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 38, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 38 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 17, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 17 } }, "local": { "type": "Identifier", "start": 7, "end": 17, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 17 }, "identifierName": "Renderable" }, "name": "Renderable" } } ], "source": { "type": "StringLiteral", "start": 23, "end": 37, "loc": { "start": { "line": 1, "column": 23 }, "end": { "line": 1, "column": 37 } }, "extra": { "rawValue": "./Renderable", "raw": "'./Renderable'" }, "value": "./Renderable" } }, { "type": "ImportDeclaration", "start": 39, "end": 85, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 46 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 46, "end": 53, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 14 } }, "local": { "type": "Identifier", "start": 46, "end": 53, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 14 }, "identifierName": "Matrix3" }, "name": "Matrix3" } } ], "source": { "type": "StringLiteral", "start": 59, "end": 84, "loc": { "start": { "line": 2, "column": 20 }, "end": { "line": 2, "column": 45 } }, "extra": { "rawValue": "../render/WebGL/Matrix3", "raw": "'../render/WebGL/Matrix3'" }, "value": "../render/WebGL/Matrix3" } }, { "type": "ImportDeclaration", "start": 86, "end": 141, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 55 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 93, "end": 107, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 21 } }, "local": { "type": "Identifier", "start": 93, "end": 107, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 21 }, "identifierName": "ProgramManager" }, "name": "ProgramManager" } } ], "source": { "type": "StringLiteral", "start": 113, "end": 140, "loc": { "start": { "line": 3, "column": 27 }, "end": { "line": 3, "column": 54 } }, "extra": { "rawValue": "../manager/ProgramManager", "raw": "'../manager/ProgramManager'" }, "value": "../manager/ProgramManager" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Renderable2DMultitex is a renderable component, similar to the Renderable2D, except\n * it supports multiple textures. The program assigned to this renderable computes what to\n * do with the shaders passed.\n ", "start": 143, "end": 359, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 9, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 360, "end": 1302, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 43, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 375, "end": 1302, "loc": { "start": { "line": 10, "column": 15 }, "end": { "line": 43, "column": 1 } }, "id": { "type": "Identifier", "start": 381, "end": 401, "loc": { "start": { "line": 10, "column": 21 }, "end": { "line": 10, "column": 41 }, "identifierName": "Renderable2DMultitex" }, "name": "Renderable2DMultitex", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 410, "end": 420, "loc": { "start": { "line": 10, "column": 50 }, "end": { "line": 10, "column": 60 }, "identifierName": "Renderable" }, "name": "Renderable" }, "body": { "type": "ClassBody", "start": 421, "end": 1302, "loc": { "start": { "line": 10, "column": 61 }, "end": { "line": 43, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 427, "end": 567, "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 14, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 427, "end": 438, "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 11, "column": 15 }, "identifierName": "constructor" }, "name": "constructor" }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "AssignmentPattern", "start": 439, "end": 485, "loc": { "start": { "line": 11, "column": 16 }, "end": { "line": 11, "column": 62 } }, "left": { "type": "Identifier", "start": 439, "end": 446, "loc": { "start": { "line": 11, "column": 16 }, "end": { "line": 11, "column": 23 }, "identifierName": "program" }, "name": "program" }, "right": { "type": "CallExpression", "start": 449, "end": 485, "loc": { "start": { "line": 11, "column": 26 }, "end": { "line": 11, "column": 62 } }, "callee": { "type": "MemberExpression", "start": 449, "end": 474, "loc": { "start": { "line": 11, "column": 26 }, "end": { "line": 11, "column": 51 } }, "object": { "type": "Identifier", "start": 449, "end": 463, "loc": { "start": { "line": 11, "column": 26 }, "end": { "line": 11, "column": 40 }, "identifierName": "ProgramManager" }, "name": "ProgramManager" }, "property": { "type": "Identifier", "start": 464, "end": 474, "loc": { "start": { "line": 11, "column": 41 }, "end": { "line": 11, "column": 51 }, "identifierName": "getProgram" }, "name": "getProgram" }, "computed": false }, "arguments": [ { "type": "StringLiteral", "start": 475, "end": 484, "loc": { "start": { "line": 11, "column": 52 }, "end": { "line": 11, "column": 61 } }, "extra": { "rawValue": "Default", "raw": "'Default'" }, "value": "Default" } ] } } ], "body": { "type": "BlockStatement", "start": 487, "end": 567, "loc": { "start": { "line": 11, "column": 64 }, "end": { "line": 14, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 497, "end": 512, "loc": { "start": { "line": 12, "column": 8 }, "end": { "line": 12, "column": 23 } }, "expression": { "type": "CallExpression", "start": 497, "end": 511, "loc": { "start": { "line": 12, "column": 8 }, "end": { "line": 12, "column": 22 } }, "callee": { "type": "Super", "start": 497, "end": 502, "loc": { "start": { "line": 12, "column": 8 }, "end": { "line": 12, "column": 13 } } }, "arguments": [ { "type": "Identifier", "start": 503, "end": 510, "loc": { "start": { "line": 12, "column": 14 }, "end": { "line": 12, "column": 21 }, "identifierName": "program" }, "name": "program" } ] } }, { "type": "ExpressionStatement", "start": 521, "end": 561, "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 48 } }, "expression": { "type": "AssignmentExpression", "start": 521, "end": 560, "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 47 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 521, "end": 535, "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 22 } }, "object": { "type": "ThisExpression", "start": 521, "end": 525, "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 12 } } }, "property": { "type": "Identifier", "start": 526, "end": 535, "loc": { "start": { "line": 13, "column": 13 }, "end": { "line": 13, "column": 22 }, "identifierName": "className" }, "name": "className" }, "computed": false }, "right": { "type": "StringLiteral", "start": 538, "end": 560, "loc": { "start": { "line": 13, "column": 25 }, "end": { "line": 13, "column": 47 } }, "extra": { "rawValue": "Renderable2DMultitex", "raw": "'Renderable2DMultitex'" }, "value": "Renderable2DMultitex" } } } ], "directives": [], "trailingComments": null }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Adds a texture to this renderable.\n * \n * @param {textureJSONObject} textureObject Texture reference object, from TextureManager.\n ", "start": 573, "end": 729, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 20, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 734, "end": 810, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 23, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 734, "end": 744, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 21, "column": 14 }, "identifierName": "addTexture" }, "name": "addTexture", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 745, "end": 758, "loc": { "start": { "line": 21, "column": 15 }, "end": { "line": 21, "column": 28 }, "identifierName": "textureObject" }, "name": "textureObject" } ], "body": { "type": "BlockStatement", "start": 760, "end": 810, "loc": { "start": { "line": 21, "column": 30 }, "end": { "line": 23, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 770, "end": 804, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 42 } }, "expression": { "type": "CallExpression", "start": 770, "end": 803, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 41 } }, "callee": { "type": "MemberExpression", "start": 770, "end": 788, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 26 } }, "object": { "type": "MemberExpression", "start": 770, "end": 783, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 21 } }, "object": { "type": "ThisExpression", "start": 770, "end": 774, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 12 } } }, "property": { "type": "Identifier", "start": 775, "end": 783, "loc": { "start": { "line": 22, "column": 13 }, "end": { "line": 22, "column": 21 }, "identifierName": "textures" }, "name": "textures" }, "computed": false }, "property": { "type": "Identifier", "start": 784, "end": 788, "loc": { "start": { "line": 22, "column": 22 }, "end": { "line": 22, "column": 26 }, "identifierName": "push" }, "name": "push" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 789, "end": 802, "loc": { "start": { "line": 22, "column": 27 }, "end": { "line": 22, "column": 40 }, "identifierName": "textureObject" }, "name": "textureObject" } ] } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Adds a texture to this renderable.\n * \n * @param {textureJSONObject} textureObject Texture reference object, from TextureManager.\n ", "start": 573, "end": 729, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 20, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Removes the nth texture from this component. Textures are pushed to end of list when added.\n * \n * @param {number} textureIndex Index of texture to remove.\n ", "start": 816, "end": 998, "loc": { "start": { "line": 25, "column": 4 }, "end": { "line": 29, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 1003, "end": 1176, "loc": { "start": { "line": 30, "column": 4 }, "end": { "line": 35, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 1003, "end": 1016, "loc": { "start": { "line": 30, "column": 4 }, "end": { "line": 30, "column": 17 }, "identifierName": "removeTexture" }, "name": "removeTexture", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 1017, "end": 1029, "loc": { "start": { "line": 30, "column": 18 }, "end": { "line": 30, "column": 30 }, "identifierName": "textureIndex" }, "name": "textureIndex" } ], "body": { "type": "BlockStatement", "start": 1031, "end": 1176, "loc": { "start": { "line": 30, "column": 32 }, "end": { "line": 35, "column": 5 } }, "body": [ { "type": "IfStatement", "start": 1041, "end": 1122, "loc": { "start": { "line": 31, "column": 8 }, "end": { "line": 32, "column": 19 } }, "test": { "type": "LogicalExpression", "start": 1045, "end": 1101, "loc": { "start": { "line": 31, "column": 12 }, "end": { "line": 31, "column": 68 } }, "left": { "type": "BinaryExpression", "start": 1045, "end": 1061, "loc": { "start": { "line": 31, "column": 12 }, "end": { "line": 31, "column": 28 } }, "left": { "type": "Identifier", "start": 1045, "end": 1057, "loc": { "start": { "line": 31, "column": 12 }, "end": { "line": 31, "column": 24 }, "identifierName": "textureIndex" }, "name": "textureIndex" }, "operator": "<", "right": { "type": "NumericLiteral", "start": 1060, "end": 1061, "loc": { "start": { "line": 31, "column": 27 }, "end": { "line": 31, "column": 28 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 } }, "operator": "||", "right": { "type": "BinaryExpression", "start": 1065, "end": 1101, "loc": { "start": { "line": 31, "column": 32 }, "end": { "line": 31, "column": 68 } }, "left": { "type": "Identifier", "start": 1065, "end": 1077, "loc": { "start": { "line": 31, "column": 32 }, "end": { "line": 31, "column": 44 }, "identifierName": "textureIndex" }, "name": "textureIndex" }, "operator": ">=", "right": { "type": "MemberExpression", "start": 1081, "end": 1101, "loc": { "start": { "line": 31, "column": 48 }, "end": { "line": 31, "column": 68 } }, "object": { "type": "MemberExpression", "start": 1081, "end": 1094, "loc": { "start": { "line": 31, "column": 48 }, "end": { "line": 31, "column": 61 } }, "object": { "type": "ThisExpression", "start": 1081, "end": 1085, "loc": { "start": { "line": 31, "column": 48 }, "end": { "line": 31, "column": 52 } } }, "property": { "type": "Identifier", "start": 1086, "end": 1094, "loc": { "start": { "line": 31, "column": 53 }, "end": { "line": 31, "column": 61 }, "identifierName": "textures" }, "name": "textures" }, "computed": false }, "property": { "type": "Identifier", "start": 1095, "end": 1101, "loc": { "start": { "line": 31, "column": 62 }, "end": { "line": 31, "column": 68 }, "identifierName": "length" }, "name": "length" }, "computed": false } } }, "consequent": { "type": "ReturnStatement", "start": 1115, "end": 1122, "loc": { "start": { "line": 32, "column": 12 }, "end": { "line": 32, "column": 19 } }, "argument": null }, "alternate": null }, { "type": "ExpressionStatement", "start": 1132, "end": 1170, "loc": { "start": { "line": 34, "column": 8 }, "end": { "line": 34, "column": 46 } }, "expression": { "type": "CallExpression", "start": 1132, "end": 1169, "loc": { "start": { "line": 34, "column": 8 }, "end": { "line": 34, "column": 45 } }, "callee": { "type": "MemberExpression", "start": 1132, "end": 1152, "loc": { "start": { "line": 34, "column": 8 }, "end": { "line": 34, "column": 28 } }, "object": { "type": "MemberExpression", "start": 1132, "end": 1145, "loc": { "start": { "line": 34, "column": 8 }, "end": { "line": 34, "column": 21 } }, "object": { "type": "ThisExpression", "start": 1132, "end": 1136, "loc": { "start": { "line": 34, "column": 8 }, "end": { "line": 34, "column": 12 } } }, "property": { "type": "Identifier", "start": 1137, "end": 1145, "loc": { "start": { "line": 34, "column": 13 }, "end": { "line": 34, "column": 21 }, "identifierName": "textures" }, "name": "textures" }, "computed": false }, "property": { "type": "Identifier", "start": 1146, "end": 1152, "loc": { "start": { "line": 34, "column": 22 }, "end": { "line": 34, "column": 28 }, "identifierName": "splice" }, "name": "splice" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 1153, "end": 1165, "loc": { "start": { "line": 34, "column": 29 }, "end": { "line": 34, "column": 41 }, "identifierName": "textureIndex" }, "name": "textureIndex" }, { "type": "NumericLiteral", "start": 1167, "end": 1168, "loc": { "start": { "line": 34, "column": 43 }, "end": { "line": 34, "column": 44 } }, "extra": { "rawValue": 1, "raw": "1" }, "value": 1 } ] } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Removes the nth texture from this component. Textures are pushed to end of list when added.\n * \n * @param {number} textureIndex Index of texture to remove.\n ", "start": 816, "end": 998, "loc": { "start": { "line": 25, "column": 4 }, "end": { "line": 29, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Removes all textures from this renderable.\n ", "start": 1182, "end": 1243, "loc": { "start": { "line": 37, "column": 4 }, "end": { "line": 39, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 1248, "end": 1300, "loc": { "start": { "line": 40, "column": 4 }, "end": { "line": 42, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 1248, "end": 1262, "loc": { "start": { "line": 40, "column": 4 }, "end": { "line": 40, "column": 18 }, "identifierName": "removeTextures" }, "name": "removeTextures", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 1265, "end": 1300, "loc": { "start": { "line": 40, "column": 21 }, "end": { "line": 42, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 1275, "end": 1294, "loc": { "start": { "line": 41, "column": 8 }, "end": { "line": 41, "column": 27 } }, "expression": { "type": "As