module.exports = Gl3dLayout;


function Gl3dLayout (config) {

    this.config = config;
}

var proto = Gl3dLayout.prototype;

proto.sceneLayoutAttributes = {
    bgcolor: {
        type: 'color',
        dflt: '#fff'
    },
    cameraposition: {
        type: 'data_array'
    },
    domain: {
        x: [
            {type: 'number', min: 0, max: 1},
            {type: 'number', min: 0, max: 1}
        ],
        y:[
            {type: 'number', min: 0, max: 1, dflt: 0},
            {type: 'number', min: 0, max: 1, dflt: 1}
        ]
    }
};


proto.supplyLayoutDefaults = function (layoutIn, layoutOut, fullData) {

    if (!layoutOut._hasGL3D) return;

    var _this = this;
    var scenes = [];
    var Plotly = this.config.Plotly;
    var $ = this.config.jQuery;

    for (var i = 0; i < fullData.length; ++i) {
        var d = fullData[i];
        if (Plotly.Plots.isGL3D(d.type)) {
            if (scenes.indexOf(d.scene) === -1) {
                scenes.push(d.scene);
            }
        }
    }

    // until they play better together
    delete layoutOut.xaxis;
    delete layoutOut.yaxis;

    // Get number of scenes to compute default scene domain
    scenesLength = scenes.length;

    for (var i_scene = 0; i_scene < scenesLength; ++i_scene) {
        var scene = scenes[i_scene];
        /*
         * Scene numbering proceeds as follows
         * scene
         * scene2
         * scene3
         *
         * and d.scene will be undefined or some number or number string
         */
        var sceneLayoutIn = layoutIn[scene] || {};
        var sceneLayoutOut = {};

        function coerceScene(attr, dflt) {
            return Plotly.Lib.coerce(sceneLayoutIn, sceneLayoutOut, _this.sceneLayoutAttributes, attr, dflt);
        }

        coerceScene('bgcolor');
        coerceScene('cameraposition');
        coerceScene('domain.x[0]', i_scene / scenesLength);
        coerceScene('domain.x[1]', (i_scene+1) / scenesLength);
        coerceScene('domain.y[0]');
        coerceScene('domain.y[1]');

         /*
          * scene arrangements need to be implemented: For now just splice
          * along the horizontal direction. ie.
          * x:[0,1] -> x:[0,0.5], x:[0.5,1] ->
          *     x:[0, 0.333] x:[0.333,0.666] x:[0.666, 1]
          */

        Plotly.Gl3dAxes.supplyDefaults(sceneLayoutIn, sceneLayoutOut, {
            font: layoutOut.font,
            scene: scene,
            data: fullData
        });

        layoutOut[scene] = sceneLayoutOut;
    }
};

@@ -86,58 +86,19 @@
 ig;%0A
-%7D%0A%0Avar proto = Gl3dLayout.prototype;%0A%0Aproto.sceneL
+%0A    this.l
 ayou
@@ -113,16 +113,20 @@
 tes = %7B%0A
+    
     bgco
@@ -136,24 +136,28 @@
 : %7B%0A        
+    
 type: 'color
@@ -167,16 +167,20 @@
         
+    
 dflt: '#
@@ -184,27 +184,35 @@
  '#fff'%0A    
+  
+  
 %7D,%0A
+    
     camerapo
@@ -217,24 +217,28 @@
 position: %7B%0A
+    
         type
@@ -252,27 +252,35 @@
 _array'%0A    
-%7D,%0A
+    %7D,%0A    
     domain: 
@@ -293,13 +293,21 @@
     
+  
+  
 x: %5B%0A
+    
     
@@ -352,32 +352,36 @@
 1%7D,%0A            
+    
 %7Btype: 'number',
@@ -405,16 +405,20 @@
         
+ 
+   
 %5D,%0A     
@@ -420,16 +420,20 @@
         
+  
+  
 y:%5B%0A    
@@ -432,32 +432,36 @@
 y:%5B%0A            
+   
+ 
 %7Btype: 'number',
@@ -487,16 +487,20 @@
 lt: 0%7D,%0A
+    
         
@@ -557,17 +557,238 @@
     
+    
 %5D%0A    
+ 
-%7D%0A%7D
+   %7D,%0A        _nestedModules: %7B  // nested module coupling%0A            'error_z': 'ErrorBars',%0A            'error_x': 'ErrorBars',%0A            'error_y': 'ErrorBars'%0A        %7D%0A    %7D;%0A%0A%7D%0A%0Avar proto = Gl3dLayout.prototype
 ;%0A%0A%0A
@@ -981,40 +981,8 @@
 tly;
-%0A    var $ = this.config.jQuery;
 %0A%0A  
@@ -1374,24 +1374,28 @@
  domain%0A    
+var 
 scenesLength
@@ -1828,21 +1828,16 @@
 n coerce
-Scene
 (attr, d
@@ -1914,21 +1914,53 @@
 Out,
+%0A                                    
  _this.
-sceneL
+l
 ayou
@@ -2010,21 +2010,16 @@
   coerce
-Scene
 ('bgcolo
@@ -2037,21 +2037,16 @@
   coerce
-Scene
 ('camera
@@ -2063,37 +2063,32 @@
 ;%0A        coerce
-Scene
 ('domain.x%5B0%5D', 
@@ -2118,37 +2118,32 @@
 ;%0A        coerce
-Scene
 ('domain.x%5B1%5D', 
@@ -2177,37 +2177,32 @@
 ;%0A        coerce
-Scene
 ('domain.y%5B0%5D');
@@ -2216,21 +2216,16 @@
   coerce
-Scene
 ('domain
@@ -2518,16 +2518,22 @@
 s.supply
+Layout
 Defaults

update gl3dlayout (this one is for layout.scene)