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,465 lines (1,464 loc) 838 kB
{ "type": "File", "start": 0, "end": 3469, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 108, "column": 1 } }, "program": { "type": "Program", "start": 0, "end": 3469, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 108, "column": 1 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 49, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 49 } }, "specifiers": [ { "type": "ImportNamespaceSpecifier", "start": 7, "end": 20, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 20 } }, "local": { "type": "Identifier", "start": 12, "end": 20, "loc": { "start": { "line": 1, "column": 12 }, "end": { "line": 1, "column": 20 }, "identifierName": "MathUtil" }, "name": "MathUtil" } } ], "source": { "type": "StringLiteral", "start": 26, "end": 48, "loc": { "start": { "line": 1, "column": 26 }, "end": { "line": 1, "column": 48 } }, "extra": { "rawValue": "../../utils/MathUtil", "raw": "'../../utils/MathUtil'" }, "value": "../../utils/MathUtil" } }, { "type": "ImportDeclaration", "start": 50, "end": 80, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 30 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 57, "end": 63, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 13 } }, "local": { "type": "Identifier", "start": 57, "end": 63, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 13 }, "identifierName": "Matrix" }, "name": "Matrix" } } ], "source": { "type": "StringLiteral", "start": 69, "end": 79, "loc": { "start": { "line": 2, "column": 19 }, "end": { "line": 2, "column": 29 } }, "extra": { "rawValue": "./Matrix", "raw": "'./Matrix'" }, "value": "./Matrix" } }, { "type": "ExportDefaultDeclaration", "start": 83, "end": 3469, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 108, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 98, "end": 3469, "loc": { "start": { "line": 5, "column": 15 }, "end": { "line": 108, "column": 1 } }, "id": { "type": "Identifier", "start": 104, "end": 111, "loc": { "start": { "line": 5, "column": 21 }, "end": { "line": 5, "column": 28 }, "identifierName": "Matrix3" }, "name": "Matrix3" }, "superClass": { "type": "Identifier", "start": 120, "end": 126, "loc": { "start": { "line": 5, "column": 37 }, "end": { "line": 5, "column": 43 }, "identifierName": "Matrix" }, "name": "Matrix" }, "body": { "type": "ClassBody", "start": 127, "end": 3469, "loc": { "start": { "line": 5, "column": 44 }, "end": { "line": 108, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 133, "end": 299, "loc": { "start": { "line": 6, "column": 4 }, "end": { "line": 11, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 133, "end": 144, "loc": { "start": { "line": 6, "column": 4 }, "end": { "line": 6, "column": 15 }, "identifierName": "constructor" }, "name": "constructor" }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "AssignmentPattern", "start": 145, "end": 171, "loc": { "start": { "line": 6, "column": 16 }, "end": { "line": 6, "column": 42 } }, "left": { "type": "Identifier", "start": 145, "end": 149, "loc": { "start": { "line": 6, "column": 16 }, "end": { "line": 6, "column": 20 }, "identifierName": "data" }, "name": "data" }, "right": { "type": "ArrayExpression", "start": 152, "end": 171, "loc": { "start": { "line": 6, "column": 23 }, "end": { "line": 6, "column": 42 } }, "elements": [ { "type": "NumericLiteral", "start": 153, "end": 154, "loc": { "start": { "line": 6, "column": 24 }, "end": { "line": 6, "column": 25 } }, "extra": { "rawValue": 1, "raw": "1" }, "value": 1 }, { "type": "NumericLiteral", "start": 155, "end": 156, "loc": { "start": { "line": 6, "column": 26 }, "end": { "line": 6, "column": 27 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 }, { "type": "NumericLiteral", "start": 157, "end": 158, "loc": { "start": { "line": 6, "column": 28 }, "end": { "line": 6, "column": 29 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 }, { "type": "NumericLiteral", "start": 159, "end": 160, "loc": { "start": { "line": 6, "column": 30 }, "end": { "line": 6, "column": 31 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 }, { "type": "NumericLiteral", "start": 161, "end": 162, "loc": { "start": { "line": 6, "column": 32 }, "end": { "line": 6, "column": 33 } }, "extra": { "rawValue": 1, "raw": "1" }, "value": 1 }, { "type": "NumericLiteral", "start": 163, "end": 164, "loc": { "start": { "line": 6, "column": 34 }, "end": { "line": 6, "column": 35 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 }, { "type": "NumericLiteral", "start": 165, "end": 166, "loc": { "start": { "line": 6, "column": 36 }, "end": { "line": 6, "column": 37 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 }, { "type": "NumericLiteral", "start": 167, "end": 168, "loc": { "start": { "line": 6, "column": 38 }, "end": { "line": 6, "column": 39 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 }, { "type": "NumericLiteral", "start": 169, "end": 170, "loc": { "start": { "line": 6, "column": 40 }, "end": { "line": 6, "column": 41 } }, "extra": { "rawValue": 1, "raw": "1" }, "value": 1 } ] } } ], "body": { "type": "BlockStatement", "start": 173, "end": 299, "loc": { "start": { "line": 6, "column": 44 }, "end": { "line": 11, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 183, "end": 191, "loc": { "start": { "line": 7, "column": 8 }, "end": { "line": 7, "column": 16 } }, "expression": { "type": "CallExpression", "start": 183, "end": 190, "loc": { "start": { "line": 7, "column": 8 }, "end": { "line": 7, "column": 15 } }, "callee": { "type": "Super", "start": 183, "end": 188, "loc": { "start": { "line": 7, "column": 8 }, "end": { "line": 7, "column": 13 } } }, "arguments": [] }, "trailingComments": [ { "type": "CommentLine", "value": "default x = 0, y = 0, scaleXY = 1, rotation = 0", "start": 200, "end": 249, "loc": { "start": { "line": 8, "column": 8 }, "end": { "line": 8, "column": 57 } } } ] }, { "type": "ExpressionStatement", "start": 258, "end": 272, "loc": { "start": { "line": 9, "column": 8 }, "end": { "line": 9, "column": 22 } }, "expression": { "type": "AssignmentExpression", "start": 258, "end": 271, "loc": { "start": { "line": 9, "column": 8 }, "end": { "line": 9, "column": 21 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 258, "end": 264, "loc": { "start": { "line": 9, "column": 8 }, "end": { "line": 9, "column": 14 } }, "object": { "type": "ThisExpression", "start": 258, "end": 262, "loc": { "start": { "line": 9, "column": 8 }, "end": { "line": 9, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 263, "end": 264, "loc": { "start": { "line": 9, "column": 13 }, "end": { "line": 9, "column": 14 }, "identifierName": "m" }, "name": "m" }, "computed": false, "leadingComments": null }, "right": { "type": "Identifier", "start": 267, "end": 271, "loc": { "start": { "line": 9, "column": 17 }, "end": { "line": 9, "column": 21 }, "identifierName": "data" }, "name": "data" }, "leadingComments": null }, "leadingComments": [ { "type": "CommentLine", "value": "default x = 0, y = 0, scaleXY = 1, rotation = 0", "start": 200, "end": 249, "loc": { "start": { "line": 8, "column": 8 }, "end": { "line": 8, "column": 57 } } } ] }, { "type": "ReturnStatement", "start": 281, "end": 293, "loc": { "start": { "line": 10, "column": 8 }, "end": { "line": 10, "column": 20 } }, "argument": { "type": "ThisExpression", "start": 288, "end": 292, "loc": { "start": { "line": 10, "column": 15 }, "end": { "line": 10, "column": 19 } } } } ], "directives": [], "trailingComments": null }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Sets the translation positions of the matrix with x, y points. This overwrites the values and \n * does not adjust the parameters to work relative to the rest of the matrix values.\n * \n * @param {number} x X position.\n * @param {number} y Y position.\n ", "start": 305, "end": 589, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 19, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 594, "end": 665, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 23, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 594, "end": 605, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 15 }, "identifierName": "setPosition" }, "name": "setPosition", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 606, "end": 607, "loc": { "start": { "line": 20, "column": 16 }, "end": { "line": 20, "column": 17 }, "identifierName": "x" }, "name": "x" }, { "type": "Identifier", "start": 609, "end": 610, "loc": { "start": { "line": 20, "column": 19 }, "end": { "line": 20, "column": 20 }, "identifierName": "y" }, "name": "y" } ], "body": { "type": "BlockStatement", "start": 612, "end": 665, "loc": { "start": { "line": 20, "column": 22 }, "end": { "line": 23, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 622, "end": 636, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 21, "column": 22 } }, "expression": { "type": "AssignmentExpression", "start": 622, "end": 635, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 21, "column": 21 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 622, "end": 631, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 21, "column": 17 } }, "object": { "type": "MemberExpression", "start": 622, "end": 628, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 21, "column": 14 } }, "object": { "type": "ThisExpression", "start": 622, "end": 626, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 21, "column": 12 } } }, "property": { "type": "Identifier", "start": 627, "end": 628, "loc": { "start": { "line": 21, "column": 13 }, "end": { "line": 21, "column": 14 }, "identifierName": "m" }, "name": "m" }, "computed": false }, "property": { "type": "NumericLiteral", "start": 629, "end": 630, "loc": { "start": { "line": 21, "column": 15 }, "end": { "line": 21, "column": 16 } }, "extra": { "rawValue": 6, "raw": "6" }, "value": 6 }, "computed": true }, "right": { "type": "Identifier", "start": 634, "end": 635, "loc": { "start": { "line": 21, "column": 20 }, "end": { "line": 21, "column": 21 }, "identifierName": "x" }, "name": "x" } } }, { "type": "ExpressionStatement", "start": 645, "end": 659, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 22 } }, "expression": { "type": "AssignmentExpression", "start": 645, "end": 658, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 21 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 645, "end": 654, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 17 } }, "object": { "type": "MemberExpression", "start": 645, "end": 651, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 14 } }, "object": { "type": "ThisExpression", "start": 645, "end": 649, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 12 } } }, "property": { "type": "Identifier", "start": 650, "end": 651, "loc": { "start": { "line": 22, "column": 13 }, "end": { "line": 22, "column": 14 }, "identifierName": "m" }, "name": "m" }, "computed": false }, "property": { "type": "NumericLiteral", "start": 652, "end": 653, "loc": { "start": { "line": 22, "column": 15 }, "end": { "line": 22, "column": 16 } }, "extra": { "rawValue": 7, "raw": "7" }, "value": 7 }, "computed": true }, "right": { "type": "Identifier", "start": 657, "end": 658, "loc": { "start": { "line": 22, "column": 20 }, "end": { "line": 22, "column": 21 }, "identifierName": "y" }, "name": "y" } } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Sets the translation positions of the matrix with x, y points. This overwrites the values and \n * does not adjust the parameters to work relative to the rest of the matrix values.\n * \n * @param {number} x X position.\n * @param {number} y Y position.\n ", "start": 305, "end": 589, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 19, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Sets the scale values of the matrix with w, h values. This overwrites the values and \n * does not adjust the parameters to work relative to the rest of the matrix values.\n * \n * @param {number} x X scale.\n * @param {number} y Y scale.\n ", "start": 671, "end": 940, "loc": { "start": { "line": 25, "column": 4 }, "end": { "line": 31, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 945, "end": 1013, "loc": { "start": { "line": 32, "column": 4 }, "end": { "line": 35, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 945, "end": 953, "loc": { "start": { "line": 32, "column": 4 }, "end": { "line": 32, "column": 12 }, "identifierName": "setScale" }, "name": "setScale", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 954, "end": 955, "loc": { "start": { "line": 32, "column": 13 }, "end": { "line": 32, "column": 14 }, "identifierName": "x" }, "name": "x" }, { "type": "Identifier", "start": 957, "end": 958, "loc": { "start": { "line": 32, "column": 16 }, "end": { "line": 32, "column": 17 }, "identifierName": "y" }, "name": "y" } ], "body": { "type": "BlockStatement", "start": 960, "end": 1013, "loc": { "start": { "line": 32, "column": 19 }, "end": { "line": 35, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 970, "end": 984, "loc": { "start": { "line": 33, "column": 8 }, "end": { "line": 33, "column": 22 } }, "expression": { "type": "AssignmentExpression", "start": 970, "end": 983, "loc": { "start": { "line": 33, "column": 8 }, "end": { "line": 33, "column": 21 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 970, "end": 979, "loc": { "start": { "line": 33, "column": 8 }, "end": { "line": 33, "column": 17 } }, "object": { "type": "MemberExpression", "start": 970, "end": 976, "loc": { "start": { "line": 33, "column": 8 }, "end": { "line": 33, "column": 14 } }, "object": { "type": "ThisExpression", "start": 970, "end": 974, "loc": { "start": { "line": 33, "column": 8 }, "end": { "line": 33, "column": 12 } } }, "property": { "type": "Identifier", "start": 975, "end": 976, "loc": { "start": { "line": 33, "column": 13 }, "end": { "line": 33, "column": 14 }, "identifierName": "m" }, "name": "m" }, "computed": false }, "property": { "type": "NumericLiteral", "start": 977, "end": 978, "loc": { "start": { "line": 33, "column": 15 }, "end": { "line": 33, "column": 16 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 }, "computed": true }, "right": { "type": "Identifier", "start": 982, "end": 983, "loc": { "start": { "line": 33, "column": 20 }, "end": { "line": 33, "column": 21 }, "identifierName": "x" }, "name": "x" } } }, { "type": "ExpressionStatement", "start": 993, "end": 1007, "loc": { "start": { "line": 34, "column": 8 }, "end": { "line": 34, "column": 22 } }, "expression": { "type": "AssignmentExpression", "start": 993, "end": 1006, "loc": { "start": { "line": 34, "column": 8 }, "end": { "line": 34, "column": 21 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 993, "end": 1002, "loc": { "start": { "line": 34, "column": 8 }, "end": { "line": 34, "column": 17 } }, "object": { "type": "MemberExpression", "start": 993, "end": 999, "loc": { "start": { "line": 34, "column": 8 }, "end": { "line": 34, "column": 14 } }, "object": { "type": "ThisExpression", "start": 993, "end": 997, "loc": { "start": { "line": 34, "column": 8 }, "end": { "line": 34, "column": 12 } } }, "property": { "type": "Identifier", "start": 998, "end": 999, "loc": { "start": { "line": 34, "column": 13 }, "end": { "line": 34, "column": 14