Skip to content
Snippets Groups Projects
voxelDesigner.html 3.32 KiB
Newer Older
  • Learn to ignore specific revisions
  • Amira Abdel-Rahman's avatar
    Amira Abdel-Rahman committed
    <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="./voxelDesigner.js"></script>
    
    
      </head>
      
      <body>
        <div id="3d-graph"></div>
      
        <script>
            var setup;
            
      
    
      
            rhino3dm().then(async m => {
                console.log('Loaded rhino3dm.');
            
                _rhino3dm = m; // global
                var name="twist";
                var size=10;
                var size=5;
                var size=10;
                var truss={
                    nnx:5,
                    nny:5,
                    nnz:5,
                    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:true,
                    equals : function(other) {
                        return other.localConnections == this.localConnections && 
                        other.nnx == this.nnx &&
                        other.nny == this.nny &&
                        other.nnz == this.nnz;
                    },
                    save:function(){
                        var fileName = name+'.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());
                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);
    
                        }
                        
                        
                    });
                }
                
                
    
                
            });
    
    
    
        
      
      
        </script>
      </body>