UNPKG

oxygen-core

Version:

Oxygen game engine (Xenon Core for browsers)

1,562 lines (1,561 loc) 631 kB
{ "type": "File", "start": 0, "end": 3801, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 190, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 3801, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 190, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 30, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 30 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 13, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 13 } }, "local": { "type": "Identifier", "start": 7, "end": 13, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 13 }, "identifierName": "Camera" }, "name": "Camera" } } ], "source": { "type": "StringLiteral", "start": 19, "end": 29, "loc": { "start": { "line": 1, "column": 19 }, "end": { "line": 1, "column": 29 } }, "extra": { "rawValue": "./Camera", "raw": "'./Camera'" }, "value": "./Camera" } }, { "type": "ImportDeclaration", "start": 32, "end": 71, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 39 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 39, "end": 45, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 13 } }, "local": { "type": "Identifier", "start": 39, "end": 45, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 13 }, "identifierName": "System" }, "name": "System" } } ], "source": { "type": "StringLiteral", "start": 51, "end": 70, "loc": { "start": { "line": 2, "column": 19 }, "end": { "line": 2, "column": 38 } }, "extra": { "rawValue": "../systems/System", "raw": "'../systems/System'" }, "value": "../systems/System" } }, { "type": "ImportDeclaration", "start": 73, "end": 115, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 42 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 82, "end": 86, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 13 } }, "imported": { "type": "Identifier", "start": 82, "end": 86, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 13 }, "identifierName": "mat4" }, "name": "mat4" }, "local": { "type": "Identifier", "start": 82, "end": 86, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 13 }, "identifierName": "mat4" }, "name": "mat4" } } ], "source": { "type": "StringLiteral", "start": 94, "end": 114, "loc": { "start": { "line": 3, "column": 21 }, "end": { "line": 3, "column": 41 } }, "extra": { "rawValue": "../utils/gl-matrix", "raw": "'../utils/gl-matrix'" }, "value": "../utils/gl-matrix" } }, { "type": "VariableDeclaration", "start": 119, "end": 206, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 8, "column": 2 } }, "declarations": [ { "type": "VariableDeclarator", "start": 125, "end": 205, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 8, "column": 1 } }, "id": { "type": "Identifier", "start": 125, "end": 133, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 14 }, "identifierName": "ZoomMode" }, "name": "ZoomMode" }, "init": { "type": "ObjectExpression", "start": 136, "end": 205, "loc": { "start": { "line": 5, "column": 17 }, "end": { "line": 8, "column": 1 } }, "properties": [ { "type": "ObjectProperty", "start": 141, "end": 171, "loc": { "start": { "line": 6, "column": 2 }, "end": { "line": 6, "column": 32 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 141, "end": 154, "loc": { "start": { "line": 6, "column": 2 }, "end": { "line": 6, "column": 15 }, "identifierName": "PIXEL_PERFECT" }, "name": "PIXEL_PERFECT" }, "value": { "type": "StringLiteral", "start": 156, "end": 171, "loc": { "start": { "line": 6, "column": 17 }, "end": { "line": 6, "column": 32 } }, "extra": { "rawValue": "pixel-perfect", "raw": "'pixel-perfect'" }, "value": "pixel-perfect" } }, { "type": "ObjectProperty", "start": 176, "end": 202, "loc": { "start": { "line": 7, "column": 2 }, "end": { "line": 7, "column": 28 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 176, "end": 187, "loc": { "start": { "line": 7, "column": 2 }, "end": { "line": 7, "column": 13 }, "identifierName": "KEEP_ASPECT" }, "name": "KEEP_ASPECT" }, "value": { "type": "StringLiteral", "start": 189, "end": 202, "loc": { "start": { "line": 7, "column": 15 }, "end": { "line": 7, "column": 28 } }, "extra": { "rawValue": "keep-aspect", "raw": "'keep-aspect'" }, "value": "keep-aspect" } } ] } } ], "kind": "const", "trailingComments": [ { "type": "CommentBlock", "value": "*\r\n * Camera used to view 2D scene.\r\n *\r\n * @example\r\n * const component = new Camera2D();\r\n * component.deserialize({ zoomOut: 1024, zoomMode: 'keep-aspect' });\r\n ", "start": 210, "end": 378, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 16, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 380, "end": 3799, "loc": { "start": { "line": 17, "column": 0 }, "end": { "line": 189, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 395, "end": 3799, "loc": { "start": { "line": 17, "column": 15 }, "end": { "line": 189, "column": 1 } }, "id": { "type": "Identifier", "start": 401, "end": 409, "loc": { "start": { "line": 17, "column": 21 }, "end": { "line": 17, "column": 29 }, "identifierName": "Camera2D" }, "name": "Camera2D", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 418, "end": 424, "loc": { "start": { "line": 17, "column": 38 }, "end": { "line": 17, "column": 44 }, "identifierName": "Camera" }, "name": "Camera" }, "body": { "type": "ClassBody", "start": 425, "end": 3799, "loc": { "start": { "line": 17, "column": 45 }, "end": { "line": 189, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 522, "end": 573, "loc": { "start": { "line": 24, "column": 2 }, "end": { "line": 26, "column": 3 } }, "static": true, "computed": false, "key": { "type": "Identifier", "start": 529, "end": 536, "loc": { "start": { "line": 24, "column": 9 }, "end": { "line": 24, "column": 16 }, "identifierName": "factory" }, "name": "factory" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 539, "end": 573, "loc": { "start": { "line": 24, "column": 19 }, "end": { "line": 26, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 546, "end": 568, "loc": { "start": { "line": 25, "column": 4 }, "end": { "line": 25, "column": 26 } }, "argument": { "type": "NewExpression", "start": 553, "end": 567, "loc": { "start": { "line": 25, "column": 11 }, "end": { "line": 25, "column": 25 } }, "callee": { "type": "Identifier", "start": 557, "end": 565, "loc": { "start": { "line": 25, "column": 15 }, "end": { "line": 25, "column": 23 }, "identifierName": "Camera2D" }, "name": "Camera2D" }, "arguments": [] } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\r\n * Component factory.\r\n *\r\n * @return {Camera2D} Component instance.\r\n ", "start": 432, "end": 518, "loc": { "start": { "line": 19, "column": 2 }, "end": { "line": 23, "column": 5 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "* @type {*} ", "start": 579, "end": 595, "loc": { "start": { "line": 28, "column": 2 }, "end": { "line": 28, "column": 18 } } } ] }, { "type": "ClassMethod", "start": 599, "end": 826, "loc": { "start": { "line": 29, "column": 2 }, "end": { "line": 38, "column": 3 } }, "static": true, "computed": false, "key": { "type": "Identifier", "start": 610, "end": 620, "loc": { "start": { "line": 29, "column": 13 }, "end": { "line": 29, "column": 23 }, "identifierName": "propsTypes" }, "name": "propsTypes" }, "kind": "get", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 623, "end": 826, "loc": { "start": { "line": 29, "column": 26 }, "end": { "line": 38, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 630, "end": 821, "loc": { "start": { "line": 30, "column": 4 }, "end": { "line": 37, "column": 6 } }, "argument": { "type": "ObjectExpression", "start": 637, "end": 820, "loc": { "start": { "line": 30, "column": 11 }, "end": { "line": 37, "column": 5 } }, "properties": [ { "type": "SpreadProperty", "start": 646, "end": 666, "loc": { "start": { "line": 31, "column": 6 }, "end": { "line": 31, "column": 26 } }, "argument": { "type": "MemberExpression", "start": 649, "end": 666, "loc": { "start": { "line": 31, "column": 9 }, "end": { "line": 31, "column": 26 } }, "object": { "type": "Identifier", "start": 649, "end": 655, "loc": { "start": { "line": 31, "column": 9 }, "end": { "line": 31, "column": 15 }, "identifierName": "Camera" }, "name": "Camera" }, "property": { "type": "Identifier", "start": 656, "end": 666, "loc": { "start": { "line": 31, "column": 16 }, "end": { "line": 31, "column": 26 }, "identifierName": "propsTypes" }, "name": "propsTypes" }, "computed": false } }, { "type": "ObjectProperty", "start": 675, "end": 689, "loc": { "start": { "line": 32, "column": 6 }, "end": { "line": 32, "column": 20 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 675, "end": 679, "loc": { "start": { "line": 32, "column": 6 }, "end": { "line": 32, "column": 10 }, "identifierName": "zoom" }, "name": "zoom" }, "value": { "type": "StringLiteral", "start": 681, "end": 689, "loc": { "start": { "line": 32, "column": 12 }, "end": { "line": 32, "column": 20 } }, "extra": { "rawValue": "number", "raw": "'number'" }, "value": "number" } }, { "type": "ObjectProperty", "start": 698, "end": 715, "loc": { "start": { "line": 33, "column": 6 }, "end": { "line": 33, "column": 23 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 698, "end": 705, "loc": { "start": { "line": 33, "column": 6 }, "end": { "line": 33, "column": 13 }, "identifierName": "zoomOut" }, "name": "zoomOut" }, "value": { "type": "StringLiteral", "start": 707, "end": 715, "loc": { "start": { "line": 33, "column": 15 }, "end": { "line": 33, "column": 23 } }, "extra": { "rawValue": "number", "raw": "'number'" }, "value": "number" } }, { "type": "ObjectProperty", "start": 724, "end": 738, "loc": { "start": { "line": 34, "column": 6 }, "end": { "line": 34, "column": 20 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 724, "end": 728, "loc": { "start": { "line": 34, "column": 6 }, "end": { "line": 34, "column": 10 }, "identifierName": "near" }, "name": "near" }, "value": { "type": "StringLiteral", "start": 730, "end": 738, "loc": { "start": { "line": 34, "column": 12 }, "end": { "line": 34, "column": 20 } }, "extra": { "rawValue": "number", "raw": "'number'" }, "value": "number" } }, { "type": "ObjectProperty", "start": 747, "end": 760, "loc": { "start": { "line": 35, "column": 6 }, "end": { "line": 35, "column": 19 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 747, "end": 750, "loc": { "start": { "line": 35, "column": 6 }, "end": { "line": 35, "column": 9 }, "identifierName": "far" }, "name": "far" }, "value": { "type": "StringLiteral", "start": 752, "end": 760, "loc": { "start": { "line": 35, "column": 11 }, "end": { "line": 35, "column": 19 } }, "extra": { "rawValue": "number", "raw": "'number'" }, "value": "number" } }, { "type": "ObjectProperty", "start": 769, "end": 813, "loc": { "start": { "line": 36, "column": 6 }, "end": { "line": 36, "column": 50 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 769, "end": 777, "loc": { "start": { "line": 36, "column": 6 }, "end": { "line": 36, "column": 14 }, "identifierName": "zoomMode" }, "name": "zoomMode" }, "value": { "type": "StringLiteral", "start": 779, "end": 813, "loc": { "start": { "line": 36, "column": 16 }, "end": { "line": 36, "column": 50 } }, "extra": { "rawValue": "enum(pixel-perfect, keep-aspect)", "raw": "'enum(pixel-perfect, keep-aspect)'" }, "value": "enum(pixel-perfect, keep-aspect)" } } ] } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {*} ", "start": 579, "end": 595, "loc": { "start": { "line": 28, "column": 2 }, "end": { "line": 28, "column": 18 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "* @type {*} ", "start": 832, "end": 848, "loc": { "start": { "line": 40, "column": 2 }, "end": { "line": 40, "column": 18 } } } ] }, { "type": "ClassMethod", "start": 852, "end": 902, "loc": { "start": { "line": 41, "column": 2 }, "end": { "line": 43, "column": 3 } }, "static": true, "computed": false, "key": { "type": "Identifier", "start": 863, "end": 871, "loc": { "start": { "line": 41, "column": 13 }, "end": { "line": 41, "column": 21 }, "identifierName": "ZoomMode" }, "name": "ZoomMode" }, "kind": "get", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 874, "end": 902, "loc": { "start": { "line": 41, "column": 24 }, "end": { "line": 43, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 881, "end": 897, "loc": { "start": { "line": 42, "column": 4 }, "end": { "line": 42, "column": 20 } }, "argument": { "type": "Identifier", "start": 888, "end": 896, "loc": { "start": { "line": 42, "column": 11 }, "end": { "line": 42, "column": 19 }, "identifierName": "ZoomMode" }, "name": "ZoomMode" } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {*} ", "start": 832, "end": 848, "loc": { "start": { "line": 40, "column": 2 }, "end": { "line": 40, "column": 18 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "* @type {number} ", "start": 908, "end": 929, "loc": { "start": { "line": 45, "column": 2 }, "end": { "line": 45, "column": 23 } } } ] }, { "type": "ClassMethod", "start": 933, "end": 974, "loc": { "start": { "line": 46, "column": 2 }, "end": { "line": 48, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 937, "end": 941, "loc": { "start": { "line": 46, "column": 6 }, "end": { "line": 46, "column": 10 }, "identifierName": "zoom" }, "name": "zoom" }, "kind": "get", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 944, "end": 974, "loc": { "start": { "line": 46, "column": 13 }, "end": { "line": 48, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 951, "end": 969, "loc": { "start": { "line": 47, "column": 4 }, "end": { "line": 47, "column": 22 } }, "argument": { "type": "MemberExpression", "start": 958, "end": 968, "loc": { "start": { "line": 47, "column": 11 }, "end": { "line": 47, "column": 21 } }, "object": { "type": "ThisExpression", "start": 958, "end": 962, "loc": { "start": { "line": 47, "column": 11 }, "end": { "line": 47, "column": 15 } } }, "property": { "type": "Identifier", "start": 963, "end": 968, "loc": { "start": { "line": 47, "column": 16 }, "end": { "line": 47, "column": 21 }, "identifierName": "_zoom" }, "name": "_zoom" }, "computed": false } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {number} ", "start": 908, "end": 929, "loc": { "start": { "line": 45, "column": 2 }, "end": { "line": 45, "column": 23 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "* @type {number} ", "start": 980, "end": 1001, "loc": { "start": { "line": 50, "column": 2 }, "end": { "line": 50, "column": 23 } } } ] }, { "type": "ClassMethod", "start": 1005, "end": 1181, "loc": { "start": { "line": 51, "column": 2 }, "end": { "line": 58, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 1009, "end": 1013, "loc": { "start": { "line": 51, "column": 6 }, "end": { "line": 51, "column": 10 }, "identifierName": "zoom" }, "name": "zoom" }, "kind": "set", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 1014, "end": 1019, "loc": { "start": { "line": 51, "column": 11 }, "end": { "line": 51, "column": 16 }, "identifierName": "value" }, "name": "value" } ], "body": { "type": "BlockStatement", "start": 1021, "end": 1181, "loc": { "start": { "line": 51, "column": 18 }, "end": { "line": 58, "column": 3 } }, "body": [ { "type": "IfStatement", "start": 1028, "end": 1124, "loc": { "start": { "line": 52, "column": 4 }, "end": { "line": 54, "column": 5 } }, "test": { "type": "BinaryExpression", "start": 1032, "end": 1057, "loc": { "start": { "line": 52, "column": 8 }, "end": { "line": 52, "column": 33 } }, "left": { "type": "UnaryExpression", "start": 1032, "end": 1044, "loc": { "start": { "line": 52, "column": 8 }, "end": { "line": 52, "column": 20 } }, "operator": "typeof", "prefix": true, "argument": { "type": "Identifier", "start": 1039, "end": 1044, "loc": { "start": { "line": 52, "column": 15 }, "end": { "line": 52, "column": 20 }, "identifierName": "value" }, "name": "value" }, "extra": { "parenthesizedArgument": false } }, "operator": "!==", "right": {