@@ -389,11 +389,8 @@ const gltfToFlowGraphMapping: { [key: string]: IGLTFToFlowGraphMapping } = {
389
389
validation ( gltfBlock ) {
390
390
// make sure types are the same
391
391
if ( gltfBlock . values ) {
392
- const types = Object . keys ( gltfBlock . values ) . map ( ( key ) => gltfBlock . values ! [ key ] . type ) ;
393
- const allSameType = types . every ( ( type ) => type === undefined || type === types [ 0 ] ) ;
394
- if ( ! allSameType ) {
395
- return { valid : false , error : "All inputs must be of the same type" } ;
396
- }
392
+ // make sure types are the same
393
+ return ValidateTypes ( gltfBlock ) ;
397
394
}
398
395
return { valid : true } ;
399
396
} ,
@@ -1619,19 +1616,26 @@ function getSimpleInputMapping(type: FlowGraphBlockNames, inputs: string[] = ["a
1619
1616
validation ( gltfBlock ) {
1620
1617
if ( inferType ) {
1621
1618
// make sure types are the same
1622
- if ( gltfBlock . values ) {
1623
- const types = Object . keys ( gltfBlock . values ) . map ( ( key ) => gltfBlock . values ! [ key ] . type ) ;
1624
- const allSameType = types . every ( ( type ) => type === undefined || type === types [ 0 ] ) ;
1625
- if ( ! allSameType ) {
1626
- return { valid : false , error : "All inputs must be of the same type" } ;
1627
- }
1628
- }
1619
+ return ValidateTypes ( gltfBlock ) ;
1629
1620
}
1630
1621
return { valid : true } ;
1631
1622
} ,
1632
1623
} ;
1633
1624
}
1634
1625
1626
+ function ValidateTypes ( gltfBlock : IKHRInteractivity_Node ) : { valid : boolean ; error ?: string } {
1627
+ if ( gltfBlock . values ) {
1628
+ const types = Object . keys ( gltfBlock . values )
1629
+ . map ( ( key ) => gltfBlock . values ! [ key ] . type )
1630
+ . filter ( ( type ) => type !== undefined ) ;
1631
+ const allSameType = types . every ( ( type ) => type === types [ 0 ] ) ;
1632
+ if ( ! allSameType ) {
1633
+ return { valid : false , error : "All inputs must be of the same type" } ;
1634
+ }
1635
+ }
1636
+ return { valid : true } ;
1637
+ }
1638
+
1635
1639
export function getAllSupportedNativeNodeTypes ( ) : string [ ] {
1636
1640
return Object . keys ( gltfToFlowGraphMapping ) ;
1637
1641
}
0 commit comments