我尝试从我的场景中获取所有元素(mtl),但是当我从控制台获取信息时,它们是重复的。
这是我从我的控制台得到的:
T…E.MeshLambertMaterial {uuid: "21E85518-6197-4F4B-9F4C-86FE10ECF504", name: "", type: "MeshLambertMaterial", side: 0, opacity: 1…}
T…E.MeshLambertMaterial {uuid: "21E85518-6197-4F4B-9F4C-86FE10ECF504", name: "", type: "MeshLambertMaterial", side: 0, opacity: 1…}
T…E.MeshPhongMaterial {uuid: "D5BBE151-96DA-4562-9111-C5D66437C24F", name: "mtl_001", type: "MeshPhongMaterial", side: 0, opacity: 1…}
T…E.MeshPhongMaterial {uuid: "D5BBE151-96DA-4562-9111-C5D66437C24F", name: "mtl_001", type: "MeshPhongMaterial", side: 0, opacity: 1…}
T…E.MeshPhongMaterial {uuid: "D5BBE151-96DA-4562-9111-C5D66437C24F", name: "mtl_001", type: "MeshPhongMaterial", side: 0, opacity: 1…}
T…E.MeshPhongMaterial {uuid: "089A38A3-1EA9-4D81-9CBC-86D68EC1BE8A", name: "mtl_002", type: "MeshPhongMaterial", side: 0, opacity: 1…}
T…E.MeshPhongMaterial {uuid: "089A38A3-1EA9-4D81-9CBC-86D68EC1BE8A", name: "mtl_002", type: "MeshPhongMaterial", side: 0, opacity: 1…}
T…E.MeshPhongMaterial {uuid: "089A38A3-1EA9-4D81-9CBC-86D68EC1BE8A", name: "mtl_002", type: "MeshPhongMaterial", side: 0, opacity: 1…}
T…E.MeshPhongMaterial {uuid: "85FEB63E-6BB1-4C26-AA04-35E5BA06EA16", name: "mtl_003", type: "MeshPhongMaterial", side: 0, opacity: 1…}
T…E.MeshPhongMaterial {uuid: "85FEB63E-6BB1-4C26-AA04-35E5BA06EA16", name: "mtl_003", type: "MeshPhongMaterial", side: 0, opacity: 1…}
T…E.MeshPhongMaterial {uuid: "85FEB63E-6BB1-4C26-AA04-35E5BA06EA16", name: "mtl_003", type: "MeshPhongMaterial", side: 0, opacity: 1…}
T…E.MeshPhongMaterial {uuid: "2687646E-2E42-4132-A2D4-3A71CB2B5671", name: "mtl_004", type: "MeshPhongMaterial", side: 0, opacity: 1…}
T…E.MeshPhongMaterial {uuid: "2687646E-2E42-4132-A2D4-3A71CB2B5671", name: "mtl_004", type: "MeshPhongMaterial", side: 0, opacity: 1…}
T…E.MeshPhongMaterial {uuid: "2687646E-2E42-4132-A2D4-3A71CB2B5671", name: "mtl_004", type: "MeshPhongMaterial", side: 0, opacity: 1…}
T…E.MeshPhongMaterial {uuid: "AF4DB0B3-71AB-4C27-9C5B-8CB146A8E979", name: "mtl_005", type: "MeshPhongMaterial", side: 0, opacity: 1…}
T…E.MeshPhongMaterial {uuid: "AF4DB0B3-71AB-4C27-9C5B-8CB146A8E979", name: "mtl_005", type: "MeshPhongMaterial", side: 0, opacity: 1…}
T…E.MeshPhongMaterial {uuid: "AF4DB0B3-71AB-4C27-9C5B-8CB146A8E979", name: "mtl_005", type: "MeshPhongMaterial", side: 0, opacity: 1…}
T…E.MeshPhongMaterial {uuid: "08E65746-AF2B-43EA-B36E-F927E54D05A7", name: "mtl_006", type: "MeshPhongMaterial", side: 0, opacity: 1…}
T…E.MeshPhongMaterial {uuid: "08E65746-AF2B-43EA-B36E-F927E54D05A7", name: "mtl_006", type: "MeshPhongMaterial", side: 0, opacity: 1…}
T…E.MeshPhongMaterial {uuid: "08E65746-AF2B-43EA-B36E-F927E54D05A7", name: "mtl_006", type: "MeshPhongMaterial", side: 0, opacity: 1…}
T…E.MeshPhongMaterial {uuid: "C58AC913-C1CA-4E14-AE83-41B473E55D66", name: "mtl_default", type: "MeshPhongMaterial", side: 0, opacity: 1…}
这是我的调试代码:
loader = new THREE.OBJMTLLoader();
loader.load( "{{ asset('/models/obj/chair/chair.obj') }}", "{{ asset('/models/obj/chair/chair.mtl') }}", function ( object ) {
object.traverse(function(child) {
if (child instanceof THREE.Mesh) {
console.log(child.material);
}
});
有任何解释吗?