From 918230fd081ee8405582a1bf1fe69c788b99aa77 Mon Sep 17 00:00:00 2001 From: Jamie Lentin Date: Thu, 7 Aug 2025 16:58:38 +0000 Subject: [PATCH 1/2] WIP: position_helper: Stash chosen anchor_node so we can see it in debug This is very useful for seeing what's going on here, but is ultimately useless for real onezoom usage. --- OZprivate/rawJS/OZTreeModule/src/position_helper.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OZprivate/rawJS/OZTreeModule/src/position_helper.js b/OZprivate/rawJS/OZTreeModule/src/position_helper.js index bd77a234..c4cf56b5 100755 --- a/OZprivate/rawJS/OZTreeModule/src/position_helper.js +++ b/OZprivate/rawJS/OZTreeModule/src/position_helper.js @@ -381,6 +381,9 @@ function reanchor_at_node(node, root_node) { // Set graphref false everywhere deanchor(root_node); + // Anchor to this node + tree_state.anchor_node = node; // NB: Only saved for debugging purposes + // Walk up tree from (node), setting graphref while (node.upnode) { node.graphref = true; @@ -393,6 +396,11 @@ function reanchor_at_node(node, root_node) { /** * Walk tree, anchoring to the first node on-screen that has 2.2 < node.rvar < 22000 * (i.e. set graphref on this node and it's ancestors) + * + * For debugging, you can draw the current anchor node with: + * onezoom.config.debug_bounding_box = (node => node === onezoom.tree_state.anchor_node ? 0x03 : 0) + * ...or add a browser watch condition of: + * onezoom.tree_state.anchored_node + ' ' + onezoom.tree_state.anchored_node.rvar */ function reanchor(node) { // If this node (or it's desendents) aren't visible, don't bother @@ -401,6 +409,7 @@ function reanchor(node) { node.graphref = true; if (node.gvar || !node.has_child || (node.rvar > 2.2 && node.rvar < 22000)) { // Anchor to this node + tree_state.anchor_node = node; // NB: Only saved for debugging purposes tree_state.xp = node.xvar; tree_state.yp = node.yvar; tree_state.ws = node.rvar / 220; From 80c3b11d30f4d1f713ba0d30ea794a9604c67c99 Mon Sep 17 00:00:00 2001 From: Jamie Lentin Date: Thu, 7 Aug 2025 17:03:38 +0000 Subject: [PATCH 2/2] WIP: position_helper: anchor to nodes that are on-screen *and* reasonably sized In a balanced tree, the node below "Animals" has a bounding box encompassing most of the insects. Thanks to this anchoring won't consider anything lower. Instead, insist that nodes are on-screen *and* of a reasonable size, decreasing the considered size to more tightly follow the flight. This fixes the initial problem, but now the flight from the Elephant Hawk-Moth to Elephant Seal is very messy. This is likely a problem elsewhere. --- OZprivate/rawJS/OZTreeModule/src/position_helper.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/OZprivate/rawJS/OZTreeModule/src/position_helper.js b/OZprivate/rawJS/OZTreeModule/src/position_helper.js index c4cf56b5..9290d4a0 100755 --- a/OZprivate/rawJS/OZTreeModule/src/position_helper.js +++ b/OZprivate/rawJS/OZTreeModule/src/position_helper.js @@ -394,9 +394,12 @@ function reanchor_at_node(node, root_node) { } /** - * Walk tree, anchoring to the first node on-screen that has 2.2 < node.rvar < 22000 + * Walk tree, anchoring to the first node that is both on screen and of a reasonable size * (i.e. set graphref on this node and it's ancestors) * + * Reasonable size here means we should ignore high-up nodes whose bounding boxes encompass half of + * insects in a balanced tree (e.g.) + * * For debugging, you can draw the current anchor node with: * onezoom.config.debug_bounding_box = (node => node === onezoom.tree_state.anchor_node ? 0x03 : 0) * ...or add a browser watch condition of: @@ -407,7 +410,7 @@ function reanchor(node) { if (!node.dvar) return; node.graphref = true; - if (node.gvar || !node.has_child || (node.rvar > 2.2 && node.rvar < 22000)) { + if (!node.has_child || node.gvar && (node.rvar > 1 && node.rvar < 2200)) { // Anchor to this node tree_state.anchor_node = node; // NB: Only saved for debugging purposes tree_state.xp = node.xvar;