Skip to content
Snippets Groups Projects
indexHW4.html 2.98 KiB
Newer Older
  • Learn to ignore specific revisions
  • <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
    
    Amira Abdel-Rahman's avatar
    Amira Abdel-Rahman committed
            var size=10;
    
            var size=5;
    
    Amira Abdel-Rahman's avatar
    Amira Abdel-Rahman committed
            var size=10;
    
            var truss={
                nnx:3,
    
    Amira Abdel-Rahman's avatar
    Amira Abdel-Rahman committed
                nny:3,
                nnz:3,
                dx:size/2,
                dy:size/2,
                dz:size/2,
                setup:{},
    
                // nnx:5,
                // nny:3,
                // nnz:1,
                // dx:size*2/3,
                // dy:size/2,
                // dz:size,
    
    
                // nnx:3,
                // nny:3,
                // nnz:1,
                // dx:size*2/3,
                // dy:size/2,
                // dz:size,
    
                localConnections:false,
    
                equals : function(other) {
                    return other.localConnections == this.localConnections && 
                    other.nnx == this.nnx &&
                    other.nny == this.nny &&
                    other.nnz == this.nnz;
    
    Amira Abdel-Rahman's avatar
    Amira Abdel-Rahman committed
                },
                save:function(){
                    var fileName = 'problem1.json';
                    this.setup.viz.colorMaps=[]
                    saveJSON(this.setup, fileName);
    
    
                }
    
            }
            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());
    
    Amira Abdel-Rahman's avatar
    Amira Abdel-Rahman committed
            gui.add(truss,'save');
    
            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);
    
                    }