jsb classes apply decorator from .ts source files (#14403)

* decorator parser
* remove used variable
This commit is contained in:
江战
2023-03-07 10:34:50 +08:00
committed by GitHub
parent a6684b18c9
commit b2bb2bf559
31 changed files with 3327 additions and 701 deletions
+105
View File
@@ -0,0 +1,105 @@
/// generate jsb decorators
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable max-len */
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const fs = require('fs');
const os = require('os');
const contentLines = [];
process.on('message', (msg) => {
if (msg.event === 'write-decorator') {
contentLines.push({ className: msg.className, lines: msg.lines });
}
});
const engineDir = path.resolve(__dirname, '../..');
const tmpDir = os.tmpdir();
const BUILD_CONFIG = {
options: {
engine: engineDir,
platform: 'HTML5',
moduleFormat: 2,
compress: false,
split: false,
ammoJsWasm: 'fallback',
assetURLFormat: 'runtime-resolved',
noDeprecatedFeatures: false,
engineName: 'cocos-js',
sourceMaps: false,
features: [
'2d', '3d',
'animation', 'audio',
'base', 'dragon-bones',
'gfx-webgl', 'gfx-webgl2',
'intersection-2d', 'light-probe',
'marionette', 'particle',
'particle-2d', 'physics-2d-box2d',
'physics-ammo', 'primitive',
'profiler', 'skeletal-animation',
'spine', 'terrain',
'tiled-map', 'tween',
'ui', 'video',
'websocket', 'webview',
],
loose: true,
mode: 'BUILD',
flags: { DEBUG: false, UI_GPU_DRIVEN: false },
name: 'cocos-js',
// incremental: 'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\CocosCreator\\3.7.2\\builder\\engine\\8e98547c3502329ef2d27ebed2ca0eac.watch-files.json',
//out: 'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\CocosCreator\\3.7.2\\builder\\engine\\8e98547c3502329ef2d27ebed2ca0eac',
out: tmpDir,
buildTimeConstants: {
HTML5: true,
NATIVE: false,
WECHAT: false,
BAIDU: false,
XIAOMI: false,
ALIPAY: false,
TAOBAO: false,
BYTEDANCE: false,
OPPO: false,
VIVO: false,
HUAWEI: false,
COCOSPLAY: false,
QTT: false,
LINKSURE: false,
EDITOR: false,
PREVIEW: false,
BUILD: true,
TEST: false,
DEBUG: true,
SERVER_MODE: false,
DEV: false,
MINIGAME: false,
RUNTIME_BASED: false,
SUPPORT_JIT: true,
JSB: false,
NOT_PACK_PHYSX_LIBS: false,
NET_MODE: 0,
WEBGPU: false,
},
generateDecoratorsForJSB: true,
// metaFile: 'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\CocosCreator\\3.7.2\\builder\\engine\\8e98547c3502329ef2d27ebed2ca0eac.meta\\meta.json'
},
};
process.env.ENGINE_PATH = engineDir;
const buildEngine = require(`${engineDir}/scripts/build-engine/dist/index.js`);
buildEngine.build(BUILD_CONFIG.options).then((result) => {
console.log('done!!!');
console.log(result);
const sortedLines = contentLines.sort((a, b) => a.className.localeCompare(b.className)).map((x) => x.lines.join('\n')).join('\n');
const destFile = path.join(engineDir, 'cocos/native-binding/decorators.ts');
fs.writeFileSync(destFile, `${sortedLines}\n`, 'utf8');
process.exit(0);
}).catch((err) => {
console.error(err);
process.exit(-1);
});
+12
View File
@@ -14,6 +14,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Generate decorators
run: |
npm install
cd scripts/build-engine
npm install
npm install @babel/types @babel/traverse @babel/generator
npm run build
cd ../..
node .github/workflows/gen_decorators.js
cd scripts/build-engine
git checkout HEAD . # revert all changes within build-engine/
- name: Download external libraries
run: |
EXT_VERSION=`node ./.github/workflows/get-native-external-version.js`
+2 -6
View File
@@ -21,8 +21,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import { ccclass, serializable } from 'cc.decorator';
import { cclegacy, Vec3 } from '../../core';
import { patch_cc_Mesh } from '../../native-binding/decorators';
declare const jsb: any;
@@ -163,8 +163,4 @@ meshAssetProto.onLoaded = function () {
cclegacy.Mesh = jsb.Mesh;
// handle meta data, it is generated automatically
const MeshProto = Mesh.prototype;
serializable(MeshProto, '_struct', () => { return { vertexBundles: [], primitives: [] } });
serializable(MeshProto, '_hash', () => 0);
serializable(MeshProto, '_allowDataAccess', () => true);
ccclass('cc.Mesh')(Mesh);
patch_cc_Mesh({Mesh});
+2 -6
View File
@@ -22,10 +22,10 @@
THE SOFTWARE.
*/
import { ccclass, type, serializable } from 'cc.decorator';
import { CCString, cclegacy, Mat4 } from '../../core';
import { DataPoolManager } from '../skeletal-animation/data-pool-manager';
import { Asset } from '../../asset/assets/asset';
import { patch_cc_Skeleton } from '../../native-binding/decorators';
export const Skeleton = jsb.Skeleton;
export type Skeleton = jsb.Skeleton;
@@ -62,8 +62,4 @@ skeletonProto.onLoaded = function () {
};
// handle meta data, it is generated automatically
const SkeletonProto = Skeleton.prototype;
type([CCString])(SkeletonProto, '_joints', () => []);
type([Mat4])(SkeletonProto, '_bindposes', () => []);
serializable(SkeletonProto, '_hash', () => 0);
ccclass('cc.Skeleton')(Skeleton);
patch_cc_Skeleton({Skeleton, CCString, Mat4});
+1 -1
View File
@@ -25,7 +25,7 @@
import { EDITOR } from 'internal:constants';
import { ImageAsset } from '../assets/image-asset';
import JsonAsset from '../assets/json-asset';
import TextAsset from '../assets/text-asset';
import { TextAsset } from '../assets/text-asset';
import { Asset } from '../assets/asset';
import { BufferAsset } from '../assets/buffer-asset';
import Bundle, { resources } from './bundle';
+2 -6
View File
@@ -21,10 +21,10 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import { ccclass, serializable } from 'cc.decorator';
import { cclegacy, js, _decorator, path, jsbUtils, CallbacksInvoker, applyMixins } from '../../core';
import { getUrlWithUuid } from '../asset-manager/helper';
import { patch_cc_Asset } from '../../native-binding/decorators';
declare const jsb: any;
@@ -121,8 +121,4 @@ export const Asset = jsb.Asset;
cclegacy.Asset = jsb.Asset;
// handle meta data, it is generated automatically
const AssetProto = Asset.prototype;
serializable(AssetProto, '_native', () => '');
const _nativeAssetDescriptor = Object.getOwnPropertyDescriptor(AssetProto, '_nativeAsset');
_decorator.property(AssetProto, '_nativeAsset', _nativeAssetDescriptor);
ccclass('cc.Asset')(Asset);
patch_cc_Asset({Asset});
+2 -5
View File
@@ -21,9 +21,9 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import { ccclass, override } from 'cc.decorator';
import { cclegacy } from '../../core';
import './asset';
import { patch_cc_BufferAsset } from '../../native-binding/decorators';
export type BufferAsset = jsb.BufferAsset;
export const BufferAsset = jsb.BufferAsset;
@@ -31,7 +31,4 @@ export const BufferAsset = jsb.BufferAsset;
cclegacy.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);
patch_cc_BufferAsset({BufferAsset});
+2 -11
View File
@@ -22,9 +22,9 @@
THE SOFTWARE.
*/
import { ccclass, editable, editorOnly, serializable } from 'cc.decorator';
import{ cclegacy } from '../../core';
import './asset';
import { patch_cc_EffectAsset } from '../../native-binding/decorators';
export type EffectAsset = jsb.EffectAsset;
export const EffectAsset = jsb.EffectAsset;
@@ -39,13 +39,4 @@ effectAssetProto._ctor = function () {
};
// 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', () => false);
serializable(EffectAssetProto, 'hideInEditor', () => false);
ccclass('cc.EffectAsset')(EffectAsset);
patch_cc_EffectAsset({EffectAsset})
+3 -5
View File
@@ -21,11 +21,11 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import { ccclass, override } from 'cc.decorator';
import { ALIPAY, XIAOMI, JSB, TEST, BAIDU } from 'internal:constants';
import { Format, FormatFeatureBit, deviceManager } from '../../gfx';
import { PixelFormat } from './asset-enum';
import { sys, macro, warnID, cclegacy } from '../../core';
import { patch_cc_ImageAsset } from '../../native-binding/decorators';
import './asset';
export type ImageAsset = jsb.ImageAsset;
@@ -273,7 +273,5 @@ imageAssetProto._deserialize = function (data: any) {
cclegacy.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);
patch_cc_ImageAsset({ImageAsset});
+1 -1
View File
@@ -30,7 +30,7 @@ export { BufferAsset } from './buffer-asset';
export * from './scripts';
export { RenderingSubMesh } from './rendering-sub-mesh';
export { SceneAsset } from './scene-asset';
export { default as TextAsset } from './text-asset';
export { TextAsset } from './text-asset';
export { default as JsonAsset } from './json-asset';
export { ImageAsset } from './image-asset';
export { Texture2D } from './texture-2d';
+1 -1
View File
@@ -30,7 +30,7 @@ export { BufferAsset } from './buffer-asset';
export * from './scripts';
export { RenderingSubMesh } from './rendering-sub-mesh';
export { SceneAsset } from './scene-asset';
export { default as TextAsset } from './text-asset';
export { TextAsset } from './text-asset';
export { default as JsonAsset } from './json-asset';
export { ImageAsset } from './image-asset';
export { Texture2D } from './texture-2d';
+5 -12
View File
@@ -27,8 +27,8 @@ import { Texture } from '../../gfx';
import { TextureBase } from './texture-base';
import { PassOverrides, MacroRecord, MaterialProperty } from '../../render-scene';
import { Color, Mat3, Mat4, Quat, Vec2, Vec3, Vec4, cclegacy } from '../../core';
import { type, serializable, ccclass } from '../../core/data/decorators';
import './asset';
import { patch_cc_Material } from '../../native-binding/decorators';
/**
* @en The basic infos for material initialization.
@@ -78,7 +78,7 @@ declare const jsb: any;
const matProto: any = jsb.Material.prototype;
type setProperyCB = (name: string, val: MaterialPropertyFull | MaterialPropertyFull[], passIdx?: number) => void;
function wrapSetProperty (cb: setProperyCB, target: Material, name: string, val: MaterialPropertyFull | MaterialPropertyFull[], passIdx?: number) {
function wrapSetProperty(cb: setProperyCB, target: Material, name: string, val: MaterialPropertyFull | MaterialPropertyFull[], passIdx?: number) {
if (passIdx != undefined) {
cb.call(target, name, val, passIdx);
} else {
@@ -158,7 +158,7 @@ matProto.setProperty = function (name: string, val: MaterialPropertyFull | Mater
this.setPropertyNull(name);
}
}
else {
else {
cclegacy.error(`Material.setProperty Unknown type: ${val}`);
}
};
@@ -283,7 +283,7 @@ materialProto._onPassesUpdated = function () {
Object.defineProperty(materialProto, 'passes', {
enumerable: true,
configurable: true,
get () {
get() {
if (!this._isCtorCalled) {
// Builtin materials are created in cpp, the _passes property is not updated when access it in JS.
// So we need to invoke getPasses() to sync _passes property.
@@ -296,11 +296,4 @@ Object.defineProperty(materialProto, 'passes', {
});
// handle meta data, it is generated automatically
const MaterialProto = Material.prototype;
// @ts-expect-error
type(EffectAsset)(MaterialProto, '_effectAsset', () => null);
serializable(MaterialProto, '_techIdx', () => 0);
serializable(MaterialProto, '_defines', () => []);
serializable(MaterialProto, '_states', () => []);
serializable(MaterialProto, '_props', () => []);
ccclass('cc.Material')(Material);
patch_cc_Material({ Material, EffectAsset});
+2 -2
View File
@@ -21,11 +21,11 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import { ccclass } from 'cc.decorator';
import { EDITOR, TEST } from 'internal:constants';
import { cclegacy } from '../../core';
import { Filter, PixelFormat, WrapMode } from './asset-enum';
import './asset';
import { patch_cc_RenderTexture } from '../../native-binding/decorators';
declare const jsb: any;
const renderTextureProto: any = jsb.RenderTexture.prototype;
@@ -76,4 +76,4 @@ renderTextureProto.readPixels = function readPixels (x: number, y: number, width
cclegacy.RenderTexture = jsb.RenderTexture;
// handle meta data, it is generated automatically
ccclass('cc.RenderTexture')(RenderTexture);
patch_cc_RenderTexture({RenderTexture});
+2 -5
View File
@@ -21,8 +21,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 { cclegacy } from '../../core';
import { patch_cc_SceneAsset } from '../../native-binding/decorators';
import './asset';
export const SceneAsset = jsb.SceneAsset;
@@ -53,7 +53,4 @@ sceneAssetProto._ctor = function () {
};
// handle meta data, it is generated automatically
const SceneAssetProto = SceneAsset.prototype;
serializable(SceneAssetProto, 'scene', () => null);
editable(SceneAssetProto, 'scene', () => null);
ccclass('cc.SceneAsset')(SceneAsset);
patch_cc_SceneAsset({SceneAsset});
+3 -4
View File
@@ -21,11 +21,11 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import { ccclass } from 'cc.decorator';
import { Filter, PixelFormat, WrapMode } from './asset-enum';
import dependUtil from '../asset-manager/depend-util';
import { js, macro, cclegacy } from '../../core';
import './texture-base';
import { patch_cc_SimpleTexture } from '../../native-binding/decorators';
declare const jsb: any;
@@ -55,8 +55,6 @@ simpleTextureProto.uploadData = function (source, level = 0, arrayIndex = 0) {
oldUpdateDataFunc.call(this, data, level, arrayIndex);
};
const clsDecorator = ccclass('cc.SimpleTexture');
simpleTextureProto._ctor = function () {
jsb.TextureBase.prototype._ctor.apply(this, arguments);
this._gfxTexture = null;
@@ -86,6 +84,7 @@ simpleTextureProto._onAfterAssignImage = function (image) {
}
};
clsDecorator(SimpleTexture);
patch_cc_SimpleTexture({SimpleTexture});
cclegacy.SimpleTexture = jsb.SimpleTexture;
+2 -5
View File
@@ -21,8 +21,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 { cclegacy } from '../../core';
import { patch_cc_TextAsset } from '../../native-binding/decorators';
import './asset';
const textAssetProto: any = jsb.TextAsset.prototype;
@@ -39,7 +39,4 @@ textAssetProto._ctor = function () {
cclegacy.TextAsset = jsb.TextAsset;
// handle meta data, it is generated automatically
const TextAssetProto = TextAsset.prototype;
editable(TextAssetProto, 'text', () => '');
serializable(TextAssetProto, 'text', () => '');
ccclass('cc.TextAsset')(TextAsset);
patch_cc_TextAsset({TextAsset});
+1 -1
View File
@@ -32,7 +32,7 @@ import { cclegacy } from '../../core';
* @zh 文本资源。
*/
@ccclass('cc.TextAsset')
export default class TextAsset extends Asset {
export class TextAsset extends Asset {
/**
* @en The text content.
* @zh 此资源包含的文本。
+2 -4
View File
@@ -21,13 +21,13 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import { ccclass, type } from 'cc.decorator';
import { ImageAsset } from './image-asset';
import { SimpleTexture } from './simple-texture';
import { TextureBase } from './texture-base.jsb';
import { js, cclegacy } from '../../core';
import { Filter, PixelFormat, WrapMode } from './asset-enum';
import './simple-texture';
import { patch_cc_Texture2D } from '../../native-binding/decorators';
const texture2DProto: any = jsb.Texture2D.prototype;
@@ -121,6 +121,4 @@ Object.defineProperty(texture2DProto, 'mipmaps', {
cclegacy.Texture2D = jsb.Texture2D;
// handle meta data, it is generated automatically
const Texture2DProto = Texture2D.prototype;
type([ImageAsset])(Texture2DProto, '_mipmaps');
ccclass('cc.Texture2D')(Texture2D);
patch_cc_Texture2D({Texture2D, ImageAsset});
+2 -11
View File
@@ -21,12 +21,12 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import { ccclass, serializable } from 'cc.decorator';
import { TEST, EDITOR } from 'internal:constants';
import { deviceManager } from '../../gfx';
import { cclegacy } from '../../core';
import { Filter, PixelFormat, WrapMode } from './asset-enum';
import './asset';
import { patch_cc_TextureBase } from '../../native-binding/decorators';
const textureBaseProto: any = jsb.TextureBase.prototype;
@@ -136,13 +136,4 @@ textureBaseProto._onGFXSamplerUpdated = function (gfxSampler, samplerInfo) {
cclegacy.TextureBase = jsb.TextureBase;
// handle meta data, it is generated automatically
const TextureBaseProto = TextureBase.prototype;
serializable(TextureBaseProto, '_format', () => PixelFormat.RGBA8888);
serializable(TextureBaseProto, '_minFilter', () => Filter.LINEAR);
serializable(TextureBaseProto, '_magFilter', () => Filter.LINEAR);
serializable(TextureBaseProto, '_mipFilter', () => Filter.NONE);
serializable(TextureBaseProto, '_wrapS', () => WrapMode.REPEAT);
serializable(TextureBaseProto, '_wrapT', () => WrapMode.REPEAT);
serializable(TextureBaseProto, '_wrapR', () => WrapMode.REPEAT);
serializable(TextureBaseProto, '_anisotropy', () => 0);
ccclass('cc.TextureBase')(TextureBase);
patch_cc_TextureBase({TextureBase, Filter, WrapMode, PixelFormat});
+2 -7
View File
@@ -21,11 +21,11 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import { ccclass, serializable } from 'cc.decorator';
import { Filter, PixelFormat, WrapMode } from './asset-enum';
import { js, cclegacy } from '../../core';
import './simple-texture';
import { EDITOR, TEST } from 'internal:constants';
import { patch_cc_TextureCube } from '../../native-binding/decorators';
const textureCubeProto: any = jsb.TextureCube.prototype;
interface ITextureCubeSerializeData {
@@ -226,9 +226,4 @@ textureCubeProto._deserialize = function (serializedData: ITextureCubeSerializeD
cclegacy.TextureCube = jsb.TextureCube;
// handle meta data, it is generated automatically
const TextureCubeProto = TextureCube.prototype;
serializable(TextureCubeProto, 'isRGBE', () => false);
serializable(TextureCubeProto, '_mipmaps', () => []);
serializable(TextureCubeProto, '_mipmapMode', () => MipmapMode.NONE);
serializable(TextureCubeProto, '_mipmapAtlas', () => null);
ccclass('cc.TextureCube')(TextureCube);
patch_cc_TextureCube({TextureCube, MipmapMode});
+4 -21
View File
@@ -22,31 +22,14 @@
THE SOFTWARE.
*/
import { Mat3, Vec3, _decorator } from "../../core";
import { patch_cc_CircumSphere, patch_cc_Tetrahedron, patch_cc_Vertex } from "../../native-binding/decorators";
const { ccclass, serializable } = _decorator;
export const Vertex = jsb.Vertex;
const VertexProto = Vertex.prototype;
serializable(VertexProto, 'position', () => new Vec3(0, 0, 0));
serializable(VertexProto, 'normal', () => new Vec3(0, 0, 0));
serializable(VertexProto, 'coefficients', () => []);
ccclass('cc.Vertex')(Vertex);
patch_cc_Vertex({Vertex, Vec3});
export const CircumSphere = jsb.CircumSphere;
const CircumSphereProto = CircumSphere.prototype;
serializable(CircumSphereProto, 'center', () => new Vec3(0, 0, 0));
serializable(CircumSphereProto, 'radiusSquared', () => 0.0);
ccclass('cc.CircumSphere')(CircumSphere);
patch_cc_CircumSphere({CircumSphere, Vec3});
export const Tetrahedron = jsb.Tetrahedron;
const TetrahedronProto = Tetrahedron.prototype;
serializable(TetrahedronProto, 'invalid', () => false);
serializable(TetrahedronProto, 'vertex0', () => -1);
serializable(TetrahedronProto, 'vertex1', () => -1);
serializable(TetrahedronProto, 'vertex2', () => -1);
serializable(TetrahedronProto, 'vertex3', () => -1);
serializable(TetrahedronProto, 'neighbours', () => [-1, -1, -1, -1]);
serializable(TetrahedronProto, 'matrix', () => new Mat3());
serializable(TetrahedronProto, 'offset', () => new Vec3(0.0, 0.0, 0.0));
serializable(TetrahedronProto, 'sphere', () => new CircumSphere());
ccclass('cc.Tetrahedron')(Tetrahedron);
patch_cc_Tetrahedron({Tetrahedron, Mat3, Vec3, CircumSphere});
+4 -10
View File
@@ -22,21 +22,15 @@
THE SOFTWARE.
*/
import { _decorator } from '../../core';
import { patch_cc_LightProbesData } from '../../native-binding/decorators';
import { Tetrahedron, Vertex } from './delaunay';
const { ccclass, serializable, type } = _decorator;
export const LightProbes = jsb.LightProbes;
ccclass('cc.LightProbes')(LightProbes);
_decorator.ccclass('cc.LightProbes')(LightProbes);
// patch_cc_LightProbes({LightProbes}); // not exists
export const LightProbesData = jsb.LightProbesData;
const LightProbesDataProto = LightProbesData.prototype;
// @ts-expect-error
type([Vertex])(LightProbesDataProto, '_probes', () => []);
serializable(LightProbesDataProto, '_probes', () => []);
patch_cc_LightProbesData({LightProbesData, Vertex, Tetrahedron});
// @ts-expect-error
type([Tetrahedron])(LightProbesDataProto, '_tetrahedrons', () => []);
serializable(LightProbesDataProto, '_tetrahedrons', () => []);
ccclass('cc.LightProbesData')(LightProbesData);
File diff suppressed because it is too large Load Diff
+11 -11
View File
@@ -81,17 +81,17 @@ export declare namespace native {
}
export namespace EventAssetsManager {
export const ERROR_NO_LOCAL_MANIFEST:number;
export const ERROR_DOWNLOAD_MANIFEST:number;
export const ERROR_PARSE_MANIFEST :number;
export const NEW_VERSION_FOUND :number;
export const ALREADY_UP_TO_DATE :number;
export const UPDATE_PROGRESSION :number;
export const ASSET_UPDATED :number;
export const ERROR_UPDATING :number;
export const UPDATE_FINISHED :number;
export const UPDATE_FAILED :number;
export const ERROR_DECOMPRESS :number;
export const ERROR_NO_LOCAL_MANIFEST: number;
export const ERROR_DOWNLOAD_MANIFEST: number;
export const ERROR_PARSE_MANIFEST: number;
export const NEW_VERSION_FOUND: number;
export const ALREADY_UP_TO_DATE: number;
export const UPDATE_PROGRESSION: number;
export const ASSET_UPDATED: number;
export const ERROR_UPDATING: number;
export const UPDATE_FINISHED: number;
export const UPDATE_FAILED: number;
export const ERROR_DECOMPRESS: number;
}
export interface ManifestAsset {
-1
View File
@@ -272,4 +272,3 @@ cameraProto.worldMatrixToScreen = function worldMatrixToScreen (out: Mat4, world
return out;
};
+25 -86
View File
@@ -28,8 +28,9 @@ declare const jsb: any;
import { getPhaseID } from './pass-phase';
import { ccenum, CCString, js } from '../core';
import * as pipeline from './define';
import { ccclass, serializable, editable, type, visible } from '../core/data/class-decorator';
import { ccclass, serializable, editable, type } from '../core/data/class-decorator';
import { legacyCC } from '../core/global-exports';
import * as decors from '../native-binding/decorators';
export { pipeline };
nr.getPhaseID = getPhaseID;
@@ -389,98 +390,36 @@ function proxyArrayAttributeImpl(proto: any, attr: string) {
});
}
function declType(proto: any, attrType: any, attr: string, dft: () => any) {
(type(attrType) as any)(proto, attr, dft);
}
let proxyArrayAttribute = proxyArrayAttributeImpl;
editable(RenderStage.prototype, '_name', () => '');
editable(RenderStage.prototype, '_tag', () => 0);
editable(RenderStage.prototype, '_priority', () => 0);
serializable(RenderStage.prototype, '_tag', () => 0);
serializable(RenderStage.prototype, '_priority', () => 0);
editable(RenderFlow.prototype, '_name', () => '');
editable(RenderFlow.prototype, '_priority', () => 0);
editable(RenderFlow.prototype, '_tag', () => 0);
editable(RenderFlow.prototype, '_stages', () => []);
declType(RenderFlow.prototype, [RenderStage], '_stages', () => []);
proxyArrayAttribute(RenderFlow.prototype, '_stages');
serializable(RenderFlow.prototype, '_name', () => '');
serializable(RenderFlow.prototype, '_priority', () => 0);
serializable(RenderFlow.prototype, '_tag', () => 0);
serializable(RenderFlow.prototype, '_stages', () => []);
editable(RenderPipeline.prototype, '_tag', () => 0);
editable(RenderPipeline.prototype, '_name', () => []);
serializable(RenderPipeline.prototype, '_tag', () => 0);
serializable(RenderPipeline.prototype, '_name', () => '');
editable(RenderPipeline.prototype, '_flows', () => []);
declType(RenderPipeline.prototype, [RenderFlow], '_flows', () => []);
proxyArrayAttribute(RenderPipeline.prototype, '_flows');
serializable(RenderPipeline.prototype, '_flows', () => []);
editable(DeferredPipeline.prototype, 'renderTextures', () => []);
declType(DeferredPipeline.prototype, [RenderTextureConfig], "renderTextures", () => []);
serializable(DeferredPipeline.prototype, 'renderTextures', () => []);
editable(DeferredPipeline.prototype, 'renderTextures', () => []);
editable(ForwardPipeline.prototype, 'renderTextures', () => []);
declType(ForwardPipeline.prototype, [RenderTextureConfig], "renderTextures", () => []);
serializable(ForwardPipeline.prototype, 'renderTextures', () => []);
declType(GbufferStage.prototype, [RenderQueueDesc], 'renderQueues', () => []);
serializable(GbufferStage.prototype, 'renderQueues', () => []);
editable(GbufferStage.prototype, 'renderQueues', () => []);
editable(LightingStage.prototype, '_deferredMaterial', () => null);
declType(LightingStage.prototype, jsb.Material, '_deferredMaterial', () => null);
declType(LightingStage.prototype, [RenderQueueDesc], 'renderQueues', () => []);
serializable(LightingStage.prototype, '_deferredMaterial', () => null);
serializable(LightingStage.prototype, 'renderQueue', () => []);
editable(LightingStage.prototype, 'renderQueue', () => []);
editable(BloomStage.prototype, '_bloomMaterial', () => null);
declType(BloomStage.prototype, jsb.Material, '_bloomMaterial', () => []);
serializable(BloomStage.prototype, '_bloomMaterial', () => null);
declType(PostProcessStage.prototype, [RenderQueueDesc], 'renderQueues', () => []);
editable(PostProcessStage.prototype, '_postProcessMaterial', () => null);
declType(PostProcessStage.prototype, jsb.Material, '_postProcessMaterial', () => null);
serializable(PostProcessStage.prototype, 'renderQueues', () => []);
editable(PostProcessStage.prototype, 'renderQueues', () => []);
serializable(PostProcessStage.prototype, '_postProcessMaterial', () => null);
declType(ForwardStage.prototype, [RenderQueueDesc], 'renderQueues', () => []);
serializable(ForwardStage.prototype, 'renderQueues', () => []);
editable(ForwardStage.prototype, 'renderQueues', () => []);
//-------------------- register types --------------------
ccclass('RenderQueueDesc')(RenderQueueDesc);
ccclass('RenderStage')(RenderStage)
ccclass('ReflectionProbeStage')(ReflectionProbeStage);
ccclass('GbufferStage')(GbufferStage);
ccclass('LightingStage')(LightingStage);
ccclass('BloomStage')(BloomStage);
ccclass('PostProcessStage')(PostProcessStage);
ccclass('ForwardStage')(ForwardStage);
ccclass('ShadowStage')(ShadowStage);
ccclass('RenderFlow')(RenderFlow)
ccclass('MainFlow')(MainFlow);
ccclass('ForwardFlow')(ForwardFlow);
ccclass('ShadowFlow')(ShadowFlow);
ccclass('ReflectionProbeFlow')(ReflectionProbeFlow);
const Material = jsb.Material;
decors.patch_RenderQueueDesc({RenderQueueDesc, RenderQueueSortMode, CCString});
decors.patch_RenderStage({RenderStage});
decors.patch_ReflectionProbeStage({ReflectionProbeStage});
decors.patch_GbufferStage({GbufferStage, RenderQueueDesc});
decors.patch_LightingStage({LightingStage, RenderQueueDesc, Material});
decors.patch_BloomStage({BloomStage, Material});
decors.patch_PostProcessStage({PostProcessStage, Material, RenderQueueDesc});
decors.patch_ForwardStage({ForwardStage, RenderQueueDesc});
decors.patch_ShadowStage({ShadowStage});
decors.patch_RenderFlow({RenderFlow, RenderStage});
decors.patch_MainFlow({MainFlow});
decors.patch_ForwardFlow({ForwardFlow});
decors.patch_ShadowFlow({ShadowFlow});
decors.patch_ReflectionProbeFlow({ReflectionProbeFlow});
decors.patch_cc_RenderPipeline({RenderPipeline, RenderFlow});
decors.patch_ForwardPipeline({ForwardPipeline, RenderTextureConfig});
decors.patch_DeferredPipeline({DeferredPipeline, RenderTextureConfig});
ccclass('cc.RenderPipeline')(RenderPipeline);
ccclass('ForwardPipeline')(ForwardPipeline);
ccclass('DeferredPipeline')(DeferredPipeline);
+113 -139
View File
@@ -21,7 +21,6 @@
*/
import { EDITOR } from 'internal:constants';
import { ccclass, editable, serializable, type } from 'cc.decorator'
import { legacyCC } from '../core/global-exports';
import { errorID, getError } from '../core/platform/debug';
import { Component } from './component';
@@ -38,6 +37,7 @@ import { syncNodeValues } from "../core/utils/jsb-utils";
import { property } from '../core/data/class-decorator';
import { nodePolyfill } from './node-dev';
import * as js from '../core/utils/js';
import { patch_cc_Node } from '../native-binding/decorators';
const reserveContentsForAllSyncablePrefabTag = Symbol('ReserveContentsForAllSyncablePrefab');
@@ -86,7 +86,7 @@ const Destroying = CCObject.Flags.Destroying;
Node._setTempFloatArray(_tempFloatArray.buffer);
function getConstructor<T> (typeOrClassName) {
function getConstructor<T>(typeOrClassName) {
if (!typeOrClassName) {
return null;
}
@@ -111,7 +111,7 @@ function getConstructor<T> (typeOrClassName) {
* node.attr(attrs);
* ```
*/
nodeProto.attr = function(attrs: unknown) {
nodeProto.attr = function (attrs: unknown) {
js.mixin(this, attrs);
}
@@ -329,11 +329,11 @@ nodeProto.targetOff = function (target: string | unknown) {
}
};
nodeProto.pauseSystemEvents = function pauseSystemEvents (recursive: boolean): void {
nodeProto.pauseSystemEvents = function pauseSystemEvents(recursive: boolean): void {
this._eventProcessor.setEnabled(false, recursive);
};
nodeProto.resumeSystemEvents = function resumeSystemEvents (recursive: boolean): void {
nodeProto.resumeSystemEvents = function resumeSystemEvents(recursive: boolean): void {
this._eventProcessor.setEnabled(true, recursive);
};
@@ -442,7 +442,7 @@ nodeProto._onChildAdded = function (child) {
};
const oldPreDestroy = nodeProto._onPreDestroy;
nodeProto._onPreDestroy = function _onPreDestroy () {
nodeProto._onPreDestroy = function _onPreDestroy() {
const ret = oldPreDestroy.call(this);
// emit node destroy event (this should before event processor destroy)
@@ -469,7 +469,7 @@ nodeProto._onPreDestroy = function _onPreDestroy () {
return ret;
};
nodeProto.destroyAllChildren = function destroyAllChildren () {
nodeProto.destroyAllChildren = function destroyAllChildren() {
const children = this._children;
for (let i = 0, len = children.length; i < len; ++i) {
children[i].destroy();
@@ -589,7 +589,7 @@ NodeCls.isNode = function (obj: unknown): obj is jsb.Node {
};
let _tempQuat = new Quat();
nodeProto.setRTS = function setRTS (rot?: Quat | Vec3, pos?: Vec3, scale?: Vec3) {
nodeProto.setRTS = function setRTS(rot?: Quat | Vec3, pos?: Vec3, scale?: Vec3) {
if (rot) {
let val = _tempQuat;
if (rot instanceof Quat) {
@@ -628,14 +628,14 @@ nodeProto.setRTS = function setRTS (rot?: Quat | Vec3, pos?: Vec3, scale?: Vec3)
this._setRTS();
};
nodeProto.getPosition = function getPosition (out?: Vec3): Vec3 {
nodeProto.getPosition = function getPosition(out?: Vec3): Vec3 {
if (out) {
return Vec3.set(out, this._lpos.x, this._lpos.y, this._lpos.z);
}
return Vec3.copy(new Vec3(), this._lpos);
};
nodeProto.setPosition = function setPosition (val: Readonly<Vec3> | number, y?: number, z?: number) {
nodeProto.setPosition = function setPosition(val: Readonly<Vec3> | number, y?: number, z?: number) {
if (y === undefined && z === undefined) {
_tempFloatArray[0] = 3;
const pos = val as Vec3;
@@ -655,7 +655,7 @@ nodeProto.setPosition = function setPosition (val: Readonly<Vec3> | number, y?:
this._setPosition();
};
nodeProto.getRotation = function getRotation (out?: Quat): Quat {
nodeProto.getRotation = function getRotation(out?: Quat): Quat {
const lrot = this._lrot;
if (out) {
return Quat.set(out, lrot.x, lrot.y, lrot.z, lrot.w);
@@ -663,7 +663,7 @@ nodeProto.getRotation = function getRotation (out?: Quat): Quat {
return Quat.copy(new Quat(), lrot);
};
nodeProto.setRotation = function setRotation (val: Readonly<Quat> | number, y?: number, z?: number, w?: number): void {
nodeProto.setRotation = function setRotation(val: Readonly<Quat> | number, y?: number, z?: number, w?: number): void {
if (y === undefined || z === undefined || w === undefined) {
const rot = val as Readonly<Quat>;
this._lrot.x = _tempFloatArray[0] = rot.x;
@@ -680,7 +680,7 @@ nodeProto.setRotation = function setRotation (val: Readonly<Quat> | number, y?:
this._setRotation();
};
nodeProto.setRotationFromEuler = function setRotationFromEuler (val: Vec3 | number, y?: number, zOpt?: number): void {
nodeProto.setRotationFromEuler = function setRotationFromEuler(val: Vec3 | number, y?: number, zOpt?: number): void {
const z = zOpt === undefined ? this._euler.z : zOpt;
if (y === undefined) {
@@ -697,14 +697,14 @@ nodeProto.setRotationFromEuler = function setRotationFromEuler (val: Vec3 | numb
this._setRotationFromEuler();
};
nodeProto.getScale = function getScale (out?: Vec3): Vec3 {
nodeProto.getScale = function getScale(out?: Vec3): Vec3 {
if (out) {
return Vec3.set(out, this._lscale.x, this._lscale.y, this._lscale.z);
}
return Vec3.copy(new Vec3(), this._lscale);
};
nodeProto.setScale = function setScale (val: Readonly<Vec3> | number, y?: number, z?: number) {
nodeProto.setScale = function setScale(val: Readonly<Vec3> | number, y?: number, z?: number) {
if (y === undefined && z === undefined) {
_tempFloatArray[0] = 3;
const scale = val as Vec3;
@@ -724,56 +724,56 @@ nodeProto.setScale = function setScale (val: Readonly<Vec3> | number, y?: number
this._setScale();
};
nodeProto.getWorldPosition = function getWorldPosition (out?: Vec3): Vec3 {
nodeProto.getWorldPosition = function getWorldPosition(out?: Vec3): Vec3 {
this._getWorldPosition();
out = out || new Vec3();
return out.set(_tempFloatArray[0], _tempFloatArray[1], _tempFloatArray[2]);
};
nodeProto.getWorldRotation = function getWorldRotation (out?: Quat): Quat {
nodeProto.getWorldRotation = function getWorldRotation(out?: Quat): Quat {
this._getWorldRotation();
out = out || new Quat();
return out.set(_tempFloatArray[0], _tempFloatArray[1], _tempFloatArray[2], _tempFloatArray[3]);
};
nodeProto.getWorldScale = function getWorldScale (out?: Vec3): Vec3 {
nodeProto.getWorldScale = function getWorldScale(out?: Vec3): Vec3 {
this._getWorldScale();
out = out || new Vec3();
return out.set(_tempFloatArray[0], _tempFloatArray[1], _tempFloatArray[2]);
};
nodeProto.getWorldMatrix = function getWorldMatrix (out?: Mat4): Mat4 {
nodeProto.getWorldMatrix = function getWorldMatrix(out?: Mat4): Mat4 {
this._getWorldMatrix();
out = out || new Mat4();
fillMat4WithTempFloatArray(out);
return out;
};
nodeProto.getEulerAngles = function getEulerAngles (out?: Vec3): Vec3 {
nodeProto.getEulerAngles = function getEulerAngles(out?: Vec3): Vec3 {
this._getEulerAngles();
out = out || new Vec3();
return out.set(_tempFloatArray[0], _tempFloatArray[1], _tempFloatArray[2]);
};
nodeProto.getForward = function getForward (out?: Vec3): Vec3 {
nodeProto.getForward = function getForward(out?: Vec3): Vec3 {
this._getForward();
out = out || new Vec3();
return out.set(_tempFloatArray[0], _tempFloatArray[1], _tempFloatArray[2]);
};
nodeProto.getUp = function getUp (out?: Vec3): Vec3 {
nodeProto.getUp = function getUp(out?: Vec3): Vec3 {
this._getUp();
out = out || new Vec3();
return out.set(_tempFloatArray[0], _tempFloatArray[1], _tempFloatArray[2]);
};
nodeProto.getRight = function getRight (out?: Vec3): Vec3 {
nodeProto.getRight = function getRight(out?: Vec3): Vec3 {
this._getRight();
out = out || new Vec3();
return out.set(_tempFloatArray[0], _tempFloatArray[1], _tempFloatArray[2]);
};
nodeProto.inverseTransformPoint = function inverseTransformPoint (out: Vec3, p: Vec3) : Vec3 {
nodeProto.inverseTransformPoint = function inverseTransformPoint(out: Vec3, p: Vec3): Vec3 {
_tempFloatArray[0] = p.x;
_tempFloatArray[1] = p.y;
_tempFloatArray[2] = p.z;
@@ -784,14 +784,14 @@ nodeProto.inverseTransformPoint = function inverseTransformPoint (out: Vec3, p:
return out;
};
nodeProto.getWorldRT = function getWorldRT (out?: Mat4): Mat4 {
nodeProto.getWorldRT = function getWorldRT(out?: Mat4): Mat4 {
out = out || new Mat4();
this._getWorldRT();
fillMat4WithTempFloatArray(out);
return out;
};
nodeProto.getWorldRS = function getWorldRS (out?: Mat4): Mat4 {
nodeProto.getWorldRS = function getWorldRS(out?: Mat4): Mat4 {
out = out || new Mat4();
this._getWorldRS();
fillMat4WithTempFloatArray(out);
@@ -812,10 +812,10 @@ Object.defineProperty(nodeProto, 'name', {
Object.defineProperty(nodeProto, 'position', {
configurable: true,
enumerable: true,
get (): Readonly<Vec3> {
get(): Readonly<Vec3> {
return this._lpos;
},
set (v: Readonly<Vec3>) {
set(v: Readonly<Vec3>) {
this.setPosition(v as Vec3);
},
});
@@ -823,10 +823,10 @@ Object.defineProperty(nodeProto, 'position', {
Object.defineProperty(nodeProto, 'rotation', {
configurable: true,
enumerable: true,
get (): Readonly<Quat> {
get(): Readonly<Quat> {
return this._lrot;
},
set (v: Readonly<Quat>) {
set(v: Readonly<Quat>) {
this.setRotation(v as Quat);
},
});
@@ -834,10 +834,10 @@ Object.defineProperty(nodeProto, 'rotation', {
Object.defineProperty(nodeProto, 'scale', {
configurable: true,
enumerable: true,
get (): Readonly<Vec3> {
get(): Readonly<Vec3> {
return this._lscale;
},
set (v: Readonly<Vec3>) {
set(v: Readonly<Vec3>) {
this.setScale(v as Vec3);
},
});
@@ -845,10 +845,10 @@ Object.defineProperty(nodeProto, 'scale', {
Object.defineProperty(nodeProto, 'worldPosition', {
configurable: true,
enumerable: true,
get (): Readonly<Vec3> {
get(): Readonly<Vec3> {
return this.getWorldPosition();
},
set (v: Readonly<Vec3>) {
set(v: Readonly<Vec3>) {
this.setWorldPosition(v as Vec3);
},
});
@@ -856,10 +856,10 @@ Object.defineProperty(nodeProto, 'worldPosition', {
Object.defineProperty(nodeProto, 'worldRotation', {
configurable: true,
enumerable: true,
get (): Readonly<Quat> {
get(): Readonly<Quat> {
return this.getWorldRotation();
},
set (v: Readonly<Quat>) {
set(v: Readonly<Quat>) {
this.setWorldRotation(v as Quat);
},
});
@@ -867,10 +867,10 @@ Object.defineProperty(nodeProto, 'worldRotation', {
Object.defineProperty(nodeProto, 'worldScale', {
configurable: true,
enumerable: true,
get (): Readonly<Vec3> {
get(): Readonly<Vec3> {
return this.getWorldScale();
},
set (v: Readonly<Vec3>) {
set(v: Readonly<Vec3>) {
this.setWorldScale(v as Vec3);
},
});
@@ -878,7 +878,7 @@ Object.defineProperty(nodeProto, 'worldScale', {
Object.defineProperty(nodeProto, '_pos', {
configurable: true,
enumerable: true,
get (): Readonly<Vec3> {
get(): Readonly<Vec3> {
return this.getWorldPosition();
}
});
@@ -886,7 +886,7 @@ Object.defineProperty(nodeProto, '_pos', {
Object.defineProperty(nodeProto, '_rot', {
configurable: true,
enumerable: true,
get (): Readonly<Quat> {
get(): Readonly<Quat> {
return this.getWorldRotation();
}
});
@@ -894,7 +894,7 @@ Object.defineProperty(nodeProto, '_rot', {
Object.defineProperty(nodeProto, '_scale', {
configurable: true,
enumerable: true,
get (): Readonly<Vec3> {
get(): Readonly<Vec3> {
return this.getWorldScale();
}
});
@@ -902,10 +902,10 @@ Object.defineProperty(nodeProto, '_scale', {
Object.defineProperty(nodeProto, 'eulerAngles', {
configurable: true,
enumerable: true,
get (): Readonly<Vec3> {
get(): Readonly<Vec3> {
return this.getEulerAngles();
},
set (v: Readonly<Vec3>) {
set(v: Readonly<Vec3>) {
this.setRotationFromEuler(v.x, v.y, v.z);
},
});
@@ -913,7 +913,7 @@ Object.defineProperty(nodeProto, 'eulerAngles', {
Object.defineProperty(nodeProto, 'worldMatrix', {
configurable: true,
enumerable: true,
get (): Readonly<Mat4> {
get(): Readonly<Mat4> {
return this.getWorldMatrix();
},
});
@@ -921,7 +921,7 @@ Object.defineProperty(nodeProto, 'worldMatrix', {
Object.defineProperty(nodeProto, '_mat', {
configurable: true,
enumerable: true,
get (): Readonly<Mat4> {
get(): Readonly<Mat4> {
return this.getWorldMatrix();
},
});
@@ -929,10 +929,10 @@ Object.defineProperty(nodeProto, '_mat', {
Object.defineProperty(nodeProto, 'activeInHierarchy', {
configurable: true,
enumerable: true,
get (): Readonly<Boolean> {
get(): Readonly<Boolean> {
return this._sharedUint8Arr[0] != 0; // Uint8, 0: activeInHierarchy
},
set (v) {
set(v) {
this._sharedUint8Arr[0] = (v ? 1 : 0); // Uint8, 0: activeInHierarchy
},
});
@@ -940,10 +940,10 @@ Object.defineProperty(nodeProto, 'activeInHierarchy', {
Object.defineProperty(nodeProto, '_activeInHierarchy', {
configurable: true,
enumerable: true,
get (): Readonly<Boolean> {
get(): Readonly<Boolean> {
return this._sharedUint8Arr[0] != 0; // Uint8, 0: activeInHierarchy
},
set (v) {
set(v) {
this._sharedUint8Arr[0] = (v ? 1 : 0); // Uint8, 0: activeInHierarchy
},
});
@@ -951,10 +951,10 @@ Object.defineProperty(nodeProto, '_activeInHierarchy', {
Object.defineProperty(nodeProto, 'layer', {
configurable: true,
enumerable: true,
get () {
get() {
return this._sharedUint32Arr[1]; // Uint32, 1: layer
},
set (v) {
set(v) {
this._sharedUint32Arr[1] = v; // Uint32, 1: layer
if (this._uiProps && this._uiProps.uiComp) {
this._uiProps.uiComp.setNodeDirty();
@@ -967,10 +967,10 @@ Object.defineProperty(nodeProto, 'layer', {
Object.defineProperty(nodeProto, '_layer', {
configurable: true,
enumerable: true,
get () {
get() {
return this._sharedUint32Arr[1]; // Uint32, 1: layer
},
set (v) {
set(v) {
this._sharedUint32Arr[1] = v; // Uint32, 1: layer
},
});
@@ -978,10 +978,10 @@ Object.defineProperty(nodeProto, '_layer', {
Object.defineProperty(nodeProto, '_eventMask', {
configurable: true,
enumerable: true,
get () {
get() {
return this._sharedUint32Arr[0]; // Uint32, 0: eventMask
},
set (v) {
set(v) {
this._sharedUint32Arr[0] = v; // Uint32, 0: eventMask
},
});
@@ -989,10 +989,10 @@ Object.defineProperty(nodeProto, '_eventMask', {
Object.defineProperty(nodeProto, '_siblingIndex', {
configurable: true,
enumerable: true,
get () {
get() {
return this._sharedInt32Arr[0]; // Int32, 0: siblingIndex
},
set (v) {
set(v) {
this._sharedInt32Arr[0] = v; // Int32, 0: siblingIndex
},
});
@@ -1004,10 +1004,10 @@ nodeProto.getSiblingIndex = function getSiblingIndex() {
Object.defineProperty(nodeProto, '_dirtyFlags', {
configurable: true,
enumerable: true,
get () {
get() {
return this._sharedUint32Arr[2]; // Uint32, 2: dirtyFlags
},
set (v) {
set(v) {
this._sharedUint32Arr[2] = v; // Uint32, 2: dirtyFlags
},
});
@@ -1015,10 +1015,10 @@ Object.defineProperty(nodeProto, '_dirtyFlags', {
Object.defineProperty(nodeProto, '_active', {
configurable: true,
enumerable: true,
get (): Readonly<Boolean> {
get(): Readonly<Boolean> {
return this._sharedUint8Arr[1] != 0; // Uint8, 1: active
},
set (v) {
set(v) {
this._sharedUint8Arr[1] = (v ? 1 : 0); // Uint8, 1: active
},
});
@@ -1026,10 +1026,10 @@ Object.defineProperty(nodeProto, '_active', {
Object.defineProperty(nodeProto, 'active', {
configurable: true,
enumerable: true,
get (): Readonly<Boolean> {
get(): Readonly<Boolean> {
return this._sharedUint8Arr[1] != 0; // Uint8, 1: active
},
set (v) {
set(v) {
this.setActive(!!v);
},
});
@@ -1037,10 +1037,10 @@ Object.defineProperty(nodeProto, 'active', {
Object.defineProperty(nodeProto, '_static', {
configurable: true,
enumerable: true,
get (): Readonly<Boolean> {
get(): Readonly<Boolean> {
return this._sharedUint8Arr[2] != 0;
},
set (v) {
set(v) {
this._sharedUint8Arr[2] = (v ? 1 : 0);
},
});
@@ -1048,10 +1048,10 @@ Object.defineProperty(nodeProto, '_static', {
Object.defineProperty(nodeProto, 'forward', {
configurable: true,
enumerable: true,
get (): Vec3 {
get(): Vec3 {
return this.getForward();
},
set (dir: Vec3) {
set(dir: Vec3) {
this.setForward(dir);
},
});
@@ -1059,7 +1059,7 @@ Object.defineProperty(nodeProto, 'forward', {
Object.defineProperty(nodeProto, 'up', {
configurable: true,
enumerable: true,
get (): Vec3 {
get(): Vec3 {
return this.getUp();
},
});
@@ -1067,7 +1067,7 @@ Object.defineProperty(nodeProto, 'up', {
Object.defineProperty(nodeProto, 'right', {
configurable: true,
enumerable: true,
get (): Vec3 {
get(): Vec3 {
return this.getRight();
},
});
@@ -1075,7 +1075,7 @@ Object.defineProperty(nodeProto, 'right', {
Object.defineProperty(nodeProto, 'eventProcessor', {
configurable: true,
enumerable: true,
get () {
get() {
return this._eventProcessor;
},
});
@@ -1083,7 +1083,7 @@ Object.defineProperty(nodeProto, 'eventProcessor', {
Object.defineProperty(nodeProto, 'components', {
configurable: true,
enumerable: true,
get (): ReadonlyArray<Component> {
get(): ReadonlyArray<Component> {
return this._components;
},
});
@@ -1091,11 +1091,11 @@ Object.defineProperty(nodeProto, 'components', {
Object.defineProperty(nodeProto, '_parent', {
configurable: true,
enumerable: true,
get () {
get() {
this._parentRef = this._parentInternal;
return this._parentRef;
},
set (v) {
set(v) {
this._parentRef = this._parentInternal = v;
},
});
@@ -1103,11 +1103,11 @@ Object.defineProperty(nodeProto, '_parent', {
Object.defineProperty(nodeProto, 'parent', {
configurable: true,
enumerable: true,
get () {
get() {
this._parentRef = this.getParent();
return this._parentRef;
},
set (v) {
set(v) {
this._parentRef = v;
this.setParent(v);
},
@@ -1116,10 +1116,10 @@ Object.defineProperty(nodeProto, 'parent', {
Object.defineProperty(nodeProto, 'children', {
configurable: true,
enumerable: true,
get () {
get() {
return this._children;
},
set (v) {
set(v) {
this._children = v;
},
});
@@ -1127,7 +1127,7 @@ Object.defineProperty(nodeProto, 'children', {
Object.defineProperty(nodeProto, 'scene', {
configurable: true,
enumerable: true,
get () {
get() {
return this._scene;
}
});
@@ -1166,35 +1166,35 @@ nodeProto[serializeTag] = function (serializationOutput: SerializationOutput, co
}
// Detects if this node is mounted node of `PrefabInstance`
// TODO: optimize
const isMountedChild = () => !!(this[editorExtrasTag] as any)?.mountedRoot;
// Returns if this node is under `PrefabInstance`
// eslint-disable-next-line arrow-body-style
const isSyncPrefab = () => {
// 1. Under `PrefabInstance`, but not mounted
// 2. If the mounted node is a `PrefabInstance`, it's also a "sync prefab".
return this._prefab?.root?._prefab?.instance && (this?._prefab?.instance || !isMountedChild());
};
const canDiscardByPrefabRoot = () => !(context.customArguments[(reserveContentsForAllSyncablePrefabTag) as any]
|| !isSyncPrefab() || context.root === this);
if (canDiscardByPrefabRoot()) {
// discard props disallow to synchronize
const isRoot = this._prefab?.root === this;
if (isRoot) {
serializationOutput.writeProperty('_objFlags', this._objFlags);
serializationOutput.writeProperty('_parent', this._parent);
serializationOutput.writeProperty('_prefab', this._prefab);
if (context.customArguments.keepNodeUuid) {
serializationOutput.writeProperty('_id', this._id);
}
// TODO: editorExtrasTag may be a symbol in the future
serializationOutput.writeProperty(editorExtrasTag, this[editorExtrasTag]);
} else {
// should not serialize child node of synchronizable prefab
// TODO: optimize
const isMountedChild = () => !!(this[editorExtrasTag] as any)?.mountedRoot;
// Returns if this node is under `PrefabInstance`
// eslint-disable-next-line arrow-body-style
const isSyncPrefab = () => {
// 1. Under `PrefabInstance`, but not mounted
// 2. If the mounted node is a `PrefabInstance`, it's also a "sync prefab".
return this._prefab?.root?._prefab?.instance && (this?._prefab?.instance || !isMountedChild());
};
const canDiscardByPrefabRoot = () => !(context.customArguments[(reserveContentsForAllSyncablePrefabTag) as any]
|| !isSyncPrefab() || context.root === this);
if (canDiscardByPrefabRoot()) {
// discard props disallow to synchronize
const isRoot = this._prefab?.root === this;
if (isRoot) {
serializationOutput.writeProperty('_objFlags', this._objFlags);
serializationOutput.writeProperty('_parent', this._parent);
serializationOutput.writeProperty('_prefab', this._prefab);
if (context.customArguments.keepNodeUuid) {
serializationOutput.writeProperty('_id', this._id);
}
// TODO: editorExtrasTag may be a symbol in the future
serializationOutput.writeProperty(editorExtrasTag, this[editorExtrasTag]);
} else {
serializationOutput.writeThis();
// should not serialize child node of synchronizable prefab
}
} else {
serializationOutput.writeThis();
}
};
nodeProto._onActiveNode = function (shouldActiveNow: boolean) {
@@ -1342,40 +1342,14 @@ nodeProto._ctor = function (name?: string) {
this._registeredNodeEventTypeMask = 0;
};
// 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', () => null);
serializable(NodeProto, '_children', () => []);
serializable(NodeProto, '_active', () => true);
serializable(NodeProto, '_components', () => []);
serializable(NodeProto, '_prefab', () => null);
serializable(NodeProto, '_lpos', () => new Vec3());
serializable(NodeProto, '_lrot', () => new Quat());
serializable(NodeProto, '_lscale', () => new Vec3(1, 1, 1));
serializable(NodeProto, '_mobility', () => MobilityMode.Static);
serializable(NodeProto, '_layer', () => Layers.Enum.DEFAULT);
serializable(NodeProto, '_euler', () => new Vec3());
const eulerAnglesDescriptor = Object.getOwnPropertyDescriptor(NodeProto, 'eulerAngles');
type(Vec3)(NodeProto, 'eulerAngles', eulerAnglesDescriptor);
const angleDescriptor = Object.getOwnPropertyDescriptor(NodeProto, 'angle');
editable(NodeProto, 'angle', angleDescriptor);
const mobilityDescriptor = Object.getOwnPropertyDescriptor(NodeProto, 'mobility');
editable(NodeProto, 'mobility', mobilityDescriptor);
type(MobilityMode)(NodeProto, 'mobility', mobilityDescriptor);
const layerDescriptor = Object.getOwnPropertyDescriptor(NodeProto, 'layer');
editable(NodeProto, 'layer', layerDescriptor);
nodePolyfill(Node);
ccclass('cc.Node')(Node);
// handle meta data, it is generated automatically
patch_cc_Node({
Node,
Vec3,
Quat,
MobilityMode,
Layers
});
+8 -301
View File
@@ -20,26 +20,14 @@
THE SOFTWARE.
*/
import {
displayName,
editable,
formerlySerializedAs,
range,
readOnly,
serializable,
tooltip,
type,
visible
// @ts-ignore
} from 'cc.decorator';
import { legacyCC } from '../core/global-exports';
import { CCFloat, CCInteger } from '../core/data';
import { TextureCube } from '../asset/assets/texture-cube';
import { Enum } from '../core/value-types';
import { ccclass, displayOrder, rangeMin, rangeStep, slide } from '../core/data/decorators';
import { Ambient, EnvironmentLightingType } from '../render-scene/scene';
import { Material } from '../asset/assets/material';
import { Vec2, Vec3, Color, Vec4 } from '../core/math';
import * as decros from '../native-binding/decorators';
export const DEFAULT_WORLD_MIN_POS = new Vec3(-1024.0, -1024.0, -1024.0);
export const DEFAULT_WORLD_MAX_POS = new Vec3(1024.0, 1024.0, 1024.0);
@@ -275,300 +263,19 @@ legacyCC.SceneGlobals = SceneGlobals;
})();
function ambientSkyLightEnable() {
const scene = legacyCC.director.getScene();
const skybox = scene.globals.skybox;
if (skybox.useIBL && skybox.applyDiffuseMap) {
return false;
} else {
return true;
}
}
function checkFieldIs(attr: string, value: number) {
return function () {
return this[attr] === value;
};
}
function checkFieldNot(attr: string, value: number) {
return function () {
return this[attr] !== value;
};
}
// handle meta data, it is generated automatically
const SceneGlobalsProto = SceneGlobals.prototype;
editable(SceneGlobalsProto, 'ambient', () => new AmbientInfo());
serializable(SceneGlobalsProto, 'ambient', () => new AmbientInfo());
editable(SceneGlobalsProto, 'shadows', () => new ShadowsInfo());
serializable(SceneGlobalsProto, 'shadows', () => new ShadowsInfo());
serializable(SceneGlobalsProto, '_skybox', () => new SkyboxInfo());
serializable(SceneGlobalsProto, 'fog', () => new FogInfo());
editable(SceneGlobalsProto, 'fog', () => new FogInfo());
const skyboxDescriptor = Object.getOwnPropertyDescriptor(SceneGlobalsProto, 'skybox');
type(SkyboxInfo)(SceneGlobalsProto, 'skybox', skyboxDescriptor);
editable(SceneGlobalsProto, 'skybox', skyboxDescriptor);
serializable(SceneGlobalsProto, 'octree', () => new OctreeInfo());
editable(SceneGlobalsProto, 'octree', () => new OctreeInfo());
serializable(SceneGlobalsProto, 'lightProbeInfo', () => new LightProbeInfo());
editable(SceneGlobalsProto, 'lightProbeInfo', () => new LightProbeInfo());
ccclass('cc.SceneGlobals')(SceneGlobals);
decros.patch_cc_SceneGlobals({SceneGlobals, AmbientInfo, SkyboxInfo, FogInfo, ShadowsInfo, LightProbeInfo, OctreeInfo, LightProbeInfo});
const OctreeInfoProto = OctreeInfo.prototype;
serializable(OctreeInfoProto, '_enabled', () => false);
serializable(OctreeInfoProto, '_minPos', () => new Vec3(DEFAULT_WORLD_MIN_POS));
serializable(OctreeInfoProto, '_maxPos', () => new Vec3(DEFAULT_WORLD_MAX_POS));
serializable(OctreeInfoProto, '_depth', () => DEFAULT_OCTREE_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);
decros.patch_cc_OctreeInfo({OctreeInfo, CCInteger, Vec3, DEFAULT_WORLD_MAX_POS, DEFAULT_WORLD_MIN_POS, DEFAULT_OCTREE_DEPTH});
const ShadowsInfoProto = ShadowsInfo.prototype;
serializable(ShadowsInfoProto, '_enabled', () => false);
serializable(ShadowsInfoProto, '_type', () => ShadowType.Planar);
serializable(ShadowsInfoProto, '_normal', () => new Vec3(0, 1, 0));
serializable(ShadowsInfoProto, '_distance', () => 0);
serializable(ShadowsInfoProto, '_shadowColor', () => new Color(0, 0, 0, 76));
serializable(ShadowsInfoProto, '_maxReceived', () => 4);
serializable(ShadowsInfoProto, '_size', () => new Vec2(1024, 1024));
const shadowEnabledDescriptor = Object.getOwnPropertyDescriptor(ShadowsInfoProto, 'enabled');
tooltip('i18n:shadow.enabled')(ShadowsInfoProto, 'enabled', shadowEnabledDescriptor);
editable(ShadowsInfoProto, 'enabled', shadowEnabledDescriptor);
const typeDescriptor = Object.getOwnPropertyDescriptor(ShadowsInfoProto, 'type');
tooltip('i18n:shadow.type')(ShadowsInfoProto, 'type', typeDescriptor)
type(ShadowType)(ShadowsInfoProto, 'type', typeDescriptor);
editable(ShadowsInfoProto, 'type', typeDescriptor);
const shadowColorDescriptor = Object.getOwnPropertyDescriptor(ShadowsInfoProto, 'shadowColor');
tooltip('i18n:shadow.shadowColor')(ShadowsInfoProto, 'shadowColor', shadowColorDescriptor);
visible(checkFieldIs("_type", ShadowType.Planar))(ShadowsInfoProto, 'shadowColor', shadowColorDescriptor);
const planeDirectionDescriptor = Object.getOwnPropertyDescriptor(ShadowsInfoProto, 'planeDirection');
tooltip('i18n:shadow.planeDirection')(ShadowsInfoProto, 'planeDirection', planeDirectionDescriptor);
visible(checkFieldIs("_type", ShadowType.Planar))(ShadowsInfoProto, 'planeDirection', planeDirectionDescriptor);
const planeHeightDescriptor = Object.getOwnPropertyDescriptor(ShadowsInfoProto, 'planeHeight');
tooltip('i18n:shadow.planeHeight')(ShadowsInfoProto, 'planeHeight', planeHeightDescriptor);
visible(checkFieldIs("_type", ShadowType.Planar))(ShadowsInfoProto, 'planeHeight', planeHeightDescriptor);
type(CCFloat)(ShadowsInfoProto, 'planeHeight', planeHeightDescriptor);
editable(ShadowsInfoProto, 'planeHeight', planeHeightDescriptor);
const maxReceivedDescriptor = Object.getOwnPropertyDescriptor(ShadowsInfoProto, 'maxReceived');
visible(checkFieldIs("_type", ShadowType.ShadowMap))(ShadowsInfoProto, 'maxReceived', maxReceivedDescriptor);
tooltip('i18n:shadow.maxReceived')(ShadowsInfoProto, 'maxReceived', maxReceivedDescriptor);
type(CCInteger)(ShadowsInfoProto, 'maxReceived', maxReceivedDescriptor);
const shadowMapSizeDescriptor = Object.getOwnPropertyDescriptor(ShadowsInfoProto, 'shadowMapSize');
visible(checkFieldIs("_type", ShadowType.ShadowMap))(ShadowsInfoProto, 'shadowMapSize', shadowMapSizeDescriptor);
tooltip('i18n:shadow.shadowMapSize')(ShadowsInfoProto, 'shadowMapSize', shadowMapSizeDescriptor);
type(ShadowSize)(ShadowsInfoProto, 'shadowMapSize', shadowMapSizeDescriptor);
ccclass('cc.ShadowsInfo')(ShadowsInfo);
decros.patch_cc_ShadowsInfo({ShadowsInfo, ShadowType, CCFloat, CCInteger, ShadowSize, Vec3, Color, Vec2});
const FogInfoProto = FogInfo.prototype;
serializable(FogInfoProto, '_type', () => FogType.LINEAR);
serializable(FogInfoProto, '_fogColor', () => new Color('#C8C8C8'));
serializable(FogInfoProto, '_enabled', () => false);
serializable(FogInfoProto, '_fogDensity', () => 0.3);
serializable(FogInfoProto, '_fogStart', () => 0.5);
serializable(FogInfoProto, '_fogEnd', () => 300);
serializable(FogInfoProto, '_fogAtten', () => 5);
serializable(FogInfoProto, '_fogTop', () => 1.5);
serializable(FogInfoProto, '_fogRange', () => 1.2);
serializable(FogInfoProto, '_accurate', () => false);
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._type !== FogType.LAYERED && this._type !== FogType.LINEAR; })(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(checkFieldNot("_type", FogType.LAYERED))(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(checkFieldIs("_type", FogType.LINEAR))(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(checkFieldNot("_type", FogType.LINEAR))(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(checkFieldIs("_type", FogType.LAYERED))(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(checkFieldIs("_type", FogType.LAYERED))(FogInfoProto, 'fogRange', fogRangeDescriptor);
ccclass('cc.FogInfo')(FogInfo);
decros.patch_cc_FogInfo({FogInfo, FogType, CCFloat, Color});
const SkyboxInfoProto = SkyboxInfo.prototype;
serializable(SkyboxInfoProto, '_envLightingType', () => EnvironmentLightingType.HEMISPHERE_DIFFUSE);
formerlySerializedAs('_envmap')(SkyboxInfoProto, '_envmapHDR', () => null);
type(TextureCube)(SkyboxInfoProto, '_envmapHDR', () => null);
serializable(SkyboxInfoProto, '_envmapHDR', () => null);
type(TextureCube)(SkyboxInfoProto, '_envmapLDR', () => null);
serializable(SkyboxInfoProto, '_envmapLDR', () => null);
type(TextureCube)(SkyboxInfoProto, '_diffuseMapHDR', () => null);
serializable(SkyboxInfoProto, '_diffuseMapHDR', () => null);
type(TextureCube)(SkyboxInfoProto, '_diffuseMapLDR', () => null);
serializable(SkyboxInfoProto, '_diffuseMapLDR', () => null);
serializable(SkyboxInfoProto, '_enabled', () => false);
serializable(SkyboxInfoProto, '_useHDR', () => true);
type(Material)(SkyboxInfoProto, '_editableMaterial', () => null);
serializable(SkyboxInfoProto, '_editableMaterial', () => null);
type(TextureCube)(SkyboxInfoProto, '_reflectionHDR', () => null);
serializable(SkyboxInfoProto, '_reflectionHDR', () => null);
type(TextureCube)(SkyboxInfoProto, '_reflectionLDR', () => null);
serializable(SkyboxInfoProto, '_reflectionLDR', () => null);
decros.patch_cc_SkyboxInfo({SkyboxInfo, EnvironmentLightingType, TextureCube, CCFloat, Material });
const skyboxRotationAngleDescriptor = Object.getOwnPropertyDescriptor(SkyboxInfoProto, 'rotationAngle');
type(CCFloat)(SkyboxInfoProto, 'rotationAngle', skyboxRotationAngleDescriptor);
range([0, 360])(SkyboxInfoProto, 'rotationAngle', skyboxRotationAngleDescriptor);
rangeStep(1)(SkyboxInfoProto, 'rotationAngle', skyboxRotationAngleDescriptor);
slide(SkyboxInfoProto, 'rotationAngle', skyboxRotationAngleDescriptor);
tooltip('i18n:skybox.rotationAngle')(SkyboxInfoProto, 'rotationAngle', skyboxRotationAngleDescriptor);
decros.patch_cc_AmbientInfo({AmbientInfo, Vec4, Ambient, CCFloat, legacyCC});
const skyboxReflectionMapDescriptor = Object.getOwnPropertyDescriptor(SkyboxInfoProto, 'reflectionMap');
editable(SkyboxInfoProto, 'reflectionMap', skyboxReflectionMapDescriptor);
readOnly(SkyboxInfoProto, 'reflectionMap', skyboxReflectionMapDescriptor)
type(TextureCube)(SkyboxInfoProto, 'reflectionMap', skyboxReflectionMapDescriptor)
displayOrder(100)(SkyboxInfoProto, 'reflectionMap', skyboxReflectionMapDescriptor)
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 () { return this.useIBL && this.applyDiffuseMap; })(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);
serializable(SkyboxInfoProto, '_rotationAngle', () => 0);
ccclass('cc.SkyboxInfo')(SkyboxInfo);
const AmbientInfoProto = AmbientInfo.prototype;
formerlySerializedAs('_skyColor')(AmbientInfoProto, '_skyColorHDR', () => new Vec4(0.2, 0.5, 0.8, 1.0));
serializable(AmbientInfoProto, '_skyColorHDR', () => new Vec4(0.2, 0.5, 0.8, 1.0));
formerlySerializedAs('_skyIllum')(AmbientInfoProto, '_skyIllumHDR', () => Ambient.SKY_ILLUM);
serializable(AmbientInfoProto, '_skyIllumHDR', () => Ambient.SKY_ILLUM);
formerlySerializedAs('_groundAlbedo')(AmbientInfoProto, '_groundAlbedoHDR', () => new Vec4(0.2, 0.2, 0.2, 1.0));
serializable(AmbientInfoProto, '_groundAlbedoHDR', () => new Vec4(0.2, 0.2, 0.2, 1.0));
serializable(AmbientInfoProto, '_skyColorLDR', () => new Vec4(0.2, 0.5, 0.8, 1.0));
serializable(AmbientInfoProto, '_skyIllumLDR', () => Ambient.SKY_ILLUM);
serializable(AmbientInfoProto, '_groundAlbedoLDR', () => new Vec4(0.2, 0.2, 0.2, 1.0));
const skyLightingColorDescriptor = Object.getOwnPropertyDescriptor(AmbientInfoProto, 'skyLightingColor');
tooltip('i18n:ambient.skyLightingColor')(AmbientInfoProto, 'skyLightingColor', skyLightingColorDescriptor);
editable(AmbientInfoProto, 'skyLightingColor', skyLightingColorDescriptor);
visible(ambientSkyLightEnable)(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(ambientSkyLightEnable)(AmbientInfoProto, 'groundLightingColor', groundLightingColorDescriptor);
ccclass('cc.AmbientInfo')(AmbientInfo);
const LightProbeInfoProto = LightProbeInfo.prototype;
serializable(LightProbeInfoProto, '_giScale', () => 1.0);
serializable(LightProbeInfoProto, '_giSamples', () => 1024);
serializable(LightProbeInfoProto, '_bounces', () => 2);
serializable(LightProbeInfoProto, '_reduceRinging', () => 0.0);
serializable(LightProbeInfoProto, '_showProbe', () => true);
serializable(LightProbeInfoProto, '_showWireframe', () => true);
serializable(LightProbeInfoProto, '_showConvex', () => false);
serializable(LightProbeInfoProto, '_data', () => null);
const lightProbeGIScaleDescriptor = Object.getOwnPropertyDescriptor(LightProbeInfoProto, 'giScale');
range([0, 100, 1])(LightProbeInfoProto, 'giScale', lightProbeGIScaleDescriptor)
type(CCFloat)(LightProbeInfoProto, 'giScale', lightProbeGIScaleDescriptor)
displayName('GIScale')(LightProbeInfoProto, 'giScale', lightProbeGIScaleDescriptor)
tooltip('i18n:light_probe.giScale')(LightProbeInfoProto, 'giScale', lightProbeGIScaleDescriptor);
editable(LightProbeInfoProto, 'giScale', lightProbeGIScaleDescriptor);
const lightProbeGISamplesDescriptor = Object.getOwnPropertyDescriptor(LightProbeInfoProto, 'giSamples');
tooltip('i18n:light_probe.giSamples')(LightProbeInfoProto, 'giSamples', lightProbeGISamplesDescriptor);
editable(LightProbeInfoProto, 'giSamples', lightProbeGISamplesDescriptor);
range([64, 65536, 1])(LightProbeInfoProto, 'giSamples', lightProbeGISamplesDescriptor);
type(CCInteger)(LightProbeInfoProto, 'giSamples', lightProbeGISamplesDescriptor);
displayName('GISamples')(LightProbeInfoProto, 'giSamples', lightProbeGISamplesDescriptor);
const lightProbeBouncesDescriptor = Object.getOwnPropertyDescriptor(LightProbeInfoProto, 'bounces');
tooltip('i18n:light_probe.bounces')(LightProbeInfoProto, 'bounces', lightProbeBouncesDescriptor);
editable(LightProbeInfoProto, 'bounces', lightProbeBouncesDescriptor);
range([1, 4, 1])(LightProbeInfoProto, 'bounces', lightProbeBouncesDescriptor);
type(CCInteger)(LightProbeInfoProto, 'bounces', lightProbeBouncesDescriptor);
tooltip('i18n:light_probe.bounces')(LightProbeInfoProto, 'bounces', lightProbeBouncesDescriptor);
const lightProbeReduceRingingDescriptor = Object.getOwnPropertyDescriptor(LightProbeInfoProto, 'reduceRinging');
tooltip('i18n:light_probe.reduceRinging')(LightProbeInfoProto, 'reduceRinging', lightProbeReduceRingingDescriptor);
editable(LightProbeInfoProto, 'reduceRinging', lightProbeReduceRingingDescriptor);
range([0.0, 0.05, 0.001])(LightProbeInfoProto, 'reduceRinging', lightProbeReduceRingingDescriptor);
slide(LightProbeInfoProto, 'reduceRinging', lightProbeReduceRingingDescriptor);
type(CCFloat)(LightProbeInfoProto, 'reduceRinging', lightProbeReduceRingingDescriptor);
const lightProbeShowProbeDescriptor = Object.getOwnPropertyDescriptor(LightProbeInfoProto, 'showProbe');
tooltip('i18n:light_probe.showProbe')(LightProbeInfoProto, 'showProbe', lightProbeShowProbeDescriptor);
editable(LightProbeInfoProto, 'showProbe', lightProbeShowProbeDescriptor);
const lightProbeShowWireframeDescriptor = Object.getOwnPropertyDescriptor(LightProbeInfoProto, 'showWireframe');
tooltip('i18n:light_probe.showWireframe')(LightProbeInfoProto, 'showWireframe', lightProbeShowWireframeDescriptor);
editable(LightProbeInfoProto, 'showWireframe', lightProbeShowWireframeDescriptor);
const lightProbeShowConvexDescriptor = Object.getOwnPropertyDescriptor(LightProbeInfoProto, 'showConvex');
tooltip('i18n:light_probe.showConvex')(LightProbeInfoProto, 'showConvex', lightProbeShowConvexDescriptor);
editable(LightProbeInfoProto, 'showConvex', lightProbeShowConvexDescriptor);
ccclass('cc.LightProbeInfo')(LightProbeInfo);
decros.patch_cc_LightProbeInfo({LightProbeInfo, CCFloat, CCInteger});
+2 -8
View File
@@ -20,7 +20,6 @@
THE SOFTWARE.
*/
import { ccclass, editable, serializable } from 'cc.decorator';
import { EDITOR, TEST } from "internal:constants";
import { legacyCC } from '../core/global-exports';
import { Node } from './node';
@@ -28,6 +27,7 @@ import { applyTargetOverrides, expandNestedPrefabInstanceNode } from "./prefab/u
import { assert } from "../core/platform/debug";
import { updateChildrenForDeserialize } from '../core/utils/jsb-utils';
import { SceneGlobals } from './scene-globals';
import { patch_cc_Scene } from '../native-binding/decorators';
export const Scene = jsb.Scene;
export type Scene = jsb.Scene;
@@ -134,10 +134,4 @@ sceneProto._activate = function (active: boolean) {
};
// handle meta data, it is generated automatically
const SceneProto = Scene.prototype;
const globalsDescriptor = Object.getOwnPropertyDescriptor(SceneProto, 'globals');
editable(SceneProto, 'globals', globalsDescriptor);
editable(SceneProto, 'autoReleaseAssets', () => false);
serializable(SceneProto, 'autoReleaseAssets', () => false);
serializable(SceneProto, '_globals', () => new SceneGlobals());
ccclass('cc.Scene')(Scene);
patch_cc_Scene({Scene, SceneGlobals});
File diff suppressed because it is too large Load Diff
+43 -31
View File
@@ -31,12 +31,14 @@ import { codeAsset } from './rollup-plugins/code-asset';
import { ModeType, PlatformType } from './constant-manager';
import { assetUrl } from './rollup-plugins/asset-url';
import * as decoratorRecorder from './babel-plugins/decorator-parser';
export { IOptimizeDecorators } from './config-interface';
export { ModeType, PlatformType, FlagType, ConstantOptions, BuildTimeConstants, CCEnvConstants } from './constant-manager';
export { StatsQuery };
export { ModuleOption, enumerateModuleOptionReps, parseModuleOption };
function equalPathIgnoreDriverLetterCase (lhs: string, rhs: string) {
function equalPathIgnoreDriverLetterCase(lhs: string, rhs: string) {
if (lhs.length !== rhs.length) {
return false;
}
@@ -53,11 +55,11 @@ const equalPath = process.platform === 'win32'
? equalPathIgnoreDriverLetterCase
: (lhs: string, rhs: string) => lhs === rhs;
function makePathEqualityKey (path: string) {
function makePathEqualityKey(path: string) {
return process.platform === 'win32' ? path.toLocaleLowerCase() : path;
}
async function build (options: build.Options) {
async function build(options: build.Options) {
console.debug(`Build-engine options: ${JSON.stringify(options, undefined, 2)}`);
return doBuild({
options,
@@ -163,6 +165,11 @@ namespace build {
};
buildTimeConstants: IBuildTimeConstants;
/**
* Generate cocos/native-binding/decorators.ts for native platforms
*/
generateDecoratorsForJSB?: boolean;
}
export interface Result {
@@ -187,7 +194,7 @@ namespace build {
hasCriticalWarns: boolean;
}
export async function transform (code: string, moduleOption: ModuleOption, loose?: boolean) {
export async function transform(code: string, moduleOption: ModuleOption, loose?: boolean) {
const babelFormat = moduleOptionsToBabelEnvModules(moduleOption);
const babelFileResult = await babel.transformAsync(code, {
presets: [[babelPresetEnv, { modules: babelFormat, loose: loose ?? true } as babelPresetEnv.Options]],
@@ -203,7 +210,7 @@ namespace build {
export { build };
async function doBuild ({
async function doBuild({
options,
}: {
options: build.Options;
@@ -304,7 +311,7 @@ async function doBuild ({
}
const rpVirtualOptions: Record<string, string> = {};
const vmInternalConstants = statsQuery.constantManager.exportStaticConstants({
platform,
mode,
@@ -404,6 +411,10 @@ async function doBuild ({
} as babelPresetCC.Options],
],
};
if (options.generateDecoratorsForJSB) {
babelOptions.presets?.push([() => ({ plugins: [[decoratorRecorder]] })]);
}
const rollupPlugins: rollup.Plugin[] = [];
@@ -432,14 +443,14 @@ async function doBuild ({
{
name: '@cocos/build-engine|module-overrides',
resolveId (source, importer) {
resolveId(source, importer) {
if (moduleOverrides[source]) {
return source;
} else {
return null;
}
},
load (this, id: string) {
load(this, id: string) {
const key = makePathEqualityKey(id);
if (!(key in moduleOverrides)) {
return null;
@@ -466,6 +477,7 @@ async function doBuild ({
preferConst: true,
}),
commonjs({
include: [
/node_modules[/\\]/,
@@ -665,7 +677,7 @@ export default Bullet;
return result;
async function nodeResolveAsync (specifier: string) {
async function nodeResolveAsync(specifier: string) {
return new Promise<string>((r, reject) => {
nodeResolve(specifier, {
basedir: engineRoot,
@@ -680,35 +692,35 @@ export default Bullet;
}
}
function moduleOptionsToRollupFormat (moduleOptions: ModuleOption): rollup.ModuleFormat {
function moduleOptionsToRollupFormat(moduleOptions: ModuleOption): rollup.ModuleFormat {
switch (moduleOptions) {
case ModuleOption.cjs: return 'cjs';
case ModuleOption.esm: return 'esm';
case ModuleOption.system: return 'system';
case ModuleOption.iife: return 'iife';
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
default: throw new Error(`Unknown module format ${moduleOptions}`);
case ModuleOption.cjs: return 'cjs';
case ModuleOption.esm: return 'esm';
case ModuleOption.system: return 'system';
case ModuleOption.iife: return 'iife';
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
default: throw new Error(`Unknown module format ${moduleOptions}`);
}
}
function moduleOptionsToBabelEnvModules (moduleOptions: ModuleOption):
| false
| 'commonjs'
| 'amd'
| 'umd'
| 'systemjs'
| 'auto' {
function moduleOptionsToBabelEnvModules(moduleOptions: ModuleOption):
| false
| 'commonjs'
| 'amd'
| 'umd'
| 'systemjs'
| 'auto' {
switch (moduleOptions) {
case ModuleOption.cjs: return 'commonjs';
case ModuleOption.system: return 'systemjs';
case ModuleOption.iife:
case ModuleOption.esm: return false;
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
default: throw new Error(`Unknown module format ${moduleOptions}`);
case ModuleOption.cjs: return 'commonjs';
case ModuleOption.system: return 'systemjs';
case ModuleOption.iife:
case ModuleOption.esm: return false;
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
default: throw new Error(`Unknown module format ${moduleOptions}`);
}
}
export async function isSourceChanged (incrementalFile: string) {
export async function isSourceChanged(incrementalFile: string) {
let record: Record<string, number>;
try {
record = await fs.readJSON(incrementalFile);
@@ -733,7 +745,7 @@ export async function isSourceChanged (incrementalFile: string) {
return false;
}
async function getDefaultModuleEntries (engine: string) {
async function getDefaultModuleEntries(engine: string) {
type ModuleDivision = any; // import('../../scripts/module-division/tools/division-config').ModuleDivision;
type GroupItem = any; // import('../../scripts/module-division/tools/division-config').GroupItem;
type Item = any; // import('../../scripts/module-division/tools/division-config').Item;