@@ -499,19 +499,28 @@ var ThreeModel = widgets.WidgetModel.extend({
499
499
} ,
500
500
501
501
convertBoolThreeToModel : function ( v ) {
502
+ if ( v === null ) {
503
+ return null ;
504
+ }
502
505
// Coerce falsy/truthy:
503
506
return ! ! v ;
504
507
} ,
505
508
506
509
// Enum
507
510
convertEnumModelToThree : function ( e ) {
511
+ if ( e === null ) {
512
+ return null ;
513
+ }
508
514
return THREE [ e ] ;
509
515
} ,
510
516
511
517
convertEnumThreeToModel : function ( e , propName ) {
518
+ if ( e === null ) {
519
+ return null ;
520
+ }
512
521
var enumType = this . enum_property_types [ propName ] ;
513
522
var enumValues = Enums [ enumType ] ;
514
- var enumValueName = enumValues [ this . obj [ propName ] ] ;
523
+ var enumValueName = enumValues [ e ] ;
515
524
return enumValueName ;
516
525
} ,
517
526
@@ -705,6 +714,9 @@ var ThreeModel = widgets.WidgetModel.extend({
705
714
} ,
706
715
707
716
convertUniformDictModelToThree : function ( modelDict ) {
717
+ if ( modelDict === null ) {
718
+ return null ;
719
+ }
708
720
// Convert any strings to THREE.Color
709
721
// Just modify dict in-place, as it should serialize the same
710
722
Object . keys ( modelDict ) . forEach ( function ( k ) {
@@ -772,23 +784,35 @@ var ThreeModel = widgets.WidgetModel.extend({
772
784
773
785
// ArrayBuffer
774
786
convertArrayBufferModelToThree : function ( arr ) {
787
+ if ( arr === null ) {
788
+ return null ;
789
+ }
775
790
if ( arr instanceof widgets . WidgetModel ) {
776
791
return arr . get ( 'array' ) . data ;
777
792
}
778
793
return arr . data ;
779
794
} ,
780
795
781
796
convertArrayBufferThreeToModel : function ( arrBuffer ) {
797
+ if ( arrBuffer === null ) {
798
+ return null ;
799
+ }
782
800
// Never back-convert to a new widget
783
801
return ndarray ( arrBuffer ) ;
784
802
} ,
785
803
786
804
// Color
787
805
convertColorModelToThree : function ( c ) {
806
+ if ( c === null ) {
807
+ return null ;
808
+ }
788
809
return new THREE . Color ( c ) ;
789
810
} ,
790
811
791
812
convertColorThreeToModel : function ( c ) {
813
+ if ( c === null ) {
814
+ return null ;
815
+ }
792
816
return '#' + c . getHexString ( ) ;
793
817
} ,
794
818
0 commit comments