mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
fix some bug
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user