Skip to content
Snippets Groups Projects
main.js 11.8 KiB
Newer Older
Amanda Ghassaei's avatar
Amanda Ghassaei committed
/**
 * Created by aghassaei on 1/7/15.
 */

Amanda Ghassaei's avatar
Amanda Ghassaei committed
require.config({
Amanda Ghassaei's avatar
Amanda Ghassaei committed

Amanda Ghassaei's avatar
Amanda Ghassaei committed
    baseUrl: 'js',
Amanda Ghassaei's avatar
Amanda Ghassaei committed

Amanda Ghassaei's avatar
Amanda Ghassaei committed
    paths: {
        jquery: '../dependencies/jquery-2.1.3',
        underscore: '../dependencies/underscore',
        backbone: '../dependencies/backbone',
        flatUI: '../dependencies/flatUI/js/flat-ui',
        bootstrapSlider: '../dependencies/bootstrap-slider/bootstrap-slider',
        fileSaverLib: '../dependencies/loaders/FileSaver.min',
Amanda Ghassaei's avatar
ui  
Amanda Ghassaei committed
        numeric: '../dependencies/numeric-1.2.6',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        codeMirrorJS: '../dependencies/codemirror/javascript',
        codeMirror: '../dependencies/codemirror/codemirror',
        text: '../dependencies/require/text',
        bin: '../dependencies/require/bin',
Amanda Ghassaei's avatar
Amanda Ghassaei committed

        //three
        three: '../dependencies/three',
        orbitControls: '../dependencies/OrbitControls',
        stlLoader: '../dependencies/loaders/STLLoader',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        stlExport: '../dependencies/loaders/binary_stl_writer',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        threeModel: 'three/ThreeModel',
        threeView: 'three/ThreeView',
        fillGeometry: 'three/FillGeometry',
        axes: 'three/Axes',
        svgRenderer: '../dependencies/svgRenderer',
        threeProjector: '../dependencies/Projector',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        //plist
        plist: 'plists/PList',

Amanda Ghassaei's avatar
Amanda Ghassaei committed
        //models
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        globals: 'models/Globals',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        appState: 'models/AppState',
        fileSaver: 'models/FileSaver',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        dnaExport: 'dnaExport/dnaExport',
Amanda Ghassaei's avatar
Amanda Ghassaei committed

        //communication
        socketio: '../dependencies/socket.io-1.3.5',
        serialComm: 'models/SerialComm',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        commPlist: 'plists/CommPlist',
        machineState: 'models/MachineState',
        //lattice classes and extra methods
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        latticeBase: 'lattice/LatticeBase',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        lattice: 'lattice/Lattice',
        compositeEditorLattice: 'lattice/CompositeEditorLattice',
        latticeImportGeo: 'lattice/ImportGeo',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        latticeCAM: 'lattice/LatticeCAM',

        //lattice "subclasses"
        cubeLattice: 'lattice/latticeSubclasses/CubeLattice',
        gikLattice: 'lattice/latticeSubclasses/GIKLattice',
        kelvinLattice: 'lattice/latticeSubclasses/KelvinLattice',
        octaEdgeLattice: 'lattice/latticeSubclasses/OctaEdgeLattice',
        octaFaceLattice: 'lattice/latticeSubclasses/OctaFaceLattice',
        octaRotEdgeLattice: 'lattice/latticeSubclasses/OctaRotEdgeLattice',
        octaVertexLattice: 'lattice/latticeSubclasses/OctaVertexLattice',
        truncatedCubeLattice: 'lattice/latticeSubclasses/TruncatedCubeLattice',
        tetraStackedLattice: 'lattice/latticeSubclasses/TetraStackedLattice',
        tetraVertexLattice: 'lattice/latticeSubclasses/TetraVertexLattice',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        hexLattice: 'lattice/latticeSubclasses/HexagonalLattice',
        hexRotLattice: 'lattice/latticeSubclasses/HexagonalRotLattice',
Amanda Ghassaei's avatar
Amanda Ghassaei committed

        //baseplane
        baseplane: 'baseplane/BasePlane',
        squareBaseplane: 'baseplane/SquareBasePlane',
        octaBaseplane: 'baseplane/OctaBasePlane',
        rotEdgeOctaBaseplane: 'baseplane/RotEdgeOctaBasePlane',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        hexBaseplane: 'baseplane/HexagonalBasePlane',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        hexRotBasePlane: 'baseplane/HexagonalRotBasePlane',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        //highlighter
        highlighter: 'highlighter/Highlighter',
        defaultHighlighter: 'highlighter/DefaultHighlighter',
        cubeHighlighter: 'highlighter/CubeHighlighter',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        superCellHighlighter: 'highlighter/SuperCellHighlighter',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        octaFaceHighlighter: 'highlighter/OctaFaceHighlighter',
        truncatedCubeHighlighter: 'highlighter/TruncatedCubeHighlighter',

Amanda Ghassaei's avatar
Amanda Ghassaei committed
        //cells
        cell: 'cells/DMACell',
        octaFaceCell: 'cells/OctaFaceCell',
        octaEdgeCell: 'cells/OctaEdgeCell',
        octaVertexCell: 'cells/OctaVertexCell',
        octaRotEdgeCell: 'cells/OctaRotEdgeCell',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        tetraStackedCell: 'cells/TetraStackedCell',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        tetraVertexCell: 'cells/TetraVertexCell',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        truncatedCubeCell: 'cells/TruncatedCubeCell',
        kelvinCell: 'cells/KelvinCell',
        cubeCell: 'cells/CubeCell',
        gikCell: 'cells/GIKCell',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        superCell: 'cells/supercells/DMASuperCell',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        gikSuperCell: 'cells/supercells/GIKSuperCell',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        compositeCell: "cells/supercells/CompositeCell",
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        hexCell: 'cells/HexagonalCell',
        hexRotCell: 'cells/HexagonalRotCell',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        dnaBrickCell: 'cells/DNABrickCell',
Amanda Ghassaei's avatar
Amanda Ghassaei committed

        //parts
        part: 'parts/DMAPart',
        octaFaceTriPart: 'parts/OctaFaceTriPart',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        octaEdgeVoxPart: 'parts/OctaEdgeVoxPart',
        octaEdgeVoxPartLowPoly: 'parts/OctaEdgeVoxPartLowPoly',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        gikPart: 'parts/GIKPart',
        gikPartLowPoly: 'parts/GIKPartLowPoly',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        kennyTeqPart: 'parts/KennyTeqPart',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        kennyTeqHighResPart: 'parts/KennyTeqHighResPart',
        samTeqPart: 'parts/SamTeqPart',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        legoPart: 'parts/LegoPart',
        dnaStraightPart: 'parts/DNAStraightPart',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        dnaLegoPart: 'parts/DNALegoPart',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        //materials
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        materialsPlist: 'plists/MaterialsPlist',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        materials: 'materials/DMAMaterials',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        material: 'materials/DMAMaterial',
        compositeMaterial: 'materials/DMACompositeMaterial',
Amanda Ghassaei's avatar
Amanda Ghassaei committed

Amanda Ghassaei's avatar
Amanda Ghassaei committed
        //UI
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        navbar: 'menus/Navbar',
        navViewMenu: 'menus/NavViewMenu',//view dropdown
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        ribbon: 'menus/Ribbon',
        modalView: 'menus/ModalView',
        menuWrapper: 'menus/MenuWrapperView',
        menuParent: 'menus/MenuParentView',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        latticeMenu: 'menus/LatticeMenuView',
        importMenu: 'menus/ImportMenuView',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        partMenu: 'menus/PartMenuView',
        scriptMenu: 'menus/ScriptMenuView',
        materialMenu: 'menus/MaterialMenuView',
        materialPropertiesMenu: 'menus/MaterialPropertiesMenuView',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        optimizeMenu: 'menus/OptimizationMenuView',
        assemblerMenu: 'menus/AssemblerMenuView',
        camMenu: 'menus/CamMenuView',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        editCamOutputMenu: 'menus/EditCamOutputMenuView',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        animateMenu: 'menus/AnimationMenuView',
        sendMenu: 'menus/SendMenuView',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        compositeMenu: 'menus/CompositeMenuView',
        materialEditorMenu: 'menus/MaterialEditorMenuView',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        setupCommMenu: 'menus/SetupCommMenuView',
        discoveryMenu: 'menus/DiscoveryMenuView',
        eSetupMenu: 'menus/ESetupMenuView',
        eStaticMenu: 'menus/EStaticMenuView',
        eDynamicMenu: 'menus/EDynamicMenuView',
        mSetupMenu: 'menus/MSetupMenuView',
        mStaticMenu: 'menus/MStaticMenuView',
        mDynamicMenu: 'menus/MDynamicMenuView',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        dnaSetupMenu: 'menus/DNASimSetupMenuView',
        dnaExportMenu: 'menus/DNAExportMenuView',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        assemblerSetupMenu: 'menus/AssemblerSetupMenuView',
        editComponentMenu: 'menus/EditComponentMenuView',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        commParentMenu: 'menus/CommParentMenu',
        serialMonitorController: 'SerialMonitor/SerialMonitorController',
        //templates
        navViewMenuTemplate: 'menus/templates/NavViewMenu.html',
        ribbonTemplate: 'menus/templates/Ribbon.html',
        modalViewTemplate: 'menus/templates/ModalView.html',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        scriptView: 'menus/ScriptView',
        menuWrapperTemplate: 'menus/templates/MenuWrapperView.html',
        latticeMenuTemplate: 'menus/templates/LatticeMenuView.html',
        importMenuTemplate: 'menus/templates/ImportMenuView.html',
        partMenuTemplate: 'menus/templates/PartMenuView.html',
        scriptMenuTemplate: 'menus/templates/ScriptMenuView.html',
        materialMenuTemplate: 'menus/templates/MaterialMenuView.html',
        optimizeMenuTemplate: 'menus/templates/OptimizationMenuView.html',
        assemblerMenuTemplate: 'menus/templates/AssemblerMenuView.html',
        camMenuTemplate: 'menus/templates/CamMenuView.html',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        editCamOutputMenuTemplate: 'menus/templates/EditCamOutputMenuView.html',
        animationMenuTemplate: 'menus/templates/AnimationMenuView.html',
        sendMenuTemplate: 'menus/templates/SendMenuView.html',
        compositeMenuTemplate: 'menus/templates/CompositeMenuView.html',
        materialEditorMenuTemplate: 'menus/templates/MaterialEditorMenuView.html',
        setupCommMenuTemplate: 'menus/templates/SetupCommMenuView.html',
        discoveryMenuTemplate: 'menus/templates/DiscoveryMenuView.html',
        eSetupMenuTemplate: 'menus/templates/ESetupMenuView.html',
        eStaticMenuTemplate: 'menus/templates/EStaticMenuView.html',
        eDynamicMenuTemplate: 'menus/templates/EDynamicMenuView.html',
        mSetupMenuTemplate: 'menus/templates/MSetupMenuView.html',
        mStaticMenuTemplate: 'menus/templates/MStaticMenuView.html',
        mDynamicMenuTemplate: 'menus/templates/MDynamicMenuView.html',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        assemblerSetupMenuTemplate: 'menus/templates/AssemblerSetupMenuView.html',
        editComponentMenuTemplate: 'menus/templates/EditComponentMenuView.html',
        //electronic sim
        eSimPlist: 'plists/ESimPlist',
        eSim: 'simulation/electronics/eSim',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        latticeESim: 'simulation/electronics/LatticeEsim',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        eSimCell: 'simulation/electronics/cells/eSimCell',
        eSimSuperCell: 'simulation/electronics/cells/eSimSuperCell',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        eSimField: 'simulation/electronics/eSimField',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        //cam
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        cam: 'cam/Cam',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        camPlist: 'plists/CamPList',
Amanda Ghassaei's avatar
Amanda Ghassaei committed

Amanda Ghassaei's avatar
Amanda Ghassaei committed
        //assemblers
        assembler: 'cam/assemblers/Assembler',
        assemblerPost: 'cam/assemblers/AssemblerPost',
        component: 'cam/assemblers/Component',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        stockComponent: 'cam/assemblers/StockComponent',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        urdfJoint: 'cam/assemblers/URDFJoint',
        urdfLink: 'cam/assemblers/URDfLink',
Amanda Ghassaei's avatar
Amanda Ghassaei committed

        //processes
        gcode: 'cam/processes/GCodeExporter',
        shopbot: 'cam/processes/ShopbotExporter',
        tinyG: 'cam/processes/TinyGExporter',

Amanda Ghassaei's avatar
Amanda Ghassaei committed
        //stls (not sure why ../ is not working here?)
        octaFaceTrianglePartSTL: 'assets/stls/parts/OctaFaceTrianglePart.stl',
        octaEdgeVoxPartSTL: 'assets/stls/parts/OctaEdgeVoxPart.stl',
        octaEdgeVoxPartLowPolySTL: 'assets/stls/parts/OctaEdgeVoxPartLowPoly.stl',
        gikPartSTL: 'assets/stls/parts/GIKPart.stl',
        gikEndPartSTL: 'assets/stls/parts/GIKEndPart.stl',
        gikPartLowPolySTL: 'assets/stls/parts/GIKPartLowPoly.stl',
        gikEndPartLowPolySTL: 'assets/stls/parts/GIKEndPartLowPoly.stl',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        kennyTeqPartSTL: 'assets/stls/parts/KennyTeqPart.stl',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        kennyTeqPartHighResSTL: 'assets/stls/parts/KennyTeqPartHighRes.stl',
        samTeqPartSTL: 'assets/stls/parts/SamTeqPart.stl',
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        legoBrickSTL: 'assets/stls/parts/legoBrick1x1.stl',
        dnaLegoBrickSTL: 'assets/stls/parts/DNALegoBrick1x2.stl',
        dnaLegoBrick1x1STL: 'assets/stls/parts/DNALegoBrick1x1.stl'
Amanda Ghassaei's avatar
Amanda Ghassaei committed

Amanda Ghassaei's avatar
Amanda Ghassaei committed

Amanda Ghassaei's avatar
Amanda Ghassaei committed
    shim: {
        three: {
            exports: 'THREE'
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        },
        orbitControls: {
            deps: ['three'],
            exports: 'THREE'
        },
        stlLoader: {
            deps: ['three'],
            exports: 'THREE'
        },
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        stlExport: {
Amanda Ghassaei's avatar
Amanda Ghassaei committed
            exports: 'geometryToSTLBin'
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        },
        threeProjector: {
            deps: ['three'],
            exports: "THREE"
        },
        svgRenderer: {
            deps: ['three', 'threeProjector'],
            exports: "THREE.SVGRenderer"
        },
Amanda Ghassaei's avatar
Amanda Ghassaei committed
        fileSaverLib: {
            exports: 'saveAs'
        },
        flatUI: {
            deps: ['jquery']
        bootstrapSlider:{
            deps: ['jquery'],
            exports: '$'
        },
        'socketio': {
            exports: 'io'
Amanda Ghassaei's avatar
ui  
Amanda Ghassaei committed
        },
        'numeric': {
            exports: 'numeric'
Amanda Ghassaei's avatar
Amanda Ghassaei committed

Amanda Ghassaei's avatar
Amanda Ghassaei committed

Amanda Ghassaei's avatar
Amanda Ghassaei committed
//require.onError = function (err) {
//    console.log(err.requireType);
//    console.log(err.requireModules);
//    throw err;
//};
Amanda Ghassaei's avatar
Amanda Ghassaei committed
//init stuff
require(['appState', 'lattice', 'navbar', 'threeModel', 'threeView', 'globals', 'flatUI', 'bootstrapSlider', 'ribbon', 'menuWrapper', 'scriptView'],
    function(appState, lattice, Navbar, three, ThreeView, globals){
Amanda Ghassaei's avatar
Amanda Ghassaei committed

    new Navbar({model:appState});

    var threeView = new ThreeView({model:three});
    globals.threeView = threeView;//todo fix this
Amanda Ghassaei's avatar
Amanda Ghassaei committed
//    three.startAnimationLoop();

Amanda Ghassaei's avatar
Amanda Ghassaei committed
//    if (lattice.get("connectionType") != "gik") lattice.getUItarget().addCellAtIndex({x:0,y:0,z:0});//add a cell