UNPKG

oxygen-core

Version:

Oxygen game engine (Xenon Core for browsers)

1,554 lines (1,553 loc) 763 kB
{ "type": "File", "start": 0, "end": 6672, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 256, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 6672, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 256, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 31, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 31 } }, "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": 30, "loc": { "start": { "line": 1, "column": 19 }, "end": { "line": 1, "column": 30 } }, "extra": { "rawValue": "../System", "raw": "'../System'" }, "value": "../System" } }, { "type": "ImportDeclaration", "start": 33, "end": 63, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 30 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 40, "end": 46, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 13 } }, "local": { "type": "Identifier", "start": 40, "end": 46, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 13 }, "identifierName": "Entity" }, "name": "Entity" } } ], "source": { "type": "StringLiteral", "start": 52, "end": 62, "loc": { "start": { "line": 2, "column": 19 }, "end": { "line": 2, "column": 29 } }, "extra": { "rawValue": "./Entity", "raw": "'./Entity'" }, "value": "./Entity" } }, { "type": "ImportDeclaration", "start": 65, "end": 101, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 36 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 72, "end": 81, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 16 } }, "local": { "type": "Identifier", "start": 72, "end": 81, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 16 }, "identifierName": "Component" }, "name": "Component" } } ], "source": { "type": "StringLiteral", "start": 87, "end": 100, "loc": { "start": { "line": 3, "column": 22 }, "end": { "line": 3, "column": 35 } }, "extra": { "rawValue": "./Component", "raw": "'./Component'" }, "value": "./Component" } }, { "type": "ImportDeclaration", "start": 103, "end": 148, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 45 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 112, "end": 116, "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 13 } }, "imported": { "type": "Identifier", "start": 112, "end": 116, "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 13 }, "identifierName": "mat4" }, "name": "mat4" }, "local": { "type": "Identifier", "start": 112, "end": 116, "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 13 }, "identifierName": "mat4" }, "name": "mat4" } } ], "source": { "type": "StringLiteral", "start": 124, "end": 147, "loc": { "start": { "line": 4, "column": 21 }, "end": { "line": 4, "column": 44 } }, "extra": { "rawValue": "../../utils/gl-matrix", "raw": "'../../utils/gl-matrix'" }, "value": "../../utils/gl-matrix" } }, { "type": "ExportNamedDeclaration", "start": 152, "end": 188, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 9, "column": 2 } }, "declaration": null, "specifiers": [ { "type": "ExportSpecifier", "start": 164, "end": 170, "loc": { "start": { "line": 7, "column": 2 }, "end": { "line": 7, "column": 8 } }, "local": { "type": "Identifier", "start": 164, "end": 170, "loc": { "start": { "line": 7, "column": 2 }, "end": { "line": 7, "column": 8 }, "identifierName": "Entity" }, "name": "Entity" }, "exported": { "type": "Identifier", "start": 164, "end": 170, "loc": { "start": { "line": 7, "column": 2 }, "end": { "line": 7, "column": 8 }, "identifierName": "Entity" }, "name": "Entity" } }, { "type": "ExportSpecifier", "start": 175, "end": 184, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 8, "column": 11 } }, "local": { "type": "Identifier", "start": 175, "end": 184, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 8, "column": 11 }, "identifierName": "Component" }, "name": "Component" }, "exported": { "type": "Identifier", "start": 175, "end": 184, "loc": { "start": { "line": 8, "column": 2 }, "end": { "line": 8, "column": 11 }, "identifierName": "Component" }, "name": "Component" } } ], "source": null }, { "type": "VariableDeclaration", "start": 192, "end": 229, "loc": { "start": { "line": 11, "column": 0 }, "end": { "line": 11, "column": 37 } }, "declarations": [ { "type": "VariableDeclarator", "start": 198, "end": 228, "loc": { "start": { "line": 11, "column": 6 }, "end": { "line": 11, "column": 36 } }, "id": { "type": "Identifier", "start": 198, "end": 212, "loc": { "start": { "line": 11, "column": 6 }, "end": { "line": 11, "column": 20 }, "identifierName": "identityMatrix" }, "name": "identityMatrix" }, "init": { "type": "CallExpression", "start": 215, "end": 228, "loc": { "start": { "line": 11, "column": 23 }, "end": { "line": 11, "column": 36 } }, "callee": { "type": "MemberExpression", "start": 215, "end": 226, "loc": { "start": { "line": 11, "column": 23 }, "end": { "line": 11, "column": 34 } }, "object": { "type": "Identifier", "start": 215, "end": 219, "loc": { "start": { "line": 11, "column": 23 }, "end": { "line": 11, "column": 27 }, "identifierName": "mat4" }, "name": "mat4" }, "property": { "type": "Identifier", "start": 220, "end": 226, "loc": { "start": { "line": 11, "column": 28 }, "end": { "line": 11, "column": 34 }, "identifierName": "create" }, "name": "create" }, "computed": false }, "arguments": [] } } ], "kind": "const", "trailingComments": [ { "type": "CommentBlock", "value": "*\r\n * Manages entities on scene.\r\n *\r\n * @example\r\n * const system = new EntitySystem();\r\n * class Hello extends Component { constructor() { this.hello = null; } onAction(name) { console.log(name); } }\r\n * system.registerComponent('Hello', () => new Hello());\r\n * system.root = system.buildEntity({ name: 'hey', components: { Hello: { hello: 'world' } } });\r\n * system.updateTransforms();\r\n * system.performAction('hi');\r\n ", "start": 233, "end": 660, "loc": { "start": { "line": 13, "column": 0 }, "end": { "line": 23, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 662, "end": 6670, "loc": { "start": { "line": 24, "column": 0 }, "end": { "line": 255, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 677, "end": 6670, "loc": { "start": { "line": 24, "column": 15 }, "end": { "line": 255, "column": 1 } }, "id": { "type": "Identifier", "start": 683, "end": 695, "loc": { "start": { "line": 24, "column": 21 }, "end": { "line": 24, "column": 33 }, "identifierName": "EntitySystem" }, "name": "EntitySystem", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 704, "end": 710, "loc": { "start": { "line": 24, "column": 42 }, "end": { "line": 24, "column": 48 }, "identifierName": "System" }, "name": "System" }, "body": { "type": "ClassBody", "start": 711, "end": 6670, "loc": { "start": { "line": 24, "column": 49 }, "end": { "line": 255, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 748, "end": 789, "loc": { "start": { "line": 27, "column": 2 }, "end": { "line": 29, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 752, "end": 756, "loc": { "start": { "line": 27, "column": 6 }, "end": { "line": 27, "column": 10 }, "identifierName": "root" }, "name": "root" }, "kind": "get", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 759, "end": 789, "loc": { "start": { "line": 27, "column": 13 }, "end": { "line": 29, "column": 3 } }, "body": [ { "type": "ReturnStatement", "start": 766, "end": 784, "loc": { "start": { "line": 28, "column": 4 }, "end": { "line": 28, "column": 22 } }, "argument": { "type": "MemberExpression", "start": 773, "end": 783, "loc": { "start": { "line": 28, "column": 11 }, "end": { "line": 28, "column": 21 } }, "object": { "type": "ThisExpression", "start": 773, "end": 777, "loc": { "start": { "line": 28, "column": 11 }, "end": { "line": 28, "column": 15 } } }, "property": { "type": "Identifier", "start": 778, "end": 783, "loc": { "start": { "line": 28, "column": 16 }, "end": { "line": 28, "column": 21 }, "identifierName": "_root" }, "name": "_root" }, "computed": false } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "* @type {Entity|null} ", "start": 718, "end": 744, "loc": { "start": { "line": 26, "column": 2 }, "end": { "line": 26, "column": 28 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "* @type {Entity|null} ", "start": 795, "end": 821, "loc": { "start": { "line": 31, "column": 2 }, "end": { "line": 31, "column": 28 } } } ] }, { "type": "ClassMethod", "start": 825, "end": 1130, "loc": { "start": { "line": 32, "column": 2 }, "end": { "line": 47, "column": 3 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 829, "end": 833, "loc": { "start": { "line": 32, "column": 6 }, "end": { "line": 32, "column": 10 }, "identifierName": "root" }, "name": "root" }, "kind": "set", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 834, "end": 839, "loc": { "start": { "line": 32, "column": 11 }, "end": { "line": 32, "column": 16 }, "identifierName": "value" }, "name": "value" } ], "body": { "type": "BlockStatement", "start": 841, "end": 1130, "loc": { "start": { "line": 32, "column": 18 }, "end": { "line": 47, "column": 3 } }, "body": [ { "type": "IfStatement", "start": 848, "end": 957, "loc": { "start": { "line": 33, "column": 4 }, "end": { "line": 35, "column": 5 } }, "test": { "type": "LogicalExpression", "start": 852, "end": 889, "loc": { "start": { "line": 33, "column": 8 }, "end": { "line": 33, "column": 45 } }, "left": { "type": "UnaryExpression", "start": 852, "end": 859, "loc": { "start": { "line": 33, "column": 8 }, "end": { "line": 33, "column": 15 } }, "operator": "!", "prefix": true, "argument": { "type": "UnaryExpression", "start": 853, "end": 859, "loc": { "start": { "line": 33, "column": 9 }, "end": { "line": 33, "column": 15 } }, "operator": "!", "prefix": true, "argument": { "type": "Identifier", "start": 854, "end": 859, "loc": { "start": { "line": 33, "column": 10 }, "end": { "line": 33, "column": 15 }, "identifierName": "value" }, "name": "value" }, "extra": { "parenthesizedArgument": false } }, "extra": { "parenthesizedArgument": false } }, "operator": "&&", "right": { "type": "UnaryExpression", "start": 863, "end": 889, "loc": { "start": { "line": 33, "column": 19 }, "end": { "line": 33, "column": 45 } }, "operator": "!", "prefix": true, "argument": { "type": "BinaryExpression", "start": 865, "end": 888, "loc": { "start": { "line": 33, "column": 21 }, "end": { "line": 33, "column": 44 } }, "left": { "type": "Identifier", "start": 865, "end": 870, "loc": { "start": { "line": 33, "column": 21 }, "end": { "line": 33, "column": 26 }, "identifierName": "value" }, "name": "value" }, "operator": "instanceof", "right": { "type": "Identifier", "start": 882, "end": 888, "loc": { "start": { "line": 33, "column": 38 }, "end": { "line": 33, "column": 44 }, "identifierName": "Entity" }, "name": "Entity" }, "extra": { "parenthesized": true, "parenStart": 864 } }, "extra": { "parenthesizedArgument": false } } }, "consequent": { "type": "BlockStatement", "start": 891, "end": 957, "loc": { "start": { "line": 33, "column": 47 }, "end": { "line": 35, "column": 5 } }, "body": [ { "type": "ThrowStatement", "start": 900, "end": 950, "loc": { "start": { "line": 34, "column": 6 }, "end": { "line": 34, "column": 56 } }, "argument": { "type": "NewExpression", "start": 906, "end": 949, "loc": { "start": { "line": 34, "column": 12 }, "end": { "line": 34, "column": 55 } }, "callee": { "type": "Identifier", "start": 910, "end": 915, "loc": { "start": { "line": 34, "column": 16 }, "end": { "line": 34, "column": 21 }, "identifierName": "Error" }, "name": "Error" }, "arguments": [ { "type": "StringLiteral", "start": 916, "end": 948, "loc": { "start": { "line": 34, "column": 22 }, "end": { "line": 34, "column": 54 } }, "extra": { "rawValue": "`value` is not type of Entity!", "raw": "'`value` is not type of Entity!'" }, "value": "`value` is not type of Entity!" } ] } } ], "directives": [] }, "alternate": null }, { "type": "VariableDeclaration", "start": 965, "end": 988, "loc": { "start": { "line": 37, "column": 4 }, "end": { "line": 37, "column": 27 } }, "declarations": [ { "type": "VariableDeclarator", "start": 971, "end": 987, "loc": { "start": { "line": 37, "column": 10 }, "end": { "line": 37, "column": 26 } }, "id": { "type": "ObjectPattern", "start": 971, "end": 980, "loc": { "start": { "line": 37, "column": 10 }, "end": { "line": 37, "column": 19 } }, "properties": [ { "type": "ObjectProperty", "start": 973, "end": 978, "loc": { "start": { "line": 37, "column": 12 }, "end": { "line": 37, "column": 17 } }, "method": false, "shorthand": true, "computed": false, "key": { "type": "Identifier", "start": 973, "end": 978, "loc": { "start": { "line": 37, "column": 12 }, "end": { "line": 37, "column": 17 }, "identifierName": "_root" }, "name": "_root" }, "value": { "type": "Identifier", "start": 973, "end": 978, "loc": { "start": { "line": 37, "column": 12 }, "end": { "line": 37, "column": 17 }, "identifierName": "_root" }, "name": "_root" }, "extra": { "shorthand": true } } ] }, "init": { "type": "ThisExpression", "start": 983, "end": 987, "loc": { "start": { "line": 37, "column": 22 }, "end": { "line": 37, "column": 26 } } } } ], "kind": "const" }, { "type": "IfStatement", "start": 996, "end": 1041, "loc": { "start": { "line": 39, "column": 4 }, "end": { "line": 41, "column": 5 } }, "test": { "type": "UnaryExpression", "start": 1000, "end": 1007, "loc": { "start": { "line": 39, "column": 8 }, "end": { "line": 39, "column": 15 } }, "operator": "!", "prefix": true, "argument": { "type": "UnaryExpression", "start": 1001, "end": 1007, "loc": { "start": { "line": 39, "column": 9 }, "end": { "line": 39, "column": 15 } }, "operator": "!", "prefix": true, "argument": { "type": "Identifier", "start": 1002, "end": 1007, "loc": { "start": { "line": 39, "column": 10 }, "end": { "line": 39, "column": 15 }, "identifierName": "_root" }, "name": "_root" }, "extra": { "parenthesizedArgument": false } }, "extra": { "parenthesizedArgument": false } }, "consequent": { "type": "BlockStatement", "start": 1009, "end": 1041, "loc": { "start": { "line": 39, "column": 17 }, "end": { "line": 41, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 1018, "end": 1034, "loc": { "start": { "line": 40, "column": 6 }, "end": { "line": 40, "column": 22 } }, "expression": { "type": "CallExpression", "start": 1018, "end": 1033, "loc": { "start": { "line": 40, "column": 6 }, "end": { "line": 40, "column": 21 } }, "callee": { "type": "MemberExpression", "start": 1018, "end": 1031, "loc": { "start": { "line": 40, "column": 6 }, "end": { "line": 40, "column": 19 } }, "object": { "type": "Identifier", "start": 1018, "end": 1023, "loc": { "start": { "line": 40, "column": 6 }, "end": { "line": 40, "column": 11 }, "identifierName": "_root" }, "name": "_root" }, "property": { "type": "Identifier", "start": 1024, "end": 1031, "loc": { "start": { "line": 40, "column": 12 }, "end": { "line": 40, "column": 19 }, "identifierName": "dispose" }, "name": "dispose" }, "computed": false }, "arguments": [] } } ], "directives": [] }, "alternate": null }, { "type": "ExpressionStatement", "start": 1049, "end": 1068, "loc": { "start": { "line": 43, "column": 4 }, "end": { "line": 43, "column": 23 } }, "expression": { "type": "AssignmentExpression", "start": 1049, "end": 1067, "loc": { "start": { "line": 43, "column": 4 }, "end": { "line": 43, "column": 22 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1049, "end": 1059, "loc": { "start": { "line": 43, "column": 4 }, "end": { "line": 43, "column": 14 } }, "object": { "type": "ThisExpression", "start": 1049, "end": 1053, "loc": { "start": { "line": 43, "column": 4 }, "end": { "line": 43, "column": 8 } } }, "property": { "type": "Identifier", "start": 1054, "end": 1059, "loc": { "start": { "line": 43, "column": 9 }, "end": { "line": 43, "column": 14 }, "identifierName": "_root" }, "name": "_root" }, "computed": false }, "right": { "type": "Identifier", "start": 1062, "end": 1067, "loc": { "start": { "line": 43, "column": 17 }, "end": { "line": 43, "column": 22 }, "identifierName": "value" }, "name": "value" } } }, { "type": "IfStatement", "start": 1074, "end": 1125, "loc": { "start": { "line": 44, "column": 4 }, "end": { "line": 46, "column": 5 } }, "test": { "type": "UnaryExpression", "start": 1078, "end": 1085, "loc": { "start": { "line": 44, "column": 8 }, "end": { "line": 44, "column": 15 } }, "operator": "!", "prefix": true, "argument": { "type": "UnaryExpression", "start": 1079,