|
|
|
@ -141,24 +141,21 @@ function recompute_dynamic_data(state, context) {
@@ -141,24 +141,21 @@ function recompute_dynamic_data(state, context) {
|
|
|
|
|
context.dynamic_positions_f32 = new Float32Array(total_dynamic_length); |
|
|
|
|
context.dynamic_colors_u8 = new Uint8Array(total_dynamic_length / 2 * 3); |
|
|
|
|
|
|
|
|
|
// TODO: preview stroke colors for other users
|
|
|
|
|
context.dynamic_colors_u8.fill(0); |
|
|
|
|
|
|
|
|
|
let at = 0; |
|
|
|
|
|
|
|
|
|
for (const player_id in context.dynamic_positions) { |
|
|
|
|
context.dynamic_positions_f32.set(context.dynamic_positions[player_id], at); |
|
|
|
|
|
|
|
|
|
const color_u32 = state.players[player_id].color; |
|
|
|
|
|
|
|
|
|
if (parseInt(player_id) === state.me) { |
|
|
|
|
const color_u32 = state.colors.active; |
|
|
|
|
const r = (color_u32 >> 16) & 0xFF; |
|
|
|
|
const g = (color_u32 >> 8) & 0xFF; |
|
|
|
|
const b = color_u32 & 0xFF; |
|
|
|
|
for (let i = 0; i < context.dynamic_positions[player_id].length; ++i) { |
|
|
|
|
context.dynamic_colors_u8[at / 2 * 3 + i * 3 + 0] = r; |
|
|
|
|
context.dynamic_colors_u8[at / 2 * 3 + i * 3 + 1] = g; |
|
|
|
|
context.dynamic_colors_u8[at / 2 * 3 + i * 3 + 2] = b; |
|
|
|
|
} |
|
|
|
|
const r = (color_u32 >> 16) & 0xFF; |
|
|
|
|
const g = (color_u32 >> 8) & 0xFF; |
|
|
|
|
const b = color_u32 & 0xFF; |
|
|
|
|
|
|
|
|
|
for (let i = 0; i < context.dynamic_positions[player_id].length; ++i) { |
|
|
|
|
context.dynamic_colors_u8[at / 2 * 3 + i * 3 + 0] = r; |
|
|
|
|
context.dynamic_colors_u8[at / 2 * 3 + i * 3 + 1] = g; |
|
|
|
|
context.dynamic_colors_u8[at / 2 * 3 + i * 3 + 2] = b; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
at += context.dynamic_positions[player_id].length; |
|
|
|
@ -169,14 +166,17 @@ function update_dynamic_stroke(state, context, player_id, point) {
@@ -169,14 +166,17 @@ function update_dynamic_stroke(state, context, player_id, point) {
|
|
|
|
|
if (!(player_id in state.current_strokes)) { |
|
|
|
|
state.current_strokes[player_id] = { |
|
|
|
|
'points': [], |
|
|
|
|
'width': state.stroke_width, |
|
|
|
|
'color': state.colors.active, |
|
|
|
|
'width': state.players[player_id].width, |
|
|
|
|
'color': state.players[player_id].color, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
context.dynamic_positions[player_id] = []; |
|
|
|
|
context.dynamic_colors[player_id] = []; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
state.current_strokes[player_id].color = state.players[player_id].color; |
|
|
|
|
state.current_strokes[player_id].width = state.players[player_id].width; |
|
|
|
|
|
|
|
|
|
// TODO: incremental
|
|
|
|
|
context.dynamic_positions[player_id].length = 0; |
|
|
|
|
context.dynamic_colors[player_id].length = 0; |
|
|
|
@ -190,8 +190,8 @@ function update_dynamic_stroke(state, context, player_id, point) {
@@ -190,8 +190,8 @@ function update_dynamic_stroke(state, context, player_id, point) {
|
|
|
|
|
function clear_dynamic_stroke(state, context, player_id) { |
|
|
|
|
if (player_id in state.current_strokes) { |
|
|
|
|
state.current_strokes[player_id].points.length = 0; |
|
|
|
|
state.current_strokes[player_id].color = state.colors.active; |
|
|
|
|
state.current_strokes[player_id].width = state.stroke_width; |
|
|
|
|
state.current_strokes[player_id].color = state.players[state.me].color; |
|
|
|
|
state.current_strokes[player_id].width = state.players[state.me].width; |
|
|
|
|
context.dynamic_positions[player_id].length = 0; |
|
|
|
|
recompute_dynamic_data(state, context); |
|
|
|
|
} |
|
|
|
|