pivot-editor/index.html
2021-05-29 12:28:46 -04:00

62 lines
1.5 KiB
HTML
Executable File

<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="N.js"></script>
<script src="Pivot.js"></script>
</head>
<body>
<script>
let root = N.Create("root");
var context = {};
let recurse = (node, depth) =>
{
// create a set of new nodes off of the input node
let c1 = N.Create(node.Meta+"-c1");
let c2 = N.Create(node.Meta+"-c2");
N.Connect(node, c1, "parent");
N.Connect(node, c2, "parent");
var iterator;
if(depth < 1)
{
N.Walk((child) =>
{
console.log(`subdividing ${child.Meta}`);
context = [child, depth+1];
recurse(child, depth+1);
return false;
}
, node, "parent");
}
else
{
N.Walk((child) =>
{
/*
issue: why does incrementing walk id cause an infinite loop
*/
N.ID.Walk++;
console.log(`changing walk ID ${child.Meta}`);
if(N.ID.Walk > 20)
{
console.log("big problems");
throw new Error("holy crap");
}
return false;
}
, node, "parent");
}
}
N.ID.Walk++;
context = [root, 0];
recurse(root, 0);
</script>
</body>
</html>