UNPKG

oxygen-core

Version:

Oxygen game engine (Xenon Core for browsers)

1,542 lines 193 kB
{ "type": "File", "start": 0, "end": 1123, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 55, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 1123, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 55, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 28, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 28 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 12, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 12 } }, "local": { "type": "Identifier", "start": 7, "end": 12, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 12 }, "identifierName": "Shape" }, "name": "Shape" } } ], "source": { "type": "StringLiteral", "start": 18, "end": 27, "loc": { "start": { "line": 1, "column": 18 }, "end": { "line": 1, "column": 27 } }, "extra": { "rawValue": "./Shape", "raw": "'./Shape'" }, "value": "./Shape" } }, { "type": "ImportDeclaration", "start": 30, "end": 72, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 42 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 39, "end": 43, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 13 } }, "imported": { "type": "Identifier", "start": 39, "end": 43, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 13 }, "identifierName": "vec2" }, "name": "vec2" }, "local": { "type": "Identifier", "start": 39, "end": 43, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 13 }, "identifierName": "vec2" }, "name": "vec2" } } ], "source": { "type": "StringLiteral", "start": 51, "end": 71, "loc": { "start": { "line": 2, "column": 21 }, "end": { "line": 2, "column": 41 } }, "extra": { "rawValue": "../utils/gl-matrix", "raw": "'../utils/gl-matrix'" }, "value": "../utils/gl-matrix" } }, { "type": "VariableDeclaration", "start": 76, "end": 109, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 33 } }, "declarations": [ { "type": "VariableDeclarator", "start": 82, "end": 108, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 32 } }, "id": { "type": "Identifier", "start": 82, "end": 92, "loc": { "start": { "line": 4, "column": 6 }, "end": { "line": 4, "column": 16 }, "identifierName": "cachedVec2" }, "name": "cachedVec2" }, "init": { "type": "CallExpression", "start": 95, "end": 108, "loc": { "start": { "line": 4, "column": 19 }, "end": { "line": 4, "column": 32 } }, "callee": { "type": "MemberExpression", "start": 95, "end": 106, "loc": { "start": { "line": 4, "column": 19 }, "end": { "line": 4, "column": 30 } }, "object": { "type": "Identifier", "start": 95, "end": 99, "loc": { "start": { "line": 4, "column": 19 }, "end": { "line": 4, "column": 23 }, "identifierName": "vec2" }, "name": "vec2" }, "property": { "type": "Identifier", "start": 100, "end": 106, "loc": { "start": { "line": 4, "column": 24 }, "end": { "line": 4, "column": 30 }, "identifierName": "create" }, "name": "create" }, "computed": false }, "arguments": [] } } ], "kind": "const" }, { "type": "ExportDefaultDeclaration", "start": 113, "end": 1121, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 54, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 128, "end": 1121, "loc": { "start": { "line": 6, "column": 15 }, "end": { "line": 54, "column": 1 } }, "id": { "type": "Identifier", "start": 134, "end": 145, "loc": { "start": { "line": 6, "column": 21 }, "end": { "line": 6, "column": 32 }, "identifierName": "CircleShape" }, "name": "CircleShape" }, "superClass": { "type": "Identifier", "start": 154, "end": 159, "loc": { "start": { "line": 6, "column": 41 }, "end": { "line": 6, "column": 46 }, "identifierName": "Shape" }, "name": "Shape" }, "body": { "type": "ClassBody", "start": 160, "end": 1121, "loc": { "start": { "line": 6, "column": 47 }, "end": { "line": 54, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 167, "end": 221, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 10, "column": 3 } }, "static": true, "computed": false, "key": { "type": "Identifier", "start": 174, "end": 181, "loc": { "start": { "line": 8, "column": 9 }, "end": { "line": 8, "column": 16 }, "identifierName": "factory" }, "name": "factory" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 184, "end": 221, "loc": { "start": { "line": 8, "column": 19 }, "end": { "line": 10, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 191, "end": 216, "loc": { "start": { "line": 9, "column": 4 }, "end": { "line": 9, "column": 29 } }, "argument": { "type": "NewExpression", "start": 198, "end": 215, "loc": { "start": { "line": 9, "column": 11 }, "end": { "line": 9, "column": 28 } }, "callee": { "type": "Identifier", "start": 202, "end": 213, "loc": { "start": { "line": 9, "column": 15 }, "end": { "line": 9, "column": 26 }, "identifierName": "CircleShape" }, "name": "CircleShape" }, "arguments": [] } } ], "directives": [] } }, { "type": "ClassMethod", "start": 227, "end": 331, "loc": { "start": { "line": 12, "column": 2 }, "end": { "line": 17, "column": 3 } }, "static": true, "computed": false, "key": { "type": "Identifier", "start": 238, "end": 248, "loc": { "start": { "line": 12, "column": 13 }, "end": { "line": 12, "column": 23 }, "identifierName": "propsTypes" }, "name": "propsTypes" }, "kind": "get", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 251, "end": 331, "loc": { "start": { "line": 12, "column": 26 }, "end": { "line": 17, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 258, "end": 326, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 16, "column": 6 } }, "argument": { "type": "ObjectExpression", "start": 265, "end": 325, "loc": { "start": { "line": 13, "column": 11 }, "end": { "line": 16, "column": 5 } }, "properties": [ { "type": "SpreadProperty", "start": 274, "end": 293, "loc": { "start": { "line": 14, "column": 6 }, "end": { "line": 14, "column": 25 } }, "argument": { "type": "MemberExpression", "start": 277, "end": 293, "loc": { "start": { "line": 14, "column": 9 }, "end": { "line": 14, "column": 25 } }, "object": { "type": "Identifier", "start": 277, "end": 282, "loc": { "start": { "line": 14, "column": 9 }, "end": { "line": 14, "column": 14 }, "identifierName": "Shape" }, "name": "Shape" }, "property": { "type": "Identifier", "start": 283, "end": 293, "loc": { "start": { "line": 14, "column": 15 }, "end": { "line": 14, "column": 25 }, "identifierName": "propsTypes" }, "name": "propsTypes" }, "computed": false } }, { "type": "ObjectProperty", "start": 302, "end": 318, "loc": { "start": { "line": 15, "column": 6 }, "end": { "line": 15, "column": 22 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 302, "end": 308, "loc": { "start": { "line": 15, "column": 6 }, "end": { "line": 15, "column": 12 }, "identifierName": "radius" }, "name": "radius" }, "value": { "type": "StringLiteral", "start": 310, "end": 318, "loc": { "start": { "line": 15, "column": 14 }, "end": { "line": 15, "column": 22 } }, "extra": { "rawValue": "number", "raw": "'number'" }, "value": "number" } } ] } } ], "directives": [] } }, { "type": "ClassMethod", "start": 337, "end": 382, "loc": { "start": { "line": 19, "column": 2 }, "end": { "line": 21, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 341, "end": 347, "loc": { "start": { "line": 19, "column": 6 }, "end": { "line": 19, "column": 12 }, "identifierName": "radius" }, "name": "radius" }, "kind": "get", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 350, "end": 382, "loc": { "start": { "line": 19, "column": 15 }, "end": { "line": 21, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 357, "end": 377, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 24 } }, "argument": { "type": "MemberExpression", "start": 364, "end": 376, "loc": { "start": { "line": 20, "column": 11 }, "end": { "line": 20, "column": 23 } }, "object": { "type": "ThisExpression", "start": 364, "end": 368, "loc": { "start": { "line": 20, "column": 11 }, "end": { "line": 20, "column": 15 } } }, "property": { "type": "Identifier", "start": 369, "end": 376, "loc": { "start": { "line": 20, "column": 16 }, "end": { "line": 20, "column": 23 }, "identifierName": "_radius" }, "name": "_radius" }, "computed": false } } ], "directives": [] } }, { "type": "ClassMethod", "start": 388, "end": 544, "loc": { "start": { "line": 23, "column": 2 }, "end": { "line": 29, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 392, "end": 398, "loc": { "start": { "line": 23, "column": 6 }, "end": { "line": 23, "column": 12 }, "identifierName": "radius" }, "name": "radius" }, "kind": "set", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 399, "end": 404, "loc": { "start": { "line": 23, "column": 13 }, "end": { "line": 23, "column": 18 }, "identifierName": "value" }, "name": "value" } ], "body": { "type": "BlockStatement", "start": 406, "end": 544, "loc": { "start": { "line": 23, "column": 20 }, "end": { "line": 29, "column": 3 } }, "body": [ { "type": "IfStatement", "start": 413, "end": 510, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 26, "column": 5 } }, "test": { "type": "BinaryExpression", "start": 417, "end": 442, "loc": { "start": { "line": 24, "column": 8 }, "end": { "line": 24, "column": 33 } }, "left": { "type": "UnaryExpression", "start": 417, "end": 429, "loc": { "start": { "line": 24, "column": 8 }, "end": { "line": 24, "column": 20 } }, "operator": "typeof", "prefix": true, "argument": { "type": "Identifier", "start": 424, "end": 429, "loc": { "start": { "line": 24, "column": 15 }, "end": { "line": 24, "column": 20 }, "identifierName": "value" }, "name": "value" }, "extra": { "parenthesizedArgument": false } }, "operator": "!==", "right": { "type": "StringLiteral", "start": 434, "end": 442, "loc": { "start": { "line": 24, "column": 25 }, "end": { "line": 24, "column": 33 } }, "extra": { "rawValue": "number", "raw": "'number'" }, "value": "number" } }, "consequent": { "type": "BlockStatement", "start": 444, "end": 510, "loc": { "start": { "line": 24, "column": 35 }, "end": { "line": 26, "column": 5 } }, "body": [ { "type": "ThrowStatement", "start": 453, "end": 503, "loc": { "start": { "line": 25, "column": 6 }, "end": { "line": 25, "column": 56 } }, "argument": { "type": "NewExpression", "start": 459, "end": 502, "loc": { "start": { "line": 25, "column": 12 }, "end": { "line": 25, "column": 55 } }, "callee": { "type": "Identifier", "start": 463, "end": 468, "loc": { "start": { "line": 25, "column": 16 }, "end": { "line": 25, "column": 21 }, "identifierName": "Error" }, "name": "Error" }, "arguments": [ { "type": "StringLiteral", "start": 469, "end": 501, "loc": { "start": { "line": 25, "column": 22 }, "end": { "line": 25, "column": 54 } }, "extra": { "rawValue": "`value` is not type of Number!", "raw": "'`value` is not type of Number!'" }, "value": "`value` is not type of Number!" } ] } } ], "directives": [] }, "alternate": null }, { "type": "ExpressionStatement", "start": 518, "end": 539, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 28, "column": 25 } }, "expression": { "type": "AssignmentExpression", "start": 518, "end": 538, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 28, "column": 24 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 518, "end": 530, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 28, "column": 16 } }, "object": { "type": "ThisExpression", "start": 518, "end": 522, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 28, "column": 8 } } }, "property": { "type": "Identifier", "start": 523, "end": 530, "loc": { "start": { "line": 28, "column": 9 }, "end": { "line": 28, "column": 16 }, "identifierName": "_radius" }, "name": "_radius" }, "computed": false }, "right": { "type": "Identifier", "start": 533, "end": 538, "loc": { "start": { "line": 28, "column": 19 }, "end": { "line": 28, "column": 24 }, "identifierName": "value" }, "name": "value" } } } ], "directives": [] } }, { "type": "ClassMethod", "start": 550, "end": 609, "loc": { "start": { "line": 31, "column": 2 }, "end": { "line": 35, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 550, "end": 561, "loc": { "start": { "line": 31, "column": 2 }, "end": { "line": 31, "column": 13 }, "identifierName": "constructor" }, "name": "constructor" }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 564, "end": 609, "loc": { "start": { "line": 31, "column": 16 }, "end": { "line": 35, "column": 3 } }, "body": [ { "type": "ExpressionStatement", "start": 571, "end": 579, "loc": { "start": { "line": 32, "column": 4 }, "end": { "line": 32, "column": 12 } }, "expression": { "type": "CallExpression", "start": 571, "end": 578, "loc": { "start": { "line": 32, "column": 4 }, "end": { "line": 32, "column": 11 } }, "callee": { "type": "Super", "start": 571, "end": 576, "loc": { "start": { "line": 32, "column": 4 }, "end": { "line": 32, "column": 9 } } }, "arguments": [] } }, { "type": "ExpressionStatement", "start": 587, "end": 604, "loc": { "start": { "line": 34, "column": 4 }, "end": { "line": 34, "column": 21 } }, "expression": { "type": "AssignmentExpression", "start": 587, "end": 603, "loc": { "start": { "line": 34, "column": 4 }, "end": { "line": 34, "column": 20 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 587, "end": 599, "loc": { "start": { "line": 34, "column": 4 }, "end": { "line": 34, "column": 16 } }, "object": { "type": "ThisExpression", "start": 587, "end": 591, "loc": { "start": { "line": 34, "column": 4 }, "end": { "line": 34, "column": 8 } } }, "property": { "type": "Identifier", "start": 592, "end": 599, "loc": { "start": { "line": 34, "column": 9 }, "end": { "line": 34, "column": 16 }, "identifierName": "_radius" }, "name": "_radius" }, "computed": false }, "right": { "type": "NumericLiteral", "start": 602, "end": 603, "loc": { "start": { "line": 34, "column": 19 }, "end": { "line": 34, "column": 20 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 } } } ], "directives": [] } }, { "type": "ClassMethod", "start": 615, "end": 1116, "loc": { "start": { "line": 37, "column": 2 }, "end": { "line": 52, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 615, "end": 628, "loc": { "start": { "line": 37, "column": 2 }, "end": { "line": 37, "column": 15 }, "identifierName": "containsPoint" }, "name": "containsPoint" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 629, "end": 640, "loc": { "start": { "line": 37, "column": 16 }, "end": { "line": 37, "column": 27 }, "identifierName": "globalPoint" }, "name": "globalPoint" }, { "type": "AssignmentPattern", "start": 642, "end": 654, "loc": { "start": { "line": 37, "column": 29 }, "end": { "line": 37, "column": 41 } }, "left": { "type": "Identifier", "start": 642, "end": 647, "loc": { "start": { "line": 37, "column": 29 }, "end": { "line": 37, "column": 34 }, "identifierName": "layer" }, "name": "layer" }, "right": { "type": "NullLiteral", "start": 650, "end": 654, "loc": { "start": { "line": 37, "column": 37 }, "end": { "line": 37, "column": 41 } } } } ], "body": { "type": "BlockStatement", "start": 656, "end": 1116, "loc": { "start": { "line": 37, "column": 43 }, "end": { "line": 52, "column": 3 } }, "body": [ { "type": "IfStatement", "start": 663, "end": 746, "loc": { "start": { "line": 38, "column": 4 }, "end": { "line": 40, "column": 5 } }, "test": { "type": "UnaryExpression", "start": 667, "end": 679, "loc": { "start": { "line": 38, "column": 8 }, "end": { "line": 38, "column": 20 } }, "operator": "!", "prefix": true, "argument": { "type": "Identifier", "start": 668, "end": 679, "loc": { "start": { "line": 38, "column": 9 }, "end": { "line": 38, "column": 20 }, "identifierName": "globalPoint" }, "name": "globalPoint" }, "extra": { "parenthesizedArgument": false } }, "consequent": { "type": "BlockStatement", "start": 681, "end": 746, "loc": { "s