File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed
Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -1885,7 +1885,7 @@ class LDrawLoader extends Loader {
18851885
18861886 }
18871887
1888- this . setMaterials ( materials ) ;
1888+ this . addMaterials ( materials ) ;
18891889
18901890 }
18911891
@@ -1907,7 +1907,7 @@ class LDrawLoader extends Loader {
19071907 fileLoader . load ( url , text => {
19081908
19091909 // Initializes the materials library with default materials
1910- this . setMaterials ( [ ] ) ;
1910+ this . addDefaultMaterials ( ) ;
19111911
19121912 this . partsCache
19131913 . parseModel ( text )
@@ -1950,14 +1950,36 @@ class LDrawLoader extends Loader {
19501950
19511951 setMaterials ( materials ) {
19521952
1953+ this . clearMaterials ( ) ;
1954+ this . addMaterials ( materials ) ;
1955+
1956+ return this ;
1957+
1958+ }
1959+
1960+ clearMaterials ( ) {
1961+
19531962 this . materialLibrary = { } ;
19541963 this . materials = [ ] ;
1964+
1965+ return this ;
1966+
1967+ }
1968+
1969+ addMaterials ( materials ) {
1970+
19551971 for ( let i = 0 , l = materials . length ; i < l ; i ++ ) {
19561972
19571973 this . addMaterial ( materials [ i ] ) ;
19581974
19591975 }
19601976
1977+ return this ;
1978+
1979+ }
1980+
1981+ addDefaultMaterials ( ) {
1982+
19611983 // Add default main triangle and line edge materials (used in pieces that can be colored with a main color)
19621984 this . addMaterial ( this . parseColorMetaDirective ( new LineParser ( 'Main_Colour CODE 16 VALUE #FF8080 EDGE #333333' ) ) ) ;
19631985 this . addMaterial ( this . parseColorMetaDirective ( new LineParser ( 'Edge_Colour CODE 24 VALUE #A0A0A0 EDGE #333333' ) ) ) ;
You can’t perform that action at this time.
0 commit comments