mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
add lighting to standard material
This commit is contained in:
Vendored
+40
-14
File diff suppressed because one or more lines are too long
@@ -100,6 +100,8 @@ export class CameraComponent extends Component {
|
||||
@property
|
||||
protected _rect = new Rect(0, 0, 1, 1);
|
||||
@property
|
||||
protected _screenScale = 1;
|
||||
@property
|
||||
protected _targetDisplay = -1;
|
||||
|
||||
protected _camera: Camera | null = null;
|
||||
@@ -112,7 +114,6 @@ export class CameraComponent extends Component {
|
||||
* !#en The projection type of the camera
|
||||
*
|
||||
* !#ch 相机的投影类型
|
||||
* @type {Number}
|
||||
*/
|
||||
@property({
|
||||
type: ProjectionType,
|
||||
@@ -129,8 +130,7 @@ export class CameraComponent extends Component {
|
||||
/**
|
||||
* !#en The camera field of view
|
||||
*
|
||||
* !#ch 相机的视野
|
||||
* @type {Number}
|
||||
* !#ch 相机的视角高度
|
||||
*/
|
||||
@property
|
||||
get fov () {
|
||||
@@ -145,8 +145,7 @@ export class CameraComponent extends Component {
|
||||
/**
|
||||
* !#en The camera height when in orthogonal mode
|
||||
*
|
||||
* !#ch 在正交模式下的相机高度
|
||||
* @type {Number}
|
||||
* !#ch 正交模式下的相机高度
|
||||
*/
|
||||
@property
|
||||
get orthoHeight () {
|
||||
@@ -161,8 +160,7 @@ export class CameraComponent extends Component {
|
||||
/**
|
||||
* !#en The near clipping distance of the camera
|
||||
*
|
||||
* !#ch 相机的最近剪切距离
|
||||
* @type {Number}
|
||||
* !#ch 相机的近平面
|
||||
*/
|
||||
@property
|
||||
get near () {
|
||||
@@ -177,8 +175,7 @@ export class CameraComponent extends Component {
|
||||
/**
|
||||
* !#en The far clipping distance of the camera
|
||||
*
|
||||
* !#ch 相机的最近剪切距离
|
||||
* @type {Number}
|
||||
* !#ch 相机的远平面
|
||||
*/
|
||||
@property
|
||||
get far () {
|
||||
@@ -191,10 +188,9 @@ export class CameraComponent extends Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* !#en The clearing color of the camera
|
||||
* !#en The color clearing value of the camera
|
||||
*
|
||||
* !#ch 在没有天空盒的情况下的屏幕颜色
|
||||
* @type {Color}
|
||||
* !#ch 相机的颜色缓冲默认值
|
||||
*/
|
||||
@property
|
||||
get color () {
|
||||
@@ -209,10 +205,9 @@ export class CameraComponent extends Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* !#en The clearing depth value of the camera
|
||||
* !#en The depth clearing value of the camera
|
||||
*
|
||||
* !#ch 清除相机的深度值
|
||||
* @type {Number}
|
||||
* !#ch 相机的深度缓冲默认值
|
||||
*/
|
||||
@property
|
||||
get depth () {
|
||||
@@ -225,10 +220,9 @@ export class CameraComponent extends Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* !#en The clearing stencil value of the camera
|
||||
* !#en The stencil clearing value of the camera
|
||||
*
|
||||
* !#ch 清除相机的模板值
|
||||
* @type {Number}
|
||||
* !#ch 相机的模板缓冲默认值
|
||||
*/
|
||||
@property
|
||||
get stencil () {
|
||||
@@ -243,8 +237,7 @@ export class CameraComponent extends Component {
|
||||
/**
|
||||
* !#en The clearing flags of this camera
|
||||
*
|
||||
* !#ch 清除相机标志位
|
||||
* @type {Number}
|
||||
* !#ch 相机的缓冲清除标志位
|
||||
*/
|
||||
@property({
|
||||
type: CameraClearFlag,
|
||||
@@ -259,10 +252,9 @@ export class CameraComponent extends Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* !#en The screen rect of the camera
|
||||
* !#en The screen viewport of the camera wrt. sceen size
|
||||
*
|
||||
* !#ch 相机的屏幕矩形
|
||||
* @type {Rect}
|
||||
* !#ch 相机相对屏幕的 viewport
|
||||
*/
|
||||
@property
|
||||
get rect () {
|
||||
@@ -274,6 +266,27 @@ export class CameraComponent extends Component {
|
||||
if (this._camera) { this._camera.viewport = val; }
|
||||
}
|
||||
|
||||
/**
|
||||
* !#en The scale of the interal buffer size,
|
||||
* set to 1 to keep the same with the canvas size
|
||||
*
|
||||
* !#ch 相机内部缓冲尺寸的缩放值, 1 为与 canvas 尺寸相同
|
||||
*/
|
||||
@property
|
||||
get screenScale () {
|
||||
return this._screenScale;
|
||||
}
|
||||
|
||||
set screenScale (val) {
|
||||
this._screenScale = val;
|
||||
if (this._camera) { this._camera.screenScale = val; }
|
||||
}
|
||||
|
||||
/**
|
||||
* !#en The target display for this Camera.
|
||||
*
|
||||
* !#ch 相机的目标屏幕序号
|
||||
*/
|
||||
@property
|
||||
get targetDisplay () {
|
||||
return this._targetDisplay;
|
||||
|
||||
@@ -131,23 +131,6 @@ export class LightComponent extends Component {
|
||||
@property
|
||||
protected _spotAngle = 60;
|
||||
|
||||
// @property
|
||||
// protected _shadowType = LightShadowType.None;
|
||||
// @property
|
||||
// protected _shadowResolution = 1024;
|
||||
// @property
|
||||
// protected _shadowDarkness = 0.5;
|
||||
// @property
|
||||
// protected _shadowMinDepth = 1;
|
||||
// @property
|
||||
// protected _shadowMaxDepth = 1000;
|
||||
// @property
|
||||
// protected _shadowDepthScale = 250;
|
||||
// @property
|
||||
// protected _shadowFrustumSize = 50;
|
||||
// @property
|
||||
// protected _shadowBias = 0.0005;
|
||||
|
||||
protected _light: Light | null = null;
|
||||
|
||||
/**
|
||||
|
||||
@@ -255,10 +255,6 @@ export class ParticleSystemComponent extends Component {
|
||||
this._isStopped = false;
|
||||
}
|
||||
|
||||
this._time = 0.0;
|
||||
this._emitRateTimeCounter = 0.0;
|
||||
this._emitRateDistanceCounter = 0.0;
|
||||
|
||||
this._isPlaying = true;
|
||||
|
||||
// prewarm
|
||||
|
||||
@@ -101,6 +101,7 @@ export default class ParticleSystemRenderer extends RenderableComponent {
|
||||
private _vertAttrs: IGFXInputAttribute[];
|
||||
private particleSystem: any;
|
||||
private _particles: RecyclePool;
|
||||
private _defaultMat: Material | null = null;
|
||||
|
||||
constructor () {
|
||||
super();
|
||||
@@ -156,7 +157,6 @@ export default class ParticleSystemRenderer extends RenderableComponent {
|
||||
|
||||
public clear () {
|
||||
this._particles.reset();
|
||||
this._model!.destroy();
|
||||
}
|
||||
|
||||
public _getFreeParticle (): Particle | null {
|
||||
@@ -277,9 +277,10 @@ export default class ParticleSystemRenderer extends RenderableComponent {
|
||||
if (!this.particleSystem) {
|
||||
return;
|
||||
}
|
||||
if (this.sharedMaterial == null) {
|
||||
this.setMaterial(builtinResMgr.get<Material>('default-particle-material'), 0, false);
|
||||
if (this.sharedMaterial == null && this._defaultMat == null) {
|
||||
this._defaultMat = Material.getInstantiatedMaterial(builtinResMgr.get<Material>('default-particle-material'), this, true);
|
||||
}
|
||||
const mat: Material | null = this.sharedMaterial ? this.getMaterial(0, CC_EDITOR)! : this._defaultMat;
|
||||
if (this.particleSystem._simulationSpace === Space.World) {
|
||||
this._defines[USE_WORLD_SPACE] = true;
|
||||
} else {
|
||||
@@ -311,14 +312,13 @@ export default class ParticleSystemRenderer extends RenderableComponent {
|
||||
} else {
|
||||
console.warn(`particle system renderMode ${this._renderMode} not support.`);
|
||||
}
|
||||
const mat = this.getMaterial(0, CC_EDITOR)!;
|
||||
mat.destroy();
|
||||
mat.initialize({ defines: this._defines });
|
||||
mat!.destroy();
|
||||
mat!.initialize({ defines: this._defines });
|
||||
|
||||
if (this.particleSystem.textureAnimationModule.enable) {
|
||||
this.getMaterial(0, CC_EDITOR)!.setProperty('frameTile_velLenScale', vec2.set(this.frameTile_velLenScale, this.particleSystem.textureAnimationModule.numTilesX, this.particleSystem.textureAnimationModule.numTilesY));
|
||||
mat!.setProperty('frameTile_velLenScale', vec2.set(this.frameTile_velLenScale, this.particleSystem.textureAnimationModule.numTilesX, this.particleSystem.textureAnimationModule.numTilesY));
|
||||
} else {
|
||||
this.getMaterial(0, CC_EDITOR)!.setProperty('frameTile_velLenScale', this.frameTile_velLenScale);
|
||||
mat!.setProperty('frameTile_velLenScale', this.frameTile_velLenScale);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ export default class ParticleSystemRenderer extends RenderableComponent {
|
||||
} else {
|
||||
this._model!.disableStretchedBillboard();
|
||||
}
|
||||
this._model!.setSubModelMaterial(0, this.sharedMaterial ? this.sharedMaterial : null);
|
||||
this._model!.setSubModelMaterial(0, this.sharedMaterial || this._defaultMat);
|
||||
// if (Object.getPrototypeOf(this).constructor.name === 'ParticleSystemGpuRenderer') {
|
||||
// return;
|
||||
// }
|
||||
|
||||
@@ -82,7 +82,6 @@ export class SkyboxComponent extends Component {
|
||||
@property
|
||||
protected _rgbeTexture = false;
|
||||
|
||||
protected _attachedCamera: Camera | null = null;
|
||||
protected _model: Model | null = null;
|
||||
protected _mesh: Mesh | null = null;
|
||||
protected _material: Material | null = null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { GFXAttributeName, GFXPrimitiveMode } from '../../gfx/define';
|
||||
export { default as find } from '../../scene-graph/find';
|
||||
export { find } from '../../scene-graph/find';
|
||||
import { Vec3 } from '../../core/value-types';
|
||||
import { AttributeBaseType, AttributeType,
|
||||
IMeshStruct, IndexUnit, IPrimitive, IVertexAttribute, IVertexBundle, Mesh } from '../assets/mesh';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
import { IPassInfo, IShaderInfo, ISamplerInfo } from '../../3d/assets/effect-asset';
|
||||
import { IPassInfo, IShaderInfo } from '../../3d/assets/effect-asset';
|
||||
import { builtinResMgr } from '../../3d/builtin';
|
||||
import { TextureBase } from '../../assets/texture-base';
|
||||
import { color4, mat2, mat3, mat4, vec2, vec3, vec4 } from '../../core/vmath';
|
||||
@@ -13,7 +13,7 @@ import { GFXPipelineLayout } from '../../gfx/pipeline-layout';
|
||||
import { GFXBlendState, GFXBlendTarget, GFXDepthStencilState,
|
||||
GFXInputState, GFXPipelineState, GFXRasterizerState } from '../../gfx/pipeline-state';
|
||||
import { GFXRenderPass } from '../../gfx/render-pass';
|
||||
import { GFXSampler, IGFXSamplerInfo, GFXSamplerState } from '../../gfx/sampler';
|
||||
import { GFXSampler, IGFXSamplerInfo } from '../../gfx/sampler';
|
||||
import { GFXShader } from '../../gfx/shader';
|
||||
import { GFXTextureView } from '../../gfx/texture-view';
|
||||
import { RenderPassStage, RenderPriority } from '../../pipeline/define';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { frustum, ray } from '../../3d/geom-utils';
|
||||
import { Color, Mat4, Rect, Vec3 } from '../../core/value-types';
|
||||
import { color4, lerp, mat4, toRadian, vec3 } from '../../core/vmath';
|
||||
import { Mat4, Rect, Vec3 } from '../../core/value-types';
|
||||
import { lerp, mat4, toRadian, vec3 } from '../../core/vmath';
|
||||
import { GFXClearFlag, IGFXColor } from '../../gfx/define';
|
||||
import { RenderView, RenderViewPriority } from '../../pipeline/render-view';
|
||||
import { RenderView } from '../../pipeline/render-view';
|
||||
import { Node } from '../../scene-graph/node';
|
||||
import { RenderScene } from './render-scene';
|
||||
|
||||
@@ -33,6 +33,7 @@ export class Camera {
|
||||
private _isWindowSize: boolean = true;
|
||||
private _width: number;
|
||||
private _height: number;
|
||||
private _screenScale: number;
|
||||
private _aspect: number;
|
||||
private _orthoHeight: number = 10.0;
|
||||
private _fov: number = toRadian(45);
|
||||
@@ -64,7 +65,7 @@ export class Camera {
|
||||
this._pipeline = info.pipeline || 'forward';
|
||||
this._priority = info.priority || 0;
|
||||
|
||||
this._aspect = this._width = this._height = 1;
|
||||
this._aspect = this._width = this._height = this._screenScale = 1;
|
||||
|
||||
this._view = scene.root.createView({
|
||||
camera: this,
|
||||
@@ -122,6 +123,14 @@ export class Camera {
|
||||
this._frustum.update(this._matViewProj, this._matViewProjInv);
|
||||
}
|
||||
|
||||
set screenScale (val) {
|
||||
this._screenScale = val;
|
||||
}
|
||||
|
||||
get screenScale () {
|
||||
return this._screenScale;
|
||||
}
|
||||
|
||||
set enabled (val) {
|
||||
this._enabled = val;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ function getConstructor (typeOrClassName: string | Function): Function | null {
|
||||
* @uses EventTarget
|
||||
* @method constructor
|
||||
* @param {String} [name]
|
||||
* @private
|
||||
* @protected
|
||||
*/
|
||||
@ccclass('cc._BaseNode')
|
||||
export class BaseNode extends CCObject {
|
||||
@@ -82,7 +82,7 @@ export class BaseNode extends CCObject {
|
||||
* @property _persistNode
|
||||
* @type {Boolean}
|
||||
* @default false
|
||||
* @private
|
||||
* @protected
|
||||
*/
|
||||
@property
|
||||
get _persistNode () {
|
||||
@@ -210,6 +210,8 @@ export class BaseNode extends CCObject {
|
||||
get activeInHierarchy () {
|
||||
return this._activeInHierarchy;
|
||||
}
|
||||
|
||||
@property
|
||||
get parent () {
|
||||
return this._parent;
|
||||
}
|
||||
@@ -229,13 +231,13 @@ export class BaseNode extends CCObject {
|
||||
}
|
||||
}
|
||||
|
||||
private static idGenerator = idGenerator;
|
||||
protected static idGenerator = idGenerator;
|
||||
|
||||
// For walk
|
||||
private static _stacks: Array<Array<(BaseNode | null)>> = [[]];
|
||||
private static _stackId = 0;
|
||||
protected static _stacks: Array<Array<(BaseNode | null)>> = [[]];
|
||||
protected static _stackId = 0;
|
||||
|
||||
private static _findComponent (node: BaseNode, constructor: Function) {
|
||||
protected static _findComponent (node: BaseNode, constructor: Function) {
|
||||
// tslint:disable-next-line
|
||||
if (constructor['_sealed']) {
|
||||
for (const comp of node._components) {
|
||||
@@ -253,7 +255,7 @@ export class BaseNode extends CCObject {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static _findComponents (node: BaseNode, constructor: Function, components: Component[]) {
|
||||
protected static _findComponents (node: BaseNode, constructor: Function, components: Component[]) {
|
||||
// tslint:disable-next-line
|
||||
if (constructor['_sealed']) {
|
||||
for (const comp of node._components) {
|
||||
@@ -270,7 +272,7 @@ export class BaseNode extends CCObject {
|
||||
}
|
||||
}
|
||||
|
||||
private static _findChildComponent (children: BaseNode[], constructor) {
|
||||
protected static _findChildComponent (children: BaseNode[], constructor) {
|
||||
for (const node of children) {
|
||||
let comp = BaseNode._findComponent(node, constructor);
|
||||
if (comp) {
|
||||
@@ -285,7 +287,7 @@ export class BaseNode extends CCObject {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static _findChildComponents (children: BaseNode[], constructor, components) {
|
||||
protected static _findChildComponents (children: BaseNode[], constructor, components) {
|
||||
for (const node of children) {
|
||||
BaseNode._findComponents(node, constructor, components);
|
||||
if (node._children.length > 0) {
|
||||
@@ -301,47 +303,47 @@ export class BaseNode extends CCObject {
|
||||
protected _children: this[] = [];
|
||||
|
||||
@property
|
||||
private _active = true;
|
||||
protected _active = true;
|
||||
|
||||
/**
|
||||
* @default 0
|
||||
*/
|
||||
@property
|
||||
private _level = 0;
|
||||
protected _level = 0;
|
||||
|
||||
/**
|
||||
* @default []
|
||||
* @readOnly
|
||||
*/
|
||||
@property
|
||||
private _components: Component[] = [];
|
||||
protected _components: Component[] = [];
|
||||
|
||||
/**
|
||||
* The PrefabInfo object
|
||||
* @type {PrefabInfo}
|
||||
*/
|
||||
@property
|
||||
private _prefab: any = null;
|
||||
protected _prefab: any = null;
|
||||
|
||||
/**
|
||||
* !#en which scene this node belongs to.
|
||||
* !#zh 此节点属于哪个场景。
|
||||
* @type {cc.Scene}}
|
||||
*/
|
||||
private _scene: any = null;
|
||||
protected _scene: any = null;
|
||||
|
||||
private _activeInHierarchy = false;
|
||||
protected _activeInHierarchy = false;
|
||||
|
||||
// TO DO
|
||||
// @ts-ignore
|
||||
private _id: string = CC_EDITOR ? Editor.Utils.UuidUtils.uuid() : idGenerator.getNewId();
|
||||
protected _id: string = CC_EDITOR ? Editor.Utils.UuidUtils.uuid() : idGenerator.getNewId();
|
||||
|
||||
/**
|
||||
* Register all related EventTargets,
|
||||
* all event callbacks will be removed in _onPreDestroy
|
||||
* private __eventTargets: EventTarget[] = [];
|
||||
* protected __eventTargets: EventTarget[] = [];
|
||||
*/
|
||||
private __eventTargets: any[] = [];
|
||||
protected __eventTargets: any[] = [];
|
||||
|
||||
get scene () {
|
||||
return this._scene;
|
||||
@@ -1123,7 +1125,7 @@ export class BaseNode extends CCObject {
|
||||
return cloned;
|
||||
}
|
||||
|
||||
private _onHierarchyChangedBase (oldParent: this | null) {
|
||||
protected _onHierarchyChangedBase (oldParent: this | null) {
|
||||
const newParent = this._parent;
|
||||
if (this._persistNode && !(newParent instanceof cc.Scene)) {
|
||||
cc.game.removePersistRootNode(this);
|
||||
@@ -1176,7 +1178,7 @@ export class BaseNode extends CCObject {
|
||||
}
|
||||
}
|
||||
|
||||
private _onPreDestroyBase () {
|
||||
protected _onPreDestroyBase () {
|
||||
// marked as destroying
|
||||
this._objFlags |= Destroying;
|
||||
|
||||
@@ -1229,7 +1231,7 @@ export class BaseNode extends CCObject {
|
||||
}
|
||||
|
||||
// do remove component, only used internally
|
||||
private _removeComponent (component: Component) {
|
||||
protected _removeComponent (component: Component) {
|
||||
if (!component) {
|
||||
cc.errorID(3814);
|
||||
return;
|
||||
@@ -1248,7 +1250,7 @@ export class BaseNode extends CCObject {
|
||||
}
|
||||
}
|
||||
|
||||
private _disableChildComps () {
|
||||
protected _disableChildComps () {
|
||||
// leave this._activeInHierarchy unmodified
|
||||
for (const component of this._components) {
|
||||
if (component._enabled) {
|
||||
@@ -1263,11 +1265,11 @@ export class BaseNode extends CCObject {
|
||||
}
|
||||
}
|
||||
|
||||
private _onSiblingIndexChanged? (siblingIndex: number): void;
|
||||
protected _onSiblingIndexChanged? (siblingIndex: number): void;
|
||||
|
||||
private _registerIfAttached? (attached: boolean): void;
|
||||
protected _registerIfAttached? (attached: boolean): void;
|
||||
|
||||
private _checkMultipleComp? (constructor: Function): boolean;
|
||||
protected _checkMultipleComp? (constructor: Function): boolean;
|
||||
}
|
||||
|
||||
baseNodePolyfill(BaseNode);
|
||||
|
||||
@@ -23,26 +23,21 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
import { Node } from './node';
|
||||
|
||||
/**
|
||||
* Finds a node by hierarchy path, the path is case-sensitive.
|
||||
* It will traverse the hierarchy by splitting the path using '/' character.
|
||||
* This function will still returns the node even if it is inactive.
|
||||
* It is recommended to not use this function every frame instead cache the result at startup.
|
||||
*
|
||||
* @method find
|
||||
* @static
|
||||
* @param {String} path
|
||||
* @param {Node} [referenceNode]
|
||||
* @return {Node|null} the node or null if not found
|
||||
*/
|
||||
export default function find (path, referenceNode) {
|
||||
export function find (path: string, referenceNode?: Node): Node | null {
|
||||
if (path == null) {
|
||||
cc.errorID(5600);
|
||||
return null;
|
||||
}
|
||||
if (!referenceNode) {
|
||||
var scene = cc.director.getScene();
|
||||
const scene = cc.director.getScene();
|
||||
if (!scene) {
|
||||
if (CC_DEV) {
|
||||
cc.warnID(5601);
|
||||
@@ -54,29 +49,29 @@ export default function find (path, referenceNode) {
|
||||
return null;
|
||||
}
|
||||
referenceNode = scene;
|
||||
}
|
||||
else if (CC_DEV && !referenceNode.isValid) {
|
||||
} else if (CC_DEV && !referenceNode.isValid) {
|
||||
cc.warnID(5603);
|
||||
return null;
|
||||
}
|
||||
|
||||
var match = referenceNode;
|
||||
var startIndex = (path[0] !== '/') ? 0 : 1; // skip first '/'
|
||||
var nameList = path.split('/');
|
||||
let match = referenceNode!;
|
||||
const startIndex = (path[0] !== '/') ? 0 : 1; // skip first '/'
|
||||
const nameList = path.split('/');
|
||||
|
||||
// parse path
|
||||
for (var n = startIndex; n < nameList.length; n++) {
|
||||
var name = nameList[n];
|
||||
var children = match._children;
|
||||
match = null;
|
||||
for (var t = 0, len = children.length; t < len; ++t) {
|
||||
var subChild = children[t];
|
||||
for (let n = startIndex; n < nameList.length; n++) {
|
||||
const name = nameList[n];
|
||||
const children = match.children;
|
||||
let found = false;
|
||||
for (let t = 0, len = children.length; t < len; ++t) {
|
||||
const subChild = children[t];
|
||||
if (subChild.name === name) {
|
||||
match = subChild;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!match) {
|
||||
if (!found) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -84,4 +79,4 @@ export default function find (path, referenceNode) {
|
||||
return match;
|
||||
}
|
||||
|
||||
cc.find = find;
|
||||
cc.find = find;
|
||||
@@ -27,8 +27,8 @@
|
||||
import './node-event-processor';
|
||||
export { BaseNode } from './base-node';
|
||||
export { Node } from './node';
|
||||
export { Scene } from './scene';
|
||||
export { Layers } from './layers';
|
||||
export { find } from './find';
|
||||
export { default as PrivateNode } from './private-node';
|
||||
export { default as NodeActivator } from './node-activator';
|
||||
export { default as Scene } from './scene';
|
||||
export { default as find } from './find';
|
||||
export { Layers } from './layers';
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,9 +23,17 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
import { Node } from './node';
|
||||
import { TextureCube } from '../3d/assets/texture-cube';
|
||||
import { ccclass, property } from '../core/data/class-decorator';
|
||||
import { RenderScene } from '../renderer/scene/render-scene';
|
||||
import { BaseNode } from './base-node';
|
||||
import { Node } from './node';
|
||||
|
||||
export interface IRenderSceneInfo {
|
||||
mainLight: Node;
|
||||
ambient: number[];
|
||||
skybox: TextureCube;
|
||||
}
|
||||
|
||||
/**
|
||||
* !#en
|
||||
@@ -37,39 +45,30 @@ import { BaseNode } from './base-node';
|
||||
* @class Scene
|
||||
* @extends Node
|
||||
*/
|
||||
@ccclass("cc.Scene")
|
||||
export default class Scene extends Node {
|
||||
@ccclass('cc.Scene')
|
||||
export class Scene extends Node {
|
||||
/**
|
||||
* !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading.
|
||||
* !#zh 指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。
|
||||
*/
|
||||
@property
|
||||
public autoReleaseAssets = false;
|
||||
|
||||
constructor(name) {
|
||||
protected _renderScene: RenderScene | null = null;
|
||||
|
||||
protected _inited = !cc.game._isCloning;
|
||||
protected _prefabSyncedInLiveReload = false;
|
||||
protected dependAssets = null; // cache all depend assets for auto release
|
||||
|
||||
constructor (name: string) {
|
||||
super(name);
|
||||
|
||||
this._activeInHierarchy = false;
|
||||
this._inited = !cc.game._isCloning;
|
||||
|
||||
if (CC_EDITOR) {
|
||||
this._prefabSyncedInLiveReload = false;
|
||||
}
|
||||
|
||||
// cache all depend assets for auto release
|
||||
this.dependAssets = null;
|
||||
|
||||
if (cc.director && cc.director.root) {
|
||||
this._renderScene = cc.director.root.createScene({});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading.
|
||||
* !#zh 指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。
|
||||
* @property {Boolean} autoReleaseAssets
|
||||
* @default false
|
||||
*/
|
||||
@property({
|
||||
type: cc.Boolean
|
||||
})
|
||||
autoReleaseAssets = undefined;
|
||||
|
||||
destroy() {
|
||||
public destroy () {
|
||||
super.destroy();
|
||||
cc.director.root.destroyScene(this._renderScene);
|
||||
this._activeInHierarchy = false;
|
||||
@@ -79,10 +78,10 @@ export default class Scene extends Node {
|
||||
return this._renderScene;
|
||||
}
|
||||
|
||||
_onHierarchyChanged() { }
|
||||
_instantiate() { }
|
||||
protected _onHierarchyChanged () { }
|
||||
protected _instantiate () { }
|
||||
|
||||
_load() {
|
||||
protected _load () {
|
||||
if (!this._inited) {
|
||||
if (CC_TEST) {
|
||||
cc.assert(!this._activeInHierarchy, 'Should deactivate ActionManager and EventManager by default');
|
||||
@@ -93,11 +92,11 @@ export default class Scene extends Node {
|
||||
this.walk(BaseNode._setScene);
|
||||
}
|
||||
|
||||
_activate(active) {
|
||||
protected _activate (active: boolean) {
|
||||
active = (active !== false);
|
||||
if (CC_EDITOR || CC_TEST) {
|
||||
// register all nodes to editor
|
||||
this._registerIfAttached(active);
|
||||
this._registerIfAttached!(active);
|
||||
}
|
||||
cc.director._nodeActivator.activateNode(this, active);
|
||||
}
|
||||
Reference in New Issue
Block a user