@@ -722,111 +722,4 @@ Object.assign(NodeMaterial.prototype, {
722
722
723
723
} ) ;
724
724
725
- var shadergraph = { } ;
726
-
727
- shadergraph . graphCounter = 0 ;
728
-
729
- shadergraph . nodeRegistry = { } ;
730
-
731
- shadergraph . _getNode = function ( name , funcString , declString ) {
732
- if ( ! this . nodeRegistry [ name ] ) {
733
- this . nodeRegistry [ name ] = new NodeMaterial ( funcString , declString ) ;
734
- }
735
-
736
- return this . nodeRegistry [ name ] ;
737
- } ;
738
-
739
- shadergraph . start = function ( ) {
740
- // check current graph is null?
741
- shadergraph . graph = this . _getNode ( 'graphRoot_' + shadergraph . graphCounter ) ;
742
- shadergraph . graph . name = 'graphRoot_' + shadergraph . graphCounter ;
743
- } ;
744
-
745
- shadergraph . end = function ( ) {
746
- var ret = shadergraph . graph ;
747
- shadergraph . graph = null ;
748
- shadergraph . graphCounter ++ ;
749
- return ret ;
750
- } ;
751
-
752
- shadergraph . textureSample2D = function ( name , texture , uv ) {
753
-
754
- var texSampNode = this . graph . addSubGraph ( this . _getNode ( 'texSample' , 'vec4 texSample(in sampler2D tex, in vec2 uv, out vec3 color, out float alpha) {\n vec4 samp=texture2D(tex, uv);\n color=samp.rgb;\n alpha=samp.a;\n return samp;\n}' ) ) ;
755
-
756
- // assumes name is unique TODO: verify?
757
- var graphVar = this . graph . addInput ( 'sampler2D' , name , texture ) ;
758
- this . graph . connect ( - 1 , graphVar . name , texSampNode , 'IN_tex' ) ;
759
- this . graph . connect ( uv , 'OUT_ret' , texSampNode , 'IN_uv' ) ;
760
-
761
- return texSampNode ;
762
- } ;
763
-
764
- shadergraph . customNode = function ( name , f , d ) {
765
- var nodeIndex = this . graph . addSubGraph ( this . _getNode ( name , f , d ) ) ;
766
- return nodeIndex ;
767
- } ;
768
-
769
- Object . defineProperty ( shadergraph , 'uv0' , {
770
- get : function ( ) {
771
- var nodeIndex = this . graph . addSubGraph ( this . _getNode ( 'uv0' , 'vec2 uv0() { return vUv0; }' ) ) ;
772
- return nodeIndex ;
773
- }
774
- } ) ;
775
-
776
- Object . defineProperty ( shadergraph , 'worldPosPS' , {
777
- get : function ( ) {
778
- var nodeIndex = this . graph . addSubGraph ( this . _getNode ( 'worldPosPS' , 'vec3 wpPS() { return vPosition; }' ) ) ;
779
- return nodeIndex ;
780
- }
781
- } ) ;
782
-
783
- Object . defineProperty ( shadergraph , 'worldNormPS' , {
784
- get : function ( ) {
785
- var nodeIndex = this . graph . addSubGraph ( this . _getNode ( 'worldNormPS' , 'vec3 wnPS() { return vNormal; }' ) ) ;
786
- return nodeIndex ;
787
- }
788
- } ) ;
789
-
790
- Object . defineProperty ( shadergraph , 'worldPosVS' , {
791
- get : function ( ) {
792
- var nodeIndex = this . graph . addSubGraph ( this . _getNode ( 'worldPosVS' , 'vec3 wpVS() { return getWorldPositionNM(); }' ) ) ;
793
- return nodeIndex ;
794
- }
795
- } ) ;
796
-
797
- Object . defineProperty ( shadergraph , 'worldNormVS' , {
798
- get : function ( ) {
799
- var nodeIndex = this . graph . addSubGraph ( this . _getNode ( 'worldNormVS' , 'vec3 wnVS() { return getWorldNormalNM(); }' ) ) ;
800
- return nodeIndex ;
801
- }
802
- } ) ;
803
-
804
- shadergraph . param = function ( type , name , value ) {
805
- // assumes name is unique TODO: verify this
806
- var graphVar = this . graph . addInput ( type , name , value ) ;
807
- return graphVar ;
808
- } ;
809
-
810
- shadergraph . connectFragOut = function ( nodeIndex , name ) {
811
- // assumes this is only called once per graph TODO: verify this
812
- var graphVar = this . graph . addOutput ( 'vec4' , 'fragOut' , [ 0 , 0 , 0 , 0 ] ) ;
813
- this . graph . connect ( nodeIndex , ( name ) ? 'OUT_' + name : 'OUT_ret' , - 1 , graphVar . name ) ;
814
- } ;
815
-
816
- shadergraph . connectVertexOffset = function ( nodeIndex , name ) {
817
- // assumes this is only called once per graph TODO: verify this
818
- var graphVar = this . graph . addOutput ( 'vec3' , 'vertOff' , [ 0 , 0 , 0 ] ) ;
819
- this . graph . connect ( nodeIndex , ( name ) ? 'OUT_' + name : 'OUT_ret' , - 1 , graphVar . name ) ;
820
- } ;
821
-
822
- shadergraph . connectCustom = function ( destNodeIndex , destName , nodeIndex_or_param , name ) {
823
- if ( typeof ( nodeIndex_or_param ) === 'number' ) {
824
- var nodeIndex = nodeIndex_or_param ;
825
- this . graph . connect ( nodeIndex , ( name ) ? 'OUT_' + name : 'OUT_ret' , destNodeIndex , 'IN_' + destName ) ;
826
- } else {
827
- var graphVar = nodeIndex_or_param ;
828
- this . graph . connect ( - 1 , graphVar . name , destNodeIndex , 'IN_' + destName ) ;
829
- }
830
- } ;
831
-
832
- export { NodeMaterial , shadergraph } ;
725
+ export { NodeMaterial } ;
0 commit comments