tree.js code example

Example 1: what is three.js

Three.js is an opensourse cross-browser JavaScript library 
application programming interface (API) 
used to create and display animated 3D computer graphics in the browser
using WebGL. 
*** available via NPM *** and Github
FEATURES
Effects: Anaglyph, cross-eyed, and parallax barrier.
Scenes: add and remove objects at run-time; fog
Cameras: perspective and orthographic; 
	controllers: trackball, FPS, 
Animation: armatures, forward kinematics, 
	inverse kinematics, morph, and keyframe
Lights: ambient, direction, point, and spot lights; shadows: cast and receive
Materials: Lambert, Phong, smooth shading, textures, and more
Shaders: access to full OpenGL Shading Language (GLSL) capabilities: 
	lens flare, depth pass, and extensive post-processing library
Objects: meshes, particles, sprites, lines, ribbons, bones,
Geometry: plane, cube, sphere, torus, 3D text,
modifiers: lathe, extrude, and tube
Data loaders: binary, image, JSON, and scene
Utilities: full set of time and 3D math functions 
	frustum, matrix, quaternion, UVs, and more
Export and import: utilities to create Three.js-compatible JSON files 
  from : Blender, openCTM, FBX, Max, and OBJ
examples plus fonts, models, textures, sounds, other support files
Debugging: Stats.js, WebGL Inspector, Three.js Inspector
Virtual and Augmented Reality via WebXR

Example 2: threejs

<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r123/three.js"
        integrity="sha512-8Yom5spEjD3HeZTNoDiOm4Y4Rn3RVKUFpiqTM4I3RIIO0u8e2m7XjT5rG1GQNHJlVcD9EZrzn+itENl4C6112A=="
        crossorigin="anonymous"></script>

Example 3: tree.js script-two

BinarySearchTree.prototype.push = function(val){
   var root = this.root;

   if(!root){
      this.root = new Node(val);
      return;
   }

   var currentNode = root;
   var newNode = new Node(val); 

   while(currentNode){
      if(val < currentNode.value){
          if(!currentNode.left){
             currentNode.left = newNode;
             break;
          }
          else{
             currentNode = currentNode.left;
        }
     }
     else{
         if(!currentNode.right){
            currentNode.right = newNode;
            break;
         }
         else{
            currentNode = currentNode.right;
         }
     }
  }

}

Tags:

Html Example