Working on recursively generating boxes to create a VR Fractal Tree.

Upon each iteration, the boxes renders an extra width and height. After I click on the rendered entity, the box shrinks to the specified size and rotates with physics.

**I’ve included both the code and screenshots of before click and after click for 2 iterations of the recursive loop.** After 3 iterations (depth = 3), the boxes are much larger.

**Is this a bug or is one of the properties messing with the entity?**

**Run Script, Before Click:**

**After Click:**

**Script Code:**

```
var depth = 2;
var length = 2;
var angle = 0;
const pi = Math.PI;
const sqrt2 = Math.sqrt(2);
function drawFractalTree(depthToGo, position, curHeight, angle) {
if (depthToGo === 0) return;
var propertiesBox = {
type: "Box",
name: "FT1",
position: position,
color: { red: 155, green: 0, blue: 0 },
dimensions: {
x: 0.1,
y: curHeight,
z: 0.1,
},
rotation: {
x: 0,
y: 0,
z: angle,
w: 1
}
};
Ent = Entities.addEntity(propertiesBox);
var nextHeight = curHeight / 2;
var triSide = (nextHeight * (1 / 2) / sqrt2); // 45 45 90 triangle solving for a in tangent = adjacent * sqrt(2);
var leftPosition = {
x: position.x - triSide,
y: position.y + triSide + nextHeight,
z: position.z
};
var rightPosition = {
x: position.x + triSide ,
y: position.y + triSide + nextHeight,
z: position.z
};
drawFractalTree(depthToGo - 1, rightPosition, nextHeight, angle + (pi / 2));
drawFractalTree(depthToGo - 1, leftPosition, nextHeight, angle - (pi / 2));
}
drawFractalTree(depth, {x: 0, y: 0, z: 0}, 2, angle);
```