diff --git a/.gitignore b/.gitignore index b947077..c2658d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ node_modules/ -dist/ diff --git a/dist/activities_009569ed-3cb9-431b-81e1-42ba4813161e.json b/dist/activities_009569ed-3cb9-431b-81e1-42ba4813161e.json new file mode 100644 index 0000000..7df8800 --- /dev/null +++ b/dist/activities_009569ed-3cb9-431b-81e1-42ba4813161e.json @@ -0,0 +1 @@ +[{ "id": "(0)", "locations": [{ "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.39027609999999, "longitude": 13.8462689, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.38809500000001, "longitude": 13.8463177, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3881775, "longitude": 13.8416285, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3852875, "longitude": 13.8363342, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.38178550000001, "longitude": 13.8220093, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3841626, "longitude": 13.8185963, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3842368, "longitude": 13.6939406, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.38564590000001, "longitude": 13.6631418, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.38557429999999, "longitude": 13.6566067, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.38634990000001, "longitude": 13.6489507, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.38583610000001, "longitude": 13.6487476, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3859064, "longitude": 13.647893, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3852607, "longitude": 13.6440153, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3850093, "longitude": 13.6409336, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3840828, "longitude": 13.6403902, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.38407789999999, "longitude": 13.6404321, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3828578, "longitude": 13.5905677, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3868893, "longitude": 13.5770375, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3871575, "longitude": 13.5755124, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3879248, "longitude": 13.5718721, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.38892009999999, "longitude": 13.5733326, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3956402, "longitude": 13.5625716, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.401765, "longitude": 13.5514857, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3911736, "longitude": 13.5292616, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3903699, "longitude": 13.5196603, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.38970769999999, "longitude": 13.5049213, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3866917, "longitude": 13.459067, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.38485559999999, "longitude": 13.456855, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3824852, "longitude": 13.4266104, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.38268129999999, "longitude": 13.4263779, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3817497, "longitude": 13.4153767, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3819499, "longitude": 13.4151661, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.38267949999999, "longitude": 13.410797, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3830257, "longitude": 13.4077661, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.38195950000001, "longitude": 13.4077884, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3763556, "longitude": 13.3839204, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.36714430000001, "longitude": 13.3491167, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.35617049999999, "longitude": 13.3333684, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3557924, "longitude": 13.3337508, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.35586429999999, "longitude": 13.3346449, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3416054, "longitude": 13.3212613, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.34149309999999, "longitude": 13.3200605, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.32144039999999, "longitude": 13.2197024, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.31885949999999, "longitude": 13.2159319, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3176728, "longitude": 13.1665863, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.32937630000001, "longitude": 13.1335495, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3331624, "longitude": 13.1236538, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3088829, "longitude": 13.0895435, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3062328, "longitude": 13.0861193, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.3026788, "longitude": 13.0827763, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.302572, "longitude": 13.0830565, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.2960344, "longitude": 13.0708284, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.29599289999999, "longitude": 13.069818, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.2959525, "longitude": 13.0647341, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.2958732, "longitude": 13.0639157, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.2953902, "longitude": 13.058634, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.29322269999999, "longitude": 13.0494282, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.2929696, "longitude": 13.0484926, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.29195989999999, "longitude": 13.0413007, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.2908534, "longitude": 13.0342894, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.2827296, "longitude": 13.0080642, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.2823653, "longitude": 13.0090367, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.2686473, "longitude": 12.9673058, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.2628576, "longitude": 12.952808, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.2628175, "longitude": 12.9494559, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.2613392, "longitude": 12.9502615, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.24972689999999, "longitude": 12.9166171, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.24992640000001, "longitude": 12.9153739, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.2435416, "longitude": 12.8741956, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.2288766, "longitude": 12.8609152, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.2114139, "longitude": 12.8259342, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.19466, "longitude": 12.7864769, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.1958006, "longitude": 12.7812912, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.19572039999999, "longitude": 12.7809242, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.19564250000001, "longitude": 12.777116, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.18972420000001, "longitude": 12.7259136, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.18997460000001, "longitude": 12.7251928, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 58.11953140000001, "longitude": 12.5334279, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.92416439999999, "longitude": 12.3572657, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.91540859999999, "longitude": 12.3685885, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.9150414, "longitude": 12.3689692, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.91478649999999, "longitude": 12.3690548, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.8961027, "longitude": 12.3356419, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.8642647, "longitude": 12.3242304, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.84007399999999, "longitude": 12.31466, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.84019290000001, "longitude": 12.3141914, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.8368867, "longitude": 12.2975483, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.8354902, "longitude": 12.2926875, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.7982288, "longitude": 12.1461301, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.7983978, "longitude": 12.1457752, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.7770251, "longitude": 12.0646485, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.772595, "longitude": 12.0507074, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.7619558, "longitude": 12.0106606, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.7608096, "longitude": 12.0111735, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.7533873, "longitude": 12.011203, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.7367384, "longitude": 12.0058913, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.7301651, "longitude": 12.0068327, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.729052, "longitude": 12.0075521, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.72428729999999, "longitude": 12.0081766, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.71565450000001, "longitude": 12.0039775, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.6992031, "longitude": 11.9987082, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.6982813, "longitude": 11.9982065, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.6839238, "longitude": 12.0003298, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.67656779999999, "longitude": 12.0066848, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.6539184, "longitude": 12.0179406, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.6521775, "longitude": 12.0182533, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.65194690000001, "longitude": 12.0162145, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.6492626, "longitude": 12.0165055, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }, { "coords": { "accuracy": 1, "altitude": 80, "altitudeAccuracy": 1, "heading": 0, "latitude": 57.6492544, "longitude": 12.0166623, "speed": 5.0040000000000004 }, "timestamp": 1652739651961 }], "timestamp": 1652739651961 }] diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..0e67d6b --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,3 @@ +import Renderer from "./modules/renderer.js"; +export { Renderer as RouteRenderer }; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/dist/index.d.ts.map b/dist/index.d.ts.map new file mode 100644 index 0000000..c3f75d3 --- /dev/null +++ b/dist/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAE7C,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,CAAC"} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..c637ae3 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,3 @@ +import Renderer from "./modules/renderer.js"; +export { Renderer as RouteRenderer }; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map new file mode 100644 index 0000000..c02b31f --- /dev/null +++ b/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAE7C,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,CAAC"} \ No newline at end of file diff --git a/dist/modules/projection.d.ts b/dist/modules/projection.d.ts new file mode 100644 index 0000000..687db44 --- /dev/null +++ b/dist/modules/projection.d.ts @@ -0,0 +1,16 @@ +export declare class Projection { + static getTileSize(zoomLevel: number): number; + static getMercatorWorldCoordinateProjection(zoomLevel: number, latitude: number, longitude: number): { + left: number; + top: number; + }; + static getPixelCoordinates(zoomLevel: number, leftWorldCoordinate: number, topWorldCoordinate: number): { + left: number; + top: number; + }; + static projectToPixelCoordinate(zoomLevel: number, latitude: number, longitude: number): { + left: number; + top: number; + }; +} +//# sourceMappingURL=projection.d.ts.map \ No newline at end of file diff --git a/dist/modules/projection.d.ts.map b/dist/modules/projection.d.ts.map new file mode 100644 index 0000000..065f1a7 --- /dev/null +++ b/dist/modules/projection.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../src/modules/projection.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAU;IACnB,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM;IAIpC,MAAM,CAAC,oCAAoC,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;IAYlG,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM;;;;IAOrG,MAAM,CAAC,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;CAMzF"} \ No newline at end of file diff --git a/dist/modules/projection.js b/dist/modules/projection.js new file mode 100644 index 0000000..649f406 --- /dev/null +++ b/dist/modules/projection.js @@ -0,0 +1,31 @@ +export class Projection { + static getTileSize(zoomLevel) { + return zoomLevel * 256; + } + ; + static getMercatorWorldCoordinateProjection(zoomLevel, latitude, longitude) { + const tileSize = this.getTileSize(zoomLevel); + const latitudeToRadians = ((latitude * Math.PI) / 180); + const northing = Math.log(Math.tan((Math.PI / 4) + (latitudeToRadians / 2))); + return { + left: ((longitude + 180) * (tileSize / 360)), + top: ((tileSize / 2) - ((tileSize * northing) / (2 * Math.PI))) + }; + } + ; + static getPixelCoordinates(zoomLevel, leftWorldCoordinate, topWorldCoordinate) { + return { + left: leftWorldCoordinate * (2 ** zoomLevel), + top: topWorldCoordinate * (2 ** zoomLevel) + }; + } + ; + static projectToPixelCoordinate(zoomLevel, latitude, longitude) { + const worldCoordinates = this.getMercatorWorldCoordinateProjection(zoomLevel, latitude, longitude); + const pixelCoordinates = this.getPixelCoordinates(zoomLevel, worldCoordinates.left, worldCoordinates.top); + return pixelCoordinates; + } + ; +} +; +//# sourceMappingURL=projection.js.map \ No newline at end of file diff --git a/dist/modules/projection.js.map b/dist/modules/projection.js.map new file mode 100644 index 0000000..89ab51f --- /dev/null +++ b/dist/modules/projection.js.map @@ -0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gBAAgB,GAAG,IAAI,CAAC,oCAAoC,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QACnG,MAAM,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAE1G,OAAO,gBAAgB,CAAC;IAC5B,CAAC;IAAA,CAAC;CACL;AAAA,CAAC"} \ No newline at end of file diff --git a/dist/modules/renderer.d.ts b/dist/modules/renderer.d.ts new file mode 100644 index 0000000..0bac80e --- /dev/null +++ b/dist/modules/renderer.d.ts @@ -0,0 +1,41 @@ +import { Animation } from "./renderer/animation.js"; +export type RendererOptions = { + topColor?: number[]; + bottomColor?: number[]; + startBlockColor?: number[]; + endBlockColor?: number[]; + leftWallColor?: number[]; + rightWallColor?: number[]; + wallColor?: number[]; + wallWidth?: number; + elevationGradient?: boolean; + elevationGradientColors?: number[][]; + keepMinimumAltitude?: boolean; + projectionZoomLevel?: number; + cameraFov?: number; + cameraTranslation?: number[]; + cameraRotation?: number[]; + premultipliedAlpha?: boolean; + grid?: boolean; + gridColor?: number[]; + gridPadding?: number; +}; +export default class Renderer { + private canvas; + private context; + private options; + private programInfo; + private paths; + private bufferers; + private animations; + private deltaX; + private deltaY; + private previous; + constructor(canvas: HTMLCanvasElement, options: RendererOptions); + setPaths(paths: any[][], animations?: Animation[] | null, project?: boolean): void; + private getAnimationFrame; + private registerMouseEvents; + private render; + private createBuffers; +} +//# sourceMappingURL=renderer.d.ts.map \ No newline at end of file diff --git a/dist/modules/renderer.d.ts.map b/dist/modules/renderer.d.ts.map new file mode 100644 index 0000000..f408910 --- /dev/null +++ b/dist/modules/renderer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/modules/renderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAkB,MAAM,yBAAyB,CAAC;AAMpE,MAAM,MAAM,e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AC,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,UAAU,GAAE,SAAS,EAAE,GAAG,IAAW,EAAE,OAAO,GAAE,OAAc;IA2H9F,OAAO,CAAC,iBAAiB;IA0DzB,OAAO,CAAC,mBAAmB;IA+B3B,OAAO,CAAC,MAAM;IAcd,OAAO,CAAC,aAAa;CAYxB"} \ No newline at end of file diff --git a/dist/modules/renderer.js b/dist/modules/renderer.js new file mode 100644 index 0000000..c100ffb --- /dev/null +++ b/dist/modules/renderer.js @@ -0,0 +1,207 @@ +import { Projection } from "./projection.js"; +import { RendererGridModel } from "./renderer/models/grid.js"; +import { RendererPathModel } from "./renderer/models/path.js"; +import { RendererScene } from "./renderer/scene.js"; +import { RendererWebGL } from "./renderer/webgl.js"; +export default class Renderer { + canvas; + context; + options; + programInfo; + paths = []; + bufferers = []; + animations = null; + deltaX = 0; + deltaY = 0; + previous = 0; + constructor(canvas, options) { + const context = canvas.getContext("webgl", { + premultipliedAlpha: options.premultipliedAlpha ?? true + }); + if (!context) + throw new Error("WebGL is not supported."); + this.canvas = canvas; + this.context = context; + this.options = options; + this.programInfo = RendererWebGL.initializeProgram(this.context); + this.registerMouseEvents(); + window.requestAnimationFrame(this.render.bind(this)); + } + ; + setPaths(paths, animations = null, project = true) { + let startLeft = NaN; + let startTop = NaN; + let minimumLeft = NaN; + let maximumLeft = NaN; + let minimumTop = NaN; + let maximumTop = NaN; + let minimumAltitude = NaN; + let maximumAltitude = NaN; + for (let path of paths) + for (let coordinate of path) { + if (!project) { + coordinate.projection = { + left: coordinate.x, + top: coordinate.y + }; + coordinate.altitude = coordinate.z; + } + else + coordinate.projection = Projection.projectToPixelCoordinate(this.options.projectionZoomLevel ?? 2, coordinate.latitude, coordinate.longitude); + if (window.isNaN(minimumAltitude) || coordinate.altitude < minimumAltitude) + minimumAltitude = coordinate.altitude; + if (window.isNaN(maximumAltitude) || coordinate.altitude > maximumAltitude) + maximumAltitude = coordinate.altitude; + if (window.isNaN(startLeft)) + startLeft = coordinate.projection.left; + if (window.isNaN(startTop)) + startTop = coordinate.projection.top; + if (window.isNaN(minimumLeft) || coordinate.projection.left < minimumLeft) + minimumLeft = coordinate.projection.left; + if (window.isNaN(maximumLeft) || coordinate.projection.left > maximumLeft) + maximumLeft = coordinate.projection.left; + if (window.isNaN(minimumTop) || coordinate.projection.top < minimumTop) + minimumTop = coordinate.projection.top; + if (window.isNaN(maximumTop) || coordinate.projection.top > maximumTop) + maximumTop = coordinate.projection.top; + } + const centerLeft = (maximumLeft - minimumLeft) / 2; + const centerTop = (maximumTop - minimumTop) / 2; + const green = [0, 1, 0, 1]; + const red = [1, 0, 0, 1]; + if (this.options.keepMinimumAltitude) + minimumAltitude = 0; + this.paths = paths.map((path) => { + const points = []; + let fullDistance = 0; + path.forEach((coordinate, index) => { + const colorMultiplier = (coordinate.altitude - minimumAltitude) / (maximumAltitude - minimumAltitude); + const x = ((startLeft > coordinate.projection.left) ? (startLeft - coordinate.projection.left) : (coordinate.projection.left - startLeft)) - (centerLeft); + const y = ((startTop < coordinate.projection.top) ? (startTop - coordinate.projection.top) : (coordinate.projection.top - startTop)) + (centerTop); + const z = (coordinate.altitude - minimumAltitude) * ((this.options.projectionZoomLevel ?? 2) / 100); + const distanceX = (index === 0) ? (0) : (Math.abs(x - points[index - 1].x)); + const distanceY = (index === 0) ? (0) : (Math.abs(y - points[index - 1].y)); + const distance = Math.sqrt(Math.pow(distanceX, 2) + Math.pow(distanceY, 2)); + const point = { + x, y, z, + distanceX, + distanceY, + distance, + distanceStart: fullDistance, + verticles: null, + color: (!this.options.elevationGradient) ? (coordinate.color?.map((index) => index / 255)) : ((this.options.elevationGradientColors) ? ([ + ((this.options.elevationGradientColors[0][0] + (this.options.elevationGradientColors[1][0] - this.options.elevationGradientColors[0][0]) * colorMultiplier)) / 255, + ((this.options.elevationGradientColors[0][1] + (this.options.elevationGradientColors[1][1] - this.options.elevationGradientColors[0][1]) * colorMultiplier)) / 255, + ((this.options.elevationGradientColors[0][2] + (this.options.elevationGradientColors[1][2] - this.options.elevationGradientColors[0][2]) * colorMultiplier)) / 255, + ((this.options.elevationGradientColors[0][3] + (this.options.elevationGradientColors[1][3] - this.options.elevationGradientColors[0][3]) * colorMultiplier)) / 255 + ]) : ([ + (green[0] + (red[0] - green[0]) * colorMultiplier), + (green[1] + (red[1] - green[1]) * colorMultiplier), + (green[2] + (red[2] - green[2]) * colorMultiplier), + 1.0 + ])) + }; + points.push(point); + fullDistance += distance; + }); + return { + points, + fullDistance + }; + }); + this.animations = animations; + this.bufferers = this.bufferers = this.createBuffers(performance.now()); + } + ; + getAnimationFrame(now = 0) { + const frame = { + distanceFraction: 1, + elevationFraction: 1 + }; + if (this.animations) { + const delta = now - this.previous; + this.previous = now; + for (let index = 0; index < this.animations.length; index++) { + const animation = this.animations[index]; + if (!animation.progress) { + animation.progress = { + elapsed: 0 + }; + } + animation.progress.elapsed += delta; + let fraction = Math.max(Math.min(animation.progress.elapsed / animation.interval, 1), 0); + if (!animation.forwards) + fraction = 1 - fraction; + if (fraction === ((animation.forwards) ? (1) : (0))) { + if (!animation.repeat) { + this.animations.splice(index, 1); + index--; + } + else { + animation.forwards = !animation.forwards; + delete animation.progress; + } + } + switch (animation.type) { + case "distance": { + frame.distanceFraction = fraction; + break; + } + case "elevation": { + frame.elevationFraction = fraction; + break; + } + } + } + } + return frame; + } + ; + registerMouseEvents() { + let mouseDown = false; + let lastMouseX = null; + let lastMouseY = null; + this.canvas.addEventListener("mousedown", (event) => { + mouseDown = true; + lastMouseX = event.pageX; + lastMouseY = event.pageY; + }); + document.body.addEventListener("mouseup", (event) => { + mouseDown = false; + }); + document.body.addEventListener("mousemove", (event) => { + if (!mouseDown || lastMouseX === null || lastMouseY === null) { + return; + } + const newX = event.pageX; + const newY = event.pageY; + this.deltaX += newX - lastMouseX; + this.deltaY += newY - lastMouseY; + lastMouseX = newX; + lastMouseY = newY; + }); + } + ; + render(now, previousAnimations) { + const animations = this.animations?.length; + if (this.bufferers.length !== this.paths.length || this.animations?.length || this.animations?.length !== previousAnimations) + this.bufferers = this.createBuffers(now); + RendererScene.drawScene(this.context, this.programInfo, this.bufferers, this.options, { + x: this.deltaX, + y: this.deltaY + }); + window.requestAnimationFrame((now) => this.render(now, animations)); + } + ; + createBuffers(now) { + const buffers = []; + const animationFrame = this.getAnimationFrame(now); + buffers.push(...this.paths.map((path) => RendererPathModel.createBuffers(this.context, path, this.options, animationFrame))); + if (this.options.grid) + buffers.push(RendererGridModel.createBuffers(this.context, this.options, animationFrame, this.paths)); + return buffers; + } + ; +} +; +//# sourceMappingURL=renderer.js.map \ No newline at end of file diff --git a/dist/modules/renderer.js.map b/dist/modules/renderer.js.map new file mode 100644 index 0000000..1c72f97 --- /dev/null +++ b/dist/modules/renderer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../src/modules/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAgCpD,MAAM,CAAC,OAAO,OAAO,QAAQ;IACjB,MAAM,CAAoB;IAC1B,OAAO,CAAwB;IAC/B,OAAO,CAAkB;IACzB,WAAW,CAAM;IAEjB,KAAK,GAAU,EAAE,CAAC;IAClB,SAAS,GAAU,EAAE,CAAC;IACtB,UAAU,GAAuB,IAAI,CAAC;IAEtC,MAAM,GAAW,CAAC,CAAC;IACnB,MAAM,GAAW,CAAC,CAAC;IAEnB,QAAQ,GAAW,CAAC,CAAC;IAE7B,YAAY,MAAyB,EAAE,OAAwB;QAC3D,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE;YACvC,kBAA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AE,IAAI,CAAC,OAAO,EAAE;YAClF,CAAC,EAAE,IAAI,CAAC,MAAM;YACd,CAAC,EAAE,IAAI,CAAC,MAAM;SACjB,CAAC,CAAC;QAEH,MAAM,CAAC,qBAAqB,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC;IACxE,CAAC;IAAA,CAAC;IAEM,aAAa,CAAC,GAAW;QAC7B,MAAM,OAAO,GAAG,EAAE,CAAC;QAEnB,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;QAEnD,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;QAE7H,IAAG,IAAI,CAAC,OAAO,CAAC,IAAI;YAChB,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAE1G,OAAO,OAAO,CAAC;IACnB,CAAC;IAAA,CAAC;CACL;AAAA,CAAC"} \ No newline at end of file diff --git a/dist/modules/renderer/animation.d.ts b/dist/modules/renderer/animation.d.ts new file mode 100644 index 0000000..592f485 --- /dev/null +++ b/dist/modules/renderer/animation.d.ts @@ -0,0 +1,15 @@ +export type Animation = { + type: "distance" | "elevation"; + forwards: boolean; + interval: number; + repeat: boolean; + progress?: AnimationProgress; +}; +export type AnimationProgress = { + elapsed: number; +}; +export type AnimationFrame = { + distanceFraction: number; + elevationFraction: number; +}; +//# sourceMappingURL=animation.d.ts.map \ No newline at end of file diff --git a/dist/modules/renderer/animation.d.ts.map b/dist/modules/renderer/animation.d.ts.map new file mode 100644 index 0000000..0c0ce56 --- /dev/null +++ b/dist/modules/renderer/animation.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"animation.d.ts","sourceRoot":"","sources":["../../../src/modules/renderer/animation.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACpB,IAAI,EAAE,UAAU,GAAG,WAAW,CAAC;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAEhB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;CAC7B,CAAC"} \ No newline at end of file diff --git a/dist/modules/renderer/animation.js b/dist/modules/renderer/animation.js new file mode 100644 index 0000000..1f9c2bb --- /dev/null +++ b/dist/modules/renderer/animation.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=animation.js.map \ No newline at end of file diff --git a/dist/modules/renderer/animation.js.map b/dist/modules/renderer/animation.js.map new file mode 100644 index 0000000..e3451f1 --- /dev/null +++ b/dist/modules/renderer/animation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"animation.js","sourceRoot":"","sources":["../../../src/modules/renderer/animation.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/modules/renderer/buffer.d.ts b/dist/modules/renderer/buffer.d.ts new file mode 100644 index 0000000..733828a --- /dev/null +++ b/dist/modules/renderer/buffer.d.ts @@ -0,0 +1,14 @@ +import { RendererOptions } from "../renderer"; +import { AnimationFrame } from "./animation"; +export declare class RendererPathBuffer { + static initBuffers(gl: WebGLRenderingContext, path: any, options: RendererOptions, animationFrame: AnimationFrame): { + verticles: number; + position: WebGLBuffer | null; + color: WebGLBuffer | null; + indices: WebGLBuffer | null; + }; + static initPositionBuffer(gl: WebGLRenderingContext, positions: number[]): WebGLBuffer | null; + static initColorBuffer(gl: WebGLRenderingContext, faceColors: any[]): WebGLBuffer | null; + static initIndexBuffer(gl: WebGLRenderingContext, indices: number[]): WebGLBuffer | null; +} +//# sourceMappingURL=buffer.d.ts.map \ No newline at end of file diff --git a/dist/modules/renderer/buffer.d.ts.map b/dist/modules/renderer/buffer.d.ts.map new file mode 100644 index 0000000..f60b4c7 --- /dev/null +++ b/dist/modules/renderer/buffer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../src/modules/renderer/buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAI7C,qBAAa,kBAAkB;IAC3B,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc;;;;;;IA4VjH,MAAM,CAAC,kBAAkB,CAAC,EAAE,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,EAAE;IAgBxE,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,qBAAqB,EAAE,UAAU,EAAE,GAAG,EAAE;IAkBnE,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,EAAE;CAkBtE"} \ No newline at end of file diff --git a/dist/modules/renderer/buffer.js b/dist/modules/renderer/buffer.js new file mode 100644 index 0000000..1c79076 --- /dev/null +++ b/dist/modules/renderer/buffer.js @@ -0,0 +1,258 @@ +export class RendererPathBuffer { + static initBuffers(gl, path, options, animationFrame) { + const positions = []; + const faceColors = []; + const indices = []; + let indexForIndices = 0; + let distance = 0; + const breakingPoint = path.fullDistance * animationFrame.distanceFraction; + for (let index = 1; index < path.points.length; index++) { + const from = path.points[index - 1]; + const to = path.points[index]; + const fromElevation = from.z * animationFrame.elevationFraction; + const toElevation = to.z * animationFrame.elevationFraction; + let pointFraction = 1.0; + distance = to.distanceStart; + if (distance > breakingPoint) + break; + if (breakingPoint < (distance + to.distance)) + pointFraction = Math.min((breakingPoint - to.distanceStart) / to.distance, 1); + const difference = { + x: (to.x - from.x), + y: (to.y - from.y) + }; + const from3 = vec3.fromValues(from.y, from.x, fromElevation); + const to3 = vec3.fromValues(from.y + (difference.y * pointFraction), from.x + (difference.x * pointFraction), toElevation); + const direction = vec3.sub(vec3.create(), to3, from3); + const perpendicular = vec3.normalize(vec3.create(), [-direction[1], direction[0], 0]); + const halfWidth = (options.wallWidth ?? .1) / 2; + const topVertices = [ + vec3.add(vec3.create(), from3, vec3.scale(vec3.create(), perpendicular, halfWidth)), + vec3.add(vec3.create(), to3, vec3.scale(vec3.create(), perpendicular, halfWidth)) + ]; + const bottomVertices = [ + vec3.sub(vec3.create(), from3, vec3.scale(vec3.create(), perpendicular, halfWidth)), + vec3.sub(vec3.create(), to3, vec3.scale(vec3.create(), perpendicular, halfWidth)) + ]; + // the main tunnel + { + // left wall + positions.push(bottomVertices[0][0], // back left Y (bottom) + 0.0, bottomVertices[0][1], // back left X (bottom) + bottomVertices[0][0], // back left Y (top) + fromElevation, bottomVertices[0][1], // back left X (top) + bottomVertices[1][0], // front left Y (top) + toElevation, bottomVertices[1][1], // front left X (top) + bottomVertices[1][0], // front left Y (bottom) + 0.0, bottomVertices[1][1] // front left X (bottom) + ); + // right wall + positions.push(topVertices[0][0], // back right Y (bottom) + 0.0, topVertices[0][1], // back right X (bottom) + topVertices[0][0], // back right Y (top) + fromElevation, topVertices[0][1], // back right X (top) + topVertices[1][0], // front right Y (top) + toElevation, topVertices[1][1], // front right X (top) + topVertices[1][0], // front right Y (bottom) + 0.0, topVertices[1][1] // front right X (bottom) + ); + // top face + positions.push(topVertices[0][0], // back right Y + topVertices[0][2], topVertices[0][1], // back right X + topVertices[1][0], // top right Y + topVertices[1][2], topVertices[1][1], // top right X + bottomVertices[1][0], // top left Y + bottomVertices[1][2], bottomVertices[1][1], // top left X, + bottomVertices[0][0], // back left Y + bottomVertices[0][2], bottomVertices[0][1] // back left X + ); + // bottom face + positions.push(topVertices[0][0], // back right Y + -0.001, topVertices[0][1], // back right X + topVertices[1][0], // top right Y + -0.001, topVertices[1][1], // top right X + bottomVertices[1][0], // top left Y + -0.001, bottomVertices[1][1], // top left X, + bottomVertices[0][0], // back left Y + -0.001, bottomVertices[0][1] // back left X + ); + faceColors.push(...[ + to.color ?? options.leftWallColor?.map((index) => index / 255) ?? options.wallColor?.map((index) => index / 255) ?? [0, 1, 0, 1], + to.color ?? options.rightWallColor?.map((index) => index / 255) ?? options.wallColor?.map((index) => index / 255) ?? [0, 0, 1, 1], + options.topColor?.map((index) => index / 255) ?? [1, 0, 0, 1], + options.bottomColor?.map((index) => index / 255) ?? [0, 0, 0, 1] // bottom face + ]); + indices.push(...([ + 0, 1, 2, + 0, 2, 3, + 4, 5, 6, + 4, 6, 7, + 8, 9, 10, + 8, 10, 11, + 12, 13, 14, + 12, 14, 15, // bottom + ].map((number) => indexForIndices + number))); + indexForIndices += 16; + } + to.verticles = { + frontRightX: topVertices[1][1], + frontRightY: topVertices[1][0], + frontRightZ: topVertices[1][2], + frontLeftX: bottomVertices[1][1], + frontLeftY: bottomVertices[1][0], + frontLeftZ: bottomVertices[1][2] + }; + // the connecting tunnel + if (from.verticles) { + positions.push( + // left face + from.verticles.frontLeftY, // back left Y (bottom) + 0.0, from.verticles.frontLeftX, // back left X (bottom) + from.verticles.frontLeftY, // back left Y (top) + from.verticles.frontLeftZ, from.verticles.frontLeftX, // back left X (top) + bottomVertices[0][0], // front left Y (top) + bottomVertices[0][2], bottomVertices[0][1], // front left X (top) + bottomVertices[0][0], // front left Y (bottom) + 0.0, bottomVertices[0][1] // front left X (bottom) + ); + positions.push( + // right face + from.verticles.frontRightY, // back right Y (bottom) + 0.0, from.verticles.frontRightX, // back right X (bottom) + from.verticles.frontRightY, // back right Y (top) + from.verticles.frontRightZ, from.verticles.frontRightX, // back right X (top) + topVertices[0][0], // front right Y (top) + topVertices[0][2], topVertices[0][1], // front right X (top) + topVertices[0][0], // front right Y (bottom) + 0.0, topVertices[0][1] // front right X (bottom) + ); + positions.push(from.verticles.frontRightY, // back right Y + from.verticles.frontRightZ, from.verticles.frontRightX, // back right X + topVertices[0][0], // top right Y + topVertices[0][2], topVertices[0][1], // top right X + bottomVertices[0][0], // top left Y + bottomVertices[0][2], bottomVertices[0][1], // top left X, + from.verticles.frontLeftY, // back left Y + from.verticles.frontLeftZ, from.verticles.frontLeftX // back left X + ); + // bottom face + positions.push(from.verticles.frontRightY, // back right Y + -0.001, from.verticles.frontRightX, // back right X + topVertices[0][0], // top right Y + -0.001, topVertices[0][1], // top right X + bottomVertices[0][0], // top left Y + -0.001, bottomVertices[0][1], // top left X, + from.verticles.frontLeftY, // back left Y + -0.001, from.verticles.frontLeftX // back left X + ); + faceColors.push(...[ + to.color ?? options.leftWallColor?.map((index) => index / 255) ?? options.wallColor?.map((index) => index / 255) ?? [0, 1, 0, 1], + to.color ?? options.rightWallColor?.map((index) => index / 255) ?? options.wallColor?.map((index) => index / 255) ?? [0, 0, 1, 1], + options.topColor?.map((index) => index / 255) ?? [1, 0, 0, 1], + options.bottomColor?.map((index) => index / 255) ?? [0, 0, 0, 1] // bottom face + ]); + indices.push(...([ + 0, 1, 2, + 0, 2, 3, + 4, 5, 6, + 4, 6, 7, + 8, 9, 10, + 8, 10, 11, + 12, 13, 14, + 12, 14, 15, // bottom + ].map((number) => indexForIndices + number))); + indexForIndices += 16; + } + if (index === path.points.length - 1) { + // final wall + positions.push( + // left face + topVertices[1][0], // back left Y (bottom) + 0.0, topVertices[1][1], // back left X (bottom) + topVertices[1][0], // back left Y (top) + toElevation, topVertices[1][1], // back left X (top) + bottomVertices[1][0], // front left Y (top) + toElevation, bottomVertices[1][1], // front left X (top) + bottomVertices[1][0], // front left Y (bottom) + 0.0, bottomVertices[1][1] // front left X (bottom) + ); + faceColors.push(...[ + to.color ?? options.endBlockColor?.map((index) => index / 255) ?? options.wallColor?.map((index) => index / 255) ?? [0, 0, 0, 1] + ]); + indices.push(...([ + 0, 1, 2, + 0, 2, 3, // front + ].map((number) => indexForIndices + number))); + indexForIndices += 4; + } + else if (index === 1) { + // initial wall + positions.push( + // left face + bottomVertices[0][0], // back left Y (bottom) + 0.0, bottomVertices[0][1], // back left X (bottom) + bottomVertices[0][0], // back left Y (top) + from.z, bottomVertices[0][1], // back left X (top) + topVertices[0][0], // front left Y (top) + from.z, topVertices[0][1], // front left X (top) + topVertices[0][0], // front left Y (bottom) + 0.0, topVertices[0][1] // front left X (bottom) + ); + faceColors.push(...[ + to.color ?? options.startBlockColor?.map((index) => index / 255) ?? options.wallColor?.map((index) => index / 255) ?? [0, 0, 0, 1] + ]); + indices.push(...([ + 0, 1, 2, + 0, 2, 3, // front + ].map((number) => indexForIndices + number))); + indexForIndices += 4; + } + } + const positionBuffer = this.initPositionBuffer(gl, positions); + const colorBuffer = this.initColorBuffer(gl, faceColors); + const indexBuffer = this.initIndexBuffer(gl, indices); + return { + verticles: positions.length / 2, + position: positionBuffer, + color: colorBuffer, + indices: indexBuffer, + }; + } + static initPositionBuffer(gl, positions) { + // Create a buffer for the square's positions. + const positionBuffer = gl.createBuffer(); + // Select the positionBuffer as the one to apply buffer + // operations to from here out. + gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer); + // Now pass the list of positions into WebGL to build the + // shape. We do this by creating a Float32Array from the + // JavaScript array, then use it to fill the current buffer. + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW); + return positionBuffer; + } + static initColorBuffer(gl, faceColors) { + // Convert the array of colors into a table for all the vertices. + var colors = []; + for (var j = 0; j < faceColors.length; ++j) { + const c = faceColors[j]; + // Repeat each color four times for the four vertices of the face + colors = colors.concat(c, c, c, c); + } + const colorBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(colors), gl.STATIC_DRAW); + return colorBuffer; + } + static initIndexBuffer(gl, indices) { + const indexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); + // This array defines each face as two triangles, using the + // indices into the vertex array to specify each triangle's + // position. + // Now send the element array to GL + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), gl.STATIC_DRAW); + return indexBuffer; + } +} +; +//# sourceMappingURL=buffer.js.map \ No newline at end of file diff --git a/dist/modules/renderer/buffer.js.map b/dist/modules/renderer/buffer.js.map new file mode 100644 index 0000000..4dc7cfa --- /dev/null +++ b/dist/modules/renderer/buffer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../../src/modules/renderer/buffer.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,kBAAkB;IAC3B,MAAM,CAAC,WAAW,CAAC,EAAyB,EAAE,IAAS,EAAE,OAAwB,EAAE,cAA8B;QAC7G,MAAM,SAAS,GAAG,EAAE,CAAC;QACrB,MAAM,UAAU,GAAG,EAAE,CAAC;QACtB,MAAM,OAAO,GAAG,EAAE,CAAC;QAEnB,IAAI,eAAe,GAAG,CAAC,CAAC;QAExB,IAAI,QAAQ,GAAG,CAAC,CAAC;QAEjB,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,GAAG,cAAc,CAAC,gBAAgB,CAAC;QAE1E,KAAI,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YACpD,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;YACpC,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAE9B,MAAM,aAAa,GA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AAC,WAAW,CACjB,CAAC;QAEF,OAAO,WAAW,CAAC;IACvB,CAAC;CACJ;AAAA,CAAC"} \ No newline at end of file diff --git a/dist/modules/renderer/buffers.d.ts b/dist/modules/renderer/buffers.d.ts new file mode 100644 index 0000000..b79d037 --- /dev/null +++ b/dist/modules/renderer/buffers.d.ts @@ -0,0 +1,6 @@ +export declare class RendererBuffers { + static initPositionBuffer(gl: WebGLRenderingContext, positions: number[]): WebGLBuffer | null; + static initColorBuffer(gl: WebGLRenderingContext, faceColors: any[]): WebGLBuffer | null; + static initIndexBuffer(gl: WebGLRenderingContext, indices: number[]): WebGLBuffer | null; +} +//# sourceMappingURL=buffers.d.ts.map \ No newline at end of file diff --git a/dist/modules/renderer/buffers.d.ts.map b/dist/modules/renderer/buffers.d.ts.map new file mode 100644 index 0000000..49246e9 --- /dev/null +++ b/dist/modules/renderer/buffers.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"buffers.d.ts","sourceRoot":"","sources":["../../../src/modules/renderer/buffers.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAe;IACxB,MAAM,CAAC,kBAAkB,CAAC,EAAE,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,EAAE;IAgBxE,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,qBAAqB,EAAE,UAAU,EAAE,GAAG,EAAE;IAkBnE,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,EAAE;CAkBtE"} \ No newline at end of file diff --git a/dist/modules/renderer/buffers.js b/dist/modules/renderer/buffers.js new file mode 100644 index 0000000..2b35bb1 --- /dev/null +++ b/dist/modules/renderer/buffers.js @@ -0,0 +1,39 @@ +export class RendererBuffers { + static initPositionBuffer(gl, positions) { + // Create a buffer for the square's positions. + const positionBuffer = gl.createBuffer(); + // Select the positionBuffer as the one to apply buffer + // operations to from here out. + gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer); + // Now pass the list of positions into WebGL to build the + // shape. We do this by creating a Float32Array from the + // JavaScript array, then use it to fill the current buffer. + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW); + return positionBuffer; + } + static initColorBuffer(gl, faceColors) { + // Convert the array of colors into a table for all the vertices. + var colors = []; + for (var j = 0; j < faceColors.length; ++j) { + const c = faceColors[j]; + // Repeat each color four times for the four vertices of the face + colors = colors.concat(c, c, c, c); + } + const colorBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(colors), gl.STATIC_DRAW); + return colorBuffer; + } + static initIndexBuffer(gl, indices) { + const indexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); + // This array defines each face as two triangles, using the + // indices into the vertex array to specify each triangle's + // position. + // Now send the element array to GL + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), gl.STATIC_DRAW); + return indexBuffer; + } +} +; +//# sourceMappingURL=buffers.js.map \ No newline at end of file diff --git a/dist/modules/renderer/buffers.js.map b/dist/modules/renderer/buffers.js.map new file mode 100644 index 0000000..59a4826 --- /dev/null +++ b/dist/modules/renderer/buffers.js.map @@ -0,0 +1 @@ +{"version":3,"file":"buffers.js","sourceRoot":"","sources":["../../../src/modules/renderer/buffers.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAe;IACxB,MAAM,CAAC,kBAAkB,CAAC,EAAyB,EAAE,SAAmB;QACpE,8CAA8C;QAC9C,MAAM,cAAc,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC;QAEzC,uDAAuD;QACvD,+BAA+B;QAC/B,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;QAE/C,yDAAyD;QACzD,wDAAwD;QACxD,4DAA4D;QAC5D,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,YAAY,EAAE,IAAI,YAAY,CAAC,SAA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ode 100644 index 0000000..7c0aed3 --- /dev/null +++ b/dist/modules/renderer/buffers/buffer.d.ts @@ -0,0 +1,14 @@ +import { RendererOptions } from "../../renderer"; +import { AnimationFrame } from "../animation"; +export declare class RendererPathBuffer { + static initBuffers(gl: WebGLRenderingContext, path: any, options: RendererOptions, animationFrame: AnimationFrame): { + verticles: number; + position: WebGLBuffer | null; + color: WebGLBuffer | null; + indices: WebGLBuffer | null; + }; + static initPositionBuffer(gl: WebGLRenderingContext, positions: number[]): WebGLBuffer | null; + static initColorBuffer(gl: WebGLRenderingContext, faceColors: any[]): WebGLBuffer | null; + static initIndexBuffer(gl: WebGLRenderingContext, indices: number[]): WebGLBuffer | null; +} +//# sourceMappingURL=buffer.d.ts.map \ No newline at end of file diff --git a/dist/modules/renderer/buffers/buffer.d.ts.map b/dist/modules/renderer/buffers/buffer.d.ts.map new file mode 100644 index 0000000..d7b3624 --- /dev/null +++ b/dist/modules/renderer/buffers/buffer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../../../src/modules/renderer/buffers/buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAI9C,qBAAa,kBAAkB;IAC3B,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc;;;;;;IA4VjH,MAAM,CAAC,kBAAkB,CAAC,EAAE,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,EAAE;IAgBxE,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,qBAAqB,EAAE,UAAU,EAAE,GAAG,EAAE;IAkBnE,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,EAAE;CAkBtE"} \ No newline at end of file diff --git a/dist/modules/renderer/buffers/buffer.js b/dist/modules/renderer/buffers/buffer.js new file mode 100644 index 0000000..1c79076 --- /dev/null +++ b/dist/modules/renderer/buffers/buffer.js @@ -0,0 +1,258 @@ +export class RendererPathBuffer { + static initBuffers(gl, path, options, animationFrame) { + const positions = []; + const faceColors = []; + const indices = []; + let indexForIndices = 0; + let distance = 0; + const breakingPoint = path.fullDistance * animationFrame.distanceFraction; + for (let index = 1; index < path.points.length; index++) { + const from = path.points[index - 1]; + const to = path.points[index]; + const fromElevation = from.z * animationFrame.elevationFraction; + const toElevation = to.z * animationFrame.elevationFraction; + let pointFraction = 1.0; + distance = to.distanceStart; + if (distance > breakingPoint) + break; + if (breakingPoint < (distance + to.distance)) + pointFraction = Math.min((breakingPoint - to.distanceStart) / to.distance, 1); + const difference = { + x: (to.x - from.x), + y: (to.y - from.y) + }; + const from3 = vec3.fromValues(from.y, from.x, fromElevation); + const to3 = vec3.fromValues(from.y + (difference.y * pointFraction), from.x + (difference.x * pointFraction), toElevation); + const direction = vec3.sub(vec3.create(), to3, from3); + const perpendicular = vec3.normalize(vec3.create(), [-direction[1], direction[0], 0]); + const halfWidth = (options.wallWidth ?? .1) / 2; + const topVertices = [ + vec3.add(vec3.create(), from3, vec3.scale(vec3.create(), perpendicular, halfWidth)), + vec3.add(vec3.create(), to3, vec3.scale(vec3.create(), perpendicular, halfWidth)) + ]; + const bottomVertices = [ + vec3.sub(vec3.create(), from3, vec3.scale(vec3.create(), perpendicular, halfWidth)), + vec3.sub(vec3.create(), to3, vec3.scale(vec3.create(), perpendicular, halfWidth)) + ]; + // the main tunnel + { + // left wall + positions.push(bottomVertices[0][0], // back left Y (bottom) + 0.0, bottomVertices[0][1], // back left X (bottom) + bottomVertices[0][0], // back left Y (top) + fromElevation, bottomVertices[0][1], // back left X (top) + bottomVertices[1][0], // front left Y (top) + toElevation, bottomVertices[1][1], // front left X (top) + bottomVertices[1][0], // front left Y (bottom) + 0.0, bottomVertices[1][1] // front left X (bottom) + ); + // right wall + positions.push(topVertices[0][0], // back right Y (bottom) + 0.0, topVertices[0][1], // back right X (bottom) + topVertices[0][0], // back right Y (top) + fromElevation, topVertices[0][1], // back right X (top) + topVertices[1][0], // front right Y (top) + toElevation, topVertices[1][1], // front right X (top) + topVertices[1][0], // front right Y (bottom) + 0.0, topVertices[1][1] // front right X (bottom) + ); + // top face + positions.push(topVertices[0][0], // back right Y + topVertices[0][2], topVertices[0][1], // back right X + topVertices[1][0], // top right Y + topVertices[1][2], topVertices[1][1], // top right X + bottomVertices[1][0], // top left Y + bottomVertices[1][2], bottomVertices[1][1], // top left X, + bottomVertices[0][0], // back left Y + bottomVertices[0][2], bottomVertices[0][1] // back left X + ); + // bottom face + positions.push(topVertices[0][0], // back right Y + -0.001, topVertices[0][1], // back right X + topVertices[1][0], // top right Y + -0.001, topVertices[1][1], // top right X + bottomVertices[1][0], // top left Y + -0.001, bottomVertices[1][1], // top left X, + bottomVertices[0][0], // back left Y + -0.001, bottomVertices[0][1] // back left X + ); + faceColors.push(...[ + to.color ?? options.leftWallColor?.map((index) => index / 255) ?? options.wallColor?.map((index) => index / 255) ?? [0, 1, 0, 1], + to.color ?? options.rightWallColor?.map((index) => index / 255) ?? options.wallColor?.map((index) => index / 255) ?? [0, 0, 1, 1], + options.topColor?.map((index) => index / 255) ?? [1, 0, 0, 1], + options.bottomColor?.map((index) => index / 255) ?? [0, 0, 0, 1] // bottom face + ]); + indices.push(...([ + 0, 1, 2, + 0, 2, 3, + 4, 5, 6, + 4, 6, 7, + 8, 9, 10, + 8, 10, 11, + 12, 13, 14, + 12, 14, 15, // bottom + ].map((number) => indexForIndices + number))); + indexForIndices += 16; + } + to.verticles = { + frontRightX: topVertices[1][1], + frontRightY: topVertices[1][0], + frontRightZ: topVertices[1][2], + frontLeftX: bottomVertices[1][1], + frontLeftY: bottomVertices[1][0], + frontLeftZ: bottomVertices[1][2] + }; + // the connecting tunnel + if (from.verticles) { + positions.push( + // left face + from.verticles.frontLeftY, // back left Y (bottom) + 0.0, from.verticles.frontLeftX, // back left X (bottom) + from.verticles.frontLeftY, // back left Y (top) + from.verticles.frontLeftZ, from.verticles.frontLeftX, // back left X (top) + bottomVertices[0][0], // front left Y (top) + bottomVertices[0][2], bottomVertices[0][1], // front left X (top) + bottomVertices[0][0], // front left Y (bottom) + 0.0, bottomVertices[0][1] // front left X (bottom) + ); + positions.push( + // right face + from.verticles.frontRightY, // back right Y (bottom) + 0.0, from.verticles.frontRightX, // back right X (bottom) + from.verticles.frontRightY, // back right Y (top) + from.verticles.frontRightZ, from.verticles.frontRightX, // back right X (top) + topVertices[0][0], // front right Y (top) + topVertices[0][2], topVertices[0][1], // front right X (top) + topVertices[0][0], // front right Y (bottom) + 0.0, topVertices[0][1] // front right X (bottom) + ); + positions.push(from.verticles.frontRightY, // back right Y + from.verticles.frontRightZ, from.verticles.frontRightX, // back right X + topVertices[0][0], // top right Y + topVertices[0][2], topVertices[0][1], // top right X + bottomVertices[0][0], // top left Y + bottomVertices[0][2], bottomVertices[0][1], // top left X, + from.verticles.frontLeftY, // back left Y + from.verticles.frontLeftZ, from.verticles.frontLeftX // back left X + ); + // bottom face + positions.push(from.verticles.frontRightY, // back right Y + -0.001, from.verticles.frontRightX, // back right X + topVertices[0][0], // top right Y + -0.001, topVertices[0][1], // top right X + bottomVertices[0][0], // top left Y + -0.001, bottomVertices[0][1], // top left X, + from.verticles.frontLeftY, // back left Y + -0.001, from.verticles.frontLeftX // back left X + ); + faceColors.push(...[ + to.color ?? options.leftWallColor?.map((index) => index / 255) ?? options.wallColor?.map((index) => index / 255) ?? [0, 1, 0, 1], + to.color ?? options.rightWallColor?.map((index) => index / 255) ?? options.wallColor?.map((index) => index / 255) ?? [0, 0, 1, 1], + options.topColor?.map((index) => index / 255) ?? [1, 0, 0, 1], + options.bottomColor?.map((index) => index / 255) ?? [0, 0, 0, 1] // bottom face + ]); + indices.push(...([ + 0, 1, 2, + 0, 2, 3, + 4, 5, 6, + 4, 6, 7, + 8, 9, 10, + 8, 10, 11, + 12, 13, 14, + 12, 14, 15, // bottom + ].map((number) => indexForIndices + number))); + indexForIndices += 16; + } + if (index === path.points.length - 1) { + // final wall + positions.push( + // left face + topVertices[1][0], // back left Y (bottom) + 0.0, topVertices[1][1], // back left X (bottom) + topVertices[1][0], // back left Y (top) + toElevation, topVertices[1][1], // back left X (top) + bottomVertices[1][0], // front left Y (top) + toElevation, bottomVertices[1][1], // front left X (top) + bottomVertices[1][0], // front left Y (bottom) + 0.0, bottomVertices[1][1] // front left X (bottom) + ); + faceColors.push(...[ + to.color ?? options.endBlockColor?.map((index) => index / 255) ?? options.wallColor?.map((index) => index / 255) ?? [0, 0, 0, 1] + ]); + indices.push(...([ + 0, 1, 2, + 0, 2, 3, // front + ].map((number) => indexForIndices + number))); + indexForIndices += 4; + } + else if (index === 1) { + // initial wall + positions.push( + // left face + bottomVertices[0][0], // back left Y (bottom) + 0.0, bottomVertices[0][1], // back left X (bottom) + bottomVertices[0][0], // back left Y (top) + from.z, bottomVertices[0][1], // back left X (top) + topVertices[0][0], // front left Y (top) + from.z, topVertices[0][1], // front left X (top) + topVertices[0][0], // front left Y (bottom) + 0.0, topVertices[0][1] // front left X (bottom) + ); + faceColors.push(...[ + to.color ?? options.startBlockColor?.map((index) => index / 255) ?? options.wallColor?.map((index) => index / 255) ?? [0, 0, 0, 1] + ]); + indices.push(...([ + 0, 1, 2, + 0, 2, 3, // front + ].map((number) => indexForIndices + number))); + indexForIndices += 4; + } + } + const positionBuffer = this.initPositionBuffer(gl, positions); + const colorBuffer = this.initColorBuffer(gl, faceColors); + const indexBuffer = this.initIndexBuffer(gl, indices); + return { + verticles: positions.length / 2, + position: positionBuffer, + color: colorBuffer, + indices: indexBuffer, + }; + } + static initPositionBuffer(gl, positions) { + // Create a buffer for the square's positions. + const positionBuffer = gl.createBuffer(); + // Select the positionBuffer as the one to apply buffer + // operations to from here out. + gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer); + // Now pass the list of positions into WebGL to build the + // shape. We do this by creating a Float32Array from the + // JavaScript array, then use it to fill the current buffer. + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW); + return positionBuffer; + } + static initColorBuffer(gl, faceColors) { + // Convert the array of colors into a table for all the vertices. + var colors = []; + for (var j = 0; j < faceColors.length; ++j) { + const c = faceColors[j]; + // Repeat each color four times for the four vertices of the face + colors = colors.concat(c, c, c, c); + } + const colorBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(colors), gl.STATIC_DRAW); + return colorBuffer; + } + static initIndexBuffer(gl, indices) { + const indexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); + // This array defines each face as two triangles, using the + // indices into the vertex array to specify each triangle's + // position. + // Now send the element array to GL + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), gl.STATIC_DRAW); + return indexBuffer; + } +} +; +//# sourceMappingURL=buffer.js.map \ No newline at end of file diff --git a/dist/modules/renderer/buffers/buffer.js.map b/dist/modules/renderer/buffers/buffer.js.map new file mode 100644 index 0000000..c3f804f --- /dev/null +++ b/dist/modules/renderer/buffers/buffer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../../../src/modules/renderer/buffers/buffer.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,kBAAkB;IAC3B,MAAM,CAAC,WAAW,CAAC,EAAyB,EAAE,IAAS,EAAE,OAAwB,EAAE,cAA8B;QAC7G,MAAM,SAAS,GAAG,EAAE,CAAC;QACrB,MAAM,UAAU,GAAG,EAAE,CAAC;QACtB,MAAM,OAAO,GAAG,EAAE,CAAC;QAEnB,IAAI,eAAe,GAAG,CAAC,CAAC;QAExB,IAAI,QAAQ,GAAG,CAAC,CAAC;QAEjB,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,GAAG,cAAc,CAAC,gB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C/D,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC;QACtC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC;QAEpD,2DAA2D;QAC3D,2DAA2D;QAC3D,YAAY;QAEZ,mCAAmC;QAEnC,EAAE,CAAC,UAAU,CACT,EAAE,CAAC,oBAAoB,EACvB,IAAI,WAAW,CAAC,OAAO,CAAC,EACxB,EAAE,CAAC,WAAW,CACjB,CAAC;QAEF,OAAO,WAAW,CAAC;IACvB,CAAC;CACJ;AAAA,CAAC"} \ No newline at end of file diff --git a/dist/modules/renderer/buffers/path.d.ts b/dist/modules/renderer/buffers/path.d.ts new file mode 100644 index 0000000..5920a83 --- /dev/null +++ b/dist/modules/renderer/buffers/path.d.ts @@ -0,0 +1,14 @@ +import { RendererOptions } from "../../renderer"; +import { AnimationFrame } from "../animation"; +export declare class RendererPathBuffer { + static createBuffers(gl: WebGLRenderingContext, path: any, options: RendererOptions, animationFrame: AnimationFrame): { + verticles: number; + position: WebGLBuffer | null; + color: WebGLBuffer | null; + indices: WebGLBuffer | null; + }; + static initPositionBuffer(gl: WebGLRenderingContext, positions: number[]): WebGLBuffer | null; + static initColorBuffer(gl: WebGLRenderingContext, faceColors: any[]): WebGLBuffer | null; + static initIndexBuffer(gl: WebGLRenderingContext, indices: number[]): WebGLBuffer | null; +} +//# sourceMappingURL=path.d.ts.map \ No newline at end of file diff --git a/dist/modules/renderer/buffers/path.d.ts.map b/dist/modules/renderer/buffers/path.d.ts.map new file mode 100644 index 0000000..96d6f74 --- /dev/null +++ b/dist/modules/renderer/buffers/path.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../../src/modules/renderer/buffers/path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAI9C,qBAAa,kBAAkB;IAC3B,MAAM,CAAC,aAAa,CAAC,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc;;;;;;IA4VnH,MAAM,CAAC,kBAAkB,CAAC,EAAE,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,EAAE;IAgBxE,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,qBAAqB,EAAE,UAAU,EAAE,GAAG,EAAE;IAkBnE,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,EAAE;CAkBtE"} \ No newline at end of file diff --git a/dist/modules/renderer/buffers/path.js b/dist/modules/renderer/buffers/path.js new file mode 100644 index 0000000..5ae1017 --- /dev/null +++ b/dist/modules/renderer/buffers/path.js @@ -0,0 +1,258 @@ +export class RendererPathBuffer { + static createBuffers(gl, path, options, animationFrame) { + const positions = []; + const faceColors = []; + const indices = []; + let indexForIndices = 0; + let distance = 0; + const breakingPoint = path.fullDistance * animationFrame.distanceFraction; + for (let index = 1; index < path.points.length; index++) { + const from = path.points[index - 1]; + const to = path.points[index]; + const fromElevation = from.z * animationFrame.elevationFraction; + const toElevation = to.z * animationFrame.elevationFraction; + let pointFraction = 1.0; + distance = to.distanceStart; + if (distance > breakingPoint) + break; + if (breakingPoint < (distance + to.distance)) + pointFraction = Math.min((breakingPoint - to.distanceStart) / to.distance, 1); + const difference = { + x: (to.x - from.x), + y: (to.y - from.y) + }; + const from3 = vec3.fromValues(from.y, from.x, fromElevation); + const to3 = vec3.fromValues(from.y + (difference.y * pointFraction), from.x + (difference.x * pointFraction), toElevation); + const direction = vec3.sub(vec3.create(), to3, from3); + const perpendicular = vec3.normalize(vec3.create(), [-direction[1], direction[0], 0]); + const halfWidth = (options.wallWidth ?? .1) / 2; + const topVertices = [ + vec3.add(vec3.create(), from3, vec3.scale(vec3.create(), perpendicular, halfWidth)), + vec3.add(vec3.create(), to3, vec3.scale(vec3.create(), perpendicular, halfWidth)) + ]; + const bottomVertices = [ + vec3.sub(vec3.create(), from3, vec3.scale(vec3.create(), perpendicular, halfWidth)), + vec3.sub(vec3.create(), to3, vec3.scale(vec3.create(), perpendicular, halfWidth)) + ]; + // the main tunnel + { + // left wall + positions.push(bottomVertices[0][0], // back left Y (bottom) + 0.0, bottomVertices[0][1], // back left X (bottom) + bottomVertices[0][0], // back left Y (top) + fromElevation, bottomVertices[0][1], // back left X (top) + bottomVertices[1][0], // front left Y (top) + toElevation, bottomVertices[1][1], // front left X (top) + bottomVertices[1][0], // front left Y (bottom) + 0.0, bottomVertices[1][1] // front left X (bottom) + ); + // right wall + positions.push(topVertices[0][0], // back right Y (bottom) + 0.0, topVertices[0][1], // back right X (bottom) + topVertices[0][0], // back right Y (top) + fromElevation, topVertices[0][1], // back right X (top) + topVertices[1][0], // front right Y (top) + toElevation, topVertices[1][1], // front right X (top) + topVertices[1][0], // front right Y (bottom) + 0.0, topVertices[1][1] // front right X (bottom) + ); + // top face + positions.push(topVertices[0][0], // back right Y + topVertices[0][2], topVertices[0][1], // back right X + topVertices[1][0], // top right Y + topVertices[1][2], topVertices[1][1], // top right X + bottomVertices[1][0], // top left Y + bottomVertices[1][2], bottomVertices[1][1], // top left X, + bottomVertices[0][0], // back left Y + bottomVertices[0][2], bottomVertices[0][1] // back left X + ); + // bottom face + positions.push(topVertices[0][0], // back right Y + -0.001, topVertices[0][1], // back right X + topVertices[1][0], // top right Y + -0.001, topVertices[1][1], // top right X + bottomVertices[1][0], // top left Y + -0.001, bottomVertices[1][1], // top left X, + bottomVertices[0][0], // back left Y + -0.001, bottomVertices[0][1] // back left X + ); + faceColors.push(...[ + to.color ?? options.leftWallColor?.map((index) => index / 255) ?? options.wallColor?.map((index) => index / 255) ?? [0, 1, 0, 1], + to.color ?? options.rightWallColor?.map((index) => index / 255) ?? options.wallColor?.map((index) => index / 255) ?? [0, 0, 1, 1], + options.topColor?.map((index) => index / 255) ?? [1, 0, 0, 1], + options.bottomColor?.map((index) => index / 255) ?? [0, 0, 0, 1] // bottom face + ]); + indices.push(...([ + 0, 1, 2, + 0, 2, 3, + 4, 5, 6, + 4, 6, 7, + 8, 9, 10, + 8, 10, 11, + 12, 13, 14, + 12, 14, 15, // bottom + ].map((number) => indexForIndices + number))); + indexForIndices += 16; + } + to.verticles = { + frontRightX: topVertices[1][1], + frontRightY: topVertices[1][0], + frontRightZ: topVertices[1][2], + frontLeftX: bottomVertices[1][1], + frontLeftY: bottomVertices[1][0], + frontLeftZ: bottomVertices[1][2] + }; + // the connecting tunnel + if (from.verticles) { + positions.push( + // left face + from.verticles.frontLeftY, // back left Y (bottom) + 0.0, from.verticles.frontLeftX, // back left X (bottom) + from.verticles.frontLeftY, // back left Y (top) + from.verticles.frontLeftZ, from.verticles.frontLeftX, // back left X (top) + bottomVertices[0][0], // front left Y (top) + bottomVertices[0][2], bottomVertices[0][1], // front left X (top) + bottomVertices[0][0], // front left Y (bottom) + 0.0, bottomVertices[0][1] // front left X (bottom) + ); + positions.push( + // right face + from.verticles.frontRightY, // back right Y (bottom) + 0.0, from.verticles.frontRightX, // back right X (bottom) + from.verticles.frontRightY, // back right Y (top) + from.verticles.frontRightZ, from.verticles.frontRightX, // back right X (top) + topVertices[0][0], // front right Y (top) + topVertices[0][2], topVertices[0][1], // front right X (top) + topVertices[0][0], // front right Y (bottom) + 0.0, topVertices[0][1] // front right X (bottom) + ); + positions.push(from.verticles.frontRightY, // back right Y + from.verticles.frontRightZ, from.verticles.frontRightX, // back right X + topVertices[0][0], // top right Y + topVertices[0][2], topVertices[0][1], // top right X + bottomVertices[0][0], // top left Y + bottomVertices[0][2], bottomVertices[0][1], // top left X, + from.verticles.frontLeftY, // back left Y + from.verticles.frontLeftZ, from.verticles.frontLeftX // back left X + ); + // bottom face + positions.push(from.verticles.frontRightY, // back right Y + -0.001, from.verticles.frontRightX, // back right X + topVertices[0][0], // top right Y + -0.001, topVertices[0][1], // top right X + bottomVertices[0][0], // top left Y + -0.001, bottomVertices[0][1], // top left X, + from.verticles.frontLeftY, // back left Y + -0.001, from.verticles.frontLeftX // back left X + ); + faceColors.push(...[ + to.color ?? options.leftWallColor?.map((index) => index / 255) ?? options.wallColor?.map((index) => index / 255) ?? [0, 1, 0, 1], + to.color ?? options.rightWallColor?.map((index) => index / 255) ?? options.wallColor?.map((index) => index / 255) ?? [0, 0, 1, 1], + options.topColor?.map((index) => index / 255) ?? [1, 0, 0, 1], + options.bottomColor?.map((index) => index / 255) ?? [0, 0, 0, 1] // bottom face + ]); + indices.push(...([ + 0, 1, 2, + 0, 2, 3, + 4, 5, 6, + 4, 6, 7, + 8, 9, 10, + 8, 10, 11, + 12, 13, 14, + 12, 14, 15, // bottom + ].map((number) => indexForIndices + number))); + indexForIndices += 16; + } + if (index === path.points.length - 1) { + // final wall + positions.push( + // left face + topVertices[1][0], // back left Y (bottom) + 0.0, topVertices[1][1], // back left X (bottom) + topVertices[1][0], // back left Y (top) + toElevation, topVertices[1][1], // back left X (top) + bottomVertices[1][0], // front left Y (top) + toElevation, bottomVertices[1][1], // front left X (top) + bottomVertices[1][0], // front left Y (bottom) + 0.0, bottomVertices[1][1] // front left X (bottom) + ); + faceColors.push(...[ + to.color ?? options.endBlockColor?.map((index) => index / 255) ?? options.wallColor?.map((index) => index / 255) ?? [0, 0, 0, 1] + ]); + indices.push(...([ + 0, 1, 2, + 0, 2, 3, // front + ].map((number) => indexForIndices + number))); + indexForIndices += 4; + } + else if (index === 1) { + // initial wall + positions.push( + // left face + bottomVertices[0][0], // back left Y (bottom) + 0.0, bottomVertices[0][1], // back left X (bottom) + bottomVertices[0][0], // back left Y (top) + from.z, bottomVertices[0][1], // back left X (top) + topVertices[0][0], // front left Y (top) + from.z, topVertices[0][1], // front left X (top) + topVertices[0][0], // front left Y (bottom) + 0.0, topVertices[0][1] // front left X (bottom) + ); + faceColors.push(...[ + to.color ?? options.startBlockColor?.map((index) => index / 255) ?? options.wallColor?.map((index) => index / 255) ?? [0, 0, 0, 1] + ]); + indices.push(...([ + 0, 1, 2, + 0, 2, 3, // front + ].map((number) => indexForIndices + number))); + indexForIndices += 4; + } + } + const positionBuffer = this.initPositionBuffer(gl, positions); + const colorBuffer = this.initColorBuffer(gl, faceColors); + const indexBuffer = this.initIndexBuffer(gl, indices); + return { + verticles: positions.length / 2, + position: positionBuffer, + color: colorBuffer, + indices: indexBuffer, + }; + } + static initPositionBuffer(gl, positions) { + // Create a buffer for the square's positions. + const positionBuffer = gl.createBuffer(); + // Select the positionBuffer as the one to apply buffer + // operations to from here out. + gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer); + // Now pass the list of positions into WebGL to build the + // shape. We do this by creating a Float32Array from the + // JavaScript array, then use it to fill the current buffer. + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW); + return positionBuffer; + } + static initColorBuffer(gl, faceColors) { + // Convert the array of colors into a table for all the vertices. + var colors = []; + for (var j = 0; j < faceColors.length; ++j) { + const c = faceColors[j]; + // Repeat each color four times for the four vertices of the face + colors = colors.concat(c, c, c, c); + } + const colorBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(colors), gl.STATIC_DRAW); + return colorBuffer; + } + static initIndexBuffer(gl, indices) { + const indexBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); + // This array defines each face as two triangles, using the + // indices into the vertex array to specify each triangle's + // position. + // Now send the element array to GL + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), gl.STATIC_DRAW); + return indexBuffer; + } +} +; +//# sourceMappingURL=path.js.map \ No newline at end of file diff --git a/dist/modules/renderer/buffers/path.js.map b/dist/modules/renderer/buffers/path.js.map new file mode 100644 index 0000000..7e5aa3d --- /dev/null +++ b/dist/modules/renderer/buffers/path.js.map @@ -0,0 +1 @@ +{"version":3,"file":"path.js","sourceRoot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AAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;SACtC;QAED,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC;QACtC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;QAC5C,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,YAAY,EAAE,IAAI,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC;QAEzE,OAAO,WAAW,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,EAAyB,EAAE,OAAiB;QAC/D,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC;QACtC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC;QAEpD,2DAA2D;QAC3D,2DAA2D;QAC3D,YAAY;QAEZ,mCAAmC;QAEnC,EAAE,CAAC,UAAU,CACT,EAAE,CAAC,oBAAoB,EACvB,IAAI,WAAW,CAAC,OAAO,CAAC,EACxB,EAAE,CAAC,WAAW,CACjB,CAAC;QAEF,OAAO,WAAW,CAAC;IACvB,CAAC;CACJ;AAAA,CAAC"} \ No newline at end of file diff --git a/dist/modules/renderer/models/grid.d.ts b/dist/modules/renderer/models/grid.d.ts new file mode 100644 index 0000000..3905c6a --- /dev/null +++ b/dist/modules/renderer/models/grid.d.ts @@ -0,0 +1,11 @@ +import { RendererOptions } from "../../renderer.js"; +import { AnimationFrame } from "../animation.js"; +export declare class RendererGridModel { + static createBuffers(gl: WebGLRenderingContext, options: RendererOptions, animationFrame: AnimationFrame, paths: any[]): { + verticles: number; + position: WebGLBuffer | null; + color: WebGLBuffer | null; + indices: WebGLBuffer | null; + }; +} +//# sourceMappingURL=grid.d.ts.map \ No newline at end of file diff --git a/dist/modules/renderer/models/grid.d.ts.map b/dist/modules/renderer/models/grid.d.ts.map new file mode 100644 index 0000000..0e100e6 --- /dev/null +++ b/dist/modules/renderer/models/grid.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../../src/modules/renderer/models/grid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,qBAAa,iBAAiB;IAC1B,MAAM,CAAC,aAAa,CAAC,EAAE,EAAE,qBAAqB,EAAE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,EAAE;;;;;;CA6DzH"} \ No newline at end of file diff --git a/dist/modules/renderer/models/grid.js b/dist/modules/renderer/models/grid.js new file mode 100644 index 0000000..13552e4 --- /dev/null +++ b/dist/modules/renderer/models/grid.js @@ -0,0 +1,54 @@ +import { RendererBuffers } from "../buffers.js"; +export class RendererGridModel { + static createBuffers(gl, options, animationFrame, paths) { + let minX = NaN; + let maxX = NaN; + let minY = NaN; + let maxY = NaN; + for (let path of paths) + for (let point of path.points) { + if (window.isNaN(minX) || point.x < minX) + minX = point.x; + if (window.isNaN(maxX) || point.x > maxX) + maxX = point.x; + if (window.isNaN(minY) || point.y < minY) + minY = point.y; + if (window.isNaN(maxY) || point.y > maxY) + maxY = point.y; + } + const padding = options.gridPadding ?? 1; + const positions = [ + minY - padding, + -0.002, + maxX + padding, + maxY + padding, + -0.002, + maxX + padding, + maxY + padding, + -0.002, + minX - padding, + minY - padding, + -0.002, + minX - padding // back left X + ]; + const faceColors = [ + options.gridColor?.map((index) => index / 255) ?? [.5, 0, 0, 1] + ]; + const indices = [ + 0, 1, 2, + 0, 2, 3, // bottom + ]; + const positionBuffer = RendererBuffers.initPositionBuffer(gl, positions); + const colorBuffer = RendererBuffers.initColorBuffer(gl, faceColors); + const indexBuffer = RendererBuffers.initIndexBuffer(gl, indices); + return { + verticles: positions.length / 2, + position: positionBuffer, + color: colorBuffer, + indices: indexBuffer, + }; + } + ; +} +; +//# sourceMappingURL=grid.js.map \ No newline at end of file diff --git a/dist/modules/renderer/models/grid.js.map b/dist/modules/renderer/models/grid.js.map new file mode 100644 index 0000000..ae36e18 --- /dev/null +++ b/dist/modules/renderer/models/grid.js.map @@ -0,0 +1 @@ +{"version":3,"file":"grid.js","sourceRoot":"","sources":["../../../../src/modules/renderer/models/grid.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,OAAO,iBAAiB;IAC1B,MAAM,CAAC,aAAa,CAAC,EAAyB,EAAE,OAAwB,EAAE,cAA8B,EAAE,KAAY;QAClH,IAAI,IAAI,GAAG,GAAG,CAAC;QACf,IAAI,IAAI,GAAG,GAAG,CAAC;QACf,IAAI,IAAI,GAAG,GAAG,CAAC;QACf,IAAI,IAAI,GAAG,GAAG,CAAC;QAEf,KAAI,IAAI,IAAI,IAAI,KAAK;YACrB,KAAI,IAAI,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;gBAC1B,IAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,IAAI;oBACnC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC;gBAEnB,IAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,IAAI;oBACnC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC;gBAEnB,IAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,IAAI;oBACnC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC;gBAEnB,IAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,IAAI;oBACnC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC;aACtB;QAED,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,CAAC;QAEzC,MAAM,SAAS,GAAa;YACxB,IAAI,GAAG,OAAO;YACd,CAAC,KAAK;YACN,IAAI,GAAG,OAAO;YAEd,IAAI,GAAG,OAAO;YACd,CAAC,KAAK;YACN,IAAI,GAAG,OAAO;YAEd,IAAI,GAAG,OAAO;YACd,CAAC,KAAK;YACN,IAAI,GAAG,OAAO;YAEd,IAAI,GAAG,OAAO;YACd,CAAC,KAAK;YACN,IAAI,GAAG,OAAO,CAAC,cAAc;SAChC,CAAC;QAEF,MAAM,UAAU,GAAe;YAC3B,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,CAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAE;SACpE,CAAC;QAEF,MAAM,OAAO,GAAa;YACtB,CAAC,EAAE,CAAC,EAAE,CAAC;YACP,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,SAAS;SACrB,CAAC;QAEF,MAAM,cAAc,GAAG,eAAe,CAAC,kBAAkB,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;QACzE,MAAM,WAAW,GAAG,eAAe,CAAC,eAAe,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;QACpE,MAAM,WAAW,GAAG,eAAe,CAAC,eAAe,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAEjE,OAAO;YACH,SAAS,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC;YAC/B,QAAQ,EAAE,cAAc;YACxB,KAAK,EAAE,WAAW;YAClB,OAAO,EAAE,WAAW;SACvB,CAAC;IACN,CAAC;IAAA,CAAC;CACL;AAAA,CAAC"} \ No newline at end of file diff --git a/dist/modules/renderer/models/path.d.ts b/dist/modules/renderer/models/path.d.ts new file mode 100644 index 0000000..ae09395 --- /dev/null +++ b/dist/modules/renderer/models/path.d.ts @@ -0,0 +1,11 @@ +import { RendererOptions } from "../../renderer.js"; +import { AnimationFrame } from "../animation.js"; +export declare class RendererPathModel { + static createBuffers(gl: WebGLRenderingContext, path: any, options: RendererOptions, animationFrame: AnimationFrame): { + verticles: number; + position: WebGLBuffer | null; + color: WebGLBuffer | null; + indices: WebGLBuffer | null; + }; +} +//# sourceMappingURL=path.d.ts.map \ No newline at end of file diff --git a/dist/modules/renderer/models/path.d.ts.map b/dist/modules/renderer/models/path.d.ts.map new file mode 100644 index 0000000..85db145 --- /dev/null +++ b/dist/modules/renderer/models/path.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../../src/modules/renderer/models/path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAKjD,qBAAa,iBAAiB;IAC1B,MAAM,CAAC,aAAa,CAAC,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc;;;;;;CAkWtH"} \ No newline at end of file diff --git a/dist/modules/renderer/models/path.js b/dist/modules/renderer/models/path.js new file mode 100644 index 0000000..1d23033 --- /dev/null +++ b/dist/modules/renderer/models/path.js @@ -0,0 +1,230 @@ +import { RendererBuffers } from "../buffers.js"; +export class RendererPathModel { + static createBuffers(gl, path, options, animationFrame) { + const positions = []; + const faceColors = []; + const indices = []; + let indexForIndices = 0; + let distance = 0; + const breakingPoint = path.fullDistance * animationFrame.distanceFraction; + for (let index = 1; index < path.points.length; index++) { + const from = path.points[index - 1]; + const to = path.points[index]; + const fromElevation = from.z * animationFrame.elevationFraction; + const toElevation = to.z * animationFrame.elevationFraction; + let pointFraction = 1.0; + distance = to.distanceStart; + const leftWallColor = to.color ?? (options.leftWallColor ?? options.wallColor)?.map((index) => index / 255) ?? [0, 1, 0, 1]; + const rightWallColor = to.color ?? (options.rightWallColor ?? options.wallColor)?.map((index) => index / 255) ?? [0, 0, 1, 1]; + const topColor = options.topColor?.map((index) => index / 255) ?? [1, 0, 0, 1]; + const bottomColor = options.bottomColor?.map((index) => index / 255) ?? [0, 0, 0, 1]; + const endBlockColor = to.color ?? (options.endBlockColor ?? options.wallColor)?.map((index) => index / 255) ?? [0, 0, 0, 1]; + const startBlockColor = to.color ?? (options.startBlockColor ?? options.wallColor)?.map((index) => index / 255) ?? [0, 0, 0, 1]; + if (distance > breakingPoint) + break; + if (breakingPoint < (distance + to.distance)) + pointFraction = Math.max(0, Math.min((breakingPoint - to.distanceStart) / to.distance, 1)); + const difference = { + x: (to.x - from.x), + y: (to.y - from.y) + }; + const from3 = vec3.fromValues(from.y, from.x, fromElevation); + const to3 = vec3.fromValues(from.y + (difference.y * pointFraction), from.x + (difference.x * pointFraction), toElevation); + const direction = vec3.sub(vec3.create(), to3, from3); + const perpendicular = vec3.normalize(vec3.create(), [-direction[1], direction[0], 0]); + const halfWidth = (options.wallWidth ?? .1) / 2; + const topVertices = [ + vec3.add(vec3.create(), from3, vec3.scale(vec3.create(), perpendicular, halfWidth)), + vec3.add(vec3.create(), to3, vec3.scale(vec3.create(), perpendicular, halfWidth)) + ]; + const bottomVertices = [ + vec3.sub(vec3.create(), from3, vec3.scale(vec3.create(), perpendicular, halfWidth)), + vec3.sub(vec3.create(), to3, vec3.scale(vec3.create(), perpendicular, halfWidth)) + ]; + // the main tunnel + { + // left wall + positions.push(bottomVertices[0][0], // back left Y (bottom) + 0.0, bottomVertices[0][1], // back left X (bottom) + bottomVertices[0][0], // back left Y (top) + fromElevation, bottomVertices[0][1], // back left X (top) + bottomVertices[1][0], // front left Y (top) + toElevation, bottomVertices[1][1], // front left X (top) + bottomVertices[1][0], // front left Y (bottom) + 0.0, bottomVertices[1][1] // front left X (bottom) + ); + // right wall + positions.push(topVertices[0][0], // back right Y (bottom) + 0.0, topVertices[0][1], // back right X (bottom) + topVertices[0][0], // back right Y (top) + fromElevation, topVertices[0][1], // back right X (top) + topVertices[1][0], // front right Y (top) + toElevation, topVertices[1][1], // front right X (top) + topVertices[1][0], // front right Y (bottom) + 0.0, topVertices[1][1] // front right X (bottom) + ); + // top face + positions.push(topVertices[0][0], // back right Y + topVertices[0][2], topVertices[0][1], // back right X + topVertices[1][0], // top right Y + topVertices[1][2], topVertices[1][1], // top right X + bottomVertices[1][0], // top left Y + bottomVertices[1][2], bottomVertices[1][1], // top left X, + bottomVertices[0][0], // back left Y + bottomVertices[0][2], bottomVertices[0][1] // back left X + ); + // bottom face + positions.push(topVertices[0][0], // back right Y + -0.001, topVertices[0][1], // back right X + topVertices[1][0], // top right Y + -0.001, topVertices[1][1], // top right X + bottomVertices[1][0], // top left Y + -0.001, bottomVertices[1][1], // top left X, + bottomVertices[0][0], // back left Y + -0.001, bottomVertices[0][1] // back left X + ); + faceColors.push(...[ + leftWallColor, + rightWallColor, + topColor, + bottomColor // bottom face + ]); + indices.push(...([ + 0, 1, 2, + 0, 2, 3, + 4, 5, 6, + 4, 6, 7, + 8, 9, 10, + 8, 10, 11, + 12, 13, 14, + 12, 14, 15, // bottom + ].map((number) => indexForIndices + number))); + indexForIndices += 16; + } + to.verticles = { + frontRightX: topVertices[1][1], + frontRightY: topVertices[1][0], + frontRightZ: topVertices[1][2], + frontLeftX: bottomVertices[1][1], + frontLeftY: bottomVertices[1][0], + frontLeftZ: bottomVertices[1][2] + }; + // the connecting tunnel + if (from.verticles) { + positions.push( + // left face + from.verticles.frontLeftY, // back left Y (bottom) + 0.0, from.verticles.frontLeftX, // back left X (bottom) + from.verticles.frontLeftY, // back left Y (top) + from.verticles.frontLeftZ, from.verticles.frontLeftX, // back left X (top) + bottomVertices[0][0], // front left Y (top) + bottomVertices[0][2], bottomVertices[0][1], // front left X (top) + bottomVertices[0][0], // front left Y (bottom) + 0.0, bottomVertices[0][1] // front left X (bottom) + ); + positions.push( + // right face + from.verticles.frontRightY, // back right Y (bottom) + 0.0, from.verticles.frontRightX, // back right X (bottom) + from.verticles.frontRightY, // back right Y (top) + from.verticles.frontRightZ, from.verticles.frontRightX, // back right X (top) + topVertices[0][0], // front right Y (top) + topVertices[0][2], topVertices[0][1], // front right X (top) + topVertices[0][0], // front right Y (bottom) + 0.0, topVertices[0][1] // front right X (bottom) + ); + positions.push(from.verticles.frontRightY, // back right Y + from.verticles.frontRightZ, from.verticles.frontRightX, // back right X + topVertices[0][0], // top right Y + topVertices[0][2], topVertices[0][1], // top right X + bottomVertices[0][0], // top left Y + bottomVertices[0][2], bottomVertices[0][1], // top left X, + from.verticles.frontLeftY, // back left Y + from.verticles.frontLeftZ, from.verticles.frontLeftX // back left X + ); + // bottom face + positions.push(from.verticles.frontRightY, // back right Y + -0.001, from.verticles.frontRightX, // back right X + topVertices[0][0], // top right Y + -0.001, topVertices[0][1], // top right X + bottomVertices[0][0], // top left Y + -0.001, bottomVertices[0][1], // top left X, + from.verticles.frontLeftY, // back left Y + -0.001, from.verticles.frontLeftX // back left X + ); + faceColors.push(...[ + leftWallColor, + rightWallColor, + topColor, + bottomColor // bottom face + ]); + indices.push(...([ + 0, 1, 2, + 0, 2, 3, + 4, 5, 6, + 4, 6, 7, + 8, 9, 10, + 8, 10, 11, + 12, 13, 14, + 12, 14, 15, // bottom + ].map((number) => indexForIndices + number))); + indexForIndices += 16; + } + if (index === path.points.length - 1) { + // final wall + positions.push( + // left face + topVertices[1][0], // back left Y (bottom) + 0.0, topVertices[1][1], // back left X (bottom) + topVertices[1][0], // back left Y (top) + toElevation, topVertices[1][1], // back left X (top) + bottomVertices[1][0], // front left Y (top) + toElevation, bottomVertices[1][1], // front left X (top) + bottomVertices[1][0], // front left Y (bottom) + 0.0, bottomVertices[1][1] // front left X (bottom) + ); + faceColors.push(...[ + endBlockColor + ]); + indices.push(...([ + 0, 1, 2, + 0, 2, 3, // front + ].map((number) => indexForIndices + number))); + indexForIndices += 4; + } + else if (index === 1) { + // initial wall + positions.push( + // left face + bottomVertices[0][0], // back left Y (bottom) + 0.0, bottomVertices[0][1], // back left X (bottom) + bottomVertices[0][0], // back left Y (top) + from.z, bottomVertices[0][1], // back left X (top) + topVertices[0][0], // front left Y (top) + from.z, topVertices[0][1], // front left X (top) + topVertices[0][0], // front left Y (bottom) + 0.0, topVertices[0][1] // front left X (bottom) + ); + faceColors.push(...[ + startBlockColor + ]); + indices.push(...([ + 0, 1, 2, + 0, 2, 3, // front + ].map((number) => indexForIndices + number))); + indexForIndices += 4; + } + } + const positionBuffer = RendererBuffers.initPositionBuffer(gl, positions); + const colorBuffer = RendererBuffers.initColorBuffer(gl, faceColors); + const indexBuffer = RendererBuffers.initIndexBuffer(gl, indices); + return { + verticles: positions.length / 2, + position: positionBuffer, + color: colorBuffer, + indices: indexBuffer, + }; + } +} +; +//# sourceMappingURL=path.js.map \ No newline at end of file diff --git a/dist/modules/renderer/models/path.js.map b/dist/modules/renderer/models/path.js.map new file mode 100644 index 0000000..159ff3f --- /dev/null +++ b/dist/modules/renderer/models/path.js.map @@ -0,0 +1 @@ +{"version":3,"file":"path.js","sourceRoot":"","sources":["../../../../src/modules/renderer/models/path.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAIhD,MAAM,OAAO,iBAAiB;IAC1B,MAAM,CAAC,aAAa,CAAC,EAAyB,EAAE,IAAS,EAAE,OAAwB,EAAE,cAA8B;QAC/G,MAAM,SAAS,GAAG,EAAE,CAAC;QACrB,MAAM,UAAU,GAAG,EAAE,CAAC;QACtB,MAAM,OAAO,GAAG,EAAE,CAAC;QAEnB,IAAI,eAAe,GAAG,CAAC,CAAC;QAExB,IAAI,QAAQ,GAAG,CAAC,CAAC;QAEjB,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,GAAG,cAAc,CAAC,gBAAgB,CAAC;QAE1E,KAAI,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YACpD,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;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AAC,CAAC;QAEzE,MAAM,WAAW,GAAG,eAAe,CAAC,eAAe,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;QAEpE,MAAM,WAAW,GAAG,eAAe,CAAC,eAAe,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAEjE,OAAO;YACH,SAAS,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC;YAC/B,QAAQ,EAAE,cAAc;YACxB,KAAK,EAAE,WAAW;YAClB,OAAO,EAAE,WAAW;SACvB,CAAC;IACN,CAAC;CACJ;AAAA,CAAC"} \ No newline at end of file diff --git a/dist/modules/renderer/scene.d.ts b/dist/modules/renderer/scene.d.ts new file mode 100644 index 0000000..3c72ea4 --- /dev/null +++ b/dist/modules/renderer/scene.d.ts @@ -0,0 +1,7 @@ +import { RendererOptions } from "../renderer.js"; +export declare class RendererScene { + static drawScene(gl: WebGLRenderingContext, programInfo: any, bufferers: any, options: RendererOptions, deltas: any): void; + static setPositionAttribute(gl: WebGLRenderingContext, buffers: any, programInfo: any): void; + static setColorAttribute(gl: WebGLRenderingContext, buffers: any, programInfo: any): void; +} +//# sourceMappingURL=scene.d.ts.map \ No newline at end of file diff --git a/dist/modules/renderer/scene.d.ts.map b/dist/modules/renderer/scene.d.ts.map new file mode 100644 index 0000000..40aeaa3 --- /dev/null +++ b/dist/modules/renderer/scene.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"scene.d.ts","sourceRoot":"","sources":["../../../src/modules/renderer/scene.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAIjD,qBAAa,aAAa;IACtB,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,qBAAqB,EAAE,WAAW,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG;IA8FnH,MAAM,CAAC,oBAAoB,CAAC,EAAE,EAAE,qBAAqB,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG;IAmBrF,MAAM,CAAC,iBAAiB,CAAC,EAAE,EAAE,qBAAqB,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG;CAiBrF"} \ No newline at end of file diff --git a/dist/modules/renderer/scene.js b/dist/modules/renderer/scene.js new file mode 100644 index 0000000..3f3beca --- /dev/null +++ b/dist/modules/renderer/scene.js @@ -0,0 +1,79 @@ +export class RendererScene { + static drawScene(gl, programInfo, bufferers, options, deltas) { + gl.clearColor(0.0, 0.0, 0.0, 0.0); // Clear to black, fully opaque + gl.clearDepth(1.0); // Clear everything + gl.enable(gl.DEPTH_TEST); // Enable depth testing + gl.depthFunc(gl.LEQUAL); // Near things obscure far things + // Clear the canvas before we start drawing on it. + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); + // Create a perspective matrix, a special matrix that is + // used to simulate the distortion of perspective in a camera. + // Our field of view is 45 degrees, with a width/height + // ratio that matches the display size of the canvas + // and we only want to see objects between 0.1 units + // and 100 units away from the camera. + const fieldOfView = ((options.cameraFov ?? 45) * Math.PI) / 180; // in radians + const aspect = gl.canvas.clientWidth / gl.canvas.clientHeight; + const zNear = 0.1; + const zFar = 10000.0; + const projectionMatrix = mat4.create(); + // note: glmatrix.js always has the first argument + // as the destination to receive the result. + mat4.perspective(projectionMatrix, fieldOfView, aspect, zNear, zFar); + // Set the drawing position to the "identity" point, which is + // the center of the scene. + const modelViewMatrix = mat4.create(); + // Now move the drawing position a bit to where we want to + // start drawing the square. + mat4.translate(modelViewMatrix, // destination matrix + modelViewMatrix, // matrix to translate + options.cameraTranslation ?? [0.0, 0.0, -25.0]); + mat4.rotate(modelViewMatrix, modelViewMatrix, (options.cameraRotation?.[1] ?? 0) + (deltas.y * 0.01), [1, 0, 0]); + mat4.rotate(modelViewMatrix, modelViewMatrix, (options.cameraRotation?.[0] ?? 0) + (deltas.x * 0.01), [0, 1, 0]); + mat4.rotate(modelViewMatrix, modelViewMatrix, (options.cameraRotation?.[2] ?? 0), [0, 0, 1]); + for (let buffers of bufferers) { + // Tell WebGL how to pull out the positions from the position + // buffer into the vertexPosition attribute. + this.setPositionAttribute(gl, buffers, programInfo); + this.setColorAttribute(gl, buffers, programInfo); + // Tell WebGL which indices to use to index the vertices + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffers.indices); + // Tell WebGL to use our program when drawing + gl.useProgram(programInfo.program); + // Set the shader uniforms + gl.uniformMatrix4fv(programInfo.uniformLocations.projectionMatrix, false, projectionMatrix); + gl.uniformMatrix4fv(programInfo.uniformLocations.modelViewMatrix, false, modelViewMatrix); + { + const vertexCount = buffers.verticles; + const type = gl.UNSIGNED_SHORT; + const offset = 0; + gl.drawElements(gl.TRIANGLES, vertexCount, type, offset); + } + } + } + ; + static setPositionAttribute(gl, buffers, programInfo) { + const numComponents = 3; + const type = gl.FLOAT; // the data in the buffer is 32bit floats + const normalize = false; // don't normalize + const stride = 0; // how many bytes to get from one set of values to the next + // 0 = use type and numComponents above + const offset = 0; // how many bytes inside the buffer to start from + gl.bindBuffer(gl.ARRAY_BUFFER, buffers.position); + gl.vertexAttribPointer(programInfo.attribLocations.vertexPosition, numComponents, type, normalize, stride, offset); + gl.enableVertexAttribArray(programInfo.attribLocations.vertexPosition); + } + ; + static setColorAttribute(gl, buffers, programInfo) { + const numComponents = 4; + const type = gl.FLOAT; + const normalize = false; + const stride = 0; + const offset = 0; + gl.bindBuffer(gl.ARRAY_BUFFER, buffers.color); + gl.vertexAttribPointer(programInfo.attribLocations.vertexColor, numComponents, type, normalize, stride, offset); + gl.enableVertexAttribArray(programInfo.attribLocations.vertexColor); + } +} +; +//# sourceMappingURL=scene.js.map \ No newline at end of file diff --git a/dist/modules/renderer/scene.js.map b/dist/modules/renderer/scene.js.map new file mode 100644 index 0000000..58def59 --- /dev/null +++ b/dist/modules/renderer/scene.js.map @@ -0,0 +1 @@ +{"version":3,"file":"scene.js","sourceRoot":"","sources":["../../../src/modules/renderer/scene.ts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AM,IAAI,GAAG,EAAE,CAAC,KAAK,CAAC;QACtB,MAAM,SAAS,GAAG,KAAK,CAAC;QACxB,MAAM,MAAM,GAAG,CAAC,CAAC;QACjB,MAAM,MAAM,GAAG,CAAC,CAAC;QACjB,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,YAAY,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9C,EAAE,CAAC,mBAAmB,CAClB,WAAW,CAAC,eAAe,CAAC,WAAW,EACvC,aAAa,EACb,IAAI,EACJ,SAAS,EACT,MAAM,EACN,MAAM,CACT,CAAC;QACF,EAAE,CAAC,uBAAuB,CAAC,WAAW,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;IACxE,CAAC;CACJ;AAAA,CAAC"} \ No newline at end of file diff --git a/dist/modules/renderer/webgl.d.ts b/dist/modules/renderer/webgl.d.ts new file mode 100644 index 0000000..f2e47a7 --- /dev/null +++ b/dist/modules/renderer/webgl.d.ts @@ -0,0 +1,16 @@ +export declare class RendererWebGL { + static initializeProgram(context: WebGLRenderingContext): { + program: WebGLProgram; + attribLocations: { + vertexPosition: number; + vertexColor: number; + }; + uniformLocations: { + projectionMatrix: WebGLUniformLocation | null; + modelViewMatrix: WebGLUniformLocation | null; + }; + }; + static initShaderProgram(gl: WebGLRenderingContext, vsSource: any, fsSource: any): WebGLProgram | null; + static loadShader(gl: WebGLRenderingContext, type: any, source: any): WebGLShader | null; +} +//# sourceMappingURL=webgl.d.ts.map \ No newline at end of file diff --git a/dist/modules/renderer/webgl.d.ts.map b/dist/modules/renderer/webgl.d.ts.map new file mode 100644 index 0000000..c7a74ca --- /dev/null +++ b/dist/modules/renderer/webgl.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"webgl.d.ts","sourceRoot":"","sources":["../../../src/modules/renderer/webgl.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAa;IACtB,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,qBAAqB;;;;;;;;;;;IAqDvD,MAAM,CAAC,iBAAiB,CAAC,EAAE,EAAE,qBAAqB,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG;IAoChF,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG;CA0BtE"} \ No newline at end of file diff --git a/dist/modules/renderer/webgl.js b/dist/modules/renderer/webgl.js new file mode 100644 index 0000000..8a1c2eb --- /dev/null +++ b/dist/modules/renderer/webgl.js @@ -0,0 +1,87 @@ +export class RendererWebGL { + static initializeProgram(context) { + // Vertex shader program + const vsSource = ` + attribute vec4 aVertexPosition; + attribute vec4 aVertexColor; + + uniform mat4 uModelViewMatrix; + uniform mat4 uProjectionMatrix; + + varying lowp vec4 vColor; + + void main(void) { + gl_Position = uProjectionMatrix * uModelViewMatrix * aVertexPosition; + vColor = aVertexColor; + } + `; + // Fragment shader program + const fsSource = ` + varying lowp vec4 vColor; + + void main(void) { + gl_FragColor = vColor; + } + `; + // Initialize a shader program; this is where all the lighting + // for the vertices and so forth is established. + const shaderProgram = RendererWebGL.initShaderProgram(context, vsSource, fsSource); + if (!shaderProgram) + throw new Error("shader program"); + // Collect all the info needed to use the shader program. + // Look up which attributes our shader program is using + // for aVertexPosition, aVertexColor and also + // look up uniform locations. + return { + program: shaderProgram, + attribLocations: { + vertexPosition: context.getAttribLocation(shaderProgram, "aVertexPosition"), + vertexColor: context.getAttribLocation(shaderProgram, "aVertexColor"), + }, + uniformLocations: { + projectionMatrix: context.getUniformLocation(shaderProgram, "uProjectionMatrix"), + modelViewMatrix: context.getUniformLocation(shaderProgram, "uModelViewMatrix"), + }, + }; + } + ; + static initShaderProgram(gl, vsSource, fsSource) { + const vertexShader = this.loadShader(gl, gl.VERTEX_SHADER, vsSource); + if (!vertexShader) + throw new Error("vertex shader"); + const fragmentShader = this.loadShader(gl, gl.FRAGMENT_SHADER, fsSource); + if (!fragmentShader) + throw new Error("fragment shader"); + // Create the shader program + const shaderProgram = gl.createProgram(); + if (!shaderProgram) + throw new Error("shader program"); + gl.attachShader(shaderProgram, vertexShader); + gl.attachShader(shaderProgram, fragmentShader); + gl.linkProgram(shaderProgram); + // If creating the shader program failed, alert + if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) { + alert(`Unable to initialize the shader program: ${gl.getProgramInfoLog(shaderProgram)}`); + return null; + } + return shaderProgram; + } + static loadShader(gl, type, source) { + const shader = gl.createShader(type); + if (!shader) + throw new Error("shader"); + // Send the source to the shader object + gl.shaderSource(shader, source); + // Compile the shader program + gl.compileShader(shader); + // See if it compiled successfully + if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { + alert(`An error occurred compiling the shaders: ${gl.getShaderInfoLog(shader)}`); + gl.deleteShader(shader); + return null; + } + return shader; + } +} +; +//# sourceMappingURL=webgl.js.map \ No newline at end of file diff --git a/dist/modules/renderer/webgl.js.map b/dist/modules/renderer/webgl.js.map new file mode 100644 index 0000000..f578af3 --- /dev/null +++ b/dist/modules/renderer/webgl.js.map @@ -0,0 +1 @@ +{"version":3,"file":"webgl.js","sourceRoot":"","sources":["../../../src/modules/renderer/webgl.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,aAAa;IACtB,MAAM,CAAC,iBAAiB,CAAC,OAA8B;QACnD,wBAAwB;QACxB,MAAM,QAAQ,GAAG;;;;;;;;;;;;;SAahB,CAAC;QAEF,0BAA0B;QAC1B,MAAM,QAAQ,GAAG;;;;;;SAMhB,CAAC;QAEF,8DAA8D;QAC9D,gDAAgD;QAChD,MAAM,aAAa,GAAG,aAAa,CAAC,iBAAiB,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAEnF,IAAG,CAAC,aAAa;YACb,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAEtC,yDAAyD;QACzD,uDAAuD;QACvD,6CAA6C;QAC7C,6BAA6B;QAC7B,OAAO;YACH,OAAO,EAAE,aAAa;YACtB,eAAe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