switch to eslint (#7727)

* switch to eslint

* eslint: extends airbnb
This commit is contained in:
Yun Hsiao Wu
2020-11-09 10:19:12 +08:00
committed by GitHub
parent 676c267150
commit 32598c25cb
172 changed files with 5698 additions and 4687 deletions
+1 -1
View File
@@ -9,4 +9,4 @@ end_of_line = lf
indent_size = 4 indent_size = 4
indent_style = space indent_style = space
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
-173
View File
@@ -1,173 +0,0 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"extends": "plugin:@typescript-eslint/recommended",
"plugins": [
"@typescript-eslint"
],
"settings": {
"import/resolver": {
"node": {
"extensions": [
".js",
".jsx",
".ts",
".tsx",
".d.ts"
]
}
}
},
"rules": {
"quotes": "off",//["warn", "single"],
"no-console": "warn",
"space-before-function-paren": "warn",
"max-len": [
"warn",
160
],
"camelcase": "off",
"indent": "off",
"no-empty-function": "off",
"no-extra-parens": "off",
"semi": "off",
"sort-imports": ["warn", {
"memberSyntaxSortOrder": ["all", "single", "multiple", "none"]
}],
"@typescript-eslint/adjacent-overload-signatures": "off",
"@typescript-eslint/array-type": ["warn", {
"default": "array"
}],
"@typescript-eslint/await-thenable": "off",
"@typescript-eslint/ban-ts-ignore": "warn",
"@typescript-eslint/ban-types": ["warn", {
"types": {
"Object": "Use {} instead"
}
}],
"@typescript-eslint/camelcase": ["error", {
"allow": [
"^_[a-z]",
"^[a-zA-Z]"
]
}],
"@typescript-eslint/class-name-casing": "warn",
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-member-accessibility": ["warn", {
"accessibility": "explicit",
"overrides": {
"constructors": "off",
"accessors": "off"
}
}],
"@typescript-eslint/func-call-spacing": "warn",
"@typescript-eslint/generic-type-naming": "off",
"@typescript-eslint/indent": ["warn", 4],
"@typescript-eslint/interface-name-prefix": "off",//["warn", "never"],
"@typescript-eslint/member-delimiter-style": ["warn", {
"multiline": {
"delimiter": "semi",
"requireLast": true
},
"singleline": {
"delimiter": "semi"
}
}],
"@typescript-eslint/member-naming": ["warn", {
"private": "^_"
}],
"@typescript-eslint/member-ordering": ["warn", {
"default": [
"public-static-field",
"protected-static-field",
"private-static-field",
"static-field",
"public-instance-field",
"protected-instance-field",
"private-instance-field",
"public-field",
"protected-field",
"private-field",
"instance-field",
"field",
"constructor",
"public-static-method",
"protected-static-method",
"private-static-method",
"static-method",
"public-instance-method",
"protected-instance-method",
"private-instance-method",
"public-method",
"protected-method",
"private-method",
"instance-method",
"method"
]
}],
"@typescript-eslint/no-array-constructor": ["error"],
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-extra-parens": "off",
"@typescript-eslint/no-extraneous-class": "warn",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-for-in-array": "warn",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-magic-numbers": ["off", {
"ignoreNumericLiteralTypes": true,
"ignoreEnums": true
}],
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-misused-promises": "error",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-this-alias": "warn",
"@typescript-eslint/no-type-alias": "off",
"@typescript-eslint/no-unnecessary-qualifier": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "warn",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-useless-constructor": "off",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "off",
"@typescript-eslint/prefer-function-type": "off",
"@typescript-eslint/prefer-includes": "warn",
"@typescript-eslint/prefer-namespace-keyword": "off",
"@typescript-eslint/prefer-readonly": "off",
"@typescript-eslint/prefer-regexp-exec": "warn",
"@typescript-eslint/prefer-string-starts-ends-with": "warn",
"@typescript-eslint/promise-function-async": "off",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/require-await": "warn",
"@typescript-eslint/restrict-plus-operands": "off",
"@typescript-eslint/semi": "error",
"@typescript-eslint/strict-boolean-expressions": "off",
"@typescript-eslint/triple-slash-reference": "error",
"@typescript-eslint/type-annotation-spacing": "warn",
"@typescript-eslint/typedef": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/unified-signatures": "warn"
},
"env": {
"browser": true,
"node": true,
"es6": true,
"jest": true
},
"globals": {
"cc": false,
"wx": false,
"Editor": false,
"_Scene": false,
"_ccsg": false
}
}
+104
View File
@@ -0,0 +1,104 @@
root: true
parser: '@typescript-eslint/parser'
parserOptions:
project: ./tsconfig.json
extends:
- eslint:recommended
- airbnb-base
- plugin:@typescript-eslint/recommended
- plugin:@typescript-eslint/recommended-requiring-type-checking
plugins:
- '@typescript-eslint'
settings:
import/resolver:
node:
extensions:
- .js
- .jsx
- .ts
- .tsx
- .d.ts
env:
browser: true
node: true
es6: true
jest: true
globals:
cc: false
wx: false
Editor: false
_Scene: false
_ccsg: false
rules:
# https://eslint.org/docs/rules/
# https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin
##### RECOMMENDED RULE OVERRIDES #####
camelcase: off # underscores may come in handy in some cases
eqeqeq: warn # important check missing from recommended
keyword-spacing: warn # we require this explicitly
no-multi-spaces: off # useful for manually align some expression across lines
prefer-rest-params: off # we need ES5 to be fast too
prefer-spread: off # we need ES5 to be fast too
space-before-function-paren: [warn, always] # we require this explicitly
##### AIRBNB-SPECIFIC RULE OVERRIDES #####
class-methods-use-this: off # so empty functions could work
guard-for-in: off # for-in is a efficient choice for plain objects
import/export: off # so export declare namespace could work
import/extensions: off # typescriptor doesn't support this
import/no-unresolved: off # TODO: fix internal modules
import/prefer-default-export: off # prefer seperate exports
indent: [warn, 4] # we use 4-space convention
lines-between-class-members: off # be more lenient on member declarations
max-classes-per-file: off # helper classes are common
max-len: [warn, 150] # more lenient on max length per line
new-cap: off # some class still doesn't follow this yet
no-underscore-dangle: off # allow underscores
no-plusplus: off # allow increment/decrement operators
no-console: off # allow console statements
no-continue: off # allow unlabeled continues
no-multi-assign: off # it is handy sometimes
no-param-reassign: off # the output object is passed as parameters all the time
no-restricted-syntax: off # for-in is a efficient choice for plain objects
no-return-assign: off # it is handy sometimes
no-shadow: off # TODO: this throws false-positives?
no-sequences: off # it is handy sometimes
no-bitwise: off # we use this extensively
no-use-before-define: off # just too much work
no-useless-constructor: off # gives false-positives for empty constructor with parameter properties
##### TYPESCRIPT-SPECIFIC RULE OVERRIDES #####
# TODO: this is just too much work
'@typescript-eslint/explicit-module-boundary-types': off
# TODO: sadly we still rely heavily on legacyCC
'@typescript-eslint/no-unsafe-assignment': off
'@typescript-eslint/no-unsafe-call': off
'@typescript-eslint/no-unsafe-member-access': off
'@typescript-eslint/unbound-method': off # we exploit prototype methods sometimes to acheive better performace
'@typescript-eslint/no-explicit-any': off # still relevant for some heavily templated usages
'@typescript-eslint/no-empty-function': off # may become useful in some parent classes
'@typescript-eslint/no-unused-vars': off # may become useful in some parent classes
'@typescript-eslint/no-non-null-assertion': off # sometimes we just know better than the compiler
'@typescript-eslint/no-namespace': [warn, { # we need to declare static properties
allowDeclarations: true,
allowDefinitionFiles: true
}]
'@typescript-eslint/restrict-template-expressions': [warn, { # concatenations of different types are common, e.g. hash calculations
allowNumber: true,
allowBoolean: true
}]
-42
View File
@@ -1,42 +0,0 @@
{
"node": true,
"esnext": true,
"bitwise": false,
"camelcase": false,
"curly": false,
"eqeqeq": true,
"immed": true,
"indent": 4,
"latedef": false,
"newcap": false,
"noarg": true,
"quotmark": "single",
"undef": true,
"unused": true,
"strict": false,
"predef": [
"window",
"document",
"Image",
"unused",
"Editor",
"EditorUI",
"Helper",
"_Scene",
"Polymer",
"sinon",
"after",
"afterAll",
"afterEach",
"assert",
"before",
"beforeAll",
"beforeEach",
"describe",
"expect",
"it",
"cc",
"wx",
"_ccsg"
]
}
+4 -1
View File
@@ -15,5 +15,8 @@
"eslint.validate": [ "eslint.validate": [
"javascript", "javascript",
"typescript" "typescript"
] ],
"editor.codeActionsOnSave": {
"source.fixAll": true,
},
} }
+3 -2
View File
@@ -25,6 +25,7 @@
*/ */
declare const gfx: any; declare const gfx: any;
declare const global: any;
interface Window { interface Window {
@@ -62,7 +63,7 @@ interface HTMLElement{
} }
type ActiveXObject = new (s: string) => any; type ActiveXObject = new (s: string) => any;
declare var ActiveXObject: ActiveXObject; declare const ActiveXObject: ActiveXObject;
declare type CompareFunction<T> = (a: T, b: T) => number; declare type CompareFunction<T> = (a: T, b: T) => number;
@@ -81,7 +82,7 @@ declare interface IWritableArrayLike<T> {
[index: number]: T; [index: number]: T;
} }
declare type Constructor<T = {}> = new(...args: any[]) => T; declare type Constructor<T = unknown> = new(...args: any[]) => T;
declare type Mutable<T> = { -readonly [P in keyof T]: T[P] }; declare type Mutable<T> = { -readonly [P in keyof T]: T[P] };
+10 -4
View File
@@ -28,8 +28,10 @@
* @module component/audio * @module component/audio
*/ */
import {
ccclass, type, serializable, override,
} from 'cc.decorator';
import { Asset } from '../../core/assets/asset'; import { Asset } from '../../core/assets/asset';
import { ccclass, type, serializable, override } from 'cc.decorator';
import { Enum } from '../../core/value-types'; import { Enum } from '../../core/value-types';
import { AudioPlayer, PlayingState } from './player'; import { AudioPlayer, PlayingState } from './player';
import { AudioPlayerDOM } from './player-dom'; import { AudioPlayerDOM } from './player-dom';
@@ -57,7 +59,6 @@ export const AudioType = Enum({
*/ */
@ccclass('cc.AudioClip') @ccclass('cc.AudioClip')
export class AudioClip extends Asset { export class AudioClip extends Asset {
public static PlayingState = PlayingState; public static PlayingState = PlayingState;
public static AudioType = AudioType; public static AudioType = AudioType;
public static preventDeferredLoadDependents = true; public static preventDeferredLoadDependents = true;
@@ -102,7 +103,12 @@ export class AudioClip extends Asset {
@override @override
get _nativeDep () { get _nativeDep () {
return { uuid: this._uuid, audioLoadMode: this.loadMode, ext: this._native, __isNative__: true }; return {
uuid: this._uuid,
audioLoadMode: this.loadMode,
ext: this._native,
__isNative__: true,
};
} }
get loadMode () { get loadMode () {
@@ -126,7 +132,7 @@ export class AudioClip extends Asset {
public getLoop () { if (this._player) { return this._player.getLoop(); } return false; } public getLoop () { if (this._player) { return this._player.getLoop(); } return false; }
private _getPlayer (clip: any) { private _getPlayer (clip: any) {
let ctor: any; let ctor: Constructor<AudioPlayer>;
if (typeof AudioBuffer !== 'undefined' && clip instanceof AudioBuffer) { if (typeof AudioBuffer !== 'undefined' && clip instanceof AudioBuffer) {
ctor = AudioPlayerWeb; ctor = AudioPlayerWeb;
this._loadMode = AudioType.WEB_AUDIO; this._loadMode = AudioType.WEB_AUDIO;
+7 -6
View File
@@ -70,6 +70,13 @@ export abstract class AudioPlayer {
legacyCC.game.on(legacyCC.Game.EVENT_SHOW, this._onShow); legacyCC.game.on(legacyCC.Game.EVENT_SHOW, this._onShow);
} }
public getState () { return this._state; }
public getDuration () { return this._duration; }
public destroy () {
legacyCC.game.off(legacyCC.Game.EVENT_HIDE, this._onHide);
legacyCC.game.off(legacyCC.Game.EVENT_SHOW, this._onShow);
}
public abstract play (): void; public abstract play (): void;
public abstract pause (): void; public abstract pause (): void;
public abstract stop (): void; public abstract stop (): void;
@@ -80,12 +87,6 @@ export abstract class AudioPlayer {
public abstract getVolume (): number; public abstract getVolume (): number;
public abstract setLoop (val: boolean): void; public abstract setLoop (val: boolean): void;
public abstract getLoop (): boolean; public abstract getLoop (): boolean;
public getState () { return this._state; }
public getDuration () { return this._duration; }
public destroy () {
legacyCC.game.off(legacyCC.Game.EVENT_HIDE, this._onHide);
legacyCC.game.off(legacyCC.Game.EVENT_SHOW, this._onShow);
}
} }
legacyCC.internal.AudioPlayer = AudioPlayer; legacyCC.internal.AudioPlayer = AudioPlayer;
+6 -5
View File
@@ -44,13 +44,13 @@ export function downloadDomAudio (
url: string, url: string,
options: IDownloadParseOptions, options: IDownloadParseOptions,
onComplete: CompleteCallback<HTMLAudioElement> onComplete: CompleteCallback<HTMLAudioElement>
): void { ): void {
createDomAudio(url).then(dom => { createDomAudio(url).then(dom => {
onComplete(null, dom); onComplete(null, dom);
}, errMsg => { }, errMsg => {
log(errMsg); log(errMsg);
onComplete(new Error(errMsg), null); onComplete(new Error(errMsg), null);
}); });
} }
@@ -61,7 +61,8 @@ function downloadArrayBuffer (url: string, options: IDownloadParseOptions, onCom
export function downloadAudio (url: string, options: IDownloadParseOptions, onComplete: CompleteCallback) { export function downloadAudio (url: string, options: IDownloadParseOptions, onComplete: CompleteCallback) {
if (formatSupport.length === 0) { if (formatSupport.length === 0) {
return onComplete(new Error(getError(4927))); onComplete(new Error(getError(4927)));
return;
} }
let handler: DownloadHandler | null = null; let handler: DownloadHandler | null = null;
if (!__audioSupport.WEB_AUDIO) { if (!__audioSupport.WEB_AUDIO) {
@@ -77,4 +78,4 @@ export function downloadAudio (url: string, options: IDownloadParseOptions, onCo
} }
} }
handler(url, options, onComplete); handler(url, options, onComplete);
}; }
+6 -5
View File
@@ -1,11 +1,12 @@
import { sys } from '../core/platform/sys'; import { sys } from '../core/platform/sys';
const __audioSupport = sys.__audioSupport;
export function createDomAudio (url): Promise<HTMLAudioElement> { const { __audioSupport } = sys;
export function createDomAudio (url: string): Promise<HTMLAudioElement> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const dom = document.createElement('audio'); const dom = document.createElement('audio');
dom.src = url; dom.src = url;
const clearEvent = () => { const clearEvent = () => {
clearTimeout(timer); clearTimeout(timer);
dom.removeEventListener('canplaythrough', success, false); dom.removeEventListener('canplaythrough', success, false);
@@ -27,7 +28,7 @@ export function createDomAudio (url): Promise<HTMLAudioElement> {
}; };
const failure = () => { const failure = () => {
clearEvent(); clearEvent();
const message = 'load audio failure - ' + url; const message = `load audio failure - ${url}`;
reject(message); reject(message);
}; };
dom.addEventListener('canplaythrough', success, false); dom.addEventListener('canplaythrough', success, false);
@@ -36,4 +37,4 @@ export function createDomAudio (url): Promise<HTMLAudioElement> {
dom.addEventListener(__audioSupport.USE_LOADER_EVENT, success, false); dom.addEventListener(__audioSupport.USE_LOADER_EVENT, success, false);
} }
}); });
} }
+1 -1
View File
@@ -1,4 +1,4 @@
// tslint:disable
// absolute essential effects // absolute essential effects
export default [ export default [
{ {
@@ -1,4 +1,4 @@
// tslint:disable
export default [ export default [
[ [
{ {
@@ -1,4 +1,4 @@
// tslint:disable
export default [ export default [
[ [
{ {
@@ -1,4 +1,4 @@
// tslint:disable
export default [ export default [
[ [
{ {
+2 -2
View File
@@ -67,7 +67,7 @@ const ClearFlag = Enum({
DONT_CLEAR: GFXClearFlag.NONE, DONT_CLEAR: GFXClearFlag.NONE,
}); });
// tslint:disable: no-shadowed-variable
export declare namespace Camera { export declare namespace Camera {
export type ProjectionType = EnumAlias<typeof ProjectionType>; export type ProjectionType = EnumAlias<typeof ProjectionType>;
export type FOVAxis = EnumAlias<typeof FOVAxis>; export type FOVAxis = EnumAlias<typeof FOVAxis>;
@@ -76,7 +76,7 @@ export declare namespace Camera {
export type Shutter = EnumAlias<typeof Shutter>; export type Shutter = EnumAlias<typeof Shutter>;
export type ISO = EnumAlias<typeof ISO>; export type ISO = EnumAlias<typeof ISO>;
} }
// tslint:enable: no-shadowed-variable
/** /**
* @en The Camera Component. * @en The Camera Component.
+2 -2
View File
@@ -94,12 +94,12 @@ class StaticLightSettings {
} }
} }
// tslint:disable: no-shadowed-variable
export declare namespace Light { export declare namespace Light {
export type Type = EnumAlias<typeof scene.LightType>; export type Type = EnumAlias<typeof scene.LightType>;
export type PhotometricTerm = EnumAlias<typeof PhotometricTerm>; export type PhotometricTerm = EnumAlias<typeof PhotometricTerm>;
} }
// tslint:enable: no-shadowed-variable
@ccclass('cc.Light') @ccclass('cc.Light')
export class Light extends Component { export class Light extends Component {
+2 -2
View File
@@ -371,7 +371,7 @@ export class MeshRenderer extends RenderableComponent {
return; return;
} }
const renderScene = this._getRenderScene(); const renderScene = this._getRenderScene();
if (this._model.scene != null) { if (this._model.scene !== null) {
this._detachFromScene(); this._detachFromScene();
} }
renderScene.addModel(this._model); renderScene.addModel(this._model);
@@ -414,7 +414,7 @@ export class MeshRenderer extends RenderableComponent {
this.lightmapSettings.uvParam.x, this.lightmapSettings.uvParam.x,
this.lightmapSettings.uvParam.y, this.lightmapSettings.uvParam.y,
this.lightmapSettings.uvParam.z, this.lightmapSettings.uvParam.z,
this.lightmapSettings.uvParam.w this.lightmapSettings.uvParam.w,
]); ]);
} }
@@ -4,9 +4,11 @@
*/ */
import { EDITOR } from 'internal:constants'; import { EDITOR } from 'internal:constants';
import {
ccclass, type, displayOrder, displayName, serializable,
} from 'cc.decorator';
import { Material } from '../../assets/material'; import { Material } from '../../assets/material';
import { Component } from '../../components/component'; import { Component } from '../../components/component';
import { ccclass, type, displayOrder, displayName, serializable } from 'cc.decorator';
import { IMaterialInstanceInfo, MaterialInstance } from '../../renderer/core/material-instance'; import { IMaterialInstanceInfo, MaterialInstance } from '../../renderer/core/material-instance';
import { scene } from '../../renderer'; import { scene } from '../../renderer';
import { Layers } from '../../scene-graph/layers'; import { Layers } from '../../scene-graph/layers';
@@ -40,7 +42,7 @@ export class RenderableComponent extends Component {
@displayName('Materials') @displayName('Materials')
get sharedMaterials () { get sharedMaterials () {
// if we don't create an array copy, the editor will modify the original array directly. // if we don't create an array copy, the editor will modify the original array directly.
return EDITOR && this._materials.slice() || this._materials; return (EDITOR && this._materials.slice()) || this._materials;
} }
set sharedMaterials (val) { set sharedMaterials (val) {
@@ -79,7 +81,8 @@ export class RenderableComponent extends Component {
} }
} }
for (let i = 0; i < this._materialInstances.length; i++) { for (let i = 0; i < this._materialInstances.length; i++) {
// tslint:disable-next-line: triple-equals // both of them may be undefined or null // they could be either undefined or null
// eslint-disable-next-line eqeqeq
if (this._materialInstances[i] != val[i]) { if (this._materialInstances[i] != val[i]) {
this.setMaterialInstance(i, val[i]); this.setMaterialInstance(i, val[i]);
} }
@@ -87,6 +90,7 @@ export class RenderableComponent extends Component {
} }
protected _materialInstances: (MaterialInstance | null)[] = []; protected _materialInstances: (MaterialInstance | null)[] = [];
protected _models: scene.Model[] = []; protected _models: scene.Model[] = [];
get sharedMaterial () { get sharedMaterial () {
@@ -166,10 +170,8 @@ export class RenderableComponent extends Component {
this._materialInstances[index] = matInst as MaterialInstance; this._materialInstances[index] = matInst as MaterialInstance;
this._onMaterialModified(index, matInst); this._onMaterialModified(index, matInst);
} }
} else { } else if (matInst !== this._materials[index]) {
if (matInst !== this._materials[index]) { this.setMaterial(matInst as Material, index);
this.setMaterial(matInst as Material, index);
}
} }
} }
@@ -28,15 +28,19 @@
*/ */
import { EDITOR } from 'internal:constants'; import { EDITOR } from 'internal:constants';
import {
ccclass, help, executeInEditMode, executionOrder, menu, tooltip, type, visible, override, serializable, editable,
} from 'cc.decorator';
import { getWorldTransformUntilRoot } from '../../animation/transform-utils'; import { getWorldTransformUntilRoot } from '../../animation/transform-utils';
import { Filter, PixelFormat } from '../../assets/asset-enum'; import { Filter, PixelFormat } from '../../assets/asset-enum';
import { Material } from '../../assets/material'; import { Material } from '../../assets/material';
import { Mesh } from '../../assets/mesh'; import { Mesh } from '../../assets/mesh';
import { Skeleton } from '../../assets/skeleton'; import { Skeleton } from '../../assets/skeleton';
import { Texture2D } from '../../assets/texture-2d'; import { Texture2D } from '../../assets/texture-2d';
import { ccclass, help, executeInEditMode, executionOrder, menu, tooltip, type, visible, override, serializable, editable } from 'cc.decorator';
import { CCString } from '../../data/utils/attribute'; import { CCString } from '../../data/utils/attribute';
import { AttributeName, FormatInfos, Format, Type } from '../../gfx/define'; import {
AttributeName, FormatInfos, Format, Type,
} from '../../gfx/define';
import { Device, Attribute, BufferTextureCopy } from '../../gfx'; import { Device, Attribute, BufferTextureCopy } from '../../gfx';
import { Mat4, Vec2, Vec3 } from '../../math'; import { Mat4, Vec2, Vec3 } from '../../math';
import { mapBuffer, readBuffer, writeBuffer } from '../misc/buffer'; import { mapBuffer, readBuffer, writeBuffer } from '../misc/buffer';
@@ -50,7 +54,6 @@ const batch_extras_size = FormatInfos[batch_id.format].size + FormatInfos[batch_
@ccclass('cc.SkinnedMeshUnit') @ccclass('cc.SkinnedMeshUnit')
export class SkinnedMeshUnit { export class SkinnedMeshUnit {
/** /**
* @en Skinned mesh of this unit. * @en Skinned mesh of this unit.
* @zh 子蒙皮模型的网格模型。 * @zh 子蒙皮模型的网格模型。
@@ -74,8 +77,10 @@ export class SkinnedMeshUnit {
@serializable @serializable
public _localTransform = new Mat4(); public _localTransform = new Mat4();
@serializable @serializable
private _offset = new Vec2(0, 0); private _offset = new Vec2(0, 0);
@serializable @serializable
private _size = new Vec2(1, 1); private _size = new Vec2(1, 1);
@@ -87,6 +92,7 @@ export class SkinnedMeshUnit {
set offset (offset) { set offset (offset) {
Vec2.copy(this._offset, offset); Vec2.copy(this._offset, offset);
} }
get offset () { get offset () {
return this._offset; return this._offset;
} }
@@ -99,6 +105,7 @@ export class SkinnedMeshUnit {
set size (size) { set size (size) {
Vec2.copy(this._size, size); Vec2.copy(this._size, size);
} }
get size () { get size () {
return this._size; return this._size;
} }
@@ -115,6 +122,7 @@ export class SkinnedMeshUnit {
this.material = comp.getMaterial(0); this.material = comp.getMaterial(0);
if (comp.skinningRoot) { getWorldTransformUntilRoot(comp.node, comp.skinningRoot, this._localTransform); } if (comp.skinningRoot) { getWorldTransformUntilRoot(comp.node, comp.skinningRoot, this._localTransform); }
} }
get copyFrom () { get copyFrom () {
return null; return null;
} }
@@ -134,14 +142,13 @@ const v3_1 = new Vec3();
@executeInEditMode @executeInEditMode
@menu('Components/SkinnedMeshBatchRenderer') @menu('Components/SkinnedMeshBatchRenderer')
export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer { export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
/** /**
* @en Size of the generated texture atlas. * @en Size of the generated texture atlas.
* @zh 合图生成的最终图集的边长。 * @zh 合图生成的最终图集的边长。
*/ */
@serializable @serializable
@tooltip('i18n:batched_skinning_model.atlas_size') @tooltip('i18n:batched_skinning_model.atlas_size')
public atlasSize: number = 1024; public atlasSize = 1024;
/** /**
* @en * @en
@@ -165,6 +172,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
public units: SkinnedMeshUnit[] = []; public units: SkinnedMeshUnit[] = [];
private _textures: Record<string, Texture2D> = {}; private _textures: Record<string, Texture2D> = {};
private _batchMaterial: Material | null = null; private _batchMaterial: Material | null = null;
@override @override
@@ -172,6 +180,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
get mesh () { get mesh () {
return super.mesh; return super.mesh;
} }
set mesh (val) { set mesh (val) {
super.mesh = val; super.mesh = val;
} }
@@ -181,6 +190,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
get skeleton () { get skeleton () {
return super.skeleton; return super.skeleton;
} }
set skeleton (val) { set skeleton (val) {
super.skeleton = val; super.skeleton = val;
} }
@@ -328,9 +338,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
for (let i = 0; i < unitLen; i++) { for (let i = 0; i < unitLen; i++) {
const unit = this.units[i]; const unit = this.units[i];
if (!unit || !unit.skeleton) { continue; } if (!unit || !unit.skeleton) { continue; }
jointIndexMap[i] = unit.skeleton.joints.map((j) => { jointIndexMap[i] = unit.skeleton.joints.map((j) => this._skeleton!.joints.findIndex((ref) => j === ref));
return this._skeleton!.joints.findIndex((ref) => j === ref);
});
} }
for (let i = 0; i < unitLen; i++) { for (let i = 0; i < unitLen; i++) {
@@ -339,8 +347,8 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
const newMesh = this._createUnitMesh(i, unit.mesh); const newMesh = this._createUnitMesh(i, unit.mesh);
const dataView = new DataView(newMesh.data.buffer); const dataView = new DataView(newMesh.data.buffer);
Mat4.inverseTranspose(m4_local, unit._localTransform); Mat4.inverseTranspose(m4_local, unit._localTransform);
const offset = unit.offset; const { offset } = unit;
const size = unit.size; const { size } = unit;
for (let b = 0; b < newMesh.struct.vertexBundles.length; b++) { for (let b = 0; b < newMesh.struct.vertexBundles.length; b++) {
const bundle = newMesh.struct.vertexBundles[b]; const bundle = newMesh.struct.vertexBundles[b];
// apply local transform to mesh // apply local transform to mesh
@@ -436,7 +444,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
mapBuffer(dataView, (cur) => idxMap[cur], jointFormat, jointOffset, bundle.view.length, bundle.view.stride, dataView); mapBuffer(dataView, (cur) => idxMap[cur], jointFormat, jointOffset, bundle.view.length, bundle.view.stride, dataView);
} }
} }
this._mesh!.merge(newMesh); this._mesh.merge(newMesh);
} }
this._onMeshChanged(this._mesh); this._onMeshChanged(this._mesh);
@@ -458,7 +466,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
region.texOffset.y = unit.offset.y * this.atlasSize; region.texOffset.y = unit.offset.y * this.atlasSize;
region.texExtent.width = unit.size.x * this.atlasSize; region.texExtent.width = unit.size.x * this.atlasSize;
region.texExtent.height = unit.size.y * this.atlasSize; region.texExtent.height = unit.size.y * this.atlasSize;
const data = partial.image.data; const { data } = partial.image;
if (!ArrayBuffer.isView(data)) { if (!ArrayBuffer.isView(data)) {
texImages.push(data); texImages.push(data);
texImageRegions.push(region); texImageRegions.push(region);
@@ -469,7 +477,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
} }
} }
const gfxTex = target.getGFXTexture()!; const gfxTex = target.getGFXTexture()!;
const device: Device = legacyCC.director.root!.device; const { device } = legacyCC.director.root!;
if (texBuffers.length > 0) { device.copyBuffersToTexture(texBuffers, gfxTex, texBufferRegions); } if (texBuffers.length > 0) { device.copyBuffersToTexture(texBuffers, gfxTex, texBufferRegions); }
if (texImages.length > 0) { device.copyTexImagesToTexture(texImages, gfxTex, texImageRegions); } if (texImages.length > 0) { device.copyTexImagesToTexture(texImages, gfxTex, texImageRegions); }
} }
@@ -524,7 +532,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
if (uvFormat) { break; } if (uvFormat) { break; }
} }
if (modifiedBundles[bundleIdx] !== undefined) { continue; } if (modifiedBundles[bundleIdx] !== undefined) { continue; }
modifiedBundles[bundleIdx] = [ uvFormat, uvOffset ]; modifiedBundles[bundleIdx] = [uvFormat, uvOffset];
const newBundle = newMeshStruct.vertexBundles[bundleIdx]; // put the new UVs in the same bundle with original UVs const newBundle = newMeshStruct.vertexBundles[bundleIdx]; // put the new UVs in the same bundle with original UVs
newBundle.attributes.push(batch_id); newBundle.attributes.push(batch_id);
newBundle.attributes.push(batch_uv); newBundle.attributes.push(batch_uv);
@@ -548,11 +556,11 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
const oldMeshData = mesh.data; const oldMeshData = mesh.data;
const newDataView = new DataView(newMeshData.buffer); const newDataView = new DataView(newMeshData.buffer);
const oldDataView = new DataView(oldMeshData.buffer); const oldDataView = new DataView(oldMeshData.buffer);
const isLittleEndian = legacyCC.sys.isLittleEndian; const { isLittleEndian } = legacyCC.sys;
for (const b in modifiedBundles) { for (const b in modifiedBundles) {
const newBundle = newMeshStruct.vertexBundles[b]; const newBundle = newMeshStruct.vertexBundles[b];
const oldBundle = mesh.struct.vertexBundles[b]; const oldBundle = mesh.struct.vertexBundles[b];
const [ uvFormat, uvOffset ] = modifiedBundles[b]; const [uvFormat, uvOffset] = modifiedBundles[b];
const uvs = readBuffer(oldDataView, uvFormat, uvOffset, oldBundle.view.length, oldBundle.view.stride); const uvs = readBuffer(oldDataView, uvFormat, uvOffset, oldBundle.view.length, oldBundle.view.stride);
const oldView = oldBundle.view; const oldView = oldBundle.view;
const newView = newBundle.view; const newView = newBundle.view;
@@ -564,7 +572,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
const srcVertex = oldMeshData.subarray(oldOffset, oldOffset + oldStride); const srcVertex = oldMeshData.subarray(oldOffset, oldOffset + oldStride);
newMeshData.set(srcVertex, newOffset); newMeshData.set(srcVertex, newOffset);
// insert batch ID // insert batch ID
newDataView.setFloat32(newOffset + oldStride, unitIdx, ); newDataView.setFloat32(newOffset + oldStride, unitIdx);
// insert batch UV // insert batch UV
newDataView.setFloat32(newOffset + oldStride + 4, uvs[j * 2], isLittleEndian); newDataView.setFloat32(newOffset + oldStride + 4, uvs[j * 2], isLittleEndian);
newDataView.setFloat32(newOffset + oldStride + 8, uvs[j * 2 + 1], isLittleEndian); newDataView.setFloat32(newOffset + oldStride + 8, uvs[j * 2 + 1], isLittleEndian);
@@ -28,10 +28,12 @@
* @module model * @module model
*/ */
import {
ccclass, executeInEditMode, executionOrder, help, menu, tooltip, type,
} from 'cc.decorator';
import { AnimationClip } from '../../animation/animation-clip'; import { AnimationClip } from '../../animation/animation-clip';
import { Material } from '../../assets'; import { Material } from '../../assets';
import { Skeleton } from '../../assets/skeleton'; import { Skeleton } from '../../assets/skeleton';
import { ccclass, executeInEditMode, executionOrder, help, menu, tooltip, type } from 'cc.decorator';
import { models } from '../../renderer'; import { models } from '../../renderer';
import { Node } from '../../scene-graph/node'; import { Node } from '../../scene-graph/node';
import { MeshRenderer } from './mesh-renderer'; import { MeshRenderer } from './mesh-renderer';
@@ -48,7 +50,6 @@ import { legacyCC } from '../../global-exports';
@executeInEditMode @executeInEditMode
@menu('Components/SkinnedMeshRenderer') @menu('Components/SkinnedMeshRenderer')
export class SkinnedMeshRenderer extends MeshRenderer { export class SkinnedMeshRenderer extends MeshRenderer {
@type(Skeleton) @type(Skeleton)
protected _skeleton: Skeleton | null = null; protected _skeleton: Skeleton | null = null;
@@ -28,7 +28,9 @@
* @module component/light * @module component/light
*/ */
import { ccclass, help, executeInEditMode, menu, tooltip, type, slide, range, unit, serializable } from 'cc.decorator'; import {
ccclass, help, executeInEditMode, menu, tooltip, type, slide, range, unit, serializable,
} from 'cc.decorator';
import { toRadian } from '../../math'; import { toRadian } from '../../math';
import { scene } from '../../renderer'; import { scene } from '../../renderer';
import { Light, PhotometricTerm } from './light-component'; import { Light, PhotometricTerm } from './light-component';
@@ -38,19 +40,23 @@ import { Light, PhotometricTerm } from './light-component';
@menu('Light/SpotLight') @menu('Light/SpotLight')
@executeInEditMode @executeInEditMode
export class SpotLight extends Light { export class SpotLight extends Light {
@serializable @serializable
protected _size = 0.15; protected _size = 0.15;
@serializable @serializable
protected _luminance = 1700 / scene.nt2lm(0.15); protected _luminance = 1700 / scene.nt2lm(0.15);
@serializable @serializable
protected _term = PhotometricTerm.LUMINOUS_POWER; protected _term = PhotometricTerm.LUMINOUS_POWER;
@serializable @serializable
protected _range = 1; protected _range = 1;
@serializable @serializable
protected _spotAngle = 60; protected _spotAngle = 60;
protected _type = scene.LightType.SPOT; protected _type = scene.LightType.SPOT;
protected _light: scene.SpotLight | null = null; protected _light: scene.SpotLight | null = null;
/** /**
@@ -62,6 +68,7 @@ export class SpotLight extends Light {
get luminousPower () { get luminousPower () {
return this._luminance * scene.nt2lm(this._size); return this._luminance * scene.nt2lm(this._size);
} }
set luminousPower (val) { set luminousPower (val) {
this._luminance = val / scene.nt2lm(this._size); this._luminance = val / scene.nt2lm(this._size);
if (this._light) { this._light.luminance = this._luminance; } if (this._light) { this._light.luminance = this._luminance; }
@@ -76,6 +83,7 @@ export class SpotLight extends Light {
get luminance () { get luminance () {
return this._luminance; return this._luminance;
} }
set luminance (val) { set luminance (val) {
this._luminance = val; this._luminance = val;
if (this._light) { this._light.luminance = val; } if (this._light) { this._light.luminance = val; }
@@ -90,6 +98,7 @@ export class SpotLight extends Light {
get term () { get term () {
return this._term; return this._term;
} }
set term (val) { set term (val) {
this._term = val; this._term = val;
} }
@@ -104,6 +113,7 @@ export class SpotLight extends Light {
get size () { get size () {
return this._size; return this._size;
} }
set size (val) { set size (val) {
this._size = val; this._size = val;
if (this._light) { this._light.size = val; } if (this._light) { this._light.size = val; }
@@ -119,6 +129,7 @@ export class SpotLight extends Light {
get range () { get range () {
return this._range; return this._range;
} }
set range (val) { set range (val) {
this._range = val; this._range = val;
if (this._light) { this._light.range = val; } if (this._light) { this._light.range = val; }
+1 -1
View File
@@ -468,7 +468,7 @@ export class Animation extends Eventify(Component) {
} }
private _removeStateOfAutomaticClip (clip: AnimationClip) { private _removeStateOfAutomaticClip (clip: AnimationClip) {
// tslint:disable-next-line:forin
for (const name in this._nameToState) { for (const name in this._nameToState) {
const state = this._nameToState[name]; const state = this._nameToState[name];
if (equalClips(clip, state.clip)) { if (equalClips(clip, state.clip)) {
+1 -1
View File
@@ -342,7 +342,7 @@ const selectLerpFx = (() => {
function makeValueTypeLerpFx<T extends ValueType> (constructor: Constructor<T>) { function makeValueTypeLerpFx<T extends ValueType> (constructor: Constructor<T>) {
const tempValue = new constructor(); const tempValue = new constructor();
return (from: T, to: T, ratio: number) => { return (from: T, to: T, ratio: number) => {
// @ts-ignore // @ts-expect-error
constructor.lerp(tempValue, from, to, ratio); constructor.lerp(tempValue, from, to, ratio);
return tempValue; return tempValue;
}; };
+1 -1
View File
@@ -72,7 +72,7 @@ function makeCubicSplineValueConstructor<T> (
} }
} }
// @ts-ignore TS2367 // @ts-expect-error TS2367
if (constructorX === Quat) { if (constructorX === Quat) {
const lerp = CubicSplineValueClass.prototype.lerp; const lerp = CubicSplineValueClass.prototype.lerp;
CubicSplineValueClass.prototype.lerp = function (this: CubicSplineValueClass, to: CubicSplineValueClass, t: number, dt: number) { CubicSplineValueClass.prototype.lerp = function (this: CubicSplineValueClass, to: CubicSplineValueClass, t: number, dt: number) {
+5 -5
View File
@@ -9,7 +9,7 @@ import { Vec2, Vec3 } from '../math';
import { AnimCurve, computeRatioByType, CurveValue, EasingMethod } from './animation-curve'; import { AnimCurve, computeRatioByType, CurveValue, EasingMethod } from './animation-curve';
import { bezier } from './bezier'; import { bezier } from './bezier';
// tslint:disable:no-shadowed-variable
export class Curve { export class Curve {
public beziers: Bezier[] = []; public beziers: Bezier[] = [];
@@ -248,7 +248,7 @@ export function sampleMotionPaths (motionPaths: Array<(MotionPath | undefined)>,
}; };
}; };
// @ts-ignore // @ts-expect-error
const values = data.values = data.values.map((value) => { const values = data.values = data.values.map((value) => {
if (Array.isArray(value)) { if (Array.isArray(value)) {
value = value.length === 2 ? new Vec2(value[0], value[1]) : new Vec3(value[0], value[1], value[2]); value = value.length === 2 ? new Vec2(value[0], value[1]) : new Vec3(value[0], value[1], value[2]);
@@ -282,13 +282,13 @@ export function sampleMotionPaths (motionPaths: Array<(MotionPath | undefined)>,
} }
const types = data.types; const types = data.types;
// @ts-ignore // @ts-expect-error
const ratios = (data.ratioSampler ? data.ratioSampler.ratios : []); const ratios = (data.ratioSampler ? data.ratioSampler.ratios : []);
// @ts-ignore // @ts-expect-error
const newValues: CurveValue[] = data.values = []; const newValues: CurveValue[] = data.values = [];
const newTypes: any[] = data.types = []; const newTypes: any[] = data.types = [];
// @ts-ignore // @ts-expect-error
const newRatios: number[] = data.ratios = []; const newRatios: number[] = data.ratios = [];
function addNewDatas (value: CurveValue, type: any, ratio: number) { function addNewDatas (value: CurveValue, type: any, ratio: number) {
@@ -28,7 +28,9 @@
* @module animation * @module animation
*/ */
import { clamp01, Mat4, Quat, Vec3 } from '../math'; import {
clamp01, Mat4, Quat, Vec3,
} from '../math';
import { DataPoolManager } from '../renderer/data-pool-manager'; import { DataPoolManager } from '../renderer/data-pool-manager';
import { AnimationClip, IObjectCurveData } from './animation-clip'; import { AnimationClip, IObjectCurveData } from './animation-clip';
import { HierarchyPath, isCustomPath, isPropertyPath } from './target-path'; import { HierarchyPath, isCustomPath, isPropertyPath } from './target-path';
@@ -54,7 +56,6 @@ interface IConvertedData {
* 骨骼动画数据转换中心。 * 骨骼动画数据转换中心。
*/ */
export class SkelAnimDataHub { export class SkelAnimDataHub {
public static getOrExtract (clip: AnimationClip) { public static getOrExtract (clip: AnimationClip) {
let data = SkelAnimDataHub.pool.get(clip); let data = SkelAnimDataHub.pool.get(clip);
if (!data || data.info.sample !== clip.sample) { if (!data || data.info.sample !== clip.sample) {
@@ -76,10 +77,10 @@ export class SkelAnimDataHub {
function convertToSkeletalCurves (clip: AnimationClip): IConvertedData { function convertToSkeletalCurves (clip: AnimationClip): IConvertedData {
const data: Record<string, ConvertedProps> = {}; const data: Record<string, ConvertedProps> = {};
clip.curves.forEach((curve) => { clip.curves.forEach((curve) => {
if (!curve.valueAdapter && if (!curve.valueAdapter
isCustomPath(curve.modifiers[0], HierarchyPath) && && isCustomPath(curve.modifiers[0], HierarchyPath)
isPropertyPath(curve.modifiers[1])) { && isPropertyPath(curve.modifiers[1])) {
const path = (curve.modifiers[0] as HierarchyPath).path; const { path } = curve.modifiers[0];
let cs = data[path]; let cs = data[path];
if (!cs) { cs = data[path] = {}; } if (!cs) { cs = data[path] = {}; }
const property = curve.modifiers[1] as string; const property = curve.modifiers[1] as string;
@@ -126,8 +127,7 @@ function convertToUniformSample (clip: AnimationClip, curve: IPropertyCurve, fra
for (let i = 0, idx = 0; i < frames; i++) { for (let i = 0, idx = 0; i < frames; i++) {
let time = i / clip.sample; let time = i / clip.sample;
while (keys[idx] <= time) { idx++; } while (keys[idx] <= time) { idx++; }
if (idx > keys.length - 1) { idx = keys.length - 1; time = keys[idx]; } if (idx > keys.length - 1) { idx = keys.length - 1; time = keys[idx]; } else if (idx === 0) { idx = 1; }
else if (idx === 0) { idx = 1; }
const from = curve.values[idx - 1].clone(); const from = curve.values[idx - 1].clone();
const denom = keys[idx] - keys[idx - 1]; const denom = keys[idx] - keys[idx - 1];
const ratio = denom ? clamp01((time - keys[idx - 1]) / denom) : 1; const ratio = denom ? clamp01((time - keys[idx - 1]) / denom) : 1;
@@ -137,7 +137,7 @@ function convertToUniformSample (clip: AnimationClip, curve: IPropertyCurve, fra
(from as Vec3).lerp(curve.values[idx] as Vec3, ratio); (from as Vec3).lerp(curve.values[idx] as Vec3, ratio);
} }
values[i] = from; values[i] = from;
} }
} }
curve.values = values; curve.values = values;
} }
@@ -55,14 +55,20 @@ interface ISocketData {
const noCurves: IRuntimeCurve[] = []; const noCurves: IRuntimeCurve[] = [];
export class SkeletalAnimationState extends AnimationState { export class SkeletalAnimationState extends AnimationState {
protected _frames = 1; protected _frames = 1;
protected _bakedDuration = 0; protected _bakedDuration = 0;
protected _animInfo: IAnimInfo | null = null; protected _animInfo: IAnimInfo | null = null;
protected _sockets: ISocketData[] = []; protected _sockets: ISocketData[] = [];
protected _animInfoMgr: JointAnimationInfo; protected _animInfoMgr: JointAnimationInfo;
protected _comps: SkinnedMeshRenderer[] = []; protected _comps: SkinnedMeshRenderer[] = [];
protected _parent: SkeletalAnimation | null = null; protected _parent: SkeletalAnimation | null = null;
protected _curvesInited = false; protected _curvesInited = false;
constructor (clip: AnimationClip, name = '') { constructor (clip: AnimationClip, name = '') {
@@ -84,7 +90,7 @@ export class SkeletalAnimationState extends AnimationState {
const baked = this._parent.useBakedAnimation; const baked = this._parent.useBakedAnimation;
super.initialize(root, baked ? noCurves : undefined); super.initialize(root, baked ? noCurves : undefined);
this._curvesInited = !baked; this._curvesInited = !baked;
const info = SkelAnimDataHub.getOrExtract(this.clip).info; const { info } = SkelAnimDataHub.getOrExtract(this.clip);
this._frames = info.frames - 1; this._frames = info.frames - 1;
this._animInfo = this._animInfoMgr.getData(root.uuid); this._animInfo = this._animInfoMgr.getData(root.uuid);
this._bakedDuration = this._frames / info.sample; // last key this._bakedDuration = this._frames / info.sample; // last key
@@ -113,7 +119,7 @@ export class SkeletalAnimationState extends AnimationState {
public rebuildSocketCurves (sockets: Socket[]) { public rebuildSocketCurves (sockets: Socket[]) {
this._sockets.length = 0; this._sockets.length = 0;
if (!this._targetNode) { return null; } if (!this._targetNode) { return; }
const root = this._targetNode; const root = this._targetNode;
for (let i = 0; i < sockets.length; ++i) { for (let i = 0; i < sockets.length; ++i) {
const socket = sockets[i]; const socket = sockets[i];
@@ -137,7 +143,7 @@ export class SkeletalAnimationState extends AnimationState {
if (idx < 0) { break; } if (idx < 0) { break; }
} }
const curveData: Mat4[] | undefined = source && source.worldMatrix.values as Mat4[]; const curveData: Mat4[] | undefined = source && source.worldMatrix.values as Mat4[];
const frames = clipData.info.frames; const { frames } = clipData.info;
const transforms: ITransform[] = []; const transforms: ITransform[] = [];
for (let f = 0; f < frames; f++) { for (let f = 0; f < frames; f++) {
let mat: Mat4; let mat: Mat4;
+14 -9
View File
@@ -28,8 +28,10 @@
* @module animation * @module animation
*/ */
import {
ccclass, executeInEditMode, executionOrder, help, menu, tooltip, type, serializable, editable,
} from 'cc.decorator';
import { SkinnedMeshRenderer } from '../3d/framework/skinned-mesh-renderer'; import { SkinnedMeshRenderer } from '../3d/framework/skinned-mesh-renderer';
import { ccclass, executeInEditMode, executionOrder, help, menu, tooltip, type, serializable, editable } from 'cc.decorator';
import { Mat4 } from '../math'; import { Mat4 } from '../math';
import { DataPoolManager } from '../renderer/data-pool-manager'; import { DataPoolManager } from '../renderer/data-pool-manager';
import { Node } from '../scene-graph/node'; import { Node } from '../scene-graph/node';
@@ -44,14 +46,13 @@ import { js } from '../utils/js';
@ccclass('cc.SkeletalAnimation.Socket') @ccclass('cc.SkeletalAnimation.Socket')
export class Socket { export class Socket {
/** /**
* @en Path of the target joint. * @en Path of the target joint.
* @zh 此挂点的目标骨骼路径。 * @zh 此挂点的目标骨骼路径。
*/ */
@serializable @serializable
@editable @editable
public path: string = ''; public path = '';
/** /**
* @en Transform output node. * @en Transform output node.
@@ -99,7 +100,6 @@ function collectRecursively (node: Node, prefix = '', out: string[] = []) {
@executeInEditMode @executeInEditMode
@menu('Components/SkeletalAnimation') @menu('Components/SkeletalAnimation')
export class SkeletalAnimation extends Animation { export class SkeletalAnimation extends Animation {
public static Socket = Socket; public static Socket = Socket;
/** /**
@@ -114,6 +114,7 @@ export class SkeletalAnimation extends Animation {
get sockets () { get sockets () {
return this._sockets; return this._sockets;
} }
set sockets (val) { set sockets (val) {
if (!this._useBakedAnimation) { if (!this._useBakedAnimation) {
const animMgr = legacyCC.director.getAnimationManager() as AnimationManager; const animMgr = legacyCC.director.getAnimationManager() as AnimationManager;
@@ -137,6 +138,7 @@ export class SkeletalAnimation extends Animation {
get useBakedAnimation () { get useBakedAnimation () {
return this._useBakedAnimation; return this._useBakedAnimation;
} }
set useBakedAnimation (val) { set useBakedAnimation (val) {
this._useBakedAnimation = val; this._useBakedAnimation = val;
const comps = this.node.getComponentsInChildren(SkinnedMeshRenderer); const comps = this.node.getComponentsInChildren(SkinnedMeshRenderer);
@@ -146,8 +148,11 @@ export class SkeletalAnimation extends Animation {
comp.setUseBakedAnimation(this._useBakedAnimation); comp.setUseBakedAnimation(this._useBakedAnimation);
} }
} }
if (this._useBakedAnimation) { (legacyCC.director.getAnimationManager() as AnimationManager).removeSockets(this.node, this._sockets); } if (this._useBakedAnimation) {
else { (legacyCC.director.getAnimationManager() as AnimationManager).addSockets(this.node, this._sockets); } (legacyCC.director.getAnimationManager() as AnimationManager).removeSockets(this.node, this._sockets);
} else {
(legacyCC.director.getAnimationManager() as AnimationManager).addSockets(this.node, this._sockets);
}
} }
@serializable @serializable
@@ -169,8 +174,8 @@ export class SkeletalAnimation extends Animation {
} }
public querySockets () { public querySockets () {
const animPaths = this._defaultClip && Object.keys(SkelAnimDataHub.getOrExtract(this._defaultClip).data).sort().reduce((acc, cur) => const animPaths = (this._defaultClip && Object.keys(SkelAnimDataHub.getOrExtract(this._defaultClip).data).sort()
cur.startsWith(acc[acc.length - 1]) ? acc : (acc.push(cur), acc), [] as string[]) || []; .reduce((acc, cur) => (cur.startsWith(acc[acc.length - 1]) ? acc : (acc.push(cur), acc)), [] as string[])) || [];
if (!animPaths.length) { return ['please specify a valid default animation clip first']; } if (!animPaths.length) { return ['please specify a valid default animation clip first']; }
const out: string[] = []; const out: string[] = [];
for (let i = 0; i < animPaths.length; i++) { for (let i = 0; i < animPaths.length; i++) {
@@ -186,7 +191,7 @@ export class SkeletalAnimation extends Animation {
public rebuildSocketAnimations () { public rebuildSocketAnimations () {
for (const socket of this._sockets) { for (const socket of this._sockets) {
const joint = this.node.getChildByPath(socket.path); const joint = this.node.getChildByPath(socket.path);
const target = socket.target; const { target } = socket;
if (joint && target) { if (joint && target) {
target.name = `${socket.path.substring(socket.path.lastIndexOf('/') + 1)} Socket`; target.name = `${socket.path.substring(socket.path.lastIndexOf('/') + 1)} Socket`;
target.parent = this.node; target.parent = this.node;
+5 -5
View File
@@ -47,12 +47,12 @@ import { IPipe, Pipeline } from './pipeline';
import preprocess from './preprocess'; import preprocess from './preprocess';
import releaseManager from './release-manager'; import releaseManager from './release-manager';
import RequestItem from './request-item'; import RequestItem from './request-item';
import { import {
CompleteCallback, CompleteCallback,
CompleteCallbackNoData, CompleteCallbackNoData,
ProgressCallback, ProgressCallback,
IBundleOptions, IBundleOptions,
INativeAssetOptions, INativeAssetOptions,
IOptions, IOptions,
IRemoteOptions, IRemoteOptions,
presets, presets,
@@ -520,7 +520,7 @@ export class AssetManager {
public postLoadNative (asset: Asset, options?: INativeAssetOptions | CompleteCallbackNoData | null, onComplete?: CompleteCallbackNoData | null) { public postLoadNative (asset: Asset, options?: INativeAssetOptions | CompleteCallbackNoData | null, onComplete?: CompleteCallbackNoData | null) {
const { options: opts, onComplete: onComp } = parseParameters(options, undefined, onComplete); const { options: opts, onComplete: onComp } = parseParameters(options, undefined, onComplete);
// @ts-ignore // @ts-expect-error
if (!asset._native || !asset.__nativeDepend__) { if (!asset._native || !asset.__nativeDepend__) {
return asyncify(onComp)(null); return asyncify(onComp)(null);
} }
@@ -536,10 +536,10 @@ export class AssetManager {
this.loadAny(depend, opts, (err, native) => { this.loadAny(depend, opts, (err, native) => {
if (!err) { if (!err) {
// @ts-ignore // @ts-expect-error
if (asset.isValid && asset.__nativeDepend__) { if (asset.isValid && asset.__nativeDepend__) {
asset._nativeAsset = native; asset._nativeAsset = native;
// @ts-ignore // @ts-expect-error
asset.__nativeDepend__ = false; asset.__nativeDepend__ = false;
} }
} }
+1 -1
View File
@@ -424,7 +424,7 @@ export default class Bundle {
} }
else if (sceneAsset instanceof SceneAsset && sceneAsset.scene) { else if (sceneAsset instanceof SceneAsset && sceneAsset.scene) {
const scene = sceneAsset.scene; const scene = sceneAsset.scene;
// @ts-ignore // @ts-expect-error
scene._id = sceneAsset._uuid; scene._id = sceneAsset._uuid;
scene.name = sceneAsset.name; scene.name = sceneAsset.name;
if (onComp) { onComp(null, sceneAsset); } if (onComp) { onComp(null, sceneAsset); }
+5 -5
View File
@@ -153,7 +153,7 @@ export class DependUtil {
return this._depends.get(uuid)!; return this._depends.get(uuid)!;
} }
// @ts-ignore // @ts-expect-error
if (Array.isArray(json) && (!(BUILD || isCompiledJson(json)) || !hasNativeDep(json))) { if (Array.isArray(json) && (!(BUILD || isCompiledJson(json)) || !hasNativeDep(json))) {
out = { out = {
deps: this._parseDepsFromJson(json), deps: this._parseDepsFromJson(json),
@@ -196,13 +196,13 @@ export class DependUtil {
preventPreloadNativeObject: (asset.constructor as typeof Asset).preventPreloadNativeObject, preventPreloadNativeObject: (asset.constructor as typeof Asset).preventPreloadNativeObject,
preventDeferredLoadDependents: (asset.constructor as typeof Asset).preventDeferredLoadDependents, preventDeferredLoadDependents: (asset.constructor as typeof Asset).preventDeferredLoadDependents,
}; };
// @ts-ignore // @ts-expect-error
const deps = asset.__depends__ as IDependProp[]; const deps = asset.__depends__ as IDependProp[];
for (let i = 0, l = deps.length; i < l; i++) { for (let i = 0, l = deps.length; i < l; i++) {
out.deps.push(deps[i].uuid); out.deps.push(deps[i].uuid);
} }
// @ts-ignore // @ts-expect-error
if (asset.__nativeDepend__) { if (asset.__nativeDepend__) {
out.nativeDep = asset._nativeDep; out.nativeDep = asset._nativeDep;
} }
@@ -214,7 +214,7 @@ export class DependUtil {
let depends: string[] | null = null; let depends: string[] | null = null;
if (DEV) { if (DEV) {
if (isCompiledJson(json)) { if (isCompiledJson(json)) {
// @ts-ignore // @ts-expect-error
depends = getDependUuidList(json); depends = getDependUuidList(json);
depends!.forEach((uuid, index) => depends![index] = decodeUuid(uuid)); depends!.forEach((uuid, index) => depends![index] = decodeUuid(uuid));
return depends!; return depends!;
@@ -242,7 +242,7 @@ export class DependUtil {
return depends; return depends;
} }
else { else {
// @ts-ignore // @ts-expect-error
depends = getDependUuidList(json); depends = getDependUuidList(json);
depends!.forEach((uuid, index) => depends![index] = decodeUuid(uuid)); depends!.forEach((uuid, index) => depends![index] = decodeUuid(uuid));
} }
+3 -3
View File
@@ -81,7 +81,7 @@ const md5Pipe = {
return match + '.' + hashValue; return match + '.' + hashValue;
}); });
} }
return url; return url;
}, },
}; };
@@ -113,7 +113,7 @@ export class CCLoader {
private _parseLoadResArgs = parseLoadResArgs; private _parseLoadResArgs = parseLoadResArgs;
public get _cache () { public get _cache () {
// @ts-ignore // @ts-expect-error
return assets._map; return assets._map;
} }
@@ -414,7 +414,7 @@ export class CCLoader {
return info.path; return info.path;
}); });
} }
// @ts-ignore // @ts-expect-error
if (onComplete) { onComplete(err, out, urls); } if (onComplete) { onComplete(err, out, urls); }
}); });
} }
+46 -43
View File
@@ -30,14 +30,19 @@
import { AudioClip } from '../../audio/assets/clip'; import { AudioClip } from '../../audio/assets/clip';
import { VideoClip } from '../../video/assets/video-clip'; import { VideoClip } from '../../video/assets/video-clip';
import { ImageAsset, JsonAsset, TextAsset, TTFFont, Asset } from '../assets'; import {
ImageAsset, JsonAsset, TextAsset, TTFFont, Asset,
} from '../assets';
import { BufferAsset } from '../assets/buffer-asset'; import { BufferAsset } from '../assets/buffer-asset';
import { js } from '../utils/js'; import { js } from '../utils/js';
import Bundle, { resources } from './bundle'; import Bundle, { resources } from './bundle';
import Cache from './cache'; import Cache from './cache';
import { IConfigOption } from './config'; import { IConfigOption } from './config';
import { assets, BuiltinBundleName, bundles, CompleteCallback, IRemoteOptions } from './shared'; import {
import { IDownloadParseOptions } from './shared'; assets, BuiltinBundleName, bundles, CompleteCallback, IRemoteOptions,
IDownloadParseOptions,
} from './shared';
import { cache } from './utilities'; import { cache } from './utilities';
export type CreateHandler = (id: string, data: any, options: IDownloadParseOptions, onComplete: CompleteCallback<Asset|Bundle>) => void; export type CreateHandler = (id: string, data: any, options: IDownloadParseOptions, onComplete: CompleteCallback<Asset|Bundle>) => void;
@@ -49,8 +54,7 @@ function createImageAsset (id: string, data: HTMLImageElement, options: IDownloa
out = new ImageAsset(); out = new ImageAsset();
out._nativeUrl = id; out._nativeUrl = id;
out._nativeAsset = data; out._nativeAsset = data;
} } catch (e) {
catch (e) {
err = e; err = e;
} }
onComplete(err, out); onComplete(err, out);
@@ -60,7 +64,7 @@ function createAudioClip (id: string, data: HTMLAudioElement | AudioBuffer, opti
const out = new AudioClip(); const out = new AudioClip();
out._nativeUrl = id; out._nativeUrl = id;
out._nativeAsset = data; out._nativeAsset = data;
// @ts-ignore // @ts-expect-error assignment to private field
out._duration = data.duration; out._duration = data.duration;
onComplete(null, out); onComplete(null, out);
} }
@@ -102,42 +106,41 @@ function createBundle (id: string, data: IConfigOption, options: IDownloadParseO
let bundle = bundles.get(data.name); let bundle = bundles.get(data.name);
if (!bundle) { if (!bundle) {
bundle = data.name === BuiltinBundleName.RESOURCES ? resources : new Bundle(); bundle = data.name === BuiltinBundleName.RESOURCES ? resources : new Bundle();
data.base = data.base || id + '/'; data.base = data.base || `${id}/`;
bundle.init(data); bundle.init(data);
} }
onComplete(null, bundle); onComplete(null, bundle);
} }
function createVideoClip (id: string, data: HTMLVideoElement, options: IDownloadParseOptions, onComplete: CompleteCallback<VideoClip>) { function createVideoClip (id: string, data: HTMLVideoElement, options: IDownloadParseOptions, onComplete: CompleteCallback<VideoClip>) {
let out = new VideoClip(); const out = new VideoClip();
out._nativeUrl = id; out._nativeUrl = id;
out._nativeAsset = data; out._nativeAsset = data;
onComplete(null, out); onComplete(null, out);
} }
export class Factory { export class Factory {
private _creating = new Cache<CompleteCallback[]>(); private _creating = new Cache<CompleteCallback[]>();
private _producers: Record<string, CreateHandler> = { private _producers: Record<string, CreateHandler> = {
// Images // Images
'.png' : createImageAsset, '.png': createImageAsset,
'.jpg' : createImageAsset, '.jpg': createImageAsset,
'.bmp' : createImageAsset, '.bmp': createImageAsset,
'.jpeg' : createImageAsset, '.jpeg': createImageAsset,
'.gif' : createImageAsset, '.gif': createImageAsset,
'.ico' : createImageAsset, '.ico': createImageAsset,
'.tiff' : createImageAsset, '.tiff': createImageAsset,
'.webp' : createImageAsset, '.webp': createImageAsset,
'.image' : createImageAsset, '.image': createImageAsset,
'.pvr': createImageAsset, '.pvr': createImageAsset,
'.pkm': createImageAsset, '.pkm': createImageAsset,
// Audio // Audio
'.mp3' : createAudioClip, '.mp3': createAudioClip,
'.ogg' : createAudioClip, '.ogg': createAudioClip,
'.wav' : createAudioClip, '.wav': createAudioClip,
'.m4a' : createAudioClip, '.m4a': createAudioClip,
// Video // Video
'.mp4': createVideoClip, '.mp4': createVideoClip,
@@ -149,26 +152,26 @@ export class Factory {
'.rmvb': createVideoClip, '.rmvb': createVideoClip,
// Txt // Txt
'.txt' : createTextAsset, '.txt': createTextAsset,
'.xml' : createTextAsset, '.xml': createTextAsset,
'.vsh' : createTextAsset, '.vsh': createTextAsset,
'.fsh' : createTextAsset, '.fsh': createTextAsset,
'.atlas' : createTextAsset, '.atlas': createTextAsset,
'.tmx' : createTextAsset, '.tmx': createTextAsset,
'.tsx' : createTextAsset, '.tsx': createTextAsset,
'.fnt' : createTextAsset, '.fnt': createTextAsset,
'.json' : createJsonAsset, '.json': createJsonAsset,
'.ExportJson' : createJsonAsset, '.ExportJson': createJsonAsset,
// font // font
'.font' : createFont, '.font': createFont,
'.eot' : createFont, '.eot': createFont,
'.ttf' : createFont, '.ttf': createFont,
'.woff' : createFont, '.woff': createFont,
'.svg' : createFont, '.svg': createFont,
'.ttc' : createFont, '.ttc': createFont,
// Binary // Binary
'.binary': createBufferAsset, '.binary': createBufferAsset,
@@ -176,17 +179,16 @@ export class Factory {
'.dbbin': createBufferAsset, '.dbbin': createBufferAsset,
'.skel': createBufferAsset, '.skel': createBufferAsset,
'bundle': createBundle, bundle: createBundle,
'default': createAsset, default: createAsset,
}; };
public register (type: string | Record<string, CreateHandler>, handler?: CreateHandler): void { public register (type: string | Record<string, CreateHandler>, handler?: CreateHandler): void {
if (typeof type === 'object') { if (typeof type === 'object') {
js.mixin(this._producers, type); js.mixin(this._producers, type);
} } else {
else {
this._producers[type] = handler!; this._producers[type] = handler!;
} }
} }
@@ -195,7 +197,8 @@ export class Factory {
const handler = this._producers[type] || this._producers.default; const handler = this._producers[type] || this._producers.default;
const asset = assets.get(id); const asset = assets.get(id);
if (!options.reloadAsset && asset) { if (!options.reloadAsset && asset) {
return onComplete(null, asset); onComplete(null, asset);
return;
} }
const creating = this._creating.get(id); const creating = this._creating.get(id);
if (creating) { if (creating) {
+1 -1
View File
@@ -57,7 +57,7 @@ export default function fetch (task: Task, done: CompleteCallbackNoData) {
if (!item.isNative && assets.has(item.uuid)) { if (!item.isNative && assets.has(item.uuid)) {
const asset = assets.get(item.uuid); const asset = assets.get(item.uuid);
asset!.addRef(); asset!.addRef();
// @ts-ignore // @ts-expect-error
handle(item, task, asset, null, asset.__asyncLoadAssets__, depends, total, done); handle(item, task, asset, null, asset.__asyncLoadAssets__, depends, total, done);
return cb(); return cb();
} }
+2 -2
View File
@@ -124,7 +124,7 @@ function nativeCheckFontLoaded (start: number, font: string, callback: CompleteC
reject(); reject();
} }
else { else {
// @ts-ignore // @ts-expect-error
document.fonts.load('40px ' + font).then((fonts) => { document.fonts.load('40px ' + font).then((fonts) => {
if (fonts.length >= 1) { if (fonts.length >= 1) {
resolve(); resolve();
@@ -236,4 +236,4 @@ export function _getFontFamily (fontHandle: string): string {
fontFamilyName = '"' + fontFamilyName + '"'; fontFamilyName = '"' + fontFamilyName + '"';
} }
return fontFamilyName; return fontFamilyName;
} }
+3 -3
View File
@@ -159,7 +159,7 @@ const loadOneAssetPipeline = new Pipeline('loadOneAsset', [
else { else {
if (!options.reloadAsset && assets.has(uuid)) { if (!options.reloadAsset && assets.has(uuid)) {
const asset = assets.get(uuid)!; const asset = assets.get(uuid)!;
// @ts-ignore // @ts-expect-error
if (options.__asyncLoadAssets__ || !asset.__asyncLoadAssets__) { if (options.__asyncLoadAssets__ || !asset.__asyncLoadAssets__) {
item.content = asset.addRef(); item.content = asset.addRef();
if (progress.canInvoke) { if (progress.canInvoke) {
@@ -207,7 +207,7 @@ function loadDepends (task: Task, asset: Asset, done: CompleteCallbackNoData, in
progress, progress,
onComplete: (err) => { onComplete: (err) => {
asset.decRef && asset.decRef(false); asset.decRef && asset.decRef(false);
// @ts-ignore // @ts-expect-error
asset.__asyncLoadAssets__ = __asyncLoadAssets__; asset.__asyncLoadAssets__ = __asyncLoadAssets__;
repeatItem.finish = true; repeatItem.finish = true;
repeatItem.err = err; repeatItem.err = err;
@@ -222,7 +222,7 @@ function loadDepends (task: Task, asset: Asset, done: CompleteCallbackNoData, in
} }
if (!init) { if (!init) {
// @ts-ignore // @ts-expect-error
if (asset.__nativeDepend__) { if (asset.__nativeDepend__) {
if (!setProperties(uuid, asset, map)) { if (!setProperties(uuid, asset, map)) {
try { try {
+1 -1
View File
@@ -89,7 +89,7 @@ export class PackManager {
if (Array.isArray(json)) { if (Array.isArray(json)) {
// @ts-ignore // @ts-expect-error
json = unpackJSONs(json, MissingScript.safeFindClass); json = unpackJSONs(json, MissingScript.safeFindClass);
if (json.length !== pack.length) { if (json.length !== pack.length) {
+4 -4
View File
@@ -163,7 +163,7 @@ class ReleaseManager {
// transfer refs from persist nodes to new scene // transfer refs from persist nodes to new scene
for (let i = 0, l = persistNodes.length; i < l; i++) { for (let i = 0, l = persistNodes.length; i < l; i++) {
const node = persistNodes[i]; const node = persistNodes[i];
// @ts-ignore // @ts-expect-error
const sceneDeps = dependUtil._depends.get(newScene._id); const sceneDeps = dependUtil._depends.get(newScene._id);
const deps = this._persistNodeDeps.get(node.uuid) as string[]; const deps = this._persistNodeDeps.get(node.uuid) as string[];
for (const dep of deps) { for (const dep of deps) {
@@ -182,7 +182,7 @@ class ReleaseManager {
if (!oldScene) { return; } if (!oldScene) { return; }
// @ts-ignore // @ts-expect-error
const childs = dependUtil.getDeps(oldScene._id); const childs = dependUtil.getDeps(oldScene._id);
for (let i = 0, l = childs.length; i < l; i++) { for (let i = 0, l = childs.length; i < l; i++) {
const asset = assets.get(childs[i]); const asset = assets.get(childs[i]);
@@ -190,7 +190,7 @@ class ReleaseManager {
asset.decRef(TEST || oldScene.autoReleaseAssets); asset.decRef(TEST || oldScene.autoReleaseAssets);
} }
} }
// @ts-ignore // @ts-expect-error
const dependencies = dependUtil._depends.get(oldScene._id); const dependencies = dependUtil._depends.get(oldScene._id);
if (dependencies && dependencies.persistDeps) { if (dependencies && dependencies.persistDeps) {
const persistDeps = dependencies.persistDeps; const persistDeps = dependencies.persistDeps;
@@ -201,7 +201,7 @@ class ReleaseManager {
} }
} }
} }
// @ts-ignore // @ts-expect-error
dependUtil.remove(oldScene._id); dependUtil.remove(oldScene._id);
} }
+5 -5
View File
@@ -94,7 +94,7 @@ export function getDepends (uuid: string, data: Asset | Record<string, any>, exc
try { try {
const info = dependUtil.parse(uuid, data); const info = dependUtil.parse(uuid, data);
let includeNative = true; let includeNative = true;
// @ts-ignore // @ts-expect-error
if (data instanceof Asset && (!data.__nativeDepend__)) { includeNative = false; } if (data instanceof Asset && (!data.__nativeDepend__)) { includeNative = false; }
if (!preload) { if (!preload) {
asyncLoadAssets = !EDITOR && (!!(data as SceneAsset|Prefab).asyncLoadAssets || (asyncLoadAssets && !info.preventDeferredLoadDependents)); asyncLoadAssets = !EDITOR && (!!(data as SceneAsset|Prefab).asyncLoadAssets || (asyncLoadAssets && !info.preventDeferredLoadDependents));
@@ -145,7 +145,7 @@ export function cache (id: string, asset: Asset, cacheAsset?: boolean) {
export function setProperties (uuid: string, asset: Asset, assetsMap: Record<string, any>) { export function setProperties (uuid: string, asset: Asset, assetsMap: Record<string, any>) {
let missingAsset = false; let missingAsset = false;
// @ts-ignore // @ts-expect-error
const depends = asset.__depends__ as IDependProp[]; const depends = asset.__depends__ as IDependProp[];
if (depends) { if (depends) {
let missingAssetReporter: any = null; let missingAssetReporter: any = null;
@@ -180,11 +180,11 @@ export function setProperties (uuid: string, asset: Asset, assetsMap: Record<str
if (missingAssetReporter) { if (missingAssetReporter) {
missingAssetReporter.reportByOwner(); missingAssetReporter.reportByOwner();
} }
// @ts-ignore // @ts-expect-error
asset.__depends__ = null; asset.__depends__ = null;
} }
// @ts-ignore // @ts-expect-error
if (asset.__nativeDepend__) { if (asset.__nativeDepend__) {
if (assetsMap[uuid + '@native']) { if (assetsMap[uuid + '@native']) {
asset._nativeAsset = assetsMap[uuid + '@native']; asset._nativeAsset = assetsMap[uuid + '@native'];
@@ -195,7 +195,7 @@ export function setProperties (uuid: string, asset: Asset, assetsMap: Record<str
console.error(`the native asset of ${uuid} is missing!`); console.error(`the native asset of ${uuid} is missing!`);
} }
} }
// @ts-ignore // @ts-expect-error
asset.__nativeDepend__ = false; asset.__nativeDepend__ = false;
} }
return missingAsset; return missingAsset;
+1 -1
View File
@@ -295,7 +295,7 @@ export class Asset extends Eventify(CCObject) {
*/ */
type CreateNodeCallback = (error: Error | null, node: Node) => void; type CreateNodeCallback = (error: Error | null, node: Node) => void;
// @ts-ignore // @ts-expect-error
Asset.prototype.createNode = null; Asset.prototype.createNode = null;
legacyCC.Asset = Asset; legacyCC.Asset = Asset;
+1 -1
View File
@@ -40,7 +40,7 @@ replaceProperty(RenderTexture.prototype, 'RenderTexture.prototype', [
{ {
name: 'getGFXWindow', name: 'getGFXWindow',
customFunction () { customFunction () {
// @ts-ignore // @ts-expect-error
return this._window; return this._window;
}, },
}, },
+1 -1
View File
@@ -38,7 +38,7 @@ import { legacyCC } from '../global-exports';
* *
*/ */
@ccclass('cc.LabelAtlas') @ccclass('cc.LabelAtlas')
export class LabelAtlas extends BitmapFont{ export class LabelAtlas extends BitmapFont {
} }
legacyCC.LabelAtlas = LabelAtlas; legacyCC.LabelAtlas = LabelAtlas;
+38 -30
View File
@@ -28,18 +28,18 @@
* @module material * @module material
*/ */
import { ccclass, type, serializable } from 'cc.decorator'; import { ccclass, serializable, type } from 'cc.decorator';
import { builtinResMgr } from '../3d/builtin/init';
import { RenderableComponent } from '../3d/framework/renderable-component';
import { Texture } from '../gfx';
import { MacroRecord, MaterialProperty, PropertyType } from '../renderer/core/pass-utils';
import { IPassInfoFull, Pass, PassOverrides } from '../renderer/core/pass';
import { legacyCC } from '../global-exports';
import { Asset } from './asset'; import { Asset } from './asset';
import { EffectAsset } from './effect-asset'; import { EffectAsset } from './effect-asset';
import { SpriteFrame } from './sprite-frame';
import { TextureBase } from './texture-base';
import { RenderTexture } from './render-texture'; import { RenderTexture } from './render-texture';
import { RenderableComponent } from '../3d/framework/renderable-component';
import { SpriteFrame } from './sprite-frame';
import { Texture } from '../gfx';
import { TextureBase } from './texture-base';
import { builtinResMgr } from '../3d/builtin/init';
import { legacyCC } from '../global-exports';
import { IPassInfoFull, Pass, PassOverrides } from '../renderer/core/pass';
import { MacroRecord, MaterialProperty, PropertyType } from '../renderer/core/pass-utils';
/** /**
* @en The basic infos for material initialization. * @en The basic infos for material initialization.
@@ -91,7 +91,6 @@ type MaterialPropertyFull = MaterialProperty | TextureBase | SpriteFrame | Rende
*/ */
@ccclass('cc.Material') @ccclass('cc.Material')
export class Material extends Asset { export class Material extends Asset {
/** /**
* @en Get hash for a material * @en Get hash for a material
* @zh 获取一个材质的哈希值 * @zh 获取一个材质的哈希值
@@ -107,18 +106,28 @@ export class Material extends Asset {
@type(EffectAsset) @type(EffectAsset)
protected _effectAsset: EffectAsset | null = null; protected _effectAsset: EffectAsset | null = null;
@serializable @serializable
protected _techIdx = 0; protected _techIdx = 0;
@serializable @serializable
protected _defines: MacroRecord[] = []; protected _defines: MacroRecord[] = [];
@serializable @serializable
protected _states: PassOverrides[] = []; protected _states: PassOverrides[] = [];
@serializable @serializable
protected _props: Record<string, MaterialPropertyFull | MaterialPropertyFull[]>[] = []; protected _props: Record<string, MaterialPropertyFull | MaterialPropertyFull[]>[] = [];
protected _passes: Pass[] = []; protected _passes: Pass[] = [];
protected _hash = 0; protected _hash = 0;
constructor () {
super();
this.loaded = false;
}
/** /**
* @en The current [[EffectAsset]]. * @en The current [[EffectAsset]].
* @zh 当前使用的 [[EffectAsset]] 资源。 * @zh 当前使用的 [[EffectAsset]] 资源。
@@ -175,11 +184,6 @@ export class Material extends Asset {
return null; return null;
} }
constructor () {
super();
this.loaded = false;
}
/** /**
* @en Initialize this material with the given information. * @en Initialize this material with the given information.
* @zh 根据所给信息初始化这个材质,初始化正常结束后材质即可立即用于渲染。 * @zh 根据所给信息初始化这个材质,初始化正常结束后材质即可立即用于渲染。
@@ -190,12 +194,16 @@ export class Material extends Asset {
if (!this._states) { this._states = []; } if (!this._states) { this._states = []; }
if (!this._props) { this._props = []; } if (!this._props) { this._props = []; }
if (info.technique !== undefined) { this._techIdx = info.technique; } if (info.technique !== undefined) { this._techIdx = info.technique; }
if (info.effectAsset) { this._effectAsset = info.effectAsset; } if (info.effectAsset) {
else if (info.effectName) { this._effectAsset = EffectAsset.get(info.effectName); } this._effectAsset = info.effectAsset;
} else if (info.effectName) {
this._effectAsset = EffectAsset.get(info.effectName);
}
if (info.defines) { this._prepareInfo(info.defines, this._defines); } if (info.defines) { this._prepareInfo(info.defines, this._defines); }
if (info.states) { this._prepareInfo(info.states, this._states); } if (info.states) { this._prepareInfo(info.states, this._states); }
this._update(); this._update();
} }
public reset (info: IMaterialInfo) { // to be consistent with other assets public reset (info: IMaterialInfo) { // to be consistent with other assets
this.initialize(info); this.initialize(info);
} }
@@ -221,7 +229,7 @@ export class Material extends Asset {
* @param passIdx The pass to apply to. Will apply to all passes if not specified. * @param passIdx The pass to apply to. Will apply to all passes if not specified.
*/ */
public recompileShaders (overrides: MacroRecord, passIdx?: number) { public recompileShaders (overrides: MacroRecord, passIdx?: number) {
console.warn('Shaders in material asset \'' + this.name + '\' cannot be modified at runtime, please instantiate the material first.'); console.warn(`Shaders in material asset '${this.name}' cannot be modified at runtime, please instantiate the material first.`);
} }
/** /**
@@ -231,7 +239,7 @@ export class Material extends Asset {
* @param passIdx The pass to apply to. Will apply to all passes if not specified. * @param passIdx The pass to apply to. Will apply to all passes if not specified.
*/ */
public overridePipelineStates (overrides: PassOverrides, passIdx?: number) { public overridePipelineStates (overrides: PassOverrides, passIdx?: number) {
console.warn('Pipeline states in material asset \'' + this.name + '\' cannot be modified at runtime, please instantiate the material first.'); console.warn(`Pipeline states in material asset '${this.name}' cannot be modified at runtime, please instantiate the material first.`);
} }
/** /**
@@ -292,7 +300,6 @@ export class Material extends Asset {
} }
if (!success) { if (!success) {
console.warn(`illegal property name: ${name}.`); console.warn(`illegal property name: ${name}.`);
return;
} }
} }
@@ -333,27 +340,28 @@ export class Material extends Asset {
this._techIdx = mat._techIdx; this._techIdx = mat._techIdx;
this._props.length = mat._props.length; this._props.length = mat._props.length;
for (let i = 0; i < mat._props.length; i++) { for (let i = 0; i < mat._props.length; i++) {
this._props[i] = Object.assign({}, mat._props[i]); this._props[i] = { ...mat._props[i] };
} }
this._defines.length = mat._defines.length; this._defines.length = mat._defines.length;
for (let i = 0; i < mat._defines.length; i++) { for (let i = 0; i < mat._defines.length; i++) {
this._defines[i] = Object.assign({}, mat._defines[i]); this._defines[i] = { ...mat._defines[i] };
} }
this._states.length = mat._states.length; this._states.length = mat._states.length;
for (let i = 0; i < mat._states.length; i++) { for (let i = 0; i < mat._states.length; i++) {
this._states[i] = Object.assign({}, mat._states[i]); this._states[i] = { ...mat._states[i] };
} }
this._effectAsset = mat._effectAsset; this._effectAsset = mat._effectAsset;
this._update(); this._update();
} }
protected _prepareInfo (patch: object | object[], cur: object[]) { protected _prepareInfo (patch: Record<string, unknown> | Record<string, unknown>[], cur: Record<string, unknown>[]) {
if (!Array.isArray(patch)) { // fill all the passes if not specified let patchArray = patch;
if (!Array.isArray(patchArray)) { // fill all the passes if not specified
const len = this._effectAsset ? this._effectAsset.techniques[this._techIdx].passes.length : 1; const len = this._effectAsset ? this._effectAsset.techniques[this._techIdx].passes.length : 1;
patch = Array(len).fill(patch); patchArray = Array(len).fill(patchArray);
} }
for (let i = 0; i < (patch as object[]).length; ++i) { for (let i = 0; i < patchArray.length; ++i) {
Object.assign(cur[i] || (cur[i] = {}), patch[i]); Object.assign(cur[i] || (cur[i] = {}), patchArray[i]);
} }
} }
@@ -382,7 +390,7 @@ export class Material extends Asset {
return passes; return passes;
} }
protected _update (keepProps: boolean = true) { protected _update (keepProps = true) {
if (this._effectAsset) { if (this._effectAsset) {
if (this._passes && this._passes.length) { if (this._passes && this._passes.length) {
for (const pass of this._passes) { for (const pass of this._passes) {
@@ -446,7 +454,7 @@ export class Material extends Asset {
const texture: Texture | null = val.getGFXTexture(); const texture: Texture | null = val.getGFXTexture();
if (!texture || !texture.width || !texture.height) { if (!texture || !texture.width || !texture.height) {
// console.warn(`material '${this._uuid}' received incomplete texture asset '${val._uuid}'`); // console.warn(`material '${this._uuid}' received incomplete texture asset '${val._uuid}'`);
return false; return;
} }
pass.bindTexture(binding, texture, index); pass.bindTexture(binding, texture, index);
pass.bindSampler(binding, val.getGFXSampler(), index); pass.bindSampler(binding, val.getGFXSampler(), index);
+196 -179
View File
@@ -29,39 +29,44 @@
*/ */
import { ccclass, serializable } from 'cc.decorator'; import { ccclass, serializable } from 'cc.decorator';
import { Mat4, Quat, Vec3 } from '../../core/math'; import { Asset } from './asset';
import { mapBuffer } from '../3d/misc/buffer';
import { BufferBlob } from '../3d/misc/buffer-blob'; import { BufferBlob } from '../3d/misc/buffer-blob';
import { Skeleton } from './skeleton';
import { aabb } from '../geometry'; import { aabb } from '../geometry';
import { Buffer, BufferInfo } from '../gfx'; import { legacyCC } from '../global-exports';
import { mapBuffer } from '../3d/misc/buffer';
import { murmurhash2_32_gc } from '../utils/murmurhash2_gc';
import { sys } from '../platform/sys';
import { warnID } from '../platform/debug';
import {
Attribute, Device, InputAssemblerInfo, Buffer, BufferInfo,
} from '../gfx';
import { import {
getTypedArrayConstructor,
AttributeName, AttributeName,
BufferUsageBit, BufferUsageBit,
Feature,
Format, Format,
FormatInfos, FormatInfos,
FormatType, FormatType,
MemoryUsageBit, MemoryUsageBit,
PrimitiveMode, PrimitiveMode,
Feature getTypedArrayConstructor,
} from '../gfx/define'; } from '../gfx/define';
import { Device, Attribute, InputAssemblerInfo } from '../gfx';
import { warnID } from '../platform/debug'; import {
import { sys } from '../platform/sys'; FlatBufferArrayPool, FlatBufferPool, FlatBufferView, NULL_HANDLE, RawBufferPool,
import { murmurhash2_32_gc } from '../utils/murmurhash2_gc'; SubMeshHandle, SubMeshPool, SubMeshView, freeHandleArray,
import { Asset } from './asset'; } from '../renderer/core/memory-pools';
import { Skeleton } from './skeleton'; import { Mat4, Quat, Vec3 } from '../math';
import { Morph, createMorphRendering, MorphRendering } from './morph'; import { Morph, MorphRendering, createMorphRendering } from './morph';
import { legacyCC } from '../global-exports';
import { FlatBufferArrayPool, FlatBufferPool, FlatBufferView, freeHandleArray, NULL_HANDLE, RawBufferPool, SubMeshHandle, SubMeshPool, SubMeshView } from '../renderer/core/memory-pools';
function getIndexStrideCtor (stride: number) { function getIndexStrideCtor (stride: number) {
switch (stride) { switch (stride) {
case 1: return Uint8Array; case 1: return Uint8Array;
case 2: return Uint16Array; case 2: return Uint16Array;
case 4: return Uint32Array; case 4: return Uint32Array;
default: return Uint8Array;
} }
return Uint8Array;
} }
/** /**
@@ -97,7 +102,7 @@ export interface IGeometricInfo {
* @en The bounding box * @en The bounding box
* @zh 此几何体的轴对齐包围盒。 * @zh 此几何体的轴对齐包围盒。
*/ */
boundingBox: { max: Vec3; min: Vec3; } boundingBox: { max: Vec3; min: Vec3 };
} }
/** /**
@@ -115,22 +120,67 @@ export interface IFlatBuffer {
* @zh 包含所有顶点数据的渲染子网格,可以用来创建 [[InputAssembler]]。 * @zh 包含所有顶点数据的渲染子网格,可以用来创建 [[InputAssembler]]。
*/ */
export class RenderingSubMesh { export class RenderingSubMesh {
public mesh?: Mesh;
public subMeshIdx?: number;
private _flatBuffers: IFlatBuffer[] = [];
private _jointMappedBuffers?: Buffer[];
private _jointMappedBufferIndices?: number[];
private _vertexIdChannel?: { stream: number; index: number };
private _geometricInfo?: IGeometricInfo;
private _vertexBuffers: Buffer[];
private _attributes: Attribute[];
private _indexBuffer: Buffer | null = null;
private _indirectBuffer: Buffer | null = null;
private _primitiveMode: PrimitiveMode;
private _iaInfo: InputAssemblerInfo;
private _handle: SubMeshHandle = NULL_HANDLE;
constructor (
vertexBuffers: Buffer[], attributes: Attribute[], primitiveMode: PrimitiveMode,
indexBuffer: Buffer | null = null, indirectBuffer: Buffer | null = null,
) {
this._attributes = attributes;
this._vertexBuffers = vertexBuffers;
this._indexBuffer = indexBuffer;
this._indirectBuffer = indirectBuffer;
this._primitiveMode = primitiveMode;
this._iaInfo = new InputAssemblerInfo(attributes, vertexBuffers, indexBuffer, indirectBuffer);
this._handle = SubMeshPool.alloc();
const fbArrayHandle = FlatBufferArrayPool.alloc();
SubMeshPool.set(this._handle, SubMeshView.FLAT_BUFFER_ARRAY, fbArrayHandle);
}
/** /**
* @en All vertex attributes used by the sub mesh * @en All vertex attributes used by the sub mesh
* @zh 所有顶点属性。 * @zh 所有顶点属性。
*/ */
get attributes () { return this._attributes; } get attributes () { return this._attributes; }
/** /**
* @en All vertex buffers used by the sub mesh * @en All vertex buffers used by the sub mesh
* @zh 使用的所有顶点缓冲区。 * @zh 使用的所有顶点缓冲区。
*/ */
get vertexBuffers () { return this._vertexBuffers; } get vertexBuffers () { return this._vertexBuffers; }
/** /**
* @en Index buffer used by the sub mesh * @en Index buffer used by the sub mesh
* @zh 使用的索引缓冲区,若未使用则无需指定。 * @zh 使用的索引缓冲区,若未使用则无需指定。
*/ */
get indexBuffer () { return this._indexBuffer; } get indexBuffer () { return this._indexBuffer; }
/** /**
* @en Indirect buffer used by the sub mesh * @en Indirect buffer used by the sub mesh
* @zh 间接绘制缓冲区。 * @zh 间接绘制缓冲区。
@@ -157,12 +207,12 @@ export class RenderingSubMesh {
if (this.subMeshIdx === undefined) { if (this.subMeshIdx === undefined) {
return { positions: new Float32Array(), indices: new Uint8Array(), boundingBox: { min: Vec3.ZERO, max: Vec3.ZERO } }; return { positions: new Float32Array(), indices: new Uint8Array(), boundingBox: { min: Vec3.ZERO, max: Vec3.ZERO } };
} }
const mesh = this.mesh!; const index = this.subMeshIdx!; const { mesh } = this; const index = this.subMeshIdx;
const positions = mesh.readAttribute(index, AttributeName.ATTR_POSITION) as unknown as Float32Array; const positions = mesh.readAttribute(index, AttributeName.ATTR_POSITION) as unknown as Float32Array;
const indices = mesh.readIndices(index) as Uint16Array; const indices = mesh.readIndices(index) as Uint16Array;
const max = new Vec3(); const max = new Vec3();
const min = new Vec3(); const min = new Vec3();
const pAttri = this.attributes.find(element => element.name === AttributeName.ATTR_POSITION); const pAttri = this.attributes.find((element) => element.name === AttributeName.ATTR_POSITION);
if (pAttri) { if (pAttri) {
const conut = FormatInfos[pAttri.format].count; const conut = FormatInfos[pAttri.format].count;
if (conut === 2) { if (conut === 2) {
@@ -197,27 +247,29 @@ export class RenderingSubMesh {
* @zh 扁平化的顶点缓冲区。 * @zh 扁平化的顶点缓冲区。
*/ */
get flatBuffers () { return this._flatBuffers; } get flatBuffers () { return this._flatBuffers; }
public genFlatBuffers() {
public genFlatBuffers () {
if (this._flatBuffers.length || !this.mesh || this.subMeshIdx === undefined) { return; } if (this._flatBuffers.length || !this.mesh || this.subMeshIdx === undefined) { return; }
const mesh = this.mesh; const { mesh } = this;
let idxCount = 0; let idxCount = 0;
const prim = mesh.struct.primitives[this.subMeshIdx]; const prim = mesh.struct.primitives[this.subMeshIdx];
const fbArrayHandle = SubMeshPool.get(this._handle, SubMeshView.FLAT_BUFFER_ARRAY); const fbArrayHandle = SubMeshPool.get(this._handle, SubMeshView.FLAT_BUFFER_ARRAY);
if (prim.indexView) { idxCount = prim.indexView.count; } if (prim.indexView) { idxCount = prim.indexView.count; }
for (const bundleIdx of prim.vertexBundelIndices) { for (let i = 0; i < prim.vertexBundelIndices.length; i++) {
const bundleIdx = prim.vertexBundelIndices[i];
const vertexBundle = mesh.struct.vertexBundles[bundleIdx]; const vertexBundle = mesh.struct.vertexBundles[bundleIdx];
const vbCount = prim.indexView ? prim.indexView.count : vertexBundle.view.count; const vbCount = prim.indexView ? prim.indexView.count : vertexBundle.view.count;
const vbStride = vertexBundle.view.stride; const vbStride = vertexBundle.view.stride;
const vbSize = vbStride * vbCount; const vbSize = vbStride * vbCount;
const rawBufferSize = prim.indexView ? vertexBundle.view.length : vbSize; const rawBufferSize = prim.indexView ? vertexBundle.view.length : vbSize;
const hBuffer = RawBufferPool.alloc(rawBufferSize); const hBuffer = RawBufferPool.alloc(rawBufferSize);
const buffer = RawBufferPool.getBuffer(hBuffer); const buffer = RawBufferPool.getBuffer(hBuffer);
const view = prim.indexView ? new Uint8Array(buffer) : new Uint8Array(rawBufferSize); const view = prim.indexView ? new Uint8Array(buffer) : new Uint8Array(rawBufferSize);
const hFlatBuffer = FlatBufferPool.alloc(); const hFlatBuffer = FlatBufferPool.alloc();
view.set(mesh.data.subarray(vertexBundle.view.offset, vertexBundle.view.offset + vertexBundle.view.length)); view.set(mesh.data.subarray(vertexBundle.view.offset, vertexBundle.view.offset + vertexBundle.view.length));
if (!prim.indexView) { if (!prim.indexView) {
FlatBufferPool.set(hFlatBuffer, FlatBufferView.STRIDE, vbStride); FlatBufferPool.set(hFlatBuffer, FlatBufferView.STRIDE, vbStride);
FlatBufferPool.set(hFlatBuffer, FlatBufferView.AMOUNT, vbCount); FlatBufferPool.set(hFlatBuffer, FlatBufferView.AMOUNT, vbCount);
@@ -243,7 +295,6 @@ export class RenderingSubMesh {
FlatBufferArrayPool.push(fbArrayHandle, hFlatBuffer); FlatBufferArrayPool.push(fbArrayHandle, hFlatBuffer);
this._flatBuffers.push({ stride: vbStride, count: vbCount, buffer: vbView }); this._flatBuffers.push({ stride: vbStride, count: vbCount, buffer: vbView });
} }
return this._flatBuffers;
} }
/** /**
@@ -255,14 +306,14 @@ export class RenderingSubMesh {
const buffers: Buffer[] = this._jointMappedBuffers = []; const buffers: Buffer[] = this._jointMappedBuffers = [];
const indices: number[] = this._jointMappedBufferIndices = []; const indices: number[] = this._jointMappedBufferIndices = [];
if (!this.mesh || this.subMeshIdx === undefined) { return this._jointMappedBuffers = this.vertexBuffers; } if (!this.mesh || this.subMeshIdx === undefined) { return this._jointMappedBuffers = this.vertexBuffers; }
const struct = this.mesh.struct; const { struct } = this.mesh;
const prim = struct.primitives[this.subMeshIdx]; const prim = struct.primitives[this.subMeshIdx];
if (!struct.jointMaps || prim.jointMapIndex === undefined || !struct.jointMaps[prim.jointMapIndex]) { if (!struct.jointMaps || prim.jointMapIndex === undefined || !struct.jointMaps[prim.jointMapIndex]) {
return this._jointMappedBuffers = this.vertexBuffers; return this._jointMappedBuffers = this.vertexBuffers;
} }
let jointFormat: Format; let jointFormat: Format;
let jointOffset: number; let jointOffset: number;
const device: Device = legacyCC.director.root.device; const { device } = legacyCC.director.root;
for (let i = 0; i < prim.vertexBundelIndices.length; i++) { for (let i = 0; i < prim.vertexBundelIndices.length; i++) {
const bundle = struct.vertexBundles[prim.vertexBundelIndices[i]]; const bundle = struct.vertexBundles[prim.vertexBundelIndices[i]];
jointOffset = 0; jointOffset = 0;
@@ -300,42 +351,10 @@ export class RenderingSubMesh {
get iaInfo () { return this._iaInfo; } get iaInfo () { return this._iaInfo; }
public mesh?: Mesh;
public subMeshIdx?: number;
private _flatBuffers: IFlatBuffer[] = [];
private _jointMappedBuffers?: Buffer[];
private _jointMappedBufferIndices?: number[];
private _vertexIdChannel?: { stream: number; index: number; };
private _geometricInfo?: IGeometricInfo;
private _vertexBuffers: Buffer[];
private _attributes: Attribute[];
private _indexBuffer: Buffer | null = null;
private _indirectBuffer: Buffer | null = null;
private _primitiveMode: PrimitiveMode;
private _iaInfo: InputAssemblerInfo;
private _handle: SubMeshHandle = NULL_HANDLE;
get handle () { get handle () {
return this._handle; return this._handle;
} }
constructor (
vertexBuffers: Buffer[], attributes: Attribute[], primitiveMode: PrimitiveMode,
indexBuffer: Buffer | null = null, indirectBuffer: Buffer | null = null,
) {
this._attributes = attributes;
this._vertexBuffers = vertexBuffers;
this._indexBuffer = indexBuffer;
this._indirectBuffer = indirectBuffer;
this._primitiveMode = primitiveMode;
this._iaInfo = new InputAssemblerInfo(attributes, vertexBuffers, indexBuffer, indirectBuffer);
this._handle = SubMeshPool.alloc();
const fbArrayHandle = FlatBufferArrayPool.alloc();
SubMeshPool.set(this._handle, SubMeshView.FLAT_BUFFER_ARRAY, fbArrayHandle);
}
public destroy () { public destroy () {
for (let i = 0; i < this.vertexBuffers.length; i++) { for (let i = 0; i < this.vertexBuffers.length; i++) {
this.vertexBuffers[i].destroy(); this.vertexBuffers[i].destroy();
@@ -356,7 +375,7 @@ export class RenderingSubMesh {
this._indirectBuffer.destroy(); this._indirectBuffer.destroy();
this._indirectBuffer = null; this._indirectBuffer = null;
} }
if(this._handle) { if (this._handle) {
const fbArrayHandle = SubMeshPool.get(this._handle, SubMeshView.FLAT_BUFFER_ARRAY); const fbArrayHandle = SubMeshPool.get(this._handle, SubMeshView.FLAT_BUFFER_ARRAY);
freeHandleArray(fbArrayHandle, FlatBufferArrayPool, FlatBufferPool); freeHandleArray(fbArrayHandle, FlatBufferArrayPool, FlatBufferPool);
@@ -391,14 +410,14 @@ export class RenderingSubMesh {
} }
private _allocVertexIdBuffer (device: Device) { private _allocVertexIdBuffer (device: Device) {
const vertexCount = (this.vertexBuffers.length === 0 || this.vertexBuffers[0].stride === 0) ? const vertexCount = (this.vertexBuffers.length === 0 || this.vertexBuffers[0].stride === 0)
0 : ? 0
// TODO: This depends on how stride of a vertex buffer is defined; Consider padding problem. // TODO: This depends on how stride of a vertex buffer is defined; Consider padding problem.
this.vertexBuffers[0].size / this.vertexBuffers[0].stride; : this.vertexBuffers[0].size / this.vertexBuffers[0].stride;
const vertexIds = new Float32Array(vertexCount); const vertexIds = new Float32Array(vertexCount);
for (let iVertex = 0; iVertex < vertexCount; ++iVertex) { for (let iVertex = 0; iVertex < vertexCount; ++iVertex) {
// `+0.5` because on some platforms, the "fetched integer" may have small error. // `+0.5` because on some platforms, the "fetched integer" may have small error.
// For example `26` may yield `25.99999`, which is convert to `25` instead of `26` using `int()`. // For example `26` may yield `25.99999`, which is convert to `25` instead of `26` using `int()`.
vertexIds[iVertex] = iVertex + 0.5; vertexIds[iVertex] = iVertex + 0.5;
} }
@@ -543,7 +562,6 @@ const globalEmptyMeshBuffer = new Uint8Array();
*/ */
@ccclass('cc.Mesh') @ccclass('cc.Mesh')
export class Mesh extends Asset { export class Mesh extends Asset {
get _nativeAsset (): ArrayBuffer { get _nativeAsset (): ArrayBuffer {
return this._data.buffer; return this._data.buffer;
} }
@@ -607,7 +625,7 @@ export class Mesh extends Asset {
* @zh 此网格的哈希值。 * @zh 此网格的哈希值。
*/ */
get hash () { get hash () {
// hashes should already be computed offline, but if not, make one // hashes should already be computed offline, but if not, make one
if (!this._hash) { this._hash = murmurhash2_32_gc(this._data, 666); } if (!this._hash) { this._hash = murmurhash2_32_gc(this._data, 666); }
return this._hash; return this._hash;
} }
@@ -629,6 +647,8 @@ export class Mesh extends Asset {
return this._renderingSubMeshes!; return this._renderingSubMeshes!;
} }
public morphRendering: MorphRendering | null = null;
@serializable @serializable
private _struct: Mesh.IStruct = { private _struct: Mesh.IStruct = {
vertexBundles: [], vertexBundles: [],
@@ -642,9 +662,13 @@ export class Mesh extends Asset {
private _hash = 0; private _hash = 0;
private _data: Uint8Array = globalEmptyMeshBuffer; private _data: Uint8Array = globalEmptyMeshBuffer;
private _initialized = false; private _initialized = false;
private _renderingSubMeshes: RenderingSubMesh[] | null = null; private _renderingSubMeshes: RenderingSubMesh[] | null = null;
private _boneSpaceBounds = new Map<number, (aabb | null)[]>();
private _boneSpaceBounds: Map<number, (aabb | null)[]> = new Map();
private _jointBufferIndices: number[] | null = null; private _jointBufferIndices: number[] | null = null;
constructor () { constructor () {
@@ -660,12 +684,12 @@ export class Mesh extends Asset {
this._initialized = true; this._initialized = true;
if (this._data.byteLength !== this._dataLength) { if (this._data.byteLength !== this._dataLength) {
// In the case of deferred loading, `this._data` is created before // In the case of deferred loading, `this._data` is created before
// the actual binary buffer is loaded. // the actual binary buffer is loaded.
this._data = new Uint8Array(this._dataLength); this._data = new Uint8Array(this._dataLength);
legacyCC.assetManager.postLoadNative(this); legacyCC.assetManager.postLoadNative(this);
} }
const buffer = this._data.buffer; const { buffer } = this._data;
const gfxDevice: Device = legacyCC.director.root.device; const gfxDevice: Device = legacyCC.director.root.device;
const vertexBuffers = this._createVertexBuffers(gfxDevice, buffer); const vertexBuffers = this._createVertexBuffers(gfxDevice, buffer);
const indexBuffers: Buffer[] = []; const indexBuffers: Buffer[] = [];
@@ -709,8 +733,7 @@ export class Mesh extends Asset {
} }
if (this.loaded) { if (this.loaded) {
indexBuffer.update(ib); indexBuffer.update(ib);
} } else {
else {
this.once('load', () => { this.once('load', () => {
indexBuffer!.update(ib); indexBuffer!.update(ib);
}); });
@@ -807,12 +830,12 @@ export class Mesh extends Asset {
const bounds: (aabb | null)[] = []; const bounds: (aabb | null)[] = [];
this._boneSpaceBounds.set(skeleton.hash, bounds); this._boneSpaceBounds.set(skeleton.hash, bounds);
const valid: boolean[] = []; const valid: boolean[] = [];
const bindposes = skeleton.bindposes; const { bindposes } = skeleton;
for (let i = 0; i < bindposes.length; i++) { for (let i = 0; i < bindposes.length; i++) {
bounds.push(new aabb(Infinity, Infinity, Infinity, -Infinity, -Infinity, -Infinity)); bounds.push(new aabb(Infinity, Infinity, Infinity, -Infinity, -Infinity, -Infinity));
valid.push(false); valid.push(false);
} }
const primitives = this._struct.primitives; const { primitives } = this._struct;
for (let p = 0; p < primitives.length; p++) { for (let p = 0; p < primitives.length; p++) {
const joints = this.readAttribute(p, AttributeName.ATTR_JOINTS); const joints = this.readAttribute(p, AttributeName.ATTR_JOINTS);
const weights = this.readAttribute(p, AttributeName.ATTR_WEIGHTS); const weights = this.readAttribute(p, AttributeName.ATTR_WEIGHTS);
@@ -835,8 +858,7 @@ export class Mesh extends Asset {
} }
for (let i = 0; i < bindposes.length; i++) { for (let i = 0; i < bindposes.length; i++) {
const b = bounds[i]!; const b = bounds[i]!;
if (!valid[i]) { bounds[i] = null; } if (!valid[i]) { bounds[i] = null; } else { aabb.fromPoints(b, b.center, b.halfExtents); }
else { aabb.fromPoints(b, b.center, b.halfExtents); }
} }
return bounds; return bounds;
} }
@@ -879,11 +901,12 @@ export class Mesh extends Asset {
const vtxBdl = struct.vertexBundles[i]; const vtxBdl = struct.vertexBundles[i];
for (let j = 0; j < vtxBdl.attributes.length; j++) { for (let j = 0; j < vtxBdl.attributes.length; j++) {
if (vtxBdl.attributes[j].name === AttributeName.ATTR_POSITION || vtxBdl.attributes[j].name === AttributeName.ATTR_NORMAL) { if (vtxBdl.attributes[j].name === AttributeName.ATTR_POSITION || vtxBdl.attributes[j].name === AttributeName.ATTR_NORMAL) {
const format = vtxBdl.attributes[j].format; const { format } = vtxBdl.attributes[j];
const inputView = new DataView( const inputView = new DataView(
data.buffer, data.buffer,
vtxBdl.view.offset + getOffset(vtxBdl.attributes, j)); vtxBdl.view.offset + getOffset(vtxBdl.attributes, j),
);
const reader = getReader(inputView, format); const reader = getReader(inputView, format);
const writer = getWriter(inputView, format); const writer = getWriter(inputView, format);
@@ -900,12 +923,13 @@ export class Mesh extends Asset {
const zOffset = yOffset + attrComponentByteLength; const zOffset = yOffset + attrComponentByteLength;
vec3_temp.set(reader(xOffset), reader(yOffset), reader(zOffset)); vec3_temp.set(reader(xOffset), reader(yOffset), reader(zOffset));
switch (vtxBdl.attributes[j].name) { switch (vtxBdl.attributes[j].name) {
case AttributeName.ATTR_POSITION: case AttributeName.ATTR_POSITION:
vec3_temp.transformMat4(worldMatrix); vec3_temp.transformMat4(worldMatrix);
break; break;
case AttributeName.ATTR_NORMAL: case AttributeName.ATTR_NORMAL:
Vec3.transformQuat(vec3_temp, vec3_temp, rotate!); Vec3.transformQuat(vec3_temp, vec3_temp, rotate!);
break; break;
default:
} }
writer(xOffset, vec3_temp.x); writer(xOffset, vec3_temp.x);
writer(yOffset, vec3_temp.y); writer(yOffset, vec3_temp.y);
@@ -980,12 +1004,12 @@ export class Mesh extends Asset {
const f32_temp = new Float32Array(vbView.buffer, srcVBOffset, 3); const f32_temp = new Float32Array(vbView.buffer, srcVBOffset, 3);
vec3_temp.set(f32_temp[0], f32_temp[1], f32_temp[2]); vec3_temp.set(f32_temp[0], f32_temp[1], f32_temp[2]);
switch (attr.name) { switch (attr.name) {
case AttributeName.ATTR_POSITION: case AttributeName.ATTR_POSITION:
vec3_temp.transformMat4(worldMatrix); vec3_temp.transformMat4(worldMatrix);
break; break;
case AttributeName.ATTR_NORMAL: case AttributeName.ATTR_NORMAL:
Vec3.transformQuat(vec3_temp, vec3_temp, rotate!); Vec3.transformQuat(vec3_temp, vec3_temp, rotate!);
break; break;
} }
f32_temp[0] = vec3_temp.x; f32_temp[0] = vec3_temp.x;
f32_temp[1] = vec3_temp.y; f32_temp[1] = vec3_temp.y;
@@ -1098,7 +1122,6 @@ export class Mesh extends Asset {
bufferBlob.setNextAlignment(idxStride); bufferBlob.setNextAlignment(idxStride);
bufferBlob.addBuffer(ib); bufferBlob.addBuffer(ib);
} }
} }
// Create mesh struct. // Create mesh struct.
@@ -1202,10 +1225,8 @@ export class Mesh extends Asset {
if (dstPrim.indexView === undefined) { if (dstPrim.indexView === undefined) {
return false; return false;
} }
} else { } else if (dstPrim.indexView) {
if (dstPrim.indexView) { return false;
return false;
}
} }
} }
@@ -1220,19 +1241,20 @@ export class Mesh extends Asset {
* @returns Return null if not found or can't read, otherwise, will create a large enough typed array to contain all data of the attribute, * @returns Return null if not found or can't read, otherwise, will create a large enough typed array to contain all data of the attribute,
* the array type will match the data type of the attribute. * the array type will match the data type of the attribute.
*/ */
public readAttribute (primitiveIndex: number, attributeName: AttributeName): Storage | null { public readAttribute (primitiveIndex: number, attributeName: AttributeName): TypedArray | null {
let result: TypedArray | null = null; let result: TypedArray | null = null;
this._accessAttribute(primitiveIndex, attributeName, (vertexBundle, iAttribute) => { this._accessAttribute(primitiveIndex, attributeName, (vertexBundle, iAttribute) => {
const vertexCount = vertexBundle.view.count; const vertexCount = vertexBundle.view.count;
const format = vertexBundle.attributes[iAttribute].format; const { format } = vertexBundle.attributes[iAttribute];
const storageConstructor = getTypedArrayConstructor(FormatInfos[format]); const storageConstructor = getTypedArrayConstructor(FormatInfos[format]);
if (vertexCount === 0) { if (vertexCount === 0) {
return new storageConstructor(); return;
} }
const inputView = new DataView( const inputView = new DataView(
this._data.buffer, this._data.buffer,
vertexBundle.view.offset + getOffset(vertexBundle.attributes, iAttribute)); vertexBundle.view.offset + getOffset(vertexBundle.attributes, iAttribute),
);
const formatInfo = FormatInfos[format]; const formatInfo = FormatInfos[format];
const reader = getReader(inputView, format); const reader = getReader(inputView, format);
@@ -1248,7 +1270,6 @@ export class Mesh extends Asset {
} }
} }
result = storage; result = storage;
return;
}); });
return result; return result;
} }
@@ -1271,11 +1292,12 @@ export class Mesh extends Asset {
written = true; written = true;
return; return;
} }
const format = vertexBundle.attributes[iAttribute].format; const { format } = vertexBundle.attributes[iAttribute];
const inputView = new DataView( const inputView = new DataView(
this._data.buffer, this._data.buffer,
vertexBundle.view.offset + getOffset(vertexBundle.attributes, iAttribute)); vertexBundle.view.offset + getOffset(vertexBundle.attributes, iAttribute),
);
const outputView = new DataView(buffer, offset); const outputView = new DataView(buffer, offset);
@@ -1301,7 +1323,6 @@ export class Mesh extends Asset {
} }
} }
written = true; written = true;
return;
}); });
return written; return written;
} }
@@ -1321,7 +1342,7 @@ export class Mesh extends Asset {
if (!primitive.indexView) { if (!primitive.indexView) {
return null; return null;
} }
const stride = primitive.indexView.stride; const { stride } = primitive.indexView;
const ctor = stride === 1 ? Uint8Array : (stride === 2 ? Uint16Array : Uint32Array); const ctor = stride === 1 ? Uint8Array : (stride === 2 ? Uint16Array : Uint32Array);
return new ctor(this._data.buffer, primitive.indexView.offset, primitive.indexView.count); return new ctor(this._data.buffer, primitive.indexView.offset, primitive.indexView.count);
} }
@@ -1333,7 +1354,7 @@ export class Mesh extends Asset {
* @param outputArray The target output array * @param outputArray The target output array
* @returns Return false if failed to access the indices data, return true otherwise. * @returns Return false if failed to access the indices data, return true otherwise.
*/ */
public copyIndices (primitiveIndex: number, outputArray: number[] | ArrayBufferView) { public copyIndices (primitiveIndex: number, outputArray: number[] | ArrayBufferView): boolean {
if (primitiveIndex >= this._struct.primitives.length) { if (primitiveIndex >= this._struct.primitives.length) {
return false; return false;
} }
@@ -1353,7 +1374,8 @@ export class Mesh extends Asset {
private _accessAttribute ( private _accessAttribute (
primitiveIndex: number, primitiveIndex: number,
attributeName: AttributeName, attributeName: AttributeName,
accessor: (vertexBundle: Mesh.IVertexBundle, iAttribute: number) => void) { accessor: (vertexBundle: Mesh.IVertexBundle, iAttribute: number) => void,
) {
if (primitiveIndex >= this._struct.primitives.length) { if (primitiveIndex >= this._struct.primitives.length) {
return; return;
} }
@@ -1367,12 +1389,10 @@ export class Mesh extends Asset {
accessor(vertexBundle, iAttribute); accessor(vertexBundle, iAttribute);
break; break;
} }
return;
} }
private _createVertexBuffers (gfxDevice: Device, data: ArrayBuffer): Buffer[] { private _createVertexBuffers (gfxDevice: Device, data: ArrayBuffer): Buffer[] {
return this._struct.vertexBundles.map((vertexBundle) => { return this._struct.vertexBundles.map((vertexBundle) => {
const vertexBuffer = gfxDevice.createBuffer(new BufferInfo( const vertexBuffer = gfxDevice.createBuffer(new BufferInfo(
BufferUsageBit.VERTEX | BufferUsageBit.TRANSFER_DST, BufferUsageBit.VERTEX | BufferUsageBit.TRANSFER_DST,
MemoryUsageBit.DEVICE, MemoryUsageBit.DEVICE,
@@ -1383,8 +1403,7 @@ export class Mesh extends Asset {
const view = new Uint8Array(data, vertexBundle.view.offset, vertexBundle.view.length); const view = new Uint8Array(data, vertexBundle.view.offset, vertexBundle.view.length);
if (this.loaded) { if (this.loaded) {
vertexBuffer.update(view); vertexBuffer.update(view);
} } else {
else {
this.once('load', () => { this.once('load', () => {
vertexBuffer.update(view); vertexBuffer.update(view);
}); });
@@ -1392,8 +1411,6 @@ export class Mesh extends Asset {
return vertexBuffer; return vertexBuffer;
}); });
} }
public morphRendering: MorphRendering | null = null;
} }
legacyCC.Mesh = Mesh; legacyCC.Mesh = Mesh;
@@ -1406,7 +1423,7 @@ function getOffset (attributes: Attribute[], attributeIndex: number) {
return result; return result;
} }
const isLittleEndian = sys.isLittleEndian; const { isLittleEndian } = sys;
function getComponentByteLength (format: Format) { function getComponentByteLength (format: Format) {
const info = FormatInfos[format]; const info = FormatInfos[format];
@@ -1418,41 +1435,41 @@ function getReader (dataView: DataView, format: Format) {
const stride = info.size / info.count; const stride = info.size / info.count;
switch (info.type) { switch (info.type) {
case FormatType.UNORM: { case FormatType.UNORM: {
switch (stride) { switch (stride) {
case 1: return (offset: number) => dataView.getUint8(offset); case 1: return (offset: number) => dataView.getUint8(offset);
case 2: return (offset: number) => dataView.getUint16(offset, isLittleEndian); case 2: return (offset: number) => dataView.getUint16(offset, isLittleEndian);
case 4: return (offset: number) => dataView.getUint32(offset, isLittleEndian); case 4: return (offset: number) => dataView.getUint32(offset, isLittleEndian);
}
break;
} }
case FormatType.SNORM: { break;
switch (stride) { }
case 1: return (offset: number) => dataView.getInt8(offset); case FormatType.SNORM: {
case 2: return (offset: number) => dataView.getInt16(offset, isLittleEndian); switch (stride) {
case 4: return (offset: number) => dataView.getInt32(offset, isLittleEndian); case 1: return (offset: number) => dataView.getInt8(offset);
} case 2: return (offset: number) => dataView.getInt16(offset, isLittleEndian);
break; case 4: return (offset: number) => dataView.getInt32(offset, isLittleEndian);
} }
case FormatType.INT: { break;
switch (stride) { }
case 1: return (offset: number) => dataView.getInt8(offset); case FormatType.INT: {
case 2: return (offset: number) => dataView.getInt16(offset, isLittleEndian); switch (stride) {
case 4: return (offset: number) => dataView.getInt32(offset, isLittleEndian); case 1: return (offset: number) => dataView.getInt8(offset);
} case 2: return (offset: number) => dataView.getInt16(offset, isLittleEndian);
break; case 4: return (offset: number) => dataView.getInt32(offset, isLittleEndian);
} }
case FormatType.UINT: { break;
switch (stride) { }
case 1: return (offset: number) => dataView.getUint8(offset); case FormatType.UINT: {
case 2: return (offset: number) => dataView.getUint16(offset, isLittleEndian); switch (stride) {
case 4: return (offset: number) => dataView.getUint32(offset, isLittleEndian); case 1: return (offset: number) => dataView.getUint8(offset);
} case 2: return (offset: number) => dataView.getUint16(offset, isLittleEndian);
break; case 4: return (offset: number) => dataView.getUint32(offset, isLittleEndian);
}
case FormatType.FLOAT: {
return (offset: number) => dataView.getFloat32(offset, isLittleEndian);
} }
break;
}
case FormatType.FLOAT: {
return (offset: number) => dataView.getFloat32(offset, isLittleEndian);
}
} }
return null; return null;
@@ -1463,41 +1480,41 @@ function getWriter (dataView: DataView, format: Format) {
const stride = info.size / info.count; const stride = info.size / info.count;
switch (info.type) { switch (info.type) {
case FormatType.UNORM: { case FormatType.UNORM: {
switch (stride) { switch (stride) {
case 1: return (offset: number, value: number) => dataView.setUint8(offset, value); case 1: return (offset: number, value: number) => dataView.setUint8(offset, value);
case 2: return (offset: number, value: number) => dataView.setUint16(offset, value, isLittleEndian); case 2: return (offset: number, value: number) => dataView.setUint16(offset, value, isLittleEndian);
case 4: return (offset: number, value: number) => dataView.setUint32(offset, value, isLittleEndian); case 4: return (offset: number, value: number) => dataView.setUint32(offset, value, isLittleEndian);
}
break;
} }
case FormatType.SNORM: { break;
switch (stride) { }
case 1: return (offset: number, value: number) => dataView.setInt8(offset, value); case FormatType.SNORM: {
case 2: return (offset: number, value: number) => dataView.setInt16(offset, value, isLittleEndian); switch (stride) {
case 4: return (offset: number, value: number) => dataView.setInt32(offset, value, isLittleEndian); case 1: return (offset: number, value: number) => dataView.setInt8(offset, value);
} case 2: return (offset: number, value: number) => dataView.setInt16(offset, value, isLittleEndian);
break; case 4: return (offset: number, value: number) => dataView.setInt32(offset, value, isLittleEndian);
} }
case FormatType.INT: { break;
switch (stride) { }
case 1: return (offset: number, value: number) => dataView.setInt8(offset, value); case FormatType.INT: {
case 2: return (offset: number, value: number) => dataView.setInt16(offset, value, isLittleEndian); switch (stride) {
case 4: return (offset: number, value: number) => dataView.setInt32(offset, value, isLittleEndian); case 1: return (offset: number, value: number) => dataView.setInt8(offset, value);
} case 2: return (offset: number, value: number) => dataView.setInt16(offset, value, isLittleEndian);
break; case 4: return (offset: number, value: number) => dataView.setInt32(offset, value, isLittleEndian);
} }
case FormatType.UINT: { break;
switch (stride) { }
case 1: return (offset: number, value: number) => dataView.setUint8(offset, value); case FormatType.UINT: {
case 2: return (offset: number, value: number) => dataView.setUint16(offset, value, isLittleEndian); switch (stride) {
case 4: return (offset: number, value: number) => dataView.setUint32(offset, value, isLittleEndian); case 1: return (offset: number, value: number) => dataView.setUint8(offset, value);
} case 2: return (offset: number, value: number) => dataView.setUint16(offset, value, isLittleEndian);
break; case 4: return (offset: number, value: number) => dataView.setUint32(offset, value, isLittleEndian);
}
case FormatType.FLOAT: {
return (offset: number, value: number) => dataView.setFloat32(offset, value, isLittleEndian);
} }
break;
}
case FormatType.FLOAT: {
return (offset: number, value: number) => dataView.setFloat32(offset, value, isLittleEndian);
}
} }
return null; return null;
+5 -5
View File
@@ -81,7 +81,7 @@ export default class Prefab extends Asset {
public static OptimizationPolicy = OptimizationPolicy; public static OptimizationPolicy = OptimizationPolicy;
public static OptimizationPolicyThreshold = 3; public static OptimizationPolicyThreshold = 3;
/** /**
* @en The main [[Node]] in the prefab * @en The main [[Node]] in the prefab
* @zh Prefab 中的根节点,[[Node]] 类型 * @zh Prefab 中的根节点,[[Node]] 类型
@@ -115,7 +115,7 @@ export default class Prefab extends Asset {
*/ */
@serializable @serializable
@editable @editable
public asyncLoadAssets: Boolean = false; public asyncLoadAssets = false;
// Cache function to optimize instance creation. // Cache function to optimize instance creation.
private _createFunction: Function | null; private _createFunction: Function | null;
@@ -140,8 +140,8 @@ export default class Prefab extends Asset {
* but you can re-call to refresh the create function once you modified the original prefab data in script. * but you can re-call to refresh the create function once you modified the original prefab data in script.
* @zh * @zh
* 将预制数据动态转换为最小化代码。<br/> * 将预制数据动态转换为最小化代码。<br/>
     * 此方法将在第一次实例化预制件之前自动调用,<br/> * 此方法将在第一次实例化预制件之前自动调用,<br/>
     * 但是您可以在脚本中修改原始预制数据后重新调用以刷新创建功能。 * 但是您可以在脚本中修改原始预制数据后重新调用以刷新创建功能。
*/ */
public compileCreateFunction (): void { public compileCreateFunction (): void {
this._createFunction = compile(this.data); this._createFunction = compile(this.data);
@@ -167,7 +167,7 @@ export default class Prefab extends Asset {
private _instantiate () { private _instantiate () {
let node; let node;
let useJit: Boolean = false; let useJit = false;
if (SUPPORT_JIT) { if (SUPPORT_JIT) {
if (this.optimizationPolicy === OptimizationPolicy.SINGLE_INSTANCE) { if (this.optimizationPolicy === OptimizationPolicy.SINGLE_INSTANCE) {
useJit = false; useJit = false;
+1 -1
View File
@@ -60,7 +60,7 @@ const _windowInfo: IRenderWindowInfo = {
}; };
/** /**
* @en Render texture is a render target for [[Camera]] or [[Canvas]] component, * @en Render texture is a render target for [[Camera]] or [[Canvas]] component,
* the render pipeline will use its [[RenderWindow]] as the target of the rendering process. * the render pipeline will use its [[RenderWindow]] as the target of the rendering process.
* @zh 渲染贴图是 [[Camera]] 或 [[Canvas]] 组件的渲染目标对象,渲染管线会使用它的 [[RenderWindow]] 作为渲染的目标窗口。 * @zh 渲染贴图是 [[Camera]] 或 [[Canvas]] 组件的渲染目标对象,渲染管线会使用它的 [[RenderWindow]] 作为渲染的目标窗口。
*/ */
+1 -1
View File
@@ -480,7 +480,7 @@ export class SpriteFrame extends Asset {
protected _capInsets = [0, 0, 0, 0]; protected _capInsets = [0, 0, 0, 0];
protected _atlasUuid: string = ''; protected _atlasUuid: string = '';
// @ts-ignore // @ts-expect-error
protected _texture: TextureBase | RenderTexture; protected _texture: TextureBase | RenderTexture;
protected _flipUv = false; protected _flipUv = false;
+25 -28
View File
@@ -24,7 +24,7 @@
THE SOFTWARE. THE SOFTWARE.
*/ */
// tslint:disable
/** /**
* @packageDocumentation * @packageDocumentation
@@ -46,9 +46,6 @@ import { errorID, warnID, assertID } from '../platform/debug';
import { CompPrefabInfo } from '../utils'; import { CompPrefabInfo } from '../utils';
const idGenerator = new IDGenerator('Comp'); const idGenerator = new IDGenerator('Comp');
// @ts-ignore
const IsOnEnableCalled = CCObject.Flags.IsOnEnableCalled;
// @ts-ignore
const IsOnLoadCalled = CCObject.Flags.IsOnLoadCalled; const IsOnLoadCalled = CCObject.Flags.IsOnLoadCalled;
const NullNode = null as unknown as Node; const NullNode = null as unknown as Node;
@@ -202,7 +199,7 @@ class Component extends CCObject {
if (this._sceneGetter) { if (this._sceneGetter) {
return this._sceneGetter(); return this._sceneGetter();
} else { } else {
return this.node.scene!._renderScene!; return this.node.scene._renderScene!;
} }
} }
@@ -357,7 +354,7 @@ class Component extends CCObject {
public destroy () { public destroy () {
if (EDITOR) { if (EDITOR) {
// @ts-ignore // @ts-expect-error
const depend = this.node._getDependComponent(this); const depend = this.node._getDependComponent(this);
if (depend) { if (depend) {
errorID(3626, errorID(3626,
@@ -380,7 +377,7 @@ class Component extends CCObject {
// //
if (EDITOR && !TEST) { if (EDITOR && !TEST) {
// @ts-ignore // @ts-expect-error
_Scene.AssetsWatcher.stop(this); _Scene.AssetsWatcher.stop(this);
} }
@@ -418,7 +415,7 @@ class Component extends CCObject {
* this.schedule((dt) => void log(`time: ${dt}`), 1); * this.schedule((dt) => void log(`time: ${dt}`), 1);
* ``` * ```
*/ */
public schedule (callback, interval: number = 0, repeat: number = legacyCC.macro.REPEAT_FOREVER, delay: number = 0) { public schedule (callback, interval = 0, repeat: number = legacyCC.macro.REPEAT_FOREVER, delay = 0) {
assertID(callback, 1619); assertID(callback, 1619);
interval = interval || 0; interval = interval || 0;
@@ -451,7 +448,7 @@ class Component extends CCObject {
* this.scheduleOnce((dt) => void log(`time: ${dt}`), 2); * this.scheduleOnce((dt) => void log(`time: ${dt}`), 2);
* ``` * ```
*/ */
public scheduleOnce (callback, delay: number = 0) { public scheduleOnce (callback, delay = 0) {
this.schedule(callback, 0, 0, delay); this.schedule(callback, 0, 0, delay);
} }
@@ -642,47 +639,47 @@ class Component extends CCObject {
} }
const proto = Component.prototype; const proto = Component.prototype;
// @ts-ignore // @ts-expect-error
proto.update = null; proto.update = null;
// @ts-ignore // @ts-expect-error
proto.lateUpdate = null; proto.lateUpdate = null;
// @ts-ignore // @ts-expect-error
proto.__preload = null; proto.__preload = null;
// @ts-ignore // @ts-expect-error
proto.onLoad = null; proto.onLoad = null;
// @ts-ignore // @ts-expect-error
proto.start = null; proto.start = null;
// @ts-ignore // @ts-expect-error
proto.onEnable = null; proto.onEnable = null;
// @ts-ignore // @ts-expect-error
proto.onDisable = null; proto.onDisable = null;
// @ts-ignore // @ts-expect-error
proto.onDestroy = null; proto.onDestroy = null;
// @ts-ignore // @ts-expect-error
proto.onFocusInEditor = null; proto.onFocusInEditor = null;
// @ts-ignore // @ts-expect-error
proto.onLostFocusInEditor = null; proto.onLostFocusInEditor = null;
// @ts-ignore // @ts-expect-error
proto.resetInEditor = null; proto.resetInEditor = null;
// @ts-ignore // @ts-expect-error
proto._getLocalBounds = null; proto._getLocalBounds = null;
// @ts-ignore // @ts-expect-error
proto.onRestore = null; proto.onRestore = null;
// @ts-ignore // @ts-expect-error
Component._requireComponent = null; Component._requireComponent = null;
// @ts-ignore // @ts-expect-error
Component._executionOrder = 0; Component._executionOrder = 0;
if (EDITOR || TEST) { if (EDITOR || TEST) {
// INHERITABLE STATIC MEMBERS // INHERITABLE STATIC MEMBERS
// @ts-ignore // @ts-expect-error
Component._executeInEditMode = false; Component._executeInEditMode = false;
// @ts-ignore // @ts-expect-error
Component._playOnFocus = false; Component._playOnFocus = false;
// @ts-ignore // @ts-expect-error
Component._disallowMultiple = null; Component._disallowMultiple = null;
// @ts-ignore // @ts-expect-error
Component._help = ''; Component._help = '';
// NON-INHERITED STATIC MEMBERS // NON-INHERITED STATIC MEMBERS
+1 -1
View File
@@ -80,7 +80,7 @@ export default class MissingScript extends Component {
constructor () { constructor () {
super(); super();
if (EDITOR) { if (EDITOR) {
// @ts-ignore // @ts-expect-error
this.compiled = _Scene.Sandbox.compiled; this.compiled = _Scene.Sandbox.compiled;
} }
} }
@@ -88,7 +88,7 @@ export class UITransform extends Component {
this._contentSize.set(value); this._contentSize.set(value);
if (EDITOR) { if (EDITOR) {
// @ts-ignore // @ts-expect-error
this.node.emit(SystemEventType.SIZE_CHANGED, clone); this.node.emit(SystemEventType.SIZE_CHANGED, clone);
} else { } else {
this.node.emit(SystemEventType.SIZE_CHANGED); this.node.emit(SystemEventType.SIZE_CHANGED);
@@ -112,7 +112,7 @@ export class UITransform extends Component {
this._contentSize.width = value; this._contentSize.width = value;
if (EDITOR) { if (EDITOR) {
// @ts-ignore // @ts-expect-error
this.node.emit(SystemEventType.SIZE_CHANGED, clone); this.node.emit(SystemEventType.SIZE_CHANGED, clone);
} else { } else {
this.node.emit(SystemEventType.SIZE_CHANGED); this.node.emit(SystemEventType.SIZE_CHANGED);
@@ -135,7 +135,7 @@ export class UITransform extends Component {
this._contentSize.height = value; this._contentSize.height = value;
if (EDITOR) { if (EDITOR) {
// @ts-ignore // @ts-expect-error
this.node.emit(SystemEventType.SIZE_CHANGED, clone); this.node.emit(SystemEventType.SIZE_CHANGED, clone);
} else { } else {
this.node.emit(SystemEventType.SIZE_CHANGED); this.node.emit(SystemEventType.SIZE_CHANGED);
@@ -310,7 +310,7 @@ export class UITransform extends Component {
} }
if (EDITOR) { if (EDITOR) {
// @ts-ignore // @ts-expect-error
this.node.emit(SystemEventType.SIZE_CHANGED, clone); this.node.emit(SystemEventType.SIZE_CHANGED, clone);
} else { } else {
this.node.emit(SystemEventType.SIZE_CHANGED); this.node.emit(SystemEventType.SIZE_CHANGED);
@@ -612,7 +612,7 @@ export class UITransform extends Component {
} }
} }
// @ts-ignore // @ts-expect-error
parent = parent.parent; parent = parent.parent;
} }
} }
+7 -8
View File
@@ -29,12 +29,12 @@
* @hidden * @hidden
*/ */
// tslint:disable:only-arrow-functions
// tslint:disable:prefer-for-of
// tslint:disable:no-shadowed-variable
// tslint:disable:max-line-length
// tslint:disable:jsdoc-format
// tslint:disable:forin
import { errorID, warnID } from '../platform/debug'; import { errorID, warnID } from '../platform/debug';
import * as js from '../utils/js'; import * as js from '../utils/js';
@@ -270,8 +270,7 @@ function define (className, baseClass, mixins, options) {
renderName = 'render_stage'; renderName = 'render_stage';
} }
// 增加了 hidden: 开头标识,使它最终不会显示在 Editor inspector 的添加组件列表里 // 增加了 hidden: 开头标识,使它最终不会显示在 Editor inspector 的添加组件列表里
// @ts-ignore
// tslint:disable-next-line:no-unused-expression
window.EditorExtends && window.EditorExtends.Component.addMenu(cls, `hidden:${renderName}/${className}`, -1); window.EditorExtends && window.EditorExtends.Component.addMenu(cls, `hidden:${renderName}/${className}`, -1);
} }
+10 -12
View File
@@ -38,7 +38,7 @@ import * as Attr from './utils/attribute';
import MissingScript from '../components/missing-script'; import MissingScript from '../components/missing-script';
import { Details } from './deserialize'; import { Details } from './deserialize';
// tslint:disable: no-shadowed-variable
// IMPLEMENT OF DESERIALIZATION // IMPLEMENT OF DESERIALIZATION
@@ -102,7 +102,7 @@ const compileDeserialize = SUPPORT_JIT ? (self, klass) => {
]; ];
const fastMode = misc.BUILTIN_CLASSID_RE.test(js._getClassId(klass)); const fastMode = misc.BUILTIN_CLASSID_RE.test(js._getClassId(klass));
// sources.push('var vb,vn,vs,vo,vu,vf;'); // boolean, number, string, object, undefined, function // sources.push('var vb,vn,vs,vo,vu,vf;'); // boolean, number, string, object, undefined, function
// tslint:disable-next-line: prefer-for-of
for (let p = 0; p < props.length; p++) { for (let p = 0; p < props.length; p++) {
const propName = props[p]; const propName = props[p];
if ((PREVIEW || (EDITOR && self._ignoreEditorOnly)) && attrs[propName + EDITOR_ONLY]) { if ((PREVIEW || (EDITOR && self._ignoreEditorOnly)) && attrs[propName + EDITOR_ONLY]) {
@@ -203,7 +203,7 @@ const compileDeserialize = SUPPORT_JIT ? (self, klass) => {
const DEFAULT = Attr.DELIMETER + 'default'; const DEFAULT = Attr.DELIMETER + 'default';
const FORMERLY_SERIALIZED_AS = Attr.DELIMETER + 'formerlySerializedAs'; const FORMERLY_SERIALIZED_AS = Attr.DELIMETER + 'formerlySerializedAs';
// tslint:disable-next-line: prefer-for-of
for (let p = 0; p < props.length; p++) { for (let p = 0; p < props.length; p++) {
const propName = props[p]; const propName = props[p];
let propNameToRead = propName; let propNameToRead = propName;
@@ -359,7 +359,7 @@ function _deserializeFireClass (self, obj, serialized, klass) {
// } // }
// } // }
// tslint:disable-next-line: class-name
class _Deserializer { class _Deserializer {
public static pool: js.Pool<{}>; public static pool: js.Pool<{}>;
@@ -446,14 +446,14 @@ class _Deserializer {
* @param {Object} [owner] - debug only * @param {Object} [owner] - debug only
* @param {String} [propName] - debug only * @param {String} [propName] - debug only
*/ */
private _deserializeObject (serialized, owner?: Object, propName?: String) { private _deserializeObject (serialized, owner?: Object, propName?: string) {
let prop; let prop;
let obj: any = null; // the obj to return let obj: any = null; // the obj to return
let klass: any = null; let klass: any = null;
const type = serialized.__type__; const type = serialized.__type__;
if (type === 'TypedArray') { if (type === 'TypedArray') {
const array = serialized.array; const array = serialized.array;
// @ts-ignore // @ts-expect-error
obj = new window[serialized.ctor](array.length); obj = new window[serialized.ctor](array.length);
for (let i = 0; i < array.length; ++i) { for (let i = 0; i < array.length; ++i) {
obj[i] = array[i]; obj[i] = array[i];
@@ -473,7 +473,6 @@ class _Deserializer {
return null; return null;
} }
const self = this; const self = this;
// @ts-ignore
function deserializeByType () { function deserializeByType () {
// instantiate a new object // instantiate a new object
obj = new klass(); obj = new klass();
@@ -490,7 +489,6 @@ class _Deserializer {
} }
} }
// @ts-ignore
function checkDeserializeByType () { function checkDeserializeByType () {
try { try {
deserializeByType(); deserializeByType();
@@ -510,7 +508,7 @@ class _Deserializer {
deserializeByType(); deserializeByType();
} }
} }
else if ( !Array.isArray(serialized) ) { else if (!Array.isArray(serialized)) {
// embedded primitive javascript object // embedded primitive javascript object
@@ -614,7 +612,7 @@ class _Deserializer {
const DEFAULT = Attr.DELIMETER + 'default'; const DEFAULT = Attr.DELIMETER + 'default';
const attrs = Attr.getClassAttrs(klass); const attrs = Attr.getClassAttrs(klass);
const fastDefinedProps = klass.__props__ || Object.keys(instance); // 遍历 instance,如果具有类型,才不会把 __type__ 也读进来 const fastDefinedProps = klass.__props__ || Object.keys(instance); // 遍历 instance,如果具有类型,才不会把 __type__ 也读进来
// tslint:disable-next-line: prefer-for-of
for (let i = 0; i < fastDefinedProps.length; i++) { for (let i = 0; i < fastDefinedProps.length; i++) {
const propName = fastDefinedProps[i]; const propName = fastDefinedProps[i];
let value = serialized[propName]; let value = serialized[propName];
@@ -646,7 +644,7 @@ _Deserializer.pool = new js.Pool((obj: any) => {
obj._idObjList.length = 0; obj._idObjList.length = 0;
obj._idPropList.length = 0; obj._idPropList.length = 0;
}, 1); }, 1);
// @ts-ignore // @ts-expect-error
_Deserializer.pool.get = function (result, classFinder, customEnv, ignoreEditorOnly) { _Deserializer.pool.get = function (result, classFinder, customEnv, ignoreEditorOnly) {
const cache: any = this._get(); const cache: any = this._get();
if (cache) { if (cache) {
@@ -674,7 +672,7 @@ export function deserializeDynamic (data, details: Details, options) {
details.init(); details.init();
// @ts-ignore // @ts-expect-error
const deserializer: _Deserializer = _Deserializer.pool.get(details, classFinder, customEnv, ignoreEditorOnly); const deserializer: _Deserializer = _Deserializer.pool.get(details, classFinder, customEnv, ignoreEditorOnly);
legacyCC.game._isCloning = true; legacyCC.game._isCloning = true;
+16 -18
View File
@@ -99,26 +99,26 @@ function serializeBuiltinValueTypes (obj: ValueType): IValueTypeData | null {
const typeId = BuiltinValueTypes.indexOf(ctor); const typeId = BuiltinValueTypes.indexOf(ctor);
switch (ctor) { switch (ctor) {
case Vec2: case Vec2:
// @ts-ignore // @ts-expect-error
return [typeId, obj.x, obj.y]; return [typeId, obj.x, obj.y];
case Vec3: case Vec3:
// @ts-ignore // @ts-expect-error
return [typeId, obj.x, obj.y, obj.z]; return [typeId, obj.x, obj.y, obj.z];
case Vec4: case Vec4:
case Quat: case Quat:
// @ts-ignore // @ts-expect-error
return [typeId, obj.x, obj.y, obj.z, obj.w]; return [typeId, obj.x, obj.y, obj.z, obj.w];
case Color: case Color:
// @ts-ignore // @ts-expect-error
return [typeId, obj._val]; return [typeId, obj._val];
case Size: case Size:
// @ts-ignore // @ts-expect-error
return [typeId, obj.width, obj.height]; return [typeId, obj.width, obj.height];
case Rect: case Rect:
// @ts-ignore // @ts-expect-error
return [typeId, obj.x, obj.y, obj.width, obj.height]; return [typeId, obj.x, obj.y, obj.width, obj.height];
case Mat4: case Mat4:
// @ts-ignore // @ts-expect-error
const res: IValueTypeData = new Array(1 + 16); const res: IValueTypeData = new Array(1 + 16);
res[VALUETYPE_SETTER] = typeId; res[VALUETYPE_SETTER] = typeId;
Mat4.toArray(res, obj as Mat4, 1); Mat4.toArray(res, obj as Mat4, 1);
@@ -505,7 +505,7 @@ interface ICustomHandler {
customEnv: any, customEnv: any,
} }
type ClassFinder = { type ClassFinder = {
// tslint:disable-next-line:callable-types
(type: string): AnyCtor; (type: string): AnyCtor;
// // for editor // // for editor
// onDereferenced: (curOwner: object, curPropName: string, newOwner: object, newPropName: string) => void; // onDereferenced: (curOwner: object, curPropName: string, newOwner: object, newPropName: string) => void;
@@ -620,7 +620,7 @@ export function dereference (refs: IRefs, instances: IFileData[File.Instances],
// owner is object // owner is object
const instanceOffset: number = refs[dataLength] * Refs.EACH_RECORD_LENGTH; const instanceOffset: number = refs[dataLength] * Refs.EACH_RECORD_LENGTH;
for (; i < instanceOffset; i += Refs.EACH_RECORD_LENGTH) { for (; i < instanceOffset; i += Refs.EACH_RECORD_LENGTH) {
const owner = refs[i] as any; const owner = refs[i] ;
const target = instances[refs[i + Refs.TARGET_OFFSET]]; const target = instances[refs[i + Refs.TARGET_OFFSET]];
const keyIndex = refs[i + Refs.KEY_OFFSET] as StringIndexBnotNumber; const keyIndex = refs[i + Refs.KEY_OFFSET] as StringIndexBnotNumber;
@@ -633,7 +633,7 @@ export function dereference (refs: IRefs, instances: IFileData[File.Instances],
} }
// owner is instance index // owner is instance index
for (; i < dataLength; i += Refs.EACH_RECORD_LENGTH) { for (; i < dataLength; i += Refs.EACH_RECORD_LENGTH) {
const owner = instances[refs[i]] as any; const owner = instances[refs[i]] ;
const target = instances[refs[i + Refs.TARGET_OFFSET]]; const target = instances[refs[i + Refs.TARGET_OFFSET]];
const keyIndex = refs[i + Refs.KEY_OFFSET] as StringIndexBnotNumber; const keyIndex = refs[i + Refs.KEY_OFFSET] as StringIndexBnotNumber;
@@ -762,11 +762,10 @@ function parseArray (data: IFileData, owner: any, key: string, value: IArrayData
const array = value[ARRAY_ITEM_VALUES]; const array = value[ARRAY_ITEM_VALUES];
owner[key] = array; owner[key] = array;
for (let i = 0; i < array.length; ++i) { for (let i = 0; i < array.length; ++i) {
const subValue = array[i] as AnyData; const subValue = array[i] ;
const type = value[i + 1] as DataTypeID; const type = value[i + 1] as DataTypeID;
if (type !== DataTypeID.SimpleType) { if (type !== DataTypeID.SimpleType) {
const op = ASSIGNMENTS[type]; const op = ASSIGNMENTS[type];
// @ts-ignore
op(data, array, i, subValue); op(data, array, i, subValue);
} }
} }
@@ -806,7 +805,7 @@ ASSIGNMENTS[DataTypeID.Array] = parseArray;
function parseInstances (data: IFileData): RootInstanceIndex { function parseInstances (data: IFileData): RootInstanceIndex {
const instances = data[File.Instances]; const instances = data[File.Instances];
const instanceTypes = data[File.InstanceTypes]; const instanceTypes = data[File.InstanceTypes];
const instanceTypesLen = instanceTypes === EMPTY_PLACEHOLDER ? 0 : (instanceTypes as OtherObjectTypeID[]).length; const instanceTypesLen = instanceTypes === EMPTY_PLACEHOLDER ? 0 : (instanceTypes).length;
let rootIndex = instances[instances.length - 1]; let rootIndex = instances[instances.length - 1];
let normalObjectCount = instances.length - instanceTypesLen; let normalObjectCount = instances.length - instanceTypesLen;
if (typeof rootIndex !== 'number') { if (typeof rootIndex !== 'number') {
@@ -835,7 +834,7 @@ function parseInstances (data: IFileData): RootInstanceIndex {
// class index for DataTypeID.CustomizedClass // class index for DataTypeID.CustomizedClass
const ctor = classes[type] as CCClass<ICustomClass>; // class const ctor = classes[type] as CCClass<ICustomClass>; // class
instances[insIndex] = deserializeCustomCCObject(data, ctor, eachData as ICustomObjectDataContent); instances[insIndex] = deserializeCustomCCObject(data, ctor, eachData);
} }
else { else {
@@ -843,7 +842,6 @@ function parseInstances (data: IFileData): RootInstanceIndex {
type = (~type) as PrimitiveObjectTypeID; type = (~type) as PrimitiveObjectTypeID;
const op = ASSIGNMENTS[type]; const op = ASSIGNMENTS[type];
// @ts-ignore
op(data, instances, insIndex, eachData); op(data, instances, insIndex, eachData);
} }
} }
@@ -858,7 +856,7 @@ function parseInstances (data: IFileData): RootInstanceIndex {
// for (let i = 0; i < keys.length; ++i) { // for (let i = 0; i < keys.length; ++i) {
// let newKey = attrs[keys[i] + DESERIALIZE_AS]; // let newKey = attrs[keys[i] + DESERIALIZE_AS];
// if (newKey) { // if (newKey) {
// // @ts-ignore // // @ts-expect-error
// if (keys.includes(newKey)) { // if (keys.includes(newKey)) {
// // %s cannot be deserialized by property %s because %s was also present in the serialized data. // // %s cannot be deserialized by property %s because %s was also present in the serialized data.
// warnID(, newKey, keys[i], newKey); // warnID(, newKey, keys[i], newKey);
@@ -924,7 +922,7 @@ function cacheMasks (data: IPackedFileData) {
const classes = data[File.SharedClasses]; const classes = data[File.SharedClasses];
for (let i = 0; i < masks.length; ++i) { for (let i = 0; i < masks.length; ++i) {
const mask = masks[i]; const mask = masks[i];
// @ts-ignore // @ts-expect-error
mask[MASK_CLASS] = classes[mask[MASK_CLASS]]; mask[MASK_CLASS] = classes[mask[MASK_CLASS]];
} }
} }
@@ -962,7 +960,7 @@ function parseResult (data: IFileData) {
} }
const uuid = dependUuids[i]; const uuid = dependUuids[i];
if (typeof uuid === 'number') { if (typeof uuid === 'number') {
dependUuids[i] = (dependSharedUuids as SharedString[])[uuid as StringIndex]; dependUuids[i] = (dependSharedUuids as SharedString[])[uuid ];
} }
else { else {
// added by Details object directly in _deserialize // added by Details object directly in _deserialize
+5 -7
View File
@@ -39,9 +39,7 @@ import {flattenCodeArray} from './utils/compiler';
import { TEST } from 'internal:constants'; import { TEST } from 'internal:constants';
import { legacyCC } from '../global-exports'; import { legacyCC } from '../global-exports';
// @ts-ignore
const Destroyed = CCObject.Flags.Destroyed; const Destroyed = CCObject.Flags.Destroyed;
// @ts-ignore
const PersistentMask = CCObject.Flags.PersistentMask; const PersistentMask = CCObject.Flags.PersistentMask;
const DEFAULT = Attr.DELIMETER + 'default'; const DEFAULT = Attr.DELIMETER + 'default';
const IDENTIFIER_RE = CCClass.IDENTIFIER_RE; const IDENTIFIER_RE = CCClass.IDENTIFIER_RE;
@@ -139,7 +137,7 @@ class Assignments {
else { else {
return; return;
} }
// tslint:disable: prefer-for-of
for (let i = 0; i < this._exps.length; i++) { for (let i = 0; i < this._exps.length; i++) {
const pair = this._exps[i]; const pair = this._exps[i];
writeAssignment(codeArray, targetVar + getPropAccessor(pair[0]) + '=', pair[1]); writeAssignment(codeArray, targetVar + getPropAccessor(pair[0]) + '=', pair[1]);
@@ -151,7 +149,7 @@ Assignments.pool = new js.Pool((obj: any) => {
obj._exps.length = 0; obj._exps.length = 0;
obj._targetExp = null; obj._targetExp = null;
}, 1); }, 1);
// @ts-ignore // @ts-expect-error
Assignments.pool.get = function (targetExpression) { Assignments.pool.get = function (targetExpression) {
const cache: any = this._get() || new Assignments(); const cache: any = this._get() || new Assignments();
cache._targetExp = targetExpression; cache._targetExp = targetExpression;
@@ -296,8 +294,8 @@ class Parser {
} }
public setValueType (codeArray, defaultValue, srcValue, targetExpression) { public setValueType (codeArray, defaultValue, srcValue, targetExpression) {
// @ts-ignore // @ts-expect-error
const assignments: any = Assignments.pool.get!(targetExpression); const assignments: any = Assignments.pool.get(targetExpression);
let fastDefinedProps = defaultValue.constructor.__props__; let fastDefinedProps = defaultValue.constructor.__props__;
if (!fastDefinedProps) { if (!fastDefinedProps) {
fastDefinedProps = Object.keys(defaultValue); fastDefinedProps = Object.keys(defaultValue);
@@ -363,7 +361,7 @@ class Parser {
} }
public instantiateTypedArray (value) { public instantiateTypedArray (value) {
let type = value.constructor.name; const type = value.constructor.name;
if (value.length === 0) { if (value.length === 0) {
return 'new ' + type; return 'new ' + type;
} }
+5 -5
View File
@@ -106,10 +106,10 @@ export function instantiate (original: any, internalForce?: boolean) {
let clone; let clone;
if (original instanceof CCObject) { if (original instanceof CCObject) {
// @ts-ignore // @ts-expect-error
if (original._instantiate) { if (original._instantiate) {
legacyCC.game._isCloning = true; legacyCC.game._isCloning = true;
// @ts-ignore // @ts-expect-error
clone = original._instantiate(); clone = original._instantiate();
legacyCC.game._isCloning = false; legacyCC.game._isCloning = false;
return clone; return clone;
@@ -175,7 +175,7 @@ function doInstantiate (obj, parent?) {
function enumerateCCClass (klass, obj, clone, parent) { function enumerateCCClass (klass, obj, clone, parent) {
const props = klass.__values__; const props = klass.__values__;
// tslint:disable: prefer-for-of
for (let p = 0; p < props.length; p++) { for (let p = 0; p < props.length; p++) {
const key = props[p]; const key = props[p];
const value = obj[key]; const value = obj[key];
@@ -246,7 +246,7 @@ function instantiateObj (obj, parent) {
if (ArrayBuffer.isView(obj)) { if (ArrayBuffer.isView(obj)) {
let len = (obj as any).length; let len = (obj as any).length;
clone = new ((obj as any).constructor)(len); clone = new ((obj as any).constructor)(len);
// @ts-ignore // @ts-expect-error
obj._iN$t = clone; obj._iN$t = clone;
objsToClearTmpVar.push(obj); objsToClearTmpVar.push(obj);
for (let i = 0; i < len; ++i) { for (let i = 0; i < len; ++i) {
@@ -257,7 +257,7 @@ function instantiateObj (obj, parent) {
if (Array.isArray(obj)) { if (Array.isArray(obj)) {
const len = obj.length; const len = obj.length;
clone = new Array(len); clone = new Array(len);
// @ts-ignore // @ts-expect-error
obj._iN$t = clone; obj._iN$t = clone;
objsToClearTmpVar.push(obj); objsToClearTmpVar.push(obj);
for (let i = 0; i < len; ++i) { for (let i = 0; i < len; ++i) {
+10 -10
View File
@@ -99,7 +99,7 @@ function compileDestruct (obj, ctor) {
if (CCClass._isCCClass(ctor)) { if (CCClass._isCCClass(ctor)) {
const attrs = legacyCC.Class.Attr.getClassAttrs(ctor); const attrs = legacyCC.Class.Attr.getClassAttrs(ctor);
const propList = ctor.__props__; const propList = ctor.__props__;
// tslint:disable-next-line: prefer-for-of
for (let i = 0; i < propList.length; i++) { for (let i = 0; i < propList.length; i++) {
key = propList[i]; key = propList[i];
const attrKey = key + legacyCC.Class.Attr.DELIMETER + 'default'; const attrKey = key + legacyCC.Class.Attr.DELIMETER + 'default';
@@ -126,7 +126,7 @@ function compileDestruct (obj, ctor) {
if (SUPPORT_JIT) { if (SUPPORT_JIT) {
// compile code // compile code
let func = ''; let func = '';
// tslint:disable: forin
for (key in propsToReset) { for (key in propsToReset) {
let statement; let statement;
if (CCClass.IDENTIFIER_RE.test(key)) { if (CCClass.IDENTIFIER_RE.test(key)) {
@@ -277,7 +277,7 @@ class CCObject {
if (EDITOR && deferredDestroyTimer === null && legacyCC.engine && ! legacyCC.engine._isUpdating) { if (EDITOR && deferredDestroyTimer === null && legacyCC.engine && ! legacyCC.engine._isUpdating) {
// auto destroy immediate in edit mode // auto destroy immediate in edit mode
// @ts-ignore // @ts-expect-error
deferredDestroyTimer = setImmediate(CCObject._deferredDestroy); deferredDestroyTimer = setImmediate(CCObject._deferredDestroy);
} }
return true; return true;
@@ -320,9 +320,9 @@ class CCObject {
return; return;
} }
// engine internal callback // engine internal callback
// @ts-ignore // @ts-expect-error
if (this._onPreDestroy) { if (this._onPreDestroy) {
// @ts-ignore // @ts-expect-error
this._onPreDestroy(); this._onPreDestroy();
} }
@@ -350,7 +350,7 @@ if (EDITOR || TEST) {
* @method realDestroyInEditor * @method realDestroyInEditor
* @private * @private
*/ */
// @ts-ignore // @ts-expect-error
prototype.realDestroyInEditor = function () { prototype.realDestroyInEditor = function () {
if ( !(this._objFlags & Destroyed) ) { if ( !(this._objFlags & Destroyed) ) {
warnID(5001); warnID(5001);
@@ -368,7 +368,7 @@ if (EDITOR || TEST) {
if (EDITOR) { if (EDITOR) {
js.value(CCObject, '_clearDeferredDestroyTimer', () => { js.value(CCObject, '_clearDeferredDestroyTimer', () => {
if (deferredDestroyTimer !== null) { if (deferredDestroyTimer !== null) {
// @ts-ignore // @ts-expect-error
clearImmediate(deferredDestroyTimer); clearImmediate(deferredDestroyTimer);
deferredDestroyTimer = null; deferredDestroyTimer = null;
} }
@@ -381,7 +381,7 @@ if (EDITOR) {
* @return {object} the serialized json data object * @return {object} the serialized json data object
* @private * @private
*/ */
// @ts-ignore // @ts-expect-error
prototype._serialize = null; prototype._serialize = null;
} }
@@ -392,14 +392,14 @@ if (EDITOR) {
* @param {_Deserializer} ctx * @param {_Deserializer} ctx
* @private * @private
*/ */
// @ts-ignore // @ts-expect-error
prototype._deserialize = null; prototype._deserialize = null;
/* /*
* Called before the object being destroyed. * Called before the object being destroyed.
* @method _onPreDestroy * @method _onPreDestroy
* @private * @private
*/ */
// @ts-ignore // @ts-expect-error
prototype._onPreDestroy = null; prototype._onPreDestroy = null;
CCClass.fastDefine('cc.Object', CCObject, { _name: '', _objFlags: 0 }); CCClass.fastDefine('cc.Object', CCObject, { _name: '', _objFlags: 0 });
+2 -2
View File
@@ -24,8 +24,8 @@
THE SOFTWARE. THE SOFTWARE.
*/ */
// tslint:disable:only-arrow-functions
// tslint:disable:one-variable-per-declaration
import { log, warnID } from '../../platform/debug'; import { log, warnID } from '../../platform/debug';
import { formatStr, get, getClassName, isChildClassOf, value } from '../../utils/js'; import { formatStr, get, getClassName, isChildClassOf, value } from '../../utils/js';
+3 -3
View File
@@ -66,7 +66,7 @@ function parseNotify (val, propName, notify, properties) {
const newValue = {}; const newValue = {};
properties[newKey] = newValue; properties[newKey] = newValue;
// 将不能用于get方法中的属性移动到newValue中 // 将不能用于get方法中的属性移动到newValue中
// tslint:disable: forin
for (const attr in SerializableAttrs) { for (const attr in SerializableAttrs) {
const v = SerializableAttrs[attr]; const v = SerializableAttrs[attr];
if (val.hasOwnProperty(attr)) { if (val.hasOwnProperty(attr)) {
@@ -157,7 +157,7 @@ function getBaseClassWherePropertyDefined_DEV (propName, cls) {
} }
} }
// tslint:disable: no-shadowed-variable
function _wrapOptions (isGetset: boolean, _default, type?: Function | Function[]) { function _wrapOptions (isGetset: boolean, _default, type?: Function | Function[]) {
let res: { let res: {
@@ -244,7 +244,7 @@ export function doValidateMethodWithProps_DEV (func, funcName, className, cls, b
js.isChildClassOf(base, legacyCC.Component) && js.isChildClassOf(base, legacyCC.Component) &&
!CALL_SUPER_DESTROY_REG_DEV.test(func) !CALL_SUPER_DESTROY_REG_DEV.test(func)
) { ) {
// tslint:disable-next-line: max-line-length
error(`Overwriting '${funcName}' function in '${className}' class without calling super is not allowed. Call the super function in '${funcName}' please.`); error(`Overwriting '${funcName}' function in '${className}' class without calling super is not allowed. Call the super function in '${funcName}' please.`);
} }
} }
+1 -1
View File
@@ -53,7 +53,7 @@ export function pop () {
const module = frameInfo.module; const module = frameInfo.module;
let exports = module.exports; let exports = module.exports;
if (exports === frameInfo.exports) { if (exports === frameInfo.exports) {
// tslint:disable-next-line: forin
for (const anykey in exports) { for (const anykey in exports) {
// exported // exported
return; return;
+2 -2
View File
@@ -19,7 +19,7 @@ export const PREVIEW = tryDefineGlobal('CC_PREVIEW', !EDITOR);
export const DEV = tryDefineGlobal('CC_DEV', true); // (CC_EDITOR && !CC_BUILD) || CC_PREVIEW || CC_TEST export const DEV = tryDefineGlobal('CC_DEV', true); // (CC_EDITOR && !CC_BUILD) || CC_PREVIEW || CC_TEST
export const DEBUG = tryDefineGlobal('CC_DEBUG', true); // CC_DEV || Debug Build export const DEBUG = tryDefineGlobal('CC_DEBUG', true); // CC_DEV || Debug Build
export const JSB = tryDefineGlobal('CC_JSB', defined('jsb')); export const JSB = tryDefineGlobal('CC_JSB', defined('jsb'));
// @ts-ignore // @ts-expect-error
export const WECHAT = tryDefineGlobal('CC_WECHAT', !!(defined('wx') && (wx.getSystemInfoSync || wx.getSharedCanvas))); export const WECHAT = tryDefineGlobal('CC_WECHAT', !!(defined('wx') && (wx.getSystemInfoSync || wx.getSharedCanvas)));
export const MINIGAME = tryDefineGlobal('CC_MINIGAME', false); export const MINIGAME = tryDefineGlobal('CC_MINIGAME', false);
export const RUNTIME_BASED = tryDefineGlobal('CC_RUNTIME_BASED', false); export const RUNTIME_BASED = tryDefineGlobal('CC_RUNTIME_BASED', false);
@@ -31,5 +31,5 @@ export const COCOSPLAY = tryDefineGlobal('CC_COCOSPLAY', false);
export const HUAWEI = tryDefineGlobal('CC_HUAWEI', false); export const HUAWEI = tryDefineGlobal('CC_HUAWEI', false);
export const OPPO = tryDefineGlobal('CC_OPPO', false); export const OPPO = tryDefineGlobal('CC_OPPO', false);
export const VIVO = tryDefineGlobal('CC_VIVO', false); export const VIVO = tryDefineGlobal('CC_VIVO', false);
// @ts-ignore // @ts-expect-error
export const SUPPORT_JIT = tryDefineGlobal('CC_SUPPORT_JIT', ('function' === typeof loadRuntime)); export const SUPPORT_JIT = tryDefineGlobal('CC_SUPPORT_JIT', ('function' === typeof loadRuntime));
+5 -6
View File
@@ -463,7 +463,7 @@ export class Director extends EventTarget {
if (BUILD && DEBUG) { if (BUILD && DEBUG) {
console.time('InitScene'); console.time('InitScene');
} }
// @ts-ignore // @ts-expect-error
scene._load(); // ensure scene initialized scene._load(); // ensure scene initialized
if (BUILD && DEBUG) { if (BUILD && DEBUG) {
console.timeEnd('InitScene'); console.timeEnd('InitScene');
@@ -529,7 +529,7 @@ export class Director extends EventTarget {
if (BUILD && DEBUG) { if (BUILD && DEBUG) {
console.time('Activate'); console.time('Activate');
} }
// @ts-ignore // @ts-expect-error
scene._activate(); scene._activate();
if (BUILD && DEBUG) { if (BUILD && DEBUG) {
console.timeEnd('Activate'); console.timeEnd('Activate');
@@ -561,7 +561,7 @@ export class Director extends EventTarget {
assertID(scene instanceof Scene, 1216); assertID(scene instanceof Scene, 1216);
// ensure scene initialized // ensure scene initialized
// @ts-ignore // @ts-expect-error
scene._load(); scene._load();
// Delay run / replace scene to the end of the frame // Delay run / replace scene to the end of the frame
@@ -583,7 +583,7 @@ export class Director extends EventTarget {
warnID(1208, sceneName, this._loadingScene); warnID(1208, sceneName, this._loadingScene);
return false; return false;
} }
var bundle = legacyCC.assetManager.bundles.find((bundle) => { const bundle = legacyCC.assetManager.bundles.find((bundle) => {
return bundle.getSceneInfo(sceneName); return bundle.getSceneInfo(sceneName);
}); });
if (bundle) { if (bundle) {
@@ -638,7 +638,6 @@ export class Director extends EventTarget {
* @param onProgress 加载进度回调。 * @param onProgress 加载进度回调。
* @param onLoaded 加载回调。 * @param onLoaded 加载回调。
*/ */
// eslint-disable-next-line @typescript-eslint/unified-signatures
public preloadScene (sceneName: string, onProgress: Director.OnLoadSceneProgress, onLoaded: Director.OnSceneLoaded): void; public preloadScene (sceneName: string, onProgress: Director.OnLoadSceneProgress, onLoaded: Director.OnSceneLoaded): void;
public preloadScene ( public preloadScene (
@@ -646,7 +645,7 @@ export class Director extends EventTarget {
onProgress?: Director.OnLoadSceneProgress | Director.OnSceneLoaded, onProgress?: Director.OnLoadSceneProgress | Director.OnSceneLoaded,
onLoaded?: Director.OnSceneLoaded) { onLoaded?: Director.OnSceneLoaded) {
var bundle = legacyCC.assetManager.bundles.find(function (bundle) { const bundle = legacyCC.assetManager.bundles.find(function (bundle) {
return bundle.getSceneInfo(sceneName); return bundle.getSceneInfo(sceneName);
}); });
if (bundle) { if (bundle) {
+1 -1
View File
@@ -34,7 +34,7 @@ export function applyMixins (derivedCtor: any, baseCtors: any[]) {
baseCtors.forEach((baseCtor) => { baseCtors.forEach((baseCtor) => {
Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => { Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
if (name !== 'constructor') { if (name !== 'constructor') {
// @ts-ignore // @ts-expect-error
Object.defineProperty(derivedCtor.prototype, name, Object.getOwnPropertyDescriptor(baseCtor.prototype, name)); Object.defineProperty(derivedCtor.prototype, name, Object.getOwnPropertyDescriptor(baseCtor.prototype, name));
} }
}); });
+1 -2
View File
@@ -34,8 +34,7 @@ import { CallbacksInvoker } from './callbacks-invoker';
import { legacyCC } from '../global-exports'; import { legacyCC } from '../global-exports';
import { Eventify } from './eventify'; import { Eventify } from './eventify';
// eslint-disable-next-line @typescript-eslint/no-extraneous-class class Empty {}
class Empty {};
/** /**
* @en * @en
+25 -25
View File
@@ -198,7 +198,7 @@ export class Game extends EventTarget {
* }); * });
* ``` * ```
*/ */
public static EVENT_HIDE: string = 'game_on_hide'; public static EVENT_HIDE = 'game_on_hide';
/** /**
* @en Event triggered when game back to foreground<br> * @en Event triggered when game back to foreground<br>
@@ -222,7 +222,7 @@ export class Game extends EventTarget {
* @en Event triggered after game inited, at this point all engine objects and game scripts are loaded * @en Event triggered after game inited, at this point all engine objects and game scripts are loaded
* @zh 游戏启动后的触发事件,此时加载所有的引擎对象和游戏脚本。 * @zh 游戏启动后的触发事件,此时加载所有的引擎对象和游戏脚本。
*/ */
public static EVENT_GAME_INITED: string = 'game_inited'; public static EVENT_GAME_INITED = 'game_inited';
/** /**
* @en Event triggered after engine inited, at this point you will be able to use all engine classes.<br> * @en Event triggered after engine inited, at this point you will be able to use all engine classes.<br>
@@ -232,7 +232,7 @@ export class Game extends EventTarget {
* 它在 cocos creator v1.x 版本中名字为 EVENT_RENDERER_INITED ,在 v2.0 版本中更名为 EVENT_ENGINE_INITED * 它在 cocos creator v1.x 版本中名字为 EVENT_RENDERER_INITED ,在 v2.0 版本中更名为 EVENT_ENGINE_INITED
* 并在 cocos creator 3d 版本中将 EVENT_RENDERER_INITED 用作为渲染器初始化的事件。 * 并在 cocos creator 3d 版本中将 EVENT_RENDERER_INITED 用作为渲染器初始化的事件。
*/ */
public static EVENT_ENGINE_INITED: string = 'engine_inited'; public static EVENT_ENGINE_INITED = 'engine_inited';
/** /**
* @en Event triggered after renderer inited, at this point you will be able to use all gfx renderer feature.<br> * @en Event triggered after renderer inited, at this point you will be able to use all gfx renderer feature.<br>
@@ -244,29 +244,29 @@ export class Game extends EventTarget {
* @en Event triggered when game restart * @en Event triggered when game restart
* @zh 调用restart后,触发事件 * @zh 调用restart后,触发事件
*/ */
public static EVENT_RESTART: string = 'game_on_restart'; public static EVENT_RESTART = 'game_on_restart';
/** /**
* @en Web Canvas 2d API as renderer backend. * @en Web Canvas 2d API as renderer backend.
* @zh 使用 Web Canvas 2d API 作为渲染器后端。 * @zh 使用 Web Canvas 2d API 作为渲染器后端。
*/ */
public static RENDER_TYPE_CANVAS: number = 0; public static RENDER_TYPE_CANVAS = 0;
/** /**
* @en WebGL API as renderer backend. * @en WebGL API as renderer backend.
* @zh 使用 WebGL API 作为渲染器后端。 * @zh 使用 WebGL API 作为渲染器后端。
*/ */
public static RENDER_TYPE_WEBGL: number = 1; public static RENDER_TYPE_WEBGL = 1;
/** /**
* @en OpenGL API as renderer backend. * @en OpenGL API as renderer backend.
* @zh 使用 OpenGL API 作为渲染器后端。 * @zh 使用 OpenGL API 作为渲染器后端。
*/ */
public static RENDER_TYPE_OPENGL: number = 2; public static RENDER_TYPE_OPENGL = 2;
/** /**
* @en The outer frame of the game canvas; parent of game container. * @en The outer frame of the game canvas; parent of game container.
* @zh 游戏画布的外框,container 的父容器。 * @zh 游戏画布的外框,container 的父容器。
*/ */
public frame: Object | null = null; public frame: Record<string, unknown> | null = null;
/** /**
* @en The container of game canvas. * @en The container of game canvas.
* @zh 游戏画布的容器。 * @zh 游戏画布的容器。
@@ -282,7 +282,7 @@ export class Game extends EventTarget {
* @en The renderer backend of the game. * @en The renderer backend of the game.
* @zh 游戏的渲染器类型。 * @zh 游戏的渲染器类型。
*/ */
public renderType: number = -1; public renderType = -1;
public eventTargetOn = super.on; public eventTargetOn = super.on;
public eventTargetOnce = super.once; public eventTargetOnce = super.once;
@@ -319,11 +319,11 @@ export class Game extends EventTarget {
public _persistRootNodes = {}; public _persistRootNodes = {};
// states // states
public _paused: boolean = true; // whether the game is paused public _paused = true; // whether the game is paused
public _configLoaded: boolean = false; // whether config loaded public _configLoaded = false; // whether config loaded
public _isCloning: boolean = false; // deserializing or instantiating public _isCloning = false; // deserializing or instantiating
public _inited: boolean = false; // whether the engine has inited public _inited = false; // whether the engine has inited
public _rendererInitialized: boolean = false; public _rendererInitialized = false;
public _gfxDevice: Device | null = null; public _gfxDevice: Device | null = null;
@@ -430,9 +430,9 @@ export class Game extends EventTarget {
*/ */
public restart (): Promise<void> { public restart (): Promise<void> {
const afterDrawPromise = new Promise<void>((resolve) => const afterDrawPromise = new Promise<void>((resolve) =>
legacyCC.director.once(legacyCC.Director.EVENT_AFTER_DRAW, () => resolve())); legacyCC.director.once(legacyCC.Director.EVENT_AFTER_DRAW, () => resolve()) as void);
return afterDrawPromise.then(() => { return afterDrawPromise.then(() => {
// tslint:disable-next-line: forin
for (const id in this._persistRootNodes) { for (const id in this._persistRootNodes) {
this.removePersistRootNode(this._persistRootNodes[id]); this.removePersistRootNode(this._persistRootNodes[id]);
} }
@@ -499,7 +499,7 @@ export class Game extends EventTarget {
* The callback is ignored if it is a duplicate (the callbacks are unique). * The callback is ignored if it is a duplicate (the callbacks are unique).
* @param target - The target (this object) to invoke the callback, can be null * @param target - The target (this object) to invoke the callback, can be null
*/ */
// @ts-ignore // @ts-expect-error
public once (type: string, callback: Function, target?: object) { public once (type: string, callback: Function, target?: object) {
// Make sure EVENT_ENGINE_INITED callbacks to be invoked // Make sure EVENT_ENGINE_INITED callbacks to be invoked
if (this._inited && type === Game.EVENT_ENGINE_INITED) { if (this._inited && type === Game.EVENT_ENGINE_INITED) {
@@ -526,7 +526,7 @@ export class Game extends EventTarget {
if (!EDITOR) { if (!EDITOR) {
this._initEvents(); this._initEvents();
} }
legacyCC.director.root.dataPoolManager.jointTexturePool.registerCustomTextureLayouts(config.customJointTextureLayouts); legacyCC.director.root.dataPoolManager.jointTexturePool.registerCustomTextureLayouts(config.customJointTextureLayouts);
return this._inited; return this._inited;
}); });
@@ -557,7 +557,7 @@ export class Game extends EventTarget {
return Promise.resolve(initPromise).then(() => { return Promise.resolve(initPromise).then(() => {
this._setAnimFrame(); this._setAnimFrame();
this._runMainLoop(); this._runMainLoop();
// register system events // register system events
if (!EDITOR && game.config.registerSystemEvent) { if (!EDITOR && game.config.registerSystemEvent) {
inputManager.registerSystemEvent(game.canvas); inputManager.registerSystemEvent(game.canvas);
@@ -647,7 +647,7 @@ export class Game extends EventTarget {
const frameRate = this.config.frameRate; const frameRate = this.config.frameRate;
this._frameTime = 1000 / frameRate; this._frameTime = 1000 / frameRate;
if (JSB || RUNTIME_BASED) { if (JSB || RUNTIME_BASED) {
// @ts-ignore // @ts-expect-error
jsb.setPreferredFramesPerSecond(frameRate); jsb.setPreferredFramesPerSecond(frameRate);
window.rAF = window.requestAnimationFrame; window.rAF = window.requestAnimationFrame;
window.cAF = window.cancelAnimationFrame; window.cAF = window.cancelAnimationFrame;
@@ -664,7 +664,7 @@ export class Game extends EventTarget {
window.oRequestAnimationFrame || window.oRequestAnimationFrame ||
window.msRequestAnimationFrame; window.msRequestAnimationFrame;
if (frameRate !== 60 && frameRate !== 30) { if (frameRate !== 60 && frameRate !== 30) {
// @ts-ignore // @ts-expect-error
window.rAF = rAF ? this._stTimeWithRAF : this._stTime; window.rAF = rAF ? this._stTimeWithRAF : this._stTime;
window.cAF = this._ctTime; window.cAF = this._ctTime;
} }
@@ -714,7 +714,7 @@ export class Game extends EventTarget {
} }
const config = this.config; const config = this.config;
const director = legacyCC.director; const director = legacyCC.director;
let skip: boolean = true; let skip = true;
const frameRate = config.frameRate; const frameRate = config.frameRate;
debug.setDisplayStats(!!config.showFPS); debug.setDisplayStats(!!config.showFPS);
@@ -849,7 +849,7 @@ export class Game extends EventTarget {
); );
for (let i = 0; i < ctors.length; i++) { for (let i = 0; i < ctors.length; i++) {
this._gfxDevice = new ctors[i](); this._gfxDevice = new ctors[i]();
if (this._gfxDevice!.initialize(opts)) { break; } if (this._gfxDevice.initialize(opts)) { break; }
} }
} }
@@ -904,12 +904,12 @@ export class Game extends EventTarget {
'webkitvisibilitychange', 'webkitvisibilitychange',
'qbrowserVisibilityChange', 'qbrowserVisibilityChange',
]; ];
// tslint:disable-next-line: prefer-for-of
for (let i = 0; i < changeList.length; i++) { for (let i = 0; i < changeList.length; i++) {
document.addEventListener(changeList[i], (event) => { document.addEventListener(changeList[i], (event) => {
let visible = document[hiddenPropName]; let visible = document[hiddenPropName];
// QQ App // QQ App
// @ts-ignore // @ts-expect-error
visible = visible || event.hidden; visible = visible || event.hidden;
if (visible) { if (visible) {
onHidden(); onHidden();
+1 -1
View File
@@ -28,7 +28,7 @@ const transform_extent_m4 = (out: Vec3, extent: Vec3, m4: Mat4) => {
* @zh * @zh
* 基础几何 轴对齐包围盒,使用中心点和半长宽高的结构。 * 基础几何 轴对齐包围盒,使用中心点和半长宽高的结构。
*/ */
// tslint:disable-next-line: class-name
export default class aabb { export default class aabb {
/** /**
+1 -1
View File
@@ -24,7 +24,7 @@ _v[7] = new Vec3(1, -1, -1);
* @zh * @zh
* 基础几何 截头锥体。 * 基础几何 截头锥体。
*/ */
// tslint:disable-next-line: class-name
export class frustum { export class frustum {
/** /**
+6 -6
View File
@@ -21,10 +21,10 @@ import { IRaySubMeshOptions, ERaycastMode, IRaySubMeshResult, IRayMeshOptions, I
import { IVec3Like } from '../math/type-define'; import { IVec3Like } from '../math/type-define';
import { scene } from '../renderer'; import { scene } from '../renderer';
// tslint:disable:only-arrow-functions
// tslint:disable:one-variable-per-declaration
// tslint:disable:prefer-for-of
// tslint:disable:no-shadowed-variable
/** /**
* @en * @en
@@ -408,7 +408,7 @@ const ray_subMesh = (function () {
const max = submesh.geometricInfo.boundingBox.max; const max = submesh.geometricInfo.boundingBox.max;
if (ray_aabb2(ray, min, max)) { if (ray_aabb2(ray, min, max)) {
const pm = submesh.primitiveMode; const pm = submesh.primitiveMode;
const { positions: vb, indices: ib } = submesh.geometricInfo!; const { positions: vb, indices: ib } = submesh.geometricInfo;
narrowphase(vb, ib!, pm, ray, opt); narrowphase(vb, ib!, pm, ray, opt);
} }
return minDis; return minDis;
@@ -1079,7 +1079,7 @@ const obb_obb = (function () {
}; };
})(); })();
// tslint:disable-next-line: max-line-length
// https://github.com/diku-dk/bvh-tvcg18/blob/1fd3348c17bc8cf3da0b4ae60fdb8f2aa90a6ff0/FOUNDATION/GEOMETRY/GEOMETRY/include/overlap/geometry_overlap_obb_capsule.h // https://github.com/diku-dk/bvh-tvcg18/blob/1fd3348c17bc8cf3da0b4ae60fdb8f2aa90a6ff0/FOUNDATION/GEOMETRY/GEOMETRY/include/overlap/geometry_overlap_obb_capsule.h
/** /**
* @en * @en
+1 -1
View File
@@ -12,7 +12,7 @@ import enums from './enums';
* @zh * @zh
* 基础几何 line。 * 基础几何 line。
*/ */
// tslint:disable-next-line:class-name
export default class line { export default class line {
/** /**
+1 -1
View File
@@ -24,7 +24,7 @@ const transform_extent_m3 = (out: Vec3, extent: Vec3, m3: Mat3) => {
* @zh * @zh
* 基础几何 方向包围盒。 * 基础几何 方向包围盒。
*/ */
// tslint:disable-next-line:class-name
export default class obb { export default class obb {
/** /**
+1 -1
View File
@@ -18,7 +18,7 @@ const temp_vec4 = legacyCC.v4();
* @zh * @zh
* 基础几何 plane。 * 基础几何 plane。
*/ */
// tslint:disable-next-line:class-name
export default class plane { export default class plane {
/** /**
+4 -4
View File
@@ -13,7 +13,7 @@ import { IVec3Like } from '../math/type-define';
* @zh * @zh
* 基础几何 射线。 * 基础几何 射线。
*/ */
// tslint:disable-next-line:class-name
export default class ray { export default class ray {
/** /**
@@ -29,7 +29,7 @@ export default class ray {
* @param {number} dz 方向的 z 部分。 * @param {number} dz 方向的 z 部分。
* @return {ray} 射线。 * @return {ray} 射线。
*/ */
public static create (ox: number = 0, oy: number = 0, oz: number = 0, dx: number = 0, dy: number = 0, dz: number = 1): ray { public static create (ox = 0, oy = 0, oz = 0, dx = 0, dy = 0, dz = 1): ray {
return new ray(ox, oy, oz, dx, dy, dz); return new ray(ox, oy, oz, dx, dy, dz);
} }
@@ -145,8 +145,8 @@ export default class ray {
* @param {number} dy 方向的 y 部分。 * @param {number} dy 方向的 y 部分。
* @param {number} dz 方向的 z 部分。 * @param {number} dz 方向的 z 部分。
*/ */
constructor (ox: number = 0, oy: number = 0, oz: number = 0, constructor (ox = 0, oy = 0, oz = 0,
dx: number = 0, dy: number = 0, dz: number = -1) { dx = 0, dy = 0, dz = -1) {
this._type = enums.SHAPE_RAY; this._type = enums.SHAPE_RAY;
this.o = new Vec3(ox, oy, oz); this.o = new Vec3(ox, oy, oz);
this.d = new Vec3(dx, dy, dz); this.d = new Vec3(dx, dy, dz);
+2 -2
View File
@@ -20,7 +20,7 @@ function maxComponent (v: Vec3) { return Math.max(Math.max(v.x, v.y), v.z); }
* @zh * @zh
* 基础几何 轴对齐球。 * 基础几何 轴对齐球。
*/ */
// tslint:disable-next-line: class-name
export default class sphere { export default class sphere {
/** /**
@@ -201,7 +201,7 @@ export default class sphere {
* @param cz 该球的世界坐标的 Z 坐标。 * @param cz 该球的世界坐标的 Z 坐标。
* @param {number} r 半径。 * @param {number} r 半径。
*/ */
constructor (cx: number = 0, cy: number = 0, cz: number = 0, r: number = 1) { constructor (cx = 0, cy = 0, cz = 0, r = 1) {
this._type = enums.SHAPE_SPHERE; this._type = enums.SHAPE_SPHERE;
this._center = new Vec3(cx, cy, cz); this._center = new Vec3(cx, cy, cz);
this._poolHandle = SpherePool.alloc(); this._poolHandle = SpherePool.alloc();
+7 -7
View File
@@ -12,7 +12,7 @@ import enums from './enums';
* @zh * @zh
* 基础几何 三角形。 * 基础几何 三角形。
*/ */
// tslint:disable-next-line:class-name
export default class triangle { export default class triangle {
/** /**
@@ -31,9 +31,9 @@ export default class triangle {
* @param {number} cz c 点的 z 部分。 * @param {number} cz c 点的 z 部分。
* @return {triangle} 一个新的 triangle。 * @return {triangle} 一个新的 triangle。
*/ */
public static create (ax: number = 1, ay: number = 0, az: number = 0, public static create (ax = 1, ay = 0, az = 0,
bx: number = 0, by: number = 0, bz: number = 0, bx = 0, by = 0, bz = 0,
cx: number = 0, cy: number = 0, cz: number = 1): triangle { cx = 0, cy = 0, cz = 1): triangle {
return new triangle(ax, ay, az, bx, by, bz, cx, cy, cz); return new triangle(ax, ay, az, bx, by, bz, cx, cy, cz);
} }
@@ -176,9 +176,9 @@ export default class triangle {
* @param {number} cy c 点的 y 部分。 * @param {number} cy c 点的 y 部分。
* @param {number} cz c 点的 z 部分。 * @param {number} cz c 点的 z 部分。
*/ */
constructor (ax: number = 0, ay: number = 0, az: number = 0, constructor (ax = 0, ay = 0, az = 0,
bx: number = 1, by: number = 0, bz: number = 0, bx = 1, by = 0, bz = 0,
cx: number = 0, cy: number = 1, cz: number = 0) { cx = 0, cy = 1, cz = 0) {
this._type = enums.SHAPE_TRIANGLE; this._type = enums.SHAPE_TRIANGLE;
this.a = new Vec3(ax, ay, az); this.a = new Vec3(ax, ay, az);
this.b = new Vec3(bx, by, bz); this.b = new Vec3(bx, by, bz);
+9 -9
View File
@@ -3,6 +3,7 @@
* @module gfx * @module gfx
*/ */
import { Device } from './device';
import { import {
BufferFlagBit, BufferFlagBit,
BufferFlags, BufferFlags,
@@ -13,10 +14,9 @@ import {
Obj, Obj,
ObjectType, ObjectType,
} from './define'; } from './define';
import { Device } from './device';
export class DrawInfo { export class DrawInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public vertexCount: number = 0, public vertexCount: number = 0,
@@ -29,10 +29,10 @@ export class DrawInfo {
) {} ) {}
} }
export const DRAW_INFO_SIZE: number = 28; export const DRAW_INFO_SIZE = 28;
export class IndirectBuffer { export class IndirectBuffer {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public drawInfos: DrawInfo[] = [], public drawInfos: DrawInfo[] = [],
@@ -42,7 +42,7 @@ export class IndirectBuffer {
export type BufferSource = ArrayBuffer | IndirectBuffer; export type BufferSource = ArrayBuffer | IndirectBuffer;
export class BufferInfo { export class BufferInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public usage: BufferUsage, public usage: BufferUsage,
@@ -54,7 +54,7 @@ export class BufferInfo {
} }
export class BufferViewInfo { export class BufferViewInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public buffer: Buffer, public buffer: Buffer,
@@ -124,9 +124,9 @@ export abstract class Buffer extends Obj {
protected _device: Device; protected _device: Device;
protected _usage: BufferUsage = BufferUsageBit.NONE; protected _usage: BufferUsage = BufferUsageBit.NONE;
protected _memUsage: MemoryUsage = MemoryUsageBit.NONE; protected _memUsage: MemoryUsage = MemoryUsageBit.NONE;
protected _size: number = 0; protected _size = 0;
protected _stride: number = 1; protected _stride = 1;
protected _count: number = 0; protected _count = 0;
protected _flags: BufferFlags = BufferFlagBit.NONE; protected _flags: BufferFlags = BufferFlagBit.NONE;
protected _bakcupBuffer: Uint8Array | null = null; protected _bakcupBuffer: Uint8Array | null = null;
protected _indirectBuffer: IndirectBuffer | null = null; protected _indirectBuffer: IndirectBuffer | null = null;
+13 -12
View File
@@ -3,25 +3,25 @@
* @module gfx * @module gfx
*/ */
import { DescriptorSet } from './descriptor-set';
import { Buffer } from './buffer'; import { Buffer } from './buffer';
import { DescriptorSet } from './descriptor-set';
import { Device } from './device';
import { Framebuffer } from './framebuffer';
import { InputAssembler } from './input-assembler';
import { PipelineState } from './pipeline-state';
import { Queue } from './queue';
import { RenderPass } from './render-pass';
import { Texture } from './texture';
import { BufferTextureCopy, Color, Rect, Viewport } from './define-class';
import { import {
CommandBufferType, CommandBufferType,
Obj, Obj,
ObjectType, ObjectType,
StencilFace, StencilFace,
} from './define'; } from './define';
import { BufferTextureCopy, Color, Rect, Viewport } from './define-class';
import { Device } from './device';
import { Framebuffer } from './framebuffer';
import { InputAssembler } from './input-assembler';
import { PipelineState } from './pipeline-state';
import { Texture } from './texture';
import { RenderPass } from './render-pass';
import { Queue } from './queue';
export class CommandBufferInfo { export class CommandBufferInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public queue: Queue, public queue: Queue,
@@ -33,7 +33,7 @@ export class CommandBufferInfo {
* @en GFX command buffer. * @en GFX command buffer.
* @zh GFX 命令缓冲。 * @zh GFX 命令缓冲。
*/ */
// tslint:disable: max-line-length
export abstract class CommandBuffer extends Obj { export abstract class CommandBuffer extends Obj {
/** /**
@@ -122,7 +122,8 @@ export abstract class CommandBuffer extends Obj {
* @param clearDepth The clearing depth. * @param clearDepth The clearing depth.
* @param clearStencil The clearing stencil. * @param clearStencil The clearing stencil.
*/ */
public abstract beginRenderPass (renderPass: RenderPass, framebuffer: Framebuffer, renderArea: Rect, clearColors: Color[], clearDepth: number, clearStencil: number): void; public abstract beginRenderPass (renderPass: RenderPass, framebuffer: Framebuffer,
renderArea: Rect, clearColors: Color[], clearDepth: number, clearStencil: number): void;
/** /**
* @en End render pass. * @en End render pass.
+8 -8
View File
@@ -3,7 +3,7 @@
*/ */
export class Rect { export class Rect {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public x: number = 0, public x: number = 0,
@@ -14,7 +14,7 @@ export class Rect {
} }
export class Viewport { export class Viewport {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public left: number = 0, public left: number = 0,
@@ -27,7 +27,7 @@ export class Viewport {
} }
export class Color { export class Color {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public x: number = 0, public x: number = 0,
@@ -38,7 +38,7 @@ export class Color {
} }
export class Offset { export class Offset {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public x: number = 0, public x: number = 0,
@@ -48,7 +48,7 @@ export class Offset {
} }
export class Extent { export class Extent {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public width: number = 0, public width: number = 0,
@@ -58,7 +58,7 @@ export class Extent {
} }
export class TextureSubres { export class TextureSubres {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public mipLevel: number = 0, public mipLevel: number = 0,
@@ -68,7 +68,7 @@ export class TextureSubres {
} }
export class TextureCopy { export class TextureCopy {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public srcSubres = new TextureSubres(), public srcSubres = new TextureSubres(),
@@ -80,7 +80,7 @@ export class TextureCopy {
} }
export class BufferTextureCopy { export class BufferTextureCopy {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public buffStride: number = 0, public buffStride: number = 0,
+2 -2
View File
@@ -600,7 +600,7 @@ export enum Feature {
} }
export class FormatInfo { export class FormatInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public readonly name: string, public readonly name: string,
@@ -615,7 +615,7 @@ export class FormatInfo {
} }
export class MemoryStatus { export class MemoryStatus {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public bufferSize: number = 0, public bufferSize: number = 0,
+3 -3
View File
@@ -3,12 +3,12 @@
* @module gfx * @module gfx
*/ */
import { DescriptorType, Obj, ObjectType, ShaderStageFlagBit, ShaderStageFlags } from './define';
import { Device } from './device'; import { Device } from './device';
import { Sampler } from './sampler'; import { Sampler } from './sampler';
import { DescriptorType, Obj, ObjectType, ShaderStageFlagBit, ShaderStageFlags } from './define';
export class DescriptorSetLayoutBinding { export class DescriptorSetLayoutBinding {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public binding: number = -1, public binding: number = -1,
@@ -20,7 +20,7 @@ export class DescriptorSetLayoutBinding {
} }
export class DescriptorSetLayoutInfo { export class DescriptorSetLayoutInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public bindings: DescriptorSetLayoutBinding[] = [] public bindings: DescriptorSetLayoutBinding[] = []
+6 -6
View File
@@ -4,11 +4,11 @@
*/ */
import { Buffer } from './buffer'; import { Buffer } from './buffer';
import { DescriptorType, Obj, ObjectType } from './define'; import { DescriptorSetLayout } from './descriptor-set-layout';
import { Device } from './device'; import { Device } from './device';
import { Sampler } from './sampler'; import { Sampler } from './sampler';
import { Texture } from './texture'; import { Texture } from './texture';
import { DescriptorSetLayout } from './descriptor-set-layout'; import { DescriptorType, Obj, ObjectType } from './define';
export const DESCRIPTOR_BUFFER_TYPE = export const DESCRIPTOR_BUFFER_TYPE =
DescriptorType.UNIFORM_BUFFER | DescriptorType.DYNAMIC_UNIFORM_BUFFER | DescriptorType.UNIFORM_BUFFER | DescriptorType.DYNAMIC_UNIFORM_BUFFER |
@@ -17,7 +17,7 @@ export const DESCRIPTOR_BUFFER_TYPE =
export const DESCRIPTOR_SAMPLER_TYPE = DescriptorType.SAMPLER; export const DESCRIPTOR_SAMPLER_TYPE = DescriptorType.SAMPLER;
export class DescriptorSetInfo { export class DescriptorSetInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public layout: DescriptorSetLayout, public layout: DescriptorSetLayout,
@@ -62,7 +62,7 @@ export abstract class DescriptorSet extends Obj {
*/ */
public bindBuffer (binding: number, buffer: Buffer, index = 0) { public bindBuffer (binding: number, buffer: Buffer, index = 0) {
const bindingIndex = this._layout!.bindingIndices[binding]; const bindingIndex = this._layout!.bindingIndices[binding];
const info = this._layout!.bindings[bindingIndex]; if (!info) return; const info = this._layout!.bindings[bindingIndex]; if (!info) { return; }
if (info.descriptorType & DESCRIPTOR_BUFFER_TYPE) { if (info.descriptorType & DESCRIPTOR_BUFFER_TYPE) {
const descriptorIndex = this._layout!.descriptorIndices[binding]; const descriptorIndex = this._layout!.descriptorIndices[binding];
if (this._buffers[descriptorIndex + index] !== buffer) { if (this._buffers[descriptorIndex + index] !== buffer) {
@@ -82,7 +82,7 @@ export abstract class DescriptorSet extends Obj {
*/ */
public bindSampler (binding: number, sampler: Sampler, index = 0) { public bindSampler (binding: number, sampler: Sampler, index = 0) {
const bindingIndex = this._layout!.bindingIndices[binding]; const bindingIndex = this._layout!.bindingIndices[binding];
const info = this._layout!.bindings[bindingIndex]; if (!info) return; const info = this._layout!.bindings[bindingIndex]; if (!info) { return; }
if (info.descriptorType & DESCRIPTOR_SAMPLER_TYPE) { if (info.descriptorType & DESCRIPTOR_SAMPLER_TYPE) {
const descriptorIndex = this._layout!.descriptorIndices[binding]; const descriptorIndex = this._layout!.descriptorIndices[binding];
if (this._samplers[descriptorIndex + index] !== sampler) { if (this._samplers[descriptorIndex + index] !== sampler) {
@@ -102,7 +102,7 @@ export abstract class DescriptorSet extends Obj {
*/ */
public bindTexture (binding: number, texture: Texture, index = 0) { public bindTexture (binding: number, texture: Texture, index = 0) {
const bindingIndex = this._layout!.bindingIndices[binding]; const bindingIndex = this._layout!.bindingIndices[binding];
const info = this._layout!.bindings[bindingIndex]; if (!info) return; const info = this._layout!.bindings[bindingIndex]; if (!info) { return; }
if (info.descriptorType & DESCRIPTOR_SAMPLER_TYPE) { if (info.descriptorType & DESCRIPTOR_SAMPLER_TYPE) {
const descriptorIndex = this._layout!.descriptorIndices[binding]; const descriptorIndex = this._layout!.descriptorIndices[binding];
if (this._textures[descriptorIndex + index] !== texture) { if (this._textures[descriptorIndex + index] !== texture) {
+36 -36
View File
@@ -4,11 +4,12 @@
*/ */
import { ccenum } from '../value-types/enum'; import { ccenum } from '../value-types/enum';
import { DescriptorSet, DescriptorSetInfo } from './descriptor-set'; import { gfx } from '../../../exports/base';
import { API, Feature, Filter, Format, MemoryStatus, SurfaceTransform } from './define';
import { Buffer, BufferInfo, BufferViewInfo } from './buffer'; import { Buffer, BufferInfo, BufferViewInfo } from './buffer';
import { CommandBuffer, CommandBufferInfo } from './command-buffer';
import { Filter, Format, MemoryStatus, API, Feature, SurfaceTransform } from './define';
import { BufferTextureCopy, Rect } from './define-class'; import { BufferTextureCopy, Rect } from './define-class';
import { CommandBuffer, CommandBufferInfo } from './command-buffer';
import { DescriptorSet, DescriptorSetInfo } from './descriptor-set';
import { Fence, FenceInfo } from './fence'; import { Fence, FenceInfo } from './fence';
import { Framebuffer, FramebufferInfo } from './framebuffer'; import { Framebuffer, FramebufferInfo } from './framebuffer';
import { InputAssembler, InputAssemblerInfo } from './input-assembler'; import { InputAssembler, InputAssemblerInfo } from './input-assembler';
@@ -18,12 +19,11 @@ import { RenderPass, RenderPassInfo } from './render-pass';
import { Sampler, SamplerInfo } from './sampler'; import { Sampler, SamplerInfo } from './sampler';
import { Shader, ShaderInfo } from './shader'; import { Shader, ShaderInfo } from './shader';
import { Texture, TextureInfo, TextureViewInfo } from './texture'; import { Texture, TextureInfo, TextureViewInfo } from './texture';
import { gfx } from '../../../exports/base';
ccenum(Format); ccenum(Format);
export class BindingMappingInfo { export class BindingMappingInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public bufferOffsets: number[] = [], public bufferOffsets: number[] = [],
@@ -33,7 +33,7 @@ export class BindingMappingInfo {
} }
export class DeviceInfo { export class DeviceInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public canvasElm: HTMLElement, public canvasElm: HTMLElement,
@@ -345,38 +345,38 @@ export abstract class Device {
protected _canvas: HTMLCanvasElement | null = null; protected _canvas: HTMLCanvasElement | null = null;
protected _canvas2D: HTMLCanvasElement | null = null; protected _canvas2D: HTMLCanvasElement | null = null;
protected _gfxAPI: API = API.UNKNOWN; protected _gfxAPI = API.UNKNOWN;
protected _transform: SurfaceTransform = SurfaceTransform.IDENTITY; protected _transform = SurfaceTransform.IDENTITY;
protected _deviceName: string = ''; protected _deviceName = '';
protected _renderer: string = ''; protected _renderer = '';
protected _vendor: string = ''; protected _vendor = '';
protected _version: string = ''; protected _version = '';
protected _features: boolean[] = new Array<boolean>(Feature.COUNT); protected _features = new Array<boolean>(Feature.COUNT);
protected _queue: Queue | null = null; protected _queue: Queue | null = null;
protected _cmdBuff: CommandBuffer | null = null; protected _cmdBuff: CommandBuffer | null = null;
protected _devicePixelRatio: number = 1.0; protected _devicePixelRatio = 1.0;
protected _width: number = 0; protected _width = 0;
protected _height: number = 0; protected _height = 0;
protected _nativeWidth: number = 0; protected _nativeWidth = 0;
protected _nativeHeight: number = 0; protected _nativeHeight = 0;
protected _maxVertexAttributes: number = 0; protected _maxVertexAttributes = 0;
protected _maxVertexUniformVectors: number = 0; protected _maxVertexUniformVectors = 0;
protected _maxFragmentUniformVectors: number = 0; protected _maxFragmentUniformVectors = 0;
protected _maxTextureUnits: number = 0; protected _maxTextureUnits = 0;
protected _maxVertexTextureUnits: number = 0; protected _maxVertexTextureUnits = 0;
protected _maxUniformBufferBindings: number = 0; protected _maxUniformBufferBindings = 0;
protected _maxUniformBlockSize: number = 0; protected _maxUniformBlockSize = 0;
protected _maxTextureSize: number = 0; protected _maxTextureSize = 0;
protected _maxCubeMapTextureSize: number = 0; protected _maxCubeMapTextureSize = 0;
protected _uboOffsetAlignment: number = 1; protected _uboOffsetAlignment = 1;
protected _depthBits: number = 0; protected _depthBits = 0;
protected _stencilBits: number = 0; protected _stencilBits = 0;
protected _colorFmt: Format = Format.UNKNOWN; protected _colorFmt = Format.UNKNOWN;
protected _depthStencilFmt: Format = Format.UNKNOWN; protected _depthStencilFmt = Format.UNKNOWN;
protected _macros: Map<string, string> = new Map(); protected _macros = new Map<string, string>();
protected _numDrawCalls: number = 0; protected _numDrawCalls = 0;
protected _numInstances: number = 0; protected _numInstances = 0;
protected _numTris: number = 0; protected _numTris = 0;
protected _memoryStatus = new MemoryStatus(); protected _memoryStatus = new MemoryStatus();
protected _clipSpaceMinZ = -1; protected _clipSpaceMinZ = -1;
protected _screenSpaceSignY = 1; protected _screenSpaceSignY = 1;
+3 -3
View File
@@ -3,14 +3,14 @@
* @module gfx * @module gfx
*/ */
import { Obj, ObjectType } from './define';
import { Device } from './device'; import { Device } from './device';
import { Obj, ObjectType } from './define';
export class FenceInfo { export class FenceInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
){} ) {}
} }
/** /**
+2 -2
View File
@@ -3,13 +3,13 @@
* @module gfx * @module gfx
*/ */
import { Obj, ObjectType } from './define';
import { Device } from './device'; import { Device } from './device';
import { RenderPass } from './render-pass'; import { RenderPass } from './render-pass';
import { Texture } from './texture'; import { Texture } from './texture';
import { Obj, ObjectType } from './define';
export class FramebufferInfo { export class FramebufferInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public renderPass: RenderPass, public renderPass: RenderPass,
+1 -1
View File
@@ -3,8 +3,8 @@
* @module gfx * @module gfx
*/ */
import { polyfillCC } from './polyfill-legacy-cc';
import { legacyCC } from '../global-exports'; import { legacyCC } from '../global-exports';
import { polyfillCC } from './polyfill-legacy-cc';
import './deprecated-3.0.0'; import './deprecated-3.0.0';
export * from './descriptor-set'; export * from './descriptor-set';
+15 -15
View File
@@ -4,9 +4,9 @@
*/ */
import { Buffer } from './buffer'; import { Buffer } from './buffer';
import { Format, Obj, ObjectType } from './define';
import { Device } from './device'; import { Device } from './device';
import { murmurhash2_32_gc } from '../utils/murmurhash2_gc'; import { murmurhash2_32_gc } from '../utils/murmurhash2_gc';
import { Format, Obj, ObjectType } from './define';
export interface IAttribute { export interface IAttribute {
name: string; name: string;
@@ -18,7 +18,7 @@ export interface IAttribute {
} }
export class Attribute { export class Attribute {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public name: string = '', public name: string = '',
@@ -31,7 +31,7 @@ export class Attribute {
} }
export class InputAssemblerInfo { export class InputAssemblerInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public attributes: Attribute[] = [], public attributes: Attribute[] = [],
@@ -179,21 +179,21 @@ export abstract class InputAssembler extends Obj {
protected _indexBuffer: Buffer | null = null; protected _indexBuffer: Buffer | null = null;
protected _vertexCount: number = 0; protected _vertexCount = 0;
protected _firstVertex: number = 0; protected _firstVertex = 0;
protected _indexCount: number = 0; protected _indexCount = 0;
protected _firstIndex: number = 0; protected _firstIndex = 0;
protected _vertexOffset: number = 0; protected _vertexOffset = 0;
protected _instanceCount: number = 0; protected _instanceCount = 0;
protected _firstInstance: number = 0; protected _firstInstance = 0;
protected _attributesHash: number = 0; protected _attributesHash = 0;
protected _indirectBuffer: Buffer | null = null; protected _indirectBuffer: Buffer | null = null;
@@ -202,15 +202,12 @@ export abstract class InputAssembler extends Obj {
this._device = device; this._device = device;
} }
public abstract initialize (info: InputAssemblerInfo): boolean;
public abstract destroy (): void;
/** /**
* @en Get the specified vertex buffer. * @en Get the specified vertex buffer.
* @zh 获取顶点缓冲。 * @zh 获取顶点缓冲。
* @param stream The stream index of the vertex buffer. * @param stream The stream index of the vertex buffer.
*/ */
public getVertexBuffer (stream: number = 0): Buffer | null { public getVertexBuffer (stream = 0): Buffer | null {
if (stream < this._vertexBuffers.length) { if (stream < this._vertexBuffers.length) {
return this._vertexBuffers[stream]; return this._vertexBuffers[stream];
} else { } else {
@@ -226,4 +223,7 @@ export abstract class InputAssembler extends Obj {
} }
return murmurhash2_32_gc(res, 666); return murmurhash2_32_gc(res, 666);
} }
public abstract initialize (info: InputAssemblerInfo): boolean;
public abstract destroy (): void;
} }
+3 -3
View File
@@ -3,12 +3,12 @@
* @module gfx * @module gfx
*/ */
import { Obj, ObjectType } from './define';
import { Device } from './device';
import { DescriptorSetLayout } from './descriptor-set-layout'; import { DescriptorSetLayout } from './descriptor-set-layout';
import { Device } from './device';
import { Obj, ObjectType } from './define';
export class PipelineLayoutInfo { export class PipelineLayoutInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public setLayouts: DescriptorSetLayout[] = [], public setLayouts: DescriptorSetLayout[] = [],
+11 -9
View File
@@ -2,6 +2,7 @@ declare const gfx: any;
declare type RecursivePartial<T> = { declare type RecursivePartial<T> = {
[P in keyof T]?: [P in keyof T]?:
T[P] extends Array<infer U> ? Array<RecursivePartial<U>> : T[P] extends Array<infer U> ? Array<RecursivePartial<U>> :
T[P] extends ReadonlyArray<infer V> ? ReadonlyArray<RecursivePartial<V>> : RecursivePartial<T[P]>; T[P] extends ReadonlyArray<infer V> ? ReadonlyArray<RecursivePartial<V>> : RecursivePartial<T[P]>;
}; };
@@ -17,8 +18,9 @@ import {
StencilOp, StencilOp,
} from './define'; } from './define';
import { Color } from './define-class'; import { Color } from './define-class';
import { BlendTargetArrayPool, NULL_HANDLE, BlendTargetArrayHandle, RasterizerStateHandle, RasterizerStatePool, RasterizerStateView, import { BlendTargetArrayPool, NULL_HANDLE, BlendTargetArrayHandle, RasterizerStateHandle, RasterizerStatePool, RasterizerStateView,
DepthStencilStateHandle, DepthStencilStatePool, DepthStencilStateView, BlendTargetHandle, BlendTargetPool, BlendTargetView, BlendStateHandle, BlendStatePool, BlendStateView } from '../renderer/core/memory-pools'; DepthStencilStateHandle, DepthStencilStatePool, DepthStencilStateView, BlendTargetHandle, BlendTargetPool, BlendTargetView,
BlendStateHandle, BlendStatePool, BlendStateView } from '../renderer/core/memory-pools';
export class RasterizerState { export class RasterizerState {
private h: RasterizerStateHandle; private h: RasterizerStateHandle;
@@ -58,9 +60,9 @@ export class RasterizerState {
else return false; else return false;
} }
set isFrontFaceCCW (val: boolean) { RasterizerStatePool.set(this.h, RasterizerStateView.IS_FRONT_FACE_CCW, val ? 1 : 0); } set isFrontFaceCCW (val: boolean) { RasterizerStatePool.set(this.h, RasterizerStateView.IS_FRONT_FACE_CCW, val ? 1 : 0); }
get depthBiasEnabled (): boolean { get depthBiasEnabled (): boolean {
if (RasterizerStatePool.get(this.h, RasterizerStateView.DEPTH_BIAS_ENABLED)) return true; if (RasterizerStatePool.get(this.h, RasterizerStateView.DEPTH_BIAS_ENABLED)) return true;
else return false; else return false;
} }
set depthBiasEnabled (val: boolean) { RasterizerStatePool.set(this.h, RasterizerStateView.DEPTH_BIAS_ENABLED, val ? 1 : 0); } set depthBiasEnabled (val: boolean) { RasterizerStatePool.set(this.h, RasterizerStateView.DEPTH_BIAS_ENABLED, val ? 1 : 0); }
get depthBias (): number { return RasterizerStatePool.get(this.h, RasterizerStateView.DEPTH_BIAS); } get depthBias (): number { return RasterizerStatePool.get(this.h, RasterizerStateView.DEPTH_BIAS); }
@@ -84,7 +86,7 @@ export class RasterizerState {
get handle (): RasterizerStateHandle { return this.h; } get handle (): RasterizerStateHandle { return this.h; }
public reset () { public reset () {
this.assignProperties(false, PolygonMode.FILL, ShadeModel.GOURAND, CullMode.BACK, true, 0, this.assignProperties(false, PolygonMode.FILL, ShadeModel.GOURAND, CullMode.BACK, true, false, 0,
0.0, 0.0, true, false, 1.0); 0.0, 0.0, true, false, 1.0);
} }
@@ -169,7 +171,7 @@ export class DepthStencilState {
if (DepthStencilStatePool.get(this.h, DepthStencilStateView.DEPTH_TEST)) return true; if (DepthStencilStatePool.get(this.h, DepthStencilStateView.DEPTH_TEST)) return true;
else return false; else return false;
} }
set depthTest(val: boolean) { DepthStencilStatePool.set(this.h, DepthStencilStateView.DEPTH_TEST, val ? 1 : 0); } set depthTest (val: boolean) { DepthStencilStatePool.set(this.h, DepthStencilStateView.DEPTH_TEST, val ? 1 : 0); }
get depthWrite (): boolean { get depthWrite (): boolean {
if (DepthStencilStatePool.get(this.h, DepthStencilStateView.DEPTH_WRITE)) return true; if (DepthStencilStatePool.get(this.h, DepthStencilStateView.DEPTH_WRITE)) return true;
else return false; else return false;
@@ -189,7 +191,7 @@ export class DepthStencilState {
get stencilWriteMaskFront (): number { return DepthStencilStatePool.get(this.h, DepthStencilStateView.STENCIL_WRITE_MASK_FRONT); } get stencilWriteMaskFront (): number { return DepthStencilStatePool.get(this.h, DepthStencilStateView.STENCIL_WRITE_MASK_FRONT); }
set stencilWriteMaskFront (val: number) { DepthStencilStatePool.set(this.h, DepthStencilStateView.STENCIL_WRITE_MASK_FRONT, val); } set stencilWriteMaskFront (val: number) { DepthStencilStatePool.set(this.h, DepthStencilStateView.STENCIL_WRITE_MASK_FRONT, val); }
get stencilFailOpFront (): StencilOp { return DepthStencilStatePool.get(this.h, DepthStencilStateView.STENCIL_FAIL_OP_FRONT); } get stencilFailOpFront (): StencilOp { return DepthStencilStatePool.get(this.h, DepthStencilStateView.STENCIL_FAIL_OP_FRONT); }
set stencilFailOpFront (val: StencilOp) { DepthStencilStatePool.set(this.h, DepthStencilStateView.STENCIL_FAIL_OP_FRONT, val); } set stencilFailOpFront (val: StencilOp) { DepthStencilStatePool.set(this.h, DepthStencilStateView.STENCIL_FAIL_OP_FRONT, val); }
get stencilZFailOpFront (): StencilOp { return DepthStencilStatePool.get(this.h, DepthStencilStateView.STENCIL_Z_FAIL_OP_FRONT); } get stencilZFailOpFront (): StencilOp { return DepthStencilStatePool.get(this.h, DepthStencilStateView.STENCIL_Z_FAIL_OP_FRONT); }
set stencilZFailOpFront (val: StencilOp) { DepthStencilStatePool.set(this.h, DepthStencilStateView.STENCIL_Z_FAIL_OP_FRONT, val); } set stencilZFailOpFront (val: StencilOp) { DepthStencilStatePool.set(this.h, DepthStencilStateView.STENCIL_Z_FAIL_OP_FRONT, val); }
get stencilPassOpFront (): StencilOp { return DepthStencilStatePool.get(this.h, DepthStencilStateView.STENCIL_PASS_OP_FRONT); } get stencilPassOpFront (): StencilOp { return DepthStencilStatePool.get(this.h, DepthStencilStateView.STENCIL_PASS_OP_FRONT); }
@@ -423,7 +425,7 @@ export class BlendState {
this.isIndepend = false; this.isIndepend = false;
BlendStatePool.setVec4(this.h, BlendStateView.BLEND_COLOR, new Color(0, 0, 0, 0)); BlendStatePool.setVec4(this.h, BlendStateView.BLEND_COLOR, new Color(0, 0, 0, 0));
let targets = this.targets; const targets = this.targets;
for (let i = 1, len = targets.length; i < len; ++i) { for (let i = 1, len = targets.length; i < len; ++i) {
targets[i].destroy(); targets[i].destroy();
} }
@@ -436,7 +438,7 @@ export class BlendState {
public destroy () { public destroy () {
BlendStatePool.free(this.h); BlendStatePool.free(this.h);
this.h = NULL_HANDLE; this.h = NULL_HANDLE;
BlendTargetArrayPool.free(this.hBt); BlendTargetArrayPool.free(this.hBt);
this.hBt = NULL_HANDLE; this.hBt = NULL_HANDLE;
+20 -17
View File
@@ -3,12 +3,19 @@
* @module gfx * @module gfx
*/ */
import { Attribute } from './input-assembler';
import { Color } from './define-class';
import { Device } from './device';
import { PipelineLayout } from './pipeline-layout';
import { RenderPass } from './render-pass';
import { Shader } from './shader';
import { import {
BlendFactor, BlendFactor,
BlendOp, BlendOp,
ColorMask, ColorMask,
ComparisonFunc, ComparisonFunc,
CullMode, CullMode,
DynamicStateFlagBit,
DynamicStateFlags, DynamicStateFlags,
Obj, Obj,
ObjectType, ObjectType,
@@ -16,14 +23,7 @@ import {
PrimitiveMode, PrimitiveMode,
ShadeModel, ShadeModel,
StencilOp, StencilOp,
DynamicStateFlagBit,
} from './define'; } from './define';
import { Color } from './define-class';
import { Device } from './device';
import { Attribute } from './input-assembler';
import { RenderPass } from './render-pass';
import { Shader } from './shader';
import { PipelineLayout } from './pipeline-layout';
import { NULL_HANDLE, RawBufferHandle } from '../renderer/core/memory-pools'; import { NULL_HANDLE, RawBufferHandle } from '../renderer/core/memory-pools';
/** /**
@@ -31,7 +31,7 @@ import { NULL_HANDLE, RawBufferHandle } from '../renderer/core/memory-pools';
* @zh GFX 光栅化状态。 * @zh GFX 光栅化状态。
*/ */
export class RasterizerState { export class RasterizerState {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public isDiscard: boolean = false, public isDiscard: boolean = false,
@@ -68,6 +68,7 @@ export class RasterizerState {
} }
get handle (): RawBufferHandle { return NULL_HANDLE; } get handle (): RawBufferHandle { return NULL_HANDLE; }
public destroy () {} public destroy () {}
} }
@@ -76,7 +77,7 @@ export class RasterizerState {
* @zh GFX 深度模板状态。 * @zh GFX 深度模板状态。
*/ */
export class DepthStencilState { export class DepthStencilState {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public depthTest: boolean = true, public depthTest: boolean = true,
@@ -127,6 +128,7 @@ export class DepthStencilState {
} }
get handle (): RawBufferHandle { return NULL_HANDLE; } get handle (): RawBufferHandle { return NULL_HANDLE; }
public destroy () {} public destroy () {}
} }
@@ -135,7 +137,7 @@ export class DepthStencilState {
* @zh GFX 混合目标。 * @zh GFX 混合目标。
*/ */
export class BlendTarget { export class BlendTarget {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public blend: boolean = false, public blend: boolean = false,
@@ -164,6 +166,7 @@ export class BlendTarget {
} }
get handle (): RawBufferHandle { return NULL_HANDLE; } get handle (): RawBufferHandle { return NULL_HANDLE; }
public destroy () {} public destroy () {}
} }
@@ -172,7 +175,7 @@ export class BlendTarget {
* @zh GFX 混合状态。 * @zh GFX 混合状态。
*/ */
export class BlendState { export class BlendState {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public isA2C: boolean = false, public isA2C: boolean = false,
@@ -209,6 +212,7 @@ export class BlendState {
} }
get handle (): RawBufferHandle { return NULL_HANDLE; } get handle (): RawBufferHandle { return NULL_HANDLE; }
public destroy () {} public destroy () {}
} }
@@ -217,7 +221,7 @@ export class BlendState {
* @zh GFX 输入状态。 * @zh GFX 输入状态。
*/ */
export class InputState { export class InputState {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public attributes: Attribute[] = [], public attributes: Attribute[] = [],
@@ -225,7 +229,7 @@ export class InputState {
} }
export class PipelineStateInfo { export class PipelineStateInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public shader: Shader, public shader: Shader,
@@ -245,7 +249,6 @@ export class PipelineStateInfo {
* @zh GFX 管线状态。 * @zh GFX 管线状态。
*/ */
export abstract class PipelineState extends Obj { export abstract class PipelineState extends Obj {
/** /**
* @en Get current shader. * @en Get current shader.
* @zh GFX 着色器。 * @zh GFX 着色器。
@@ -275,7 +278,7 @@ export abstract class PipelineState extends Obj {
* @zh GFX 光栅化状态。 * @zh GFX 光栅化状态。
*/ */
get rasterizerState (): RasterizerState { get rasterizerState (): RasterizerState {
return this._rs as RasterizerState; return this._rs as RasterizerState;
} }
/** /**
@@ -283,7 +286,7 @@ export abstract class PipelineState extends Obj {
* @zh GFX 深度模板状态。 * @zh GFX 深度模板状态。
*/ */
get depthStencilState (): DepthStencilState { get depthStencilState (): DepthStencilState {
return this._dss as DepthStencilState; return this._dss as DepthStencilState;
} }
/** /**
@@ -291,7 +294,7 @@ export abstract class PipelineState extends Obj {
* @zh GFX 混合状态。 * @zh GFX 混合状态。
*/ */
get blendState (): BlendState { get blendState (): BlendState {
return this._bs as BlendState; return this._bs as BlendState;
} }
/** /**
+16 -16
View File
@@ -13,20 +13,20 @@ import { RenderPass } from './render-pass';
import { Sampler } from './sampler'; import { Sampler } from './sampler';
import { Shader } from './shader'; import { Shader } from './shader';
import { Texture } from './texture'; import { Texture } from './texture';
import { FormatSize,FormatSurfaceSize,GetTypeSize,getTypedArrayConstructor,MAX_ATTACHMENTS, import { Address, AttributeName, BlendFactor, BlendOp, BufferAccessBit,
ObjectType,Obj,AttributeName,Type,Format,BufferUsageBit,MemoryUsageBit,BufferFlagBit, BufferFlagBit, BufferUsageBit, ClearFlag, ColorMask, CommandBufferType, ComparisonFunc, CullMode, DescriptorType,
BufferAccessBit,PrimitiveMode,PolygonMode,ShadeModel,CullMode,ComparisonFunc,StencilOp,BlendOp, DynamicStateFlagBit, Filter, Format, FormatInfo, FormatInfos, FormatSize, FormatSurfaceSize, FormatType,
BlendFactor,ColorMask,Filter,Address,TextureType,TextureUsageBit,SampleCount,TextureFlagBit,ShaderStageFlagBit, GetTypeSize, LoadOp, MAX_ATTACHMENTS, MemoryStatus, MemoryUsageBit, Obj, ObjectType, PipelineBindPoint, PolygonMode,
DescriptorType,CommandBufferType,LoadOp,StoreOp,TextureLayout,PipelineBindPoint,DynamicStateFlagBit,StencilFace, PrimitiveMode, QueueType, SampleCount, ShadeModel, ShaderStageFlagBit, StencilFace, StencilOp, StoreOp,
QueueType,ClearFlag,FormatType, TextureFlagBit, TextureLayout, TextureType,
FormatInfo,MemoryStatus,FormatInfos } from './define'; TextureUsageBit, Type, getTypedArrayConstructor } from './define';
import { Rect, Viewport, Color, Offset, Extent, TextureSubres, TextureCopy, BufferTextureCopy } from './define-class'; import { BufferTextureCopy, Color, Extent, Offset, Rect, TextureCopy, TextureSubres, Viewport } from './define-class';
export const polyfillCC = {Device,Buffer,Texture,Sampler,Shader,InputAssembler,RenderPass,Framebuffer,PipelineState,CommandBuffer,Queue, export const polyfillCC = { Device, Buffer, Texture, Sampler, Shader, InputAssembler, RenderPass, Framebuffer, PipelineState, CommandBuffer, Queue,
FormatSize,FormatSurfaceSize,GetTypeSize,getTypedArrayConstructor,MAX_ATTACHMENTS, FormatSize, FormatSurfaceSize, GetTypeSize, getTypedArrayConstructor, MAX_ATTACHMENTS,
ObjectType,Obj,AttributeName,Type,Format,BufferUsageBit,MemoryUsageBit,BufferFlagBit, ObjectType, Obj, AttributeName, Type, Format, BufferUsageBit, MemoryUsageBit, BufferFlagBit,
BufferAccessBit,PrimitiveMode,PolygonMode,ShadeModel,CullMode,ComparisonFunc,StencilOp,BlendOp, BufferAccessBit, PrimitiveMode, PolygonMode, ShadeModel, CullMode, ComparisonFunc, StencilOp, BlendOp,
BlendFactor,ColorMask,Filter,Address,TextureType,TextureUsageBit,SampleCount,TextureFlagBit,ShaderStageFlagBit, BlendFactor, ColorMask, Filter, Address, TextureType, TextureUsageBit, SampleCount, TextureFlagBit, ShaderStageFlagBit,
DescriptorType,CommandBufferType,LoadOp,StoreOp,TextureLayout,PipelineBindPoint,DynamicStateFlagBit,StencilFace, DescriptorType, CommandBufferType, LoadOp, StoreOp, TextureLayout, PipelineBindPoint, DynamicStateFlagBit, StencilFace,
QueueType,Rect,Viewport,Color,ClearFlag,Offset,Extent,TextureSubres,TextureCopy,BufferTextureCopy,FormatType, QueueType, Rect, Viewport, Color, ClearFlag, Offset, Extent, TextureSubres, TextureCopy, BufferTextureCopy, FormatType,
FormatInfo,MemoryStatus,FormatInfos}; FormatInfo, MemoryStatus, FormatInfos };
+4 -4
View File
@@ -4,12 +4,12 @@
*/ */
import { CommandBuffer } from './command-buffer'; import { CommandBuffer } from './command-buffer';
import { Obj, ObjectType, QueueType } from './define';
import { Device } from './device'; import { Device } from './device';
import { Fence } from './fence'; import { Fence } from './fence';
import { Obj, ObjectType, QueueType } from './define';
export class QueueInfo { export class QueueInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public type: QueueType = QueueType.GRAPHICS, public type: QueueType = QueueType.GRAPHICS,
@@ -41,12 +41,12 @@ export abstract class Queue extends Obj {
this._device = device; this._device = device;
} }
public isAsync () { return this._isAsync; }
public abstract initialize (info: QueueInfo): boolean; public abstract initialize (info: QueueInfo): boolean;
public abstract destroy (): void; public abstract destroy (): void;
public isAsync () { return this._isAsync; }
/** /**
* @en Submit command buffers. * @en Submit command buffers.
* @zh 提交命令缓冲数组。 * @zh 提交命令缓冲数组。
+12 -12
View File
@@ -3,6 +3,8 @@
* @module gfx * @module gfx
*/ */
import { Device } from './device';
import { murmurhash2_32_gc } from '../utils/murmurhash2_gc';
import { import {
Format, Format,
LoadOp, LoadOp,
@@ -12,15 +14,13 @@ import {
StoreOp, StoreOp,
TextureLayout, TextureLayout,
} from './define'; } from './define';
import { Device } from './device';
import { murmurhash2_32_gc } from '../utils/murmurhash2_gc';
/** /**
* @en Color attachment. * @en Color attachment.
* @zh GFX 颜色附件。 * @zh GFX 颜色附件。
*/ */
export class ColorAttachment { export class ColorAttachment {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public format: Format = Format.UNKNOWN, public format: Format = Format.UNKNOWN,
@@ -37,7 +37,7 @@ export class ColorAttachment {
* @zh GFX 深度模板附件。 * @zh GFX 深度模板附件。
*/ */
export class DepthStencilAttachment { export class DepthStencilAttachment {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public format: Format = Format.UNKNOWN, public format: Format = Format.UNKNOWN,
@@ -52,7 +52,7 @@ export class DepthStencilAttachment {
} }
export class SubPassInfo { export class SubPassInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public bindPoint: PipelineBindPoint = PipelineBindPoint.GRAPHICS, public bindPoint: PipelineBindPoint = PipelineBindPoint.GRAPHICS,
@@ -65,7 +65,7 @@ export class SubPassInfo {
} }
export class RenderPassInfo { export class RenderPassInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public colorAttachments: ColorAttachment[] = [], public colorAttachments: ColorAttachment[] = [],
@@ -86,9 +86,9 @@ export abstract class RenderPass extends Obj {
protected _depthStencilInfo: DepthStencilAttachment | null = null; protected _depthStencilInfo: DepthStencilAttachment | null = null;
protected _subPasses : SubPassInfo[] = []; protected _subPasses: SubPassInfo[] = [];
protected _hash: number = 0; protected _hash = 0;
get colorAttachments () { return this._colorInfos; } get colorAttachments () { return this._colorInfos; }
get depthStencilAttachment () { return this._depthStencilInfo; } get depthStencilAttachment () { return this._depthStencilInfo; }
@@ -100,10 +100,6 @@ export abstract class RenderPass extends Obj {
this._device = device; this._device = device;
} }
public abstract initialize (info: RenderPassInfo): boolean;
public abstract destroy (): void;
// Based on render pass compatibility // Based on render pass compatibility
protected computeHash (): number { protected computeHash (): number {
let res = ''; let res = '';
@@ -143,4 +139,8 @@ export abstract class RenderPass extends Obj {
return murmurhash2_32_gc(res, 666); return murmurhash2_32_gc(res, 666);
} }
public abstract initialize (info: RenderPassInfo): boolean;
public abstract destroy (): void;
} }
+6 -6
View File
@@ -3,12 +3,12 @@
* @module gfx * @module gfx
*/ */
import { Address, ComparisonFunc, Filter, Obj, ObjectType } from './define';
import { Color } from './define-class'; import { Color } from './define-class';
import { Device } from './device'; import { Device } from './device';
import { Address, ComparisonFunc, Filter, Obj, ObjectType } from './define';
export class SamplerInfo { export class SamplerInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public minFilter: Filter = Filter.LINEAR, public minFilter: Filter = Filter.LINEAR,
@@ -53,12 +53,12 @@ export abstract class Sampler extends Obj {
protected _addressU: Address = Address.WRAP; protected _addressU: Address = Address.WRAP;
protected _addressV: Address = Address.WRAP; protected _addressV: Address = Address.WRAP;
protected _addressW: Address = Address.WRAP; protected _addressW: Address = Address.WRAP;
protected _maxAnisotropy: number = 16; protected _maxAnisotropy = 16;
protected _cmpFunc: ComparisonFunc = ComparisonFunc.NEVER; protected _cmpFunc: ComparisonFunc = ComparisonFunc.NEVER;
protected _borderColor: Color = new Color(); protected _borderColor: Color = new Color();
protected _minLOD: number = 0; protected _minLOD = 0;
protected _maxLOD: number = 0; protected _maxLOD = 0;
protected _mipLODBias: number = 0.0; protected _mipLODBias = 0.0;
constructor (device: Device) { constructor (device: Device) {
super(ObjectType.SAMPLER); super(ObjectType.SAMPLER);
+9 -9
View File
@@ -3,9 +3,9 @@
* @module gfx * @module gfx
*/ */
import { Obj, ObjectType, ShaderStageFlagBit, Type } from './define';
import { Device } from './device';
import { Attribute } from './input-assembler'; import { Attribute } from './input-assembler';
import { Device } from './device';
import { Obj, ObjectType, ShaderStageFlagBit, Type } from './define';
export interface IShaderStage { export interface IShaderStage {
stage: ShaderStageFlagBit; stage: ShaderStageFlagBit;
@@ -13,7 +13,7 @@ export interface IShaderStage {
} }
export class ShaderStage implements IShaderStage { export class ShaderStage implements IShaderStage {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public stage: ShaderStageFlagBit = ShaderStageFlagBit.NONE, public stage: ShaderStageFlagBit = ShaderStageFlagBit.NONE,
@@ -32,7 +32,7 @@ export interface IUniform {
* @zh GFX uniform。 * @zh GFX uniform。
*/ */
export class Uniform implements IUniform { export class Uniform implements IUniform {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public name: string = '', public name: string = '',
@@ -46,7 +46,7 @@ export class Uniform implements IUniform {
* @zh GFX uniform 块。 * @zh GFX uniform 块。
*/ */
export class UniformBlock { export class UniformBlock {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public set: number = -1, public set: number = -1,
@@ -62,7 +62,7 @@ export class UniformBlock {
* @zh GFX Uniform 采样器。 * @zh GFX Uniform 采样器。
*/ */
export class UniformSampler { export class UniformSampler {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public set: number = -1, public set: number = -1,
@@ -74,7 +74,7 @@ export class UniformSampler {
} }
export class ShaderInfo { export class ShaderInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public name: string = '', public name: string = '',
@@ -90,7 +90,7 @@ export class ShaderInfo {
* @zh GFX 着色器。 * @zh GFX 着色器。
*/ */
export abstract class Shader extends Obj { export abstract class Shader extends Obj {
private static _shaderIdGen: number = 0; private static _shaderIdGen = 0;
/** /**
* @en Get current shader id. * @en Get current shader id.
@@ -124,7 +124,7 @@ export abstract class Shader extends Obj {
protected _id: number; protected _id: number;
protected _name: string = ''; protected _name = '';
protected _stages: ShaderStage[] = []; protected _stages: ShaderStage[] = [];
+11 -11
View File
@@ -3,6 +3,7 @@
* @module gfx * @module gfx
*/ */
import { Device } from './device';
import { import {
Format, Format,
Obj, Obj,
@@ -14,10 +15,9 @@ import {
TextureUsage, TextureUsage,
TextureUsageBit, TextureUsageBit,
} from './define'; } from './define';
import { Device } from './device';
export class TextureInfo { export class TextureInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public type: TextureType, public type: TextureType,
@@ -34,7 +34,7 @@ export class TextureInfo {
} }
export class TextureViewInfo { export class TextureViewInfo {
declare private token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
constructor ( constructor (
public texture: Texture, public texture: Texture,
@@ -47,7 +47,7 @@ export class TextureViewInfo {
) {} ) {}
} }
export function IsPowerOf2 (x: number): boolean{ export function IsPowerOf2 (x: number): boolean {
return x > 0 && (x & (x - 1)) === 0; return x > 0 && (x & (x - 1)) === 0;
} }
@@ -158,15 +158,15 @@ export abstract class Texture extends Obj {
protected _type: TextureType = TextureType.TEX2D; protected _type: TextureType = TextureType.TEX2D;
protected _usage: TextureUsage = TextureUsageBit.NONE; protected _usage: TextureUsage = TextureUsageBit.NONE;
protected _format: Format = Format.UNKNOWN; protected _format: Format = Format.UNKNOWN;
protected _width: number = 0; protected _width = 0;
protected _height: number = 0; protected _height = 0;
protected _depth: number = 1; protected _depth = 1;
protected _layerCount: number = 1; protected _layerCount = 1;
protected _levelCount: number = 1; protected _levelCount = 1;
protected _samples: SampleCount = SampleCount.X1; protected _samples: SampleCount = SampleCount.X1;
protected _flags: TextureFlags = TextureFlagBit.NONE; protected _flags: TextureFlags = TextureFlagBit.NONE;
protected _isPowerOf2: boolean = false; protected _isPowerOf2 = false;
protected _size: number = 0; protected _size = 0;
protected _buffer: ArrayBuffer | null = null; protected _buffer: ArrayBuffer | null = null;
constructor (device: Device) { constructor (device: Device) {
+3 -3
View File
@@ -48,7 +48,7 @@ export class WebGLCommandBuffer extends CommandBuffer {
public cmdPackage: WebGLCmdPackage = new WebGLCmdPackage(); public cmdPackage: WebGLCmdPackage = new WebGLCmdPackage();
protected _webGLAllocator: WebGLCommandAllocator | null = null; protected _webGLAllocator: WebGLCommandAllocator | null = null;
protected _isInRenderPass: boolean = false; protected _isInRenderPass = false;
protected _curGPUPipelineState: IWebGLGPUPipelineState | null = null; protected _curGPUPipelineState: IWebGLGPUPipelineState | null = null;
protected _curGPUInputAssembler: IWebGLGPUInputAssembler | null = null; protected _curGPUInputAssembler: IWebGLGPUInputAssembler | null = null;
protected _curGPUDescriptorSets: IWebGLGPUDescriptorSet[] = []; protected _curGPUDescriptorSets: IWebGLGPUDescriptorSet[] = [];
@@ -61,7 +61,7 @@ export class WebGLCommandBuffer extends CommandBuffer {
protected _curDepthBounds: IWebGLDepthBounds | null = null; protected _curDepthBounds: IWebGLDepthBounds | null = null;
protected _curStencilWriteMask: IWebGLStencilWriteMask | null = null; protected _curStencilWriteMask: IWebGLStencilWriteMask | null = null;
protected _curStencilCompareMask: IWebGLStencilCompareMask | null = null; protected _curStencilCompareMask: IWebGLStencilCompareMask | null = null;
protected _isStateInvalied: boolean = false; protected _isStateInvalied = false;
public initialize (info: CommandBufferInfo): boolean { public initialize (info: CommandBufferInfo): boolean {
@@ -409,7 +409,7 @@ export class WebGLCommandBuffer extends CommandBuffer {
} }
} }
// tslint:disable: max-line-length
public execute (cmdBuffs: CommandBuffer[], count: number) { public execute (cmdBuffs: CommandBuffer[], count: number) {
for (let i = 0; i < count; ++i) { for (let i = 0; i < count; ++i) {
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -359,7 +359,7 @@ export class WebGLDevice extends Device {
// earlier runtime VAO implementations doesn't work // earlier runtime VAO implementations doesn't work
if (RUNTIME_BASED && !VIVO) { if (RUNTIME_BASED && !VIVO) {
// @ts-ignore // @ts-expect-error
if (typeof loadRuntime !== 'function' || !loadRuntime() || typeof loadRuntime().getFeature !== 'function' || loadRuntime() if (typeof loadRuntime !== 'function' || !loadRuntime() || typeof loadRuntime().getFeature !== 'function' || loadRuntime()
.getFeature('webgl.extensions.oes_vertex_array_object.revision') <= 0) { .getFeature('webgl.extensions.oes_vertex_array_object.revision') <= 0) {
this._OES_vertex_array_object = null; this._OES_vertex_array_object = null;
File diff suppressed because it is too large Load Diff
-1
View File
@@ -50,7 +50,6 @@ import {
VIVO, VIVO,
} from 'internal:constants'; } from 'internal:constants';
// @ts-ignore
const _global = typeof window === 'undefined' ? global : window; const _global = typeof window === 'undefined' ? global : window;
/** /**
+4 -4
View File
@@ -314,7 +314,7 @@ export class Color extends ValueType {
* @zh 用十六进制颜色字符串中构造颜色。 * @zh 用十六进制颜色字符串中构造颜色。
* @param hexString Hexadecimal color string. * @param hexString Hexadecimal color string.
*/ */
// tslint:disable-next-line: unified-signatures
constructor (hexString: string); constructor (hexString: string);
/** /**
@@ -466,8 +466,8 @@ export class Color extends ValueType {
(this.g < 16 ? prefix : '') + (this.g).toString(16), (this.g < 16 ? prefix : '') + (this.g).toString(16),
(this.b < 16 ? prefix : '') + (this.b).toString(16), (this.b < 16 ? prefix : '') + (this.b).toString(16),
]; ];
let i = -1; const i = -1;
if ( fmt === '#rgb' ) { if (fmt === '#rgb') {
hex[0] = hex[0][0]; hex[0] = hex[0][0];
hex[1] = hex[1][0]; hex[1] = hex[1][0];
hex[2] = hex[2][0]; hex[2] = hex[2][0];
@@ -617,7 +617,7 @@ export class Color extends ValueType {
*/ */
public set(other: Color): Color; public set(other: Color): Color;
public set(r?: number, g?: number, b?: number, a?: number): Color; public set(r?: number, g?: number, b?: number, a?: number): Color;
public set(r?: number | Color, g?: number, b?: number, a?: number): Color { public set (r?: number | Color, g?: number, b?: number, a?: number): Color {
if (typeof r === 'object') { if (typeof r === 'object') {
if (r._val != null) { if (r._val != null) {
this._val = r._val; this._val = r._val;
+7 -7
View File
@@ -40,7 +40,7 @@ import { legacyCC } from '../global-exports';
* @en Mathematical 3x3 matrix. * @en Mathematical 3x3 matrix.
* @zh 表示三维(3x3)矩阵。 * @zh 表示三维(3x3)矩阵。
*/ */
// tslint:disable:one-variable-per-declaration
export class Mat3 extends ValueType { export class Mat3 extends ValueType {
public static IDENTITY = Object.freeze(new Mat3()); public static IDENTITY = Object.freeze(new Mat3());
@@ -692,9 +692,9 @@ export class Mat3 extends ValueType {
m06?: number, m07?: number, m08?: number); m06?: number, m07?: number, m08?: number);
constructor ( constructor (
m00: number | Mat3 = 1, m01: number = 0, m02: number = 0, m00: number | Mat3 = 1, m01 = 0, m02 = 0,
m03: number = 0, m04: number = 1, m05: number = 0, m03 = 0, m04 = 1, m05 = 0,
m06: number = 0, m07: number = 0, m08: number = 1 ) { m06 = 0, m07 = 0, m08 = 1) {
super(); super();
if (typeof m00 === 'object') { if (typeof m00 === 'object') {
this.m00 = m00.m00; this.m01 = m00.m01; this.m02 = m00.m02; this.m00 = m00.m00; this.m01 = m00.m01; this.m02 = m00.m02;
@@ -736,9 +736,9 @@ export class Mat3 extends ValueType {
m03?: number, m04?: number, m05?: number, m03?: number, m04?: number, m05?: number,
m06?: number, m07?: number, m08?: number); m06?: number, m07?: number, m08?: number);
public set (m00: number | Mat3 = 1, m01: number = 0, m02: number = 0, public set (m00: number | Mat3 = 1, m01 = 0, m02 = 0,
m03: number = 0, m04: number = 1, m05: number = 0, m03 = 0, m04 = 1, m05 = 0,
m06: number = 0, m07: number = 0, m08: number = 1 ) { m06 = 0, m07 = 0, m08 = 1) {
if (typeof m00 === 'object') { if (typeof m00 === 'object') {
this.m00 = m00.m00; this.m01 = m00.m01; this.m02 = m00.m02; this.m00 = m00.m00; this.m01 = m00.m01; this.m02 = m00.m02;
this.m03 = m00.m03; this.m04 = m00.m04; this.m05 = m00.m05; this.m03 = m00.m03; this.m04 = m00.m04; this.m05 = m00.m05;

Some files were not shown because too many files have changed in this diff Show More