fix some bug

This commit is contained in:
zhuxuguang
2019-01-22 17:21:55 +08:00
committed by Yun Hsiao Wu
parent a074b2c217
commit a62bfdb768
2 changed files with 14 additions and 12 deletions
+3 -3
View File
@@ -175,7 +175,6 @@ export class ModelComponent extends RenderableComponent {
this._updateModels();
this._updateCastShadow();
this._updateReceiveShadow();
this._model.enable = true;
}
onDisable() {
@@ -198,6 +197,7 @@ export class ModelComponent extends RenderableComponent {
} else {
this._model = this._createModel();
}
this._model.enable = this.enabled;
this._model.createBoundingShape(this._mesh.minPosition, this._mesh.maxPosition);
@@ -235,7 +235,7 @@ export class ModelComponent extends RenderableComponent {
}
_updateCastShadow() {
if (!this.enabled)
if (!this.enabled || !this._model)
return;
if (this._shadowCastingMode === ModelShadowCastingMode.Off) {
for (let i = 0; i < this._model.subModelNum; ++i) {
@@ -253,7 +253,7 @@ export class ModelComponent extends RenderableComponent {
}
_updateReceiveShadow() {
if (!this.enabled)
if (!this.enabled || !this._model)
return;
for (let i = 0; i < this._model.subModelNum; ++i) {
let subModel = this._model.getSubModel(i);
+11 -9
View File
@@ -286,7 +286,7 @@ export class BaseNode extends CCObject {
private static _findChildComponents (children: BaseNode[], constructor, components) {
for (const node of children) {
BaseNode._findComponents (node, constructor, components);
BaseNode._findComponents(node, constructor, components);
if (node._children.length > 0) {
BaseNode._findChildComponents(node._children, constructor, components);
}
@@ -1058,13 +1058,15 @@ export class BaseNode extends CCObject {
return;
}
public emit? (type: string, ...args: any[]): void;
public emit?(type: string, ...args: any[]): void;
protected _onSetParent (oldParent: this | null) {
if ((oldParent == null || oldParent._scene !== this._parent!._scene) && this._parent!._scene != null) {
this.walk((node) => {
BaseNode._setScene(node);
});
if (this._parent) {
if ((oldParent == null || oldParent._scene !== this._parent._scene) && this._parent._scene != null) {
this.walk((node) => {
BaseNode._setScene(node);
});
}
}
}
@@ -1252,11 +1254,11 @@ export class BaseNode extends CCObject {
}
}
private _onSiblingIndexChanged? (siblingIndex: number): void;
private _onSiblingIndexChanged?(siblingIndex: number): void;
private _registerIfAttached? (attached: boolean): void;
private _registerIfAttached?(attached: boolean): void;
private _checkMultipleComp? (constructor: Function): boolean;
private _checkMultipleComp?(constructor: Function): boolean;
private _onPreDestroyBase () {
return this._onPreDestroy();