From 905b5f70813be505191e29901a48b59d0f8ffcf2 Mon Sep 17 00:00:00 2001 From: zhuxuguang <247274249@qq.com> Date: Tue, 22 Jan 2019 16:42:54 +0800 Subject: [PATCH] fix default material --- cocos/3d/builtin/init.js | 1 + cocos/3d/framework/model-component.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cocos/3d/builtin/init.js b/cocos/3d/builtin/init.js index 62843f198f..6ace146fb3 100644 --- a/cocos/3d/builtin/init.js +++ b/cocos/3d/builtin/init.js @@ -107,6 +107,7 @@ let builtinResMgr = { // [defaultTextureCube._uuid]: defaultTextureCub [blackTexture._uuid]: blackTexture, [whiteTexture._uuid]: whiteTexture, + [defaultMtl._uuid]: defaultMtl, [spriteMtl._uuid]: spriteMtl, [spriteFrame._uuid]:spriteFrame }; diff --git a/cocos/3d/framework/model-component.js b/cocos/3d/framework/model-component.js index d9472711ae..5195ebde8c 100644 --- a/cocos/3d/framework/model-component.js +++ b/cocos/3d/framework/model-component.js @@ -189,7 +189,7 @@ export class ModelComponent extends RenderableComponent { } _updateModels(forceUpdate) { - if (!this.enabled || !this.node._scene || (this._model && !forceUpdate)) { + if (!this.enabled || !this.node._scene || !this._mesh || (this._model && !forceUpdate)) { return; } @@ -214,7 +214,7 @@ export class ModelComponent extends RenderableComponent { for (let i = 0; i < meshCount; ++i) { let material = this.getSharedMaterial(i); let subMeshData = this._mesh.renderingMesh.getSubmesh(i); - this._model.initSubModel(i, subMeshData, material); + this._model.initSubModel(i, subMeshData, material || this._getBuiltinMaterial()); } }