UNPKG

awv3

Version:
1,508 lines (1,507 loc) 247 kB
{ "type": "File", "start": 0, "end": 1023, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 32, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 1023, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 32, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 31, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 31 } }, "specifiers": [ { "type": "ImportNamespaceSpecifier", "start": 7, "end": 17, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 17 } }, "local": { "type": "Identifier", "start": 12, "end": 17, "loc": { "start": { "line": 1, "column": 12 }, "end": { "line": 1, "column": 17 }, "identifierName": "THREE" }, "name": "THREE" } } ], "source": { "type": "StringLiteral", "start": 23, "end": 30, "loc": { "start": { "line": 1, "column": 23 }, "end": { "line": 1, "column": 30 } }, "extra": { "rawValue": "three", "raw": "'three'" }, "value": "three" } }, { "type": "ExportNamedDeclaration", "start": 34, "end": 466, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 13, "column": 1 } }, "specifiers": [], "source": null, "declaration": { "type": "FunctionDeclaration", "start": 41, "end": 466, "loc": { "start": { "line": 4, "column": 7 }, "end": { "line": 13, "column": 1 } }, "id": { "type": "Identifier", "start": 50, "end": 63, "loc": { "start": { "line": 4, "column": 16 }, "end": { "line": 4, "column": 29 }, "identifierName": "calcSketchPos" }, "name": "calcSketchPos" }, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 64, "end": 67, "loc": { "start": { "line": 4, "column": 30 }, "end": { "line": 4, "column": 33 }, "identifierName": "ray" }, "name": "ray" }, { "type": "Identifier", "start": 69, "end": 75, "loc": { "start": { "line": 4, "column": 35 }, "end": { "line": 4, "column": 41 }, "identifierName": "sketch" }, "name": "sketch" } ], "body": { "type": "BlockStatement", "start": 77, "end": 466, "loc": { "start": { "line": 4, "column": 43 }, "end": { "line": 13, "column": 1 } }, "body": [ { "type": "VariableDeclaration", "start": 132, "end": 207, "loc": { "start": { "line": 6, "column": 4 }, "end": { "line": 6, "column": 79 } }, "declarations": [ { "type": "VariableDeclarator", "start": 136, "end": 206, "loc": { "start": { "line": 6, "column": 8 }, "end": { "line": 6, "column": 78 } }, "id": { "type": "Identifier", "start": 136, "end": 148, "loc": { "start": { "line": 6, "column": 8 }, "end": { "line": 6, "column": 20 }, "identifierName": "worldToLocal" }, "name": "worldToLocal", "leadingComments": null }, "init": { "type": "CallExpression", "start": 151, "end": 206, "loc": { "start": { "line": 6, "column": 23 }, "end": { "line": 6, "column": 78 } }, "callee": { "type": "MemberExpression", "start": 151, "end": 181, "loc": { "start": { "line": 6, "column": 23 }, "end": { "line": 6, "column": 53 } }, "object": { "type": "NewExpression", "start": 151, "end": 170, "loc": { "start": { "line": 6, "column": 23 }, "end": { "line": 6, "column": 42 } }, "callee": { "type": "MemberExpression", "start": 155, "end": 168, "loc": { "start": { "line": 6, "column": 27 }, "end": { "line": 6, "column": 40 } }, "object": { "type": "Identifier", "start": 155, "end": 160, "loc": { "start": { "line": 6, "column": 27 }, "end": { "line": 6, "column": 32 }, "identifierName": "THREE" }, "name": "THREE" }, "property": { "type": "Identifier", "start": 161, "end": 168, "loc": { "start": { "line": 6, "column": 33 }, "end": { "line": 6, "column": 40 }, "identifierName": "Matrix4" }, "name": "Matrix4" }, "computed": false }, "arguments": [] }, "property": { "type": "Identifier", "start": 171, "end": 181, "loc": { "start": { "line": 6, "column": 43 }, "end": { "line": 6, "column": 53 }, "identifierName": "getInverse" }, "name": "getInverse" }, "computed": false }, "arguments": [ { "type": "CallExpression", "start": 182, "end": 205, "loc": { "start": { "line": 6, "column": 54 }, "end": { "line": 6, "column": 77 } }, "callee": { "type": "MemberExpression", "start": 182, "end": 203, "loc": { "start": { "line": 6, "column": 54 }, "end": { "line": 6, "column": 75 } }, "object": { "type": "Identifier", "start": 182, "end": 188, "loc": { "start": { "line": 6, "column": 54 }, "end": { "line": 6, "column": 60 }, "identifierName": "sketch" }, "name": "sketch" }, "property": { "type": "Identifier", "start": 189, "end": 203, "loc": { "start": { "line": 6, "column": 61 }, "end": { "line": 6, "column": 75 }, "identifierName": "getMatrixWorld" }, "name": "getMatrixWorld" }, "computed": false }, "arguments": [] } ] }, "leadingComments": null } ], "kind": "let", "leadingComments": [ { "type": "CommentLine", "value": "transform line from world to sketch coords", "start": 83, "end": 127, "loc": { "start": { "line": 5, "column": 4 }, "end": { "line": 5, "column": 48 } } } ] }, { "type": "ExpressionStatement", "start": 212, "end": 243, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 7, "column": 35 } }, "expression": { "type": "CallExpression", "start": 212, "end": 242, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 7, "column": 34 } }, "callee": { "type": "MemberExpression", "start": 212, "end": 228, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 7, "column": 20 } }, "object": { "type": "Identifier", "start": 212, "end": 215, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 7, "column": 7 }, "identifierName": "ray" }, "name": "ray" }, "property": { "type": "Identifier", "start": 216, "end": 228, "loc": { "start": { "line": 7, "column": 8 }, "end": { "line": 7, "column": 20 }, "identifierName": "applyMatrix4" }, "name": "applyMatrix4" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 229, "end": 241, "loc": { "start": { "line": 7, "column": 21 }, "end": { "line": 7, "column": 33 }, "identifierName": "worldToLocal" }, "name": "worldToLocal" } ] }, "trailingComments": [ { "type": "CommentLine", "value": "calculate intersection of line with z = 0 plane", "start": 248, "end": 297, "loc": { "start": { "line": 8, "column": 4 }, "end": { "line": 8, "column": 53 } } } ] }, { "type": "VariableDeclaration", "start": 302, "end": 351, "loc": { "start": { "line": 9, "column": 4 }, "end": { "line": 9, "column": 53 } }, "declarations": [ { "type": "VariableDeclarator", "start": 306, "end": 350, "loc": { "start": { "line": 9, "column": 8 }, "end": { "line": 9, "column": 52 } }, "id": { "type": "Identifier", "start": 306, "end": 311, "loc": { "start": { "line": 9, "column": 8 }, "end": { "line": 9, "column": 13 }, "identifierName": "param" }, "name": "param", "leadingComments": null }, "init": { "type": "BinaryExpression", "start": 314, "end": 350, "loc": { "start": { "line": 9, "column": 16 }, "end": { "line": 9, "column": 52 } }, "left": { "type": "BinaryExpression", "start": 315, "end": 331, "loc": { "start": { "line": 9, "column": 17 }, "end": { "line": 9, "column": 33 } }, "left": { "type": "NumericLiteral", "start": 315, "end": 316, "loc": { "start": { "line": 9, "column": 17 }, "end": { "line": 9, "column": 18 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 }, "operator": "-", "right": { "type": "MemberExpression", "start": 319, "end": 331, "loc": { "start": { "line": 9, "column": 21 }, "end": { "line": 9, "column": 33 } }, "object": { "type": "MemberExpression", "start": 319, "end": 329, "loc": { "start": { "line": 9, "column": 21 }, "end": { "line": 9, "column": 31 } }, "object": { "type": "Identifier", "start": 319, "end": 322, "loc": { "start": { "line": 9, "column": 21 }, "end": { "line": 9, "column": 24 }, "identifierName": "ray" }, "name": "ray" }, "property": { "type": "Identifier", "start": 323, "end": 329, "loc": { "start": { "line": 9, "column": 25 }, "end": { "line": 9, "column": 31 }, "identifierName": "origin" }, "name": "origin" }, "computed": false }, "property": { "type": "Identifier", "start": 330, "end": 331, "loc": { "start": { "line": 9, "column": 32 }, "end": { "line": 9, "column": 33 }, "identifierName": "z" }, "name": "z" }, "computed": false }, "extra": { "parenthesized": true, "parenStart": 314 } }, "operator": "/", "right": { "type": "MemberExpression", "start": 335, "end": 350, "loc": { "start": { "line": 9, "column": 37 }, "end": { "line": 9, "column": 52 } }, "object": { "type": "MemberExpression", "start": 335, "end": 348, "loc": { "start": { "line": 9, "column": 37 }, "end": { "line": 9, "column": 50 } }, "object": { "type": "Identifier", "start": 335, "end": 338, "loc": { "start": { "line": 9, "column": 37 }, "end": { "line": 9, "column": 40 }, "identifierName": "ray" }, "name": "ray" }, "property": { "type": "Identifier", "start": 339, "end": 348, "loc": { "start": { "line": 9, "column": 41 }, "end": { "line": 9, "column": 50 }, "identifierName": "direction" }, "name": "direction" }, "computed": false }, "property": { "type": "Identifier", "start": 349, "end": 350, "loc": { "start": { "line": 9, "column": 51 }, "end": { "line": 9, "column": 52 }, "identifierName": "z" }, "name": "z" }, "computed": false } }, "leadingComments": null } ], "kind": "var", "leadingComments": [ { "type": "CommentLine", "value": "calculate intersection of line with z = 0 plane", "start": 248, "end": 297, "loc": { "start": { "line": 8, "column": 4 }, "end": { "line": 8, "column": 53 } } } ] }, { "type": "VariableDeclaration", "start": 356, "end": 388, "loc": { "start": { "line": 10, "column": 4 }, "end": { "line": 10, "column": 36 } }, "declarations": [ { "type": "VariableDeclarator", "start": 360, "end": 387, "loc": { "start": { "line": 10, "column": 8 }, "end": { "line": 10, "column": 35 } }, "id": { "type": "Identifier", "start": 360, "end": 371, "loc": { "start": { "line": 10, "column": 8 }, "end": { "line": 10, "column": 19 }, "identifierName": "sketchPoint" }, "name": "sketchPoint" }, "init": { "type": "CallExpression", "start": 374, "end": 387, "loc": { "start": { "line": 10, "column": 22 }, "end": { "line": 10, "column": 35 } }, "callee": { "type": "MemberExpression", "start": 374, "end": 380, "loc": { "start": { "line": 10, "column": 22 }, "end": { "line": 10, "column": 28 } }, "object": { "type": "Identifier", "start": 374, "end": 377, "loc": { "start": { "line": 10, "column": 22 }, "end": { "line": 10, "column": 25 }, "identifierName": "ray" }, "name": "ray" }, "property": { "type": "Identifier", "start": 378, "end": 380, "loc": { "start": { "line": 10, "column": 26 }, "end": { "line": 10, "column": 28 }, "identifierName": "at" }, "name": "at" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 381, "end": 386, "loc": { "start": { "line": 10, "column": 29 }, "end": { "line": 10, "column": 34 }, "identifierName": "param" }, "name": "param" } ] } } ], "kind": "let" }, { "type": "ExpressionStatement", "start": 393, "end": 411, "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 11, "column": 22 } }, "expression": { "type": "AssignmentExpression", "start": 393, "end": 410, "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 11, "column": 21 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 393, "end": 406, "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 11, "column": 17 } }, "object": { "type": "Identifier", "start": 393, "end": 404, "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 11, "column": 15 }, "identifierName": "sketchPoint" }, "name": "sketchPoint" }, "property": { "type": "Identifier", "start": 405, "end": 406, "loc": { "start": { "line": 11, "column": 16 }, "end": { "line": 11, "column": 17 }, "identifierName": "z" }, "name": "z" }, "computed": false }, "right": { "type": "NumericLiteral", "start": 409, "end": 410, "loc": { "start": { "line": 11, "column": 20 }, "end": { "line": 11, "column": 21 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 } }, "trailingComments": [ { "type": "CommentLine", "value": "ensure it is exactly zero", "start": 413, "end": 440, "loc": { "start": { "line": 11, "column": 24 }, "end": { "line": 11, "column": 51 } } } ] }, { "type": "ReturnStatement", "start": 445, "end": 464, "loc": { "start": { "line": 12, "column": 4 }, "end": { "line": 12, "column": 23 } }, "argument": { "type": "Identifier", "start": 452, "end": 463, "loc": { "start": { "line": 12, "column": 11 }, "end": { "line": 12, "column": 22 }, "identifierName": "sketchPoint" }, "name": "sketchPoint", "leadingComments": null }, "leadingComments": [ { "type": "CommentLine", "value": "ensure it is exactly zero", "start": 413, "end": 440, "loc": { "start": { "line": 11, "column": 24 }, "end": { "line": 11, "column": 51 } } } ] } ], "directives": [] }, "leadingComments": [], "trailingComments": [] } }, { "type": "ExportNamedDeclaration", "start": 468, "end": 1022, "loc": { "start": { "line": 15, "column": 0 }, "end": { "line": 31, "column": 1 } }, "specifiers": [], "source": null, "declaration": { "type": "FunctionDeclaration", "start": 475, "end": 1022, "loc": { "start": { "line": 15, "column": 7 }, "end": { "line": 31, "column": 1 } }, "id": { "type": "Identifier", "start": 484, "end": 505, "loc": { "start": { "line": 15, "column": 16 }, "end": { "line": 15, "column": 37 }, "identifierName": "calcWorldToPixelScale" }, "name": "calcWorldToPixelScale" }, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 506, "end": 510, "loc": { "start": { "line": 15, "column": 38 }, "end": { "line": 15, "column": 42 }, "identifierName": "view" }, "name": "view" }, { "type": "Identifier", "start": 512, "end": 515, "loc": { "start": { "line": 15, "column": 44 }, "end": { "line": 15, "column": 47 }, "identifierName": "pos" }, "name": "pos" } ], "body": { "type": "BlockStatement", "start": 517, "end": 1022, "loc": { "start": { "line": 15, "column": 49 }, "end": { "line": 31, "column": 1 } }, "body": [ { "type": "VariableDeclaration", "start": 523, "end": 567, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 16, "column": 48 } }, "declarations": [ { "type": "VariableDeclarator", "start": 529, "end": 566, "loc": { "start": { "line": 16, "column": 10 }, "end": { "line": 16, "column": 47 } }, "id": { "type": "Identifier", "start": 529, "end": 533, "loc": { "start": { "line": 16, "column": 10 }, "end": { "line": 16, "column": 14 }, "identifierName": "dirs" }, "name": "dirs" }, "init": { "type": "ArrayExpression", "start": 536, "end": 566, "loc": { "start": { "line": 16, "column": 17 }, "end": { "line": 16, "column": 47 } }, "elements": [ { "type": "ArrayExpression", "start": 537, "end": 542, "loc": { "start": { "line": 16, "column": 18 }, "end": { "line": 16, "column": 23 } }, "elements": [ { "type": "NumericLiteral", "start": 538, "end": 539, "loc": { "start": { "line": 16, "column": 19 }, "end": { "line": 16, "column": 20 } }, "extra": { "rawValue": 1, "raw": "1" }, "value": 1 }, { "type": "NumericLiteral", "start": 540, "end": 541, "loc": { "start": { "line": 16, "column": 21 }, "end": { "line": 16, "column": 22 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 } ] }, { "type": "ArrayExpression", "start": 544, "end": 549, "loc": { "start": { "line": 16, "column": 25 }, "end": { "line": 16, "column": 30 } }, "elements": [ { "type": "NumericLiteral", "start": 545, "end": 546, "loc": { "start": { "line": 16, "column": 26 }, "end": { "line": 16, "column": 27 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 }, { "type": "NumericLiteral", "start": 547, "end": 548, "loc": { "start": { "line": 16, "column": 28 }, "end": { "line": 16, "column": 29 } }, "extra": { "rawValue": 1, "raw": "1" }, "value": 1 } ] }, { "type": "ArrayExpression", "start": 551, "end": 557, "loc": { "start": { "line": 16, "column": 32 }, "end": { "line": 16, "column": 38 } }, "elements": [ { "type": "UnaryExpression", "start": 552, "end": 554, "loc": { "start": { "line": 16, "column": 33 }, "end": { "line": 16, "column": 35 } }, "operator": "-", "prefix": true, "argument": { "type": "NumericLiteral", "start": 553, "end": 554, "loc": { "start": { "line": 16, "column": 34 }, "end": { "line": 16, "column": 35 } }, "extra": { "rawValue": 1, "raw": "1" }, "value": 1 }, "extra": { "parenthesizedArgument": false } }, { "type": "NumericLiteral", "start": 555, "end": 556,