diff --git a/cocos/3d/assets/mesh.jsb.ts b/cocos/3d/assets/mesh.jsb.ts index 98bd979074..876e9ea784 100644 --- a/cocos/3d/assets/mesh.jsb.ts +++ b/cocos/3d/assets/mesh.jsb.ts @@ -23,7 +23,6 @@ THE SOFTWARE. */ import { ccclass, serializable } from 'cc.decorator'; -import { _applyDecoratedDescriptor } from '../../core/data/utils/decorator-jsb-utils'; import { legacyCC } from '../../core/global-exports'; export declare namespace Mesh { @@ -47,34 +46,8 @@ const meshAssetProto: any = jsb.Mesh.prototype; meshAssetProto.createNode = null!; -const clsDecorator = ccclass('cc.Mesh'); - -const _class2$V = Mesh; - -const _descriptor$M = _applyDecoratedDescriptor(_class2$V.prototype, '_struct', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return { - vertexBundles: [], - primitives: [], - }; - }, -}); -const _descriptor2$y = _applyDecoratedDescriptor(_class2$V.prototype, '_hash', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return 0; - }, -}); - meshAssetProto._ctor = function () { jsb.Asset.prototype._ctor.apply(this, arguments); - // _initializerDefineProperty(_this, "_struct", _descriptor$M, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, "_hash", _descriptor2$y, _assertThisInitialized(_this)); this._struct = { vertexBundles: [], primitives: [], @@ -95,6 +68,10 @@ meshAssetProto.onLoaded = function () { this._struct = null; }; -clsDecorator(Mesh); - legacyCC.Mesh = jsb.Mesh; + +// handle meta data, it is generated automatically +const MeshProto = Mesh.prototype; +serializable(MeshProto, '_struct'); +serializable(MeshProto, '_hash'); +ccclass('cc.Mesh')(Mesh); diff --git a/cocos/3d/assets/skeleton.jsb.ts b/cocos/3d/assets/skeleton.jsb.ts index f6dd8dc5b7..736c3a2941 100644 --- a/cocos/3d/assets/skeleton.jsb.ts +++ b/cocos/3d/assets/skeleton.jsb.ts @@ -34,15 +34,12 @@ import { Mat4 } from '../../core/math'; import { DataPoolManager } from '../skeletal-animation/data-pool-manager'; import { Asset } from '../../core/assets/asset'; import { legacyCC } from '../../core/global-exports'; -import { _applyDecoratedDescriptor } from '../../core/data/utils/decorator-jsb-utils'; export const Skeleton = jsb.Skeleton; export type Skeleton = jsb.Skeleton; legacyCC.Skeleton = Skeleton; const skeletonProto: any = Skeleton.prototype; -const skeletonDecorator = ccclass('cc.Skeleton'); - Object.defineProperty(skeletonProto, 'bindposes', { enumerable: true, configurable: true, @@ -55,35 +52,6 @@ Object.defineProperty(skeletonProto, 'bindposes', { }, }); -const _dec2$1 = type([CCString]); -const _dec3$1 = type([Mat4]); - -const _descriptor$2 = _applyDecoratedDescriptor(skeletonProto, '_joints', [_dec2$1], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return []; - }, -}); - -const _descriptor2$2 = _applyDecoratedDescriptor(skeletonProto, '_bindposes', [_dec3$1], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return []; - }, -}); - -const _descriptor3$1 = _applyDecoratedDescriptor(skeletonProto, '_hash', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return 0; - }, -}); skeletonProto._ctor = function () { jsb.Asset.prototype._ctor.apply(this, arguments); @@ -101,4 +69,9 @@ skeletonProto.onLoaded = function () { oldSkeletonProtoOnLoaded.call(this); }; -skeletonDecorator(Skeleton); +// handle meta data, it is generated automatically +const SkeletonProto = Skeleton.prototype; +type([CCString])(SkeletonProto, '_joints'); +type([Mat4])(SkeletonProto, '_bindposes'); +serializable(SkeletonProto, '_hash'); +ccclass('cc.Skeleton')(Skeleton); \ No newline at end of file diff --git a/cocos/core/assets/asset.jsb.ts b/cocos/core/assets/asset.jsb.ts index 4ec48ddef4..a6ddd3a536 100644 --- a/cocos/core/assets/asset.jsb.ts +++ b/cocos/core/assets/asset.jsb.ts @@ -22,9 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import { ccclass, editable, serializable } from 'cc.decorator'; +import { ccclass, serializable } from 'cc.decorator'; import { - _applyDecoratedDescriptor, _assertThisInitialized, _initializerDefineProperty, } from '../data/utils/decorator-jsb-utils'; @@ -124,20 +123,11 @@ assetProto.createNode = null!; export type Asset = jsb.Asset; export const Asset = jsb.Asset; -const clsDecorator = ccclass('cc.Asset'); - -const _class2$1 = Asset; -const _descriptor$1 = _applyDecoratedDescriptor(_class2$1.prototype, '_native', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return ''; - }, -}); - -_applyDecoratedDescriptor(_class2$1.prototype, '_nativeAsset', [property], Object.getOwnPropertyDescriptor(_class2$1.prototype, '_nativeAsset'), _class2$1.prototype); - -clsDecorator(Asset); - legacyCC.Asset = jsb.Asset; + +// handle meta data, it is generated automatically +const AssetProto = Asset.prototype; +serializable(AssetProto, '_native'); +const _nativeAssetDescriptor = Object.getOwnPropertyDescriptor(AssetProto, '_nativeAsset'); +property(AssetProto, '_nativeAsset', _nativeAssetDescriptor); +ccclass('cc.Asset')(Asset); \ No newline at end of file diff --git a/cocos/core/assets/buffer-asset.jsb.ts b/cocos/core/assets/buffer-asset.jsb.ts index 24aa37b0f6..376326821e 100644 --- a/cocos/core/assets/buffer-asset.jsb.ts +++ b/cocos/core/assets/buffer-asset.jsb.ts @@ -23,21 +23,15 @@ THE SOFTWARE. */ import { ccclass, override } from 'cc.decorator'; -import { - _applyDecoratedDescriptor, - _assertThisInitialized, - _initializerDefineProperty, -} from '../data/utils/decorator-jsb-utils'; import { legacyCC } from '../global-exports'; export type BufferAsset = jsb.BufferAsset; export const BufferAsset = jsb.BufferAsset; -const clsDecorator = ccclass('cc.BufferAsset'); - -const _class2$D = BufferAsset; -//cjh FIXME: _applyDecoratedDescriptor(_class2$D.prototype, '_nativeAsset', [override], Object.getOwnPropertyDescriptor(_class2$D.prototype, '_nativeAsset'), _class2$D.prototype); - -clsDecorator(BufferAsset); - legacyCC.BufferAsset = jsb.BufferAsset; + +// handle meta data, it is generated automatically +const BufferAssetProto = BufferAsset.prototype; +const _nativeAssetDescriptor = Object.getOwnPropertyDescriptor(BufferAssetProto, '_nativeAsset'); +override(BufferAssetProto, '_nativeAsset', _nativeAssetDescriptor); +ccclass('cc.BufferAsset')(BufferAsset); diff --git a/cocos/core/assets/effect-asset.jsb.ts b/cocos/core/assets/effect-asset.jsb.ts index 5ca6dc084a..894922ea72 100644 --- a/cocos/core/assets/effect-asset.jsb.ts +++ b/cocos/core/assets/effect-asset.jsb.ts @@ -26,7 +26,6 @@ import { ccclass, editable, editorOnly, serializable } from 'cc.decorator'; import { legacyCC } from '../global-exports'; import { - _applyDecoratedDescriptor, _assertThisInitialized, _initializerDefineProperty, } from '../data/utils/decorator-jsb-utils'; @@ -36,53 +35,21 @@ export const EffectAsset = jsb.EffectAsset; legacyCC.EffectAsset = EffectAsset; -const clsDecorator = ccclass('cc.EffectAsset'); - const effectAssetProto: any = EffectAsset.prototype; -const _descriptor_techniques = _applyDecoratedDescriptor(effectAssetProto, 'techniques', [serializable, editable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return []; - }, -}); - -const _descriptor_shaders = _applyDecoratedDescriptor(effectAssetProto, 'shaders', [serializable, editable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return []; - }, -}); - -const _descriptor_combinations = _applyDecoratedDescriptor(effectAssetProto, 'combinations', [serializable, editable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return []; - }, -}); - -const _descriptor_hideInEditor = _applyDecoratedDescriptor(effectAssetProto, 'hideInEditor', [serializable, editorOnly], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return false; - }, -}); - effectAssetProto._ctor = function () { jsb.Asset.prototype._ctor.apply(this, arguments); this.hideInEditor = false; - // _initializerDefineProperty(this, 'techniques', _descriptor_techniques, _assertThisInitialized(this)); - // _initializerDefineProperty(this, 'shaders', _descriptor_shaders, _assertThisInitialized(this)); - // _initializerDefineProperty(this, 'combinations', _descriptor_combinations, _assertThisInitialized(this)); - // _initializerDefineProperty(this, 'hideInEditor', _descriptor_hideInEditor, _assertThisInitialized(this)); }; -clsDecorator(EffectAsset); +// handle meta data, it is generated automatically +const EffectAssetProto = EffectAsset.prototype; +editable(EffectAssetProto, 'techniques'); +serializable(EffectAssetProto, 'techniques'); +editable(EffectAssetProto, 'shaders'); +serializable(EffectAssetProto, 'shaders'); +editable(EffectAssetProto, 'combinations'); +serializable(EffectAssetProto, 'combinations'); +editorOnly(EffectAssetProto, 'hideInEditor'); +serializable(EffectAssetProto, 'hideInEditor'); +ccclass('cc.EffectAsset')(EffectAsset); diff --git a/cocos/core/assets/image-asset.jsb.ts b/cocos/core/assets/image-asset.jsb.ts index 043dc10f52..b7a316e77e 100644 --- a/cocos/core/assets/image-asset.jsb.ts +++ b/cocos/core/assets/image-asset.jsb.ts @@ -24,13 +24,7 @@ */ import { ccclass, override } from 'cc.decorator'; import { ALIPAY, XIAOMI, JSB, TEST, BAIDU } from 'internal:constants'; - -import { - _applyDecoratedDescriptor, - _assertThisInitialized, - _initializerDefineProperty, -} from '../data/utils/decorator-jsb-utils'; -import { Device, Feature, Format, FormatFeatureBit } from '../gfx'; +import { Format, FormatFeatureBit } from '../gfx'; import { legacyCC } from '../global-exports'; import { PixelFormat } from './asset-enum'; import { warnID } from '../platform'; @@ -261,12 +255,10 @@ imageAssetProto._deserialize = function (data: any) { } }; -const clsDecorator = ccclass('cc.ImageAsset'); - -const _class2$a = ImageAsset; - -// cjh FIXME: _applyDecoratedDescriptor(_class2$a.prototype, '_nativeAsset', [override], Object.getOwnPropertyDescriptor(_class2$a.prototype, '_nativeAsset'), _class2$a.prototype); - -clsDecorator(ImageAsset); - legacyCC.ImageAsset = jsb.ImageAsset; + +// handle meta data, it is generated automatically +const ImageAssetProto = ImageAsset.prototype; +const _nativeAssetDescriptor = Object.getOwnPropertyDescriptor(ImageAssetProto, '_nativeAsset'); +override(ImageAssetProto, '_nativeAsset', _nativeAssetDescriptor); +ccclass('cc.ImageAsset')(ImageAsset); diff --git a/cocos/core/assets/material.jsb.ts b/cocos/core/assets/material.jsb.ts index 94396488c8..39d6ff3160 100644 --- a/cocos/core/assets/material.jsb.ts +++ b/cocos/core/assets/material.jsb.ts @@ -34,8 +34,7 @@ import { legacyCC } from '../global-exports'; import { PassOverrides, MacroRecord, MaterialProperty } from '../renderer'; import { Color, Mat3, Mat4, Quat, Vec2, Vec3, Vec4 } from '../math'; -import { setClassName } from '../utils/js-typed'; -import { _applyDecoratedDescriptor, _assertThisInitialized, _initializerDefineProperty } from '../data/utils/decorator-jsb-utils'; +import { _assertThisInitialized, _initializerDefineProperty } from '../data/utils/decorator-jsb-utils'; import { ccclass, serializable, type } from '../data/decorators'; /** @@ -251,54 +250,6 @@ legacyCC.Material = Material; const materialProto: any = Material.prototype; -const clsDecorator = ccclass('cc.Material'); - -// Deserialization -const _class2$f = Material; -const _dec2$7 = type(EffectAsset); -const _descriptor$d = _applyDecoratedDescriptor(_class2$f.prototype, '_effectAsset', [_dec2$7], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return null; - }, -}); - -const _descriptor2$9 = _applyDecoratedDescriptor(_class2$f.prototype, '_techIdx', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return 0; - }, -}); - -const _descriptor3$7 = _applyDecoratedDescriptor(_class2$f.prototype, '_defines', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return []; - }, -}); -const _descriptor4$6 = _applyDecoratedDescriptor(_class2$f.prototype, '_states', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return []; - }, -}); -const _descriptor5$4 = _applyDecoratedDescriptor(_class2$f.prototype, '_props', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return []; - }, -}); - materialProto._ctor = function () { jsb.Asset.prototype._ctor.apply(this, arguments); this._props = []; @@ -338,4 +289,11 @@ Object.defineProperty(materialProto, 'passes', { }, }); -clsDecorator(Material); +// handle meta data, it is generated automatically +const MaterialProto = Material.prototype; +type(EffectAsset)(MaterialProto, '_effectAsset'); +serializable(MaterialProto, '_techIdx'); +serializable(MaterialProto, '_defines'); +serializable(MaterialProto, '_states'); +serializable(MaterialProto, '_props'); +ccclass('cc.Material')(Material); diff --git a/cocos/core/assets/prefab.jsb.ts b/cocos/core/assets/prefab.jsb.ts index 94581e27e9..ca023da855 100644 --- a/cocos/core/assets/prefab.jsb.ts +++ b/cocos/core/assets/prefab.jsb.ts @@ -24,7 +24,6 @@ */ import { ccclass, editable, serializable } from 'cc.decorator'; import { - _applyDecoratedDescriptor, _assertThisInitialized, _initializerDefineProperty, } from '../data/utils/decorator-jsb-utils'; @@ -62,42 +61,22 @@ const OptimizationPolicy = Enum({ MULTI_INSTANCE: 2, }); -const clsDecorator = ccclass('cc.Prefab'); - const prefabProto: any = Prefab.prototype; -const _class2$B = Prefab; -const _descriptor$v = _applyDecoratedDescriptor(_class2$B.prototype, 'data', [serializable, editable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return null; - }, -}); -const _descriptor2$o = _applyDecoratedDescriptor(_class2$B.prototype, 'optimizationPolicy', [serializable, editable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return OptimizationPolicy.AUTO; - }, -}); -const _descriptor2$p = _applyDecoratedDescriptor(_class2$B.prototype, 'persistent', [serializable, editable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return false; - }, -}); - prefabProto._ctor = function () { jsb.Asset.prototype._ctor.apply(this, arguments); // _initializerDefineProperty(_this, 'data', _descriptor$v, _assertThisInitialized(_this)); // _initializerDefineProperty(_this, 'optimizationPolicy', _descriptor2$o, _assertThisInitialized(_this)); }; -clsDecorator(Prefab); - legacyCC.Prefab = Prefab; + +// handle meta data, it is generated automatically +const PrefabProto = Prefab.prototype; +editable(PrefabProto, 'data'); +serializable(PrefabProto, 'data'); +editable(PrefabProto, 'optimizationPolicy'); +serializable(PrefabProto, 'optimizationPolicy'); +editable(PrefabProto, 'persistent'); +serializable(PrefabProto, 'persistent'); +ccclass('cc.Prefab')(Prefab); diff --git a/cocos/core/assets/render-texture.jsb.ts b/cocos/core/assets/render-texture.jsb.ts index 6668a0fd63..e0876a0297 100644 --- a/cocos/core/assets/render-texture.jsb.ts +++ b/cocos/core/assets/render-texture.jsb.ts @@ -22,10 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import { ccclass, rangeMax, rangeMin, serializable } from 'cc.decorator'; +import { ccclass } from 'cc.decorator'; import { EDITOR, TEST } from 'internal:constants'; import { - _applyDecoratedDescriptor, _assertThisInitialized, _initializerDefineProperty, } from '../data/utils/decorator-jsb-utils'; @@ -46,39 +45,6 @@ RenderTexture.Filter = Filter; RenderTexture.PixelFormat = PixelFormat; RenderTexture.WrapMode = WrapMode; -const clsDecorator = ccclass('cc.RenderTexture'); - -const _class2$j = RenderTexture; -const _dec2$b = rangeMin(1); -const _dec3$6 = rangeMax(1024); -const _dec4$5 = rangeMin(1); -const _dec5$2 = rangeMax(1024); - -const _descriptor$h = _applyDecoratedDescriptor(_class2$j.prototype, '_width', [serializable, _dec2$b, _dec3$6], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return 1; - }, -}); - -const _descriptor2$d = _applyDecoratedDescriptor(_class2$j.prototype, '_height', [serializable, _dec4$5, _dec5$2], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return 1; - }, -}); - -renderTextureProto._ctor = function () { - textureBaseProto._ctor.apply(this, arguments); - // for deserialization - // _initializerDefineProperty(_this, '_width', _descriptor$h, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, '_height', _descriptor2$d, _assertThisInitialized(_this)); -}; - renderTextureProto._serialize = function (ctxForExporting: any): any { if (EDITOR || TEST) { return { base: textureBaseProto._serialize(ctxForExporting), w: this._width, h: this._height, n: this._name }; @@ -111,6 +77,7 @@ renderTextureProto.readPixels = function readPixels (x: number, y: number, width return buffer; }; -clsDecorator(RenderTexture); - legacyCC.RenderTexture = jsb.RenderTexture; + +// handle meta data, it is generated automatically +ccclass('cc.RenderTexture')(RenderTexture); diff --git a/cocos/core/assets/scene-asset.jsb.ts b/cocos/core/assets/scene-asset.jsb.ts index e9d850e651..6dc8ac2f78 100644 --- a/cocos/core/assets/scene-asset.jsb.ts +++ b/cocos/core/assets/scene-asset.jsb.ts @@ -23,30 +23,15 @@ THE SOFTWARE. */ import { ccclass, editable, serializable } from 'cc.decorator'; -import { - _applyDecoratedDescriptor, - _assertThisInitialized, - _initializerDefineProperty, -} from '../data/utils/decorator-jsb-utils'; import { legacyCC } from '../global-exports'; export const SceneAsset = jsb.SceneAsset; export type SceneAsset = jsb.SceneAsset; legacyCC.SceneAsset = SceneAsset; -const sceneAssetDecorator = ccclass('cc.SceneAsset'); const sceneAssetProto: any = SceneAsset.prototype; -const des_scene = _applyDecoratedDescriptor(sceneAssetProto, 'scene', [editable, serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return null; - }, -}); - Object.defineProperty(sceneAssetProto, 'scene', { enumerable: true, configurable: true, @@ -64,8 +49,11 @@ Object.defineProperty(sceneAssetProto, 'scene', { sceneAssetProto._ctor = function () { jsb.Asset.prototype._ctor.apply(this, arguments); - // _initializerDefineProperty(this, "scene", des_scene, _assertThisInitialized(this)); this._scene = null; }; -sceneAssetDecorator(SceneAsset); +// handle meta data, it is generated automatically +const SceneAssetProto = SceneAsset.prototype; +serializable(SceneAssetProto, 'scene'); +editable(SceneAssetProto, 'scene'); +ccclass('cc.SceneAsset')(SceneAsset); diff --git a/cocos/core/assets/text-asset.jsb.ts b/cocos/core/assets/text-asset.jsb.ts index b708148beb..6c548a00e2 100644 --- a/cocos/core/assets/text-asset.jsb.ts +++ b/cocos/core/assets/text-asset.jsb.ts @@ -22,12 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import { ccclass, editable, serializable, type } from 'cc.decorator'; -import { - _applyDecoratedDescriptor, - _assertThisInitialized, - _initializerDefineProperty, -} from '../data/utils/decorator-jsb-utils'; +import { ccclass, editable, serializable } from 'cc.decorator'; import { legacyCC } from '../global-exports'; const textAssetProto: any = jsb.TextAsset.prototype; @@ -37,23 +32,14 @@ textAssetProto.createNode = null!; export type TextAsset = jsb.TextAsset; export const TextAsset = jsb.TextAsset; -const clsDecorator = ccclass('cc.TextAsset'); - -const _class2$F = TextAsset; -const _descriptor$y = _applyDecoratedDescriptor(_class2$F.prototype, 'text', [serializable, editable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return ''; - }, -}); - textAssetProto._ctor = function () { jsb.Asset.prototype._ctor.apply(this, arguments); - // _initializerDefineProperty(_this, 'text', _descriptor$y, _assertThisInitialized(_this)); }; -clsDecorator(TextAsset); - legacyCC.TextAsset = jsb.TextAsset; + +// handle meta data, it is generated automatically +const TextAssetProto = TextAsset.prototype; +editable(TextAssetProto, 'text'); +serializable(TextAssetProto, 'text'); +ccclass('cc.TextAsset')(TextAsset); diff --git a/cocos/core/assets/texture-2d.jsb.ts b/cocos/core/assets/texture-2d.jsb.ts index 862c66431b..c581b73446 100644 --- a/cocos/core/assets/texture-2d.jsb.ts +++ b/cocos/core/assets/texture-2d.jsb.ts @@ -23,11 +23,6 @@ THE SOFTWARE. */ import { ccclass, type } from 'cc.decorator'; -import { - _applyDecoratedDescriptor, - _assertThisInitialized, - _initializerDefineProperty, -} from '../data/utils/decorator-jsb-utils'; import { legacyCC } from '../global-exports'; import { ImageAsset } from './image-asset'; import { SimpleTexture } from './simple-texture'; @@ -51,30 +46,11 @@ export interface ITexture2DSerializeData { mipmaps: string[]; } -const clsDecorator = ccclass('cc.Texture2D'); - -const _class2$c = Texture2D; -const _dec2$6 = type([ImageAsset]); // xwx: jsb.ImageAsset? - -const _descriptor$a = _applyDecoratedDescriptor(_class2$c.prototype, '_mipmaps', [_dec2$6], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return []; - }, -}); - texture2DProto._ctor = function () { SimpleTexture.prototype._ctor.apply(this, arguments); this._mipmaps = []; - // for deserialization - // _initializerDefineProperty(_this, 'isRGBE', _descriptor$b, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, '_mipmaps', _descriptor2$7, _assertThisInitialized(_this)); }; -clsDecorator(Texture2D); - texture2DProto._serialize = function (ctxForExporting: any) { if (EDITOR || TEST) { return { @@ -144,3 +120,8 @@ Object.defineProperty(texture2DProto, 'mipmaps', { }); legacyCC.Texture2D = jsb.Texture2D; + +// handle meta data, it is generated automatically +const Texture2DProto = Texture2D.prototype; +type([ImageAsset])(Texture2DProto, '_mipmaps'); +ccclass('cc.Texture2D')(Texture2D); diff --git a/cocos/core/assets/texture-base.jsb.ts b/cocos/core/assets/texture-base.jsb.ts index 0404cdb56a..ba721941e1 100644 --- a/cocos/core/assets/texture-base.jsb.ts +++ b/cocos/core/assets/texture-base.jsb.ts @@ -24,7 +24,6 @@ */ import { ccclass, serializable } from 'cc.decorator'; import { - _applyDecoratedDescriptor, _assertThisInitialized, _initializerDefineProperty, } from '../data/utils/decorator-jsb-utils'; @@ -91,73 +90,6 @@ TextureBase.Filter = Filter; TextureBase.PixelFormat = PixelFormat; TextureBase.WrapMode = WrapMode; -const clsDecorator = ccclass('cc.TextureBase'); - -const _class2$b = TextureBase; -const _descriptor$9 = _applyDecoratedDescriptor(_class2$b.prototype, '_format', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return PixelFormat.RGBA8888; - }, -}); -const _descriptor2$6 = _applyDecoratedDescriptor(_class2$b.prototype, '_minFilter', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return Filter.LINEAR; - }, -}); -const _descriptor3$5 = _applyDecoratedDescriptor(_class2$b.prototype, '_magFilter', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return Filter.LINEAR; - }, -}); -const _descriptor4$4 = _applyDecoratedDescriptor(_class2$b.prototype, '_mipFilter', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return Filter.NONE; - }, -}); -const _descriptor5$3 = _applyDecoratedDescriptor(_class2$b.prototype, '_wrapS', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return WrapMode.REPEAT; - }, -}); -const _descriptor6$1 = _applyDecoratedDescriptor(_class2$b.prototype, '_wrapT', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return WrapMode.REPEAT; - }, -}); -const _descriptor7$1 = _applyDecoratedDescriptor(_class2$b.prototype, '_wrapR', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return WrapMode.REPEAT; - }, -}); -const _descriptor8$1 = _applyDecoratedDescriptor(_class2$b.prototype, '_anisotropy', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return 0; - }, -}); textureBaseProto._ctor = function () { jsb.Asset.prototype._ctor.apply(this, arguments); this._gfxSampler = null; @@ -165,15 +97,6 @@ textureBaseProto._ctor = function () { this._textureHash = 0; this._registerGFXSamplerUpdatedListener(); - // for deserialization - // _initializerDefineProperty(_this, "_format", _descriptor$9, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, "_minFilter", _descriptor2$6, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, "_magFilter", _descriptor3$5, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, "_mipFilter", _descriptor4$4, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, "_wrapS", _descriptor5$3, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, "_wrapT", _descriptor6$1, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, "_wrapR", _descriptor7$1, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, "_anisotropy", _descriptor8$1, _assertThisInitialized(_this)); }; const oldGetGFXSampler = textureBaseProto.getGFXSampler; @@ -214,6 +137,16 @@ textureBaseProto._onGFXSamplerUpdated = function (gfxSampler, samplerInfo) { this._samplerInfo = samplerInfo; }; -clsDecorator(TextureBase); - legacyCC.TextureBase = jsb.TextureBase; + +// handle meta data, it is generated automatically +const TextureBaseProto = TextureBase.prototype; +serializable(TextureBaseProto, '_format'); +serializable(TextureBaseProto, '_minFilter'); +serializable(TextureBaseProto, '_magFilter'); +serializable(TextureBaseProto, '_mipFilter'); +serializable(TextureBaseProto, '_wrapS'); +serializable(TextureBaseProto, '_wrapT'); +serializable(TextureBaseProto, '_wrapR'); +serializable(TextureBaseProto, '_anisotropy'); +ccclass('cc.TextureBase')(TextureBase); diff --git a/cocos/core/assets/texture-cube.jsb.ts b/cocos/core/assets/texture-cube.jsb.ts index 52d85e1b20..38a6b51469 100644 --- a/cocos/core/assets/texture-cube.jsb.ts +++ b/cocos/core/assets/texture-cube.jsb.ts @@ -24,7 +24,6 @@ */ import { ccclass, serializable } from 'cc.decorator'; import { - _applyDecoratedDescriptor, _assertThisInitialized, _initializerDefineProperty, } from '../data/utils/decorator-jsb-utils'; @@ -78,49 +77,10 @@ TextureCube.Filter = Filter; TextureCube.PixelFormat = PixelFormat; TextureCube.WrapMode = WrapMode; -const clsDecorator = ccclass('cc.TextureCube'); - -const _class2$d = TextureCube; -const _descriptor$b = _applyDecoratedDescriptor(_class2$d.prototype, 'isRGBE', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return false; - }, -}); -const _descriptor2$7 = _applyDecoratedDescriptor(_class2$d.prototype, '_mipmaps', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return []; - }, -}); -const _descriptor3$b = _applyDecoratedDescriptor(_class2$d.prototype, '_mipmapMode', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return MipmapMode.AUTO; - }, -}); -const _descriptor4$b = _applyDecoratedDescriptor(_class2$d.prototype, '_mipmapAtlas', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return null; - }, -}); - textureCubeProto._ctor = function () { jsb.SimpleTexture.prototype._ctor.apply(this, arguments); this._mipmaps = null; this._mipmapAtlas = null; - // for deserialization - // _initializerDefineProperty(_this, 'isRGBE', _descriptor$b, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, '_mipmaps', _descriptor2$7, _assertThisInitialized(_this)); }; function _forEachFace (mipmap, callback: (face, faceIndex) => void) { @@ -292,6 +252,12 @@ textureCubeProto._deserialize = function (serializedData: ITextureCubeSerializeD } } -clsDecorator(TextureCube); - legacyCC.TextureCube = jsb.TextureCube; + +// handle meta data, it is generated automatically +const TextureCubeProto = TextureCube.prototype; +serializable(TextureCubeProto, 'isRGBE'); +serializable(TextureCubeProto, '_mipmaps'); +serializable(TextureCubeProto, '_mipmapMode'); +serializable(TextureCubeProto, '_mipmapAtlas'); +ccclass('cc.TextureCube')(TextureCube); diff --git a/cocos/core/data/decorators/property.ts b/cocos/core/data/decorators/property.ts index 6fb287e194..9adaf59ea4 100644 --- a/cocos/core/data/decorators/property.ts +++ b/cocos/core/data/decorators/property.ts @@ -23,7 +23,7 @@ THE SOFTWARE. */ -import { DEV, EDITOR, TEST } from 'internal:constants'; +import { DEV, EDITOR, JSB, TEST } from 'internal:constants'; import { CCString, CCInteger, CCFloat, CCBoolean } from '../utils/attribute'; import { IExposedAttributes } from '../utils/attribute-defines'; import { LegacyPropertyDecorator, getSubDict, getClassCache, BabelPropertyDecoratorDescriptor } from './utils'; @@ -248,6 +248,12 @@ function setDefaultValue ( propertyKey: PropertyKey, descriptor: BabelPropertyDecoratorDescriptor | undefined, ) { + // Default values are needed by editor, and now editor run with web version, so don't + // have to provide default values. + if (JSB) { + return; + } + if (descriptor) { // In case of Babel, if an initializer is given for class field. // That initializer is passed to `descriptor.initializer`. diff --git a/cocos/core/data/deserialize-dynamic.ts b/cocos/core/data/deserialize-dynamic.ts index 2aaded4c87..decfd78201 100644 --- a/cocos/core/data/deserialize-dynamic.ts +++ b/cocos/core/data/deserialize-dynamic.ts @@ -144,10 +144,10 @@ function compileDeserializeJIT (self: _Deserializer, klass: CCClassConstructor { - desc[key] = descriptor[key]; - }); - desc.enumerable = !!desc.enumerable; - desc.configurable = !!desc.configurable; - - if ('value' in desc || desc.initializer) { - desc.writable = true; - } - - desc = decorators.slice().reverse().reduce((desc, decorator) => { - return decorator(target, property, desc) || desc; - }, desc); - - if (context && desc.initializer !== undefined) { - desc.value = desc.initializer ? desc.initializer.call(context) : undefined; - desc.initializer = undefined; - } - - if (desc.initializer === undefined) { - Object.defineProperty(target, property, desc); - desc = null; - } - - return desc; -} - -export function _inheritsLoose(subClass, superClass) { - subClass.prototype = Object.create(superClass.prototype); - subClass.prototype.constructor = subClass; - - _setPrototypeOf(subClass, superClass); -} - -export function _getPrototypeOf(o) { - const getPrototypeOf: any = Object.getPrototypeOf ? Object.getPrototypeOf : (o) => { - return o.__proto__ || Object.getPrototypeOf(o); - }; - return getPrototypeOf(o); -} - -export function _setPrototypeOf(o, p) { - const setPrototypeOf = Object.setPrototypeOf || function (o, p) { - o.__proto__ = p; - return o; - }; - return setPrototypeOf(o, p); -} diff --git a/cocos/core/renderer/core/material-instance.jsb.ts b/cocos/core/renderer/core/material-instance.jsb.ts index 8b048aab98..32e13c0346 100644 --- a/cocos/core/renderer/core/material-instance.jsb.ts +++ b/cocos/core/renderer/core/material-instance.jsb.ts @@ -22,12 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import { ccclass, editable, serializable } from 'cc.decorator'; -import { - _applyDecoratedDescriptor, - _assertThisInitialized, - _initializerDefineProperty, -} from '../data/utils/decorator-jsb-utils'; import { Material } from '../../assets'; import { Renderer } from '../../components/renderer'; @@ -75,10 +69,3 @@ materialInstanceProto._onRebuildPSO = function () { this._owner._onRebuildPSO(this._subModelIdx, this); } }; - -const clsDecorator = ccclass('cc.MaterialInstance'); - -// TODO: -// _applyDecoratedDescriptor - -clsDecorator(MaterialInstance); diff --git a/cocos/core/renderer/core/pass.jsb.ts b/cocos/core/renderer/core/pass.jsb.ts index 2c61e82d83..d22d9151e4 100644 --- a/cocos/core/renderer/core/pass.jsb.ts +++ b/cocos/core/renderer/core/pass.jsb.ts @@ -22,12 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import { ccclass, editable, serializable } from 'cc.decorator'; -import { - _applyDecoratedDescriptor, - _assertThisInitialized, - _initializerDefineProperty, -} from '../data/utils/decorator-jsb-utils'; import { MacroRecord } from "./pass-utils"; import { EffectAsset } from '../../assets/effect-asset'; @@ -52,10 +46,3 @@ export enum BatchingSchemes { export const Pass = jsb.Pass; export type Pass = jsb.Pass; - -const clsDecorator = ccclass('cc.Pass'); - -//TODO: -// _applyDecoratedDescriptor - -clsDecorator(Pass); diff --git a/cocos/core/renderer/core/render-window.jsb.ts b/cocos/core/renderer/core/render-window.jsb.ts index 9e75de60aa..d1944dbbb7 100644 --- a/cocos/core/renderer/core/render-window.jsb.ts +++ b/cocos/core/renderer/core/render-window.jsb.ts @@ -22,8 +22,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import { ccclass } from 'cc.decorator'; - export interface IRenderWindowInfo { title?: string; width: number; @@ -36,10 +34,3 @@ declare const jsb: any; export const RenderWindow = jsb.RenderWindow; // @ts-ignore export type RenderWindow = jsb.RenderWindow; - -const clsDecorator = ccclass('cc.RenderWindow'); - -//TODO: -// _applyDecoratedDescriptor - -clsDecorator(RenderWindow); diff --git a/cocos/core/renderer/core/sampler-lib.jsb.ts b/cocos/core/renderer/core/sampler-lib.jsb.ts index 2752cb528b..ef30f56c9a 100644 --- a/cocos/core/renderer/core/sampler-lib.jsb.ts +++ b/cocos/core/renderer/core/sampler-lib.jsb.ts @@ -22,19 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import { ccclass, editable, serializable } from 'cc.decorator'; -import { - _applyDecoratedDescriptor, - _assertThisInitialized, - _initializerDefineProperty, -} from '../data/utils/decorator-jsb-utils'; import { legacyCC } from "../../global-exports"; const SamplerLib = nr.SamplerLib; -const clsDecorator = ccclass('cc.SamplerLib'); - -clsDecorator(SamplerLib); - export const samplerLib = new SamplerLib(); legacyCC.samplerLib = samplerLib; diff --git a/cocos/core/renderer/scene/index.jsb.ts b/cocos/core/renderer/scene/index.jsb.ts index 8c3c7d01bb..0244a815a6 100644 --- a/cocos/core/renderer/scene/index.jsb.ts +++ b/cocos/core/renderer/scene/index.jsb.ts @@ -257,6 +257,32 @@ export const CSMLevel = Enum({ */ DisableRotaitonFix: 3, }); +export const EnvironmentLightingType = Enum({ + /** + * @zh + * 半球漫反射 + * @en + * hemisphere diffuse + * @readonly + */ + HEMISPHERE_DIFFUSE: 0, + /** + * @zh + * 半球漫反射和环境反射 + * @en + * hemisphere diffuse and Environment reflection + * @readonly + */ + AUTOGEN_HEMISPHERE_DIFFUSE_WITH_REFLECTION: 1, + /** + * @zh + * 漫反射卷积图和环境反射 + * @en + * diffuse convolution map and environment reflection + * @readonly + */ + DIFFUSEMAP_WITH_REFLECTION: 2, +}); export const ShadowsInfo = jsb.ShadowsInfo; export type ShadowsInfo = jsb.ShadowsInfo; export const Shadows = jsb.Shadow; diff --git a/cocos/core/scene-graph/base-node.jsb.ts b/cocos/core/scene-graph/base-node.jsb.ts index 8f627123f6..ef09eaa9ca 100644 --- a/cocos/core/scene-graph/base-node.jsb.ts +++ b/cocos/core/scene-graph/base-node.jsb.ts @@ -23,10 +23,8 @@ THE SOFTWARE. */ -import { ccclass, editable, serializable } from 'cc.decorator'; -import { property } from '../data/decorators/property'; +import { ccclass } from '../data/decorators'; import { legacyCC } from '../global-exports'; -import { _applyDecoratedDescriptor } from '../data/utils/decorator-jsb-utils'; import { baseNodePolyfill } from './base-node-dev'; const baseNodeProto: any = jsb.BaseNode.prototype; @@ -35,66 +33,6 @@ baseNodeProto.createNode = null!; export type BaseNode = jsb.BaseNode; export const BaseNode = jsb.BaseNode; -const clsDecorator = ccclass('cc.BaseNode'); - -// const _class2$u = BaseNode; -// -// _applyDecoratedDescriptor(_class2$u.prototype, '_persistNode', [property], Object.getOwnPropertyDescriptor(_class2$u.prototype, '_persistNode'), _class2$u.prototype); -// _applyDecoratedDescriptor(_class2$u.prototype, 'name', [editable], Object.getOwnPropertyDescriptor(_class2$u.prototype, 'name'), _class2$u.prototype); -// _applyDecoratedDescriptor(_class2$u.prototype, 'children', [editable], Object.getOwnPropertyDescriptor(_class2$u.prototype, 'children'), _class2$u.prototype); -// _applyDecoratedDescriptor(_class2$u.prototype, 'active', [editable], Object.getOwnPropertyDescriptor(_class2$u.prototype, 'active'), _class2$u.prototype); -// _applyDecoratedDescriptor(_class2$u.prototype, 'activeInHierarchy', [editable], Object.getOwnPropertyDescriptor(_class2$u.prototype, 'activeInHierarchy'), _class2$u.prototype); -// _applyDecoratedDescriptor(_class2$u.prototype, 'parent', [editable], Object.getOwnPropertyDescriptor(_class2$u.prototype, 'parent'), _class2$u.prototype); -// -// const _descriptor$o = _applyDecoratedDescriptor(_class2$u.prototype, '_parent', [serializable], { -// configurable: true, -// enumerable: true, -// writable: true, -// initializer: function initializer () { -// return null; -// }, -// }); -// const _descriptor2$h = _applyDecoratedDescriptor(_class2$u.prototype, '_children', [serializable], { -// configurable: true, -// enumerable: true, -// writable: true, -// initializer: function initializer () { -// return []; -// }, -// }); -// const _descriptor3$b = _applyDecoratedDescriptor(_class2$u.prototype, '_active', [serializable], { -// configurable: true, -// enumerable: true, -// writable: true, -// initializer: function initializer () { -// return true; -// }, -// }); -// const _descriptor4$9 = _applyDecoratedDescriptor(_class2$u.prototype, '_components', [serializable], { -// configurable: true, -// enumerable: true, -// writable: true, -// initializer: function initializer () { -// return []; -// }, -// }); -// const _descriptor5$6 = _applyDecoratedDescriptor(_class2$u.prototype, '_prefab', [serializable], { -// configurable: true, -// enumerable: true, -// writable: true, -// initializer: function initializer () { -// return null; -// }, -// }); -// -baseNodeProto._ctor = function () { -// // _initializerDefineProperty(_this, "_parent", _descriptor$o, _assertThisInitialized(_this)); -// // _initializerDefineProperty(_this, "_children", _descriptor2$h, _assertThisInitialized(_this)); -// // _initializerDefineProperty(_this, "_active", _descriptor3$b, _assertThisInitialized(_this)); -// // _initializerDefineProperty(_this, "_components", _descriptor4$9, _assertThisInitialized(_this)); -// // _initializerDefineProperty(_this, "_prefab", _descriptor5$6, _assertThisInitialized(_this)); -}; - -clsDecorator(BaseNode); baseNodePolyfill(BaseNode); -legacyCC._BaseNode = jsb.BaseNode; +legacyCC._BaseNode = BaseNode; +ccclass('cc.BaseNode')(BaseNode); \ No newline at end of file diff --git a/cocos/core/scene-graph/index.jsb.ts b/cocos/core/scene-graph/index.jsb.ts index a8bf012231..0d0ea948fa 100644 --- a/cocos/core/scene-graph/index.jsb.ts +++ b/cocos/core/scene-graph/index.jsb.ts @@ -1,6 +1,7 @@ +import './node-event-processor'; + export * from './node'; export * from './scene'; - export { Layers } from './layers'; export * from './deprecated'; export * from './scene-globals'; diff --git a/cocos/core/scene-graph/node.jsb.ts b/cocos/core/scene-graph/node.jsb.ts index 42ac21d06f..b4d37002fa 100644 --- a/cocos/core/scene-graph/node.jsb.ts +++ b/cocos/core/scene-graph/node.jsb.ts @@ -20,13 +20,7 @@ */ import { EDITOR } from 'internal:constants'; -import { ccclass, editable, serializable, type } from 'cc.decorator'; -import { - _applyDecoratedDescriptor, - _assertThisInitialized, - _initializerDefineProperty, -} from '../data/utils/decorator-jsb-utils'; - +import { ccclass, editable, serializable, type } from 'cc.decorator' import { legacyCC } from '../global-exports'; import { errorID, getError } from '../platform/debug'; import { Component } from '../components/component'; @@ -35,21 +29,13 @@ import { CCObject } from '../data/object'; import { NodeUIProperties } from './node-ui-properties'; import { NodeSpace, TransformBit } from './node-enum'; import { Mat4, Quat, Vec3 } from '../math'; -import { NodeEventProcessor } from './node-event-processor'; import { Layers } from './layers'; import { SerializationContext, SerializationOutput, serializeTag } from '../data'; import { _tempFloatArray } from './utils.jsb'; - -import { - applyMountedChildren, - applyMountedComponents, applyPropertyOverrides, - applyRemovedComponents, applyTargetOverrides, - createNodeWithPrefab, - generateTargetMap, -} from '../utils/prefab/utils'; import { getClassByName, isChildClassOf } from '../utils/js-typed'; import { syncNodeValues } from "../utils/jsb-utils"; -import { BaseNode } from "./base-node"; +import { property } from '../data/class-decorator'; +import './base-node'; declare const jsb: any; @@ -58,8 +44,6 @@ export const Node = jsb.Node; export type Node = jsb.Node; legacyCC.Node = Node; -const clsDecorator = ccclass('cc.Node'); - const NodeCls: any = Node; /** * @en Event types emitted by Node @@ -1004,7 +988,7 @@ Object.defineProperty(nodeProto, 'right', { Object.defineProperty(nodeProto, 'eventProcessor', { configurable: true, enumerable: true, - get (): NodeEventProcessor { + get () { return this._eventProcessor; }, }); @@ -1088,31 +1072,6 @@ nodeProto.insertChild = function (child: Node, siblingIndex: number) { child.setSiblingIndex(siblingIndex); }; -// nodeProto.removeFromParent = function () { -// if (this._parent) { -// this._parent.removeChild(this); -// } -// }; -// -// const oldRemoveChild = nodeProto.removeChild; -// nodeProto.removeChild = function (child: Node) { -// oldRemoveChild.call(this, child); -// jsb.unregisterNativeRef(this, child); -// }; -// -// const oldRemoveAllChildren = nodeProto.removeAllChildren; -// nodeProto.removeAllChildren = function () { -// oldRemoveAllChildren.call(this); -// // cjh TODO: need to improve performance -// const children = this.children; -// for (let i = children.length - 1; i >= 0; i--) { -// const node = children[i]; -// if (node) { -// jsb.unregisterNativeRef(this, node); -// } -// } -// }; - nodeProto[serializeTag] = function (serializationOutput: SerializationOutput, context: SerializationContext) { if (!EDITOR) { serializationOutput.writeThis(); @@ -1243,129 +1202,8 @@ nodeProto._instantiate = function (cloned: Node, isSyncedNode: boolean) { return cloned; }; -// Deserialization -const _class2$u = Node; - -// cjh FIXME: replace object.ts with object.jsb.ts -// _applyDecoratedDescriptor(_class2$u.prototype, '_name', [serializable], { -// configurable: true, -// enumerable: true, -// writable: true, -// initializer: function initializer () { -// return ''; -// }, -// }); - -// _applyDecoratedDescriptor(_class2$u.prototype, '_objFlags', [serializable], { -// configurable: true, -// enumerable: true, -// writable: true, -// initializer: function initializer () { -// return 0; -// }, -// }); -// - -const _descriptor$o = _applyDecoratedDescriptor(_class2$u.prototype, '_parent', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return null; - }, -}); - -const _descriptor2$h = _applyDecoratedDescriptor(_class2$u.prototype, '_children', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return []; - }, -}); - -const _descriptor3$b = _applyDecoratedDescriptor(_class2$u.prototype, '_active', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return true; - }, -}); - -const _descriptor4$9 = _applyDecoratedDescriptor(_class2$u.prototype, '_components', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return []; - }, -}); - -const _descriptor5$6 = _applyDecoratedDescriptor(_class2$u.prototype, '_prefab', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return null; - }, -}); - -// Node -const _class2$v = Node; -const _descriptor$p = _applyDecoratedDescriptor(_class2$v.prototype, '_lpos', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return new Vec3(); - }, -}); - -const _descriptor2$i = _applyDecoratedDescriptor(_class2$v.prototype, '_lrot', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return new Quat(); - }, -}); - -const _descriptor3$c = _applyDecoratedDescriptor(_class2$v.prototype, '_lscale', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return new Vec3(1, 1, 1); - }, -}); - -const _descriptor4$a = _applyDecoratedDescriptor(_class2$v.prototype, '_layer', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return Layers.Enum.DEFAULT; - }, -}); - -const _descriptor5$7 = _applyDecoratedDescriptor(_class2$v.prototype, '_euler', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return new Vec3(); - }, -}); - -const _dec2$i = type(Vec3); -_applyDecoratedDescriptor(_class2$v.prototype, 'eulerAngles', [_dec2$i], Object.getOwnPropertyDescriptor(_class2$v.prototype, 'eulerAngles'), _class2$v.prototype); -_applyDecoratedDescriptor(_class2$v.prototype, 'angle', [editable], Object.getOwnPropertyDescriptor(_class2$v.prototype, 'angle'), _class2$v.prototype); -_applyDecoratedDescriptor(_class2$v.prototype, 'layer', [editable], Object.getOwnPropertyDescriptor(_class2$v.prototype, 'layer'), _class2$v.prototype); - // nodeProto._ctor = function (name?: string) { - BaseNode.prototype._ctor.apply(this, arguments); this.__nativeRefs = {}; this.__jsb_ref_id = undefined; this._iN$t = null; @@ -1383,39 +1221,6 @@ nodeProto._ctor = function (name?: string) { this._originalSceneId = ''; this._registerListeners(); - // // for deserialization - // // eslint-disable-next-line @typescript-eslint/no-this-alias - // const _this = this; - // // baseNode properties - // _initializerDefineProperty(_this, "_parent", _descriptor$o, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, "_children", _descriptor2$h, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, "_active", _descriptor3$b, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, "_components", _descriptor4$9, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, "_prefab", _descriptor5$6, _assertThisInitialized(_this)); - // // Node properties - // _initializerDefineProperty(_this, "_lpos", _descriptor$p, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, "_lrot", _descriptor2$i, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, "_lscale", _descriptor3$c, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, "_layer", _descriptor4$a, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, "_euler", _descriptor5$7, _assertThisInitialized(_this)); - // // - // defineArrayProxy({ - // owner: this, - // arrElementType: "object", - // arrPropertyName: "_children", - // getArrayElementCB(index: number) { - // return this._getChild(index); - // }, - // getArraySizeCB(): number { - // return this._getChildrenSize(); - // }, - // setArrayElementCB(index: number, val: any): void { - // this._setChild(index, val); - // }, - // setArraySizeCB(size: number): void { - // this._setChildrenSize(size); - // }, - // }); this._children = []; // this._isChildrenRedefined = false; @@ -1472,8 +1277,7 @@ nodeProto._ctor = function (name?: string) { } } }; -// -clsDecorator(Node); + const oldGetWorldRT = nodeProto.getWorldRT; nodeProto.getWorldRT = function (out?: Mat4) { @@ -1482,3 +1286,35 @@ nodeProto.getWorldRT = function (out?: Mat4) { Mat4.copy(target, worldRT); return target; }; + +// handle meta data, it is generated automatically +const NodeProto = Node.prototype; +const _persistNodeDescriptor = Object.getOwnPropertyDescriptor(NodeProto, '_persistNode'); +property(NodeProto, '_persistNode', _persistNodeDescriptor); +const nameDescriptor = Object.getOwnPropertyDescriptor(NodeProto, 'name'); +editable(NodeProto, 'name', nameDescriptor); +const childrenDescriptor = Object.getOwnPropertyDescriptor(NodeProto, 'children'); +editable(NodeProto, 'children', childrenDescriptor); +const activeDescriptor = Object.getOwnPropertyDescriptor(NodeProto, 'active'); +editable(NodeProto, 'active', activeDescriptor); +const activeInHierarchyDescriptor = Object.getOwnPropertyDescriptor(NodeProto, 'activeInHierarchy'); +editable(NodeProto, 'activeInHierarchy', activeInHierarchyDescriptor); +const parentDescriptor = Object.getOwnPropertyDescriptor(NodeProto, 'parent'); +editable(NodeProto, 'parent', parentDescriptor); +serializable(NodeProto, '_parent'); +serializable(NodeProto, '_children'); +serializable(NodeProto, '_active'); +serializable(NodeProto, '_components'); +serializable(NodeProto, '_prefab'); +serializable(NodeProto, '_lpos'); +serializable(NodeProto, '_lrot'); +serializable(NodeProto, '_lscale'); +serializable(NodeProto, '_layer'); +serializable(NodeProto, '_euler'); +const eulerAnglesDescriptor = Object.getOwnPropertyDescriptor(NodeProto, 'eulerAngles'); +type(Vec3)(NodeProto, 'eulerAngles', eulerAnglesDescriptor); +const angleDescriptor = Object.getOwnPropertyDescriptor(NodeProto, 'angle'); +editable(NodeProto, 'angle', angleDescriptor); +const layerDescriptor = Object.getOwnPropertyDescriptor(NodeProto, 'layer'); +editable(NodeProto, 'layer', layerDescriptor); +ccclass('cc.Node')(Node); diff --git a/cocos/core/scene-graph/scene-globals.jsb.ts b/cocos/core/scene-graph/scene-globals.jsb.ts index 51ade1399c..c2177c6920 100644 --- a/cocos/core/scene-graph/scene-globals.jsb.ts +++ b/cocos/core/scene-graph/scene-globals.jsb.ts @@ -20,10 +20,10 @@ */ import { - ccclass, displayName, + displayName, editable, formerlySerializedAs, - help, range, + range, readOnly, serializable, tooltip, @@ -31,16 +31,13 @@ import { visible // @ts-ignore } from 'cc.decorator'; -import { - _applyDecoratedDescriptor, - _assertThisInitialized, - _initializerDefineProperty, -} from '../data/utils/decorator-jsb-utils'; import { legacyCC } from '../global-exports'; -import { Color, Vec2, Vec3 } from '../math'; import { CCFloat, CCInteger } from '../data'; import { TextureCube } from '../assets/texture-cube'; import { Enum } from '../value-types'; +import { ccclass, displayOrder, rangeMin, rangeStep, slide } from '../data/decorators'; +import { EnvironmentLightingType } from '../renderer/scene'; +import { Material } from '../assets/material'; /** * @zh @@ -144,454 +141,33 @@ export const ShadowType = Enum({ ShadowMap: 1, }); -/** - * @en Environment lighting information in the Scene - * @zh 场景的环境光照相关信息 - */ // @ts-ignore export const AmbientInfo = jsb.AmbientInfo; legacyCC.AmbientInfo = AmbientInfo; -(function () { - const ambientInfoProto: any = AmbientInfo.prototype; - const ambientInfoDecorator = ccclass('cc.AmbientInfo'); - const _class2$w = AmbientInfo; - const _descriptor$q = _applyDecoratedDescriptor(_class2$w.prototype, '_skyColor', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return new Color(51, 128, 204, 1.0); - }, - }); - - const _descriptor2$j = _applyDecoratedDescriptor(_class2$w.prototype, '_skyIllum', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return 20000.0; // cjh FIXME: Ambient.SKY_ILLUM; - }, - }); - - const _descriptor3$d = _applyDecoratedDescriptor(_class2$w.prototype, '_groundAlbedo', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return new Color(51, 51, 51, 255); - }, - }); - - const _dec2$j = type(CCFloat); - - _applyDecoratedDescriptor(_class2$w.prototype, 'skyColor', [editable], Object.getOwnPropertyDescriptor(_class2$w.prototype, 'skyColor'), _class2$w.prototype); - _applyDecoratedDescriptor(_class2$w.prototype, 'skyIllum', [editable, _dec2$j], Object.getOwnPropertyDescriptor(_class2$w.prototype, 'skyIllum'), _class2$w.prototype); - _applyDecoratedDescriptor(_class2$w.prototype, 'groundAlbedo', [editable], Object.getOwnPropertyDescriptor(_class2$w.prototype, 'groundAlbedo'), _class2$w.prototype); - - ambientInfoProto._ctor = function () { - // _initializerDefineProperty(this, "_skyColor", _descriptor$q, this); - // _initializerDefineProperty(this, "_skyIllum", _descriptor2$j, this); - // _initializerDefineProperty(this, "_groundAlbedo", _descriptor3$d, this); - }; - - ambientInfoDecorator(AmbientInfo); - -})(); - -/** - * @en Skybox related information - * @zh 天空盒相关信息 - */ // @ts-ignore export const SkyboxInfo = jsb.SkyboxInfo; legacyCC.SkyboxInfo = SkyboxInfo; -(function () { - const skyboxInfoProto: any = SkyboxInfo.prototype; - const skyboxInfoDecorator = ccclass('cc.SkyboxInfo'); - const _dec16$1 = type(TextureCube); - const _dec14$1 = type(TextureCube); - const _dec17$1 = type(TextureCube); - const _dec18$1 = type(TextureCube); - const _dec15$1 = formerlySerializedAs('_envmap'); - const _dec19$1 = visible(); - const _dec20$1 = tooltip(); - const _dec21$1 = tooltip(); - const _dec22$1 = tooltip(); - const _dec23$1 = tooltip(); - const _dec24$1 = type(TextureCube); - const _dec25$1 = tooltip(); - const _dec26$1 = visible(); - const _dec27$1 = type(TextureCube); - const _class5$2 = SkyboxInfo; - - const _descriptor7$2 = _applyDecoratedDescriptor(_class5$2.prototype, "_applyDiffuseMap", [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return false; - } - }); - - const _descriptor8$1 = _applyDecoratedDescriptor(_class5$2.prototype, "_envmap", [serializable, _dec14$1, _dec15$1], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return null; - } - }); - - const _descriptor8$2 = _applyDecoratedDescriptor(_class5$2.prototype, "_envmapHDR", [serializable, _dec14$1, _dec15$1], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return null; - } - }); - - const _descriptor9$1 = _applyDecoratedDescriptor(_class5$2.prototype, "_envmapLDR", [serializable, _dec16$1], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return null; - } - }); - - const _descriptor10$1 = _applyDecoratedDescriptor(_class5$2.prototype, "_diffuseMapHDR", [serializable, _dec17$1], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return null; - } - }); - - const _descriptor11$1 = _applyDecoratedDescriptor(_class5$2.prototype, "_diffuseMapLDR", [serializable, _dec18$1], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return null; - } - }); - - const _descriptor12$1 = _applyDecoratedDescriptor(_class5$2.prototype, "_enabled", [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return false; - } - }); - - const _descriptor13$1 = _applyDecoratedDescriptor(_class5$2.prototype, "_useIBL", [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return false; - } - }); - - const _descriptor14$1 = _applyDecoratedDescriptor(_class5$2.prototype, "_useHDR", [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return true; - } - }); - - const _descriptor15$1 = _applyDecoratedDescriptor(_class5$2.prototype, "_editableMaterial", [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return null; - } - }); - - _applyDecoratedDescriptor(_class5$2.prototype, "applyDiffuseMap", [_dec19$1, editable, _dec20$1], Object.getOwnPropertyDescriptor(_class5$2.prototype, "applyDiffuseMap"), _class5$2.prototype); - _applyDecoratedDescriptor(_class5$2.prototype, "enabled", [editable, _dec21$1], Object.getOwnPropertyDescriptor(_class5$2.prototype, "enabled"), _class5$2.prototype); - _applyDecoratedDescriptor(_class5$2.prototype, "useIBL", [editable, _dec22$1], Object.getOwnPropertyDescriptor(_class5$2.prototype, "useIBL"), _class5$2.prototype); - _applyDecoratedDescriptor(_class5$2.prototype, "useHDR", [editable, _dec23$1], Object.getOwnPropertyDescriptor(_class5$2.prototype, "useHDR"), _class5$2.prototype); - _applyDecoratedDescriptor(_class5$2.prototype, "envmap", [editable, _dec24$1, _dec25$1], Object.getOwnPropertyDescriptor(_class5$2.prototype, "envmap"), _class5$2.prototype); - _applyDecoratedDescriptor(_class5$2.prototype, "diffuseMap", [_dec26$1, editable, readOnly, _dec27$1], Object.getOwnPropertyDescriptor(_class5$2.prototype, "diffuseMap"), _class5$2.prototype); - - - skyboxInfoProto._ctor = function () { - // _initializerDefineProperty(this, "_envmap", _descriptor4$b, this); - // _initializerDefineProperty(this, "_isRGBE", _descriptor5$8, this); - // _initializerDefineProperty(this, "_enabled", _descriptor6$3, this); - // _initializerDefineProperty(this, "_useIBL", _descriptor7$3, this); - }; - - skyboxInfoDecorator(SkyboxInfo); - -})(); - -/** - * @zh 全局雾相关信息 - * @en Global fog info - */ // @ts-ignore export const FogInfo = jsb.FogInfo; legacyCC.FogInfo = FogInfo; -(function () { - const fogInfoProto: any = FogInfo.prototype; - const fogInfoDecorator = ccclass('cc.FogInfo'); - const _class8$1 = FogInfo; - - _applyDecoratedDescriptor(_class8$1.prototype, '_type', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return FogType.LINEAR; - }, - }); - _applyDecoratedDescriptor(_class8$1.prototype, '_fogColor', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return new Color('#C8C8C8'); - }, - }); - _applyDecoratedDescriptor(_class8$1.prototype, '_enabled', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return false; - }, - }); - - _applyDecoratedDescriptor(_class8$1.prototype, '_fogDensity', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return 0.3; - }, - }); - _applyDecoratedDescriptor(_class8$1.prototype, '_fogStart', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return 0.5; - }, - }); - _applyDecoratedDescriptor(_class8$1.prototype, '_fogEnd', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return 300; - }, - }); - _applyDecoratedDescriptor(_class8$1.prototype, '_fogAtten', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return 5; - }, - }); - _applyDecoratedDescriptor(_class8$1.prototype, '_fogTop', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return 1.5; - }, - }); - _applyDecoratedDescriptor(_class8$1.prototype, '_fogRange', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return 1.2; - }, - }); - - // , _dec8$1 = visible(), _dec9$1 = type(CCFloat), _dec10$1 = range(), _dec11$1 = rangeStep(), _dec12$1 = displayOrder(), _dec13$1 = visible(), _dec14$1 = type(CCFloat), _dec15$1 = rangeStep(), _dec16$1 = displayOrder(), _dec17$1 = visible(), _dec18$1 = type(CCFloat), _dec19$1 = rangeStep(), _dec20$1 = displayOrder(), _dec21$1 = visible(), _dec22$1 = type(CCFloat), _dec23$1 = rangeMin(), _dec24$1 = rangeStep(), _dec25$1 = displayOrder(), _dec26$1 = visible(), _dec27$1 = type(CCFloat), _dec28$1 = rangeStep(), _dec29$1 = displayOrder(), _dec30$1 = visible(), _dec31$1 = type(CCFloat), _dec32 = rangeStep(), _dec33 = displayOrder() - - // _applyDecoratedDescriptor(_class8$1.prototype, "enabled", [editable], Object.getOwnPropertyDescriptor(_class8$1.prototype, "enabled"), _class8$1.prototype); - // _applyDecoratedDescriptor(_class8$1.prototype, "fogColor", [editable], Object.getOwnPropertyDescriptor(_class8$1.prototype, "fogColor"), _class8$1.prototype); - // _applyDecoratedDescriptor(_class8$1.prototype, "type", [editable, _dec7$1], Object.getOwnPropertyDescriptor(_class8$1.prototype, "type"), _class8$1.prototype); - // _applyDecoratedDescriptor(_class8$1.prototype, "fogDensity", [_dec8$1, _dec9$1, _dec10$1, _dec11$1, slide, _dec12$1], Object.getOwnPropertyDescriptor(_class8$1.prototype, "fogDensity"), _class8$1.prototype); - // _applyDecoratedDescriptor(_class8$1.prototype, "fogStart", [_dec13$1, _dec14$1, _dec15$1, _dec16$1], Object.getOwnPropertyDescriptor(_class8$1.prototype, "fogStart"), _class8$1.prototype); - // _applyDecoratedDescriptor(_class8$1.prototype, "fogEnd", [_dec17$1, _dec18$1, _dec19$1, _dec20$1], Object.getOwnPropertyDescriptor(_class8$1.prototype, "fogEnd"), _class8$1.prototype); - // _applyDecoratedDescriptor(_class8$1.prototype, "fogAtten", [_dec21$1, _dec22$1, _dec23$1, _dec24$1, _dec25$1], Object.getOwnPropertyDescriptor(_class8$1.prototype, "fogAtten"), _class8$1.prototype); - // _applyDecoratedDescriptor(_class8$1.prototype, "fogTop", [_dec26$1, _dec27$1, _dec28$1, _dec29$1], Object.getOwnPropertyDescriptor(_class8$1.prototype, "fogTop"), _class8$1.prototype), _applyDecoratedDescriptor(_class8$1.prototype, "fogRange", [_dec30$1, _dec31$1, _dec32, _dec33], Object.getOwnPropertyDescriptor(_class8$1.prototype, "fogRange"), _class8$1.prototype)), _class8$1)) || _class7$1); - - fogInfoDecorator(FogInfo); -})(); - -/** - * @en Scene level planar shadow related information - * @zh 平面阴影相关信息 - */ // @ts-ignore export const ShadowsInfo = jsb.ShadowsInfo; legacyCC.ShadowsInfo = ShadowsInfo; -(function () { - const shadowInfoDecorator = ccclass('cc.ShadowsInfo'); - - const _class11$1 = ShadowsInfo; - const _descriptor17$1 = _applyDecoratedDescriptor(_class11$1.prototype, '_type', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return ShadowType.Planar; - }, - }); - const _descriptor18$1 = _applyDecoratedDescriptor(_class11$1.prototype, '_enabled', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return false; - }, - }); - - const _descriptor19$1 = _applyDecoratedDescriptor(_class11$1.prototype, '_normal', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return new Vec3(0, 1, 0); - }, - }); - - const _descriptor20$1 = _applyDecoratedDescriptor(_class11$1.prototype, '_distance', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return 0; - }, - }); - - const _descriptor21$1 = _applyDecoratedDescriptor(_class11$1.prototype, '_shadowColor', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return new Color(0, 0, 0, 76); - }, - }); - - const _descriptor29$1 = _applyDecoratedDescriptor(_class11$1.prototype, '_maxReceived', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return 4; - }, - }); - - const _descriptor30$11 = _applyDecoratedDescriptor(_class11$1.prototype, '_size', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return new Vec2(512, 512); - }, - }); - - shadowInfoDecorator(ShadowsInfo); - -})(); - -// OctreeInfo // @ts-ignore export const OctreeInfo = jsb.OctreeInfo; legacyCC.OctreeInfo = OctreeInfo; -(function () { - const octreeInfoDecorator = ccclass('cc.OctreeInfo'); - const _class14$1 = OctreeInfo; - var DEFAULT_WORLD_MIN_POS = new Vec3(-1024.0, -1024.0, -1024.0); - var DEFAULT_WORLD_MAX_POS = new Vec3(1024.0, 1024.0, 1024.0); - var DEFAULT_OCTREE_DEPTH = 8; - - const _dec116 = help(); - const _dec117 = tooltip(); - const _dec118 = tooltip(); - const _dec119 = displayName(); - const _dec120 = tooltip(); - const _dec121 = displayName(); - const _dec122 = range(); - const _dec123 = type(CCInteger); - const _dec124 = tooltip(); - - const _descriptor43 = _applyDecoratedDescriptor(_class14$1.prototype, "_enabled", [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return false; - } - }); - - const _descriptor44 = _applyDecoratedDescriptor(_class14$1.prototype, "_minPos", [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return new Vec3(DEFAULT_WORLD_MIN_POS); - } - }); - - const _descriptor45 = _applyDecoratedDescriptor(_class14$1.prototype, "_maxPos", [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return new Vec3(DEFAULT_WORLD_MAX_POS); - } - }); - - const _descriptor46 = _applyDecoratedDescriptor(_class14$1.prototype, "_depth", [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return DEFAULT_OCTREE_DEPTH; - } - }); - - _applyDecoratedDescriptor(_class14$1.prototype, "enabled", [editable, _dec117], Object.getOwnPropertyDescriptor(_class14$1.prototype, "enabled"), _class14$1.prototype); - _applyDecoratedDescriptor(_class14$1.prototype, "minPos", [editable, _dec118, _dec119], Object.getOwnPropertyDescriptor(_class14$1.prototype, "minPos"), _class14$1.prototype); - _applyDecoratedDescriptor(_class14$1.prototype, "maxPos", [editable, _dec120, _dec121], Object.getOwnPropertyDescriptor(_class14$1.prototype, "maxPos"), _class14$1.prototype); - _applyDecoratedDescriptor(_class14$1.prototype, "depth", [editable, _dec122, _dec123, _dec124], Object.getOwnPropertyDescriptor(_class14$1.prototype, "depth"), _class14$1.prototype); - - octreeInfoDecorator(OctreeInfo); -})(); - -/** - * @en All scene related global parameters, it affects all content in the corresponding scene - * @zh 各类场景级别的渲染参数,将影响全场景的所有物体 - */ // @ts-ignore export const SceneGlobals = jsb.SceneGlobals; legacyCC.SceneGlobals = SceneGlobals; (function () { const sceneGlobalsProto: any = SceneGlobals.prototype; - const sceneGlobalsDecorator = ccclass('cc.SceneGlobals'); sceneGlobalsProto._ctor = function () { this._ambientRef = null; @@ -672,42 +248,206 @@ legacyCC.SceneGlobals = SceneGlobals; this.setOctreeInfo(v); }, }); - - const _class14$1 = SceneGlobals; - const _descriptor32$1 = _applyDecoratedDescriptor(_class14$1.prototype, 'ambient', [serializable, editable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return new AmbientInfo(); - }, - }); - const _descriptor33$1 = _applyDecoratedDescriptor(_class14$1.prototype, 'shadows', [serializable, editable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return new ShadowsInfo(); - }, - }); - const _descriptor34$1 = _applyDecoratedDescriptor(_class14$1.prototype, '_skybox', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return new SkyboxInfo(); - }, - }); - const _descriptor35$1 = _applyDecoratedDescriptor(_class14$1.prototype, 'fog', [editable, serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return new FogInfo(); - }, - }); - - // _applyDecoratedDescriptor(_class14$1.prototype, "skybox", [editable, _dec62], Object.getOwnPropertyDescriptor(_class14$1.prototype, "skybox"), _class14$1.prototype); - - sceneGlobalsDecorator(SceneGlobals); })(); + +// handle meta data, it is generated automatically + +const SceneGlobalsProto = SceneGlobals.prototype; +editable(SceneGlobalsProto, 'ambient'); +serializable(SceneGlobalsProto, 'ambient'); +editable(SceneGlobalsProto, 'shadows'); +serializable(SceneGlobalsProto, 'shadows'); +serializable(SceneGlobalsProto, '_skybox'); +serializable(SceneGlobalsProto, 'fog'); +editable(SceneGlobalsProto, 'fog'); +const skyboxDescriptor = Object.getOwnPropertyDescriptor(SceneGlobalsProto, 'skybox'); +type(SkyboxInfo)(SceneGlobalsProto, 'skybox', skyboxDescriptor); +editable(SceneGlobalsProto, 'skybox', skyboxDescriptor); +serializable(SceneGlobalsProto, 'octree'); +editable(SceneGlobalsProto, 'octree'); +ccclass('cc.SceneGlobals')(SceneGlobals); + +const OctreeInfoProto = OctreeInfo.prototype; +serializable(OctreeInfoProto, '_enabled'); +serializable(OctreeInfoProto, '_minPos'); +serializable(OctreeInfoProto, '_maxPos'); +serializable(OctreeInfoProto, '_depth'); +const enabledDescriptor = Object.getOwnPropertyDescriptor(OctreeInfoProto, 'enabled'); +tooltip('i18n:octree_culling.enabled')(OctreeInfoProto, 'enabled', enabledDescriptor); +editable(OctreeInfoProto, 'enabled', enabledDescriptor); +const minPosDescriptor = Object.getOwnPropertyDescriptor(OctreeInfoProto, 'minPos'); +displayName('World MinPos')(OctreeInfoProto, 'minPos', minPosDescriptor); +tooltip('i18n:octree_culling.minPos')(OctreeInfoProto, 'minPos', minPosDescriptor); +editable(OctreeInfoProto, 'minPos', minPosDescriptor); +const maxPosDescriptor = Object.getOwnPropertyDescriptor(OctreeInfoProto, 'maxPos'); +displayName('World MaxPos')(OctreeInfoProto, 'maxPos', maxPosDescriptor); +tooltip('i18n:octree_culling.maxPos')(OctreeInfoProto, 'maxPos', maxPosDescriptor); +editable(OctreeInfoProto, 'maxPos', maxPosDescriptor); +const depthDescriptor = Object.getOwnPropertyDescriptor(OctreeInfoProto, 'depth'); +tooltip('i18n:octree_culling.depth')(OctreeInfoProto, 'depth', depthDescriptor); +type(CCInteger)(OctreeInfoProto, 'depth', depthDescriptor); +slide(OctreeInfoProto, 'depth', depthDescriptor); +range([4, 12, 1])(OctreeInfoProto, 'depth', depthDescriptor); +editable(OctreeInfoProto, 'depth', depthDescriptor); +ccclass('cc.OctreeInfo')(OctreeInfo); + +const ShadowsInfoProto = ShadowsInfo.prototype; +serializable(ShadowsInfoProto, '_enabled'); +serializable(ShadowsInfoProto, '_type'); +serializable(ShadowsInfoProto, '_normal'); +serializable(ShadowsInfoProto, '_distance'); +serializable(ShadowsInfoProto, '_shadowColor'); +serializable(ShadowsInfoProto, '_maxReceived'); +serializable(ShadowsInfoProto, '_size'); +const shadowEnabledDescriptor = Object.getOwnPropertyDescriptor(ShadowsInfoProto, 'enabled'); +tooltip('i18n:shadow.enabled')(ShadowsInfoProto, 'enabled', shadowEnabledDescriptor); +editable(ShadowsInfoProto, 'enabled', shadowEnabledDescriptor); +const typeDescriptor = Object.getOwnPropertyDescriptor(ShadowsInfoProto, 'type'); +type(ShadowType)(ShadowsInfoProto, 'type', typeDescriptor); +editable(ShadowsInfoProto, 'type', typeDescriptor); +const shadowColorDescriptor = Object.getOwnPropertyDescriptor(ShadowsInfoProto, 'shadowColor'); +visible(function (this) { /* Need to copy source code */ })(ShadowsInfoProto, 'shadowColor', shadowColorDescriptor); +const planeDirectionDescriptor = Object.getOwnPropertyDescriptor(ShadowsInfoProto, 'planeDirection'); +tooltip('i18n:shadow.planeDirection')(ShadowsInfoProto, 'planeDirection', planeDirectionDescriptor); +visible(function (this) { /* Need to copy source code */ })(ShadowsInfoProto, 'planeDirection', planeDirectionDescriptor); +const planeHeightDescriptor = Object.getOwnPropertyDescriptor(ShadowsInfoProto, 'planeHeight'); +tooltip('i18n:shadow.planeHeight')(ShadowsInfoProto, 'planeHeight', planeHeightDescriptor); +visible(function (this) { /* Need to copy source code */ })(ShadowsInfoProto, 'planeHeight', planeHeightDescriptor); +type(CCFloat)(ShadowsInfoProto, 'planeHeight', planeHeightDescriptor); +editable(ShadowsInfoProto, 'planeHeight', planeHeightDescriptor); +const maxReceivedDescriptor = Object.getOwnPropertyDescriptor(ShadowsInfoProto, 'maxReceived'); +visible(function (this) { /* Need to copy source code */ })(ShadowsInfoProto, 'maxReceived', maxReceivedDescriptor); +tooltip('i18n:shadow.maxReceived')(ShadowsInfoProto, 'maxReceived', maxReceivedDescriptor); +type(CCInteger)(ShadowsInfoProto, 'maxReceived', maxReceivedDescriptor); +const shadowMapSizeDescriptor = Object.getOwnPropertyDescriptor(ShadowsInfoProto, 'shadowMapSize'); +visible(function (this) { /* Need to copy source code */ })(ShadowsInfoProto, 'shadowMapSize', shadowMapSizeDescriptor); +tooltip('i18n:shadow.shadowMapSize')(ShadowsInfoProto, 'shadowMapSize', shadowMapSizeDescriptor); +type(ShadowSize)(ShadowsInfoProto, 'shadowMapSize', shadowMapSizeDescriptor); +ccclass('cc.ShadowsInfo')(ShadowsInfo); + +const FogInfoProto = FogInfo.prototype; +serializable(FogInfoProto, '_type'); +serializable(FogInfoProto, '_fogColor'); +serializable(FogInfoProto, '_enabled'); +serializable(FogInfoProto, '_fogDensity'); +serializable(FogInfoProto, '_fogStart'); +serializable(FogInfoProto, '_fogEnd'); +serializable(FogInfoProto, '_fogAtten'); +serializable(FogInfoProto, '_fogTop'); +serializable(FogInfoProto, '_fogRange'); +serializable(FogInfoProto, '_accurate'); +const fogEnabledDescriptor = Object.getOwnPropertyDescriptor(FogInfoProto, 'enabled'); +displayOrder(0)(FogInfoProto, 'enabled', fogEnabledDescriptor); +tooltip('i18n:fog.enabled')(FogInfoProto, 'enabled', fogEnabledDescriptor); +editable(FogInfoProto, 'enabled', fogEnabledDescriptor); +const accurateDescriptor = Object.getOwnPropertyDescriptor(FogInfoProto, 'accurate'); +displayOrder(0)(FogInfoProto, 'accurate', accurateDescriptor); +tooltip('i18n:fog.accurate')(FogInfoProto, 'accurate', accurateDescriptor); +editable(FogInfoProto, 'accurate', accurateDescriptor); +const fogColorDescriptor = Object.getOwnPropertyDescriptor(FogInfoProto, 'fogColor'); +tooltip('i18n:fog.fogColor')(FogInfoProto, 'fogColor', fogColorDescriptor); +editable(FogInfoProto, 'fogColor', fogColorDescriptor); +const fogTypeDescriptor = Object.getOwnPropertyDescriptor(FogInfoProto, 'type'); +tooltip('i18n:fog.type')(FogInfoProto, 'type', fogTypeDescriptor); +displayOrder(1)(FogInfoProto, 'type', fogTypeDescriptor); +type(FogType)(FogInfoProto, 'type', fogTypeDescriptor); +editable(FogInfoProto, 'type', fogTypeDescriptor); +const fogDensityDescriptor = Object.getOwnPropertyDescriptor(FogInfoProto, 'fogDensity'); +tooltip('i18n:fog.fogDensity')(FogInfoProto, 'fogDensity', fogDensityDescriptor); +slide(FogInfoProto, 'fogDensity', fogDensityDescriptor); +rangeStep(0.01)(FogInfoProto, 'fogDensity', fogDensityDescriptor); +range([0, 1])(FogInfoProto, 'fogDensity', fogDensityDescriptor); +type(CCFloat)(FogInfoProto, 'fogDensity', fogDensityDescriptor); +visible(function (this) { /* Need to copy source code */ })(FogInfoProto, 'fogDensity', fogDensityDescriptor); +const fogStartDescriptor = Object.getOwnPropertyDescriptor(FogInfoProto, 'fogStart'); +tooltip('i18n:fog.fogStart')(FogInfoProto, 'fogStart', fogStartDescriptor); +rangeStep(0.01)(FogInfoProto, 'fogStart', fogStartDescriptor); +type(CCFloat)(FogInfoProto, 'fogStart', fogStartDescriptor); +visible(function (this) { /* Need to copy source code */ })(FogInfoProto, 'fogStart', fogStartDescriptor); +const fogEndDescriptor = Object.getOwnPropertyDescriptor(FogInfoProto, 'fogEnd'); +tooltip('i18n:fog.fogEnd')(FogInfoProto, 'fogEnd', fogEndDescriptor); +rangeStep(0.01)(FogInfoProto, 'fogEnd', fogEndDescriptor); +type(CCFloat)(FogInfoProto, 'fogEnd', fogEndDescriptor); +visible(function (this) { /* Need to copy source code */ })(FogInfoProto, 'fogEnd', fogEndDescriptor); +const fogAttenDescriptor = Object.getOwnPropertyDescriptor(FogInfoProto, 'fogAtten'); +tooltip('i18n:fog.fogAtten')(FogInfoProto, 'fogAtten', fogAttenDescriptor); +rangeStep(0.01)(FogInfoProto, 'fogAtten', fogAttenDescriptor); +rangeMin(0.01)(FogInfoProto, 'fogAtten', fogAttenDescriptor); +type(CCFloat)(FogInfoProto, 'fogAtten', fogAttenDescriptor); +visible(function (this) { /* Need to copy source code */ })(FogInfoProto, 'fogAtten', fogAttenDescriptor); +const fogTopDescriptor = Object.getOwnPropertyDescriptor(FogInfoProto, 'fogTop'); +tooltip('i18n:fog.fogTop')(FogInfoProto, 'fogTop', fogTopDescriptor); +rangeStep(0.01)(FogInfoProto, 'fogTop', fogTopDescriptor); +type(CCFloat)(FogInfoProto, 'fogTop', fogTopDescriptor); +visible(function (this) { /* Need to copy source code */ })(FogInfoProto, 'fogTop', fogTopDescriptor); +const fogRangeDescriptor = Object.getOwnPropertyDescriptor(FogInfoProto, 'fogRange'); +tooltip('i18n:fog.fogRange')(FogInfoProto, 'fogRange', fogRangeDescriptor); +rangeStep(0.01)(FogInfoProto, 'fogRange', fogRangeDescriptor); +type(CCFloat)(FogInfoProto, 'fogRange', fogRangeDescriptor); +visible(function (this) { /* Need to copy source code */ })(FogInfoProto, 'fogRange', fogRangeDescriptor); +ccclass('cc.FogInfo')(FogInfo); + +const SkyboxInfoProto = SkyboxInfo.prototype; +serializable(SkyboxInfoProto, '_envLightingType'); +formerlySerializedAs('_envmap')(SkyboxInfoProto, '_envmapHDR'); +type(TextureCube)(SkyboxInfoProto, '_envmapHDR'); +serializable(SkyboxInfoProto, '_envmapHDR'); +type(TextureCube)(SkyboxInfoProto, '_envmapLDR'); +serializable(SkyboxInfoProto, '_envmapLDR'); +type(TextureCube)(SkyboxInfoProto, '_diffuseMapHDR'); +serializable(SkyboxInfoProto, '_diffuseMapHDR'); +type(TextureCube)(SkyboxInfoProto, '_diffuseMapLDR'); +serializable(SkyboxInfoProto, '_diffuseMapLDR'); +serializable(SkyboxInfoProto, '_enabled'); +serializable(SkyboxInfoProto, '_useHDR'); +type(Material)(SkyboxInfoProto, '_editableMaterial'); +serializable(SkyboxInfoProto, '_editableMaterial'); +const skyboxEnabledDescriptor = Object.getOwnPropertyDescriptor(SkyboxInfoProto, 'enabled'); +tooltip('i18n:skybox.enabled')(SkyboxInfoProto, 'enabled', skyboxEnabledDescriptor); +editable(SkyboxInfoProto, 'enabled', skyboxEnabledDescriptor); +const envLightingTypeDescriptor = Object.getOwnPropertyDescriptor(SkyboxInfoProto, 'envLightingType'); +tooltip('i18n:skybox.EnvironmentLightingType')(SkyboxInfoProto, 'envLightingType', envLightingTypeDescriptor); +type(EnvironmentLightingType)(SkyboxInfoProto, 'envLightingType', envLightingTypeDescriptor); +editable(SkyboxInfoProto, 'envLightingType', envLightingTypeDescriptor); +const useHDRDescriptor = Object.getOwnPropertyDescriptor(SkyboxInfoProto, 'useHDR'); +tooltip('i18n:skybox.useHDR')(SkyboxInfoProto, 'useHDR', useHDRDescriptor); +editable(SkyboxInfoProto, 'useHDR', useHDRDescriptor); +const envmapDescriptor = Object.getOwnPropertyDescriptor(SkyboxInfoProto, 'envmap'); +tooltip('i18n:skybox.envmap')(SkyboxInfoProto, 'envmap', envmapDescriptor); +type(TextureCube)(SkyboxInfoProto, 'envmap', envmapDescriptor); +editable(SkyboxInfoProto, 'envmap', envmapDescriptor); +const diffuseMapDescriptor = Object.getOwnPropertyDescriptor(SkyboxInfoProto, 'diffuseMap'); +displayOrder(100)(SkyboxInfoProto, 'diffuseMap', diffuseMapDescriptor); +type(TextureCube)(SkyboxInfoProto, 'diffuseMap', diffuseMapDescriptor); +readOnly(SkyboxInfoProto, 'diffuseMap', diffuseMapDescriptor); +editable(SkyboxInfoProto, 'diffuseMap', diffuseMapDescriptor); +visible(function (this) { /* Need to copy source code */ })(SkyboxInfoProto, 'diffuseMap', diffuseMapDescriptor); +const skyboxMaterialDescriptor = Object.getOwnPropertyDescriptor(SkyboxInfoProto, 'skyboxMaterial'); +tooltip('i18n:skybox.material')(SkyboxInfoProto, 'skyboxMaterial', skyboxMaterialDescriptor); +type(Material)(SkyboxInfoProto, 'skyboxMaterial', skyboxMaterialDescriptor); +editable(SkyboxInfoProto, 'skyboxMaterial', skyboxMaterialDescriptor); +ccclass('cc.SkyboxInfo')(SkyboxInfo); + +const AmbientInfoProto = AmbientInfo.prototype; +formerlySerializedAs('_skyColor')(AmbientInfoProto, '_skyColorHDR'); +serializable(AmbientInfoProto, '_skyColorHDR'); +formerlySerializedAs('_skyIllum')(AmbientInfoProto, '_skyIllumHDR'); +serializable(AmbientInfoProto, '_skyIllumHDR'); +formerlySerializedAs('_groundAlbedo')(AmbientInfoProto, '_groundAlbedoHDR'); +serializable(AmbientInfoProto, '_groundAlbedoHDR'); +serializable(AmbientInfoProto, '_skyColorLDR'); +serializable(AmbientInfoProto, '_skyIllumLDR'); +serializable(AmbientInfoProto, '_groundAlbedoLDR'); +const skyLightingColorDescriptor = Object.getOwnPropertyDescriptor(AmbientInfoProto, 'skyLightingColor'); +tooltip('i18n:ambient.skyLightingColor')(AmbientInfoProto, 'skyLightingColor', skyLightingColorDescriptor); +editable(AmbientInfoProto, 'skyLightingColor', skyLightingColorDescriptor); +visible(() => { /* Need to copy source code */ })(AmbientInfoProto, 'skyLightingColor', skyLightingColorDescriptor); +const skyIllumDescriptor = Object.getOwnPropertyDescriptor(AmbientInfoProto, 'skyIllum'); +tooltip('i18n:ambient.skyIllum')(AmbientInfoProto, 'skyIllum', skyIllumDescriptor); +type(CCFloat)(AmbientInfoProto, 'skyIllum', skyIllumDescriptor); +editable(AmbientInfoProto, 'skyIllum', skyIllumDescriptor); +const groundLightingColorDescriptor = Object.getOwnPropertyDescriptor(AmbientInfoProto, 'groundLightingColor'); +tooltip('i18n:ambient.groundLightingColor')(AmbientInfoProto, 'groundLightingColor', groundLightingColorDescriptor); +editable(AmbientInfoProto, 'groundLightingColor', groundLightingColorDescriptor); +visible(() => { /* Need to copy source code */ })(AmbientInfoProto, 'groundLightingColor', groundLightingColorDescriptor); +ccclass('cc.AmbientInfo')(AmbientInfo); diff --git a/cocos/core/scene-graph/scene.jsb.ts b/cocos/core/scene-graph/scene.jsb.ts index 4e015d6cce..83698fa30f 100644 --- a/cocos/core/scene-graph/scene.jsb.ts +++ b/cocos/core/scene-graph/scene.jsb.ts @@ -21,13 +21,7 @@ import { ccclass, editable, serializable } from 'cc.decorator'; import { EDITOR, TEST } from "internal:constants"; -import { - _applyDecoratedDescriptor, - _assertThisInitialized, - _initializerDefineProperty, -} from '../data/utils/decorator-jsb-utils'; import { legacyCC } from '../global-exports'; -import { SceneGlobals } from './scene-globals'; import { Node } from './node'; import { applyTargetOverrides, expandNestedPrefabInstanceNode } from "../utils/prefab/utils"; import { assert } from "../platform/debug"; @@ -35,11 +29,9 @@ import { updateChildrenForDeserialize } from '../utils/jsb-utils'; export const Scene = jsb.Scene; export type Scene = jsb.Scene; - -const clsDecorator = ccclass('cc.Scene'); +legacyCC.Scene = Scene; const sceneProto: any = Scene.prototype; -const _class2$x = Scene; Object.defineProperty(sceneProto, '_globals', { enumerable: true, @@ -83,35 +75,12 @@ Object.defineProperty(sceneProto, 'renderScene', { } }); -_applyDecoratedDescriptor(_class2$x.prototype, 'globals', [editable], Object.getOwnPropertyDescriptor(_class2$x.prototype, 'globals'), _class2$x.prototype); -const _descriptor$r = _applyDecoratedDescriptor(_class2$x.prototype, 'autoReleaseAssets', [serializable, editable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return false; - }, -}); - -const _descriptor2$k = _applyDecoratedDescriptor(_class2$x.prototype, '_globals', [serializable], { - configurable: true, - enumerable: true, - writable: true, - initializer: function initializer () { - return new SceneGlobals(); - }, -}); - sceneProto._ctor = function () { Node.prototype._ctor.apply(this, arguments); this._inited = false; this._renderSceneInternal = null; this._globalRef = null; this._prefabSyncedInLiveReload = false; - // eslint-disable-next-line @typescript-eslint/no-this-alias - // const _this = this; - // _initializerDefineProperty(_this, "autoReleaseAssets", _descriptor$r, _assertThisInitialized(_this)); - // _initializerDefineProperty(_this, "_globals", _descriptor2$k, _assertThisInitialized(_this)); }; sceneProto._onBatchCreated = function (dontSyncChildPrefab: boolean) { @@ -145,7 +114,6 @@ sceneProto._load = function () { oldLoad.call(this); }; -const oldActivate = sceneProto._activate; sceneProto._activate = function (active: boolean) { active = (active !== false); if (EDITOR) { @@ -162,5 +130,11 @@ sceneProto._activate = function (active: boolean) { } }; -clsDecorator(Scene); -legacyCC.Scene = Scene; +// handle meta data, it is generated automatically +const SceneProto = Scene.prototype; +const globalsDescriptor = Object.getOwnPropertyDescriptor(SceneProto, 'globals'); +editable(SceneProto, 'globals', globalsDescriptor); +editable(SceneProto, 'autoReleaseAssets'); +serializable(SceneProto, 'autoReleaseAssets'); +serializable(SceneProto, '_globals'); +ccclass('cc.Scene')(Scene);