@@ -340,15 +340,9 @@ var ThreeModel = widgets.DOMWidgetModel.extend({
340
340
// initialize properties arrays
341
341
this . three_properties = [ ] ;
342
342
this . three_array_properties = [ ] ;
343
+
344
+ // TODO: not currently integrated
343
345
this . three_dict_properties = [ ] ;
344
- // this.scalar_properties = [];
345
- // this.enum_properties = [];
346
- // this.color_properties = [];
347
- // this.array_properties = [];
348
- // this.dict_properties = [];
349
- // this.function_properties = [];
350
- // this.properties_properties = [];
351
- // this.vector_properties = [];
352
346
353
347
this . enum_property_types = { } ;
354
348
this . props_created_by_three = { } ;
@@ -405,7 +399,7 @@ var ThreeModel = widgets.DOMWidgetModel.extend({
405
399
} , this ) ;
406
400
} , this ) ;
407
401
408
- // TODO: handle dicts of children
402
+ // TODO: handle dicts of children via this.three_dict_properties
409
403
410
404
this . on ( 'change' , this . onChange , this ) ;
411
405
this . on ( 'msg:custom' , this . onCustomMessage , this ) ;
@@ -588,9 +582,6 @@ var ThreeModel = widgets.DOMWidgetModel.extend({
588
582
//
589
583
590
584
onChange : function ( model , options ) {
591
- // console.log(this.id + ' onChange: ');
592
- // console.log(this.changedAttributes());
593
-
594
585
this . syncToThreeObj ( ) ;
595
586
this . trigger ( 'rerender' , this , { } ) ;
596
587
} ,
@@ -603,19 +594,6 @@ var ThreeModel = widgets.DOMWidgetModel.extend({
603
594
// push data from model to three object
604
595
syncToThreeObj : function ( ) {
605
596
606
- // var arrayMappers = {
607
- // 'three_properties': this.syncThreePropToThree,
608
- // 'three_array_properties': this.syncThreeArrayToThree,
609
- // 'three_dict_properties': this.syncThreeDictToThree,
610
- // 'scalar_properties': this.syncScalarToThree,
611
- // 'enum_properties': this.syncEnumToThree,
612
- // 'color_properties': this.syncColorToThree,
613
- // 'array_properties': this.syncArrayToThree,
614
- // 'dict_properties': this.syncDictToThree,
615
- // 'function_properties': this.syncFunctionToThree,
616
- // 'vector_properties': this.syncVectorToThree,
617
- // };
618
-
619
597
_ . each ( this . property_converters , function ( converterName , propName ) {
620
598
if ( ! converterName ) {
621
599
this . obj [ propName ] = this . get ( propName ) ;
@@ -647,103 +625,14 @@ var ThreeModel = widgets.DOMWidgetModel.extend({
647
625
mapperFn . bind ( this ) ( ) ;
648
626
} , this ) ;
649
627
650
- // _.each(arrayMappers, function(mapFn, arrayName) {
651
- // this[arrayName].forEach(function(propName) {
652
- // mapFn.bind(this)(propName);
653
- // }, this);
654
- // }, this);
655
-
656
628
this . obj . needsUpdate = true ;
657
629
} ,
658
630
659
- // syncThreePropToThree: function(propName) {
660
- // var submodel = this.get(propName);
661
-
662
- // if (!submodel) {
663
- // this.obj[propName] = null;
664
- // } else {
665
- // var subThreeObj = submodel.obj;
666
- // this.obj[propName] = subThreeObj;
667
- // }
668
- // },
669
-
670
- // syncThreeArrayToThree: function(propName) {
671
- // var submodelArray = this.get(propName);
672
-
673
- // if (!submodelArray) {
674
- // this.obj[propName] = null;
675
- // return;
676
- // }
677
-
678
- // this.obj[propName] = _.map(submodelArray, function(submodel) {
679
- // return submodel.obj;
680
- // });
681
- // },
682
-
683
- // syncThreeDictToThree: function(propName) {
684
- // var submodelDict = this.get(propName);
685
-
686
- // if (!submodelDict) {
687
- // this.obj[propName] = null;
688
- // return;
689
- // }
690
-
691
- // this.obj[propName] = _.mapObject(submodelDict, function(submodel) {
692
- // return submodel.obj;
693
- // });
694
- // },
695
-
696
- // syncScalarToThree: function(propName) {
697
- // this.obj[propName] = this.get(propName);
698
- // },
699
-
700
- // syncEnumToThree: function(propName) {
701
- // this.obj[propName] = THREE[this.get(propName)];
702
- // },
703
-
704
- // syncColorToThree: function(propName) {
705
- // this.obj[propName].set(this.get(propName));
706
- // },
707
-
708
- // syncArrayToThree: function(propName) {
709
- // // TODO: is this needed?
710
- // this.obj[propName] = this.get(propName);
711
- // },
712
-
713
- // syncDictToThree: function(propName) {
714
- // // TODO: is this needed?
715
- // this.obj[propName] = this.get(propName);
716
- // },
717
-
718
- // syncFunctionToThree: function(propName) {
719
- // // TODO: is this needed?
720
- // eval('var fn = ' + this.get(propName));
721
- // this.obj[propName] = fn;
722
- // },
723
-
724
- // syncVectorToThree: function(propName) {
725
- // var arr = this.get(propName);
726
- // this.obj[propName].fromArray(arr);
727
- // },
728
-
729
631
// push data from three object to model
730
632
syncToModel : function ( syncAllProps ) {
731
633
732
634
syncAllProps = syncAllProps == null ? false : syncAllProps ;
733
635
734
- // var arrayMappers = {
735
- // 'three_properties': this.syncThreePropToModel,
736
- // 'three_array_properties': this.syncThreeArrayToModel,
737
- // 'three_dict_properties': this.syncThreeDictToModel,
738
- // 'scalar_properties': this.syncScalarToModel,
739
- // 'enum_properties': this.syncEnumToModel,
740
- // 'color_properties': this.syncColorToModel,
741
- // 'array_properties': this.syncArrayToModel,
742
- // 'dict_properties': this.syncDictToModel,
743
- // 'function_properties': this.syncFunctionToModel,
744
- // 'vector_properties': this.syncVectorToModel,
745
- // };
746
-
747
636
_ . each ( this . property_converters , function ( converterName , propName ) {
748
637
if ( ! syncAllProps && ! ( propName in this . props_created_by_three ) ) {
749
638
return ;
@@ -779,71 +668,9 @@ var ThreeModel = widgets.DOMWidgetModel.extend({
779
668
mapperFn . bind ( this ) ( ) ;
780
669
} , this ) ;
781
670
782
- // _.each(arrayMappers, function(mapFn, arrayName) {
783
- // // class config defines the list of properties that are explicitly
784
- // // set by three.js.
785
- // // this method will only sync those properties back to the model
786
- // // in order to minimize the number of props set and sent to the server
787
-
788
- // var props = this[arrayName];
789
- // if (!syncAllProps) {
790
- // props = props.filter(function(propName) {
791
- // return (propName in this.props_created_by_three);
792
- // }, this);
793
- // }
794
-
795
- // props.forEach(function(propName) {
796
- // mapFn.bind(this)(propName);
797
- // }, this);
798
-
799
- // }, this);
800
-
801
671
this . save_changes ( ) ;
802
672
} ,
803
673
804
- // syncThreePropToModel: function(propName) {
805
- // // TODO: implement
806
- // },
807
-
808
- // syncThreeArrayToModel: function(propName) {
809
- // // TODO: implement
810
- // },
811
-
812
- // syncThreeDictToModel: function(propName) {
813
- // // TODO: implement
814
- // },
815
-
816
- // syncScalarToModel: function(propName) {
817
- // this.set(propName, this.obj[propName]);
818
- // },
819
-
820
- // syncEnumToModel: function(propName) {
821
- // var enumType = this.enum_property_types[propName];
822
- // var enumValues = Enums[enumType];
823
- // var enumValueName = enumValues[this.obj[propName]];
824
- // this.set(propName, enumValueName);
825
- // },
826
-
827
- // syncColorToModel: function(propName) {
828
- // this.set(propName, this.obj[propName].getHexString())
829
- // },
830
-
831
- // syncArrayToModel: function(propName) {
832
- // this.set(propName, this.obj[propName]);
833
- // },
834
-
835
- // syncDictToModel: function(propName) {
836
- // this.set(propName, this.obj[propName]);
837
- // },
838
-
839
- // syncFunctionToModel: function(propName) {
840
- // this.set(propName, this.obj[propName].toString());
841
- // },
842
-
843
- // syncVectorToModel: function(propName) {
844
- // this.set(propName, this.obj[propName].toArray());
845
- // },
846
-
847
674
//
848
675
// Conversions
849
676
//
0 commit comments