eg:
SceneLoader.LoadAssetContainer(
"./assets/model/",
"test3.obj",
this.scene,
(container) => {
this.scene.executeWhenReady(() => {
// Attach camera.
if (!this.scene.activeCamera) {
throw new Error("No camera defined in the scene. Please add at least one camera in the project or create one yourself in the code.");
}
container.meshes.forEach((mesh:any) => {
mesh.material = new PBRMetallicRoughnessMaterial(
"pbr",
this.scene
);
// mesh.position = new Vector3(0,20,0)
mesh.material.metallic = 0.0;
mesh.material.roughness = 1;
mesh.material.alpha = 1;
mesh.material.metallicF0Factor = 0;
mesh.material.useRoughnessFromMetallicTextureAlpha = false;
mesh.material.useRoughnessFromMetallicTextureGreen = true;
mesh.material.useMetallnessFromMetallicTextureBlue = true;
//截图是模型保持中心
mesh.material.useAmbientInGrayScale = true;
mesh.scaling.z = 4;
mesh.scaling.y = 4;
mesh.scaling.x = 4;
mesh.alwaysSelectAsActiveMesh = true
let uScale = 6;
let vScale = 6;
//颜色
mesh.material.baseTexture = new Texture(
'https://t7.baidu.com/it/u=1595072465,3644073269&fm=193&f=GIF',
this.scene
);
// mesh.material.baseTexture.uScale = uScale;
// mesh.material.baseTexture.vScale = vScale;
this.shadowGenerator.addShadowCaster(mesh);
});
container.addAllToScene();
});
},
null,
function (err) {
console.log("err", err);
}
);