UNPKG

oxygen-core

Version:

Oxygen game engine (Xenon Core for browsers)

1,702 lines (1,701 loc) 1.5 MB
{ "type": "File", "start": 0, "end": 7864, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 290, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 7864, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 290, "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": "System" }, "name": "System" } } ], "source": { "type": "StringLiteral", "start": 19, "end": 29, "loc": { "start": { "line": 1, "column": 19 }, "end": { "line": 1, "column": 29 } }, "extra": { "rawValue": "./System", "raw": "'./System'" }, "value": "./System" } }, { "type": "ImportDeclaration", "start": 32, "end": 69, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 37 } }, "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": "Events" }, "name": "Events" } } ], "source": { "type": "StringLiteral", "start": 51, "end": 68, "loc": { "start": { "line": 2, "column": 19 }, "end": { "line": 2, "column": 36 } }, "extra": { "rawValue": "../utils/Events", "raw": "'../utils/Events'" }, "value": "../utils/Events" } }, { "type": "ImportDeclaration", "start": 71, "end": 113, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 42 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 80, "end": 84, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 13 } }, "imported": { "type": "Identifier", "start": 80, "end": 84, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 13 }, "identifierName": "vec2" }, "name": "vec2" }, "local": { "type": "Identifier", "start": 80, "end": 84, "loc": { "start": { "line": 3, "column": 9 }, "end": { "line": 3, "column": 13 }, "identifierName": "vec2" }, "name": "vec2" } } ], "source": { "type": "StringLiteral", "start": 92, "end": 112, "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": 117, "end": 157, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 40 } }, "declarations": [ { "type": "VariableDeclarator", "start": 123, "end": 156, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 39 } }, "id": { "type": "Identifier", "start": 123, "end": 140, "loc": { "start": { "line": 5, "column": 6 }, "end": { "line": 5, "column": 23 }, "identifierName": "cachedUnitsVector" }, "name": "cachedUnitsVector" }, "init": { "type": "CallExpression", "start": 143, "end": 156, "loc": { "start": { "line": 5, "column": 26 }, "end": { "line": 5, "column": 39 } }, "callee": { "type": "MemberExpression", "start": 143, "end": 154, "loc": { "start": { "line": 5, "column": 26 }, "end": { "line": 5, "column": 37 } }, "object": { "type": "Identifier", "start": 143, "end": 147, "loc": { "start": { "line": 5, "column": 26 }, "end": { "line": 5, "column": 30 }, "identifierName": "vec2" }, "name": "vec2" }, "property": { "type": "Identifier", "start": 148, "end": 154, "loc": { "start": { "line": 5, "column": 31 }, "end": { "line": 5, "column": 37 }, "identifierName": "create" }, "name": "create" }, "computed": false }, "arguments": [] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 159, "end": 200, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 41 } }, "declarations": [ { "type": "VariableDeclarator", "start": 165, "end": 199, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 40 } }, "id": { "type": "Identifier", "start": 165, "end": 183, "loc": { "start": { "line": 6, "column": 6 }, "end": { "line": 6, "column": 24 }, "identifierName": "cachedScreenVector" }, "name": "cachedScreenVector" }, "init": { "type": "CallExpression", "start": 186, "end": 199, "loc": { "start": { "line": 6, "column": 27 }, "end": { "line": 6, "column": 40 } }, "callee": { "type": "MemberExpression", "start": 186, "end": 197, "loc": { "start": { "line": 6, "column": 27 }, "end": { "line": 6, "column": 38 } }, "object": { "type": "Identifier", "start": 186, "end": 190, "loc": { "start": { "line": 6, "column": 27 }, "end": { "line": 6, "column": 31 }, "identifierName": "vec2" }, "name": "vec2" }, "property": { "type": "Identifier", "start": 191, "end": 197, "loc": { "start": { "line": 6, "column": 32 }, "end": { "line": 6, "column": 38 }, "identifierName": "create" }, "name": "create" }, "computed": false }, "arguments": [] } } ], "kind": "const" }, { "type": "VariableDeclaration", "start": 202, "end": 344, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 13, "column": 12 } }, "declarations": [ { "type": "VariableDeclarator", "start": 208, "end": 343, "loc": { "start": { "line": 7, "column": 6 }, "end": { "line": 13, "column": 11 } }, "id": { "type": "Identifier", "start": 208, "end": 232, "loc": { "start": { "line": 7, "column": 6 }, "end": { "line": 7, "column": 30 }, "identifierName": "touchDetectionMediaQuery" }, "name": "touchDetectionMediaQuery" }, "init": { "type": "CallExpression", "start": 235, "end": 343, "loc": { "start": { "line": 7, "column": 33 }, "end": { "line": 13, "column": 11 } }, "callee": { "type": "MemberExpression", "start": 235, "end": 338, "loc": { "start": { "line": 7, "column": 33 }, "end": { "line": 13, "column": 6 } }, "object": { "type": "ArrayExpression", "start": 235, "end": 333, "loc": { "start": { "line": 7, "column": 33 }, "end": { "line": 13, "column": 1 } }, "elements": [ { "type": "StringLiteral", "start": 240, "end": 258, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 8, "column": 20 } }, "extra": { "rawValue": "(-webkit-heartz)", "raw": "'(-webkit-heartz)'" }, "value": "(-webkit-heartz)" }, { "type": "StringLiteral", "start": 263, "end": 278, "loc": { "start": { "line": 9, "column": 2 }, "end": { "line": 9, "column": 17 } }, "extra": { "rawValue": "(-moz-heartz)", "raw": "'(-moz-heartz)'" }, "value": "(-moz-heartz)" }, { "type": "StringLiteral", "start": 283, "end": 296, "loc": { "start": { "line": 10, "column": 2 }, "end": { "line": 10, "column": 15 } }, "extra": { "rawValue": "(-o-heartz)", "raw": "'(-o-heartz)'" }, "value": "(-o-heartz)" }, { "type": "StringLiteral", "start": 301, "end": 315, "loc": { "start": { "line": 11, "column": 2 }, "end": { "line": 11, "column": 16 } }, "extra": { "rawValue": "(-ms-heartz)", "raw": "'(-ms-heartz)'" }, "value": "(-ms-heartz)" }, { "type": "StringLiteral", "start": 320, "end": 330, "loc": { "start": { "line": 12, "column": 2 }, "end": { "line": 12, "column": 12 } }, "extra": { "rawValue": "(heartz)", "raw": "'(heartz)'" }, "value": "(heartz)" } ] }, "property": { "type": "Identifier", "start": 334, "end": 338, "loc": { "start": { "line": 13, "column": 2 }, "end": { "line": 13, "column": 6 }, "identifierName": "join" }, "name": "join" }, "computed": false }, "arguments": [ { "type": "StringLiteral", "start": 339, "end": 342, "loc": { "start": { "line": 13, "column": 7 }, "end": { "line": 13, "column": 10 } }, "extra": { "rawValue": ",", "raw": "','" }, "value": "," } ] } } ], "kind": "const" }, { "type": "FunctionDeclaration", "start": 348, "end": 598, "loc": { "start": { "line": 15, "column": 0 }, "end": { "line": 24, "column": 1 } }, "id": { "type": "Identifier", "start": 357, "end": 374, "loc": { "start": { "line": 15, "column": 9 }, "end": { "line": 15, "column": 26 }, "identifierName": "detectTouchDevice" }, "name": "detectTouchDevice" }, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 377, "end": 598, "loc": { "start": { "line": 15, "column": 29 }, "end": { "line": 24, "column": 1 } }, "body": [ { "type": "IfStatement", "start": 382, "end": 595, "loc": { "start": { "line": 16, "column": 2 }, "end": { "line": 23, "column": 3 } }, "test": { "type": "LogicalExpression", "start": 392, "end": 488, "loc": { "start": { "line": 17, "column": 4 }, "end": { "line": 18, "column": 65 } }, "left": { "type": "BinaryExpression", "start": 393, "end": 417, "loc": { "start": { "line": 17, "column": 5 }, "end": { "line": 17, "column": 29 } }, "left": { "type": "StringLiteral", "start": 393, "end": 407, "loc": { "start": { "line": 17, "column": 5 }, "end": { "line": 17, "column": 19 } }, "extra": { "rawValue": "ontouchstart", "raw": "'ontouchstart'" }, "value": "ontouchstart" }, "operator": "in", "right": { "type": "Identifier", "start": 411, "end": 417, "loc": { "start": { "line": 17, "column": 23 }, "end": { "line": 17, "column": 29 }, "identifierName": "window" }, "name": "window" }, "extra": { "parenthesized": true, "parenStart": 392 } }, "operator": "||", "right": { "type": "LogicalExpression", "start": 428, "end": 487, "loc": { "start": { "line": 18, "column": 5 }, "end": { "line": 18, "column": 64 } }, "left": { "type": "UnaryExpression", "start": 428, "end": 450, "loc": { "start": { "line": 18, "column": 5 }, "end": { "line": 18, "column": 27 } }, "operator": "!", "prefix": true, "argument": { "type": "UnaryExpression", "start": 429, "end": 450, "loc": { "start": { "line": 18, "column": 6 }, "end": { "line": 18, "column": 27 } }, "operator": "!", "prefix": true, "argument": { "type": "MemberExpression", "start": 430, "end": 450, "loc": { "start": { "line": 18, "column": 7 }, "end": { "line": 18, "column": 27 } }, "object": { "type": "Identifier", "start": 430, "end": 436, "loc": { "start": { "line": 18, "column": 7 }, "end": { "line": 18, "column": 13 }, "identifierName": "window" }, "name": "window" }, "property": { "type": "Identifier", "start": 437, "end": 450, "loc": { "start": { "line": 18, "column": 14 }, "end": { "line": 18, "column": 27 }, "identifierName": "DocumentTouch" }, "name": "DocumentTouch" }, "computed": false }, "extra": { "parenthesizedArgument": false } }, "extra": { "parenthesizedArgument": false } }, "operator": "&&", "right": { "type": "BinaryExpression", "start": 454, "end": 487, "loc": { "start": { "line": 18, "column": 31 }, "end": { "line": 18, "column": 64 } }, "left": { "type": "Identifier", "start": 454, "end": 462, "loc": { "start": { "line": 18, "column": 31 }, "end": { "line": 18, "column": 39 }, "identifierName": "document" }, "name": "document" }, "operator": "instanceof", "right": { "type": "Identifier", "start": 474, "end": 487, "loc": { "start": { "line": 18, "column": 51 }, "end": { "line": 18, "column": 64 }, "identifierName": "DocumentTouch" }, "name": "DocumentTouch" } }, "extra": { "parenthesized": true, "parenStart": 427 } } }, "consequent": { "type": "BlockStatement", "start": 494, "end": 518, "loc": { "start": { "line": 19, "column": 4 }, "end": { "line": 21, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 501, "end": 513, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 16 } }, "argument": { "type": "BooleanLiteral", "start": 508, "end": 512, "loc": { "start": { "line": 20, "column": 11 }, "end": { "line": 20, "column": 15 } }, "value": true } } ], "directives": [] }, "alternate": { "type": "BlockStatement", "start": 524, "end": 595, "loc": { "start": { "line": 21, "column": 9 }, "end": { "line": 23, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 531, "end": 590, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 22, "column": 63 } }, "argument": { "type": "MemberExpression", "start": 538, "end": 589, "loc": { "start": { "line": 22, "column": 11 }, "end": { "line": 22, "column": 62 } }, "object": { "type": "CallExpression", "start": 538, "end": 581, "loc": { "start": { "line": 22, "column": 11 }, "end": { "line": 22, "column": 54 } }, "callee": { "type": "MemberExpression", "start": 538, "end": 555, "loc": { "start": { "line": 22, "column": 11 }, "end": { "line": 22, "column": 28 } }, "object": { "type": "Identifier", "start": 538, "end": 544, "loc": { "start": { "line": 22, "column": 11 }, "end": { "line": 22, "column": 17 }, "identifierName": "window" }, "name": "window" }, "property": { "type": "Identifier", "start": 545, "end": 555, "loc": { "start": { "line": 22, "column": 18 }, "end": { "line": 22, "column": 28 }, "identifierName": "matchMedia" }, "name": "matchMedia" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 556, "end": 580, "loc": { "start": { "line": 22, "column": 29 }, "end": { "line": 22, "column": 53 }, "identifierName": "touchDetectionMediaQuery" }, "name": "touchDetectionMediaQuery" } ] }, "property": { "type": "Identifier", "start": 582, "end": 589, "loc": { "start": { "line": 22, "column": 55 }, "end": { "line": 22, "column": 62 }, "identifierName": "matches" }, "name": "matches" }, "computed": false } } ], "directives": [] } } ], "directives": [], "trailingComments": null }, "trailingComments": [ { "type": "CommentBlock", "value": "*\r\n * User input (mouse, keyboard, gamepad).\r\n *\r\n * @example\r\n * const system = new InputSystem(document.getElementById('screen-0'));\r\n ", "start": 602, "end": 743, "loc": { "start": { "line": 26, "column": 0 }, "end": { "line": 31, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 745, "end": 7862, "loc": { "start": { "line": 32, "column": 0 }, "end": { "line": 289, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 760, "end": 7862, "loc": { "start": { "line": 32, "column": 15 }, "end": { "line": 289, "column": 1 } }, "id": { "type": "Identifier", "start": 766, "end": 777, "loc": { "start": { "line": 32, "column": 21 }, "end": { "line": 32, "column": 32 }, "identifierName": "InputSystem" }, "name": "InputSystem", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 786, "end": 792, "loc": { "start": { "line": 32, "column": 41 }, "end": { "line": 32, "column": 47 }, "identifierName": "System" }, "name": "System" }, "body": { "type": "ClassBody", "start": 793, "end": 7862, "loc": { "start": { "line": 32, "column": 48 }, "end": { "line": 289, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 825, "end": 870, "loc": { "start": { "line": 35, "column": 2 }, "end": { "line": 37, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 829, "end": 835, "loc": { "start": { "line": 35, "column": 6 }, "end": { "line": 35, "column": 12 }, "identifierName": "events" }, "name": "events" }, "kind": "get", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 838, "end": 870, "loc": { "start": { "line": 35, "column": 15 }, "end": { "line": 37, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 845, "end": 865, "loc": { "start": { "line": 36, "column": 4 }, "end": { "line": 36, "column": 24 } }, "argument": { "type": "MemberExpression", "start": 852, "end": 864, "loc": { "start": { "line": 36, "column": 11 }, "end": { "line": 36, "column": 23 } }, "object": { "type": "ThisExpression", "start": 852, "end": 856, "loc": { "start": { "line": 36, "column": 11 }, "end": { "line": 36, "column": 15 } } }, "property": { "type": "Identifier", "start": 857, "end": 864, "loc": { "start": { "line": 36, "column": 16 }, "end": { "line": 36, "column": 23 }, "identifierName": "_events" }, "name": "_events" }, "computed": false } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {Events} ", "start": 800, "end": 821, "loc": { "start": { "line": 34, "column": 2 }, "end": { "line": 34, "column": 23 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "* @type {Map} ", "start": 876, "end": 894, "loc": { "start": { "line": 39, "column": 2 }, "end": { "line": 39, "column": 20 } } } ] }, { "type": "ClassMethod", "start": 898, "end": 947, "loc": { "start": { "line": 40, "column": 2 }, "end": { "line": 42, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 902, "end": 910, "loc": { "start": { "line": 40, "column": 6 }, "end": { "line": 40, "column": 14 }, "identifierName": "gamepads" }, "name": "gamepads" }, "kind": "get", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 913, "end": 947, "loc": { "start": { "line": 40, "column": 17 }, "end": { "line": 42, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 920, "end": 942, "loc": { "start": { "line": 41, "column": 4 }, "end": { "line": 41, "column": 26 } }, "argument": { "type": "MemberExpression", "start": 927, "end": 941, "loc": { "start": { "line": 41, "column": 11 }, "end": { "line": 41, "column": 25 } }, "object": { "type": "ThisExpression", "start": 927, "end": 931, "loc": { "start": { "line": 41, "column": 11 }, "end": { "line": 41, "column": 15 } } }, "property": { "type": "Identifier", "start": 932, "end": 941, "loc": { "start": { "line": 41, "column": 16 }, "end": { "line": 41, "column": 25 }, "identifierName": "_gamepads" }, "name": "_gamepads" }, "computed": false } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {Map} ", "start": 876, "end": 894, "loc": { "start": { "line": 39, "column": 2 }, "end": { "line": 39, "column": 20 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "* @type {boolean}", "start": 953, "end": 974, "loc": { "start": { "line": 44, "column": 2 }, "end": { "line": 44, "column": 23 } } } ] }, { "type": "ClassMethod", "start": 978, "end": 1037, "loc": { "start": { "line": 45, "column": 2 }, "end": { "line": 47, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 982, "end": 995, "loc": { "start": { "line": 45, "column": 6 }, "end": { "line": 45, "column": 19 }, "identifierName": "isTouchDevice" }, "name": "isTouchDevice" }, "kind": "get", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 998, "end": 1037, "loc": { "start": { "line": 45, "column": 22 }, "end": { "line": 47, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 1005, "end": 1032, "loc": { "start": { "line": 46, "column": 4 }, "end": {