diff --git a/client/index.js b/client/index.js index 6282f7d..250869f 100644 --- a/client/index.js +++ b/client/index.js @@ -1,4 +1,6 @@ -// NEXT: pan with m3, place dot, cursor size and color, YELLOW and gray +// NEXT: pan with m3, place dot, cursor size and color, YELLOW and gray, show user cursor, background styles, +// view desks, undo, eraser, ruler, images (movable), quadtree for clipping, f5 without redownload, progress bar +// document.addEventListener('DOMContentLoaded', main); @@ -6,16 +8,16 @@ const config = { // ws_url: 'wss://desk.some.website/ws/', // ping_url: 'https://desk.some.website/api/ping', // image_url: 'https://desk.some.website/images/', - ws_url: 'wss://192.168.100.2/ws/', - ping_url: 'https://192.168.100.2/api/ping', - image_url: 'https://192.168.100.2/images/', + ws_url: 'wss://localhost/ws/', + ping_url: 'https://localhost/api/ping', + image_url: 'https://localhost/images/', sync_timeout: 1000, ws_reconnect_timeout: 2000, brush_preview_timeout: 1000, second_finger_timeout: 500, buffer_first_touchmoves: 5, debug_print: true, - min_zoom: 0.05, + min_zoom: 0.0000005, max_zoom: 10.0, initial_offline_timeout: 1000, default_color: 0x00, @@ -25,7 +27,7 @@ const config = { initial_dynamic_bytes: 4096, frametime_window_size: 100, tile_size: 16, - clip_zoom_threshold: 0.3, + clip_zoom_threshold: 0.1, }; const EVENT = Object.freeze({ diff --git a/client/webgl_draw.js b/client/webgl_draw.js index a6eaba2..9679194 100644 --- a/client/webgl_draw.js +++ b/client/webgl_draw.js @@ -57,7 +57,7 @@ function draw(state, context) { gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); let index_count; - const do_clip = (state.canvas.zoom > config.clip_zoom_threshold); + const do_clip = false; //(state.canvas.zoom > config.clip_zoom_threshold); if (do_clip) { context.need_index_upload = true; diff --git a/server/milton.js b/server/milton.js new file mode 100644 index 0000000..6b1e6b3 --- /dev/null +++ b/server/milton.js @@ -0,0 +1,68 @@ +import * as storage from './storage.js' +import * as math from './math.js' + +import { SESSION, MESSAGE, EVENT } from './enums'; + +let first_point_x = null; +let first_point_y = null; + +function parse_and_insert_stroke(desk_id, line) { + const stroke_id = math.fast_random32(); + const points = new Float32Array(line.split(' ').filter(s => s.length > 0).map(i => parseFloat(i))); + + if (first_point_x === null) { + first_point_x = 1; + first_point_y = 1; + } else if (first_point_x === 1) { + first_point_x = points[0]; + first_point_y = points[1]; + } + + for (let i = 0; i < points.length; i += 2) { + points[i + 0] -= first_point_x; + points[i + 1] -= first_point_y; + } + + storage.queries.insert_stroke.run({ + '$id': stroke_id, + '$width': 8, // possibly handle pressure here if we ever support it + '$color': 0, + '$points': points + }); + + storage.queries.insert_event.run({ + '$type': EVENT.STROKE, + '$desk_id': desk_id, + '$session_id': 0, + '$stroke_id': stroke_id, + '$image_id': 0, + '$x': 0, + '$y': 0, + }); +} + +async function import_milton_file_to_sqlite(fullpath) { + storage.startup(); + + const desk_id = 542; // math.fast_random32(); + + console.log(`Importing ${fullpath} into desk ${desk_id}`); + + storage.queries.insert_desk.run({ + '$id': desk_id, + '$title': `Desk ${desk_id}` + }); + + const input_file = Bun.file(fullpath); + const input_text = await input_file.text(); + const input_lines = input_text.split('\n'); + + for (let i = 0; i < input_lines.length; ++i) { + console.log(`Importing ${i}/${input_lines.length}`); + parse_and_insert_stroke(desk_id, input_lines[i]); + } + + consoe.log(`Finished importing desk ${desk_id}`); +} + +import_milton_file_to_sqlite("/home/aolo2/desk2/server/points.txt"); diff --git a/server/send.js b/server/send.js index cc5d3ef..829a600 100644 --- a/server/send.js +++ b/server/send.js @@ -52,6 +52,7 @@ function event_size(event) { } default: { + console.error(event.desk_id); console.error('fuck'); console.trace(); process.exit(1); @@ -245,4 +246,4 @@ export function sync_desk(desk_id) { sync_session(sid); } } -} \ No newline at end of file +} diff --git a/server/storage.js b/server/storage.js index 14086ac..23fa0da 100644 --- a/server/storage.js +++ b/server/storage.js @@ -126,4 +126,4 @@ export function startup() { session.ws = null; sessions[session.id] = session; } -} \ No newline at end of file +}