I am interested in exploring the new MaterialShading function. I have created a Manipulate object with two fields for making a Graphics3d object of ExampleData's built-in cases. The first parameter relates to the material the object is made of, and the second relates to which object in ExampleData["Geometry3D"] is displayed. I would like to somehow introduce a third field if the user selects Plastic or Glazed for color. I have used the following resources:

A generalization of this question:

  • Given a function that accepts n number of arguments f[e1,e2,e3,...en]
  • where not all arguments are required
  • and the last argument is only applicable to certain inputs for the first inputs
  • how to create a Manipulate object that works around this.
   ExampleData[{"Geometry3D", object}, "GraphicsComplex"]}, 
  Boxed -> False, 
  Lighting -> "ThreePoint"], {material, {"Aluminum", "Brass", 
   "Bronze", "Copper", "Electrum", "Gold", "Iron", "Pewter", "Silver",
    "Clay", "Foil", "Glazed", "Plastic", "Rubber", "Satin", 
   "Velvet"}}, {object, ExampleData["Geometry3D"][[All, 2]]}]
  • $\begingroup$ Please provide a concrete example and the code that you have tried. Explain what specific problems you are having. $\endgroup$
    – Bob Hanlon
    Commented Nov 25, 2021 at 14:49
  • $\begingroup$ I forgot! I meant to add my code. Please consider un downvoting my question. $\endgroup$ Commented Nov 25, 2021 at 14:56
  • $\begingroup$ There are 16 materials and 27 objects for a total of 432 combinations. Which of the combinations are known to cause problems and what is the nature of the problem? $\endgroup$
    – Bob Hanlon
    Commented Nov 25, 2021 at 15:23
  • $\begingroup$ I want to add a field for the color of plastic and glazed materials when those are selected as the materials. $\endgroup$ Commented Nov 25, 2021 at 16:04

2 Answers 2


A brute force approach is to just nest two Manipulates.

  Boxed -> False,
  Lighting -> "ThreePoint"];

 If[(material === "Plastic" || material === "Glazed"), Manipulate[
     MaterialShading[{material, color}],
     ExampleData[{"Geometry3D", object}, "GraphicsComplex"]}],
   {color, ColorSlider},
   Paneled -> False],
    ExampleData[{"Geometry3D", object}, "GraphicsComplex"]}]],
   Control[{{material, "Plastic"},
     {"Aluminum", "Brass", "Bronze", "Copper", "Electrum", "Gold", 
      "Iron", "Pewter", "Silver", "Clay", "Foil", "Glazed", "Plastic",
       "Rubber", "Satin", "Velvet"}}],
     ExampleData["Geometry3D"][[All, 2]]}]}],
 TrackedSymbols :> All]

enter image description here

materials =   {"Aluminum", "Brass", "Bronze", "Copper", "Electrum", "Gold", "Iron",
 "Pewter", "Silver", "Clay", "Foil", "Glazed", "Plastic", "Rubber", "Satin", "Velvet"};

objects = ExampleData["Geometry3D"][[All, 2]];

assoc = Association[# -> ExampleData[{"Geometry3D", #}, "GraphicsComplex"]& /@ objects];

We can use a single Manipulate with the control color added only if material is "Plastic" or "Glazed":

       MaterialShading[material /. m : "Plastic" | "Glazed" -> {m, color}],
       assoc @ object},
      Boxed -> False, Lighting -> "ThreePoint"],
  Row[{Control[{{material, "Plastic"}, materials }],
       Dynamic @ If[(material === "Plastic" || material === "Glazed"), 
           Row[{ Control@{{color, Red}, ColorSlider}, Spacer[50]}], 
       Control[{object, objects}]}]] 

enter image description here


       MaterialShading[material /. m : "Plastic" | "Glazed" -> {m, color}],
       assoc @ object}, 
    Boxed -> False,  Lighting -> "ThreePoint"],
Dynamic @ If[material === "Plastic" || material === "Glazed", 
   Row[{Control @ { {material, "Plastic"}, materials }, 
        Control @ {{color, Red}, ColorSlider}, 
        Control @ {object, objects  }}, Spacer[20]], 
   Row[{Control@{ {material, "Plastic"}, materials }, 
        Control @ {object, objects}}, Spacer[20]]]]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.