oxygen-core
Version:
Oxygen game engine (Xenon Core for browsers)
1,527 lines (1,526 loc) • 2.12 MB
JSON
{
"type": "File",
"start": 0,
"end": 14487,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 509,
"column": 0
}
},
"program": {
"type": "Program",
"start": 0,
"end": 14487,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 509,
"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": 61,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 28
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 40,
"end": 45,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 12
}
},
"local": {
"type": "Identifier",
"start": 40,
"end": 45,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 12
},
"identifierName": "Asset"
},
"name": "Asset"
}
}
],
"source": {
"type": "StringLiteral",
"start": 51,
"end": 60,
"loc": {
"start": {
"line": 2,
"column": 18
},
"end": {
"line": 2,
"column": 27
}
},
"extra": {
"rawValue": "./Asset",
"raw": "'./Asset'"
},
"value": "./Asset"
}
},
{
"type": "ImportDeclaration",
"start": 63,
"end": 103,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 40
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 70,
"end": 76,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 13
}
},
"local": {
"type": "Identifier",
"start": 70,
"end": 76,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 13
},
"identifierName": "Events"
},
"name": "Events"
}
}
],
"source": {
"type": "StringLiteral",
"start": 82,
"end": 102,
"loc": {
"start": {
"line": 3,
"column": 19
},
"end": {
"line": 3,
"column": 39
}
},
"extra": {
"rawValue": "../../utils/Events",
"raw": "'../../utils/Events'"
},
"value": "../../utils/Events"
}
},
{
"type": "ImportDeclaration",
"start": 105,
"end": 149,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 4,
"column": 44
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 112,
"end": 118,
"loc": {
"start": {
"line": 4,
"column": 7
},
"end": {
"line": 4,
"column": 13
}
},
"local": {
"type": "Identifier",
"start": 112,
"end": 118,
"loc": {
"start": {
"line": 4,
"column": 7
},
"end": {
"line": 4,
"column": 13
},
"identifierName": "parser"
},
"name": "parser"
}
}
],
"source": {
"type": "StringLiteral",
"start": 124,
"end": 148,
"loc": {
"start": {
"line": 4,
"column": 19
},
"end": {
"line": 4,
"column": 43
}
},
"extra": {
"rawValue": "../../utils/jsonParser",
"raw": "'../../utils/jsonParser'"
},
"value": "../../utils/jsonParser"
}
},
{
"type": "ExportNamedDeclaration",
"start": 153,
"end": 170,
"loc": {
"start": {
"line": 6,
"column": 0
},
"end": {
"line": 6,
"column": 17
}
},
"declaration": null,
"specifiers": [
{
"type": "ExportSpecifier",
"start": 162,
"end": 167,
"loc": {
"start": {
"line": 6,
"column": 9
},
"end": {
"line": 6,
"column": 14
}
},
"local": {
"type": "Identifier",
"start": 162,
"end": 167,
"loc": {
"start": {
"line": 6,
"column": 9
},
"end": {
"line": 6,
"column": 14
},
"identifierName": "Asset"
},
"name": "Asset"
},
"exported": {
"type": "Identifier",
"start": 162,
"end": 167,
"loc": {
"start": {
"line": 6,
"column": 9
},
"end": {
"line": 6,
"column": 14
},
"identifierName": "Asset"
},
"name": "Asset"
}
}
],
"source": null
},
{
"type": "VariableDeclaration",
"start": 174,
"end": 213,
"loc": {
"start": {
"line": 8,
"column": 0
},
"end": {
"line": 8,
"column": 39
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 180,
"end": 212,
"loc": {
"start": {
"line": 8,
"column": 6
},
"end": {
"line": 8,
"column": 38
}
},
"id": {
"type": "Identifier",
"start": 180,
"end": 190,
"loc": {
"start": {
"line": 8,
"column": 6
},
"end": {
"line": 8,
"column": 16
},
"identifierName": "_pathRegex"
},
"name": "_pathRegex"
},
"init": {
"type": "RegExpLiteral",
"start": 193,
"end": 212,
"loc": {
"start": {
"line": 8,
"column": 19
},
"end": {
"line": 8,
"column": 38
}
},
"extra": {
"raw": "/(\\w+)(\\:\\/\\/)(.*)/"
},
"pattern": "(\\w+)(\\:\\/\\/)(.*)",
"flags": ""
}
}
],
"kind": "const",
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\r\n * Assets database and loader.\r\n *\r\n * @example\r\n * const system = new AssetSystem('assets/', { cache: 'no-store' }, AssetSystem.fetchArrayView);\r\n ",
"start": 217,
"end": 372,
"loc": {
"start": {
"line": 10,
"column": 0
},
"end": {
"line": 15,
"column": 3
}
}
}
]
},
{
"type": "ExportDefaultDeclaration",
"start": 374,
"end": 14485,
"loc": {
"start": {
"line": 16,
"column": 0
},
"end": {
"line": 508,
"column": 1
}
},
"declaration": {
"type": "ClassDeclaration",
"start": 389,
"end": 14485,
"loc": {
"start": {
"line": 16,
"column": 15
},
"end": {
"line": 508,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 395,
"end": 406,
"loc": {
"start": {
"line": 16,
"column": 21
},
"end": {
"line": 16,
"column": 32
},
"identifierName": "AssetSystem"
},
"name": "AssetSystem",
"leadingComments": null
},
"superClass": {
"type": "Identifier",
"start": 415,
"end": 421,
"loc": {
"start": {
"line": 16,
"column": 41
},
"end": {
"line": 16,
"column": 47
},
"identifierName": "System"
},
"name": "System"
},
"body": {
"type": "ClassBody",
"start": 422,
"end": 14485,
"loc": {
"start": {
"line": 16,
"column": 48
},
"end": {
"line": 508,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 594,
"end": 650,
"loc": {
"start": {
"line": 25,
"column": 2
},
"end": {
"line": 27,
"column": 3
}
},
"static": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 601,
"end": 606,
"loc": {
"start": {
"line": 25,
"column": 9
},
"end": {
"line": 25,
"column": 14
},
"identifierName": "fetch"
},
"name": "fetch"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "RestElement",
"start": 607,
"end": 614,
"loc": {
"start": {
"line": 25,
"column": 15
},
"end": {
"line": 25,
"column": 22
}
},
"argument": {
"type": "Identifier",
"start": 610,
"end": 614,
"loc": {
"start": {
"line": 25,
"column": 18
},
"end": {
"line": 25,
"column": 22
},
"identifierName": "args"
},
"name": "args"
}
}
],
"body": {
"type": "BlockStatement",
"start": 616,
"end": 650,
"loc": {
"start": {
"line": 25,
"column": 24
},
"end": {
"line": 27,
"column": 3
}
},
"body": [
{
"type": "ReturnStatement",
"start": 623,
"end": 645,
"loc": {
"start": {
"line": 26,
"column": 4
},
"end": {
"line": 26,
"column": 26
}
},
"argument": {
"type": "CallExpression",
"start": 630,
"end": 644,
"loc": {
"start": {
"line": 26,
"column": 11
},
"end": {
"line": 26,
"column": 25
}
},
"callee": {
"type": "Identifier",
"start": 630,
"end": 635,
"loc": {
"start": {
"line": 26,
"column": 11
},
"end": {
"line": 26,
"column": 16
},
"identifierName": "fetch"
},
"name": "fetch"
},
"arguments": [
{
"type": "SpreadElement",
"start": 636,
"end": 643,
"loc": {
"start": {
"line": 26,
"column": 17
},
"end": {
"line": 26,
"column": 24
}
},
"argument": {
"type": "Identifier",
"start": 639,
"end": 643,
"loc": {
"start": {
"line": 26,
"column": 20
},
"end": {
"line": 26,
"column": 24
},
"identifierName": "args"
},
"name": "args"
}
}
]
}
}
],
"directives": [],
"trailingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\r\n * Default browser fetch mechanism.\r\n *\r\n * @param {*}\targs - Fetch engine parameters.\r\n *\r\n * @return {Promise} Promise that fetches file.\r\n ",
"start": 429,
"end": 590,
"loc": {
"start": {
"line": 18,
"column": 2
},
"end": {
"line": 24,
"column": 5
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\r\n * Custom fetch mechanism that loads data from array view.\r\n *\r\n * @param {ArrayBufferView}\tview - Data array buffer view.\r\n * @param {string}\tpath - Asset path.\r\n * @param {*}\toptions - Fetch engine options.\r\n * @param {Function}\tfallbackEngine - Fallback fetch engine.\r\n *\r\n * @return {Promise} Promise that fetches file from array view.\r\n ",
"start": 656,
"end": 1023,
"loc": {
"start": {
"line": 29,
"column": 2
},
"end": {
"line": 38,
"column": 5
}
}
}
]
},
{
"type": "ClassMethod",
"start": 1027,
"end": 1885,
"loc": {
"start": {
"line": 39,
"column": 2
},
"end": {
"line": 65,
"column": 3
}
},
"static": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 1034,
"end": 1048,
"loc": {
"start": {
"line": 39,
"column": 9
},
"end": {
"line": 39,
"column": 23
},
"identifierName": "fetchArrayView"
},
"name": "fetchArrayView"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 1049,
"end": 1053,
"loc": {
"start": {
"line": 39,
"column": 24
},
"end": {
"line": 39,
"column": 28
},
"identifierName": "view"
},
"name": "view"
},
{
"type": "Identifier",
"start": 1055,
"end": 1059,
"loc": {
"start": {
"line": 39,
"column": 30
},
"end": {
"line": 39,
"column": 34
},
"identifierName": "path"
},
"name": "path"
},
{
"type": "AssignmentPattern",
"start": 1061,
"end": 1073,
"loc": {
"start": {
"line": 39,
"column": 36
},
"end": {
"line": 39,
"column": 48
}
},
"left": {
"type": "Identifier",
"start": 1061,
"end": 1068,
"loc": {
"start": {
"line": 39,
"column": 36
},
"end": {
"line": 39,
"column": 43
},
"identifierName": "options"
},
"name": "options"
},
"right": {
"type": "ObjectExpression",
"start": 1071,
"end": 1073,
"loc": {
"start": {
"line": 39,
"column": 46
},
"end": {
"line": 39,
"column": 48
}
},
"properties": []
}
},
{
"type": "AssignmentPattern",
"start": 1075,
"end": 1096,
"loc": {
"start": {
"line": 39,
"column": 50
},
"end": {
"line": 39,
"column": 71
}
},
"left": {
"type": "Identifier",
"start": 1075,
"end": 1089,
"loc": {
"start": {
"line": 39,
"column": 50
},
"end": {
"line": 39,
"column": 64
},
"identifierName": "fallbackEngine"
},
"name": "fallbackEngine"
},
"right": {
"type": "NullLiteral",
"start": 1092,
"end": 1096,
"loc": {
"start": {
"line": 39,
"column": 67
},
"end": {
"line": 39,
"column": 71
}
}
}
}
],
"body": {
"type": "BlockStatement",
"start": 1098,
"end": 1885,
"loc": {
"start": {
"line": 39,
"column": 73
},
"end": {
"line": 65,
"column": 3
}
},
"body": [
{
"type": "IfStatement",
"start": 1105,
"end": 1214,
"loc": {
"start": {
"line": 40,
"column": 4
},
"end": {
"line": 42,
"column": 5
}
},
"test": {
"type": "LogicalExpression",
"start": 1109,
"end": 1144,
"loc": {
"start": {
"line": 40,
"column": 8
},
"end": {
"line": 40,
"column": 43
}
},
"left": {
"type": "UnaryExpression",
"start": 1109,
"end": 1115,
"loc": {
"start": {
"line": 40,
"column": 8
},
"end": {
"line": 40,
"column": 14
}
},
"operator": "!",
"prefix": true,
"argument": {
"type": "UnaryExpression",
"start": 1110,
"end": 1115,
"loc": {
"start": {
"line": 40,
"column": 9
},
"end": {
"line": 40,
"column": 14
}
},
"operator": "!",
"prefix": true,
"argument": {
"type": "Identifier",
"start": 1111,
"end": 1115,
"loc": {
"start": {
"line": 40,
"column": 10
},
"end": {
"line": 40,
"column": 14
},
"identifierName": "view"
},
"name": "view"
},
"extra": {
"parenthesizedArgument": false
}
},
"extra": {
"parenthesizedArgument": false
}
},
"operator": "&&",
"right": {
"type": "UnaryExpression",
"start": 1119,
"end": 1144,
"loc": {
"start": {
"line": 40,
"column": 18
},
"end": {
"line": 40,
"column": 43
}
},
"operator": "!",
"prefix": true,
"argument": {
"type": "CallExpression",
"start": 1120,
"end": 1144,
"loc": {
"start": {
"line": 40,
"column": 19
},
"end": {
"line": 40,
"column": 43
}
},
"callee": {
"type": "MemberExpression",
"start": 1120,
"end": 1138,
"loc": {
"start": {
"line": 40,
"column": 19
},
"end": {
"line": 40,
"column": 37
}
},
"object": {
"type": "Identifier",
"start": 1120,
"end": 1131,
"loc": {
"start": {
"line": 40,
"column": 19
},
"end": {
"line": 40,
"column": 30
},
"identifierName": "ArrayBuffer"
},
"name": "ArrayBuffer"
},
"property": {
"type": "Identifier",
"start": 1132,
"end": 1138,
"loc": {
"start": {
"line": 40,
"column": 31
},
"end": {
"line": 40,
"column": 37
},
"identifierName": "isView"
},
"name": "isView"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 1139,
"end": 1143,
"loc": {
"start": {
"line": 40,
"column": 38
},
"end": {
"line": 40,
"column": 42
},
"identifierName": "view"
},
"name": "view"
}
]
},
"extra": {
"parenthesizedArgument": false
}
}
},
"consequent": {
"type": "BlockStatement",
"start": 1146,
"end": 1214,
"loc": {
"start": {
"line": 40,
"column": 45
},
"end": {
"line": 42,
"column": 5
}
},
"body": [
{
"type": "ThrowStatement",
"start": 1155,
"end": 1207,
"loc": {
"start": {
"line": 41,
"column": 6
},
"end": {
"line": 41,
"column": 58
}
},
"argument": {
"type": "NewExpression",
"start": 1161,
"end": 1206,
"loc": {
"start": {
"line": 41,
"column": 12
},
"end": {
"line": 41,
"column": 57
}
},
"callee": {
"type": "Identifier",
"start": 1165,
"end": 1170,
"loc": {
"start": {
"line": 41,
"column": 16
},
"end": {
"line": 41,
"column": 21
},
"identifierName": "Error"
},
"name": "Error"
},
"arguments": [
{
"type": "StringLiteral",
"start": 1171,
"end": 1205,
"loc": {
"start": {
"line": 41,
"column": 22
},
"end": {
"line": 41,
"column": 56
}
},
"extra": {
"rawValue": "`view` is not type of ArrayView!",
"raw": "'`view` is not type of ArrayView!'"
},
"value": "`view` is not type of ArrayView!"
}
]
}
}
],
"directives": []
},
"alternate": null
},
{
"type": "IfStatement",
"start": 1220,
"end": 1315,
"loc": {
"start": {
"line": 43,
"column": 4
},
"end": {
"line": 45,
"column": 5
}
},
"test": {
"type": "BinaryExpression",
"start": 1224,
"end": 1248,
"loc": {
"start": {
"line": 43,
"column": 8
},
"end": {
"line": 43,
"column": 32
}
},
"left": {
"type": "UnaryExpression",
"start": 1224,
"end": 1235,
"loc": {
"start": {
"line": 43,
"column": 8
},
"end": {
"line": 43,
"column": 19
}
},
"operator": "typeof",
"prefix": true,
"argument": {
"type": "Identifier",
"start": 1231,
"end": 1235,
"loc": {
"start": {
"line": 43,
"column": 15
},
"end": {
"line": 43,
"column": 19
},
"identifierName": "path"
},
"name": "path"
},
"extra": {
"parenthesizedArgument": false
}
},
"operator": "!==",
"right": {
"type": "StringLiteral",
"start": 1240,
"end": 1248,
"loc": {
"start": {
"line": 43,
"column": 24
},
"end": {
"line": 43,
"column": 32
}
},
"extra": {
"rawValue": "string",
"raw": "'string'"
},
"value": "string"
}
},
"consequent": {
"type": "BlockStatement",
"start": 1250,
"end": 1315,
"loc": {
"start": {
"line": 43,
"column": 34
},
"end": {
"line": 45,
"column": 5
}
},
"body": [
{
"type": "ThrowStatement",
"start": 1259,
"end": 1308,
"loc": {
"start": {
"line": 44,
"column": 6
},
"end": {
"line": 44,
"column": 55
}
},
"argument": {
"type": "NewExpression",
"start": 1265,
"end": 1307,
"loc": {
"start": {
"line": 44,
"column": 12
},
"end": {
"line": 44,
"column": 54
}
},
"callee": {
"type": "Identifier",
"start": 1269,
"end": 1274,
"loc": {
"start": {
"line": 44,
"column": 16
},
"end": {
"line": 44,
"column": 21
},
"identifierName": "Error"
},
"name": "Error"
},
"arguments": [
{
"type": "StringLiteral",
"start": 1275,
"end": 1306,
"loc": {
"start": {
"line": 44,
"column": 22
},
"end": {
"line": 44,
"column": 53
}
},
"extra": {
"rawValue": "`path` is not type of String!",
"raw": "'`path` is not type of String!'"
},
"value": "`path` is not type of String!"
}
]
}
}
],
"directives": []
},
"alternate": null
},
{
"type": "IfStatement",
"start": 1321,
"end": 1461,
"loc": {
"start": {
"line": 46,
"column": 4
},
"end": {
"line": 48,
"column": 5
}
},
"test": {
"type": "LogicalExpression",
"start": 1325,
"end": 1382,
"loc": {
"start": {
"line": 46,
"column": 8
},
"end": {
"line": 46,
"column": 65
}
},
"left": {
"type": "UnaryExpression",
"start": 1325,
"end": 1341,
"loc": {
"start": {
"line": 46,
"column": 8
},
"end": {
"line": 46,
"column": 24
}
},
"operator": "!",
"prefix": true,
"argument": {
"type": "UnaryExpression",
"start": 1326,
"end": 1341,
"loc": {
"start": {
"line": 46,
"column": 9
},
"end": {
"line": 46,
"column": 24
}
},
"operator": "!",
"prefix": true,
"argument": {
"type": "Identifier",
"start": 1327,
"end": 1341,
"loc": {
"start": {
"line": 46,
"column": 10
},
"end": {
"line": 46,
"column": 24
},
"identifierName": "fallbackEngine"
},
"name": "fallbackEngine"
},
"extra": {
"parenthesizedArgument": false
}
},
"extra": {
"parenthesizedArgument": false
}
},
"operator": "&&",
"right": {
"type": "UnaryExpression",
"start": 1345,
"end": 1382,
"loc": {
"start": {
"line": 46,
"column": 28
},
"end": {
"line": 46,
"column": 65
}
},
"operator": "!",
"prefix": true,
"argument": {
"type": "BinaryExpression",
"start": 1347,
"end": 1381,
"loc": {
"start": {
"line": 46,
"column": 30
},
"end": {
"line": 46,
"column": 64
}
},
"left": {
"type": "Identifier",
"start": 1347,
"end": 1361,
"loc": {
"start": {
"line": 46,
"column": 30
},
"end": {
"line": 46,
"column": 44
},
"identifierName": "fallbackEngine"
},
"name": "fallbackEngine"
},
"operator": "instanceof",
"right": {
"type": "Identifier",
"start": 1373,