mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
@@ -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
|
||||
Vendored
+20
-1
@@ -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,
|
||||
|
||||
Vendored
+5
@@ -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;
|
||||
|
||||
Vendored
+6
-2
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ if (DEV) {
|
||||
legacyCC._Test = {};
|
||||
}
|
||||
|
||||
const engineVersion = '3.1';
|
||||
const engineVersion = '3.1.1';
|
||||
/**
|
||||
* The current version of Cocos2d being used.<br/>
|
||||
* Please DO NOT remove this String, it is an important flag for bug tracking.<br/>
|
||||
|
||||
@@ -239,5 +239,7 @@ export class ShadowFlow extends RenderFlow {
|
||||
depth,
|
||||
));
|
||||
}
|
||||
|
||||
shadowInfo.shadowMapDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<string, any> = {
|
||||
|
||||
/**
|
||||
* @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 () {
|
||||
|
||||
+12
-2
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.<br/>
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 }],
|
||||
},
|
||||
};
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"ver": "1.0.0",
|
||||
"importer": "*",
|
||||
"imported": true,
|
||||
"uuid": "c9bbaedb-125a-4942-a8eb-6952f9f2a00f",
|
||||
"files": [
|
||||
"",
|
||||
".json"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"syncNodeName": "Node"
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@
|
||||
"y": 1,
|
||||
"z": 1
|
||||
},
|
||||
"_layer": 1073741824,
|
||||
"_layer": 33554432,
|
||||
"_euler": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
|
||||
@@ -44,7 +44,7 @@ export interface ModuleRenderConfig {
|
||||
categories: {[category: string]: CategoryInfo};
|
||||
}
|
||||
|
||||
export type Features = Record<EngineFeature, Item>;
|
||||
export type Features = Record<EngineFeature, Item>;
|
||||
|
||||
export interface BaseItem {
|
||||
/**
|
||||
|
||||
+183
-183
@@ -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,
|
||||
};
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
* Populate module `'internal-constants'` to editor
|
||||
* so it be can connected to the `'build-time-constants'`.
|
||||
*/
|
||||
export * from 'internal:constants';
|
||||
export * from 'internal:constants';
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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',
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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: '在本地坐标系中,对刚体施加的扭转力',
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ exports.template = `
|
||||
<ui-select slot="content" class="shader-select"></ui-select>
|
||||
</ui-prop>
|
||||
|
||||
<ui-section expand class="config">
|
||||
<ui-section expand class="config" cache-expand="effect-combinations">
|
||||
<ui-label slot="header" value="i18n:ENGINE.assets.effect.combinations" tooltip="i18n:ENGINE.assets.effect.combinationsTip"></ui-label>
|
||||
<div class="description">
|
||||
<ui-label value="i18n:ENGINE.assets.effect.choose"></ui-label>
|
||||
@@ -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];
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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];
|
||||
});
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -18,13 +18,13 @@ exports.template = `
|
||||
<ui-label slot="label" value="i18n:ENGINE.assets.fbx.disableMeshSplit.name" tooltip="i18n:ENGINE.assets.fbx.disableMeshSplit.title"></ui-label>
|
||||
<ui-checkbox slot="content" class="disableMeshSplit-checkbox"></ui-checkbox>
|
||||
</ui-prop>
|
||||
<ui-section class="ins-object config" expand>
|
||||
<ui-section class="ins-object config" expand cache-expand="fbx-model-mesh-optimizer">
|
||||
<div slot="header" class="header">
|
||||
<ui-checkbox slot="content" class="meshOptimizer-checkbox"></ui-checkbox>
|
||||
<ui-label value="i18n:ENGINE.assets.fbx.meshOptimizer.name" tooltip="i18n:ENGINE.assets.fbx.meshOptimizer.title"></ui-label>
|
||||
</div>
|
||||
<div class="object mesh-optimizer">
|
||||
<ui-section expand>
|
||||
<ui-section expand cache-expand="fbx-model-mesh-optimizer-simplification">
|
||||
<ui-label slot="header" value="i18n:ENGINE.assets.fbx.meshOptimizer.simplification.name" tooltip="i18n:ENGINE.assets.fbx.meshOptimizer.simplification.title"></ui-label>
|
||||
<ui-prop>
|
||||
<ui-label slot="label" value="i18n:ENGINE.assets.fbx.meshOptimizer.simplification.si.name" tooltip="i18n:ENGINE.assets.fbx.meshOptimizer.simplification.si.title"></ui-label>
|
||||
@@ -35,7 +35,7 @@ exports.template = `
|
||||
<ui-checkbox slot="content" class="meshOptimizer-sa-checkbox"></ui-checkbox>
|
||||
</ui-prop>
|
||||
</ui-section>
|
||||
<ui-section expand>
|
||||
<ui-section expand cache-expand="fbx-model-mesh-optimizer-scene">
|
||||
<ui-label slot="header" value="i18n:ENGINE.assets.fbx.meshOptimizer.scene.name" tooltip="i18n:ENGINE.assets.fbx.meshOptimizer.scene.title"></ui-label>
|
||||
<ui-prop>
|
||||
<ui-label slot="label" value="i18n:ENGINE.assets.fbx.meshOptimizer.scene.kn.name" tooltip="i18n:ENGINE.assets.fbx.meshOptimizer.scene.kn.title"></ui-label>
|
||||
@@ -46,7 +46,7 @@ exports.template = `
|
||||
<ui-checkbox slot="content" class="meshOptimizer-ke-checkbox"></ui-checkbox>
|
||||
</ui-prop>
|
||||
</ui-section>
|
||||
<ui-section expand>
|
||||
<ui-section expand cache-expand="fbx-model-mesh-optimizer-miscellaneous">
|
||||
<ui-label slot="header" value="i18n:ENGINE.assets.fbx.meshOptimizer.miscellaneous.name" tooltip="i18n:ENGINE.assets.fbx.meshOptimizer.miscellaneous.title"></ui-label>
|
||||
<ui-prop>
|
||||
<ui-label slot="label" value="i18n:ENGINE.assets.fbx.meshOptimizer.miscellaneous.noq.name" tooltip="i18n:ENGINE.assets.fbx.meshOptimizer.miscellaneous.noq.title"></ui-label>
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -18,7 +18,7 @@ exports.template = `
|
||||
<ui-checkbox slot="content" class="isRGBE-checkbox"></ui-checkbox>
|
||||
</ui-prop>
|
||||
|
||||
<ui-section expand class="sub-panel-section">
|
||||
<ui-section expand class="sub-panel-section" cache-expand="image-sub-panel-section">
|
||||
<ui-label class="sub-panel-name" slot="header"></ui-label>
|
||||
<ui-panel class="sub-panel"></ui-panel>
|
||||
</ui-section>
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 += `<option value="${index}">${index} - ${technique.name}</option>`;
|
||||
const name = technique.name ? `${index} - ${technique.name}` : index;
|
||||
techniqueOption += `<option value="${index}">${name}</option>`;
|
||||
});
|
||||
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 <select> tag
|
||||
this.$.effect.value = this.material.effect;
|
||||
@@ -260,7 +283,7 @@ exports.update = async function (assetList, metaList) {
|
||||
/**
|
||||
* Method of initializing the panel
|
||||
*/
|
||||
exports.ready = async function () {
|
||||
exports.ready = async function() {
|
||||
// Used to determine whether the material has been modified in isDirty()
|
||||
this.dirtyData = {
|
||||
uuid: '',
|
||||
@@ -273,7 +296,7 @@ exports.ready = async function () {
|
||||
const dump = event.target.dump;
|
||||
|
||||
// show its children
|
||||
if (dump && dump.childMap && dump.children.length) {
|
||||
if (dump && dump.childMap && dump.children.length && event.target.$children) {
|
||||
if (dump.value) {
|
||||
event.target.$children.removeAttribute('hidden');
|
||||
} else {
|
||||
@@ -351,7 +374,7 @@ exports.ready = async function () {
|
||||
this.$.effect.innerHTML = effectOption;
|
||||
};
|
||||
|
||||
exports.close = function () {
|
||||
exports.close = function() {
|
||||
// Used to determine whether the material has been modified in isDirty()
|
||||
this.dirtyData = {
|
||||
uuid: '',
|
||||
|
||||
@@ -74,7 +74,7 @@ const Elements = {
|
||||
|
||||
document.addEventListener('mousemove', mousemove);
|
||||
document.addEventListener('mouseup', mouseup);
|
||||
|
||||
|
||||
panel.isPreviewDataDirty = true;
|
||||
});
|
||||
|
||||
@@ -105,7 +105,7 @@ const Elements = {
|
||||
const panel = this;
|
||||
|
||||
panel.resizeObserver.unobserve(panel.$.image);
|
||||
}
|
||||
},
|
||||
},
|
||||
info: {
|
||||
ready() {
|
||||
@@ -131,7 +131,7 @@ const Elements = {
|
||||
},
|
||||
};
|
||||
|
||||
exports.update = function (assetList, metaList) {
|
||||
exports.update = function(assetList, metaList) {
|
||||
this.assetList = assetList;
|
||||
this.metaList = metaList;
|
||||
this.asset = assetList[0];
|
||||
@@ -145,7 +145,7 @@ exports.update = function (assetList, metaList) {
|
||||
}
|
||||
};
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
for (const prop in Elements) {
|
||||
const element = Elements[prop];
|
||||
if (element.ready) {
|
||||
@@ -154,7 +154,7 @@ exports.ready = function () {
|
||||
}
|
||||
};
|
||||
|
||||
exports.close = function () {
|
||||
exports.close = function() {
|
||||
for (const prop in Elements) {
|
||||
const element = Elements[prop];
|
||||
if (element.close) {
|
||||
|
||||
@@ -23,12 +23,12 @@ exports.$ = {
|
||||
asset: '#asset',
|
||||
};
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
// Note: Currently, the material of 2d particles cannot be changed, ui-asset readonly, so the following is not valid
|
||||
this.$.asset.addEventListener('confirm', this.onDataChanged.bind(this, 'spriteFrameUuid'));
|
||||
};
|
||||
|
||||
exports.update = function (assetList, metaList) {
|
||||
exports.update = function(assetList, metaList) {
|
||||
this.assetList = assetList;
|
||||
this.metaList = metaList;
|
||||
this.asset = assetList[0];
|
||||
|
||||
@@ -48,7 +48,7 @@ exports.$ = {
|
||||
container: '.asset-physics-material',
|
||||
};
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
// Used to determine whether the material has been modified in isDirty()
|
||||
this.dirtyData = {
|
||||
uuid: '',
|
||||
@@ -57,7 +57,7 @@ exports.ready = function () {
|
||||
};
|
||||
};
|
||||
|
||||
exports.update = async function (assetList, metaList) {
|
||||
exports.update = async function(assetList, metaList) {
|
||||
this.assetList = assetList;
|
||||
this.metaList = metaList;
|
||||
this.asset = assetList[0];
|
||||
@@ -97,7 +97,7 @@ exports.update = async function (assetList, metaList) {
|
||||
this.setDirtyData();
|
||||
};
|
||||
|
||||
exports.close = function () {
|
||||
exports.close = function() {
|
||||
// Used to determine whether the material has been modified in isDirty()
|
||||
this.dirtyData = {
|
||||
uuid: '',
|
||||
|
||||
@@ -63,13 +63,15 @@ const Elements = {
|
||||
async update() {
|
||||
const panel = this;
|
||||
|
||||
this.$.content.innerText = '';
|
||||
const $content = panel.$.content;
|
||||
const oldPropList = Object.keys(panel.$propList);
|
||||
const newPropList = [];
|
||||
|
||||
if (panel.$.pipelinesSelect.value === '-1') {
|
||||
panel.$.content.setAttribute('hidden', '');
|
||||
$content.setAttribute('hidden', '');
|
||||
return;
|
||||
} else {
|
||||
panel.$.content.removeAttribute('hidden');
|
||||
$content.removeAttribute('hidden');
|
||||
}
|
||||
|
||||
for (const key in panel.pipeline.value) {
|
||||
@@ -82,18 +84,35 @@ const Elements = {
|
||||
continue;
|
||||
}
|
||||
|
||||
const prop = document.createElement('ui-prop');
|
||||
this.$.content.appendChild(prop);
|
||||
const id = `${dump.type}:${dump.name}`;
|
||||
newPropList.push(id);
|
||||
|
||||
prop.setAttribute('type', 'dump');
|
||||
prop.render(dump);
|
||||
prop.addEventListener('change-dump', this.dataChange.bind(this));
|
||||
let $prop = this.$propList[id];
|
||||
if (!$prop) {
|
||||
$prop = document.createElement('ui-prop');
|
||||
$prop.setAttribute('type', 'dump');
|
||||
$prop.addEventListener('change-dump', this.dataChange.bind(this));
|
||||
|
||||
$content.appendChild($prop);
|
||||
panel.$propList[id] = $prop;
|
||||
}
|
||||
|
||||
$prop.render(dump);
|
||||
}
|
||||
|
||||
for (const id of oldPropList) {
|
||||
if (!newPropList.includes(id)) {
|
||||
const $prop = panel.$propList[id];
|
||||
if ($prop && $prop.parentElement) {
|
||||
$prop.parentElement.removeChild($prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
exports.update = async function (assetList, metaList) {
|
||||
exports.update = async function(assetList, metaList) {
|
||||
this.assetList = assetList;
|
||||
this.metaList = metaList;
|
||||
this.meta = this.metaList[0];
|
||||
@@ -122,9 +141,10 @@ exports.update = async function (assetList, metaList) {
|
||||
}
|
||||
|
||||
this.setDirtyData();
|
||||
await this.preview();
|
||||
};
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
// Used to determine whether the material has been modified in isDirty()
|
||||
this.dirtyData = {
|
||||
uuid: '',
|
||||
@@ -132,6 +152,8 @@ exports.ready = function () {
|
||||
realtime: '',
|
||||
};
|
||||
|
||||
this.$propList = {};
|
||||
|
||||
for (const prop in Elements) {
|
||||
const element = Elements[prop];
|
||||
if (element.ready) {
|
||||
@@ -140,23 +162,33 @@ exports.ready = function () {
|
||||
}
|
||||
};
|
||||
|
||||
exports.close = function () {
|
||||
exports.close = function() {
|
||||
// Used to determine whether the material has been modified in isDirty()
|
||||
this.dirtyData = {
|
||||
uuid: '',
|
||||
origin: '',
|
||||
realtime: '',
|
||||
};
|
||||
|
||||
this.$propList = {};
|
||||
};
|
||||
|
||||
exports.methods = {
|
||||
async preview() {
|
||||
if (!this.pipeline) {
|
||||
return;
|
||||
}
|
||||
await Editor.Message.request('scene', 'preview-render-pipeline', this.asset.uuid, this.pipeline);
|
||||
},
|
||||
|
||||
async query(uuid) {
|
||||
return await Editor.Message.request('scene', 'query-render-pipeline', uuid);
|
||||
},
|
||||
|
||||
async apply () {
|
||||
async apply() {
|
||||
this.reset();
|
||||
await Editor.Message.request('scene', 'apply-render-pipeline', this.asset.uuid, this.pipeline);
|
||||
await this.preview();
|
||||
},
|
||||
reset() {
|
||||
this.dirtyData.origin = this.dirtyData.realtime;
|
||||
@@ -164,9 +196,14 @@ exports.methods = {
|
||||
},
|
||||
|
||||
async dataChange() {
|
||||
await Editor.Message.request('scene', 'change-render-pipeline', this.pipeline);
|
||||
this.pipeline = await Editor.Message.request('scene', 'change-render-pipeline', this.pipeline);
|
||||
|
||||
Elements.pipeline.update.call(this);
|
||||
|
||||
this.setDirtyData();
|
||||
this.dispatch('change');
|
||||
|
||||
await this.preview();
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,9 +25,9 @@ exports.methods = {
|
||||
this.dirtyData.uuid = '';
|
||||
},
|
||||
|
||||
async dataChange () {
|
||||
async dataChange() {
|
||||
await Editor.Message.request('scene', 'change-render-texture', this.renderTexture);
|
||||
|
||||
|
||||
this.setDirtyData();
|
||||
this.dispatch('change');
|
||||
},
|
||||
@@ -35,7 +35,7 @@ exports.methods = {
|
||||
/**
|
||||
* Detection of data changes only determines the currently selected technique
|
||||
*/
|
||||
setDirtyData() {
|
||||
setDirtyData() {
|
||||
this.dirtyData.realtime = JSON.stringify(this.renderTexture);
|
||||
|
||||
if (!this.dirtyData.origin) {
|
||||
@@ -53,7 +53,7 @@ exports.$ = {
|
||||
container: '.asset-render-texture',
|
||||
};
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
// Used to determine whether the material has been modified in isDirty()
|
||||
this.dirtyData = {
|
||||
uuid: '',
|
||||
@@ -62,7 +62,7 @@ exports.ready = function () {
|
||||
};
|
||||
};
|
||||
|
||||
exports.update = async function (assetList, metaList) {
|
||||
exports.update = async function(assetList, metaList) {
|
||||
this.assetList = assetList;
|
||||
this.metaList = metaList;
|
||||
this.meta = this.metaList[0];
|
||||
@@ -79,7 +79,7 @@ exports.update = async function (assetList, metaList) {
|
||||
}
|
||||
|
||||
this.renderTexture = await this.query(this.asset.uuid);
|
||||
|
||||
|
||||
for (const key in this.renderTexture) {
|
||||
const dump = this.renderTexture[key];
|
||||
|
||||
@@ -106,11 +106,11 @@ exports.update = async function (assetList, metaList) {
|
||||
this.setDirtyData();
|
||||
};
|
||||
|
||||
exports.close = function () {
|
||||
exports.close = function() {
|
||||
// Used to determine whether the material has been modified in isDirty()
|
||||
this.dirtyData = {
|
||||
uuid: '',
|
||||
origin: '',
|
||||
realtime: '',
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -73,7 +73,7 @@ const Elements = {
|
||||
document.addEventListener('mousemove', mousemove);
|
||||
document.addEventListener('mouseup', mouseup);
|
||||
|
||||
|
||||
|
||||
panel.isPreviewDataDirty = true;
|
||||
});
|
||||
|
||||
@@ -104,7 +104,7 @@ const Elements = {
|
||||
const panel = this;
|
||||
|
||||
panel.resizeObserver.unobserve(panel.$.image);
|
||||
}
|
||||
},
|
||||
},
|
||||
info: {
|
||||
ready() {
|
||||
@@ -129,7 +129,7 @@ const Elements = {
|
||||
},
|
||||
};
|
||||
|
||||
exports.update = function (assetList, metaList) {
|
||||
exports.update = function(assetList, metaList) {
|
||||
this.assetList = assetList;
|
||||
this.metaList = metaList;
|
||||
this.asset = assetList[0];
|
||||
@@ -143,7 +143,7 @@ exports.update = function (assetList, metaList) {
|
||||
}
|
||||
};
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
for (const prop in Elements) {
|
||||
const element = Elements[prop];
|
||||
if (element.ready) {
|
||||
@@ -152,7 +152,7 @@ exports.ready = function () {
|
||||
}
|
||||
};
|
||||
|
||||
exports.close = function () {
|
||||
exports.close = function() {
|
||||
for (const prop in Elements) {
|
||||
const element = Elements[prop];
|
||||
if (element.close) {
|
||||
|
||||
@@ -428,7 +428,7 @@ const Elements = {
|
||||
},
|
||||
update() {
|
||||
const panel = this;
|
||||
|
||||
|
||||
panel.updateReadonly(panel.$.editButton);
|
||||
|
||||
if (panel.assetList.length > 1) {
|
||||
@@ -450,7 +450,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];
|
||||
@@ -467,7 +467,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) {
|
||||
@@ -476,7 +476,7 @@ exports.ready = function () {
|
||||
}
|
||||
};
|
||||
|
||||
exports.close = function () {
|
||||
exports.close = function() {
|
||||
for (const prop in Elements) {
|
||||
const element = Elements[prop];
|
||||
if (element.close) {
|
||||
|
||||
@@ -26,7 +26,7 @@ exports.style = `
|
||||
}
|
||||
`;
|
||||
|
||||
exports.update = function (assetList, metaList) {
|
||||
exports.update = function(assetList, metaList) {
|
||||
this.assetList = assetList;
|
||||
this.metaList = metaList;
|
||||
this.meta = metaList[0];
|
||||
@@ -79,7 +79,7 @@ exports.update = function (assetList, metaList) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
|
||||
if (this.$.code) {
|
||||
this.$.code.textContent = text;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ const Direction = {
|
||||
top: 'top ( +Y )',
|
||||
bottom: 'bottom ( -Y )',
|
||||
front: 'front ( +Z )',
|
||||
back: 'left ( -X )',
|
||||
back: 'back ( -Z )',
|
||||
};
|
||||
|
||||
exports.template = `
|
||||
@@ -124,7 +124,7 @@ const Elements = {
|
||||
image.setAttribute('class', key);
|
||||
image.setAttribute('placeholder', key);
|
||||
image.addEventListener('confirm', panel.dataChange.bind(panel, key));
|
||||
|
||||
|
||||
panel.$[`${key}-image`] = image;
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ const Elements = {
|
||||
},
|
||||
};
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
for (const prop in Elements) {
|
||||
const element = Elements[prop];
|
||||
if (element.ready) {
|
||||
@@ -174,7 +174,7 @@ exports.ready = function () {
|
||||
}
|
||||
};
|
||||
|
||||
exports.update = function (assetList, metaList) {
|
||||
exports.update = function(assetList, metaList) {
|
||||
this.assetList = assetList;
|
||||
this.metaList = metaList;
|
||||
this.asset = assetList[0];
|
||||
@@ -188,7 +188,7 @@ exports.update = function (assetList, metaList) {
|
||||
}
|
||||
};
|
||||
|
||||
exports.close = function () {
|
||||
exports.close = function() {
|
||||
for (const prop in Elements) {
|
||||
const element = Elements[prop];
|
||||
if (element.close) {
|
||||
@@ -215,7 +215,7 @@ exports.methods = {
|
||||
this.metaList.forEach((meta) => {
|
||||
meta.userData[key] = event.target.value || undefined;
|
||||
});
|
||||
|
||||
|
||||
this.dispatch('change');
|
||||
|
||||
Elements.assets.update.call(this);
|
||||
|
||||
@@ -18,7 +18,7 @@ const Elements = texture.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];
|
||||
@@ -40,4 +40,4 @@ exports.update = function (assetList, metaList) {
|
||||
*/
|
||||
exports.ready = texture.ready;
|
||||
|
||||
exports.methods = texture.methods;;
|
||||
exports.methods = texture.methods;
|
||||
|
||||
@@ -18,7 +18,7 @@ const Elements = texture.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];
|
||||
@@ -40,4 +40,4 @@ exports.update = function (assetList, metaList) {
|
||||
*/
|
||||
exports.ready = texture.ready;
|
||||
|
||||
exports.methods = texture.methods;;
|
||||
exports.methods = texture.methods;
|
||||
|
||||
@@ -297,7 +297,7 @@ exports.Elements = Elements;
|
||||
/**
|
||||
* Method of initializing the panel
|
||||
*/
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
for (const prop in Elements) {
|
||||
const element = Elements[prop];
|
||||
if (element.ready) {
|
||||
|
||||
@@ -26,7 +26,7 @@ exports.style = `
|
||||
}
|
||||
`;
|
||||
|
||||
exports.update = function (assetList, metaList) {
|
||||
exports.update = function(assetList, metaList) {
|
||||
this.assetList = assetList;
|
||||
this.metaList = metaList;
|
||||
this.meta = metaList[0];
|
||||
@@ -44,7 +44,7 @@ exports.update = function (assetList, metaList) {
|
||||
|
||||
// Displays 400 lines or 20,000 characters
|
||||
const readStream = createReadStream(this.asset.file, {
|
||||
encoding: 'utf-8'
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
|
||||
let remainLines = MAX_LINES;
|
||||
@@ -53,7 +53,7 @@ exports.update = function (assetList, metaList) {
|
||||
|
||||
const readLineStream = ReadLine.createInterface({
|
||||
input: readStream,
|
||||
setEncoding: 'utf-8'
|
||||
setEncoding: 'utf-8',
|
||||
});
|
||||
|
||||
readLineStream.on('line', (line) => {
|
||||
|
||||
@@ -16,7 +16,7 @@ exports.$ = {
|
||||
constainer: '.asset-video-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;
|
||||
@@ -34,4 +34,4 @@ exports.update = function (assetList, metaList) {
|
||||
});
|
||||
|
||||
this.$.constainer.innerHTML = html;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ exports.update = update;
|
||||
|
||||
const { setHidden, isMultipleInvalid } = require('../utils/prop');
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
this.elements = {
|
||||
term: {
|
||||
displayOrder: 0,
|
||||
|
||||
@@ -10,6 +10,6 @@ exports.$ = {
|
||||
componentContainer: '.component-container',
|
||||
};
|
||||
|
||||
exports.update = function (dump) {
|
||||
exports.update = function(dump) {
|
||||
updatePropByDump(this, dump);
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@ exports.template = template;
|
||||
exports.$ = $;
|
||||
exports.update = update;
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
const $prop = document.createElement('ui-prop');
|
||||
this.$.componentContainer.before($prop);
|
||||
|
||||
@@ -21,7 +21,7 @@ exports.ready = function () {
|
||||
|
||||
$button.addEventListener('confirm', () => {
|
||||
Editor.Message.send('scene', 'snapshot');
|
||||
|
||||
|
||||
const uuids = this.dump.value.uuid.values || [this.dump.value.uuid.value];
|
||||
|
||||
uuids.forEach((uuid) => {
|
||||
|
||||
@@ -69,6 +69,6 @@ exports.elements = {
|
||||
},
|
||||
};
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
this.elements = exports.elements;
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ exports.update = update;
|
||||
|
||||
const { setHidden, isMultipleInvalid } = require('../utils/prop');
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
this.elements = {
|
||||
type: {
|
||||
displayOrder: 0,
|
||||
|
||||
@@ -6,7 +6,7 @@ exports.update = update;
|
||||
|
||||
const { setHidden, setDisabled, isMultipleInvalid } = require('../utils/prop');
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
// Handling in-line displayed attributes
|
||||
const needToInlines = [
|
||||
'life',
|
||||
@@ -212,13 +212,13 @@ exports.ready = function () {
|
||||
isAppendToParent() {
|
||||
const $left = this.$[key];
|
||||
const $right = this.$[`${key}Var`];
|
||||
|
||||
|
||||
if ($left && $right && $right.parentNode === $left) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
},
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ exports.template = `
|
||||
<ui-prop type="dump" key="rateOverDistance"></ui-prop>
|
||||
<ui-prop type="dump" key="bursts"></ui-prop>
|
||||
<ui-prop type="dump" key="enableCulling"></ui-prop>
|
||||
<ui-section class="config" key="shapeModule">
|
||||
<ui-section class="config" key="shapeModule" cache-expand="particle-system-shapeModule">
|
||||
<ui-prop slot="header" class="header" type="dump" key="shapeModule.value.enable" labelflag="shapeModule"
|
||||
empty="true">
|
||||
<ui-checkbox></ui-checkbox>
|
||||
@@ -90,10 +90,10 @@ exports.template = `
|
||||
<ui-prop type="dump" key="shapeModule.value.randomPositionAmount"></ui-prop>
|
||||
|
||||
</ui-section>
|
||||
<ui-section class="config" key="velocityOvertimeModule" autoflag="true"></ui-section>
|
||||
<ui-section class="config" key="forceOvertimeModule" autoflag="true"></ui-section>
|
||||
<ui-section class="config" key="velocityOvertimeModule" autoflag="true" cache-expand="particle-system-velocityOvertimeModule"></ui-section>
|
||||
<ui-section class="config" key="forceOvertimeModule" autoflag="true" cache-expand="particle-system-forceOvertimeModule"></ui-section>
|
||||
|
||||
<ui-section empty="true" class="config" key="sizeOvertimeModule">
|
||||
<ui-section empty="true" class="config" key="sizeOvertimeModule" cache-expand="particle-system-sizeOvertimeModule">
|
||||
<ui-prop slot="header" class="header" type="dump" key="sizeOvertimeModule.value.enable"
|
||||
labelflag="sizeOvertimeModule" empty="true">
|
||||
<ui-checkbox></ui-checkbox>
|
||||
@@ -114,7 +114,7 @@ exports.template = `
|
||||
|
||||
</ui-section>
|
||||
|
||||
<ui-section empty="true" class="config" key="rotationOvertimeModule">
|
||||
<ui-section empty="true" class="config" key="rotationOvertimeModule" cache-expand="particle-system-rotationOvertimeModule">
|
||||
|
||||
<ui-prop slot="header" class="header" type="dump" key="rotationOvertimeModule.value.enable"
|
||||
labelflag="rotationOvertimeModule" empty="true">
|
||||
@@ -130,9 +130,9 @@ exports.template = `
|
||||
<ui-prop type="dump" key="rotationOvertimeModule.value.z"></ui-prop>
|
||||
|
||||
</ui-section>
|
||||
<ui-section class="config" key="colorOverLifetimeModule" autoflag="true"></ui-section>
|
||||
<ui-section class="config" key="textureAnimationModule" autoflag="true"></ui-section>
|
||||
<ui-section type="dump" showflag="!renderer.value.useGPU" key="limitVelocityOvertimeModule" class="config">
|
||||
<ui-section class="config" key="colorOverLifetimeModule" autoflag="true" cache-expand="particle-system-colorOverLifetimeModule"></ui-section>
|
||||
<ui-section class="config" key="textureAnimationModule" autoflag="true" cache-expand="particle-system-textureAnimationModule"></ui-section>
|
||||
<ui-section type="dump" showflag="!renderer.value.useGPU" key="limitVelocityOvertimeModule" class="config" cache-expand="particle-system-limitVelocityOvertimeModule">
|
||||
<ui-prop slot="header" class="header" type="dump" key="limitVelocityOvertimeModule.value.enable" labelflag="limitVelocityOvertimeModule"
|
||||
empty="true">
|
||||
<ui-checkbox></ui-checkbox>
|
||||
@@ -146,7 +146,7 @@ exports.template = `
|
||||
<ui-prop type="dump" key="limitVelocityOvertimeModule.value.limitY" showflag="limitVelocityOvertimeModule.value.separateAxes"></ui-prop>
|
||||
<ui-prop type="dump" key="limitVelocityOvertimeModule.value.limitZ" showflag="limitVelocityOvertimeModule.value.separateAxes"></ui-prop>
|
||||
</ui-section>
|
||||
<ui-section empty="true" class="config" showflag="!renderer.value.useGPU" key="trailModule">
|
||||
<ui-section empty="true" class="config" showflag="!renderer.value.useGPU" key="trailModule" cache-expand="particle-system-trailModule">
|
||||
<ui-prop slot="header" class="header" type="dump" key="trailModule.value.enable" labelflag="trailModule"
|
||||
empty="true">
|
||||
<ui-checkbox></ui-checkbox>
|
||||
@@ -186,7 +186,7 @@ const excludeList = [
|
||||
];
|
||||
|
||||
exports.methods = {
|
||||
getObjectByKey (target, key) {
|
||||
getObjectByKey(target, key) {
|
||||
let params = [];
|
||||
if (typeof key === 'string') {
|
||||
params = key.split('.');
|
||||
@@ -203,7 +203,7 @@ exports.methods = {
|
||||
/**
|
||||
* Get the name based on the dump data
|
||||
*/
|
||||
getName (value) {
|
||||
getName(value) {
|
||||
if (!value) {
|
||||
return '';
|
||||
}
|
||||
@@ -225,7 +225,7 @@ exports.methods = {
|
||||
* Get tooltip based on dump data
|
||||
* @param value
|
||||
*/
|
||||
getTitle (value) {
|
||||
getTitle(value) {
|
||||
if (value.tooltip) {
|
||||
if (!value.tooltip.startsWith('i18n:')) {
|
||||
return value.tooltip;
|
||||
@@ -236,7 +236,7 @@ exports.methods = {
|
||||
return this.getName(value);
|
||||
},
|
||||
|
||||
getEnumName (type, value) {
|
||||
getEnumName(type, value) {
|
||||
for (const opt of type.enumList) {
|
||||
if (opt.value === value) {
|
||||
return opt.name;
|
||||
@@ -245,7 +245,7 @@ exports.methods = {
|
||||
return String();
|
||||
},
|
||||
|
||||
getEnumObjFromName (type, ...name) {
|
||||
getEnumObjFromName(type, ...name) {
|
||||
const enumMap = {};
|
||||
for (const opt of type.enumList) {
|
||||
enumMap[opt.name] = {
|
||||
@@ -256,29 +256,29 @@ exports.methods = {
|
||||
return name.map((value) => enumMap[value]);
|
||||
},
|
||||
|
||||
getShapeTypeEmitFrom (shapeType) {
|
||||
getShapeTypeEmitFrom(shapeType) {
|
||||
const shapeTypeName = this.getEnumName(this.dump.value.shapeModule.value.shapeType, shapeType);
|
||||
let emitEnum = null;
|
||||
switch (shapeTypeName) {
|
||||
case 'Box':
|
||||
emitEnum = this.getEnumObjFromName(this.dump.value.shapeModule.value.emitFrom, 'Volume', 'Shell', 'Edge');
|
||||
break;
|
||||
case 'Cone':
|
||||
emitEnum = this.getEnumObjFromName(this.dump.value.shapeModule.value.emitFrom, 'Base', 'Shell', 'Volume');
|
||||
break;
|
||||
case 'Sphere':
|
||||
emitEnum = this.getEnumObjFromName(this.dump.value.shapeModule.value.emitFrom, 'Volume', 'Shell');
|
||||
break;
|
||||
case 'Hemisphere':
|
||||
emitEnum = this.getEnumObjFromName(this.dump.value.shapeModule.value.emitFrom, 'Volume', 'Shell');
|
||||
break;
|
||||
default:
|
||||
emitEnum = [];
|
||||
case 'Box':
|
||||
emitEnum = this.getEnumObjFromName(this.dump.value.shapeModule.value.emitFrom, 'Volume', 'Shell', 'Edge');
|
||||
break;
|
||||
case 'Cone':
|
||||
emitEnum = this.getEnumObjFromName(this.dump.value.shapeModule.value.emitFrom, 'Base', 'Shell', 'Volume');
|
||||
break;
|
||||
case 'Sphere':
|
||||
emitEnum = this.getEnumObjFromName(this.dump.value.shapeModule.value.emitFrom, 'Volume', 'Shell');
|
||||
break;
|
||||
case 'Hemisphere':
|
||||
emitEnum = this.getEnumObjFromName(this.dump.value.shapeModule.value.emitFrom, 'Volume', 'Shell');
|
||||
break;
|
||||
default:
|
||||
emitEnum = [];
|
||||
}
|
||||
return emitEnum;
|
||||
},
|
||||
|
||||
checkEnumInSubset (enumValue, ...subset) {
|
||||
checkEnumInSubset(enumValue, ...subset) {
|
||||
const optName = this.getEnumName(enumValue, enumValue.value);
|
||||
for (const name of subset) {
|
||||
if (name === optName) {
|
||||
@@ -291,10 +291,10 @@ exports.methods = {
|
||||
|
||||
const uiElements = {
|
||||
uiSections: {
|
||||
ready () {
|
||||
ready() {
|
||||
this.$.uiSections = this.$this.shadowRoot.querySelectorAll('ui-section');
|
||||
},
|
||||
update () {
|
||||
update() {
|
||||
this.$.uiSections.forEach((element) => {
|
||||
const key = element.getAttribute('key');
|
||||
const showflag = element.getAttribute('showflag');
|
||||
@@ -379,13 +379,13 @@ const uiElements = {
|
||||
},
|
||||
},
|
||||
emitFromSelect: {
|
||||
ready () {
|
||||
ready() {
|
||||
this.$.emitFromSelect.addEventListener('change', (event) => {
|
||||
this.dump.value.shapeModule.value.emitFrom.value = event.target.value;
|
||||
this.$.emitFromSelect.parentNode.dispatch('change-dump');
|
||||
});
|
||||
},
|
||||
update () {
|
||||
update() {
|
||||
this.$.emitFromSelect.setAttribute('value', this.dump.value.shapeModule.value.emitFrom.value);
|
||||
const datas = this.getShapeTypeEmitFrom(this.dump.value.shapeModule.value.shapeType.value);
|
||||
const children = datas.map((data) => {
|
||||
@@ -398,7 +398,7 @@ const uiElements = {
|
||||
},
|
||||
},
|
||||
baseProps: {
|
||||
ready () {
|
||||
ready() {
|
||||
this.$.baseProps = this.$this.shadowRoot.querySelectorAll('ui-prop:not(.customProp)');
|
||||
this.$.baseProps.forEach((element) => {
|
||||
const key = element.getAttribute('key');
|
||||
@@ -430,7 +430,7 @@ const uiElements = {
|
||||
}
|
||||
});
|
||||
},
|
||||
update () {
|
||||
update() {
|
||||
this.$.baseProps.forEach((element) => {
|
||||
const key = element.getAttribute('key');
|
||||
const isEmpty = element.getAttribute('empty');
|
||||
@@ -490,7 +490,7 @@ const uiElements = {
|
||||
},
|
||||
},
|
||||
customProps: {
|
||||
update () {
|
||||
update() {
|
||||
this.$.customProps.replaceChildren(...propUtils.getCustomPropElements(excludeList, this.dump, (element, prop) => {
|
||||
element.className = 'customProp';
|
||||
if (prop.dump.visible) {
|
||||
@@ -504,7 +504,7 @@ exports.$ = {
|
||||
customProps: '#customProps',
|
||||
emitFromSelect: '#emitFromSelect',
|
||||
};
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
for (const key in uiElements) {
|
||||
const element = uiElements[key];
|
||||
if (typeof element.ready === 'function') {
|
||||
@@ -512,7 +512,7 @@ exports.ready = function () {
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.update = function (dump) {
|
||||
exports.update = function(dump) {
|
||||
this.dump = dump;
|
||||
for (const key in uiElements) {
|
||||
const element = uiElements[key];
|
||||
|
||||
@@ -4,7 +4,7 @@ exports.template = template;
|
||||
exports.$ = $;
|
||||
exports.update = update;
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
this.elements = {
|
||||
threshold: {
|
||||
displayOrder: 0,
|
||||
|
||||
@@ -4,7 +4,7 @@ exports.template = template;
|
||||
exports.$ = $;
|
||||
exports.update = update;
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
const tooltip = document.createElement('ui-tooltip');
|
||||
tooltip.setAttribute('arrow', 'top left+10px');
|
||||
this.$.componentContainer.before(tooltip);
|
||||
|
||||
@@ -6,7 +6,7 @@ exports.update = update;
|
||||
|
||||
const { setHidden, isMultipleInvalid } = require('../utils/prop');
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
this.elements = {
|
||||
string: {
|
||||
displayOrder: 0,
|
||||
|
||||
@@ -4,7 +4,7 @@ exports.template = template;
|
||||
exports.$ = $;
|
||||
exports.update = update;
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
const tooltip = document.createElement('ui-tooltip');
|
||||
tooltip.setAttribute('arrow', 'top left+10px');
|
||||
this.$.componentContainer.before(tooltip);
|
||||
|
||||
@@ -6,7 +6,7 @@ exports.update = update;
|
||||
|
||||
const { setHidden, isMultipleInvalid } = require('../utils/prop');
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
this.elements = {
|
||||
horizontal: {
|
||||
displayOrder: 0,
|
||||
|
||||
@@ -6,7 +6,7 @@ exports.update = update;
|
||||
|
||||
const { setHidden, setReadonly, isMultipleInvalid } = require('../utils/prop');
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
this.elements = {
|
||||
type: {
|
||||
displayOrder: 0,
|
||||
@@ -37,4 +37,4 @@ exports.ready = function () {
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -6,11 +6,11 @@ exports.update = update;
|
||||
|
||||
const { setHidden } = require('../utils/prop');
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
this.elements = {
|
||||
_asset: {
|
||||
displayOrder: 0,
|
||||
ready (element) {
|
||||
ready(element) {
|
||||
element.addEventListener('change-dump', (event) => {
|
||||
Editor.Message.send('scene', 'snapshot');
|
||||
Editor.Message.request('scene', 'execute-component-method', {
|
||||
@@ -24,7 +24,7 @@ exports.ready = function () {
|
||||
info: {
|
||||
update(element) {
|
||||
setHidden(true, element);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@ exports.template = template;
|
||||
exports.$ = $;
|
||||
exports.update = update;
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
this.elements = Object.assign(elements, {
|
||||
isChecked: {
|
||||
displayOrder: 2,
|
||||
|
||||
@@ -6,7 +6,7 @@ exports.update = update;
|
||||
|
||||
const { setHidden, isMultipleInvalid } = require('../utils/prop');
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
this.elements = {
|
||||
resourceType: {
|
||||
displayOrder: 0,
|
||||
@@ -23,5 +23,5 @@ exports.ready = function () {
|
||||
setHidden(isMultipleInvalid(dump.resourceType) || dump.resourceType.value === 0, element);
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@ exports.template = template;
|
||||
exports.$ = $;
|
||||
exports.update = update;
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
this.elements = {
|
||||
url: {
|
||||
displayOrder: 0,
|
||||
|
||||
@@ -480,7 +480,7 @@ exports.$ = {
|
||||
app: '#app',
|
||||
};
|
||||
exports.methods = {
|
||||
getObjectByKey (target, key) {
|
||||
getObjectByKey(target, key) {
|
||||
let params = [];
|
||||
if (typeof key === 'string') {
|
||||
params = key.split('.');
|
||||
@@ -494,7 +494,7 @@ exports.methods = {
|
||||
return target;
|
||||
}
|
||||
},
|
||||
getDimensionHorizontal () {
|
||||
getDimensionHorizontal() {
|
||||
const {
|
||||
isAlignLeft, isAlignRight, isAlignHorizontalCenter,
|
||||
} = this.dump.value;
|
||||
@@ -516,7 +516,7 @@ exports.methods = {
|
||||
|
||||
return dimension;
|
||||
},
|
||||
getDimensionVertical () {
|
||||
getDimensionVertical() {
|
||||
const {
|
||||
isAlignTop, isAlignBottom, isAlignVerticalCenter,
|
||||
} = this.dump.value;
|
||||
@@ -544,7 +544,7 @@ exports.methods = {
|
||||
|
||||
return false;
|
||||
},
|
||||
update () {
|
||||
update() {
|
||||
for (const key in uiElements) {
|
||||
const element = uiElements[key];
|
||||
if (typeof element.update === 'function') {
|
||||
@@ -552,60 +552,60 @@ exports.methods = {
|
||||
}
|
||||
}
|
||||
},
|
||||
change (key, newValue) {
|
||||
change(key, newValue) {
|
||||
this.dump.value[key].value = newValue;
|
||||
this.$refs.summitProp.dump = this.dump.value[key];
|
||||
this.$refs.summitProp.dispatch('change-dump');
|
||||
},
|
||||
|
||||
getUnit (type) {
|
||||
getUnit(type) {
|
||||
const data = this.dump.value;
|
||||
|
||||
switch (type) {
|
||||
case 'editorTop':
|
||||
return data.isAbsoluteTop.value ? 'px' : '%';
|
||||
case 'editorBottom':
|
||||
return data.isAbsoluteBottom.value ? 'px' : '%';
|
||||
case 'editorLeft':
|
||||
return data.isAbsoluteLeft.value ? 'px' : '%';
|
||||
case 'editorRight':
|
||||
return data.isAbsoluteRight.value ? 'px' : '%';
|
||||
case 'editorHorizontalCenter':
|
||||
return data.isAbsoluteHorizontalCenter.value ? 'px' : '%';
|
||||
case 'editorVerticalCenter':
|
||||
return data.isAbsoluteVerticalCenter.value ? 'px' : '%';
|
||||
default:
|
||||
break;
|
||||
case 'editorTop':
|
||||
return data.isAbsoluteTop.value ? 'px' : '%';
|
||||
case 'editorBottom':
|
||||
return data.isAbsoluteBottom.value ? 'px' : '%';
|
||||
case 'editorLeft':
|
||||
return data.isAbsoluteLeft.value ? 'px' : '%';
|
||||
case 'editorRight':
|
||||
return data.isAbsoluteRight.value ? 'px' : '%';
|
||||
case 'editorHorizontalCenter':
|
||||
return data.isAbsoluteHorizontalCenter.value ? 'px' : '%';
|
||||
case 'editorVerticalCenter':
|
||||
return data.isAbsoluteVerticalCenter.value ? 'px' : '%';
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
changeUnit (type) {
|
||||
function update (dump, force) {
|
||||
changeUnit(type) {
|
||||
function update(dump, force) {
|
||||
if (force !== true && dump === this.dump) {
|
||||
return;
|
||||
}
|
||||
const value = dump.value;
|
||||
switch (type) {
|
||||
case 'editorTop':
|
||||
value.isAbsoluteTop.value = !value.isAbsoluteTop.value;
|
||||
return { path: 'isAbsoluteTop', dump: value.isAbsoluteTop };
|
||||
case 'editorBottom':
|
||||
value.isAbsoluteBottom.value = !value.isAbsoluteBottom.value;
|
||||
return { path: 'isAbsoluteBottom', dump: value.isAbsoluteBottom };
|
||||
case 'editorLeft':
|
||||
value.isAbsoluteLeft.value = !value.isAbsoluteLeft.value;
|
||||
return { path: 'isAbsoluteLeft', dump: value.isAbsoluteLeft };
|
||||
case 'editorRight':
|
||||
value.isAbsoluteRight.value = !value.isAbsoluteRight.value;
|
||||
return { path: 'isAbsoluteRight', dump: value.isAbsoluteRight };
|
||||
case 'editorHorizontalCenter':
|
||||
value.isAbsoluteHorizontalCenter.value = !value.isAbsoluteHorizontalCenter.value;
|
||||
return { path: 'isAbsoluteHorizontalCenter', dump: value.isAbsoluteHorizontalCenter };
|
||||
case 'editorVerticalCenter':
|
||||
value.isAbsoluteVerticalCenter.value = !value.isAbsoluteVerticalCenter.value;
|
||||
return { path: 'isAbsoluteVerticalCenter', dump: value.isAbsoluteVerticalCenter };
|
||||
default:
|
||||
break;
|
||||
case 'editorTop':
|
||||
value.isAbsoluteTop.value = !value.isAbsoluteTop.value;
|
||||
return { path: 'isAbsoluteTop', dump: value.isAbsoluteTop };
|
||||
case 'editorBottom':
|
||||
value.isAbsoluteBottom.value = !value.isAbsoluteBottom.value;
|
||||
return { path: 'isAbsoluteBottom', dump: value.isAbsoluteBottom };
|
||||
case 'editorLeft':
|
||||
value.isAbsoluteLeft.value = !value.isAbsoluteLeft.value;
|
||||
return { path: 'isAbsoluteLeft', dump: value.isAbsoluteLeft };
|
||||
case 'editorRight':
|
||||
value.isAbsoluteRight.value = !value.isAbsoluteRight.value;
|
||||
return { path: 'isAbsoluteRight', dump: value.isAbsoluteRight };
|
||||
case 'editorHorizontalCenter':
|
||||
value.isAbsoluteHorizontalCenter.value = !value.isAbsoluteHorizontalCenter.value;
|
||||
return { path: 'isAbsoluteHorizontalCenter', dump: value.isAbsoluteHorizontalCenter };
|
||||
case 'editorVerticalCenter':
|
||||
value.isAbsoluteVerticalCenter.value = !value.isAbsoluteVerticalCenter.value;
|
||||
return { path: 'isAbsoluteVerticalCenter', dump: value.isAbsoluteVerticalCenter };
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
const { dump } = update(this.dump, true);
|
||||
@@ -613,7 +613,7 @@ exports.methods = {
|
||||
this.$refs.summitProp.dispatch('change-dump');
|
||||
},
|
||||
|
||||
select (event) {
|
||||
select(event) {
|
||||
// Handling through delegated events
|
||||
const button = event.path.find((element) => element && element.classList && element.classList.contains('button'));
|
||||
|
||||
@@ -627,138 +627,138 @@ exports.methods = {
|
||||
let vertical;
|
||||
|
||||
switch (dimension) {
|
||||
case 'horizontal':
|
||||
horizontal = {
|
||||
isAlignLeft: {
|
||||
value: false,
|
||||
},
|
||||
isAlignRight: {
|
||||
value: false,
|
||||
},
|
||||
isAlignHorizontalCenter: {
|
||||
value: false,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 'left':
|
||||
horizontal = {
|
||||
isAlignLeft: {
|
||||
value: true,
|
||||
},
|
||||
isAlignRight: {
|
||||
value: false,
|
||||
},
|
||||
isAlignHorizontalCenter: {
|
||||
value: false,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 'center':
|
||||
horizontal = {
|
||||
isAlignLeft: {
|
||||
value: false,
|
||||
},
|
||||
isAlignRight: {
|
||||
value: false,
|
||||
},
|
||||
isAlignHorizontalCenter: {
|
||||
value: true,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 'right':
|
||||
horizontal = {
|
||||
isAlignLeft: {
|
||||
value: false,
|
||||
},
|
||||
isAlignRight: {
|
||||
value: true,
|
||||
},
|
||||
isAlignHorizontalCenter: {
|
||||
value: false,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 'h-stretch':
|
||||
horizontal = {
|
||||
isAlignLeft: {
|
||||
value: true,
|
||||
},
|
||||
isAlignRight: {
|
||||
value: true,
|
||||
},
|
||||
isAlignHorizontalCenter: {
|
||||
value: false,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 'vertical':
|
||||
vertical = {
|
||||
isAlignTop: {
|
||||
value: false,
|
||||
},
|
||||
isAlignVerticalCenter: {
|
||||
value: false,
|
||||
},
|
||||
isAlignBottom: {
|
||||
value: false,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 'top':
|
||||
vertical = {
|
||||
isAlignTop: {
|
||||
value: true,
|
||||
},
|
||||
isAlignVerticalCenter: {
|
||||
value: false,
|
||||
},
|
||||
isAlignBottom: {
|
||||
value: false,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 'middle':
|
||||
vertical = {
|
||||
isAlignTop: {
|
||||
value: false,
|
||||
},
|
||||
isAlignVerticalCenter: {
|
||||
value: true,
|
||||
},
|
||||
isAlignBottom: {
|
||||
value: false,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 'bottom':
|
||||
vertical = {
|
||||
isAlignTop: {
|
||||
value: false,
|
||||
},
|
||||
isAlignVerticalCenter: {
|
||||
value: false,
|
||||
},
|
||||
isAlignBottom: {
|
||||
value: true,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 'v-stretch':
|
||||
vertical = {
|
||||
isAlignTop: {
|
||||
value: true,
|
||||
},
|
||||
isAlignVerticalCenter: {
|
||||
value: false,
|
||||
},
|
||||
isAlignBottom: {
|
||||
value: true,
|
||||
},
|
||||
};
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 'horizontal':
|
||||
horizontal = {
|
||||
isAlignLeft: {
|
||||
value: false,
|
||||
},
|
||||
isAlignRight: {
|
||||
value: false,
|
||||
},
|
||||
isAlignHorizontalCenter: {
|
||||
value: false,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 'left':
|
||||
horizontal = {
|
||||
isAlignLeft: {
|
||||
value: true,
|
||||
},
|
||||
isAlignRight: {
|
||||
value: false,
|
||||
},
|
||||
isAlignHorizontalCenter: {
|
||||
value: false,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 'center':
|
||||
horizontal = {
|
||||
isAlignLeft: {
|
||||
value: false,
|
||||
},
|
||||
isAlignRight: {
|
||||
value: false,
|
||||
},
|
||||
isAlignHorizontalCenter: {
|
||||
value: true,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 'right':
|
||||
horizontal = {
|
||||
isAlignLeft: {
|
||||
value: false,
|
||||
},
|
||||
isAlignRight: {
|
||||
value: true,
|
||||
},
|
||||
isAlignHorizontalCenter: {
|
||||
value: false,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 'h-stretch':
|
||||
horizontal = {
|
||||
isAlignLeft: {
|
||||
value: true,
|
||||
},
|
||||
isAlignRight: {
|
||||
value: true,
|
||||
},
|
||||
isAlignHorizontalCenter: {
|
||||
value: false,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 'vertical':
|
||||
vertical = {
|
||||
isAlignTop: {
|
||||
value: false,
|
||||
},
|
||||
isAlignVerticalCenter: {
|
||||
value: false,
|
||||
},
|
||||
isAlignBottom: {
|
||||
value: false,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 'top':
|
||||
vertical = {
|
||||
isAlignTop: {
|
||||
value: true,
|
||||
},
|
||||
isAlignVerticalCenter: {
|
||||
value: false,
|
||||
},
|
||||
isAlignBottom: {
|
||||
value: false,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 'middle':
|
||||
vertical = {
|
||||
isAlignTop: {
|
||||
value: false,
|
||||
},
|
||||
isAlignVerticalCenter: {
|
||||
value: true,
|
||||
},
|
||||
isAlignBottom: {
|
||||
value: false,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 'bottom':
|
||||
vertical = {
|
||||
isAlignTop: {
|
||||
value: false,
|
||||
},
|
||||
isAlignVerticalCenter: {
|
||||
value: false,
|
||||
},
|
||||
isAlignBottom: {
|
||||
value: true,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 'v-stretch':
|
||||
vertical = {
|
||||
isAlignTop: {
|
||||
value: true,
|
||||
},
|
||||
isAlignVerticalCenter: {
|
||||
value: false,
|
||||
},
|
||||
isAlignBottom: {
|
||||
value: true,
|
||||
},
|
||||
};
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Editor.Message.send('scene', 'snapshot');
|
||||
@@ -802,7 +802,7 @@ exports.methods = {
|
||||
}
|
||||
},
|
||||
|
||||
toggleLock (direction) {
|
||||
toggleLock(direction) {
|
||||
const isLock = this.isLock(direction);
|
||||
let directions = [direction];
|
||||
let lockValue = this.dump.value._lockFlags.value;
|
||||
@@ -832,7 +832,7 @@ exports.methods = {
|
||||
this.$refs.summitProp.dump = this.dump.value._lockFlags;
|
||||
this.$refs.summitProp.dispatch('change-dump');
|
||||
},
|
||||
isLock (direction) {
|
||||
isLock(direction) {
|
||||
const lockValue = this.dump.value._lockFlags.value;
|
||||
const lockDirection = LockFlags[direction];
|
||||
return lockValue & lockDirection;
|
||||
@@ -840,10 +840,10 @@ exports.methods = {
|
||||
};
|
||||
const uiElements = {
|
||||
baseProps: {
|
||||
ready () {
|
||||
ready() {
|
||||
this.$baseProps = this.$el && this.$el.querySelectorAll('ui-prop:not(.customProp)');
|
||||
},
|
||||
update () {
|
||||
update() {
|
||||
if (!this.$baseProps) {
|
||||
uiElements.baseProps.ready.call(this);
|
||||
}
|
||||
@@ -862,7 +862,7 @@ const uiElements = {
|
||||
},
|
||||
},
|
||||
customProps: {
|
||||
update () {
|
||||
update() {
|
||||
if (!this.$customProps) {
|
||||
this.$customProps = this.$el.querySelector('#customProps');
|
||||
}
|
||||
@@ -1081,7 +1081,7 @@ const components = {
|
||||
},
|
||||
};
|
||||
|
||||
exports.ready = function () {
|
||||
exports.ready = function() {
|
||||
this.resizeObserver = new window.ResizeObserver(() => {
|
||||
const rect = this.$this.getBoundingClientRect();
|
||||
if (rect.width > 300) {
|
||||
@@ -1100,7 +1100,7 @@ exports.ready = function () {
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.update = function (dump) {
|
||||
exports.update = function(dump) {
|
||||
this.dump = dump;
|
||||
this.dimensionHorizontal = this.getDimensionHorizontal();
|
||||
this.dimensionVertical = this.getDimensionVertical();
|
||||
@@ -1121,6 +1121,6 @@ exports.update = function (dump) {
|
||||
}
|
||||
this.vm.update();
|
||||
};
|
||||
exports.close = function () {
|
||||
exports.close = function() {
|
||||
this.resizeObserver.unobserve(this.$this);
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ exports.buildEffect = function(index, passData) {
|
||||
function encode(item) {
|
||||
let current = tree;
|
||||
|
||||
/**
|
||||
/**
|
||||
* USE_INSTANCING and USE_BATCHING are common to every child in passes
|
||||
* To make editing easier, they are referred to the outside of the passes
|
||||
* At this point, you need to set each of the passes to be non-editable and invisible
|
||||
@@ -168,7 +168,7 @@ exports.buildEffect = function(index, passData) {
|
||||
const dump = translate(tree);
|
||||
dump.value = tree.childMap;
|
||||
return dump;
|
||||
}
|
||||
};
|
||||
|
||||
exports.materialTechniquePolyfill = function(origin) {
|
||||
let useInstancing;
|
||||
@@ -206,4 +206,4 @@ exports.materialTechniquePolyfill = function(origin) {
|
||||
};
|
||||
|
||||
return technique;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* @param {*} value of dump
|
||||
* @returns {key:string dump:object}[]
|
||||
*/
|
||||
exports.sortProp = function (propMap) {
|
||||
exports.sortProp = function(propMap) {
|
||||
const orderList = [];
|
||||
const normalList = [];
|
||||
|
||||
@@ -35,7 +35,7 @@ exports.sortProp = function (propMap) {
|
||||
* @param {object} dump
|
||||
* @param {(element,prop)=>void} onElementCreated
|
||||
*/
|
||||
exports.getCustomPropElements = function (excludeList, dump, onElementCreated) {
|
||||
exports.getCustomPropElements = function(excludeList, dump, onElementCreated) {
|
||||
const customPropElements = [];
|
||||
const sortedProp = exports.sortProp(dump.value);
|
||||
sortedProp.forEach((prop) => {
|
||||
@@ -54,7 +54,7 @@ exports.getCustomPropElements = function (excludeList, dump, onElementCreated) {
|
||||
/**
|
||||
* Tool function: recursively set readonly in resource data
|
||||
*/
|
||||
exports.loopSetAssetDumpDataReadonly = function (dump) {
|
||||
exports.loopSetAssetDumpDataReadonly = function(dump) {
|
||||
if (typeof dump !== 'object') {
|
||||
return;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ exports.loopSetAssetDumpDataReadonly = function (dump) {
|
||||
* @param {object} data dump | function
|
||||
* @param element
|
||||
*/
|
||||
exports.setDisabled = function (data, element) {
|
||||
exports.setDisabled = function(data, element) {
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ exports.setDisabled = function (data, element) {
|
||||
* @param {object} data dump | function
|
||||
* @param element
|
||||
*/
|
||||
exports.setReadonly = function (data, element) {
|
||||
exports.setReadonly = function(data, element) {
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ exports.setReadonly = function (data, element) {
|
||||
* @param {object} data dump | function
|
||||
* @param element
|
||||
*/
|
||||
exports.setHidden = function (data, element) {
|
||||
exports.setHidden = function(data, element) {
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ exports.setHidden = function (data, element) {
|
||||
}
|
||||
};
|
||||
|
||||
exports.updatePropByDump = function (panel, dump) {
|
||||
exports.updatePropByDump = function(panel, dump) {
|
||||
panel.dump = dump;
|
||||
|
||||
if (!panel.elements) {
|
||||
@@ -216,20 +216,15 @@ exports.updatePropByDump = function (panel, dump) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($children[i]) {
|
||||
$children[i].replaceWith(child);
|
||||
} else {
|
||||
panel.$.componentContainer.appendChild(child);
|
||||
}
|
||||
panel.$.componentContainer.appendChild(child);
|
||||
});
|
||||
|
||||
// delete extra children
|
||||
$children = Array.from(panel.$.componentContainer.children);
|
||||
if ($children.length > children.length) {
|
||||
for (let i = children.length; i < $children.length; i++) {
|
||||
$children[i].remove();
|
||||
$children.forEach(($child) => {
|
||||
if (!children.includes($child)) {
|
||||
$child.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (const key in panel.elements) {
|
||||
const element = panel.elements[key];
|
||||
@@ -250,7 +245,7 @@ exports.updatePropByDump = function (panel, dump) {
|
||||
/**
|
||||
* Tool function: check whether the value of the attribute is consistent after multi-selection
|
||||
*/
|
||||
exports.isMultipleInvalid = function (dump) {
|
||||
exports.isMultipleInvalid = function(dump) {
|
||||
let invalid = false;
|
||||
|
||||
if (dump.values && dump.values.some((ds) => ds !== dump.value)) {
|
||||
|
||||
@@ -82,7 +82,7 @@ let VideoPlayerImpl = cc.Class({
|
||||
let cbs = this.__eventListeners;
|
||||
cbs.loadedmetadata = function () {
|
||||
this._loadedmeta = true;
|
||||
if (sys.os === sys.OS_IOS && sys.isBrowser) {
|
||||
if (sys.os === sys.OS.IOS && sys.isBrowser) {
|
||||
triggerFullScene(video, self._fullScreenEnabled);
|
||||
}
|
||||
self._dispatchEvent(VideoPlayerImpl.EventType.META_LOADED);
|
||||
@@ -368,7 +368,7 @@ let VideoPlayerImpl = cc.Class({
|
||||
if (!video) {
|
||||
return;
|
||||
}
|
||||
if (sys.os === sys.OS_IOS && sys.isBrowser) {
|
||||
if (sys.os === sys.OS.IOS && sys.isBrowser) {
|
||||
this._fullScreenEnabled = enable;
|
||||
if (this._loadedmeta) {
|
||||
triggerFullScene(video, enable);
|
||||
@@ -557,14 +557,14 @@ if (sys.platform !== sys.WECHAT_GAME) {
|
||||
VideoPlayerImpl._polyfill.canPlayType.push(".webm");
|
||||
}
|
||||
|
||||
if (sys.browserType === sys.BROWSER_TYPE_FIREFOX) {
|
||||
if (sys.browserType === sys.BrowserType.FIREFOX) {
|
||||
VideoPlayerImpl._polyfill.autoplayAfterOperation = true;
|
||||
}
|
||||
|
||||
if (
|
||||
sys.OS_ANDROID === sys.os && (
|
||||
sys.browserType === sys.BROWSER_TYPE_SOUGOU ||
|
||||
sys.browserType === sys.BROWSER_TYPE_360
|
||||
sys.browserType === sys.BrowserType.SOUGOU ||
|
||||
sys.browserType === sys.BrowserType.BROWSER_360
|
||||
)
|
||||
) {
|
||||
VideoPlayerImpl._polyfill.zoomInvalid = true;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cocos-creator",
|
||||
"version": "3.0.0",
|
||||
"version": "3.1.1",
|
||||
"description": "Cocos Creator is a cross-platform 2D & 3D game engine written in TypeScript, licensed under MIT.",
|
||||
"homepage": "http://www.cocos.com",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -16,12 +16,12 @@ export class AccelerometerInputSource {
|
||||
private _didAccelerateFunc: (event: DeviceMotionEvent | DeviceOrientationEvent) => void;
|
||||
|
||||
constructor () {
|
||||
this.support = true;
|
||||
this.support = (window.DeviceMotionEvent !== undefined || window.DeviceOrientationEvent !== undefined);
|
||||
|
||||
// init event name
|
||||
this._globalEventClass = window.DeviceMotionEvent || window.DeviceOrientationEvent;
|
||||
// TODO fix DeviceMotionEvent bug on QQ Browser version 4.1 and below.
|
||||
if (system.browserType === BrowserType.QQ) {
|
||||
if (system.browserType === BrowserType.MOBILE_QQ) {
|
||||
this._globalEventClass = window.DeviceOrientationEvent;
|
||||
}
|
||||
this._deviceEventName = this._globalEventClass === window.DeviceMotionEvent ? 'devicemotion' : 'deviceorientation';
|
||||
|
||||
@@ -8,7 +8,7 @@ export class KeyboardInputSource {
|
||||
private _eventTarget: EventTarget = new EventTarget();
|
||||
|
||||
constructor () {
|
||||
this.support = !system.isMobile;
|
||||
this.support = document.documentElement.onkeyup !== undefined;
|
||||
this._registerEvent();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DEBUG, EDITOR } from 'internal:constants';
|
||||
import { EDITOR, TEST } from 'internal:constants';
|
||||
import { MouseCallback, MouseInputEvent, MouseWheelCallback, MouseWheelInputEvent } from 'pal/input';
|
||||
import { system } from 'pal/system';
|
||||
import { EventTarget } from '../../../cocos/core/event/event-target';
|
||||
@@ -16,10 +16,10 @@ export class MouseInputSource {
|
||||
private _preMousePos: Vec2 = new Vec2();
|
||||
|
||||
constructor () {
|
||||
this.support = !system.isMobile && !EDITOR;
|
||||
this.support = !EDITOR && document.documentElement.onmouseup !== undefined;
|
||||
if (this.support) {
|
||||
this._canvas = document.getElementById('GameCanvas') as HTMLCanvasElement;
|
||||
if (!this._canvas && DEBUG) {
|
||||
if (!this._canvas && !TEST) {
|
||||
console.warn('failed to access canvas');
|
||||
}
|
||||
this._registerEvent();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { TouchCallback, TouchData, TouchInputEvent } from 'pal/input';
|
||||
import { system } from 'pal/system';
|
||||
import { DEBUG } from 'internal:constants';
|
||||
import { TEST } from 'internal:constants';
|
||||
import { Rect, Vec2 } from '../../../cocos/core/math';
|
||||
import { EventTarget } from '../../../cocos/core/event/event-target';
|
||||
import { legacyCC } from '../../../cocos/core/global-exports';
|
||||
@@ -12,10 +12,10 @@ export class TouchInputSource {
|
||||
private _eventTarget: EventTarget = new EventTarget();
|
||||
|
||||
constructor () {
|
||||
this.support = system.isMobile;
|
||||
this.support = (document.documentElement.ontouchstart !== undefined || document.ontouchstart !== undefined || navigator.msPointerEnabled);
|
||||
if (this.support) {
|
||||
this._canvas = document.getElementById('GameCanvas') as HTMLCanvasElement;
|
||||
if (!this._canvas && DEBUG) {
|
||||
if (!this._canvas && !TEST) {
|
||||
console.warn('failed to access canvas');
|
||||
}
|
||||
this._registerEvent();
|
||||
|
||||
+7
-15
@@ -119,27 +119,19 @@ minigame.stopAccelerometer = function (res: any) {
|
||||
};
|
||||
// #endregion Accelerometer
|
||||
|
||||
// #region SafeArea
|
||||
minigame.getSafeArea = function () {
|
||||
console.warn('getSafeArea is not supported on this platform');
|
||||
if (minigame.getSystemInfoSync) {
|
||||
const systemInfo = minigame.getSystemInfoSync();
|
||||
return {
|
||||
top: 0,
|
||||
left: 0,
|
||||
bottom: systemInfo.screenHeight,
|
||||
right: systemInfo.screenWidth,
|
||||
width: systemInfo.screenWidth,
|
||||
height: systemInfo.screenHeight,
|
||||
};
|
||||
}
|
||||
const systemInfo = minigame.getSystemInfoSync();
|
||||
return {
|
||||
top: 0,
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
bottom: systemInfo.screenHeight,
|
||||
right: systemInfo.screenWidth,
|
||||
width: systemInfo.screenWidth,
|
||||
height: systemInfo.screenHeight,
|
||||
};
|
||||
};
|
||||
// #endregion SafeArea
|
||||
|
||||
export { minigame };
|
||||
|
||||
+34
-44
@@ -30,40 +30,38 @@ Object.defineProperty(minigame, 'orientation', {
|
||||
// #endregion SystemInfo
|
||||
|
||||
// #region Accelerometer
|
||||
let _accelerometerCb: AccelerometerChangeCallback | undefined;
|
||||
let _customAccelerometerCb: AccelerometerChangeCallback | undefined;
|
||||
let _innerAccelerometerCb: AccelerometerChangeCallback | undefined;
|
||||
minigame.onAccelerometerChange = function (cb: AccelerometerChangeCallback) {
|
||||
minigame.offAccelerometerChange();
|
||||
// onAccelerometerChange would start accelerometer
|
||||
// so we won't call this method here
|
||||
_accelerometerCb = (res: any) => {
|
||||
let x = res.x;
|
||||
let y = res.y;
|
||||
if (minigame.isLandscape) {
|
||||
const orientationFactor = (landscapeOrientation === Orientation.LANDSCAPE_RIGHT ? 1 : -1);
|
||||
const tmp = x;
|
||||
x = -y * orientationFactor;
|
||||
y = tmp * orientationFactor;
|
||||
}
|
||||
// swan.offAccelerometerChange() is not supported.
|
||||
// so we can only register AccelerometerChange callback, but can't unregister.
|
||||
if (!_innerAccelerometerCb) {
|
||||
_innerAccelerometerCb = (res: any) => {
|
||||
let x = res.x;
|
||||
let y = res.y;
|
||||
if (minigame.isLandscape) {
|
||||
const orientationFactor = (landscapeOrientation === Orientation.LANDSCAPE_RIGHT ? 1 : -1);
|
||||
const tmp = x;
|
||||
x = -y * orientationFactor;
|
||||
y = tmp * orientationFactor;
|
||||
}
|
||||
|
||||
const resClone = {
|
||||
x,
|
||||
y,
|
||||
z: res.z,
|
||||
const resClone = {
|
||||
x,
|
||||
y,
|
||||
z: res.z,
|
||||
};
|
||||
_customAccelerometerCb?.(resClone);
|
||||
};
|
||||
cb(resClone);
|
||||
};
|
||||
swan.onAccelerometerChange(_innerAccelerometerCb);
|
||||
// onAccelerometerChange would start accelerometer, need to stop it mannually
|
||||
swan.stopAccelerometer({});
|
||||
}
|
||||
_customAccelerometerCb = cb;
|
||||
};
|
||||
minigame.offAccelerometerChange = function (cb?: AccelerometerChangeCallback) {
|
||||
if (_accelerometerCb) {
|
||||
swan.offAccelerometerChange(_accelerometerCb);
|
||||
_accelerometerCb = undefined;
|
||||
}
|
||||
};
|
||||
minigame.startAccelerometer = function (res: any) {
|
||||
if (_accelerometerCb) {
|
||||
swan.onAccelerometerChange(_accelerometerCb);
|
||||
}
|
||||
swan.startAccelerometer(res);
|
||||
// swan.offAccelerometerChange() is not supported.
|
||||
_customAccelerometerCb = undefined;
|
||||
};
|
||||
// #endregion Accelerometer
|
||||
|
||||
@@ -74,27 +72,19 @@ minigame.createInnerAudioContext = createInnerAudioContextPolyfill(swan, {
|
||||
onSeek: false,
|
||||
});
|
||||
|
||||
// #region SafeArea
|
||||
minigame.getSafeArea = function () {
|
||||
console.warn('getSafeArea is not supported on this platform');
|
||||
if (minigame.getSystemInfoSync) {
|
||||
const systemInfo = minigame.getSystemInfoSync();
|
||||
return {
|
||||
top: 0,
|
||||
left: 0,
|
||||
bottom: systemInfo.screenHeight,
|
||||
right: systemInfo.screenWidth,
|
||||
width: systemInfo.screenWidth,
|
||||
height: systemInfo.screenHeight,
|
||||
};
|
||||
}
|
||||
const systemInfo = minigame.getSystemInfoSync();
|
||||
return {
|
||||
top: 0,
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
bottom: systemInfo.screenHeight,
|
||||
right: systemInfo.screenWidth,
|
||||
width: systemInfo.screenWidth,
|
||||
height: systemInfo.screenHeight,
|
||||
};
|
||||
};
|
||||
// #endregion SafeArea
|
||||
|
||||
export { minigame };
|
||||
|
||||
+12
-12
@@ -1,4 +1,4 @@
|
||||
import { IMiniGame } from 'pal/minigame';
|
||||
import { IMiniGame, SystemInfo } from 'pal/minigame';
|
||||
import { Orientation } from '../system/enum-type/orientation';
|
||||
import { cloneObject, createInnerAudioContextPolyfill } from '../utils';
|
||||
|
||||
@@ -74,21 +74,21 @@ minigame.createInnerAudioContext = createInnerAudioContextPolyfill(tt, {
|
||||
onSeek: true,
|
||||
});
|
||||
|
||||
// safeArea
|
||||
// origin point on the top-left corner
|
||||
// #region SafeArea
|
||||
// FIX_ME: wrong safe area when orientation is landscape left
|
||||
minigame.getSafeArea = function () {
|
||||
let { top, left, bottom, right, width, height } = systemInfo.safeArea;
|
||||
const locSystemInfo = tt.getSystemInfoSync() as SystemInfo;
|
||||
let { top, left, right } = locSystemInfo.safeArea;
|
||||
const { bottom, width, height } = locSystemInfo.safeArea;
|
||||
// HACK: on iOS device, the orientation should mannually rotate
|
||||
if (systemInfo.platform === 'ios' && !minigame.isDevTool && minigame.isLandscape) {
|
||||
const tempData = [right, top, left, bottom, width, height];
|
||||
top = tempData[2];
|
||||
left = tempData[1];
|
||||
bottom = tempData[3];
|
||||
right = tempData[0];
|
||||
height = tempData[5];
|
||||
width = tempData[4];
|
||||
if (locSystemInfo.platform === 'ios' && !minigame.isDevTool && minigame.isLandscape) {
|
||||
const tmpTop = top; const tmpLeft = left; const tmpBottom = bottom; const tmpRight = right; const tmpWidth = width; const tmpHeight = height;
|
||||
top = tmpLeft;
|
||||
left = tmpTop;
|
||||
right = tmpRight - tmpTop;
|
||||
}
|
||||
return { top, left, bottom, right, width, height };
|
||||
};
|
||||
// #endregion SafeArea
|
||||
|
||||
export { minigame };
|
||||
|
||||
+52
-34
@@ -40,6 +40,23 @@ Object.defineProperty(minigame, 'orientation', {
|
||||
return minigame.isLandscape ? landscapeOrientation : Orientation.PORTRAIT;
|
||||
},
|
||||
});
|
||||
|
||||
if (VIVO) {
|
||||
// TODO: need to be handled in ral lib.
|
||||
minigame.getSystemInfoSync = function () {
|
||||
const sys = ral.getSystemInfoSync() as SystemInfo;
|
||||
// on VIVO, windowWidth should be windowHeight when it is landscape
|
||||
sys.windowWidth = sys.screenWidth;
|
||||
sys.windowHeight = sys.screenHeight;
|
||||
return sys;
|
||||
};
|
||||
} else if (LINKSURE) {
|
||||
// TODO: update system info when view resized, currently the resize callback is not supported.
|
||||
const cachedSystemInfo = ral.getSystemInfoSync() as SystemInfo;
|
||||
minigame.getSystemInfoSync = function () {
|
||||
return cachedSystemInfo;
|
||||
};
|
||||
}
|
||||
// #endregion SystemInfo
|
||||
|
||||
// #region Accelerometer
|
||||
@@ -64,40 +81,41 @@ minigame.onAccelerometerChange = function (cb) {
|
||||
};
|
||||
// #endregion Accelerometer
|
||||
|
||||
minigame.createInnerAudioContext = createInnerAudioContextPolyfill(ral, {
|
||||
onPlay: true, // polyfill for vivo
|
||||
onPause: true,
|
||||
onStop: true,
|
||||
onSeek: true,
|
||||
});
|
||||
|
||||
// safeArea
|
||||
// origin point on the top-left corner
|
||||
// FIX_ME: wrong safe area when orientation is landscape left
|
||||
minigame.getSafeArea = function () {
|
||||
let { top, left, bottom, right, width, height } = systemInfo.safeArea;
|
||||
// HACK: on iOS device, the orientation should mannually rotate
|
||||
if (systemInfo.platform === 'ios' && !minigame.isDevTool && minigame.isLandscape) {
|
||||
const tempData = [right, top, left, bottom, width, height];
|
||||
top = systemInfo.screenHeight - tempData[0];
|
||||
left = tempData[1];
|
||||
bottom = systemInfo.screenHeight - tempData[2];
|
||||
right = tempData[3];
|
||||
height = tempData[4];
|
||||
width = tempData[5];
|
||||
}
|
||||
return { top, left, bottom, right, width, height };
|
||||
};
|
||||
|
||||
if (VIVO) {
|
||||
// TODO: need to be handled in ral lib.
|
||||
minigame.getSystemInfoSync = function () {
|
||||
const sys = ral.getSystemInfoSync() as SystemInfo;
|
||||
// on VIVO, windowWidth should be windowHeight when it is landscape
|
||||
sys.windowWidth = sys.screenWidth;
|
||||
sys.windowHeight = sys.screenHeight;
|
||||
return sys;
|
||||
};
|
||||
// NOTE: Audio playing crash on COCOSPLAY, need to play audio asynchronously.
|
||||
if (COCOSPLAY) {
|
||||
minigame.createInnerAudioContext = createInnerAudioContextPolyfill(ral, {
|
||||
onPlay: true, // polyfill for vivo
|
||||
onPause: true,
|
||||
onStop: true,
|
||||
onSeek: true,
|
||||
}, true);
|
||||
} else {
|
||||
minigame.createInnerAudioContext = createInnerAudioContextPolyfill(ral, {
|
||||
onPlay: true, // polyfill for vivo
|
||||
onPause: true,
|
||||
onStop: true,
|
||||
onSeek: true,
|
||||
});
|
||||
}
|
||||
|
||||
// #region SafeArea
|
||||
minigame.getSafeArea = function () {
|
||||
const locSystemInfo = ral.getSystemInfoSync() as SystemInfo;
|
||||
if (locSystemInfo.safeArea) {
|
||||
return locSystemInfo.safeArea;
|
||||
} else {
|
||||
console.warn('getSafeArea is not supported on this platform');
|
||||
const systemInfo = minigame.getSystemInfoSync();
|
||||
return {
|
||||
top: 0,
|
||||
left: 0,
|
||||
bottom: systemInfo.screenHeight,
|
||||
right: systemInfo.screenWidth,
|
||||
width: systemInfo.screenWidth,
|
||||
height: systemInfo.screenHeight,
|
||||
};
|
||||
}
|
||||
};
|
||||
// #endregion SafeArea
|
||||
|
||||
export { minigame };
|
||||
|
||||
+42
-80
@@ -1,4 +1,4 @@
|
||||
import { IMiniGame } from 'pal/minigame';
|
||||
import { IMiniGame, SystemInfo } from 'pal/minigame';
|
||||
import { Orientation } from '../system/enum-type/orientation';
|
||||
import { cloneObject, createInnerAudioContextPolyfill } from '../utils';
|
||||
|
||||
@@ -9,12 +9,42 @@ const minigame: IMiniGame = {};
|
||||
cloneObject(minigame, wx);
|
||||
|
||||
// #region SystemInfo
|
||||
let _cachedSystemInfo: SystemInfo = wx.getSystemInfoSync();
|
||||
// @ts-expect-error TODO: move into minigame.d.ts
|
||||
minigame.testAndUpdateSystemInfoCache = function (testAmount: number, testInterval: number) {
|
||||
let successfullyTestTimes = 0;
|
||||
let intervalTimer: number | null = null;
|
||||
function testCachedSystemInfo () {
|
||||
const currentSystemInfo = wx.getSystemInfoSync() as SystemInfo;
|
||||
if (_cachedSystemInfo.screenWidth === currentSystemInfo.screenWidth && _cachedSystemInfo.screenHeight === currentSystemInfo.screenHeight) {
|
||||
if (++successfullyTestTimes >= testAmount && intervalTimer !== null) {
|
||||
clearInterval(intervalTimer);
|
||||
intervalTimer = null;
|
||||
}
|
||||
} else {
|
||||
successfullyTestTimes = 0;
|
||||
}
|
||||
_cachedSystemInfo = currentSystemInfo;
|
||||
}
|
||||
intervalTimer = setInterval(testCachedSystemInfo, testInterval);
|
||||
};
|
||||
// @ts-expect-error TODO: update when view resize
|
||||
minigame.testAndUpdateSystemInfoCache(10, 500);
|
||||
minigame.getSystemInfoSync = function () {
|
||||
return _cachedSystemInfo;
|
||||
};
|
||||
|
||||
const systemInfo = minigame.getSystemInfoSync();
|
||||
minigame.isDevTool = (systemInfo.platform === 'devtools');
|
||||
// NOTE: size and orientation info is wrong at the init phase, especially on iOS device
|
||||
Object.defineProperty(minigame, 'isLandscape', {
|
||||
get () {
|
||||
return systemInfo.deviceOrientation ? (systemInfo.deviceOrientation === 'landscape') : (systemInfo.screenWidth > systemInfo.screenHeight);
|
||||
const locSystemInfo = wx.getSystemInfoSync() as SystemInfo;
|
||||
if (typeof locSystemInfo.deviceOrientation === 'string') {
|
||||
return locSystemInfo.deviceOrientation.startsWith('landscape');
|
||||
} else {
|
||||
return locSystemInfo.screenWidth > locSystemInfo.screenHeight;
|
||||
}
|
||||
},
|
||||
});
|
||||
// init landscapeOrientation as LANDSCAPE_RIGHT
|
||||
@@ -75,87 +105,19 @@ minigame.startAccelerometer = function (res: any) {
|
||||
};
|
||||
// #endregion Accelerometer
|
||||
|
||||
// minigame.createInnerAudioContext = createInnerAudioContextPolyfill(wx, {
|
||||
// onPlay: true,
|
||||
// onPause: true,
|
||||
// onStop: true,
|
||||
// onSeek: false,
|
||||
// });
|
||||
minigame.createInnerAudioContext = createInnerAudioContextPolyfill(wx, {
|
||||
onPlay: true,
|
||||
onPause: true,
|
||||
onStop: true,
|
||||
onSeek: false,
|
||||
}, true);
|
||||
|
||||
// TODO: move to createInnerAudioContextPolyfill()
|
||||
minigame.createInnerAudioContext = function () {
|
||||
const audioContext: InnerAudioContext = wx.createInnerAudioContext();
|
||||
|
||||
// add polyfill if onPlay method doesn't work this platform
|
||||
const originalPlay = audioContext.play;
|
||||
let _onPlayCB: (()=> void) | null = null;
|
||||
Object.defineProperty(audioContext, 'onPlay', {
|
||||
value (cb: ()=> void) {
|
||||
_onPlayCB = cb;
|
||||
},
|
||||
});
|
||||
Object.defineProperty(audioContext, 'play', {
|
||||
value () {
|
||||
originalPlay.call(audioContext);
|
||||
if (_onPlayCB) {
|
||||
setTimeout(_onPlayCB, 0);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// add polyfill if onPause method doesn't work this platform
|
||||
const originalPause = audioContext.pause;
|
||||
let _onPauseCB: (()=> void) | null = null;
|
||||
Object.defineProperty(audioContext, 'onPause', {
|
||||
value (cb: ()=> void) {
|
||||
_onPauseCB = cb;
|
||||
},
|
||||
});
|
||||
Object.defineProperty(audioContext, 'pause', {
|
||||
value () {
|
||||
originalPause.call(audioContext);
|
||||
if (_onPauseCB) {
|
||||
setTimeout(_onPauseCB, 0);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// add polyfill if onStop method doesn't work on this platform
|
||||
const originalStop = audioContext.stop;
|
||||
let _onStopCB: (()=> void) | null = null;
|
||||
Object.defineProperty(audioContext, 'onStop', {
|
||||
value (cb: ()=> void) {
|
||||
_onStopCB = cb;
|
||||
},
|
||||
});
|
||||
Object.defineProperty(audioContext, 'stop', {
|
||||
value () {
|
||||
originalStop.call(audioContext);
|
||||
if (_onStopCB) {
|
||||
setTimeout(_onStopCB, 0);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
return audioContext;
|
||||
};
|
||||
|
||||
// safeArea
|
||||
// origin point on the top-left corner
|
||||
// #region SafeArea
|
||||
// FIX_ME: wrong safe area when orientation is landscape left
|
||||
minigame.getSafeArea = function () {
|
||||
let { top, left, bottom, right, width, height } = systemInfo.safeArea;
|
||||
// HACK: on iOS device, the orientation should mannually rotate
|
||||
if (systemInfo.platform === 'ios' && !minigame.isDevTool && minigame.isLandscape) {
|
||||
const tempData = [right, top, left, bottom, width, height];
|
||||
top = systemInfo.screenHeight - tempData[0];
|
||||
left = tempData[1];
|
||||
bottom = systemInfo.screenHeight - tempData[2];
|
||||
right = tempData[3];
|
||||
height = tempData[4];
|
||||
width = tempData[5];
|
||||
}
|
||||
return { top, left, bottom, right, width, height };
|
||||
const locSystemInfo = wx.getSystemInfoSync() as SystemInfo;
|
||||
return locSystemInfo.safeArea;
|
||||
};
|
||||
// #endregion SafeArea
|
||||
|
||||
export { minigame };
|
||||
|
||||
+23
-15
@@ -88,34 +88,42 @@ minigame.offAccelerometerChange = function (cb?: AccelerometerChangeCallback) {
|
||||
};
|
||||
// #endregion Accelerometer
|
||||
|
||||
// #region InnerAudioContext
|
||||
minigame.createInnerAudioContext = createInnerAudioContextPolyfill(qg, {
|
||||
onPlay: true,
|
||||
onPause: true,
|
||||
onStop: true,
|
||||
onSeek: false,
|
||||
});
|
||||
const originalCreateInnerAudioContext = minigame.createInnerAudioContext;
|
||||
minigame.createInnerAudioContext = function () {
|
||||
const audioContext = originalCreateInnerAudioContext.call(minigame);
|
||||
const originalStop = audioContext.stop;
|
||||
Object.defineProperty(audioContext, 'stop', {
|
||||
configurable: true,
|
||||
value () {
|
||||
// NOTE: stop won't seek to 0 when audio is paused on Xiaomi platform.
|
||||
audioContext.seek(0);
|
||||
originalStop.call(audioContext);
|
||||
},
|
||||
});
|
||||
return audioContext;
|
||||
};
|
||||
// #endregion InnerAudioContext
|
||||
|
||||
// #region SafeArea
|
||||
minigame.getSafeArea = function () {
|
||||
console.warn('getSafeArea is not supported on this platform');
|
||||
if (minigame.getSystemInfoSync) {
|
||||
const systemInfo = minigame.getSystemInfoSync();
|
||||
return {
|
||||
top: 0,
|
||||
left: 0,
|
||||
bottom: systemInfo.screenHeight,
|
||||
right: systemInfo.screenWidth,
|
||||
width: systemInfo.screenWidth,
|
||||
height: systemInfo.screenHeight,
|
||||
};
|
||||
}
|
||||
const systemInfo = minigame.getSystemInfoSync();
|
||||
return {
|
||||
top: 0,
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
bottom: systemInfo.screenHeight,
|
||||
right: systemInfo.screenWidth,
|
||||
width: systemInfo.screenWidth,
|
||||
height: systemInfo.screenHeight,
|
||||
};
|
||||
};
|
||||
// #endregion SafeArea
|
||||
|
||||
export { minigame };
|
||||
|
||||
@@ -133,7 +133,31 @@ class System {
|
||||
return minigame.orientation;
|
||||
}
|
||||
public getSafeAreaEdge (): SafeAreaEdge {
|
||||
throw new Error('TODO');
|
||||
const minigameSafeArea = minigame.getSafeArea();
|
||||
const viewSize = this.getViewSize();
|
||||
let topEdge = minigameSafeArea.top;
|
||||
let bottomEdge = viewSize.height - minigameSafeArea.bottom;
|
||||
let leftEdge = minigameSafeArea.left;
|
||||
let rightEdge = viewSize.width - minigameSafeArea.right;
|
||||
const orientation = this.getOrientation();
|
||||
// Make it symmetrical.
|
||||
if (orientation === Orientation.PORTRAIT) {
|
||||
if (topEdge < bottomEdge) {
|
||||
topEdge = bottomEdge;
|
||||
} else {
|
||||
bottomEdge = topEdge;
|
||||
}
|
||||
} else if (leftEdge < rightEdge) {
|
||||
leftEdge = rightEdge;
|
||||
} else {
|
||||
rightEdge = leftEdge;
|
||||
}
|
||||
return {
|
||||
top: topEdge,
|
||||
bottom: bottomEdge,
|
||||
left: leftEdge,
|
||||
right: rightEdge,
|
||||
};
|
||||
}
|
||||
public getBatteryLevel (): number {
|
||||
return minigame.getBatteryInfoSync().level / 100;
|
||||
|
||||
@@ -122,8 +122,30 @@ class System {
|
||||
return orientationMap[jsb.device.getDeviceOrientation()];
|
||||
}
|
||||
public getSafeAreaEdge (): SafeAreaEdge {
|
||||
// jsb.device.getSafeAreaEdge()
|
||||
throw new Error('TODO');
|
||||
const nativeSafeArea = jsb.device.getSafeAreaEdge();
|
||||
let topEdge = nativeSafeArea.x;
|
||||
let bottomEdge = nativeSafeArea.z;
|
||||
let leftEdge = nativeSafeArea.y;
|
||||
let rightEdge = nativeSafeArea.w;
|
||||
const orientation = this.getOrientation();
|
||||
// Make it symmetrical.
|
||||
if (orientation === Orientation.PORTRAIT) {
|
||||
if (topEdge < bottomEdge) {
|
||||
topEdge = bottomEdge;
|
||||
} else {
|
||||
bottomEdge = topEdge;
|
||||
}
|
||||
} else if (leftEdge < rightEdge) {
|
||||
leftEdge = rightEdge;
|
||||
} else {
|
||||
rightEdge = leftEdge;
|
||||
}
|
||||
return {
|
||||
top: topEdge,
|
||||
bottom: bottomEdge,
|
||||
left: leftEdge,
|
||||
right: rightEdge,
|
||||
};
|
||||
}
|
||||
public getBatteryLevel (): number {
|
||||
return jsb.device.getBatteryLevel();
|
||||
|
||||
@@ -271,7 +271,12 @@ class System {
|
||||
throw new Error('TODO');
|
||||
}
|
||||
public getSafeAreaEdge (): SafeAreaEdge {
|
||||
throw new Error('TODO');
|
||||
return {
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
};
|
||||
}
|
||||
public getBatteryLevel (): number {
|
||||
if (this._battery) {
|
||||
|
||||
+38
-5
@@ -21,9 +21,10 @@ type InnerAudioContextPolyfillConfig = {
|
||||
* This method is to create a polyfill on minigame platform when the innerAudioContext callback doesn't work.
|
||||
* @param minigameEnv Specify the minigame enviroment such as `wx`, `swan` etc.
|
||||
* @param polyfillConfig Specify the field, if it's true, the polyfill callback will be applied.
|
||||
* @param isAsynchronous Specify whether the callback is called asynchronous.
|
||||
* @returns A polyfilled createInnerAudioContext method.
|
||||
*/
|
||||
export function createInnerAudioContextPolyfill (minigameEnv: any, polyfillConfig: InnerAudioContextPolyfillConfig) {
|
||||
export function createInnerAudioContextPolyfill (minigameEnv: any, polyfillConfig: InnerAudioContextPolyfillConfig, isAsynchronous = false) {
|
||||
return () => {
|
||||
const audioContext: InnerAudioContext = minigameEnv.createInnerAudioContext();
|
||||
|
||||
@@ -32,14 +33,22 @@ export function createInnerAudioContextPolyfill (minigameEnv: any, polyfillConfi
|
||||
const originalPlay = audioContext.play;
|
||||
let _onPlayCB: (()=> void) | null = null;
|
||||
Object.defineProperty(audioContext, 'onPlay', {
|
||||
configurable: true,
|
||||
value (cb: ()=> void) {
|
||||
_onPlayCB = cb;
|
||||
},
|
||||
});
|
||||
Object.defineProperty(audioContext, 'play', {
|
||||
configurable: true,
|
||||
value () {
|
||||
originalPlay.call(audioContext);
|
||||
_onPlayCB?.();
|
||||
if (_onPlayCB) {
|
||||
if (isAsynchronous) {
|
||||
setTimeout(_onPlayCB, 0);
|
||||
} else {
|
||||
_onPlayCB();
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -49,14 +58,22 @@ export function createInnerAudioContextPolyfill (minigameEnv: any, polyfillConfi
|
||||
const originalPause = audioContext.pause;
|
||||
let _onPauseCB: (()=> void) | null = null;
|
||||
Object.defineProperty(audioContext, 'onPause', {
|
||||
configurable: true,
|
||||
value (cb: ()=> void) {
|
||||
_onPauseCB = cb;
|
||||
},
|
||||
});
|
||||
Object.defineProperty(audioContext, 'pause', {
|
||||
configurable: true,
|
||||
value () {
|
||||
originalPause.call(audioContext);
|
||||
_onPauseCB?.();
|
||||
if (_onPauseCB) {
|
||||
if (isAsynchronous) {
|
||||
setTimeout(_onPauseCB, 0);
|
||||
} else {
|
||||
_onPauseCB();
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -66,14 +83,22 @@ export function createInnerAudioContextPolyfill (minigameEnv: any, polyfillConfi
|
||||
const originalStop = audioContext.stop;
|
||||
let _onStopCB: (()=> void) | null = null;
|
||||
Object.defineProperty(audioContext, 'onStop', {
|
||||
configurable: true,
|
||||
value (cb: ()=> void) {
|
||||
_onStopCB = cb;
|
||||
},
|
||||
});
|
||||
Object.defineProperty(audioContext, 'stop', {
|
||||
configurable: true,
|
||||
value () {
|
||||
originalStop.call(audioContext);
|
||||
_onStopCB?.();
|
||||
if (_onStopCB) {
|
||||
if (isAsynchronous) {
|
||||
setTimeout(_onStopCB, 0);
|
||||
} else {
|
||||
_onStopCB();
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -83,14 +108,22 @@ export function createInnerAudioContextPolyfill (minigameEnv: any, polyfillConfi
|
||||
const originalSeek = audioContext.seek;
|
||||
let _onSeekCB: (()=> void) | null = null;
|
||||
Object.defineProperty(audioContext, 'onSeeked', {
|
||||
configurable: true,
|
||||
value (cb: ()=> void) {
|
||||
_onSeekCB = cb;
|
||||
},
|
||||
});
|
||||
Object.defineProperty(audioContext, 'seek', {
|
||||
configurable: true,
|
||||
value (time: number) {
|
||||
originalSeek.call(audioContext, time);
|
||||
_onSeekCB?.();
|
||||
if (_onSeekCB) {
|
||||
if (isAsynchronous) {
|
||||
setTimeout(_onSeekCB, 0);
|
||||
} else {
|
||||
_onSeekCB();
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ var cacheManager = {
|
||||
caches.sort(function (a, b) {
|
||||
return a.lastTime - b.lastTime;
|
||||
});
|
||||
caches.length = Math.floor(this.cachedFiles.count / 3);
|
||||
caches.length = Math.floor(caches.length / 3);
|
||||
if (caches.length === 0) return;
|
||||
for (var i = 0, l = caches.length; i < l; i++) {
|
||||
this.cachedFiles.remove(caches[i].originUrl);
|
||||
|
||||
@@ -211,7 +211,7 @@ function downloadBundle (nameOrUrl, options, onComplete) {
|
||||
// PATCH: for android alipay version before v10.1.95 (v10.1.95 included)
|
||||
// to remove in the future
|
||||
let sys = cc.sys;
|
||||
if (sys.platform === sys.ALIPAY_MINI_GAME && sys.os === sys.OS_ANDROID) {
|
||||
if (sys.platform === sys.Platform.ALIPAY_MINI_GAME && sys.os === sys.OS.ANDROID) {
|
||||
let resPath = unzipPath + 'res/';
|
||||
if (fs.accessSync({path: resPath})) {
|
||||
data.base = resPath;
|
||||
|
||||
@@ -113,21 +113,4 @@ if (window.__globalAdapter) {
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
// safeArea
|
||||
// origin point on the top-left corner
|
||||
globalAdapter.getSafeArea = function () {
|
||||
let { top, left, bottom, right, width, height } = systemInfo.safeArea;
|
||||
// HACK: on iOS device, the orientation should mannually rotate
|
||||
if (systemInfo.platform === 'ios' && !globalAdapter.isDevTool && isLandscape) {
|
||||
let tempData = [right, top, left, bottom, width, height];
|
||||
top = tempData[2];
|
||||
left = tempData[1];
|
||||
bottom = tempData[3];
|
||||
right = tempData[0];
|
||||
height = tempData[5];
|
||||
width = tempData[4];
|
||||
}
|
||||
return { top, left, bottom, right, width, height };
|
||||
}
|
||||
}
|
||||
@@ -117,21 +117,4 @@ if (window.__globalAdapter) {
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
// safeArea
|
||||
// origin point on the top-left corner
|
||||
globalAdapter.getSafeArea = function () {
|
||||
let { top, left, bottom, right, width, height } = systemInfo.safeArea;
|
||||
// HACK: on iOS device, the orientation should mannually rotate
|
||||
if (systemInfo.platform === 'ios' && !globalAdapter.isDevTool && isLandscape) {
|
||||
let tempData = [right, top, left, bottom, width, height];
|
||||
top = windowHeight - tempData[0];
|
||||
left = tempData[1];
|
||||
bottom = windowHeight - tempData[2];
|
||||
right = tempData[3];
|
||||
height = tempData[4];
|
||||
width = tempData[5];
|
||||
}
|
||||
return { top, left, bottom, right, width, height };
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,6 @@ require('./jsb-loader.js');
|
||||
require('./jsb-videoplayer.js');
|
||||
require('./jsb-webview.js');
|
||||
require('./jsb-editbox.js');
|
||||
require('./jsb-safearea.js');
|
||||
require('./jsb-editor-support.js')
|
||||
require('./jsb-spine-skeleton.js')
|
||||
require('./jsb-dragonbones.js')
|
||||
|
||||
@@ -108,7 +108,7 @@ var cacheManager = {
|
||||
caches.sort(function (a, b) {
|
||||
return a.lastTime - b.lastTime;
|
||||
});
|
||||
caches.length = Math.floor(this.cachedFiles.count / 3);
|
||||
caches.length = Math.floor(caches.length / 3);
|
||||
if (caches.length === 0) return;
|
||||
for (var i = 0, l = caches.length; i < l; i++) {
|
||||
this.cachedFiles.remove(caches[i].originUrl);
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
Object.defineProperty(jsb, "reflection", {
|
||||
get: function () {
|
||||
if (jsb.__bridge !== undefined) return jsb.__bridge;
|
||||
if (window.JavascriptJavaBridge && cc.sys.os === cc.sys.OS_ANDROID) {
|
||||
if (window.JavascriptJavaBridge && cc.sys.os === cc.sys.OS.ANDROID) {
|
||||
jsb.__bridge = new JavascriptJavaBridge();
|
||||
} else if (window.JavaScriptObjCBridge && (cc.sys.os === cc.sys.OS_IOS || cc.sys.os === cc.sys.OS_OSX)) {
|
||||
} else if (window.JavaScriptObjCBridge && (cc.sys.os === cc.sys.OS.IOS || cc.sys.os === cc.sys.OS.OSX)) {
|
||||
jsb.__bridge = new JavaScriptObjCBridge();
|
||||
}else {
|
||||
jsb.__bridge = null;
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
let SafeArea = cc.SafeArea;
|
||||
if (SafeArea) {
|
||||
let _onEnable = SafeArea.prototype.onEnable;
|
||||
let _onDisable = SafeArea.prototype.onDisable;
|
||||
Object.assign(SafeArea.prototype, {
|
||||
onEnable(){
|
||||
_onEnable.call(this);
|
||||
this._adaptSafeAreaChangeWithThis = this.adaptSafeAreaChange.bind(this);
|
||||
this._updateAreaWithThis = this.adaptSafeAreaChange.bind(this);
|
||||
window.addEventListener('orientationchange', this._adaptSafeAreaChangeWithThis);
|
||||
window.addEventListener('safearea-change', this._updateAreaWithThis);
|
||||
},
|
||||
|
||||
onDisable(){
|
||||
_onDisable.call(this);
|
||||
window.removeEventListener('orientationchange', this._adaptSafeAreaChangeWithThis);
|
||||
window.removeEventListener('safearea-change', this._updateAreaWithThis);
|
||||
},
|
||||
|
||||
adaptSafeAreaChange(){
|
||||
if (JSB && (cc.sys.os === cc.sys.OS_IOS || cc.sys.os === cc.sys.OS_ANDROID)) {
|
||||
setTimeout(() => {
|
||||
this.updateArea();
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ var cacheManager = {
|
||||
caches.sort(function (a, b) {
|
||||
return a.lastTime - b.lastTime;
|
||||
});
|
||||
caches.length = Math.floor(this.cachedFiles.count / 3);
|
||||
caches.length = Math.floor(caches.length / 3);
|
||||
if (caches.length === 0) return;
|
||||
for (var i = 0, l = caches.length; i < l; i++) {
|
||||
this.cachedFiles.remove(caches[i].originUrl);
|
||||
|
||||
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user