UNPKG

oxygen-core

Version:

Oxygen game engine (Xenon Core for browsers)

1,477 lines (1,476 loc) 459 kB
{ "type": "File", "start": 0, "end": 2293, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 102, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 2293, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 102, "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": 2291, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 101, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 128, "end": 2291, "loc": { "start": { "line": 6, "column": 15 }, "end": { "line": 101, "column": 1 } }, "id": { "type": "Identifier", "start": 134, "end": 146, "loc": { "start": { "line": 6, "column": 21 }, "end": { "line": 6, "column": 33 }, "identifierName": "PolygonShape" }, "name": "PolygonShape" }, "superClass": { "type": "Identifier", "start": 155, "end": 160, "loc": { "start": { "line": 6, "column": 42 }, "end": { "line": 6, "column": 47 }, "identifierName": "Shape" }, "name": "Shape" }, "body": { "type": "ClassBody", "start": 161, "end": 2291, "loc": { "start": { "line": 6, "column": 48 }, "end": { "line": 101, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 168, "end": 223, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 10, "column": 3 } }, "static": true, "computed": false, "key": { "type": "Identifier", "start": 175, "end": 182, "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": 185, "end": 223, "loc": { "start": { "line": 8, "column": 19 }, "end": { "line": 10, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 192, "end": 218, "loc": { "start": { "line": 9, "column": 4 }, "end": { "line": 9, "column": 30 } }, "argument": { "type": "NewExpression", "start": 199, "end": 217, "loc": { "start": { "line": 9, "column": 11 }, "end": { "line": 9, "column": 29 } }, "callee": { "type": "Identifier", "start": 203, "end": 215, "loc": { "start": { "line": 9, "column": 15 }, "end": { "line": 9, "column": 27 }, "identifierName": "PolygonShape" }, "name": "PolygonShape" }, "arguments": [] } } ], "directives": [] } }, { "type": "ClassMethod", "start": 229, "end": 342, "loc": { "start": { "line": 12, "column": 2 }, "end": { "line": 17, "column": 3 } }, "static": true, "computed": false, "key": { "type": "Identifier", "start": 240, "end": 250, "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": 253, "end": 342, "loc": { "start": { "line": 12, "column": 26 }, "end": { "line": 17, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 260, "end": 337, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 16, "column": 6 } }, "argument": { "type": "ObjectExpression", "start": 267, "end": 336, "loc": { "start": { "line": 13, "column": 11 }, "end": { "line": 16, "column": 5 } }, "properties": [ { "type": "SpreadProperty", "start": 276, "end": 295, "loc": { "start": { "line": 14, "column": 6 }, "end": { "line": 14, "column": 25 } }, "argument": { "type": "MemberExpression", "start": 279, "end": 295, "loc": { "start": { "line": 14, "column": 9 }, "end": { "line": 14, "column": 25 } }, "object": { "type": "Identifier", "start": 279, "end": 284, "loc": { "start": { "line": 14, "column": 9 }, "end": { "line": 14, "column": 14 }, "identifierName": "Shape" }, "name": "Shape" }, "property": { "type": "Identifier", "start": 285, "end": 295, "loc": { "start": { "line": 14, "column": 15 }, "end": { "line": 14, "column": 25 }, "identifierName": "propsTypes" }, "name": "propsTypes" }, "computed": false } }, { "type": "ObjectProperty", "start": 304, "end": 329, "loc": { "start": { "line": 15, "column": 6 }, "end": { "line": 15, "column": 31 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 304, "end": 312, "loc": { "start": { "line": 15, "column": 6 }, "end": { "line": 15, "column": 14 }, "identifierName": "vertices" }, "name": "vertices" }, "value": { "type": "StringLiteral", "start": 314, "end": 329, "loc": { "start": { "line": 15, "column": 16 }, "end": { "line": 15, "column": 31 } }, "extra": { "rawValue": "array(number)", "raw": "'array(number)'" }, "value": "array(number)" } } ] } } ], "directives": [] } }, { "type": "ClassMethod", "start": 348, "end": 397, "loc": { "start": { "line": 19, "column": 2 }, "end": { "line": 21, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 352, "end": 360, "loc": { "start": { "line": 19, "column": 6 }, "end": { "line": 19, "column": 14 }, "identifierName": "vertices" }, "name": "vertices" }, "kind": "get", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 363, "end": 397, "loc": { "start": { "line": 19, "column": 17 }, "end": { "line": 21, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 370, "end": 392, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 26 } }, "argument": { "type": "MemberExpression", "start": 377, "end": 391, "loc": { "start": { "line": 20, "column": 11 }, "end": { "line": 20, "column": 25 } }, "object": { "type": "ThisExpression", "start": 377, "end": 381, "loc": { "start": { "line": 20, "column": 11 }, "end": { "line": 20, "column": 15 } } }, "property": { "type": "Identifier", "start": 382, "end": 391, "loc": { "start": { "line": 20, "column": 16 }, "end": { "line": 20, "column": 25 }, "identifierName": "_vertices" }, "name": "_vertices" }, "computed": false } } ], "directives": [] } }, { "type": "ClassMethod", "start": 403, "end": 967, "loc": { "start": { "line": 23, "column": 2 }, "end": { "line": 44, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 407, "end": 415, "loc": { "start": { "line": 23, "column": 6 }, "end": { "line": 23, "column": 14 }, "identifierName": "vertices" }, "name": "vertices" }, "kind": "set", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 416, "end": 421, "loc": { "start": { "line": 23, "column": 15 }, "end": { "line": 23, "column": 20 }, "identifierName": "value" }, "name": "value" } ], "body": { "type": "BlockStatement", "start": 423, "end": 967, "loc": { "start": { "line": 23, "column": 22 }, "end": { "line": 44, "column": 3 } }, "body": [ { "type": "IfStatement", "start": 430, "end": 501, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 26, "column": 5 } }, "test": { "type": "UnaryExpression", "start": 434, "end": 440, "loc": { "start": { "line": 24, "column": 8 }, "end": { "line": 24, "column": 14 } }, "operator": "!", "prefix": true, "argument": { "type": "Identifier", "start": 435, "end": 440, "loc": { "start": { "line": 24, "column": 9 }, "end": { "line": 24, "column": 14 }, "identifierName": "value" }, "name": "value" }, "extra": { "parenthesizedArgument": false } }, "consequent": { "type": "BlockStatement", "start": 442, "end": 501, "loc": { "start": { "line": 24, "column": 16 }, "end": { "line": 26, "column": 5 } }, "body": [ { "type": "ThrowStatement", "start": 451, "end": 494, "loc": { "start": { "line": 25, "column": 6 }, "end": { "line": 25, "column": 49 } }, "argument": { "type": "NewExpression", "start": 457, "end": 493, "loc": { "start": { "line": 25, "column": 12 }, "end": { "line": 25, "column": 48 } }, "callee": { "type": "Identifier", "start": 461, "end": 466, "loc": { "start": { "line": 25, "column": 16 }, "end": { "line": 25, "column": 21 }, "identifierName": "Error" }, "name": "Error" }, "arguments": [ { "type": "StringLiteral", "start": 467, "end": 492, "loc": { "start": { "line": 25, "column": 22 }, "end": { "line": 25, "column": 47 } }, "extra": { "rawValue": "`value` cannot be null!", "raw": "'`value` cannot be null!'" }, "value": "`value` cannot be null!" } ] } } ], "directives": [] }, "alternate": null }, { "type": "IfStatement", "start": 509, "end": 585, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 30, "column": 5 } }, "test": { "type": "BinaryExpression", "start": 513, "end": 535, "loc": { "start": { "line": 28, "column": 8 }, "end": { "line": 28, "column": 30 } }, "left": { "type": "Identifier", "start": 513, "end": 518, "loc": { "start": { "line": 28, "column": 8 }, "end": { "line": 28, "column": 13 }, "identifierName": "value" }, "name": "value" }, "operator": "instanceof", "right": { "type": "Identifier", "start": 530, "end": 535, "loc": { "start": { "line": 28, "column": 25 }, "end": { "line": 28, "column": 30 }, "identifierName": "Array" }, "name": "Array" } }, "consequent": { "type": "BlockStatement", "start": 537, "end": 585, "loc": { "start": { "line": 28, "column": 32 }, "end": { "line": 30, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 546, "end": 578, "loc": { "start": { "line": 29, "column": 6 }, "end": { "line": 29, "column": 38 } }, "expression": { "type": "AssignmentExpression", "start": 546, "end": 577, "loc": { "start": { "line": 29, "column": 6 }, "end": { "line": 29, "column": 37 } }, "operator": "=", "left": { "type": "Identifier", "start": 546, "end": 551, "loc": { "start": { "line": 29, "column": 6 }, "end": { "line": 29, "column": 11 }, "identifierName": "value" }, "name": "value" }, "right": { "type": "NewExpression", "start": 554, "end": 577, "loc": { "start": { "line": 29, "column": 14 }, "end": { "line": 29, "column": 37 } }, "callee": { "type": "Identifier", "start": 558, "end": 570, "loc": { "start": { "line": 29, "column": 18 }, "end": { "line": 29, "column": 30 }, "identifierName": "Float32Array" }, "name": "Float32Array" }, "arguments": [ { "type": "Identifier", "start": 571, "end": 576, "loc": { "start": { "line": 29, "column": 31 }, "end": { "line": 29, "column": 36 }, "identifierName": "value" }, "name": "value" } ] } } } ], "directives": [] }, "alternate": null }, { "type": "IfStatement", "start": 593, "end": 719, "loc": { "start": { "line": 32, "column": 4 }, "end": { "line": 34, "column": 5 } }, "test": { "type": "UnaryExpression", "start": 597, "end": 629, "loc": { "start": { "line": 32, "column": 8 }, "end": { "line": 32, "column": 40 } }, "operator": "!", "prefix": true, "argument": { "type": "BinaryExpression", "start": 599, "end": 628, "loc": { "start": { "line": 32, "column": 10 }, "end": { "line": 32, "column": 39 } }, "left": { "type": "Identifier", "start": 599, "end": 604, "loc": { "start": { "line": 32, "column": 10 }, "end": { "line": 32, "column": 15 }, "identifierName": "value" }, "name": "value" }, "operator": "instanceof", "right": { "type": "Identifier", "start": 616, "end": 628, "loc": { "start": { "line": 32, "column": 27 }, "end": { "line": 32, "column": 39 }, "identifierName": "Float32Array" }, "name": "Float32Array" }, "extra": { "parenthesized": true, "parenStart": 598 } }, "extra": { "parenthesizedArgument": false } }, "consequent": { "type": "BlockStatement", "start": 631, "end": 719, "loc": { "start": { "line": 32, "column": 42 }, "end": { "line": 34, "column": 5 } }, "body": [ { "type": "ThrowStatement", "start": 640, "end": 712, "loc": { "start": { "line": 33, "column": 6 }, "end": { "line": 33, "column": 78 } }, "argument": { "type": "NewExpression", "start": 646, "end": 711, "loc": { "start": { "line": 33, "column": 12 }, "end": { "line": 33, "column": 77 } }, "callee": { "type": "Identifier", "start": 650, "end": 655, "loc": { "start": { "line": 33, "column": 16 }, "end": { "line": 33, "column": 21 }, "identifierName": "Error" }, "name": "Error" }, "arguments": [ { "type": "StringLiteral", "start": 656, "end": 710, "loc": { "start": { "line": 33, "column": 22 }, "end": { "line": 33, "column": 76 } }, "extra": { "rawValue": "`value` is not type of either Array or Float32Array!", "raw": "'`value` is not type of either Array or Float32Array!'" }, "value": "`value` is not type of either Array or Float32Array!" } ] } } ], "directives": [] }, "alternate": null }, { "type": "IfStatement", "start": 727, "end": 820, "loc": { "start": { "line": 36, "column": 4 }, "end": { "line": 38, "column": 5 } }, "test": { "type": "BinaryExpression", "start": 731, "end": 747, "loc": { "start": { "line": 36, "column": 8 }, "end": { "line": 36, "column": 24 } }, "left": { "type": "MemberExpression", "start": 731, "end": 743, "loc": { "start": { "line": 36, "column": 8 }, "end": { "line": 36, "column": 20 } }, "object": { "type": "Identifier", "start": 731, "end": 736, "loc": { "start": { "line": 36, "column": 8 }, "end": { "line": 36, "column": 13 }, "identifierName": "value" }, "name": "value" }, "property": { "type": "Identifier", "start": 737, "end": 743, "loc": { "start": { "line": 36, "column": 14 }, "end": { "line": 36, "column": 20 }, "identifierName": "length" }, "name": "length" }, "computed": false }, "operator": "<", "right": { "type": "NumericLiteral", "start": 746, "end": 747, "loc": { "start": { "line": 36, "column": 23 }, "end": {