Skip to content
Snippets Groups Projects
indexHW4.html 2.38 KiB
Newer Older
<head>
    <style> body { margin: 0; } </style>
    <title>MetaVoxel</title>
    <script src="//unpkg.com/three"></script>
    <script type="text/javascript" src="https://files.mcneel.com/rhino3dm/js/latest/rhino3dm.js"></script>
    <script src="../lib/dat.gui.js"></script>
  
    <script src="../lib/js-colormaps.js"></script>
  
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="//unpkg.com/3d-force-graph"></script>
    <!-- <script src="../lib/3d-force-graph.js"></script> -->
    <script src="//unpkg.com/three-spritetext"></script>

    <script src="../visualization/geometry.js"></script>
    <script src="../visualization/utils.js"></script>
    <script src="../visualization/drawGraph.js"></script>
    <script src="./HW4.js"></script>


  </head>
  
  <body>
    <div id="3d-graph"></div>
  
    <script>
        var setup;
  

  
    rhino3dm().then(async m => {
        console.log('Loaded rhino3dm.');
    
        _rhino3dm = m; // global
        var size=5;
        var truss={
            nnx:3,
            nny:4,
            nnz:2,
            dx:size,
            dy:size,
            dz:size,
            localConnections:true,
            equals : function(other) {
                return other.localConnections == this.localConnections && 
                other.nnx == this.nnx &&
                other.nny == this.nny &&
                other.nnz == this.nnz;
            }

        }
        var prevTruss=JSON.parse(JSON.stringify(truss));
        setup=createTruss(truss);

        scale=10.0;

        var container='3d-graph';

        var Graph=drawGraph(container,setup,scale,false);
        var gui = new dat.GUI();
        var params=[];
        params.push(gui.add(truss, 'nnx', 1, 5.0).step(1).listen());
        params.push(gui.add(truss, 'nny', 1, 5.0).step(1).listen());
        params.push(gui.add(truss, 'nnz', 1, 5.0).step(1).listen());
        params.push(gui.add(truss, 'localConnections').listen());

        for (var i=0;i<params.length;i++) {
			params[i].onChange(function(value) {
                if(truss.equals(prevTruss)){
                    

                }else{
                    prevTruss=JSON.parse(JSON.stringify(truss));
                    setup=createTruss(truss);
                    updateGraph(Graph,setup,scale);

                }
                
				
		});
	}
    });



    
  
  
    </script>
  </body>