Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion examples/jsm/loaders/LDrawLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1948,15 +1948,27 @@ class LDrawLoader extends Loader {

}

/**
* Sets the loader's material library. This method clears existing
* material definitions.
*
* @param {Array<Material>} materials - The materials to set.
* @return {LDrawLoader} A reference to this loader.
*/
setMaterials( materials ) {

this.clearMaterials();
this.addMaterials(materials);
this.addMaterials( materials );

return this;

}

/**
* Clears the loader's material library.
*
* @return {LDrawLoader} A reference to this loader.
*/
clearMaterials() {

this.materialLibrary = {};
Expand All @@ -1966,6 +1978,12 @@ class LDrawLoader extends Loader {

}

/**
* Adds a list of materials to the loader's material library.
*
* @param {Array<Material>} materials - The materials to add.
* @return {LDrawLoader} A reference to this loader.
*/
addMaterials( materials ) {

for ( let i = 0, l = materials.length; i < l; i ++ ) {
Expand All @@ -1978,6 +1996,11 @@ class LDrawLoader extends Loader {

}

/**
* Initializes the loader with default materials.
*
* @return {LDrawLoader} A reference to this loader.
*/
addDefaultMaterials() {

// Add default main triangle and line edge materials (used in pieces that can be colored with a main color)
Expand All @@ -2004,6 +2027,12 @@ class LDrawLoader extends Loader {

}

/**
* Adds a single material to the loader's material library.
*
* @param {Material} material - The material to add.
* @return {LDrawLoader} A reference to this loader.
*/
addMaterial( material ) {

// Adds a material to the material library which is on top of the parse scopes stack. And also to the materials array
Expand Down