scene-graph migration (#3250)

* put 2d node aside

* migrate 3d node
This commit is contained in:
Yun Hsiao Wu
2018-09-17 14:43:12 +08:00
committed by pandamicro
parent 0d03bcf4bf
commit f26e1db2e6
6 changed files with 3373 additions and 3008 deletions
+32 -38
View File
@@ -26,7 +26,6 @@
import * as js from '../core/utils/js';
import IdGenerater from '../core/utils/id-generater';
import eventManager from '../core/platform/event-manager/CCEventManager';
import CCObject from '../core/data/object';
import _decorator from '../core/data/class-decorator';
const { ccclass, property } = _decorator;
@@ -341,6 +340,9 @@ export default class BaseNode extends CCObject {
getParent () {
return this._parent;
}
get parent() {
return this._parent;
}
/**
* !#en Set parent of the node.
@@ -365,14 +367,13 @@ export default class BaseNode extends CCObject {
}
this._parent = value || null;
this._onSetParent(value);
this._onSetParent(oldParent);
if (value) {
if (CC_DEBUG && (value._objFlags & Deactivating)) {
cc.errorID(3821);
}
this._level = value._level + 1;
eventManager._setDirtyForNode(this);
value._children.push(this);
value.emit && value.emit(CHILD_ADDED, this);
}
@@ -384,12 +385,12 @@ export default class BaseNode extends CCObject {
}
oldParent._children.splice(removeAt, 1);
oldParent.emit && oldParent.emit(CHILD_REMOVED, this);
this._onHierarchyChanged(oldParent);
}
}
else if (value) {
this._onHierarchyChanged(null);
}
this._onHierarchyChanged(oldParent);
}
set parent(value) {
this.setParent(value);
}
// ABSTRACT INTERFACES
@@ -650,10 +651,6 @@ export default class BaseNode extends CCObject {
BaseNode._stackId--;
}
cleanup () {
}
/**
* !#en
* Remove itself from its parent node. If cleanup is `true`, then also remove all events and actions. <br/>
@@ -1034,7 +1031,8 @@ export default class BaseNode extends CCObject {
}
}
_onSetParent (/*value*/) {}
cleanup () {}
_onSetParent (/*oldParent*/) {}
_onPostActivated () {}
_onBatchRestored () {}
_onBatchCreated () {}
@@ -1263,6 +1261,18 @@ if (CC_EDITOR) {
cc.director._nodeActivator.activateNode(this, shouldActiveNow);
}
};
BaseNode.prototype._onPreDestroy = function () {
var destroyByParent = this._onPreDestroyBase();
if (!destroyByParent) {
// ensure this node can reattach to scene by undo system
// (simulate some destruct logic to make undo system work correctly)
this._parent = null;
}
return destroyByParent;
};
BaseNode.prototype._onRestoreBase = BaseNode.prototype.onRestore;
}
if (CC_EDITOR || CC_TEST) {
@@ -1292,32 +1302,6 @@ if (CC_EDITOR || CC_TEST) {
};
}
BaseNode.idGenerater = idGenerater;
// For walk
BaseNode._stacks = [[]];
BaseNode._stackId = 0;
BaseNode.prototype._onPreDestroyBase = BaseNode.prototype._onPreDestroy;
if (CC_EDITOR) {
BaseNode.prototype._onPreDestroy = function () {
var destroyByParent = this._onPreDestroyBase();
if (!destroyByParent) {
// ensure this node can reattach to scene by undo system
// (simulate some destruct logic to make undo system work correctly)
this._parent = null;
}
return destroyByParent;
};
}
BaseNode.prototype._onHierarchyChangedBase = BaseNode.prototype._onHierarchyChanged;
if(CC_EDITOR) {
BaseNode.prototype._onRestoreBase = BaseNode.prototype.onRestore;
}
if (CC_DEV) {
// promote debug info
js.get(BaseNode.prototype, ' INFO ', function () {
@@ -1336,6 +1320,16 @@ if (CC_DEV) {
});
}
BaseNode.idGenerater = idGenerater;
// For walk
BaseNode._stacks = [[]];
BaseNode._stackId = 0;
BaseNode.prototype._onPreDestroyBase = BaseNode.prototype._onPreDestroy;
BaseNode.prototype._onHierarchyChangedBase = BaseNode.prototype._onHierarchyChanged;
/**
* !#en
* Note: This event is only emitted from the top most node whose active value did changed,
-2
View File
@@ -26,8 +26,6 @@
import CCObject from '../core/data/object';
import { array } from '../core/utils/js';
import _decorator from '../core/data/class-decorator';
const { ccclass } = _decorator;
var IsStartCalled = CCObject.Flags.IsStartCalled;
var IsOnEnableCalled = CCObject.Flags.IsOnEnableCalled;
-1
View File
@@ -27,6 +27,5 @@
export { default as BaseNode } from './base-node';
export { default as Node } from './node';
export { default as NodeActivator } from './node-activator';
export { default as PrivateNode } from './private-node';
export { default as Scene } from './scene';
export { default as find } from './find';
File diff suppressed because it is too large Load Diff
-2
View File
@@ -28,8 +28,6 @@ import CompScheduler from './component-scheduler';
import CCObject from '../core/data/object';
import { Pool, array } from '../core/utils/js';
import { tryCatchFunctor_EDITOR } from '../core/utils/misc';
import _decorator from '../core/data/class-decorator';
const { ccclass } = _decorator;
var MAX_POOL_SIZE = 4;
+318 -2965
View File
File diff suppressed because it is too large Load Diff