Valay
Valay

Reputation: 1999

three.js - create cube around tube geometry

Please find the URL for tube geometry: 3d tube with 200 points of data passed in JSON format.

As number of points vary for the length of the tube, how do I create a transparent cube around tube geometry dynamically to cover entire tube structure inside the cube and the whole scene look like a pipe inside a surface ?

Upvotes: 0

Views: 1187

Answers (1)

Gero3
Gero3

Reputation: 2887

geometry.computeboundingbox() which adjusts the scale at which the box is and postion of where the box should be placed

scaleX = (max.x -min.x);
scaleY = (max.y -min.y);
scaleZ = (max.z -min.z);

positionX = min.x + scaleX/2;
positionY = min.y + scaleY/2;
positionZ = min.z + scaleZ/2;

Upvotes: 1

Related Questions