diff --git a/.github/workflows/npm_test.yml b/.github/workflows/npm_test.yml new file mode 100644 index 0000000000..0e4eb159dc --- /dev/null +++ b/.github/workflows/npm_test.yml @@ -0,0 +1,30 @@ +name: npm test + +on: [push, pull_request] + +jobs: + npm_test: + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v2 + with: + node-version: '12.13' + + - name: install gulp + run: | + npm install -g gulp + + - name: npm install + run: | + npm install + + - name: build-debug-infos + run: | + gulp build-debug-infos + + - name: run test + run: | + npm test diff --git a/@types/jsb.d.ts b/@types/jsb.d.ts index 99d226351e..1a817fecfb 100644 --- a/@types/jsb.d.ts +++ b/@types/jsb.d.ts @@ -18,13 +18,32 @@ declare namespace jsb { export function getDevicePixelRatio(): number; export function getDeviceOrientation(): number; export function getNetworkType(): number; // TODO: enum type - export function getSafeAreaEdge(): any; // TODO: interface type + export function getSafeAreaEdge(): NativeSafeAreaEdge; export function setAccelerometerEnabled(isEnabled: boolean); export function setAccelerometerInterval(intervalInSeconds: number); export function getDeviceMotionValue(): DeviceMotionValue; } + export interface NativeSafeAreaEdge { + /** + * top + */ + x: number; + /** + * left + */ + y: number; + /** + * bottom + */ + z: number; + /** + * right + */ + w: number; + } + export interface MouseEvent { x: number, y: number, diff --git a/@types/pal/minigame.d.ts b/@types/pal/minigame.d.ts index 046e238c50..a03dfa204b 100644 --- a/@types/pal/minigame.d.ts +++ b/@types/pal/minigame.d.ts @@ -10,6 +10,11 @@ declare module 'pal/minigame' { offShow(callback: () => void): void; onHide(callback: () => void): void; offHide(callback: () => void): void; + /** + * This method returns the standardized SafeArea based on the screen coordinate system, + * which is not affected by the orientation of the screen. + * @returns {SafeArea} An interface displaying the data of safe area, including 'top', 'bottom', 'left', 'right', 'width' and 'height'. + */ getSafeArea(): SafeArea; triggerGC(): void; getBatteryInfoSync(): BatteryInfo; diff --git a/@types/pal/system.d.ts b/@types/pal/system.d.ts index 292bd5dc25..7735823bc9 100644 --- a/@types/pal/system.d.ts +++ b/@types/pal/system.d.ts @@ -38,6 +38,10 @@ declare module 'pal/system' { public getViewSize (): import('cocos/core/math').Size; public getOrientation (): import('pal/system/enum-type').Orientation; + /** + * Get the SafeAreaEdge based on the screen coordinate system. + * @return {SafeAreaEdge} An interface displaying the distance of the sides 'top', 'bottom', 'left' and 'right'. + */ public getSafeAreaEdge (): SafeAreaEdge; public getBatteryLevel (): number; @@ -62,9 +66,9 @@ declare module 'pal/system' { export const system: System; export interface SafeAreaEdge { - left: number; - right: number; top: number; bottom: number; + left: number; + right: number; } } diff --git a/cocos/core/animation/animation-component.ts b/cocos/core/animation/animation-component.ts index 983aa53501..e4d8302cb2 100644 --- a/cocos/core/animation/animation-component.ts +++ b/cocos/core/animation/animation-component.ts @@ -105,9 +105,11 @@ export class Animation extends Eventify(Component) { /** * @en * Gets or sets the default clip. + * Two clips that both have same non-empty UUID are treat as equivalent. * @en * 获取或设置默认剪辑。 * 设置时,若指定的剪辑不在 `this.clips` 中则会被自动添加至 `this.clips`。 + * 具有相同的非空 UUID 的两个动画剪辑将被视为是相同的。 * @see [[playOnLoad]] */ @type(AnimationClip) @@ -498,5 +500,5 @@ function equalClips (clip1: AnimationClip | null, clip2: AnimationClip | null) { if (clip1 === clip2) { return true; } - return !!clip1 && !!clip2 && (clip1.name === clip2.name || clip1._uuid === clip2._uuid); + return !!clip1 && !!clip2 && (clip1._uuid === clip2._uuid) && clip1._uuid; } diff --git a/cocos/core/animation/easing.ts b/cocos/core/animation/easing.ts index 78063b7a8d..e37c113604 100644 --- a/cocos/core/animation/easing.ts +++ b/cocos/core/animation/easing.ts @@ -101,6 +101,9 @@ export function quintInOut (k: number) { } export function sineIn (k: number) { + if (k === 1) { + return 1; + } return 1 - Math.cos(k * Math.PI / 2); } @@ -213,11 +216,17 @@ export function elasticInOut (k: number) { } export function backIn (k: number) { + if (k === 1) { + return 1; + } const s = 1.70158; return k * k * ((s + 1) * k - s); } export function backOut (k: number) { + if (k === 0) { + return 0; + } const s = 1.70158; return --k * k * ((s + 1) * k + s) + 1; } diff --git a/cocos/core/global-exports.ts b/cocos/core/global-exports.ts index f7afe2923c..bb651da96d 100644 --- a/cocos/core/global-exports.ts +++ b/cocos/core/global-exports.ts @@ -173,7 +173,7 @@ if (DEV) { legacyCC._Test = {}; } -const engineVersion = '3.1'; +const engineVersion = '3.1.1'; /** * The current version of Cocos2d being used.
* Please DO NOT remove this String, it is an important flag for bug tracking.
diff --git a/cocos/core/pipeline/shadow/shadow-flow.ts b/cocos/core/pipeline/shadow/shadow-flow.ts index be9f429e41..b212d3c891 100644 --- a/cocos/core/pipeline/shadow/shadow-flow.ts +++ b/cocos/core/pipeline/shadow/shadow-flow.ts @@ -239,5 +239,7 @@ export class ShadowFlow extends RenderFlow { depth, )); } + + shadowInfo.shadowMapDirty = false; } } diff --git a/cocos/core/platform/sys.ts b/cocos/core/platform/sys.ts index 00ccdaea22..ea143e02de 100644 --- a/cocos/core/platform/sys.ts +++ b/cocos/core/platform/sys.ts @@ -33,6 +33,7 @@ import { legacyCC } from '../global-exports'; import { Rect } from '../math/rect'; import { warnID, log } from './debug'; import { NetworkType, Language, OS, Platform, BrowserType } from '../../../pal/system/enum-type'; +import { Vec2 } from '../math'; const viewSize = system.getViewSize(); const pixelRatio = system.pixelRatio; @@ -278,16 +279,37 @@ export const sys: Record = { /** * @en - * Returns the safe area of the screen (in design resolution). If the screen is not notched, the visibleRect will be returned by default. - * Currently supports Android, iOS and WeChat Mini Game platform. + * Returns the safe area of the screen (in design resolution) based on the game view coordinate system. + * If the screen is not notched, this method returns a Rect of the same size as visibleSize by default. + * Currently supports Android, iOS and WeChat, ByteDance Mini Game platform. * @zh - * 返回手机屏幕安全区域(设计分辨率为单位),如果不是异形屏将默认返回 visibleRect。目前支持安卓、iOS 原生平台和微信小游戏平台。 + * 返回基于游戏视图坐标系的手机屏幕安全区域(设计分辨率为单位),如果不是异形屏将默认返回一个和 visibleSize 一样大的 Rect。目前支持安卓、iOS 原生平台和微信、字节小游戏平台。 * @method getSafeAreaRect * @return {Rect} */ getSafeAreaRect () { - const visibleSize = legacyCC.view.getVisibleSize(); - return legacyCC.rect(0, 0, visibleSize.width, visibleSize.height) as Rect; + const locView = legacyCC.view; + const edge = system.getSafeAreaEdge(); + const viewSize = system.getViewSize(); + + // Get leftBottom and rightTop point in screen coordinates system. + const leftBottom = new Vec2(edge.left, viewSize.height - edge.bottom); + const rightTop = new Vec2(viewSize.width - edge.right, edge.top); + + // Convert to the location in game view coordinates system. + const relatedPos = { left: 0, top: 0, width: viewSize.width, height: viewSize.height }; + locView.convertToLocationInView(leftBottom.x, leftBottom.y, relatedPos, leftBottom); + locView.convertToLocationInView(rightTop.x, rightTop.y, relatedPos, rightTop); + + // Convert view point to design resolution size + locView._convertPointWithScale(leftBottom); + locView._convertPointWithScale(rightTop); + + const x = leftBottom.x; + const y = leftBottom.y; + const width = rightTop.x - leftBottom.x; + const height = rightTop.y - leftBottom.y; + return new Rect(x, y, width, height); }, __init () { diff --git a/cocos/ui/safe-area.ts b/cocos/ui/safe-area.ts index a5cf2f107f..6eb9b64bdb 100644 --- a/cocos/ui/safe-area.ts +++ b/cocos/ui/safe-area.ts @@ -30,6 +30,7 @@ import { ccclass, help, executionOrder, menu, executeInEditMode, requireComponent } from 'cc.decorator'; import { EDITOR } from 'internal:constants'; +import { system } from 'pal/system'; import { Component } from '../core/components'; import { UITransform } from '../2d/framework'; import { view, sys } from '../core/platform'; @@ -62,13 +63,22 @@ import { legacyCC } from '../core/global-exports'; @menu('UI/SafeArea') @requireComponent(Widget) export class SafeArea extends Component { + private _boundUpdateArea!: () => void; + + public onLoad () { + this._boundUpdateArea = this.updateArea.bind(this); + } + public onEnable () { this.updateArea(); - view.on('canvas-resize', this.updateArea, this); + // IDEA: need to delay the callback on Native platform ? + system.onViewResize(this._boundUpdateArea); + system.onOrientationChange(this._boundUpdateArea); } public onDisable () { - view.off('canvas-resize', this.updateArea, this); + system.offViewResize(this._boundUpdateArea); + system.offOrientationChange(this._boundUpdateArea); } /** diff --git a/cocos/ui/sub-context-view.ts b/cocos/ui/sub-context-view.ts index be8c6b44e9..3235aa7bc3 100644 --- a/cocos/ui/sub-context-view.ts +++ b/cocos/ui/sub-context-view.ts @@ -42,7 +42,7 @@ import { ImageAsset } from '../core/assets/image-asset'; import { Rect, Size } from '../core/math'; import { legacyCC } from '../core/global-exports'; -import { CCObject } from '../core'; +import { CCObject, SystemEventType } from '../core'; /** * @en SubContextView is a view component which controls open data context viewport in WeChat game platform.
@@ -123,6 +123,7 @@ export class SubContextView extends Component { this._initSharedCanvas(); this._initContentNode(); this._updateSubContextView(); + this._updateContentLayer(); } else { this.enabled = false; } @@ -228,11 +229,17 @@ export class SubContextView extends Component { private _registerNodeEvent () { this.node.on(Node.EventType.TRANSFORM_CHANGED, this._updateSubContextView, this); this.node.on(Node.EventType.SIZE_CHANGED, this._updateSubContextView, this); + this.node.on(SystemEventType.LAYER_CHANGED, this._updateContentLayer, this); } private _unregisterNodeEvent () { this.node.off(Node.EventType.TRANSFORM_CHANGED, this._updateSubContextView, this); this.node.off(Node.EventType.SIZE_CHANGED, this._updateSubContextView, this); + this.node.off(SystemEventType.LAYER_CHANGED, this._updateContentLayer, this); + } + + private _updateContentLayer () { + this._content.layer = this.node.layer; } public update (dt?: number) { diff --git a/cocos/ui/widget-manager.ts b/cocos/ui/widget-manager.ts index 7c5c5d2176..c9b4a18a96 100644 --- a/cocos/ui/widget-manager.ts +++ b/cocos/ui/widget-manager.ts @@ -91,12 +91,12 @@ function align (node: Node, widget: Widget) { } else { localLeft = -targetAnchor.x * targetWidth; localRight = localLeft + targetWidth; - - // adjust borders according to offsets - localLeft += widget.isAbsoluteLeft ? widget.left : widget.left * targetWidth; - localRight -= widget.isAbsoluteRight ? widget.right : widget.right * targetWidth; } + // adjust borders according to offsets + localLeft += widget.isAbsoluteLeft ? widget.left : widget.left * targetWidth; + localRight -= widget.isAbsoluteRight ? widget.right : widget.right * targetWidth; + if (hasTarget) { localLeft += inverseTranslate.x; localLeft *= inverseScale.x; @@ -148,12 +148,12 @@ function align (node: Node, widget: Widget) { } else { localBottom = -targetAnchor.y * targetHeight; localTop = localBottom + targetHeight; - - // adjust borders according to offsets - localBottom += widget.isAbsoluteBottom ? widget.bottom : widget.bottom * targetHeight; - localTop -= widget.isAbsoluteTop ? widget.top : widget.top * targetHeight; } + // adjust borders according to offsets + localBottom += widget.isAbsoluteBottom ? widget.bottom : widget.bottom * targetHeight; + localTop -= widget.isAbsoluteTop ? widget.top : widget.top * targetHeight; + if (hasTarget) { // transform localBottom += inverseTranslate.y; diff --git a/editor/.eslintrc.js b/editor/.eslintrc.js new file mode 100644 index 0000000000..a0e45a2ab1 --- /dev/null +++ b/editor/.eslintrc.js @@ -0,0 +1,136 @@ +module.exports = { + root:true, + 'env': { + 'browser': true, + 'commonjs': true, + 'es6': true, + 'node': true, + }, + 'extends': [ + 'eslint:recommended', + 'plugin:@typescript-eslint/eslint-recommended', + ], + 'globals': { + 'Atomics': 'readonly', + 'SharedArrayBuffer': 'readonly', + }, + 'parser': '@typescript-eslint/parser', + 'parserOptions': { + // 也就是ES6语法支持的意思 + 'ecmaVersion': 6, + 'sourceType': 'module', + 'ecmaFeatures': { + 'modules': true, + }, + // 'project': './tsconfig.json' + }, + 'plugins': [ + '@typescript-eslint', + // 'jsdoc', + // 'prettier', + ], + 'rules': { + // 'prettier/prettier': 'warn', + 'keyword-spacing': ['warn', { + 'before': true, + 'after': true, + }], + 'camelcase': ['warn', { + 'properties': 'always', + }], + 'indent': ['error', 4, { SwitchCase: 1, CallExpression: { arguments: 'off' }, ArrayExpression: 'first' }], + // 'no-else-return': 'error', + 'object-curly-spacing': ['error', 'always'], + 'array-bracket-spacing': ['error', 'never'], + 'semi-spacing': ['error', { + 'before': false, + 'after': true, + }], + 'rest-spread-spacing': ['error', 'never'], + 'space-in-parens': ['error', 'never'], + 'curly': 'error', + 'semi': ['error', 'always'], + 'no-multi-spaces': ['error', { ignoreEOLComments: true }], + 'no-whitespace-before-property': 'error', + 'no-tabs': ['error', { allowIndentationTabs: true }], + + 'no-unused-vars': ['warn', 'all'], + 'no-empty': ['error', { 'allowEmptyCatch': true }], + 'consistent-return': ['warn', { 'treatUndefinedAsUnspecified': true }], + 'eqeqeq': ['warn', 'always'], + // 'line-comment-position': ['warn', { 'position': 'above' }], + 'max-len': ['warn', { + 'code': 180, + }], + 'no-undef': 0, + 'no-constant-condition': ['warn', { + 'checkLoops': false, + }], + 'no-inner-declarations': ['warn'], + 'no-case-declarations': ['warn'], + + // 'jsdoc/check-alignment': 1, + // 'jsdoc/check-param-names': 1, + // 'jsdoc/check-tag-names': 1, + // 'jsdoc/check-types': 1, + // 'jsdoc/implements-on-classes': 1, + // 'jsdoc/newline-after-description': 1, + // 'jsdoc/no-undefined-types': 1, + // 'jsdoc/require-jsdoc': 1, + // 'jsdoc/require-param': 1, + // 'jsdoc/require-param-description': 1, + // 'jsdoc/require-param-name': 1, + // 'jsdoc/require-param-type': 1, + // 'jsdoc/require-returns': 1, + // 'jsdoc/require-returns-check': 1, + // 'jsdoc/require-returns-description': 1, + // 'jsdoc/require-returns-type': 1, + // 'jsdoc/valid-types': 1, + + // 行尾逗号 + 'comma-style': ['error', 'last'], + 'comma-dangle': ['error', { + 'arrays': 'always-multiline', + 'objects': 'always-multiline', + 'imports': 'always-multiline', + 'exports': 'always-multiline', + 'functions': 'only-multiline', + }], + 'comma-spacing': ['error', { + 'before': false, + 'after': true, + }], + + // 空格、空行约定 + 'unicode-bom': ['warn', 'never'], + 'block-spacing': ['error', 'always'], + 'arrow-spacing': ['error', { + 'before': true, + 'after': true, + }], + 'space-before-function-paren': ['error', { + 'anonymous': 'never', + 'named': 'never', + 'asyncArrow': 'always', + }], + 'space-before-blocks': ['error', 'always'], + 'space-infix-ops': ['warn'], + 'space-unary-ops': ['warn', { + 'words': true, + 'nonwords': false, + }], + 'spaced-comment': ['warn', 'always', { + 'line': { + 'markers': ['/'], + 'exceptions': ['/', '*'], + }, + }, + ], + 'switch-colon-spacing': ['warn', { + 'before': false, + 'after': true, + }], + 'eol-last': ['error', 'always'], + 'no-trailing-spaces': ['error', { 'ignoreComments': true }], + }, +}; diff --git a/editor/assets/default_file_content/prefab b/editor/assets/default_file_content/prefab new file mode 100644 index 0000000000..d8f89ab01e --- /dev/null +++ b/editor/assets/default_file_content/prefab @@ -0,0 +1,62 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "Node", + "_objFlags": 0, + "_parent": null, + "_children": [], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 2 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "c46/YsCPVOJYA4mWEpNYRx" + } +] \ No newline at end of file diff --git a/editor/assets/default_file_content/prefab.meta b/editor/assets/default_file_content/prefab.meta new file mode 100644 index 0000000000..ac995e8153 --- /dev/null +++ b/editor/assets/default_file_content/prefab.meta @@ -0,0 +1,14 @@ +{ + "ver": "1.0.0", + "importer": "*", + "imported": true, + "uuid": "c9bbaedb-125a-4942-a8eb-6952f9f2a00f", + "files": [ + "", + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "Node" + } +} diff --git a/editor/assets/default_prefab/ui/Graphics.prefab b/editor/assets/default_prefab/ui/Graphics.prefab index d4519af31f..21b926654e 100644 --- a/editor/assets/default_prefab/ui/Graphics.prefab +++ b/editor/assets/default_prefab/ui/Graphics.prefab @@ -47,7 +47,7 @@ "y": 1, "z": 1 }, - "_layer": 1073741824, + "_layer": 33554432, "_euler": { "__type__": "cc.Vec3", "x": 0, diff --git a/editor/engine-features/types.ts b/editor/engine-features/types.ts index 101ad3f324..6cf57f7c35 100644 --- a/editor/engine-features/types.ts +++ b/editor/engine-features/types.ts @@ -44,7 +44,7 @@ export interface ModuleRenderConfig { categories: {[category: string]: CategoryInfo}; } -export type Features = Record; +export type Features = Record; export interface BaseItem { /** diff --git a/editor/exports/offline-mappings.ts b/editor/exports/offline-mappings.ts index 9ca10696c8..550f5b29d2 100644 --- a/editor/exports/offline-mappings.ts +++ b/editor/exports/offline-mappings.ts @@ -1,8 +1,8 @@ import { - Address, BlendFactor, BlendOp, ColorMask, ComparisonFunc, CullMode, DynamicStateFlagBit, - Filter, Format, FormatInfos, FormatType, GetTypeSize, PolygonMode, PrimitiveMode, - ShadeModel, ShaderStageFlagBit, StencilOp, Type, DescriptorType, + Address, BlendFactor, BlendOp, ColorMask, ComparisonFunc, CullMode, DynamicStateFlagBit, + Filter, Format, FormatInfos, FormatType, GetTypeSize, PolygonMode, PrimitiveMode, + ShadeModel, ShaderStageFlagBit, StencilOp, Type, DescriptorType, } from '../../cocos/core/gfx/base/define'; import { RenderQueue } from '../../cocos/core/renderer/core/constants'; import { RenderPassStage, RenderPriority, SetIndex } from '../../cocos/core/pipeline/define'; @@ -87,169 +87,169 @@ const isSampler = (type) => type >= Type.SAMPLER1D; const isPaddedMatrix = (type) => type >= Type.MAT2 && type < Type.MAT4; const formatMap = { - bool: Format.R8, - bvec2: Format.RG8, - bvec3: Format.RGB8, - bvec4: Format.RGBA8, - int: Format.R32I, - ivec2: Format.RG32I, - ivec3: Format.RGB32I, - ivec4: Format.RGBA32I, - uint: Format.R32UI, - uvec2: Format.RG32UI, - uvec3: Format.RGB32UI, - uvec4: Format.RGBA32UI, - float: Format.R32F, - vec2: Format.RG32F, - vec3: Format.RGB32F, - vec4: Format.RGBA32F, - int8_t: Format.R8I, - i8vec2: Format.RG8I, - i8vec3: Format.RGB8I, - i8vec4: Format.RGBA8I, - uint8_t: Format.R8UI, - u8vec2: Format.RG8UI, - u8vec3: Format.RGB8UI, - u8vec4: Format.RGBA8UI, - int16_t: Format.R16I, - i16vec2: Format.RG16I, - i16vec3: Format.RGB16I, - i16vec4: Format.RGBA16I, - uint16_t: Format.R16UI, - u16vec2: Format.RG16UI, - u16vec3: Format.RGB16UI, - u16vec4: Format.RGBA16UI, - float16_t: Format.R16F, - f16vec2: Format.RG16F, - f16vec3: Format.RGB16F, - f16vec4: Format.RGBA16F, - // no suitable conversions: - mat2: Format.RGBA32F, - mat3: Format.RGBA32F, - mat4: Format.RGBA32F, - mat2x2: Format.RGBA32F, - mat3x3: Format.RGBA32F, - mat4x4: Format.RGBA32F, - mat2x3: Format.RGBA32F, - mat2x4: Format.RGBA32F, - mat3x2: Format.RGBA32F, - mat3x4: Format.RGBA32F, - mat4x2: Format.RGBA32F, - mat4x3: Format.RGBA32F, + bool: Format.R8, + bvec2: Format.RG8, + bvec3: Format.RGB8, + bvec4: Format.RGBA8, + int: Format.R32I, + ivec2: Format.RG32I, + ivec3: Format.RGB32I, + ivec4: Format.RGBA32I, + uint: Format.R32UI, + uvec2: Format.RG32UI, + uvec3: Format.RGB32UI, + uvec4: Format.RGBA32UI, + float: Format.R32F, + vec2: Format.RG32F, + vec3: Format.RGB32F, + vec4: Format.RGBA32F, + int8_t: Format.R8I, + i8vec2: Format.RG8I, + i8vec3: Format.RGB8I, + i8vec4: Format.RGBA8I, + uint8_t: Format.R8UI, + u8vec2: Format.RG8UI, + u8vec3: Format.RGB8UI, + u8vec4: Format.RGBA8UI, + int16_t: Format.R16I, + i16vec2: Format.RG16I, + i16vec3: Format.RGB16I, + i16vec4: Format.RGBA16I, + uint16_t: Format.R16UI, + u16vec2: Format.RG16UI, + u16vec3: Format.RGB16UI, + u16vec4: Format.RGBA16UI, + float16_t: Format.R16F, + f16vec2: Format.RG16F, + f16vec3: Format.RGB16F, + f16vec4: Format.RGBA16F, + // no suitable conversions: + mat2: Format.RGBA32F, + mat3: Format.RGBA32F, + mat4: Format.RGBA32F, + mat2x2: Format.RGBA32F, + mat3x3: Format.RGBA32F, + mat4x4: Format.RGBA32F, + mat2x3: Format.RGBA32F, + mat2x4: Format.RGBA32F, + mat3x2: Format.RGBA32F, + mat3x4: Format.RGBA32F, + mat4x2: Format.RGBA32F, + mat4x3: Format.RGBA32F, }; const getFormat = (name) => typeof name === 'string' && Format[name.toUpperCase()]; const getShaderStage = (name) => typeof name === 'string' && ShaderStageFlagBit[name.toUpperCase()]; const getDescriptorType = (name) => typeof name === 'string' && DescriptorType[name.toUpperCase()]; const isNormalized = (format) => { - const type = FormatInfos[format] && FormatInfos[format].type; - return type === FormatType.UNORM || type === FormatType.SNORM; + const type = FormatInfos[format] && FormatInfos[format].type; + return type === FormatType.UNORM || type === FormatType.SNORM; }; const passParams = { - // color mask - NONE: ColorMask.NONE, - R: ColorMask.R, - G: ColorMask.G, - B: ColorMask.B, - A: ColorMask.A, - RG: ColorMask.R | ColorMask.G, - RB: ColorMask.R | ColorMask.B, - RA: ColorMask.R | ColorMask.A, - GB: ColorMask.G | ColorMask.B, - GA: ColorMask.G | ColorMask.A, - BA: ColorMask.B | ColorMask.A, - RGB: ColorMask.R | ColorMask.G | ColorMask.B, - RGA: ColorMask.R | ColorMask.G | ColorMask.A, - RBA: ColorMask.R | ColorMask.B | ColorMask.A, - GBA: ColorMask.G | ColorMask.B | ColorMask.A, - ALL: ColorMask.ALL, - // blend operation - ADD: BlendOp.ADD, - SUB: BlendOp.SUB, - REV_SUB: BlendOp.REV_SUB, - MIN: BlendOp.MIN, - MAX: BlendOp.MAX, - // blend factor - ZERO: BlendFactor.ZERO, - ONE: BlendFactor.ONE, - SRC_ALPHA: BlendFactor.SRC_ALPHA, - DST_ALPHA: BlendFactor.DST_ALPHA, - ONE_MINUS_SRC_ALPHA: BlendFactor.ONE_MINUS_SRC_ALPHA, - ONE_MINUS_DST_ALPHA: BlendFactor.ONE_MINUS_DST_ALPHA, - SRC_COLOR: BlendFactor.SRC_COLOR, - DST_COLOR: BlendFactor.DST_COLOR, - ONE_MINUS_SRC_COLOR: BlendFactor.ONE_MINUS_SRC_COLOR, - ONE_MINUS_DST_COLOR: BlendFactor.ONE_MINUS_DST_COLOR, - SRC_ALPHA_SATURATE: BlendFactor.SRC_ALPHA_SATURATE, - CONSTANT_COLOR: BlendFactor.CONSTANT_COLOR, - ONE_MINUS_CONSTANT_COLOR: BlendFactor.ONE_MINUS_CONSTANT_COLOR, - CONSTANT_ALPHA: BlendFactor.CONSTANT_ALPHA, - ONE_MINUS_CONSTANT_ALPHA: BlendFactor.ONE_MINUS_CONSTANT_ALPHA, - // stencil operation - // ZERO: StencilOp.ZERO, // duplicate, safely removed because enum value is(and always will be) the same - KEEP: StencilOp.KEEP, - REPLACE: StencilOp.REPLACE, - INCR: StencilOp.INCR, - DECR: StencilOp.DECR, - INVERT: StencilOp.INVERT, - INCR_WRAP: StencilOp.INCR_WRAP, - DECR_WRAP: StencilOp.DECR_WRAP, + // color mask + NONE: ColorMask.NONE, + R: ColorMask.R, + G: ColorMask.G, + B: ColorMask.B, + A: ColorMask.A, + RG: ColorMask.R | ColorMask.G, + RB: ColorMask.R | ColorMask.B, + RA: ColorMask.R | ColorMask.A, + GB: ColorMask.G | ColorMask.B, + GA: ColorMask.G | ColorMask.A, + BA: ColorMask.B | ColorMask.A, + RGB: ColorMask.R | ColorMask.G | ColorMask.B, + RGA: ColorMask.R | ColorMask.G | ColorMask.A, + RBA: ColorMask.R | ColorMask.B | ColorMask.A, + GBA: ColorMask.G | ColorMask.B | ColorMask.A, + ALL: ColorMask.ALL, + // blend operation + ADD: BlendOp.ADD, + SUB: BlendOp.SUB, + REV_SUB: BlendOp.REV_SUB, + MIN: BlendOp.MIN, + MAX: BlendOp.MAX, + // blend factor + ZERO: BlendFactor.ZERO, + ONE: BlendFactor.ONE, + SRC_ALPHA: BlendFactor.SRC_ALPHA, + DST_ALPHA: BlendFactor.DST_ALPHA, + ONE_MINUS_SRC_ALPHA: BlendFactor.ONE_MINUS_SRC_ALPHA, + ONE_MINUS_DST_ALPHA: BlendFactor.ONE_MINUS_DST_ALPHA, + SRC_COLOR: BlendFactor.SRC_COLOR, + DST_COLOR: BlendFactor.DST_COLOR, + ONE_MINUS_SRC_COLOR: BlendFactor.ONE_MINUS_SRC_COLOR, + ONE_MINUS_DST_COLOR: BlendFactor.ONE_MINUS_DST_COLOR, + SRC_ALPHA_SATURATE: BlendFactor.SRC_ALPHA_SATURATE, + CONSTANT_COLOR: BlendFactor.CONSTANT_COLOR, + ONE_MINUS_CONSTANT_COLOR: BlendFactor.ONE_MINUS_CONSTANT_COLOR, + CONSTANT_ALPHA: BlendFactor.CONSTANT_ALPHA, + ONE_MINUS_CONSTANT_ALPHA: BlendFactor.ONE_MINUS_CONSTANT_ALPHA, + // stencil operation + // ZERO: StencilOp.ZERO, // duplicate, safely removed because enum value is(and always will be) the same + KEEP: StencilOp.KEEP, + REPLACE: StencilOp.REPLACE, + INCR: StencilOp.INCR, + DECR: StencilOp.DECR, + INVERT: StencilOp.INVERT, + INCR_WRAP: StencilOp.INCR_WRAP, + DECR_WRAP: StencilOp.DECR_WRAP, // comparison function - NEVER: ComparisonFunc.NEVER, - LESS: ComparisonFunc.LESS, - EQUAL: ComparisonFunc.EQUAL, - LESS_EQUAL: ComparisonFunc.LESS_EQUAL, - GREATER: ComparisonFunc.GREATER, - NOT_EQUAL: ComparisonFunc.NOT_EQUAL, - GREATER_EQUAL: ComparisonFunc.GREATER_EQUAL, - ALWAYS: ComparisonFunc.ALWAYS, - // cull mode - // NONE: CullMode.NONE, // duplicate, safely removed because enum value is(and always will be) the same - FRONT: CullMode.FRONT, - BACK: CullMode.BACK, - // shade mode - GOURAND: ShadeModel.GOURAND, - FLAT: ShadeModel.FLAT, - // polygon mode - FILL: PolygonMode.FILL, - LINE: PolygonMode.LINE, - POINT: PolygonMode.POINT, - // primitive mode - POINT_LIST: PrimitiveMode.POINT_LIST, - LINE_LIST: PrimitiveMode.LINE_LIST, - LINE_STRIP: PrimitiveMode.LINE_STRIP, - LINE_LOOP: PrimitiveMode.LINE_LOOP, - TRIANGLE_LIST: PrimitiveMode.TRIANGLE_LIST, - TRIANGLE_STRIP: PrimitiveMode.TRIANGLE_STRIP, - TRIANGLE_FAN: PrimitiveMode.TRIANGLE_FAN, - LINE_LIST_ADJACENCY: PrimitiveMode.LINE_LIST_ADJACENCY, - LINE_STRIP_ADJACENCY: PrimitiveMode.LINE_STRIP_ADJACENCY, - TRIANGLE_LIST_ADJACENCY: PrimitiveMode.TRIANGLE_LIST_ADJACENCY, - TRIANGLE_STRIP_ADJACENCY: PrimitiveMode.TRIANGLE_STRIP_ADJACENCY, - TRIANGLE_PATCH_ADJACENCY: PrimitiveMode.TRIANGLE_PATCH_ADJACENCY, - QUAD_PATCH_LIST: PrimitiveMode.QUAD_PATCH_LIST, - ISO_LINE_LIST: PrimitiveMode.ISO_LINE_LIST, + NEVER: ComparisonFunc.NEVER, + LESS: ComparisonFunc.LESS, + EQUAL: ComparisonFunc.EQUAL, + LESS_EQUAL: ComparisonFunc.LESS_EQUAL, + GREATER: ComparisonFunc.GREATER, + NOT_EQUAL: ComparisonFunc.NOT_EQUAL, + GREATER_EQUAL: ComparisonFunc.GREATER_EQUAL, + ALWAYS: ComparisonFunc.ALWAYS, + // cull mode + // NONE: CullMode.NONE, // duplicate, safely removed because enum value is(and always will be) the same + FRONT: CullMode.FRONT, + BACK: CullMode.BACK, + // shade mode + GOURAND: ShadeModel.GOURAND, + FLAT: ShadeModel.FLAT, + // polygon mode + FILL: PolygonMode.FILL, + LINE: PolygonMode.LINE, + POINT: PolygonMode.POINT, + // primitive mode + POINT_LIST: PrimitiveMode.POINT_LIST, + LINE_LIST: PrimitiveMode.LINE_LIST, + LINE_STRIP: PrimitiveMode.LINE_STRIP, + LINE_LOOP: PrimitiveMode.LINE_LOOP, + TRIANGLE_LIST: PrimitiveMode.TRIANGLE_LIST, + TRIANGLE_STRIP: PrimitiveMode.TRIANGLE_STRIP, + TRIANGLE_FAN: PrimitiveMode.TRIANGLE_FAN, + LINE_LIST_ADJACENCY: PrimitiveMode.LINE_LIST_ADJACENCY, + LINE_STRIP_ADJACENCY: PrimitiveMode.LINE_STRIP_ADJACENCY, + TRIANGLE_LIST_ADJACENCY: PrimitiveMode.TRIANGLE_LIST_ADJACENCY, + TRIANGLE_STRIP_ADJACENCY: PrimitiveMode.TRIANGLE_STRIP_ADJACENCY, + TRIANGLE_PATCH_ADJACENCY: PrimitiveMode.TRIANGLE_PATCH_ADJACENCY, + QUAD_PATCH_LIST: PrimitiveMode.QUAD_PATCH_LIST, + ISO_LINE_LIST: PrimitiveMode.ISO_LINE_LIST, - // POINT: Filter.POINT, // duplicate, safely removed because enum value is(and always will be) the same - LINEAR: Filter.LINEAR, - ANISOTROPIC: Filter.ANISOTROPIC, + // POINT: Filter.POINT, // duplicate, safely removed because enum value is(and always will be) the same + LINEAR: Filter.LINEAR, + ANISOTROPIC: Filter.ANISOTROPIC, - WRAP: Address.WRAP, - MIRROR: Address.MIRROR, - CLAMP: Address.CLAMP, - BORDER: Address.BORDER, + WRAP: Address.WRAP, + MIRROR: Address.MIRROR, + CLAMP: Address.CLAMP, + BORDER: Address.BORDER, - VIEWPORT: DynamicStateFlagBit.VIEWPORT, - SCISSOR: DynamicStateFlagBit.SCISSOR, - LINE_WIDTH: DynamicStateFlagBit.LINE_WIDTH, - DEPTH_BIAS: DynamicStateFlagBit.DEPTH_BIAS, - BLEND_CONSTANTS: DynamicStateFlagBit.BLEND_CONSTANTS, - DEPTH_BOUNDS: DynamicStateFlagBit.DEPTH_BOUNDS, - STENCIL_WRITE_MASK: DynamicStateFlagBit.STENCIL_WRITE_MASK, - STENCIL_COMPARE_MASK: DynamicStateFlagBit.STENCIL_COMPARE_MASK, + VIEWPORT: DynamicStateFlagBit.VIEWPORT, + SCISSOR: DynamicStateFlagBit.SCISSOR, + LINE_WIDTH: DynamicStateFlagBit.LINE_WIDTH, + DEPTH_BIAS: DynamicStateFlagBit.DEPTH_BIAS, + BLEND_CONSTANTS: DynamicStateFlagBit.BLEND_CONSTANTS, + DEPTH_BOUNDS: DynamicStateFlagBit.DEPTH_BOUNDS, + STENCIL_WRITE_MASK: DynamicStateFlagBit.STENCIL_WRITE_MASK, + STENCIL_COMPARE_MASK: DynamicStateFlagBit.STENCIL_COMPARE_MASK, - TRUE: true, - FALSE: false + TRUE: true, + FALSE: false, }; Object.assign(passParams, RenderPassStage); @@ -257,38 +257,38 @@ Object.assign(passParams, RenderPassStage); // an 'any' key will check against all elements defined in that object // a key start with '$' means its essential, and can't be undefined const effectStructure = { - $techniques: [ - { - $passes: [ + $techniques: [ { - depthStencilState: {}, - rasterizerState: {}, - blendState: { targets: [{}] }, - properties: { any: { sampler: {}, editor: {} } }, - migrations: { properties: { any: {} }, macros: { any: {} } }, - embeddedMacros: {}, - } - ] - } - ] + $passes: [ + { + depthStencilState: {}, + rasterizerState: {}, + blendState: { targets: [{}] }, + properties: { any: { sampler: {}, editor: {} } }, + migrations: { properties: { any: {} }, macros: { any: {} } }, + embeddedMacros: {}, + }, + ], + }, + ], }; export { - murmurhash2_32_gc, - SamplerInfoIndex, - genSamplerHash, - effectStructure, - isSampler, - typeMap, - formatMap, - getFormat, - getShaderStage, - getDescriptorType, - isNormalized, - isPaddedMatrix, - passParams, - RenderQueue, - SetIndex, - RenderPriority, - GetTypeSize, + murmurhash2_32_gc, + SamplerInfoIndex, + genSamplerHash, + effectStructure, + isSampler, + typeMap, + formatMap, + getFormat, + getShaderStage, + getDescriptorType, + isNormalized, + isPaddedMatrix, + passParams, + RenderQueue, + SetIndex, + RenderPriority, + GetTypeSize, }; diff --git a/editor/exports/populate-internal-constants.ts b/editor/exports/populate-internal-constants.ts index fa51c3395d..a49085544b 100644 --- a/editor/exports/populate-internal-constants.ts +++ b/editor/exports/populate-internal-constants.ts @@ -3,4 +3,4 @@ * Populate module `'internal-constants'` to editor * so it be can connected to the `'build-time-constants'`. */ -export * from 'internal:constants'; \ No newline at end of file +export * from 'internal:constants'; diff --git a/editor/i18n/en/assets.js b/editor/i18n/en/assets.js index 82eb9ca969..54f779b06e 100644 --- a/editor/i18n/en/assets.js +++ b/editor/i18n/en/assets.js @@ -14,7 +14,7 @@ module.exports = { }, particle: { spriteFrame:'Sprite Frame', - spriteFrameTip:'Sprite Frame' + spriteFrameTip:'Sprite Frame', }, erpTextureCube: { anisotropy: 'Anisotropy', @@ -256,7 +256,7 @@ module.exports = { }, animationBakeRate: { name: 'Animation Bake Rate', - title: 'Specify the animation bake rate in frames per second (fps).' + title: 'Specify the animation bake rate in frames per second (fps).', }, }, textureCube: { diff --git a/editor/i18n/en/localization.js b/editor/i18n/en/localization.js index 17cc74e6ba..46aecbd18b 100755 --- a/editor/i18n/en/localization.js +++ b/editor/i18n/en/localization.js @@ -125,7 +125,7 @@ module.exports = { sprite: { sprite_frame: 'SpriteFrame image to use', atlas: 'Atlas that the image belongs to', - type: + type: 'Rendering mode:\n - Simple: Modifying the size will stretch the image as a whole, which is suitable for sequence frame animation and normal images. \n' + '- Sliced: When changing the size, the four corners will not stretch, which is suitable for UI buttons and panel backgrounds. \n' + '- Tiled : When changing the size, the original size image will continue to be tiled. \n' + @@ -197,12 +197,12 @@ module.exports = { font_size: 'Font size, in points', font_family: 'Font family name', line_height: 'Line height, in points', - overflow: + overflow: 'Text layout modes: \n 1. CLAMP: Text nodes outside the bounding box will be truncated. \n 2. SHRINK: Automatically shrink text box according to the constraint node. \n 3. RESIZE: Automatically updates the Node based on heightof the text.', wrap: 'Wrap text?', font: 'What font to use', system_font: 'Whether to use the system default font', - cache_mode: + cache_mode: 'Text cache modes:\n 1. NONE: No cache,draw once. \n 2. BITMAP: Text is added as a static image to the dynamic atlas for batch merging, but its content cannot be dynamically modified frequently. \n 3. CHAR: Split the text into characters and cache the character texture into a character atlas for reuse, which is suitable for text content with repeated character content and frequently updated.', font_bold: 'Bold font', font_italic: 'Font italic', @@ -233,7 +233,7 @@ module.exports = { width: 'Fixed line width if constant input, or line width gradually changes according to the value if curve input', tile: 'Number of texture tiles', offset: 'Texture coordinates offset', - color: 'Fixed color if constant input, or color gradually changes according to the value if gradient color input' + color: 'Fixed color if constant input, or color gradually changes according to the value if gradient color input', }, progress: { bar_sprite: 'A progress bar is displayed with the Sprite node that can dynamically change the size', @@ -499,7 +499,7 @@ module.exports = { camera: 'The 3D camera representing the original coordinate system.', use_scale: "Whether to scale the converted 2d node's size according to the distance between the camera and the 3d node.", distance: 'The distance from the camera for displaying the 2d node in normal size', - sync_events: 'Event callback after coordinates synchronization.\nThe first parameter of the callback is the mapped local coordinate in UI camera.\nThe second parameter is the distance scale of the 3d node from the 3d camera viewport.', + sync_events: 'Event callback after coordinates synchronization.\nThe first parameter of the callback is the mapped local coordinate in UI camera.\nThe second parameter is the distance scale of the 3d node from the 3d camera viewport.', }, SubContextView: { design_size: 'Design resolution of the SubContextView, dynamic updates at runtime is not possible', @@ -873,13 +873,13 @@ module.exports = { simplex_vertex0: 'Vertex 0 of the shape', simplex_vertex1: 'Vertex 1 of the shape', simplex_vertex2: 'Vertex 2 of the shape', - simplex_vertex3: 'Vertex 3 of the shape' + simplex_vertex3: 'Vertex 3 of the shape', }, constant_force:{ force: 'The force apply on a rigid body in the world coordinate system', localForce: 'The force apply on a rigid body in the local coordinate system', torque: 'The torque applied to the rigid body in the world coordinate system', localTorque: 'The torque applied to the rigid body in the local coordinate system', - } - } + }, + }, }; diff --git a/editor/i18n/zh/assets.js b/editor/i18n/zh/assets.js index 180c4d520d..d4f31e6878 100644 --- a/editor/i18n/zh/assets.js +++ b/editor/i18n/zh/assets.js @@ -14,7 +14,7 @@ module.exports = { }, particle:{ spriteFrame:'Sprite Frame', - spriteFrameTip:'Sprite Frame' + spriteFrameTip:'Sprite Frame', }, erpTextureCube: { anisotropy: 'Anisotropy', @@ -255,7 +255,7 @@ module.exports = { }, animationBakeRate: { name: '动画烘焙速率', - title: '指定动画烘焙速率,单位为帧每秒(FPS)' + title: '指定动画烘焙速率,单位为帧每秒(FPS)', }, }, textureCube: { diff --git a/editor/i18n/zh/localization.js b/editor/i18n/zh/localization.js index 34ad5a4bd6..7c36299626 100755 --- a/editor/i18n/zh/localization.js +++ b/editor/i18n/zh/localization.js @@ -193,12 +193,12 @@ module.exports = { font_size: '文字尺寸,以 point 为单位', font_family: '文字字体名字', line_height: '文字行高,以 point 为单位', - overflow: + overflow: '文字排版模式,包括以下三种:\n 1. CLAMP: 节点约束框之外的文字会被截断 \n 2. SHRINK: 自动根据节点约束框缩小文字\n 3. RESIZE: 根据文本内容自动更新节点的 height 属性.', wrap: '是否允许自动换行', font: 'Label 使用的字体资源', system_font: '是否使用系统默认字体,选中此项会将 file 属性置空', - cache_mode: + cache_mode: '文本缓存模式,包括以下三种:\n 1. NONE: 不做任何缓存,文本内容进行一次绘制 \n 2. BITMAP: 将文本作为静态图像加入动态图集进行批次合并,但是不能频繁动态修改文本内容 \n 3. CHAR: 将文本拆分为字符并且把字符纹理缓存到一张字符图集中进行复用,适用于字符内容重复并且频繁更新的文本内容', font_bold: '字体加粗', font_italic: '字体倾斜', @@ -229,7 +229,7 @@ module.exports = { width: '线段宽度,如果采用曲线,则表示沿着线段方向上的曲线变化', tile: '贴图平铺次数', offset: '贴图坐标的偏移', - color: '线段颜色,如果采用渐变色,则表示沿着线段方向上的颜色渐变' + color: '线段颜色,如果采用渐变色,则表示沿着线段方向上的颜色渐变', }, progress: { bar_sprite: '进度条显示用的 Sprite 节点,可以动态改变尺寸', @@ -487,7 +487,7 @@ module.exports = { camera: '照射相机', use_scale: '是否是缩放映射', distance: '距相机多少距离为正常显示计算大小', - sync_events: '映射数据事件\n回调的第一个参数是映射后的本地坐标,第二个是距相机距离', + sync_events: '映射数据事件\n回调的第一个参数是映射后的本地坐标,第二个是距相机距离', }, SubContextView: { design_size: '子域的设计分辨率,禁止在运行时动态更新', @@ -854,13 +854,13 @@ module.exports = { simplex_vertex0: '形状的顶点0', simplex_vertex1: '形状的顶点1', simplex_vertex2: '形状的顶点2', - simplex_vertex3: '形状的顶点3' + simplex_vertex3: '形状的顶点3', }, constant_force:{ force: '在世界坐标系中,对刚体施加的力', localForce: '在本地坐标系中,对刚体施加的力', torque: '在世界坐标系中,对刚体施加的扭转力', localTorque: '在本地坐标系中,对刚体施加的扭转力', - } - } + }, + }, }; diff --git a/editor/inspector/assets/audio-clip.js b/editor/inspector/assets/audio-clip.js index 9fac8783c4..ee69af99c1 100644 --- a/editor/inspector/assets/audio-clip.js +++ b/editor/inspector/assets/audio-clip.js @@ -13,7 +13,7 @@ exports.style = ` exports.$ = { constainer: '.asset-audio-clip', }; -exports.update = function (assetList, metaList) { +exports.update = function(assetList, metaList) { // Support multi-select list display, limit the number of display let html = ''; const maxShowNumber = 1000; diff --git a/editor/inspector/assets/effect-header.js b/editor/inspector/assets/effect-header.js index df4f8fae27..ad9219e85d 100644 --- a/editor/inspector/assets/effect-header.js +++ b/editor/inspector/assets/effect-header.js @@ -27,11 +27,11 @@ exports.$ = { code: 'ui-code', }; -exports.ready = function () { +exports.ready = function() { this.code = this.$.code; }; -exports.update = function (assetList, metaList) { +exports.update = function(assetList, metaList) { this.assetList = assetList; this.metaList = metaList; this.meta = metaList[0]; @@ -89,4 +89,4 @@ exports.update = function (assetList, metaList) { this.code.textContent = text; } }); -}; \ No newline at end of file +}; diff --git a/editor/inspector/assets/effect.js b/editor/inspector/assets/effect.js index 65f7885dc9..2a816699b8 100644 --- a/editor/inspector/assets/effect.js +++ b/editor/inspector/assets/effect.js @@ -9,7 +9,7 @@ exports.template = ` - +
@@ -196,6 +196,7 @@ const Elements = { panel.$.codes.appendChild(section); section.setAttribute('class', 'config'); section.setAttribute('expand', ''); + section.setAttribute('cache-expand', `effect-${glslKey}`); const glslName = panel.glslNames[glslKey]; @@ -248,7 +249,7 @@ const Elements = { /** * A method to initialize the panel */ -exports.ready = function () { +exports.ready = function() { for (const prop in Elements) { const element = Elements[prop]; if (element.ready) { @@ -262,7 +263,7 @@ exports.ready = function () { * @param assetList * @param metaList */ -exports.update = function (assetList, metaList) { +exports.update = function(assetList, metaList) { this.assetList = assetList; this.metaList = metaList; this.asset = assetList[0]; diff --git a/editor/inspector/assets/erp-texture-cube.js b/editor/inspector/assets/erp-texture-cube.js index 3b733030d9..b3a134f376 100644 --- a/editor/inspector/assets/erp-texture-cube.js +++ b/editor/inspector/assets/erp-texture-cube.js @@ -116,7 +116,7 @@ exports.$ = { wrapModeT: '#wrapModeT', }; -exports.ready = function () { +exports.ready = function() { for (const key in Elements) { if (typeof Elements[key].ready === 'function') { Elements[key].ready.call(this); @@ -124,7 +124,7 @@ exports.ready = function () { } }; -exports.update = function (assetList, metaList) { +exports.update = function(assetList, metaList) { this.assetList = assetList; this.metaList = metaList; this.asset = assetList[0]; @@ -139,71 +139,71 @@ exports.update = function (assetList, metaList) { const Elements = { anisotropy: { - ready () { + ready() { this.$.anisotropy.addEventListener('change', this.dataChange.bind(this, 'anisotropy')); }, - update () { + update() { this.$.anisotropy.value = this.meta.userData.anisotropy; this.updateInvalid(this.$.anisotropy, 'anisotropy'); this.updateReadonly(this.$.anisotropy); }, }, faceSize: { - ready () { + ready() { this.$.faceSize.addEventListener('change', this.dataChange.bind(this, 'faceSize')); }, update() { - + this.$.faceSize.value = this.meta.userData.faceSize; this.updateInvalid(this.$.faceSize, 'faceSize'); this.updateReadonly(this.$.faceSize); }, }, minfilter: { - ready () { + ready() { this.$.minfilter.addEventListener('change', this.dataChange.bind(this, 'minfilter')); }, - update () { + update() { this.$.minfilter.value = this.meta.userData.minfilter; this.updateInvalid(this.$.minfilter, 'minfilter'); this.updateReadonly(this.$.minfilter); }, }, magfilter: { - ready () { + ready() { this.$.magfilter.addEventListener('change', this.dataChange.bind(this, 'magfilter')); }, - update () { + update() { this.$.magfilter.value = this.meta.userData.magfilter; this.updateInvalid(this.$.magfilter, 'magfilter'); this.updateReadonly(this.$.magfilter); }, }, mipfilter: { - ready () { + ready() { this.$.mipfilter.addEventListener('change', this.dataChange.bind(this, 'mipfilter')); }, - update () { + update() { this.$.mipfilter.value = this.meta.userData.mipfilter; this.updateInvalid(this.$.mipfilter, 'mipfilter'); this.updateReadonly(this.$.mipfilter); }, }, wrapModeS: { - ready () { + ready() { this.$.wrapModeS.addEventListener('change', this.dataChange.bind(this, 'wrapModeS')); }, - update () { + update() { this.$.wrapModeS.value = this.meta.userData.wrapModeS; this.updateInvalid(this.$.wrapModeS, 'wrapModeS'); this.updateReadonly(this.$.wrapModeS); }, }, wrapModeT: { - ready () { + ready() { this.$.wrapModeT.addEventListener('change', this.dataChange.bind(this, 'wrapModeT')); }, - update () { + update() { this.$.wrapModeT.value = this.meta.userData.wrapModeT; this.updateInvalid(this.$.wrapModeT, 'wrapModeT'); this.updateReadonly(this.$.wrapModeT); @@ -226,7 +226,7 @@ exports.methods = { element.removeAttribute('disabled'); } }, - dataChange (key, event) { + dataChange(key, event) { this.metaList.forEach((meta) => { meta.userData[key] = event.target.value || undefined; }); diff --git a/editor/inspector/assets/fbx/animation.js b/editor/inspector/assets/fbx/animation.js index 47bec13779..7148970537 100644 --- a/editor/inspector/assets/fbx/animation.js +++ b/editor/inspector/assets/fbx/animation.js @@ -303,14 +303,14 @@ exports.$ = { const Elements = { // infos put first infos: { - ready () { + ready() { const panel = this; Object.assign(panel, { animationInfos: null, }); }, - update () { + update() { const panel = this; if (panel.meta && panel.meta.userData.animationImportSettings) { @@ -329,7 +329,7 @@ const Elements = { }, }, showType: { - ready () { + ready() { const panel = this; panel.animationTimeShowType = panel.$.showType.value === 0 ? 'time' : 'frame'; panel.$.showType.addEventListener('change', (event) => { @@ -337,7 +337,7 @@ const Elements = { Elements.clips.update.call(panel); }); }, - update () { + update() { const panel = this; if (!panel.animationInfos) { @@ -351,7 +351,7 @@ const Elements = { }, }, clips: { - ready () { + ready() { const panel = this; Object.assign(panel, { @@ -360,7 +360,7 @@ const Elements = { currentClipInfo: null, }); }, - update () { + update() { const panel = this; panel.$.clips.innerText = ''; @@ -423,11 +423,11 @@ const Elements = { line.appendChild(name); const time = document.createElement('div'); time.setAttribute('class', 'time'); - time.innerHTML = panel.animationTimeShowType === 'time' ? subAnim.from.toFixed(2) : Math.round(subAnim.from * panel.rawClipInfo.fps); + time.innerHTML = panel.animationTimeShowType === 'time' ? subAnim.from.toFixed(2) : Math.round(subAnim.from * panel.rawClipInfo.fps); line.appendChild(time); const timeEnd = document.createElement('div'); timeEnd.setAttribute('class', 'time end'); - timeEnd.innerHTML = panel.animationTimeShowType === 'time' ? subAnim.to.toFixed(2) : Math.round(subAnim.to * panel.rawClipInfo.fps); + timeEnd.innerHTML = panel.animationTimeShowType === 'time' ? subAnim.to.toFixed(2) : Math.round(subAnim.to * panel.rawClipInfo.fps); line.appendChild(timeEnd); }); @@ -473,7 +473,7 @@ const Elements = { }, }, editor: { - ready () { + ready() { const panel = this; Object.assign(panel, { @@ -500,7 +500,7 @@ const Elements = { panel.onWrapModeChangeBind = panel.onWrapModeChange.bind(panel); panel.$.wrapMode.addEventListener('confirm', panel.onWrapModeChangeBind); - function observer () { + function observer() { const rect = panel.$.editor.getBoundingClientRect(); panel.gridTableWith = rect.width - 60; @@ -516,7 +516,7 @@ const Elements = { panel.resizeObserver.observe(panel.$.editor); observer(); }, - close () { + close() { const panel = this; panel.resizeObserver.unobserve(panel.$.editor); @@ -532,7 +532,7 @@ const Elements = { panel.$.wrapMode.removeEventListener('confirm', panel.onWrapModeChangeBind); }, - update () { + update() { const panel = this; panel.updateRawClipInfo(); @@ -604,7 +604,7 @@ const Elements = { }, }; -exports.update = function (assetList, metaList) { +exports.update = function(assetList, metaList) { this.assetList = assetList; this.metaList = metaList; this.asset = assetList[0]; @@ -623,7 +623,7 @@ exports.update = function (assetList, metaList) { } }; -exports.ready = function () { +exports.ready = function() { for (const prop in Elements) { const element = Elements[prop]; if (element.ready) { @@ -632,7 +632,7 @@ exports.ready = function () { } }; -exports.close = function () { +exports.close = function() { for (const prop in Elements) { const element = Elements[prop]; if (element.close) { @@ -643,7 +643,7 @@ exports.close = function () { exports.methods = { /** animation name -> uuid */ - initAnimationNameToUUIDMap () { + initAnimationNameToUUIDMap() { if (this.meta && this.meta.subMetas) { const animationNameToUUIDMap = new Map(); Object.keys(this.meta.subMetas).forEach((id) => { @@ -658,7 +658,7 @@ exports.methods = { this.animationNameToUUIDMap = animationNameToUUIDMap; } }, - initAnimationInfos () { + initAnimationInfos() { if (this.meta && this.meta.userData.animationImportSettings) { this.animationInfos = this.meta.userData.animationImportSettings; // Collect clip names for renaming and creating to determine whether the name is repeated @@ -674,7 +674,7 @@ exports.methods = { } }, - onSelect (rawClipIndex, splitClipIndex) { + onSelect(rawClipIndex, splitClipIndex) { this.rawClipIndex = rawClipIndex; this.splitClipIndex = splitClipIndex; const isElementSelect = (element) => element.getAttribute('rawClipIndex') == rawClipIndex && element.getAttribute('splitClipIndex') == splitClipIndex; @@ -690,7 +690,7 @@ exports.methods = { const curClipInfo = this.getCurClipInfo(); Editor.Message.broadcast('fbx-inspector:animation-change', curClipInfo); }, - getCurClipInfo () { + getCurClipInfo() { const animInfo = this.animationInfos[this.rawClipIndex]; const splitInfo = animInfo.splits[this.splitClipIndex]; @@ -724,7 +724,7 @@ exports.methods = { to, }; }, - getRightName (name) { + getRightName(name) { if (!name) { return null; } @@ -739,7 +739,7 @@ exports.methods = { } while (panel.clipNames.has(name)); return name; }, - newClipTemplate () { + newClipTemplate() { const panel = this; // Verify the name return { @@ -749,7 +749,7 @@ exports.methods = { wrapMode: 2 /* Loop */, }; }, - updateCurrentClipInfo () { + updateCurrentClipInfo() { const panel = this; if (!panel.animationInfos) { panel.currentClipInfo = null; @@ -806,7 +806,7 @@ exports.methods = { panel.$.wrapMode.value = panel.currentClipInfo.wrapMode; }, - updateRawClipInfo () { + updateRawClipInfo() { const panel = this; if (!panel.animationInfos) { panel.rawClipInfo = null; @@ -822,7 +822,7 @@ exports.methods = { panel.$.clipDuration.innerText = duration.toFixed(2); }, - updateGridConfig () { + updateGridConfig() { const panel = this; if (!panel.currentClipInfo) { @@ -847,7 +847,7 @@ exports.methods = { labelStep, }; }, - getStepAndSpacing (width, frames) { + getStepAndSpacing(width, frames) { const config = { minSpacing: 10, maxSpacing: 20, @@ -867,7 +867,7 @@ exports.methods = { spacing, }; }, - onMouseDown (type) { + onMouseDown(type) { const panel = this; const info = panel.currentClipInfo; @@ -896,7 +896,7 @@ exports.methods = { document.addEventListener('mousemove', panel.onMouseMoveBind); document.addEventListener('mouseup', panel.onMouseUpBind); }, - onMouseMove (event) { + onMouseMove(event) { const panel = this; event.preventDefault(); @@ -936,7 +936,7 @@ exports.methods = { panel.updateVirtualControl(); }); }, - onMouseUp () { + onMouseUp() { const panel = this; if (!panel.virtualControl) { @@ -966,7 +966,7 @@ exports.methods = { Editor.Message.broadcast('fbx-inspector:animation-change', curClipInfo); panel.dispatch('change'); }, - updateVirtualControl () { + updateVirtualControl() { const panel = this; Object.assign(panel.$.controlVirtual.style, panel.virtualControl.style); @@ -980,7 +980,7 @@ exports.methods = { } } }, - onClipName (event) { + onClipName(event) { const panel = this; if (!panel.currentClipInfo) { @@ -1005,7 +1005,7 @@ exports.methods = { panel.dispatch('change'); Elements.clips.update.call(panel); }, - onCutClip (event) { + onCutClip(event) { const panel = this; const path = event.target.getAttribute('path'); @@ -1016,7 +1016,7 @@ exports.methods = { panel.dispatch('change'); }, - onFpsChange (event) { + onFpsChange(event) { const panel = this; panel.animationInfos[panel.rawClipIndex].splits[panel.splitClipIndex].fps = Number(event.target.value); @@ -1024,7 +1024,7 @@ exports.methods = { Elements.editor.update.call(panel); panel.dispatch('change'); }, - onWrapModeChange (event) { + onWrapModeChange(event) { const panel = this; panel.animationInfos[panel.rawClipIndex].splits[panel.splitClipIndex].wrapMode = Number(event.target.value); diff --git a/editor/inspector/assets/fbx/fbx.js b/editor/inspector/assets/fbx/fbx.js index acba5434b1..90596e234d 100644 --- a/editor/inspector/assets/fbx/fbx.js +++ b/editor/inspector/assets/fbx/fbx.js @@ -76,7 +76,7 @@ const Elements = { }, }; -exports.update = function (assetList, metaList) { +exports.update = function(assetList, metaList) { this.assetList = assetList; this.metaList = metaList; this.asset = assetList[0]; @@ -90,7 +90,7 @@ exports.update = function (assetList, metaList) { } }; -exports.ready = function () { +exports.ready = function() { for (const prop in Elements) { const element = Elements[prop]; if (element.ready) { @@ -99,7 +99,7 @@ exports.ready = function () { } }; -exports.close = function () { +exports.close = function() { for (const prop in Elements) { const element = Elements[prop]; if (element.close) { @@ -119,7 +119,7 @@ exports.methods = { /** * Update whether a data is editable in multi-select state */ - updateInvalid(element, prop) { + updateInvalid(element, prop) { const invalid = this.metaList.some((meta) => { return meta.userData[prop] !== this.meta.userData[prop]; }); diff --git a/editor/inspector/assets/fbx/index.js b/editor/inspector/assets/fbx/index.js index 70648dff98..e2e202a2f3 100644 --- a/editor/inspector/assets/fbx/index.js +++ b/editor/inspector/assets/fbx/index.js @@ -46,7 +46,7 @@ const Components = { */ const Elements = { tabs: { - ready () { + ready() { const panel = this; panel.$.tabs.addEventListener('change', () => { @@ -56,7 +56,7 @@ const Elements = { panel.activeTab = 'animation'; }, - update () { + update() { const panel = this; panel.$.tabs.innerText = ''; @@ -82,14 +82,14 @@ const Elements = { }, }, tabPanel: { - ready () { + ready() { const panel = this; panel.$.tabPanel.addEventListener('change', () => { panel.dispatch('change'); }); }, - update () { + update() { const panel = this; Editor.Message.broadcast('fbx-inspector:change-tab', panel.activeTab); panel.$.tabPanel.setAttribute('src', Components[panel.activeTab]); @@ -103,7 +103,7 @@ const Elements = { * @param assetList * @param metaList */ -exports.update = function (assetList, metaList) { +exports.update = function(assetList, metaList) { this.assetList = assetList; this.metaList = metaList; this.asset = assetList[0]; @@ -120,7 +120,7 @@ exports.update = function (assetList, metaList) { /** * Method of initializing the panel */ -exports.ready = function () { +exports.ready = function() { for (const prop in Elements) { const element = Elements[prop]; if (element.ready) { @@ -133,14 +133,14 @@ exports.methods = { /** * Update whether a data is editable in multi-select state */ - updateInvalid (element, prop) { + updateInvalid(element, prop) { const invalid = this.metaList.some((meta) => meta.userData[prop] !== this.meta.userData[prop]); element.invalid = invalid; }, /** * Update read-only status */ - updateReadonly (element) { + updateReadonly(element) { if (this.asset.readonly) { element.setAttribute('disabled', true); } else { diff --git a/editor/inspector/assets/fbx/material.js b/editor/inspector/assets/fbx/material.js index 69f82f1e89..c10e4e0cf8 100644 --- a/editor/inspector/assets/fbx/material.js +++ b/editor/inspector/assets/fbx/material.js @@ -316,7 +316,7 @@ const Elements = { }, }; -exports.update = function (assetList, metaList) { +exports.update = function(assetList, metaList) { this.assetList = assetList; this.metaList = metaList; this.asset = assetList[0]; @@ -330,7 +330,7 @@ exports.update = function (assetList, metaList) { } }; -exports.ready = function () { +exports.ready = function() { for (const prop in Elements) { const element = Elements[prop]; if (element.ready) { @@ -339,7 +339,7 @@ exports.ready = function () { } }; -exports.close = function () { +exports.close = function() { for (const prop in Elements) { const element = Elements[prop]; if (element.close) { diff --git a/editor/inspector/assets/fbx/model.js b/editor/inspector/assets/fbx/model.js index 09d0bfaf7a..0777d4026e 100644 --- a/editor/inspector/assets/fbx/model.js +++ b/editor/inspector/assets/fbx/model.js @@ -18,13 +18,13 @@ exports.template = ` - +
- + @@ -35,7 +35,7 @@ exports.template = ` - + @@ -46,7 +46,7 @@ exports.template = ` - + @@ -288,7 +288,7 @@ const Elements = { }, }; -exports.update = function (assetList, metaList) { +exports.update = function(assetList, metaList) { this.assetList = assetList; this.metaList = metaList; this.asset = assetList[0]; @@ -302,7 +302,7 @@ exports.update = function (assetList, metaList) { } }; -exports.ready = function () { +exports.ready = function() { for (const prop in Elements) { const element = Elements[prop]; if (element.ready) { @@ -311,7 +311,7 @@ exports.ready = function () { } }; -exports.close = function () { +exports.close = function() { for (const prop in Elements) { const element = Elements[prop]; if (element.close) { diff --git a/editor/inspector/assets/fbx/preview.js b/editor/inspector/assets/fbx/preview.js index 29d42f8ecc..5d12d43d5f 100644 --- a/editor/inspector/assets/fbx/preview.js +++ b/editor/inspector/assets/fbx/preview.js @@ -86,29 +86,29 @@ exports.$ = { const Elements = { playButton: { - ready () { + ready() { this.$.playButton.addEventListener('confirm', this.onPlayButtonClick.bind(this)); }, }, stopButton: { - ready () { + ready() { this.$.stopButton.addEventListener('confirm', this.onStopButtonClick.bind(this)); }, }, animationTimeSlider: { - ready () { + ready() { const slider = this.$.animationTimeSlider; slider.addEventListener('change', this.onAnimationTimeSliderChange.bind(this)); }, }, preview: { - ready () { + ready() { const panel = this; panel.$.canvas.addEventListener('mousedown', async (event) => { await Editor.Message.request('scene', 'on-model-preview-mouse-down', { x: event.x, y: event.y }); - async function mousemove (event) { + async function mousemove(event) { await Editor.Message.request('scene', 'on-model-preview-mouse-move', { movementX: event.movementX, movementY: event.movementY, @@ -117,7 +117,7 @@ const Elements = { panel.isPreviewDataDirty = true; } - async function mouseup (event) { + async function mouseup(event) { await Editor.Message.request('scene', 'on-model-preview-mouse-up', { x: event.x, y: event.y, @@ -139,7 +139,7 @@ const Elements = { panel.glPreview = new GlPreview('scene:model-preview', 'query-model-preview-data'); panel.isPreviewDataDirty = true; }, - async update () { + async update() { const panel = this; if (!panel.$.canvas) { @@ -156,10 +156,10 @@ const Elements = { }, }, modelInfo: { - ready () { + ready() { this.infoUpdate = Elements.modelInfo.update.bind(this); }, - update (info) { + update(info) { if (!info) { return; } @@ -167,13 +167,13 @@ const Elements = { this.$.triangles.value = `Triangles:${info.polygons}`; this.isPreviewDataDirty = true; }, - close () { + close() { Editor.Message.send('scene', 'hide-model-preview'); }, }, }; -exports.update = async function (assetList, metaList) { +exports.update = async function(assetList, metaList) { this.assetList = assetList; this.metaList = metaList; this.asset = assetList[0]; @@ -198,7 +198,7 @@ exports.update = async function (assetList, metaList) { this.refreshPreview(); }; -exports.ready = function () { +exports.ready = function() { const panel = this; this.gridWidth = 0; @@ -238,7 +238,7 @@ exports.ready = function () { panel.resizeObserver.observe(panel.$.container); }; -exports.close = function () { +exports.close = function() { for (const prop in Elements) { const element = Elements[prop]; if (element.close) { @@ -255,7 +255,7 @@ exports.close = function () { }; exports.methods = { - async refreshPreview () { + async refreshPreview() { const panel = this; // After await, the panel no longer exists @@ -296,7 +296,7 @@ exports.methods = { panel.refreshPreview(); }); }, - async onTabChanged (activeTab) { + async onTabChanged(activeTab) { if (typeof activeTab === 'string') { this.activeTab = activeTab; this.$.animationInfo.style.display = this.activeTab === 'animation' ? 'flex' : 'none'; @@ -304,7 +304,7 @@ exports.methods = { await this.stopAnimation(); } }, - async onStopButtonClick (event) { + async onStopButtonClick(event) { event.stopPropagation(); if (!this.curEditClipInfo) { return; @@ -312,35 +312,35 @@ exports.methods = { await this.stopAnimation(); }, - async stopAnimation () { + async stopAnimation() { if (!this.curEditClipInfo) { return; } await Editor.Message.request('scene', 'execute-model-preview-animation-operation', 'stop'); }, - async onPlayButtonClick (event) { + async onPlayButtonClick(event) { event.stopPropagation(); if (!this.curEditClipInfo) { return; } switch (this.curPlayState) { - case PLAY_STATE.PAUSE: - await Editor.Message.request('scene', 'execute-model-preview-animation-operation', 'resume'); - break; - case PLAY_STATE.PLAYING: - await Editor.Message.request('scene', 'execute-model-preview-animation-operation', 'pause'); - break; - case PLAY_STATE.STOP: - await Editor.Message.request('scene', 'execute-model-preview-animation-operation', 'play', this.curEditClipInfo.clipUUID); - break; - default: - break; + case PLAY_STATE.PAUSE: + await Editor.Message.request('scene', 'execute-model-preview-animation-operation', 'resume'); + break; + case PLAY_STATE.PLAYING: + await Editor.Message.request('scene', 'execute-model-preview-animation-operation', 'pause'); + break; + case PLAY_STATE.STOP: + await Editor.Message.request('scene', 'execute-model-preview-animation-operation', 'play', this.curEditClipInfo.clipUUID); + break; + default: + break; } this.isPreviewDataDirty = true; }, - async onAnimationTimeSliderChange (event) { + async onAnimationTimeSliderChange(event) { event.stopPropagation(); if (!this.curEditClipInfo) { return; @@ -352,7 +352,7 @@ exports.methods = { this.isPreviewDataDirty = true; }, - onModelAnimationUpdate (time) { + onModelAnimationUpdate(time) { if (!this.curEditClipInfo) { return; } @@ -366,28 +366,28 @@ exports.methods = { this.isPreviewDataDirty = true; }, - setCurPlayState (state) { + setCurPlayState(state) { this.curPlayState = state; let buttonIconName = ''; switch (state) { - case PLAY_STATE.STOP: - buttonIconName = 'play'; - break; - case PLAY_STATE.PLAYING: - buttonIconName = 'pause'; - break; - case PLAY_STATE.PAUSE: - buttonIconName = 'play'; - break; - default: - break; + case PLAY_STATE.STOP: + buttonIconName = 'play'; + break; + case PLAY_STATE.PLAYING: + buttonIconName = 'pause'; + break; + case PLAY_STATE.PAUSE: + buttonIconName = 'play'; + break; + default: + break; } if (this.$.playButtonIcon) { this.$.playButtonIcon.value = buttonIconName; } }, - async setCurEditClipInfo (clipInfo) { + async setCurEditClipInfo(clipInfo) { this.curEditClipInfo = clipInfo; if (clipInfo) { this.curTotalFrames = Math.round(clipInfo.duration * clipInfo.fps); @@ -404,7 +404,7 @@ exports.methods = { await this.stopAnimation(); } }, - onAnimationPlayStateChanged (state) { + onAnimationPlayStateChanged(state) { this.setCurPlayState(state); }, }; diff --git a/editor/inspector/assets/image-preview.js b/editor/inspector/assets/image-preview.js index a94f3755b4..5547d1930b 100644 --- a/editor/inspector/assets/image-preview.js +++ b/editor/inspector/assets/image-preview.js @@ -73,7 +73,7 @@ const Elements = { * @param assetList * @param metaList */ -exports.update = function (assetList, metaList) { +exports.update = function(assetList, metaList) { this.assetList = assetList; this.metaList = metaList; this.asset = assetList[0]; @@ -90,7 +90,7 @@ exports.update = function (assetList, metaList) { /** * Method of initializing the panel */ -exports.ready = function () { +exports.ready = function() { for (const prop in Elements) { const element = Elements[prop]; if (element.ready) { @@ -99,7 +99,7 @@ exports.ready = function () { } }; -exports.close = function () { +exports.close = function() { for (const prop in Elements) { const element = Elements[prop]; if (element.close) { diff --git a/editor/inspector/assets/image.js b/editor/inspector/assets/image.js index b79d9c457f..c7693d4573 100644 --- a/editor/inspector/assets/image.js +++ b/editor/inspector/assets/image.js @@ -18,7 +18,7 @@ exports.template = ` - + @@ -136,7 +136,7 @@ const Elements = { * @param assetList * @param metaList */ -exports.update = function (assetList, metaList) { +exports.update = function(assetList, metaList) { this.assetList = assetList; this.metaList = metaList; this.asset = assetList[0]; @@ -155,7 +155,7 @@ exports.update = function (assetList, metaList) { /** * Method of initializing the panel */ -exports.ready = function () { +exports.ready = function() { for (const prop in Elements) { const element = Elements[prop]; if (element.ready) { diff --git a/editor/inspector/assets/javascript.js b/editor/inspector/assets/javascript.js index d7506f1ba7..bbc481de16 100644 --- a/editor/inspector/assets/javascript.js +++ b/editor/inspector/assets/javascript.js @@ -348,7 +348,7 @@ const Elements = { }, }; -exports.update = function (assetList, metaList) { +exports.update = function(assetList, metaList) { this.assetList = assetList; this.metaList = metaList; this.asset = assetList[0]; @@ -362,7 +362,7 @@ exports.update = function (assetList, metaList) { } }; -exports.ready = function () { +exports.ready = function() { for (const key in Elements) { const element = Elements[key]; if (element.ready) { diff --git a/editor/inspector/assets/json.js b/editor/inspector/assets/json.js index 61aa0f2711..f34cfad37a 100644 --- a/editor/inspector/assets/json.js +++ b/editor/inspector/assets/json.js @@ -27,11 +27,11 @@ exports.$ = { code: 'ui-code', }; -exports.ready = function () { +exports.ready = function() { this.code = this.$.code; }; -exports.update = function (assetList, metaList) { +exports.update = function(assetList, metaList) { this.assetList = assetList; this.metaList = metaList; this.meta = metaList[0]; diff --git a/editor/inspector/assets/label-atlas.js b/editor/inspector/assets/label-atlas.js index 02f7bde4f3..2c35a88b2b 100644 --- a/editor/inspector/assets/label-atlas.js +++ b/editor/inspector/assets/label-atlas.js @@ -127,7 +127,7 @@ exports.methods = { }, }; -exports.ready = function () { +exports.ready = function() { for (const key in Elements) { if (Elements[key].ready) { Elements[key].ready.call(this); @@ -135,7 +135,7 @@ exports.ready = function () { } }; -exports.update = function (assetList, metaList) { +exports.update = function(assetList, metaList) { this.metaList = metaList; this.assetList = assetList; this.meta = metaList[0]; diff --git a/editor/inspector/assets/material-header.js b/editor/inspector/assets/material-header.js index 88a8b50d56..898013d7a0 100644 --- a/editor/inspector/assets/material-header.js +++ b/editor/inspector/assets/material-header.js @@ -1,7 +1,12 @@ 'use strict'; exports.style = ` -:host > .section { height: 200px; display: flex; } +:host > .section { + height: 200px; + display: flex; + background: var(--color-normal-fill); + border-bottom: 1px solid var(--color-normal-border); + } :host > .section > canvas { flex: 1; min-width: 0; } :host > .section > .tools { display: flex; flex-direction: column; padding: 6px 4px; } `; @@ -32,8 +37,8 @@ exports.$ = { }; exports.methods = { - hideAllContent (hide) { - this.$.container.style= hide ? 'display:none' : ''; + hideAllContent(hide) { + this.$.container.style = hide ? 'display:none' : ''; }, async refreshPreview() { const panel = this; @@ -78,7 +83,7 @@ exports.methods = { const panel = this; panel.isPreviewDataDirty = true; - } + }, }; /** @@ -86,7 +91,7 @@ exports.methods = { * @param assetList * @param metaList */ -exports.update = async function (assetList, metaList) { +exports.update = async function(assetList, metaList) { const panel = this; panel.assetList = assetList; @@ -112,7 +117,7 @@ exports.update = async function (assetList, metaList) { /** * Method of initializing the panel */ -exports.ready = async function () { +exports.ready = async function() { const panel = this; Editor.Message.request('scene', 'set-material-preview-light-enable', true); @@ -171,7 +176,7 @@ exports.ready = async function () { Editor.Message.addBroadcastListener('material-inspector:change-dump', this.updatePreviewDataDirtyBind); }; -exports.close = function () { +exports.close = function() { const panel = this; panel.resizeObserver.unobserve(panel.$.container); diff --git a/editor/inspector/assets/material.js b/editor/inspector/assets/material.js index cb24671de7..65c6f93670 100644 --- a/editor/inspector/assets/material.js +++ b/editor/inspector/assets/material.js @@ -127,17 +127,17 @@ exports.methods = { $container.$children = {}; } - let i = 0; - for (i; i < technique.passes.length; i++) { + for (let i = 0; i < technique.passes.length; i++) { + const pass = technique.passes[i]; // If the propertyIndex is not equal to the current pass index, then do not render - if (technique.passes[i].propertyIndex !== undefined && technique.passes[i].propertyIndex.value !== i) { + if (pass.propertyIndex !== undefined && pass.propertyIndex.value !== i) { continue; } // if asset is readonly if (this.asset.readonly) { - for (const key in technique.passes[i].value) { - loopSetAssetDumpDataReadonly(technique.passes[i].value[key]); + for (const key in pass.value) { + loopSetAssetDumpDataReadonly(pass.value[key]); } } @@ -145,7 +145,24 @@ exports.methods = { $container.$children[i].setAttribute('type', 'dump'); $container.$children[i].setAttribute('fold', 'false'); $container.appendChild($container.$children[i]); - $container.$children[i].render(technique.passes[i]); + $container.$children[i].render(pass); + + // Add the checkbox given by the switch attribute + if (pass.switch && pass.switch.name) { + const $checkbox = document.createElement('ui-checkbox'); + $checkbox.innerText = pass.switch.name; + $checkbox.setAttribute('slot', 'header'); + $checkbox.addEventListener('change', (e) => { + pass.switch.value = e.target.value; + }); + setReadonly(this.asset.readonly, $checkbox); + + const $section = $container.$children[i].querySelector('ui-section'); + $section.appendChild($checkbox); + + const $label = $section.querySelector('ui-label'); + $label.style.width = 'calc(var(--left-width) - 10px)'; + } $container.$children[i].querySelectorAll('ui-prop').forEach(($prop) => { const dump = $prop.dump; @@ -162,6 +179,10 @@ exports.methods = { continue; } + if (this.asset.readonly) { + loopSetAssetDumpDataReadonly(dump.childMap[childName]); + } + $prop.$children[childName] = document.createElement('ui-prop'); $prop.$children[childName].setAttribute('type', 'dump'); $prop.$children[childName].render(dump.childMap[childName]); @@ -211,7 +232,8 @@ exports.methods = { updateTechniqueOptions() { let techniqueOption = ''; this.material.data.forEach((technique, index) => { - techniqueOption += ``; + const name = technique.name ? `${index} - ${technique.name}` : index; + techniqueOption += ``; }); this.$.technique.innerHTML = techniqueOption; }, @@ -227,7 +249,7 @@ exports.methods = { * @param assetList * @param metaList */ -exports.update = async function (assetList, metaList) { +exports.update = async function(assetList, metaList) { this.assetList = assetList; this.metaList = metaList; this.asset = assetList[0]; @@ -243,6 +265,7 @@ exports.update = async function (assetList, metaList) { } this.material = await Editor.Message.request('scene', 'query-material', this.asset.uuid); + await Editor.Message.request('scene', 'preview-material', this.asset.uuid); // effect