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
-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": [
"javascript",
"typescript"
]
],
"editor.codeActionsOnSave": {
"source.fixAll": true,
},
}
+3 -2
View File
@@ -25,6 +25,7 @@
*/
declare const gfx: any;
declare const global: any;
interface Window {
@@ -62,7 +63,7 @@ interface HTMLElement{
}
type ActiveXObject = new (s: string) => any;
declare var ActiveXObject: ActiveXObject;
declare const ActiveXObject: ActiveXObject;
declare type CompareFunction<T> = (a: T, b: T) => number;
@@ -81,7 +82,7 @@ declare interface IWritableArrayLike<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] };
+10 -4
View File
@@ -28,8 +28,10 @@
* @module component/audio
*/
import {
ccclass, type, serializable, override,
} from 'cc.decorator';
import { Asset } from '../../core/assets/asset';
import { ccclass, type, serializable, override } from 'cc.decorator';
import { Enum } from '../../core/value-types';
import { AudioPlayer, PlayingState } from './player';
import { AudioPlayerDOM } from './player-dom';
@@ -57,7 +59,6 @@ export const AudioType = Enum({
*/
@ccclass('cc.AudioClip')
export class AudioClip extends Asset {
public static PlayingState = PlayingState;
public static AudioType = AudioType;
public static preventDeferredLoadDependents = true;
@@ -102,7 +103,12 @@ export class AudioClip extends Asset {
@override
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 () {
@@ -126,7 +132,7 @@ export class AudioClip extends Asset {
public getLoop () { if (this._player) { return this._player.getLoop(); } return false; }
private _getPlayer (clip: any) {
let ctor: any;
let ctor: Constructor<AudioPlayer>;
if (typeof AudioBuffer !== 'undefined' && clip instanceof AudioBuffer) {
ctor = AudioPlayerWeb;
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);
}
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 pause (): void;
public abstract stop (): void;
@@ -80,12 +87,6 @@ export abstract class AudioPlayer {
public abstract getVolume (): number;
public abstract setLoop (val: boolean): void;
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;
+6 -5
View File
@@ -44,13 +44,13 @@ export function downloadDomAudio (
url: string,
options: IDownloadParseOptions,
onComplete: CompleteCallback<HTMLAudioElement>
): void {
): void {
createDomAudio(url).then(dom => {
onComplete(null, dom);
}, errMsg => {
log(errMsg);
onComplete(new Error(errMsg), null);
log(errMsg);
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) {
if (formatSupport.length === 0) {
return onComplete(new Error(getError(4927)));
onComplete(new Error(getError(4927)));
return;
}
let handler: DownloadHandler | null = null;
if (!__audioSupport.WEB_AUDIO) {
@@ -77,4 +78,4 @@ export function downloadAudio (url: string, options: IDownloadParseOptions, onCo
}
}
handler(url, options, onComplete);
};
}
+4 -3
View File
@@ -1,7 +1,8 @@
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) => {
const dom = document.createElement('audio');
dom.src = url;
@@ -27,7 +28,7 @@ export function createDomAudio (url): Promise<HTMLAudioElement> {
};
const failure = () => {
clearEvent();
const message = 'load audio failure - ' + url;
const message = `load audio failure - ${url}`;
reject(message);
};
dom.addEventListener('canplaythrough', success, false);
+1 -1
View File
@@ -1,4 +1,4 @@
// tslint:disable
// absolute essential effects
export default [
{
@@ -1,4 +1,4 @@
// tslint:disable
export default [
[
{
@@ -1,4 +1,4 @@
// tslint:disable
export default [
[
{
@@ -1,4 +1,4 @@
// tslint:disable
export default [
[
{
+2 -2
View File
@@ -67,7 +67,7 @@ const ClearFlag = Enum({
DONT_CLEAR: GFXClearFlag.NONE,
});
// tslint:disable: no-shadowed-variable
export declare namespace Camera {
export type ProjectionType = EnumAlias<typeof ProjectionType>;
export type FOVAxis = EnumAlias<typeof FOVAxis>;
@@ -76,7 +76,7 @@ export declare namespace Camera {
export type Shutter = EnumAlias<typeof Shutter>;
export type ISO = EnumAlias<typeof ISO>;
}
// tslint:enable: no-shadowed-variable
/**
* @en The Camera Component.
+2 -2
View File
@@ -94,12 +94,12 @@ class StaticLightSettings {
}
}
// tslint:disable: no-shadowed-variable
export declare namespace Light {
export type Type = EnumAlias<typeof scene.LightType>;
export type PhotometricTerm = EnumAlias<typeof PhotometricTerm>;
}
// tslint:enable: no-shadowed-variable
@ccclass('cc.Light')
export class Light extends Component {
+2 -2
View File
@@ -371,7 +371,7 @@ export class MeshRenderer extends RenderableComponent {
return;
}
const renderScene = this._getRenderScene();
if (this._model.scene != null) {
if (this._model.scene !== null) {
this._detachFromScene();
}
renderScene.addModel(this._model);
@@ -414,7 +414,7 @@ export class MeshRenderer extends RenderableComponent {
this.lightmapSettings.uvParam.x,
this.lightmapSettings.uvParam.y,
this.lightmapSettings.uvParam.z,
this.lightmapSettings.uvParam.w
this.lightmapSettings.uvParam.w,
]);
}
@@ -4,9 +4,11 @@
*/
import { EDITOR } from 'internal:constants';
import {
ccclass, type, displayOrder, displayName, serializable,
} from 'cc.decorator';
import { Material } from '../../assets/material';
import { Component } from '../../components/component';
import { ccclass, type, displayOrder, displayName, serializable } from 'cc.decorator';
import { IMaterialInstanceInfo, MaterialInstance } from '../../renderer/core/material-instance';
import { scene } from '../../renderer';
import { Layers } from '../../scene-graph/layers';
@@ -40,7 +42,7 @@ export class RenderableComponent extends Component {
@displayName('Materials')
get sharedMaterials () {
// 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) {
@@ -79,7 +81,8 @@ export class RenderableComponent extends Component {
}
}
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]) {
this.setMaterialInstance(i, val[i]);
}
@@ -87,6 +90,7 @@ export class RenderableComponent extends Component {
}
protected _materialInstances: (MaterialInstance | null)[] = [];
protected _models: scene.Model[] = [];
get sharedMaterial () {
@@ -166,10 +170,8 @@ export class RenderableComponent extends Component {
this._materialInstances[index] = matInst as MaterialInstance;
this._onMaterialModified(index, matInst);
}
} else {
if (matInst !== this._materials[index]) {
this.setMaterial(matInst as Material, index);
}
} else if (matInst !== this._materials[index]) {
this.setMaterial(matInst as Material, index);
}
}
@@ -28,15 +28,19 @@
*/
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 { Filter, PixelFormat } from '../../assets/asset-enum';
import { Material } from '../../assets/material';
import { Mesh } from '../../assets/mesh';
import { Skeleton } from '../../assets/skeleton';
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 { AttributeName, FormatInfos, Format, Type } from '../../gfx/define';
import {
AttributeName, FormatInfos, Format, Type,
} from '../../gfx/define';
import { Device, Attribute, BufferTextureCopy } from '../../gfx';
import { Mat4, Vec2, Vec3 } from '../../math';
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')
export class SkinnedMeshUnit {
/**
* @en Skinned mesh of this unit.
* @zh 子蒙皮模型的网格模型。
@@ -74,8 +77,10 @@ export class SkinnedMeshUnit {
@serializable
public _localTransform = new Mat4();
@serializable
private _offset = new Vec2(0, 0);
@serializable
private _size = new Vec2(1, 1);
@@ -87,6 +92,7 @@ export class SkinnedMeshUnit {
set offset (offset) {
Vec2.copy(this._offset, offset);
}
get offset () {
return this._offset;
}
@@ -99,6 +105,7 @@ export class SkinnedMeshUnit {
set size (size) {
Vec2.copy(this._size, size);
}
get size () {
return this._size;
}
@@ -115,6 +122,7 @@ export class SkinnedMeshUnit {
this.material = comp.getMaterial(0);
if (comp.skinningRoot) { getWorldTransformUntilRoot(comp.node, comp.skinningRoot, this._localTransform); }
}
get copyFrom () {
return null;
}
@@ -134,14 +142,13 @@ const v3_1 = new Vec3();
@executeInEditMode
@menu('Components/SkinnedMeshBatchRenderer')
export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
/**
* @en Size of the generated texture atlas.
* @zh 合图生成的最终图集的边长。
*/
@serializable
@tooltip('i18n:batched_skinning_model.atlas_size')
public atlasSize: number = 1024;
public atlasSize = 1024;
/**
* @en
@@ -165,6 +172,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
public units: SkinnedMeshUnit[] = [];
private _textures: Record<string, Texture2D> = {};
private _batchMaterial: Material | null = null;
@override
@@ -172,6 +180,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
get mesh () {
return super.mesh;
}
set mesh (val) {
super.mesh = val;
}
@@ -181,6 +190,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
get skeleton () {
return super.skeleton;
}
set skeleton (val) {
super.skeleton = val;
}
@@ -328,9 +338,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
for (let i = 0; i < unitLen; i++) {
const unit = this.units[i];
if (!unit || !unit.skeleton) { continue; }
jointIndexMap[i] = unit.skeleton.joints.map((j) => {
return this._skeleton!.joints.findIndex((ref) => j === ref);
});
jointIndexMap[i] = unit.skeleton.joints.map((j) => this._skeleton!.joints.findIndex((ref) => j === ref));
}
for (let i = 0; i < unitLen; i++) {
@@ -339,8 +347,8 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
const newMesh = this._createUnitMesh(i, unit.mesh);
const dataView = new DataView(newMesh.data.buffer);
Mat4.inverseTranspose(m4_local, unit._localTransform);
const offset = unit.offset;
const size = unit.size;
const { offset } = unit;
const { size } = unit;
for (let b = 0; b < newMesh.struct.vertexBundles.length; b++) {
const bundle = newMesh.struct.vertexBundles[b];
// 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);
}
}
this._mesh!.merge(newMesh);
this._mesh.merge(newMesh);
}
this._onMeshChanged(this._mesh);
@@ -458,7 +466,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
region.texOffset.y = unit.offset.y * this.atlasSize;
region.texExtent.width = unit.size.x * this.atlasSize;
region.texExtent.height = unit.size.y * this.atlasSize;
const data = partial.image.data;
const { data } = partial.image;
if (!ArrayBuffer.isView(data)) {
texImages.push(data);
texImageRegions.push(region);
@@ -469,7 +477,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
}
}
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 (texImages.length > 0) { device.copyTexImagesToTexture(texImages, gfxTex, texImageRegions); }
}
@@ -524,7 +532,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
if (uvFormat) { break; }
}
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
newBundle.attributes.push(batch_id);
newBundle.attributes.push(batch_uv);
@@ -548,11 +556,11 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
const oldMeshData = mesh.data;
const newDataView = new DataView(newMeshData.buffer);
const oldDataView = new DataView(oldMeshData.buffer);
const isLittleEndian = legacyCC.sys.isLittleEndian;
const { isLittleEndian } = legacyCC.sys;
for (const b in modifiedBundles) {
const newBundle = newMeshStruct.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 oldView = oldBundle.view;
const newView = newBundle.view;
@@ -564,7 +572,7 @@ export class SkinnedMeshBatchRenderer extends SkinnedMeshRenderer {
const srcVertex = oldMeshData.subarray(oldOffset, oldOffset + oldStride);
newMeshData.set(srcVertex, newOffset);
// insert batch ID
newDataView.setFloat32(newOffset + oldStride, unitIdx, );
newDataView.setFloat32(newOffset + oldStride, unitIdx);
// insert batch UV
newDataView.setFloat32(newOffset + oldStride + 4, uvs[j * 2], isLittleEndian);
newDataView.setFloat32(newOffset + oldStride + 8, uvs[j * 2 + 1], isLittleEndian);
@@ -28,10 +28,12 @@
* @module model
*/
import {
ccclass, executeInEditMode, executionOrder, help, menu, tooltip, type,
} from 'cc.decorator';
import { AnimationClip } from '../../animation/animation-clip';
import { Material } from '../../assets';
import { Skeleton } from '../../assets/skeleton';
import { ccclass, executeInEditMode, executionOrder, help, menu, tooltip, type } from 'cc.decorator';
import { models } from '../../renderer';
import { Node } from '../../scene-graph/node';
import { MeshRenderer } from './mesh-renderer';
@@ -48,7 +50,6 @@ import { legacyCC } from '../../global-exports';
@executeInEditMode
@menu('Components/SkinnedMeshRenderer')
export class SkinnedMeshRenderer extends MeshRenderer {
@type(Skeleton)
protected _skeleton: Skeleton | null = null;
@@ -28,7 +28,9 @@
* @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 { scene } from '../../renderer';
import { Light, PhotometricTerm } from './light-component';
@@ -38,19 +40,23 @@ import { Light, PhotometricTerm } from './light-component';
@menu('Light/SpotLight')
@executeInEditMode
export class SpotLight extends Light {
@serializable
protected _size = 0.15;
@serializable
protected _luminance = 1700 / scene.nt2lm(0.15);
@serializable
protected _term = PhotometricTerm.LUMINOUS_POWER;
@serializable
protected _range = 1;
@serializable
protected _spotAngle = 60;
protected _type = scene.LightType.SPOT;
protected _light: scene.SpotLight | null = null;
/**
@@ -62,6 +68,7 @@ export class SpotLight extends Light {
get luminousPower () {
return this._luminance * scene.nt2lm(this._size);
}
set luminousPower (val) {
this._luminance = val / scene.nt2lm(this._size);
if (this._light) { this._light.luminance = this._luminance; }
@@ -76,6 +83,7 @@ export class SpotLight extends Light {
get luminance () {
return this._luminance;
}
set luminance (val) {
this._luminance = val;
if (this._light) { this._light.luminance = val; }
@@ -90,6 +98,7 @@ export class SpotLight extends Light {
get term () {
return this._term;
}
set term (val) {
this._term = val;
}
@@ -104,6 +113,7 @@ export class SpotLight extends Light {
get size () {
return this._size;
}
set size (val) {
this._size = val;
if (this._light) { this._light.size = val; }
@@ -119,6 +129,7 @@ export class SpotLight extends Light {
get range () {
return this._range;
}
set range (val) {
this._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) {
// tslint:disable-next-line:forin
for (const name in this._nameToState) {
const state = this._nameToState[name];
if (equalClips(clip, state.clip)) {
+1 -1
View File
@@ -342,7 +342,7 @@ const selectLerpFx = (() => {
function makeValueTypeLerpFx<T extends ValueType> (constructor: Constructor<T>) {
const tempValue = new constructor();
return (from: T, to: T, ratio: number) => {
// @ts-ignore
// @ts-expect-error
constructor.lerp(tempValue, from, to, ratio);
return tempValue;
};
+1 -1
View File
@@ -72,7 +72,7 @@ function makeCubicSplineValueConstructor<T> (
}
}
// @ts-ignore TS2367
// @ts-expect-error TS2367
if (constructorX === Quat) {
const lerp = CubicSplineValueClass.prototype.lerp;
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 { bezier } from './bezier';
// tslint:disable:no-shadowed-variable
export class Curve {
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) => {
if (Array.isArray(value)) {
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;
// @ts-ignore
// @ts-expect-error
const ratios = (data.ratioSampler ? data.ratioSampler.ratios : []);
// @ts-ignore
// @ts-expect-error
const newValues: CurveValue[] = data.values = [];
const newTypes: any[] = data.types = [];
// @ts-ignore
// @ts-expect-error
const newRatios: number[] = data.ratios = [];
function addNewDatas (value: CurveValue, type: any, ratio: number) {
@@ -28,7 +28,9 @@
* @module animation
*/
import { clamp01, Mat4, Quat, Vec3 } from '../math';
import {
clamp01, Mat4, Quat, Vec3,
} from '../math';
import { DataPoolManager } from '../renderer/data-pool-manager';
import { AnimationClip, IObjectCurveData } from './animation-clip';
import { HierarchyPath, isCustomPath, isPropertyPath } from './target-path';
@@ -54,7 +56,6 @@ interface IConvertedData {
* 骨骼动画数据转换中心。
*/
export class SkelAnimDataHub {
public static getOrExtract (clip: AnimationClip) {
let data = SkelAnimDataHub.pool.get(clip);
if (!data || data.info.sample !== clip.sample) {
@@ -76,10 +77,10 @@ export class SkelAnimDataHub {
function convertToSkeletalCurves (clip: AnimationClip): IConvertedData {
const data: Record<string, ConvertedProps> = {};
clip.curves.forEach((curve) => {
if (!curve.valueAdapter &&
isCustomPath(curve.modifiers[0], HierarchyPath) &&
isPropertyPath(curve.modifiers[1])) {
const path = (curve.modifiers[0] as HierarchyPath).path;
if (!curve.valueAdapter
&& isCustomPath(curve.modifiers[0], HierarchyPath)
&& isPropertyPath(curve.modifiers[1])) {
const { path } = curve.modifiers[0];
let cs = data[path];
if (!cs) { cs = data[path] = {}; }
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++) {
let time = i / clip.sample;
while (keys[idx] <= time) { idx++; }
if (idx > keys.length - 1) { idx = keys.length - 1; time = keys[idx]; }
else if (idx === 0) { idx = 1; }
if (idx > keys.length - 1) { idx = keys.length - 1; time = keys[idx]; } else if (idx === 0) { idx = 1; }
const from = curve.values[idx - 1].clone();
const denom = keys[idx] - keys[idx - 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);
}
values[i] = from;
}
}
}
curve.values = values;
}
@@ -55,14 +55,20 @@ interface ISocketData {
const noCurves: IRuntimeCurve[] = [];
export class SkeletalAnimationState extends AnimationState {
protected _frames = 1;
protected _bakedDuration = 0;
protected _animInfo: IAnimInfo | null = null;
protected _sockets: ISocketData[] = [];
protected _animInfoMgr: JointAnimationInfo;
protected _comps: SkinnedMeshRenderer[] = [];
protected _parent: SkeletalAnimation | null = null;
protected _curvesInited = false;
constructor (clip: AnimationClip, name = '') {
@@ -84,7 +90,7 @@ export class SkeletalAnimationState extends AnimationState {
const baked = this._parent.useBakedAnimation;
super.initialize(root, baked ? noCurves : undefined);
this._curvesInited = !baked;
const info = SkelAnimDataHub.getOrExtract(this.clip).info;
const { info } = SkelAnimDataHub.getOrExtract(this.clip);
this._frames = info.frames - 1;
this._animInfo = this._animInfoMgr.getData(root.uuid);
this._bakedDuration = this._frames / info.sample; // last key
@@ -113,7 +119,7 @@ export class SkeletalAnimationState extends AnimationState {
public rebuildSocketCurves (sockets: Socket[]) {
this._sockets.length = 0;
if (!this._targetNode) { return null; }
if (!this._targetNode) { return; }
const root = this._targetNode;
for (let i = 0; i < sockets.length; ++i) {
const socket = sockets[i];
@@ -137,7 +143,7 @@ export class SkeletalAnimationState extends AnimationState {
if (idx < 0) { break; }
}
const curveData: Mat4[] | undefined = source && source.worldMatrix.values as Mat4[];
const frames = clipData.info.frames;
const { frames } = clipData.info;
const transforms: ITransform[] = [];
for (let f = 0; f < frames; f++) {
let mat: Mat4;
+14 -9
View File
@@ -28,8 +28,10 @@
* @module animation
*/
import {
ccclass, executeInEditMode, executionOrder, help, menu, tooltip, type, serializable, editable,
} from 'cc.decorator';
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 { DataPoolManager } from '../renderer/data-pool-manager';
import { Node } from '../scene-graph/node';
@@ -44,14 +46,13 @@ import { js } from '../utils/js';
@ccclass('cc.SkeletalAnimation.Socket')
export class Socket {
/**
* @en Path of the target joint.
* @zh 此挂点的目标骨骼路径。
*/
@serializable
@editable
public path: string = '';
public path = '';
/**
* @en Transform output node.
@@ -99,7 +100,6 @@ function collectRecursively (node: Node, prefix = '', out: string[] = []) {
@executeInEditMode
@menu('Components/SkeletalAnimation')
export class SkeletalAnimation extends Animation {
public static Socket = Socket;
/**
@@ -114,6 +114,7 @@ export class SkeletalAnimation extends Animation {
get sockets () {
return this._sockets;
}
set sockets (val) {
if (!this._useBakedAnimation) {
const animMgr = legacyCC.director.getAnimationManager() as AnimationManager;
@@ -137,6 +138,7 @@ export class SkeletalAnimation extends Animation {
get useBakedAnimation () {
return this._useBakedAnimation;
}
set useBakedAnimation (val) {
this._useBakedAnimation = val;
const comps = this.node.getComponentsInChildren(SkinnedMeshRenderer);
@@ -146,8 +148,11 @@ export class SkeletalAnimation extends Animation {
comp.setUseBakedAnimation(this._useBakedAnimation);
}
}
if (this._useBakedAnimation) { (legacyCC.director.getAnimationManager() as AnimationManager).removeSockets(this.node, this._sockets); }
else { (legacyCC.director.getAnimationManager() as AnimationManager).addSockets(this.node, this._sockets); }
if (this._useBakedAnimation) {
(legacyCC.director.getAnimationManager() as AnimationManager).removeSockets(this.node, this._sockets);
} else {
(legacyCC.director.getAnimationManager() as AnimationManager).addSockets(this.node, this._sockets);
}
}
@serializable
@@ -169,8 +174,8 @@ export class SkeletalAnimation extends Animation {
}
public querySockets () {
const animPaths = this._defaultClip && Object.keys(SkelAnimDataHub.getOrExtract(this._defaultClip).data).sort().reduce((acc, cur) =>
cur.startsWith(acc[acc.length - 1]) ? acc : (acc.push(cur), acc), [] as string[]) || [];
const animPaths = (this._defaultClip && Object.keys(SkelAnimDataHub.getOrExtract(this._defaultClip).data).sort()
.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']; }
const out: string[] = [];
for (let i = 0; i < animPaths.length; i++) {
@@ -186,7 +191,7 @@ export class SkeletalAnimation extends Animation {
public rebuildSocketAnimations () {
for (const socket of this._sockets) {
const joint = this.node.getChildByPath(socket.path);
const target = socket.target;
const { target } = socket;
if (joint && target) {
target.name = `${socket.path.substring(socket.path.lastIndexOf('/') + 1)} Socket`;
target.parent = this.node;
+3 -3
View File
@@ -520,7 +520,7 @@ export class AssetManager {
public postLoadNative (asset: Asset, options?: INativeAssetOptions | CompleteCallbackNoData | null, onComplete?: CompleteCallbackNoData | null) {
const { options: opts, onComplete: onComp } = parseParameters(options, undefined, onComplete);
// @ts-ignore
// @ts-expect-error
if (!asset._native || !asset.__nativeDepend__) {
return asyncify(onComp)(null);
}
@@ -536,10 +536,10 @@ export class AssetManager {
this.loadAny(depend, opts, (err, native) => {
if (!err) {
// @ts-ignore
// @ts-expect-error
if (asset.isValid && asset.__nativeDepend__) {
asset._nativeAsset = native;
// @ts-ignore
// @ts-expect-error
asset.__nativeDepend__ = false;
}
}
+1 -1
View File
@@ -424,7 +424,7 @@ export default class Bundle {
}
else if (sceneAsset instanceof SceneAsset && sceneAsset.scene) {
const scene = sceneAsset.scene;
// @ts-ignore
// @ts-expect-error
scene._id = sceneAsset._uuid;
scene.name = sceneAsset.name;
if (onComp) { onComp(null, sceneAsset); }
+5 -5
View File
@@ -153,7 +153,7 @@ export class DependUtil {
return this._depends.get(uuid)!;
}
// @ts-ignore
// @ts-expect-error
if (Array.isArray(json) && (!(BUILD || isCompiledJson(json)) || !hasNativeDep(json))) {
out = {
deps: this._parseDepsFromJson(json),
@@ -196,13 +196,13 @@ export class DependUtil {
preventPreloadNativeObject: (asset.constructor as typeof Asset).preventPreloadNativeObject,
preventDeferredLoadDependents: (asset.constructor as typeof Asset).preventDeferredLoadDependents,
};
// @ts-ignore
// @ts-expect-error
const deps = asset.__depends__ as IDependProp[];
for (let i = 0, l = deps.length; i < l; i++) {
out.deps.push(deps[i].uuid);
}
// @ts-ignore
// @ts-expect-error
if (asset.__nativeDepend__) {
out.nativeDep = asset._nativeDep;
}
@@ -214,7 +214,7 @@ export class DependUtil {
let depends: string[] | null = null;
if (DEV) {
if (isCompiledJson(json)) {
// @ts-ignore
// @ts-expect-error
depends = getDependUuidList(json);
depends!.forEach((uuid, index) => depends![index] = decodeUuid(uuid));
return depends!;
@@ -242,7 +242,7 @@ export class DependUtil {
return depends;
}
else {
// @ts-ignore
// @ts-expect-error
depends = getDependUuidList(json);
depends!.forEach((uuid, index) => depends![index] = decodeUuid(uuid));
}
+2 -2
View File
@@ -113,7 +113,7 @@ export class CCLoader {
private _parseLoadResArgs = parseLoadResArgs;
public get _cache () {
// @ts-ignore
// @ts-expect-error
return assets._map;
}
@@ -414,7 +414,7 @@ export class CCLoader {
return info.path;
});
}
// @ts-ignore
// @ts-expect-error
if (onComplete) { onComplete(err, out, urls); }
});
}
+46 -43
View File
@@ -30,14 +30,19 @@
import { AudioClip } from '../../audio/assets/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 { js } from '../utils/js';
import Bundle, { resources } from './bundle';
import Cache from './cache';
import { IConfigOption } from './config';
import { assets, BuiltinBundleName, bundles, CompleteCallback, IRemoteOptions } from './shared';
import { IDownloadParseOptions } from './shared';
import {
assets, BuiltinBundleName, bundles, CompleteCallback, IRemoteOptions,
IDownloadParseOptions,
} from './shared';
import { cache } from './utilities';
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._nativeUrl = id;
out._nativeAsset = data;
}
catch (e) {
} catch (e) {
err = e;
}
onComplete(err, out);
@@ -60,7 +64,7 @@ function createAudioClip (id: string, data: HTMLAudioElement | AudioBuffer, opti
const out = new AudioClip();
out._nativeUrl = id;
out._nativeAsset = data;
// @ts-ignore
// @ts-expect-error assignment to private field
out._duration = data.duration;
onComplete(null, out);
}
@@ -102,42 +106,41 @@ function createBundle (id: string, data: IConfigOption, options: IDownloadParseO
let bundle = bundles.get(data.name);
if (!bundle) {
bundle = data.name === BuiltinBundleName.RESOURCES ? resources : new Bundle();
data.base = data.base || id + '/';
data.base = data.base || `${id}/`;
bundle.init(data);
}
onComplete(null, bundle);
}
function createVideoClip (id: string, data: HTMLVideoElement, options: IDownloadParseOptions, onComplete: CompleteCallback<VideoClip>) {
let out = new VideoClip();
const out = new VideoClip();
out._nativeUrl = id;
out._nativeAsset = data;
onComplete(null, out);
}
export class Factory {
private _creating = new Cache<CompleteCallback[]>();
private _producers: Record<string, CreateHandler> = {
// Images
'.png' : createImageAsset,
'.jpg' : createImageAsset,
'.bmp' : createImageAsset,
'.jpeg' : createImageAsset,
'.gif' : createImageAsset,
'.ico' : createImageAsset,
'.tiff' : createImageAsset,
'.webp' : createImageAsset,
'.image' : createImageAsset,
'.png': createImageAsset,
'.jpg': createImageAsset,
'.bmp': createImageAsset,
'.jpeg': createImageAsset,
'.gif': createImageAsset,
'.ico': createImageAsset,
'.tiff': createImageAsset,
'.webp': createImageAsset,
'.image': createImageAsset,
'.pvr': createImageAsset,
'.pkm': createImageAsset,
// Audio
'.mp3' : createAudioClip,
'.ogg' : createAudioClip,
'.wav' : createAudioClip,
'.m4a' : createAudioClip,
'.mp3': createAudioClip,
'.ogg': createAudioClip,
'.wav': createAudioClip,
'.m4a': createAudioClip,
// Video
'.mp4': createVideoClip,
@@ -149,26 +152,26 @@ export class Factory {
'.rmvb': createVideoClip,
// Txt
'.txt' : createTextAsset,
'.xml' : createTextAsset,
'.vsh' : createTextAsset,
'.fsh' : createTextAsset,
'.atlas' : createTextAsset,
'.txt': createTextAsset,
'.xml': createTextAsset,
'.vsh': createTextAsset,
'.fsh': createTextAsset,
'.atlas': createTextAsset,
'.tmx' : createTextAsset,
'.tsx' : createTextAsset,
'.fnt' : createTextAsset,
'.tmx': createTextAsset,
'.tsx': createTextAsset,
'.fnt': createTextAsset,
'.json' : createJsonAsset,
'.ExportJson' : createJsonAsset,
'.json': createJsonAsset,
'.ExportJson': createJsonAsset,
// font
'.font' : createFont,
'.eot' : createFont,
'.ttf' : createFont,
'.woff' : createFont,
'.svg' : createFont,
'.ttc' : createFont,
'.font': createFont,
'.eot': createFont,
'.ttf': createFont,
'.woff': createFont,
'.svg': createFont,
'.ttc': createFont,
// Binary
'.binary': createBufferAsset,
@@ -176,17 +179,16 @@ export class Factory {
'.dbbin': createBufferAsset,
'.skel': createBufferAsset,
'bundle': createBundle,
bundle: createBundle,
'default': createAsset,
default: createAsset,
};
public register (type: string | Record<string, CreateHandler>, handler?: CreateHandler): void {
if (typeof type === 'object') {
js.mixin(this._producers, type);
}
else {
} else {
this._producers[type] = handler!;
}
}
@@ -195,7 +197,8 @@ export class Factory {
const handler = this._producers[type] || this._producers.default;
const asset = assets.get(id);
if (!options.reloadAsset && asset) {
return onComplete(null, asset);
onComplete(null, asset);
return;
}
const creating = this._creating.get(id);
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)) {
const asset = assets.get(item.uuid);
asset!.addRef();
// @ts-ignore
// @ts-expect-error
handle(item, task, asset, null, asset.__asyncLoadAssets__, depends, total, done);
return cb();
}
+1 -1
View File
@@ -124,7 +124,7 @@ function nativeCheckFontLoaded (start: number, font: string, callback: CompleteC
reject();
}
else {
// @ts-ignore
// @ts-expect-error
document.fonts.load('40px ' + font).then((fonts) => {
if (fonts.length >= 1) {
resolve();
+3 -3
View File
@@ -159,7 +159,7 @@ const loadOneAssetPipeline = new Pipeline('loadOneAsset', [
else {
if (!options.reloadAsset && assets.has(uuid)) {
const asset = assets.get(uuid)!;
// @ts-ignore
// @ts-expect-error
if (options.__asyncLoadAssets__ || !asset.__asyncLoadAssets__) {
item.content = asset.addRef();
if (progress.canInvoke) {
@@ -207,7 +207,7 @@ function loadDepends (task: Task, asset: Asset, done: CompleteCallbackNoData, in
progress,
onComplete: (err) => {
asset.decRef && asset.decRef(false);
// @ts-ignore
// @ts-expect-error
asset.__asyncLoadAssets__ = __asyncLoadAssets__;
repeatItem.finish = true;
repeatItem.err = err;
@@ -222,7 +222,7 @@ function loadDepends (task: Task, asset: Asset, done: CompleteCallbackNoData, in
}
if (!init) {
// @ts-ignore
// @ts-expect-error
if (asset.__nativeDepend__) {
if (!setProperties(uuid, asset, map)) {
try {
+1 -1
View File
@@ -89,7 +89,7 @@ export class PackManager {
if (Array.isArray(json)) {
// @ts-ignore
// @ts-expect-error
json = unpackJSONs(json, MissingScript.safeFindClass);
if (json.length !== pack.length) {
+4 -4
View File
@@ -163,7 +163,7 @@ class ReleaseManager {
// transfer refs from persist nodes to new scene
for (let i = 0, l = persistNodes.length; i < l; i++) {
const node = persistNodes[i];
// @ts-ignore
// @ts-expect-error
const sceneDeps = dependUtil._depends.get(newScene._id);
const deps = this._persistNodeDeps.get(node.uuid) as string[];
for (const dep of deps) {
@@ -182,7 +182,7 @@ class ReleaseManager {
if (!oldScene) { return; }
// @ts-ignore
// @ts-expect-error
const childs = dependUtil.getDeps(oldScene._id);
for (let i = 0, l = childs.length; i < l; i++) {
const asset = assets.get(childs[i]);
@@ -190,7 +190,7 @@ class ReleaseManager {
asset.decRef(TEST || oldScene.autoReleaseAssets);
}
}
// @ts-ignore
// @ts-expect-error
const dependencies = dependUtil._depends.get(oldScene._id);
if (dependencies && dependencies.persistDeps) {
const persistDeps = dependencies.persistDeps;
@@ -201,7 +201,7 @@ class ReleaseManager {
}
}
}
// @ts-ignore
// @ts-expect-error
dependUtil.remove(oldScene._id);
}
+5 -5
View File
@@ -94,7 +94,7 @@ export function getDepends (uuid: string, data: Asset | Record<string, any>, exc
try {
const info = dependUtil.parse(uuid, data);
let includeNative = true;
// @ts-ignore
// @ts-expect-error
if (data instanceof Asset && (!data.__nativeDepend__)) { includeNative = false; }
if (!preload) {
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>) {
let missingAsset = false;
// @ts-ignore
// @ts-expect-error
const depends = asset.__depends__ as IDependProp[];
if (depends) {
let missingAssetReporter: any = null;
@@ -180,11 +180,11 @@ export function setProperties (uuid: string, asset: Asset, assetsMap: Record<str
if (missingAssetReporter) {
missingAssetReporter.reportByOwner();
}
// @ts-ignore
// @ts-expect-error
asset.__depends__ = null;
}
// @ts-ignore
// @ts-expect-error
if (asset.__nativeDepend__) {
if (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!`);
}
}
// @ts-ignore
// @ts-expect-error
asset.__nativeDepend__ = false;
}
return missingAsset;
+1 -1
View File
@@ -295,7 +295,7 @@ export class Asset extends Eventify(CCObject) {
*/
type CreateNodeCallback = (error: Error | null, node: Node) => void;
// @ts-ignore
// @ts-expect-error
Asset.prototype.createNode = null;
legacyCC.Asset = Asset;
+1 -1
View File
@@ -40,7 +40,7 @@ replaceProperty(RenderTexture.prototype, 'RenderTexture.prototype', [
{
name: 'getGFXWindow',
customFunction () {
// @ts-ignore
// @ts-expect-error
return this._window;
},
},
+1 -1
View File
@@ -38,7 +38,7 @@ import { legacyCC } from '../global-exports';
*
*/
@ccclass('cc.LabelAtlas')
export class LabelAtlas extends BitmapFont{
export class LabelAtlas extends BitmapFont {
}
legacyCC.LabelAtlas = LabelAtlas;
+38 -30
View File
@@ -28,18 +28,18 @@
* @module material
*/
import { ccclass, type, serializable } 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 { ccclass, serializable, type } from 'cc.decorator';
import { Asset } from './asset';
import { EffectAsset } from './effect-asset';
import { SpriteFrame } from './sprite-frame';
import { TextureBase } from './texture-base';
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.
@@ -91,7 +91,6 @@ type MaterialPropertyFull = MaterialProperty | TextureBase | SpriteFrame | Rende
*/
@ccclass('cc.Material')
export class Material extends Asset {
/**
* @en Get hash for a material
* @zh 获取一个材质的哈希值
@@ -107,18 +106,28 @@ export class Material extends Asset {
@type(EffectAsset)
protected _effectAsset: EffectAsset | null = null;
@serializable
protected _techIdx = 0;
@serializable
protected _defines: MacroRecord[] = [];
@serializable
protected _states: PassOverrides[] = [];
@serializable
protected _props: Record<string, MaterialPropertyFull | MaterialPropertyFull[]>[] = [];
protected _passes: Pass[] = [];
protected _hash = 0;
constructor () {
super();
this.loaded = false;
}
/**
* @en The current [[EffectAsset]].
* @zh 当前使用的 [[EffectAsset]] 资源。
@@ -175,11 +184,6 @@ export class Material extends Asset {
return null;
}
constructor () {
super();
this.loaded = false;
}
/**
* @en Initialize this material with the given information.
* @zh 根据所给信息初始化这个材质,初始化正常结束后材质即可立即用于渲染。
@@ -190,12 +194,16 @@ export class Material extends Asset {
if (!this._states) { this._states = []; }
if (!this._props) { this._props = []; }
if (info.technique !== undefined) { this._techIdx = info.technique; }
if (info.effectAsset) { this._effectAsset = info.effectAsset; }
else if (info.effectName) { this._effectAsset = EffectAsset.get(info.effectName); }
if (info.effectAsset) {
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.states) { this._prepareInfo(info.states, this._states); }
this._update();
}
public reset (info: IMaterialInfo) { // to be consistent with other assets
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.
*/
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.
*/
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) {
console.warn(`illegal property name: ${name}.`);
return;
}
}
@@ -333,27 +340,28 @@ export class Material extends Asset {
this._techIdx = mat._techIdx;
this._props.length = mat._props.length;
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;
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;
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._update();
}
protected _prepareInfo (patch: object | object[], cur: object[]) {
if (!Array.isArray(patch)) { // fill all the passes if not specified
protected _prepareInfo (patch: Record<string, unknown> | Record<string, unknown>[], cur: Record<string, unknown>[]) {
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;
patch = Array(len).fill(patch);
patchArray = Array(len).fill(patchArray);
}
for (let i = 0; i < (patch as object[]).length; ++i) {
Object.assign(cur[i] || (cur[i] = {}), patch[i]);
for (let i = 0; i < patchArray.length; ++i) {
Object.assign(cur[i] || (cur[i] = {}), patchArray[i]);
}
}
@@ -382,7 +390,7 @@ export class Material extends Asset {
return passes;
}
protected _update (keepProps: boolean = true) {
protected _update (keepProps = true) {
if (this._effectAsset) {
if (this._passes && this._passes.length) {
for (const pass of this._passes) {
@@ -446,7 +454,7 @@ export class Material extends Asset {
const texture: Texture | null = val.getGFXTexture();
if (!texture || !texture.width || !texture.height) {
// console.warn(`material '${this._uuid}' received incomplete texture asset '${val._uuid}'`);
return false;
return;
}
pass.bindTexture(binding, texture, index);
pass.bindSampler(binding, val.getGFXSampler(), index);
+194 -177
View File
@@ -29,39 +29,44 @@
*/
import { ccclass, serializable } from 'cc.decorator';
import { Mat4, Quat, Vec3 } from '../../core/math';
import { mapBuffer } from '../3d/misc/buffer';
import { Asset } from './asset';
import { BufferBlob } from '../3d/misc/buffer-blob';
import { Skeleton } from './skeleton';
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 {
getTypedArrayConstructor,
AttributeName,
BufferUsageBit,
Feature,
Format,
FormatInfos,
FormatType,
MemoryUsageBit,
PrimitiveMode,
Feature
getTypedArrayConstructor,
} from '../gfx/define';
import { Device, Attribute, InputAssemblerInfo } from '../gfx';
import { warnID } from '../platform/debug';
import { sys } from '../platform/sys';
import { murmurhash2_32_gc } from '../utils/murmurhash2_gc';
import { Asset } from './asset';
import { Skeleton } from './skeleton';
import { Morph, createMorphRendering, MorphRendering } from './morph';
import { legacyCC } from '../global-exports';
import { FlatBufferArrayPool, FlatBufferPool, FlatBufferView, freeHandleArray, NULL_HANDLE, RawBufferPool, SubMeshHandle, SubMeshPool, SubMeshView } from '../renderer/core/memory-pools';
import {
FlatBufferArrayPool, FlatBufferPool, FlatBufferView, NULL_HANDLE, RawBufferPool,
SubMeshHandle, SubMeshPool, SubMeshView, freeHandleArray,
} from '../renderer/core/memory-pools';
import { Mat4, Quat, Vec3 } from '../math';
import { Morph, MorphRendering, createMorphRendering } from './morph';
function getIndexStrideCtor (stride: number) {
switch (stride) {
case 1: return Uint8Array;
case 2: return Uint16Array;
case 4: return Uint32Array;
case 1: return Uint8Array;
case 2: return Uint16Array;
case 4: return Uint32Array;
default: return Uint8Array;
}
return Uint8Array;
}
/**
@@ -97,7 +102,7 @@ export interface IGeometricInfo {
* @en The bounding box
* @zh 此几何体的轴对齐包围盒。
*/
boundingBox: { max: Vec3; min: Vec3; }
boundingBox: { max: Vec3; min: Vec3 };
}
/**
@@ -115,22 +120,67 @@ export interface IFlatBuffer {
* @zh 包含所有顶点数据的渲染子网格,可以用来创建 [[InputAssembler]]。
*/
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
* @zh 所有顶点属性。
*/
get attributes () { return this._attributes; }
/**
* @en All vertex buffers used by the sub mesh
* @zh 使用的所有顶点缓冲区。
*/
get vertexBuffers () { return this._vertexBuffers; }
/**
* @en Index buffer used by the sub mesh
* @zh 使用的索引缓冲区,若未使用则无需指定。
*/
get indexBuffer () { return this._indexBuffer; }
/**
* @en Indirect buffer used by the sub mesh
* @zh 间接绘制缓冲区。
@@ -157,12 +207,12 @@ export class RenderingSubMesh {
if (this.subMeshIdx === undefined) {
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 indices = mesh.readIndices(index) as Uint16Array;
const max = 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) {
const conut = FormatInfos[pAttri.format].count;
if (conut === 2) {
@@ -197,15 +247,17 @@ export class RenderingSubMesh {
* @zh 扁平化的顶点缓冲区。
*/
get flatBuffers () { return this._flatBuffers; }
public genFlatBuffers() {
public genFlatBuffers () {
if (this._flatBuffers.length || !this.mesh || this.subMeshIdx === undefined) { return; }
const mesh = this.mesh;
const { mesh } = this;
let idxCount = 0;
const prim = mesh.struct.primitives[this.subMeshIdx];
const fbArrayHandle = SubMeshPool.get(this._handle, SubMeshView.FLAT_BUFFER_ARRAY);
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 vbCount = prim.indexView ? prim.indexView.count : vertexBundle.view.count;
const vbStride = vertexBundle.view.stride;
@@ -243,7 +295,6 @@ export class RenderingSubMesh {
FlatBufferArrayPool.push(fbArrayHandle, hFlatBuffer);
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 indices: number[] = this._jointMappedBufferIndices = [];
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];
if (!struct.jointMaps || prim.jointMapIndex === undefined || !struct.jointMaps[prim.jointMapIndex]) {
return this._jointMappedBuffers = this.vertexBuffers;
}
let jointFormat: Format;
let jointOffset: number;
const device: Device = legacyCC.director.root.device;
const { device } = legacyCC.director.root;
for (let i = 0; i < prim.vertexBundelIndices.length; i++) {
const bundle = struct.vertexBundles[prim.vertexBundelIndices[i]];
jointOffset = 0;
@@ -300,42 +351,10 @@ export class RenderingSubMesh {
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 () {
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 () {
for (let i = 0; i < this.vertexBuffers.length; i++) {
this.vertexBuffers[i].destroy();
@@ -356,7 +375,7 @@ export class RenderingSubMesh {
this._indirectBuffer.destroy();
this._indirectBuffer = null;
}
if(this._handle) {
if (this._handle) {
const fbArrayHandle = SubMeshPool.get(this._handle, SubMeshView.FLAT_BUFFER_ARRAY);
freeHandleArray(fbArrayHandle, FlatBufferArrayPool, FlatBufferPool);
@@ -391,14 +410,14 @@ export class RenderingSubMesh {
}
private _allocVertexIdBuffer (device: Device) {
const vertexCount = (this.vertexBuffers.length === 0 || this.vertexBuffers[0].stride === 0) ?
0 :
// TODO: This depends on how stride of a vertex buffer is defined; Consider padding problem.
this.vertexBuffers[0].size / this.vertexBuffers[0].stride;
const vertexCount = (this.vertexBuffers.length === 0 || this.vertexBuffers[0].stride === 0)
? 0
// TODO: This depends on how stride of a vertex buffer is defined; Consider padding problem.
: this.vertexBuffers[0].size / this.vertexBuffers[0].stride;
const vertexIds = new Float32Array(vertexCount);
for (let iVertex = 0; iVertex < vertexCount; ++iVertex) {
// `+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()`.
// `+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()`.
vertexIds[iVertex] = iVertex + 0.5;
}
@@ -543,7 +562,6 @@ const globalEmptyMeshBuffer = new Uint8Array();
*/
@ccclass('cc.Mesh')
export class Mesh extends Asset {
get _nativeAsset (): ArrayBuffer {
return this._data.buffer;
}
@@ -607,7 +625,7 @@ export class Mesh extends Asset {
* @zh 此网格的哈希值。
*/
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); }
return this._hash;
}
@@ -629,6 +647,8 @@ export class Mesh extends Asset {
return this._renderingSubMeshes!;
}
public morphRendering: MorphRendering | null = null;
@serializable
private _struct: Mesh.IStruct = {
vertexBundles: [],
@@ -642,9 +662,13 @@ export class Mesh extends Asset {
private _hash = 0;
private _data: Uint8Array = globalEmptyMeshBuffer;
private _initialized = false;
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;
constructor () {
@@ -660,12 +684,12 @@ export class Mesh extends Asset {
this._initialized = true;
if (this._data.byteLength !== this._dataLength) {
// In the case of deferred loading, `this._data` is created before
// the actual binary buffer is loaded.
// In the case of deferred loading, `this._data` is created before
// the actual binary buffer is loaded.
this._data = new Uint8Array(this._dataLength);
legacyCC.assetManager.postLoadNative(this);
}
const buffer = this._data.buffer;
const { buffer } = this._data;
const gfxDevice: Device = legacyCC.director.root.device;
const vertexBuffers = this._createVertexBuffers(gfxDevice, buffer);
const indexBuffers: Buffer[] = [];
@@ -709,8 +733,7 @@ export class Mesh extends Asset {
}
if (this.loaded) {
indexBuffer.update(ib);
}
else {
} else {
this.once('load', () => {
indexBuffer!.update(ib);
});
@@ -807,12 +830,12 @@ export class Mesh extends Asset {
const bounds: (aabb | null)[] = [];
this._boneSpaceBounds.set(skeleton.hash, bounds);
const valid: boolean[] = [];
const bindposes = skeleton.bindposes;
const { bindposes } = skeleton;
for (let i = 0; i < bindposes.length; i++) {
bounds.push(new aabb(Infinity, Infinity, Infinity, -Infinity, -Infinity, -Infinity));
valid.push(false);
}
const primitives = this._struct.primitives;
const { primitives } = this._struct;
for (let p = 0; p < primitives.length; p++) {
const joints = this.readAttribute(p, AttributeName.ATTR_JOINTS);
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++) {
const b = bounds[i]!;
if (!valid[i]) { bounds[i] = null; }
else { aabb.fromPoints(b, b.center, b.halfExtents); }
if (!valid[i]) { bounds[i] = null; } else { aabb.fromPoints(b, b.center, b.halfExtents); }
}
return bounds;
}
@@ -879,11 +901,12 @@ export class Mesh extends Asset {
const vtxBdl = struct.vertexBundles[i];
for (let j = 0; j < vtxBdl.attributes.length; j++) {
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(
data.buffer,
vtxBdl.view.offset + getOffset(vtxBdl.attributes, j));
vtxBdl.view.offset + getOffset(vtxBdl.attributes, j),
);
const reader = getReader(inputView, format);
const writer = getWriter(inputView, format);
@@ -900,12 +923,13 @@ export class Mesh extends Asset {
const zOffset = yOffset + attrComponentByteLength;
vec3_temp.set(reader(xOffset), reader(yOffset), reader(zOffset));
switch (vtxBdl.attributes[j].name) {
case AttributeName.ATTR_POSITION:
vec3_temp.transformMat4(worldMatrix);
break;
case AttributeName.ATTR_NORMAL:
Vec3.transformQuat(vec3_temp, vec3_temp, rotate!);
break;
case AttributeName.ATTR_POSITION:
vec3_temp.transformMat4(worldMatrix);
break;
case AttributeName.ATTR_NORMAL:
Vec3.transformQuat(vec3_temp, vec3_temp, rotate!);
break;
default:
}
writer(xOffset, vec3_temp.x);
writer(yOffset, vec3_temp.y);
@@ -980,12 +1004,12 @@ export class Mesh extends Asset {
const f32_temp = new Float32Array(vbView.buffer, srcVBOffset, 3);
vec3_temp.set(f32_temp[0], f32_temp[1], f32_temp[2]);
switch (attr.name) {
case AttributeName.ATTR_POSITION:
vec3_temp.transformMat4(worldMatrix);
break;
case AttributeName.ATTR_NORMAL:
Vec3.transformQuat(vec3_temp, vec3_temp, rotate!);
break;
case AttributeName.ATTR_POSITION:
vec3_temp.transformMat4(worldMatrix);
break;
case AttributeName.ATTR_NORMAL:
Vec3.transformQuat(vec3_temp, vec3_temp, rotate!);
break;
}
f32_temp[0] = vec3_temp.x;
f32_temp[1] = vec3_temp.y;
@@ -1098,7 +1122,6 @@ export class Mesh extends Asset {
bufferBlob.setNextAlignment(idxStride);
bufferBlob.addBuffer(ib);
}
}
// Create mesh struct.
@@ -1202,10 +1225,8 @@ export class Mesh extends Asset {
if (dstPrim.indexView === undefined) {
return false;
}
} else {
if (dstPrim.indexView) {
return false;
}
} else if (dstPrim.indexView) {
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,
* 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;
this._accessAttribute(primitiveIndex, attributeName, (vertexBundle, iAttribute) => {
const vertexCount = vertexBundle.view.count;
const format = vertexBundle.attributes[iAttribute].format;
const { format } = vertexBundle.attributes[iAttribute];
const storageConstructor = getTypedArrayConstructor(FormatInfos[format]);
if (vertexCount === 0) {
return new storageConstructor();
return;
}
const inputView = new DataView(
this._data.buffer,
vertexBundle.view.offset + getOffset(vertexBundle.attributes, iAttribute));
vertexBundle.view.offset + getOffset(vertexBundle.attributes, iAttribute),
);
const formatInfo = FormatInfos[format];
const reader = getReader(inputView, format);
@@ -1248,7 +1270,6 @@ export class Mesh extends Asset {
}
}
result = storage;
return;
});
return result;
}
@@ -1271,11 +1292,12 @@ export class Mesh extends Asset {
written = true;
return;
}
const format = vertexBundle.attributes[iAttribute].format;
const { format } = vertexBundle.attributes[iAttribute];
const inputView = new DataView(
this._data.buffer,
vertexBundle.view.offset + getOffset(vertexBundle.attributes, iAttribute));
vertexBundle.view.offset + getOffset(vertexBundle.attributes, iAttribute),
);
const outputView = new DataView(buffer, offset);
@@ -1301,7 +1323,6 @@ export class Mesh extends Asset {
}
}
written = true;
return;
});
return written;
}
@@ -1321,7 +1342,7 @@ export class Mesh extends Asset {
if (!primitive.indexView) {
return null;
}
const stride = primitive.indexView.stride;
const { stride } = primitive.indexView;
const ctor = stride === 1 ? Uint8Array : (stride === 2 ? Uint16Array : Uint32Array);
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
* @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) {
return false;
}
@@ -1353,7 +1374,8 @@ export class Mesh extends Asset {
private _accessAttribute (
primitiveIndex: number,
attributeName: AttributeName,
accessor: (vertexBundle: Mesh.IVertexBundle, iAttribute: number) => void) {
accessor: (vertexBundle: Mesh.IVertexBundle, iAttribute: number) => void,
) {
if (primitiveIndex >= this._struct.primitives.length) {
return;
}
@@ -1367,12 +1389,10 @@ export class Mesh extends Asset {
accessor(vertexBundle, iAttribute);
break;
}
return;
}
private _createVertexBuffers (gfxDevice: Device, data: ArrayBuffer): Buffer[] {
return this._struct.vertexBundles.map((vertexBundle) => {
const vertexBuffer = gfxDevice.createBuffer(new BufferInfo(
BufferUsageBit.VERTEX | BufferUsageBit.TRANSFER_DST,
MemoryUsageBit.DEVICE,
@@ -1383,8 +1403,7 @@ export class Mesh extends Asset {
const view = new Uint8Array(data, vertexBundle.view.offset, vertexBundle.view.length);
if (this.loaded) {
vertexBuffer.update(view);
}
else {
} else {
this.once('load', () => {
vertexBuffer.update(view);
});
@@ -1392,8 +1411,6 @@ export class Mesh extends Asset {
return vertexBuffer;
});
}
public morphRendering: MorphRendering | null = null;
}
legacyCC.Mesh = Mesh;
@@ -1406,7 +1423,7 @@ function getOffset (attributes: Attribute[], attributeIndex: number) {
return result;
}
const isLittleEndian = sys.isLittleEndian;
const { isLittleEndian } = sys;
function getComponentByteLength (format: Format) {
const info = FormatInfos[format];
@@ -1418,41 +1435,41 @@ function getReader (dataView: DataView, format: Format) {
const stride = info.size / info.count;
switch (info.type) {
case FormatType.UNORM: {
switch (stride) {
case 1: return (offset: number) => dataView.getUint8(offset);
case 2: return (offset: number) => dataView.getUint16(offset, isLittleEndian);
case 4: return (offset: number) => dataView.getUint32(offset, isLittleEndian);
}
break;
case FormatType.UNORM: {
switch (stride) {
case 1: return (offset: number) => dataView.getUint8(offset);
case 2: return (offset: number) => dataView.getUint16(offset, isLittleEndian);
case 4: return (offset: number) => dataView.getUint32(offset, isLittleEndian);
}
case FormatType.SNORM: {
switch (stride) {
case 1: return (offset: number) => dataView.getInt8(offset);
case 2: return (offset: number) => dataView.getInt16(offset, isLittleEndian);
case 4: return (offset: number) => dataView.getInt32(offset, isLittleEndian);
}
break;
break;
}
case FormatType.SNORM: {
switch (stride) {
case 1: return (offset: number) => dataView.getInt8(offset);
case 2: return (offset: number) => dataView.getInt16(offset, isLittleEndian);
case 4: return (offset: number) => dataView.getInt32(offset, isLittleEndian);
}
case FormatType.INT: {
switch (stride) {
case 1: return (offset: number) => dataView.getInt8(offset);
case 2: return (offset: number) => dataView.getInt16(offset, isLittleEndian);
case 4: return (offset: number) => dataView.getInt32(offset, isLittleEndian);
}
break;
break;
}
case FormatType.INT: {
switch (stride) {
case 1: return (offset: number) => dataView.getInt8(offset);
case 2: return (offset: number) => dataView.getInt16(offset, isLittleEndian);
case 4: return (offset: number) => dataView.getInt32(offset, isLittleEndian);
}
case FormatType.UINT: {
switch (stride) {
case 1: return (offset: number) => dataView.getUint8(offset);
case 2: return (offset: number) => dataView.getUint16(offset, isLittleEndian);
case 4: return (offset: number) => dataView.getUint32(offset, isLittleEndian);
}
break;
}
case FormatType.FLOAT: {
return (offset: number) => dataView.getFloat32(offset, isLittleEndian);
break;
}
case FormatType.UINT: {
switch (stride) {
case 1: return (offset: number) => dataView.getUint8(offset);
case 2: return (offset: number) => dataView.getUint16(offset, isLittleEndian);
case 4: return (offset: number) => dataView.getUint32(offset, isLittleEndian);
}
break;
}
case FormatType.FLOAT: {
return (offset: number) => dataView.getFloat32(offset, isLittleEndian);
}
}
return null;
@@ -1463,41 +1480,41 @@ function getWriter (dataView: DataView, format: Format) {
const stride = info.size / info.count;
switch (info.type) {
case FormatType.UNORM: {
switch (stride) {
case 1: return (offset: number, value: number) => dataView.setUint8(offset, value);
case 2: return (offset: number, value: number) => dataView.setUint16(offset, value, isLittleEndian);
case 4: return (offset: number, value: number) => dataView.setUint32(offset, value, isLittleEndian);
}
break;
case FormatType.UNORM: {
switch (stride) {
case 1: return (offset: number, value: number) => dataView.setUint8(offset, value);
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 FormatType.SNORM: {
switch (stride) {
case 1: return (offset: number, value: number) => dataView.setInt8(offset, value);
case 2: return (offset: number, value: number) => dataView.setInt16(offset, value, isLittleEndian);
case 4: return (offset: number, value: number) => dataView.setInt32(offset, value, isLittleEndian);
}
break;
break;
}
case FormatType.SNORM: {
switch (stride) {
case 1: return (offset: number, value: number) => dataView.setInt8(offset, value);
case 2: return (offset: number, value: number) => dataView.setInt16(offset, value, isLittleEndian);
case 4: return (offset: number, value: number) => dataView.setInt32(offset, value, isLittleEndian);
}
case FormatType.INT: {
switch (stride) {
case 1: return (offset: number, value: number) => dataView.setInt8(offset, value);
case 2: return (offset: number, value: number) => dataView.setInt16(offset, value, isLittleEndian);
case 4: return (offset: number, value: number) => dataView.setInt32(offset, value, isLittleEndian);
}
break;
break;
}
case FormatType.INT: {
switch (stride) {
case 1: return (offset: number, value: number) => dataView.setInt8(offset, value);
case 2: return (offset: number, value: number) => dataView.setInt16(offset, value, isLittleEndian);
case 4: return (offset: number, value: number) => dataView.setInt32(offset, value, isLittleEndian);
}
case FormatType.UINT: {
switch (stride) {
case 1: return (offset: number, value: number) => dataView.setUint8(offset, value);
case 2: return (offset: number, value: number) => dataView.setUint16(offset, value, isLittleEndian);
case 4: return (offset: number, value: number) => dataView.setUint32(offset, value, isLittleEndian);
}
break;
}
case FormatType.FLOAT: {
return (offset: number, value: number) => dataView.setFloat32(offset, value, isLittleEndian);
break;
}
case FormatType.UINT: {
switch (stride) {
case 1: return (offset: number, value: number) => dataView.setUint8(offset, value);
case 2: return (offset: number, value: number) => dataView.setUint16(offset, value, isLittleEndian);
case 4: return (offset: number, value: number) => dataView.setUint32(offset, value, isLittleEndian);
}
break;
}
case FormatType.FLOAT: {
return (offset: number, value: number) => dataView.setFloat32(offset, value, isLittleEndian);
}
}
return null;
+4 -4
View File
@@ -115,7 +115,7 @@ export default class Prefab extends Asset {
*/
@serializable
@editable
public asyncLoadAssets: Boolean = false;
public asyncLoadAssets = false;
// Cache function to optimize instance creation.
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.
* @zh
* 将预制数据动态转换为最小化代码。<br/>
     * 此方法将在第一次实例化预制件之前自动调用,<br/>
     * 但是您可以在脚本中修改原始预制数据后重新调用以刷新创建功能。
* 此方法将在第一次实例化预制件之前自动调用,<br/>
* 但是您可以在脚本中修改原始预制数据后重新调用以刷新创建功能。
*/
public compileCreateFunction (): void {
this._createFunction = compile(this.data);
@@ -167,7 +167,7 @@ export default class Prefab extends Asset {
private _instantiate () {
let node;
let useJit: Boolean = false;
let useJit = false;
if (SUPPORT_JIT) {
if (this.optimizationPolicy === OptimizationPolicy.SINGLE_INSTANCE) {
useJit = false;
+1 -1
View File
@@ -480,7 +480,7 @@ export class SpriteFrame extends Asset {
protected _capInsets = [0, 0, 0, 0];
protected _atlasUuid: string = '';
// @ts-ignore
// @ts-expect-error
protected _texture: TextureBase | RenderTexture;
protected _flipUv = false;
+25 -28
View File
@@ -24,7 +24,7 @@
THE SOFTWARE.
*/
// tslint:disable
/**
* @packageDocumentation
@@ -46,9 +46,6 @@ import { errorID, warnID, assertID } from '../platform/debug';
import { CompPrefabInfo } from '../utils';
const idGenerator = new IDGenerator('Comp');
// @ts-ignore
const IsOnEnableCalled = CCObject.Flags.IsOnEnableCalled;
// @ts-ignore
const IsOnLoadCalled = CCObject.Flags.IsOnLoadCalled;
const NullNode = null as unknown as Node;
@@ -202,7 +199,7 @@ class Component extends CCObject {
if (this._sceneGetter) {
return this._sceneGetter();
} else {
return this.node.scene!._renderScene!;
return this.node.scene._renderScene!;
}
}
@@ -357,7 +354,7 @@ class Component extends CCObject {
public destroy () {
if (EDITOR) {
// @ts-ignore
// @ts-expect-error
const depend = this.node._getDependComponent(this);
if (depend) {
errorID(3626,
@@ -380,7 +377,7 @@ class Component extends CCObject {
//
if (EDITOR && !TEST) {
// @ts-ignore
// @ts-expect-error
_Scene.AssetsWatcher.stop(this);
}
@@ -418,7 +415,7 @@ class Component extends CCObject {
* 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);
interval = interval || 0;
@@ -451,7 +448,7 @@ class Component extends CCObject {
* 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);
}
@@ -642,47 +639,47 @@ class Component extends CCObject {
}
const proto = Component.prototype;
// @ts-ignore
// @ts-expect-error
proto.update = null;
// @ts-ignore
// @ts-expect-error
proto.lateUpdate = null;
// @ts-ignore
// @ts-expect-error
proto.__preload = null;
// @ts-ignore
// @ts-expect-error
proto.onLoad = null;
// @ts-ignore
// @ts-expect-error
proto.start = null;
// @ts-ignore
// @ts-expect-error
proto.onEnable = null;
// @ts-ignore
// @ts-expect-error
proto.onDisable = null;
// @ts-ignore
// @ts-expect-error
proto.onDestroy = null;
// @ts-ignore
// @ts-expect-error
proto.onFocusInEditor = null;
// @ts-ignore
// @ts-expect-error
proto.onLostFocusInEditor = null;
// @ts-ignore
// @ts-expect-error
proto.resetInEditor = null;
// @ts-ignore
// @ts-expect-error
proto._getLocalBounds = null;
// @ts-ignore
// @ts-expect-error
proto.onRestore = null;
// @ts-ignore
// @ts-expect-error
Component._requireComponent = null;
// @ts-ignore
// @ts-expect-error
Component._executionOrder = 0;
if (EDITOR || TEST) {
// INHERITABLE STATIC MEMBERS
// @ts-ignore
// @ts-expect-error
Component._executeInEditMode = false;
// @ts-ignore
// @ts-expect-error
Component._playOnFocus = false;
// @ts-ignore
// @ts-expect-error
Component._disallowMultiple = null;
// @ts-ignore
// @ts-expect-error
Component._help = '';
// NON-INHERITED STATIC MEMBERS
+1 -1
View File
@@ -80,7 +80,7 @@ export default class MissingScript extends Component {
constructor () {
super();
if (EDITOR) {
// @ts-ignore
// @ts-expect-error
this.compiled = _Scene.Sandbox.compiled;
}
}
@@ -88,7 +88,7 @@ export class UITransform extends Component {
this._contentSize.set(value);
if (EDITOR) {
// @ts-ignore
// @ts-expect-error
this.node.emit(SystemEventType.SIZE_CHANGED, clone);
} else {
this.node.emit(SystemEventType.SIZE_CHANGED);
@@ -112,7 +112,7 @@ export class UITransform extends Component {
this._contentSize.width = value;
if (EDITOR) {
// @ts-ignore
// @ts-expect-error
this.node.emit(SystemEventType.SIZE_CHANGED, clone);
} else {
this.node.emit(SystemEventType.SIZE_CHANGED);
@@ -135,7 +135,7 @@ export class UITransform extends Component {
this._contentSize.height = value;
if (EDITOR) {
// @ts-ignore
// @ts-expect-error
this.node.emit(SystemEventType.SIZE_CHANGED, clone);
} else {
this.node.emit(SystemEventType.SIZE_CHANGED);
@@ -310,7 +310,7 @@ export class UITransform extends Component {
}
if (EDITOR) {
// @ts-ignore
// @ts-expect-error
this.node.emit(SystemEventType.SIZE_CHANGED, clone);
} else {
this.node.emit(SystemEventType.SIZE_CHANGED);
@@ -612,7 +612,7 @@ export class UITransform extends Component {
}
}
// @ts-ignore
// @ts-expect-error
parent = parent.parent;
}
}
+7 -8
View File
@@ -29,12 +29,12 @@
* @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 * as js from '../utils/js';
@@ -270,8 +270,7 @@ function define (className, baseClass, mixins, options) {
renderName = 'render_stage';
}
// 增加了 hidden: 开头标识,使它最终不会显示在 Editor inspector 的添加组件列表里
// @ts-ignore
// tslint:disable-next-line:no-unused-expression
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 { Details } from './deserialize';
// tslint:disable: no-shadowed-variable
// IMPLEMENT OF DESERIALIZATION
@@ -102,7 +102,7 @@ const compileDeserialize = SUPPORT_JIT ? (self, 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
// tslint:disable-next-line: prefer-for-of
for (let p = 0; p < props.length; p++) {
const propName = props[p];
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 FORMERLY_SERIALIZED_AS = Attr.DELIMETER + 'formerlySerializedAs';
// tslint:disable-next-line: prefer-for-of
for (let p = 0; p < props.length; p++) {
const propName = props[p];
let propNameToRead = propName;
@@ -359,7 +359,7 @@ function _deserializeFireClass (self, obj, serialized, klass) {
// }
// }
// tslint:disable-next-line: class-name
class _Deserializer {
public static pool: js.Pool<{}>;
@@ -446,14 +446,14 @@ class _Deserializer {
* @param {Object} [owner] - debug only
* @param {String} [propName] - debug only
*/
private _deserializeObject (serialized, owner?: Object, propName?: String) {
private _deserializeObject (serialized, owner?: Object, propName?: string) {
let prop;
let obj: any = null; // the obj to return
let klass: any = null;
const type = serialized.__type__;
if (type === 'TypedArray') {
const array = serialized.array;
// @ts-ignore
// @ts-expect-error
obj = new window[serialized.ctor](array.length);
for (let i = 0; i < array.length; ++i) {
obj[i] = array[i];
@@ -473,7 +473,6 @@ class _Deserializer {
return null;
}
const self = this;
// @ts-ignore
function deserializeByType () {
// instantiate a new object
obj = new klass();
@@ -490,7 +489,6 @@ class _Deserializer {
}
}
// @ts-ignore
function checkDeserializeByType () {
try {
deserializeByType();
@@ -510,7 +508,7 @@ class _Deserializer {
deserializeByType();
}
}
else if ( !Array.isArray(serialized) ) {
else if (!Array.isArray(serialized)) {
// embedded primitive javascript object
@@ -614,7 +612,7 @@ class _Deserializer {
const DEFAULT = Attr.DELIMETER + 'default';
const attrs = Attr.getClassAttrs(klass);
const fastDefinedProps = klass.__props__ || Object.keys(instance); // 遍历 instance,如果具有类型,才不会把 __type__ 也读进来
// tslint:disable-next-line: prefer-for-of
for (let i = 0; i < fastDefinedProps.length; i++) {
const propName = fastDefinedProps[i];
let value = serialized[propName];
@@ -646,7 +644,7 @@ _Deserializer.pool = new js.Pool((obj: any) => {
obj._idObjList.length = 0;
obj._idPropList.length = 0;
}, 1);
// @ts-ignore
// @ts-expect-error
_Deserializer.pool.get = function (result, classFinder, customEnv, ignoreEditorOnly) {
const cache: any = this._get();
if (cache) {
@@ -674,7 +672,7 @@ export function deserializeDynamic (data, details: Details, options) {
details.init();
// @ts-ignore
// @ts-expect-error
const deserializer: _Deserializer = _Deserializer.pool.get(details, classFinder, customEnv, ignoreEditorOnly);
legacyCC.game._isCloning = true;
+16 -18
View File
@@ -99,26 +99,26 @@ function serializeBuiltinValueTypes (obj: ValueType): IValueTypeData | null {
const typeId = BuiltinValueTypes.indexOf(ctor);
switch (ctor) {
case Vec2:
// @ts-ignore
// @ts-expect-error
return [typeId, obj.x, obj.y];
case Vec3:
// @ts-ignore
// @ts-expect-error
return [typeId, obj.x, obj.y, obj.z];
case Vec4:
case Quat:
// @ts-ignore
// @ts-expect-error
return [typeId, obj.x, obj.y, obj.z, obj.w];
case Color:
// @ts-ignore
// @ts-expect-error
return [typeId, obj._val];
case Size:
// @ts-ignore
// @ts-expect-error
return [typeId, obj.width, obj.height];
case Rect:
// @ts-ignore
// @ts-expect-error
return [typeId, obj.x, obj.y, obj.width, obj.height];
case Mat4:
// @ts-ignore
// @ts-expect-error
const res: IValueTypeData = new Array(1 + 16);
res[VALUETYPE_SETTER] = typeId;
Mat4.toArray(res, obj as Mat4, 1);
@@ -505,7 +505,7 @@ interface ICustomHandler {
customEnv: any,
}
type ClassFinder = {
// tslint:disable-next-line:callable-types
(type: string): AnyCtor;
// // for editor
// 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
const instanceOffset: number = refs[dataLength] * 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 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
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 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];
owner[key] = array;
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;
if (type !== DataTypeID.SimpleType) {
const op = ASSIGNMENTS[type];
// @ts-ignore
op(data, array, i, subValue);
}
}
@@ -806,7 +805,7 @@ ASSIGNMENTS[DataTypeID.Array] = parseArray;
function parseInstances (data: IFileData): RootInstanceIndex {
const instances = data[File.Instances];
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 normalObjectCount = instances.length - instanceTypesLen;
if (typeof rootIndex !== 'number') {
@@ -835,7 +834,7 @@ function parseInstances (data: IFileData): RootInstanceIndex {
// class index for DataTypeID.CustomizedClass
const ctor = classes[type] as CCClass<ICustomClass>; // class
instances[insIndex] = deserializeCustomCCObject(data, ctor, eachData as ICustomObjectDataContent);
instances[insIndex] = deserializeCustomCCObject(data, ctor, eachData);
}
else {
@@ -843,7 +842,6 @@ function parseInstances (data: IFileData): RootInstanceIndex {
type = (~type) as PrimitiveObjectTypeID;
const op = ASSIGNMENTS[type];
// @ts-ignore
op(data, instances, insIndex, eachData);
}
}
@@ -858,7 +856,7 @@ function parseInstances (data: IFileData): RootInstanceIndex {
// for (let i = 0; i < keys.length; ++i) {
// let newKey = attrs[keys[i] + DESERIALIZE_AS];
// if (newKey) {
// // @ts-ignore
// // @ts-expect-error
// if (keys.includes(newKey)) {
// // %s cannot be deserialized by property %s because %s was also present in the serialized data.
// warnID(, newKey, keys[i], newKey);
@@ -924,7 +922,7 @@ function cacheMasks (data: IPackedFileData) {
const classes = data[File.SharedClasses];
for (let i = 0; i < masks.length; ++i) {
const mask = masks[i];
// @ts-ignore
// @ts-expect-error
mask[MASK_CLASS] = classes[mask[MASK_CLASS]];
}
}
@@ -962,7 +960,7 @@ function parseResult (data: IFileData) {
}
const uuid = dependUuids[i];
if (typeof uuid === 'number') {
dependUuids[i] = (dependSharedUuids as SharedString[])[uuid as StringIndex];
dependUuids[i] = (dependSharedUuids as SharedString[])[uuid ];
}
else {
// 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 { legacyCC } from '../global-exports';
// @ts-ignore
const Destroyed = CCObject.Flags.Destroyed;
// @ts-ignore
const PersistentMask = CCObject.Flags.PersistentMask;
const DEFAULT = Attr.DELIMETER + 'default';
const IDENTIFIER_RE = CCClass.IDENTIFIER_RE;
@@ -139,7 +137,7 @@ class Assignments {
else {
return;
}
// tslint:disable: prefer-for-of
for (let i = 0; i < this._exps.length; i++) {
const pair = this._exps[i];
writeAssignment(codeArray, targetVar + getPropAccessor(pair[0]) + '=', pair[1]);
@@ -151,7 +149,7 @@ Assignments.pool = new js.Pool((obj: any) => {
obj._exps.length = 0;
obj._targetExp = null;
}, 1);
// @ts-ignore
// @ts-expect-error
Assignments.pool.get = function (targetExpression) {
const cache: any = this._get() || new Assignments();
cache._targetExp = targetExpression;
@@ -296,8 +294,8 @@ class Parser {
}
public setValueType (codeArray, defaultValue, srcValue, targetExpression) {
// @ts-ignore
const assignments: any = Assignments.pool.get!(targetExpression);
// @ts-expect-error
const assignments: any = Assignments.pool.get(targetExpression);
let fastDefinedProps = defaultValue.constructor.__props__;
if (!fastDefinedProps) {
fastDefinedProps = Object.keys(defaultValue);
@@ -363,7 +361,7 @@ class Parser {
}
public instantiateTypedArray (value) {
let type = value.constructor.name;
const type = value.constructor.name;
if (value.length === 0) {
return 'new ' + type;
}
+5 -5
View File
@@ -106,10 +106,10 @@ export function instantiate (original: any, internalForce?: boolean) {
let clone;
if (original instanceof CCObject) {
// @ts-ignore
// @ts-expect-error
if (original._instantiate) {
legacyCC.game._isCloning = true;
// @ts-ignore
// @ts-expect-error
clone = original._instantiate();
legacyCC.game._isCloning = false;
return clone;
@@ -175,7 +175,7 @@ function doInstantiate (obj, parent?) {
function enumerateCCClass (klass, obj, clone, parent) {
const props = klass.__values__;
// tslint:disable: prefer-for-of
for (let p = 0; p < props.length; p++) {
const key = props[p];
const value = obj[key];
@@ -246,7 +246,7 @@ function instantiateObj (obj, parent) {
if (ArrayBuffer.isView(obj)) {
let len = (obj as any).length;
clone = new ((obj as any).constructor)(len);
// @ts-ignore
// @ts-expect-error
obj._iN$t = clone;
objsToClearTmpVar.push(obj);
for (let i = 0; i < len; ++i) {
@@ -257,7 +257,7 @@ function instantiateObj (obj, parent) {
if (Array.isArray(obj)) {
const len = obj.length;
clone = new Array(len);
// @ts-ignore
// @ts-expect-error
obj._iN$t = clone;
objsToClearTmpVar.push(obj);
for (let i = 0; i < len; ++i) {
+10 -10
View File
@@ -99,7 +99,7 @@ function compileDestruct (obj, ctor) {
if (CCClass._isCCClass(ctor)) {
const attrs = legacyCC.Class.Attr.getClassAttrs(ctor);
const propList = ctor.__props__;
// tslint:disable-next-line: prefer-for-of
for (let i = 0; i < propList.length; i++) {
key = propList[i];
const attrKey = key + legacyCC.Class.Attr.DELIMETER + 'default';
@@ -126,7 +126,7 @@ function compileDestruct (obj, ctor) {
if (SUPPORT_JIT) {
// compile code
let func = '';
// tslint:disable: forin
for (key in propsToReset) {
let statement;
if (CCClass.IDENTIFIER_RE.test(key)) {
@@ -277,7 +277,7 @@ class CCObject {
if (EDITOR && deferredDestroyTimer === null && legacyCC.engine && ! legacyCC.engine._isUpdating) {
// auto destroy immediate in edit mode
// @ts-ignore
// @ts-expect-error
deferredDestroyTimer = setImmediate(CCObject._deferredDestroy);
}
return true;
@@ -320,9 +320,9 @@ class CCObject {
return;
}
// engine internal callback
// @ts-ignore
// @ts-expect-error
if (this._onPreDestroy) {
// @ts-ignore
// @ts-expect-error
this._onPreDestroy();
}
@@ -350,7 +350,7 @@ if (EDITOR || TEST) {
* @method realDestroyInEditor
* @private
*/
// @ts-ignore
// @ts-expect-error
prototype.realDestroyInEditor = function () {
if ( !(this._objFlags & Destroyed) ) {
warnID(5001);
@@ -368,7 +368,7 @@ if (EDITOR || TEST) {
if (EDITOR) {
js.value(CCObject, '_clearDeferredDestroyTimer', () => {
if (deferredDestroyTimer !== null) {
// @ts-ignore
// @ts-expect-error
clearImmediate(deferredDestroyTimer);
deferredDestroyTimer = null;
}
@@ -381,7 +381,7 @@ if (EDITOR) {
* @return {object} the serialized json data object
* @private
*/
// @ts-ignore
// @ts-expect-error
prototype._serialize = null;
}
@@ -392,14 +392,14 @@ if (EDITOR) {
* @param {_Deserializer} ctx
* @private
*/
// @ts-ignore
// @ts-expect-error
prototype._deserialize = null;
/*
* Called before the object being destroyed.
* @method _onPreDestroy
* @private
*/
// @ts-ignore
// @ts-expect-error
prototype._onPreDestroy = null;
CCClass.fastDefine('cc.Object', CCObject, { _name: '', _objFlags: 0 });
+2 -2
View File
@@ -24,8 +24,8 @@
THE SOFTWARE.
*/
// tslint:disable:only-arrow-functions
// tslint:disable:one-variable-per-declaration
import { log, warnID } from '../../platform/debug';
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 = {};
properties[newKey] = newValue;
// 将不能用于get方法中的属性移动到newValue中
// tslint:disable: forin
for (const attr in SerializableAttrs) {
const v = SerializableAttrs[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[]) {
let res: {
@@ -244,7 +244,7 @@ export function doValidateMethodWithProps_DEV (func, funcName, className, cls, b
js.isChildClassOf(base, legacyCC.Component) &&
!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.`);
}
}
+1 -1
View File
@@ -53,7 +53,7 @@ export function pop () {
const module = frameInfo.module;
let exports = module.exports;
if (exports === frameInfo.exports) {
// tslint:disable-next-line: forin
for (const anykey in exports) {
// exported
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 DEBUG = tryDefineGlobal('CC_DEBUG', true); // CC_DEV || Debug Build
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 MINIGAME = tryDefineGlobal('CC_MINIGAME', 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 OPPO = tryDefineGlobal('CC_OPPO', false);
export const VIVO = tryDefineGlobal('CC_VIVO', false);
// @ts-ignore
// @ts-expect-error
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) {
console.time('InitScene');
}
// @ts-ignore
// @ts-expect-error
scene._load(); // ensure scene initialized
if (BUILD && DEBUG) {
console.timeEnd('InitScene');
@@ -529,7 +529,7 @@ export class Director extends EventTarget {
if (BUILD && DEBUG) {
console.time('Activate');
}
// @ts-ignore
// @ts-expect-error
scene._activate();
if (BUILD && DEBUG) {
console.timeEnd('Activate');
@@ -561,7 +561,7 @@ export class Director extends EventTarget {
assertID(scene instanceof Scene, 1216);
// ensure scene initialized
// @ts-ignore
// @ts-expect-error
scene._load();
// Delay run / replace scene to the end of the frame
@@ -583,7 +583,7 @@ export class Director extends EventTarget {
warnID(1208, sceneName, this._loadingScene);
return false;
}
var bundle = legacyCC.assetManager.bundles.find((bundle) => {
const bundle = legacyCC.assetManager.bundles.find((bundle) => {
return bundle.getSceneInfo(sceneName);
});
if (bundle) {
@@ -638,7 +638,6 @@ export class Director extends EventTarget {
* @param onProgress 加载进度回调。
* @param onLoaded 加载回调。
*/
// eslint-disable-next-line @typescript-eslint/unified-signatures
public preloadScene (sceneName: string, onProgress: Director.OnLoadSceneProgress, onLoaded: Director.OnSceneLoaded): void;
public preloadScene (
@@ -646,7 +645,7 @@ export class Director extends EventTarget {
onProgress?: Director.OnLoadSceneProgress | 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);
});
if (bundle) {
+1 -1
View File
@@ -34,7 +34,7 @@ export function applyMixins (derivedCtor: any, baseCtors: any[]) {
baseCtors.forEach((baseCtor) => {
Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
if (name !== 'constructor') {
// @ts-ignore
// @ts-expect-error
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 { Eventify } from './eventify';
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
class Empty {};
class Empty {}
/**
* @en
+23 -23
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>
@@ -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
* @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>
@@ -232,7 +232,7 @@ export class Game extends EventTarget {
* 它在 cocos creator v1.x 版本中名字为 EVENT_RENDERER_INITED ,在 v2.0 版本中更名为 EVENT_ENGINE_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>
@@ -244,29 +244,29 @@ export class Game extends EventTarget {
* @en Event triggered when game 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.
* @zh 使用 Web Canvas 2d API 作为渲染器后端。
*/
public static RENDER_TYPE_CANVAS: number = 0;
public static RENDER_TYPE_CANVAS = 0;
/**
* @en WebGL API as renderer backend.
* @zh 使用 WebGL API 作为渲染器后端。
*/
public static RENDER_TYPE_WEBGL: number = 1;
public static RENDER_TYPE_WEBGL = 1;
/**
* @en OpenGL API as renderer backend.
* @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.
* @zh 游戏画布的外框,container 的父容器。
*/
public frame: Object | null = null;
public frame: Record<string, unknown> | null = null;
/**
* @en The container of game canvas.
* @zh 游戏画布的容器。
@@ -282,7 +282,7 @@ export class Game extends EventTarget {
* @en The renderer backend of the game.
* @zh 游戏的渲染器类型。
*/
public renderType: number = -1;
public renderType = -1;
public eventTargetOn = super.on;
public eventTargetOnce = super.once;
@@ -319,11 +319,11 @@ export class Game extends EventTarget {
public _persistRootNodes = {};
// states
public _paused: boolean = true; // whether the game is paused
public _configLoaded: boolean = false; // whether config loaded
public _isCloning: boolean = false; // deserializing or instantiating
public _inited: boolean = false; // whether the engine has inited
public _rendererInitialized: boolean = false;
public _paused = true; // whether the game is paused
public _configLoaded = false; // whether config loaded
public _isCloning = false; // deserializing or instantiating
public _inited = false; // whether the engine has inited
public _rendererInitialized = false;
public _gfxDevice: Device | null = null;
@@ -430,9 +430,9 @@ export class Game extends EventTarget {
*/
public restart (): Promise<void> {
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(() => {
// tslint:disable-next-line: forin
for (const id in this._persistRootNodes) {
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).
* @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) {
// Make sure EVENT_ENGINE_INITED callbacks to be invoked
if (this._inited && type === Game.EVENT_ENGINE_INITED) {
@@ -647,7 +647,7 @@ export class Game extends EventTarget {
const frameRate = this.config.frameRate;
this._frameTime = 1000 / frameRate;
if (JSB || RUNTIME_BASED) {
// @ts-ignore
// @ts-expect-error
jsb.setPreferredFramesPerSecond(frameRate);
window.rAF = window.requestAnimationFrame;
window.cAF = window.cancelAnimationFrame;
@@ -664,7 +664,7 @@ export class Game extends EventTarget {
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame;
if (frameRate !== 60 && frameRate !== 30) {
// @ts-ignore
// @ts-expect-error
window.rAF = rAF ? this._stTimeWithRAF : this._stTime;
window.cAF = this._ctTime;
}
@@ -714,7 +714,7 @@ export class Game extends EventTarget {
}
const config = this.config;
const director = legacyCC.director;
let skip: boolean = true;
let skip = true;
const frameRate = config.frameRate;
debug.setDisplayStats(!!config.showFPS);
@@ -849,7 +849,7 @@ export class Game extends EventTarget {
);
for (let i = 0; i < ctors.length; 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',
'qbrowserVisibilityChange',
];
// tslint:disable-next-line: prefer-for-of
for (let i = 0; i < changeList.length; i++) {
document.addEventListener(changeList[i], (event) => {
let visible = document[hiddenPropName];
// QQ App
// @ts-ignore
// @ts-expect-error
visible = visible || event.hidden;
if (visible) {
onHidden();
+1 -1
View File
@@ -28,7 +28,7 @@ const transform_extent_m4 = (out: Vec3, extent: Vec3, m4: Mat4) => {
* @zh
* 基础几何 轴对齐包围盒,使用中心点和半长宽高的结构。
*/
// tslint:disable-next-line: class-name
export default class aabb {
/**
+1 -1
View File
@@ -24,7 +24,7 @@ _v[7] = new Vec3(1, -1, -1);
* @zh
* 基础几何 截头锥体。
*/
// tslint:disable-next-line: class-name
export class frustum {
/**
+6 -6
View File
@@ -21,10 +21,10 @@ import { IRaySubMeshOptions, ERaycastMode, IRaySubMeshResult, IRayMeshOptions, I
import { IVec3Like } from '../math/type-define';
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
@@ -408,7 +408,7 @@ const ray_subMesh = (function () {
const max = submesh.geometricInfo.boundingBox.max;
if (ray_aabb2(ray, min, max)) {
const pm = submesh.primitiveMode;
const { positions: vb, indices: ib } = submesh.geometricInfo!;
const { positions: vb, indices: ib } = submesh.geometricInfo;
narrowphase(vb, ib!, pm, ray, opt);
}
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
/**
* @en
+1 -1
View File
@@ -12,7 +12,7 @@ import enums from './enums';
* @zh
* 基础几何 line。
*/
// tslint:disable-next-line:class-name
export default class line {
/**
+1 -1
View File
@@ -24,7 +24,7 @@ const transform_extent_m3 = (out: Vec3, extent: Vec3, m3: Mat3) => {
* @zh
* 基础几何 方向包围盒。
*/
// tslint:disable-next-line:class-name
export default class obb {
/**
+1 -1
View File
@@ -18,7 +18,7 @@ const temp_vec4 = legacyCC.v4();
* @zh
* 基础几何 plane。
*/
// tslint:disable-next-line:class-name
export default class plane {
/**
+4 -4
View File
@@ -13,7 +13,7 @@ import { IVec3Like } from '../math/type-define';
* @zh
* 基础几何 射线。
*/
// tslint:disable-next-line:class-name
export default class ray {
/**
@@ -29,7 +29,7 @@ export default class ray {
* @param {number} dz 方向的 z 部分。
* @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);
}
@@ -145,8 +145,8 @@ export default class ray {
* @param {number} dy 方向的 y 部分。
* @param {number} dz 方向的 z 部分。
*/
constructor (ox: number = 0, oy: number = 0, oz: number = 0,
dx: number = 0, dy: number = 0, dz: number = -1) {
constructor (ox = 0, oy = 0, oz = 0,
dx = 0, dy = 0, dz = -1) {
this._type = enums.SHAPE_RAY;
this.o = new Vec3(ox, oy, oz);
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
* 基础几何 轴对齐球。
*/
// tslint:disable-next-line: class-name
export default class sphere {
/**
@@ -201,7 +201,7 @@ export default class sphere {
* @param cz 该球的世界坐标的 Z 坐标。
* @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._center = new Vec3(cx, cy, cz);
this._poolHandle = SpherePool.alloc();
+7 -7
View File
@@ -12,7 +12,7 @@ import enums from './enums';
* @zh
* 基础几何 三角形。
*/
// tslint:disable-next-line:class-name
export default class triangle {
/**
@@ -31,9 +31,9 @@ export default class triangle {
* @param {number} cz c 点的 z 部分。
* @return {triangle} 一个新的 triangle。
*/
public static create (ax: number = 1, ay: number = 0, az: number = 0,
bx: number = 0, by: number = 0, bz: number = 0,
cx: number = 0, cy: number = 0, cz: number = 1): triangle {
public static create (ax = 1, ay = 0, az = 0,
bx = 0, by = 0, bz = 0,
cx = 0, cy = 0, cz = 1): triangle {
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} cz c 点的 z 部分。
*/
constructor (ax: number = 0, ay: number = 0, az: number = 0,
bx: number = 1, by: number = 0, bz: number = 0,
cx: number = 0, cy: number = 1, cz: number = 0) {
constructor (ax = 0, ay = 0, az = 0,
bx = 1, by = 0, bz = 0,
cx = 0, cy = 1, cz = 0) {
this._type = enums.SHAPE_TRIANGLE;
this.a = new Vec3(ax, ay, az);
this.b = new Vec3(bx, by, bz);
+9 -9
View File
@@ -3,6 +3,7 @@
* @module gfx
*/
import { Device } from './device';
import {
BufferFlagBit,
BufferFlags,
@@ -13,10 +14,9 @@ import {
Obj,
ObjectType,
} from './define';
import { Device } from './device';
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 (
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 {
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 (
public drawInfos: DrawInfo[] = [],
@@ -42,7 +42,7 @@ export class IndirectBuffer {
export type BufferSource = ArrayBuffer | IndirectBuffer;
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 (
public usage: BufferUsage,
@@ -54,7 +54,7 @@ export class BufferInfo {
}
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 (
public buffer: Buffer,
@@ -124,9 +124,9 @@ export abstract class Buffer extends Obj {
protected _device: Device;
protected _usage: BufferUsage = BufferUsageBit.NONE;
protected _memUsage: MemoryUsage = MemoryUsageBit.NONE;
protected _size: number = 0;
protected _stride: number = 1;
protected _count: number = 0;
protected _size = 0;
protected _stride = 1;
protected _count = 0;
protected _flags: BufferFlags = BufferFlagBit.NONE;
protected _bakcupBuffer: Uint8Array | null = null;
protected _indirectBuffer: IndirectBuffer | null = null;
+13 -12
View File
@@ -3,25 +3,25 @@
* @module gfx
*/
import { DescriptorSet } from './descriptor-set';
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 {
CommandBufferType,
Obj,
ObjectType,
StencilFace,
} 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 {
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 (
public queue: Queue,
@@ -33,7 +33,7 @@ export class CommandBufferInfo {
* @en GFX command buffer.
* @zh GFX 命令缓冲。
*/
// tslint:disable: max-line-length
export abstract class CommandBuffer extends Obj {
/**
@@ -122,7 +122,8 @@ export abstract class CommandBuffer extends Obj {
* @param clearDepth The clearing depth.
* @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.
+8 -8
View File
@@ -3,7 +3,7 @@
*/
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 (
public x: number = 0,
@@ -14,7 +14,7 @@ export class Rect {
}
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 (
public left: number = 0,
@@ -27,7 +27,7 @@ export class Viewport {
}
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 (
public x: number = 0,
@@ -38,7 +38,7 @@ export class Color {
}
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 (
public x: number = 0,
@@ -48,7 +48,7 @@ export class Offset {
}
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 (
public width: number = 0,
@@ -58,7 +58,7 @@ export class Extent {
}
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 (
public mipLevel: number = 0,
@@ -68,7 +68,7 @@ export class TextureSubres {
}
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 (
public srcSubres = new TextureSubres(),
@@ -80,7 +80,7 @@ export class TextureCopy {
}
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 (
public buffStride: number = 0,
+2 -2
View File
@@ -600,7 +600,7 @@ export enum Feature {
}
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 (
public readonly name: string,
@@ -615,7 +615,7 @@ export class FormatInfo {
}
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 (
public bufferSize: number = 0,
+3 -3
View File
@@ -3,12 +3,12 @@
* @module gfx
*/
import { DescriptorType, Obj, ObjectType, ShaderStageFlagBit, ShaderStageFlags } from './define';
import { Device } from './device';
import { Sampler } from './sampler';
import { DescriptorType, Obj, ObjectType, ShaderStageFlagBit, ShaderStageFlags } from './define';
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 (
public binding: number = -1,
@@ -20,7 +20,7 @@ export class DescriptorSetLayoutBinding {
}
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 (
public bindings: DescriptorSetLayoutBinding[] = []
+6 -6
View File
@@ -4,11 +4,11 @@
*/
import { Buffer } from './buffer';
import { DescriptorType, Obj, ObjectType } from './define';
import { DescriptorSetLayout } from './descriptor-set-layout';
import { Device } from './device';
import { Sampler } from './sampler';
import { Texture } from './texture';
import { DescriptorSetLayout } from './descriptor-set-layout';
import { DescriptorType, Obj, ObjectType } from './define';
export const DESCRIPTOR_BUFFER_TYPE =
DescriptorType.UNIFORM_BUFFER | DescriptorType.DYNAMIC_UNIFORM_BUFFER |
@@ -17,7 +17,7 @@ export const DESCRIPTOR_BUFFER_TYPE =
export const DESCRIPTOR_SAMPLER_TYPE = DescriptorType.SAMPLER;
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 (
public layout: DescriptorSetLayout,
@@ -62,7 +62,7 @@ export abstract class DescriptorSet extends Obj {
*/
public bindBuffer (binding: number, buffer: Buffer, index = 0) {
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) {
const descriptorIndex = this._layout!.descriptorIndices[binding];
if (this._buffers[descriptorIndex + index] !== buffer) {
@@ -82,7 +82,7 @@ export abstract class DescriptorSet extends Obj {
*/
public bindSampler (binding: number, sampler: Sampler, index = 0) {
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) {
const descriptorIndex = this._layout!.descriptorIndices[binding];
if (this._samplers[descriptorIndex + index] !== sampler) {
@@ -102,7 +102,7 @@ export abstract class DescriptorSet extends Obj {
*/
public bindTexture (binding: number, texture: Texture, index = 0) {
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) {
const descriptorIndex = this._layout!.descriptorIndices[binding];
if (this._textures[descriptorIndex + index] !== texture) {
+36 -36
View File
@@ -4,11 +4,12 @@
*/
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 { CommandBuffer, CommandBufferInfo } from './command-buffer';
import { Filter, Format, MemoryStatus, API, Feature, SurfaceTransform } from './define';
import { BufferTextureCopy, Rect } from './define-class';
import { CommandBuffer, CommandBufferInfo } from './command-buffer';
import { DescriptorSet, DescriptorSetInfo } from './descriptor-set';
import { Fence, FenceInfo } from './fence';
import { Framebuffer, FramebufferInfo } from './framebuffer';
import { InputAssembler, InputAssemblerInfo } from './input-assembler';
@@ -18,12 +19,11 @@ import { RenderPass, RenderPassInfo } from './render-pass';
import { Sampler, SamplerInfo } from './sampler';
import { Shader, ShaderInfo } from './shader';
import { Texture, TextureInfo, TextureViewInfo } from './texture';
import { gfx } from '../../../exports/base';
ccenum(Format);
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 (
public bufferOffsets: number[] = [],
@@ -33,7 +33,7 @@ export class BindingMappingInfo {
}
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 (
public canvasElm: HTMLElement,
@@ -345,38 +345,38 @@ export abstract class Device {
protected _canvas: HTMLCanvasElement | null = null;
protected _canvas2D: HTMLCanvasElement | null = null;
protected _gfxAPI: API = API.UNKNOWN;
protected _transform: SurfaceTransform = SurfaceTransform.IDENTITY;
protected _deviceName: string = '';
protected _renderer: string = '';
protected _vendor: string = '';
protected _version: string = '';
protected _features: boolean[] = new Array<boolean>(Feature.COUNT);
protected _gfxAPI = API.UNKNOWN;
protected _transform = SurfaceTransform.IDENTITY;
protected _deviceName = '';
protected _renderer = '';
protected _vendor = '';
protected _version = '';
protected _features = new Array<boolean>(Feature.COUNT);
protected _queue: Queue | null = null;
protected _cmdBuff: CommandBuffer | null = null;
protected _devicePixelRatio: number = 1.0;
protected _width: number = 0;
protected _height: number = 0;
protected _nativeWidth: number = 0;
protected _nativeHeight: number = 0;
protected _maxVertexAttributes: number = 0;
protected _maxVertexUniformVectors: number = 0;
protected _maxFragmentUniformVectors: number = 0;
protected _maxTextureUnits: number = 0;
protected _maxVertexTextureUnits: number = 0;
protected _maxUniformBufferBindings: number = 0;
protected _maxUniformBlockSize: number = 0;
protected _maxTextureSize: number = 0;
protected _maxCubeMapTextureSize: number = 0;
protected _uboOffsetAlignment: number = 1;
protected _depthBits: number = 0;
protected _stencilBits: number = 0;
protected _colorFmt: Format = Format.UNKNOWN;
protected _depthStencilFmt: Format = Format.UNKNOWN;
protected _macros: Map<string, string> = new Map();
protected _numDrawCalls: number = 0;
protected _numInstances: number = 0;
protected _numTris: number = 0;
protected _devicePixelRatio = 1.0;
protected _width = 0;
protected _height = 0;
protected _nativeWidth = 0;
protected _nativeHeight = 0;
protected _maxVertexAttributes = 0;
protected _maxVertexUniformVectors = 0;
protected _maxFragmentUniformVectors = 0;
protected _maxTextureUnits = 0;
protected _maxVertexTextureUnits = 0;
protected _maxUniformBufferBindings = 0;
protected _maxUniformBlockSize = 0;
protected _maxTextureSize = 0;
protected _maxCubeMapTextureSize = 0;
protected _uboOffsetAlignment = 1;
protected _depthBits = 0;
protected _stencilBits = 0;
protected _colorFmt = Format.UNKNOWN;
protected _depthStencilFmt = Format.UNKNOWN;
protected _macros = new Map<string, string>();
protected _numDrawCalls = 0;
protected _numInstances = 0;
protected _numTris = 0;
protected _memoryStatus = new MemoryStatus();
protected _clipSpaceMinZ = -1;
protected _screenSpaceSignY = 1;
+3 -3
View File
@@ -3,14 +3,14 @@
* @module gfx
*/
import { Obj, ObjectType } from './define';
import { Device } from './device';
import { Obj, ObjectType } from './define';
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 (
){}
) {}
}
/**
+2 -2
View File
@@ -3,13 +3,13 @@
* @module gfx
*/
import { Obj, ObjectType } from './define';
import { Device } from './device';
import { RenderPass } from './render-pass';
import { Texture } from './texture';
import { Obj, ObjectType } from './define';
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 (
public renderPass: RenderPass,
+1 -1
View File
@@ -3,8 +3,8 @@
* @module gfx
*/
import { polyfillCC } from './polyfill-legacy-cc';
import { legacyCC } from '../global-exports';
import { polyfillCC } from './polyfill-legacy-cc';
import './deprecated-3.0.0';
export * from './descriptor-set';
+15 -15
View File
@@ -4,9 +4,9 @@
*/
import { Buffer } from './buffer';
import { Format, Obj, ObjectType } from './define';
import { Device } from './device';
import { murmurhash2_32_gc } from '../utils/murmurhash2_gc';
import { Format, Obj, ObjectType } from './define';
export interface IAttribute {
name: string;
@@ -18,7 +18,7 @@ export interface IAttribute {
}
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 (
public name: string = '',
@@ -31,7 +31,7 @@ export class Attribute {
}
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 (
public attributes: Attribute[] = [],
@@ -179,21 +179,21 @@ export abstract class InputAssembler extends Obj {
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;
@@ -202,15 +202,12 @@ export abstract class InputAssembler extends Obj {
this._device = device;
}
public abstract initialize (info: InputAssemblerInfo): boolean;
public abstract destroy (): void;
/**
* @en Get the specified vertex buffer.
* @zh 获取顶点缓冲。
* @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) {
return this._vertexBuffers[stream];
} else {
@@ -226,4 +223,7 @@ export abstract class InputAssembler extends Obj {
}
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
*/
import { Obj, ObjectType } from './define';
import { Device } from './device';
import { DescriptorSetLayout } from './descriptor-set-layout';
import { Device } from './device';
import { Obj, ObjectType } from './define';
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 (
public setLayouts: DescriptorSetLayout[] = [],
+6 -4
View File
@@ -2,6 +2,7 @@ declare const gfx: any;
declare type RecursivePartial<T> = {
[P in keyof T]?:
T[P] extends Array<infer U> ? Array<RecursivePartial<U>> :
T[P] extends ReadonlyArray<infer V> ? ReadonlyArray<RecursivePartial<V>> : RecursivePartial<T[P]>;
};
@@ -18,7 +19,8 @@ import {
} from './define';
import { Color } from './define-class';
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 {
private h: RasterizerStateHandle;
@@ -84,7 +86,7 @@ export class RasterizerState {
get handle (): RasterizerStateHandle { return this.h; }
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);
}
@@ -169,7 +171,7 @@ export class DepthStencilState {
if (DepthStencilStatePool.get(this.h, DepthStencilStateView.DEPTH_TEST)) return true;
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 {
if (DepthStencilStatePool.get(this.h, DepthStencilStateView.DEPTH_WRITE)) return true;
else return false;
@@ -423,7 +425,7 @@ export class BlendState {
this.isIndepend = false;
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) {
targets[i].destroy();
}
+20 -17
View File
@@ -3,12 +3,19 @@
* @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 {
BlendFactor,
BlendOp,
ColorMask,
ComparisonFunc,
CullMode,
DynamicStateFlagBit,
DynamicStateFlags,
Obj,
ObjectType,
@@ -16,14 +23,7 @@ import {
PrimitiveMode,
ShadeModel,
StencilOp,
DynamicStateFlagBit,
} 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';
/**
@@ -31,7 +31,7 @@ import { NULL_HANDLE, RawBufferHandle } from '../renderer/core/memory-pools';
* @zh GFX 光栅化状态。
*/
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 (
public isDiscard: boolean = false,
@@ -68,6 +68,7 @@ export class RasterizerState {
}
get handle (): RawBufferHandle { return NULL_HANDLE; }
public destroy () {}
}
@@ -76,7 +77,7 @@ export class RasterizerState {
* @zh GFX 深度模板状态。
*/
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 (
public depthTest: boolean = true,
@@ -127,6 +128,7 @@ export class DepthStencilState {
}
get handle (): RawBufferHandle { return NULL_HANDLE; }
public destroy () {}
}
@@ -135,7 +137,7 @@ export class DepthStencilState {
* @zh GFX 混合目标。
*/
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 (
public blend: boolean = false,
@@ -164,6 +166,7 @@ export class BlendTarget {
}
get handle (): RawBufferHandle { return NULL_HANDLE; }
public destroy () {}
}
@@ -172,7 +175,7 @@ export class BlendTarget {
* @zh GFX 混合状态。
*/
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 (
public isA2C: boolean = false,
@@ -209,6 +212,7 @@ export class BlendState {
}
get handle (): RawBufferHandle { return NULL_HANDLE; }
public destroy () {}
}
@@ -217,7 +221,7 @@ export class BlendState {
* @zh GFX 输入状态。
*/
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 (
public attributes: Attribute[] = [],
@@ -225,7 +229,7 @@ export class InputState {
}
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 (
public shader: Shader,
@@ -245,7 +249,6 @@ export class PipelineStateInfo {
* @zh GFX 管线状态。
*/
export abstract class PipelineState extends Obj {
/**
* @en Get current shader.
* @zh GFX 着色器。
@@ -275,7 +278,7 @@ export abstract class PipelineState extends Obj {
* @zh GFX 光栅化状态。
*/
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 深度模板状态。
*/
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 混合状态。
*/
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 { Shader } from './shader';
import { Texture } from './texture';
import { FormatSize,FormatSurfaceSize,GetTypeSize,getTypedArrayConstructor,MAX_ATTACHMENTS,
ObjectType,Obj,AttributeName,Type,Format,BufferUsageBit,MemoryUsageBit,BufferFlagBit,
BufferAccessBit,PrimitiveMode,PolygonMode,ShadeModel,CullMode,ComparisonFunc,StencilOp,BlendOp,
BlendFactor,ColorMask,Filter,Address,TextureType,TextureUsageBit,SampleCount,TextureFlagBit,ShaderStageFlagBit,
DescriptorType,CommandBufferType,LoadOp,StoreOp,TextureLayout,PipelineBindPoint,DynamicStateFlagBit,StencilFace,
QueueType,ClearFlag,FormatType,
FormatInfo,MemoryStatus,FormatInfos } from './define';
import { Rect, Viewport, Color, Offset, Extent, TextureSubres, TextureCopy, BufferTextureCopy } from './define-class';
import { Address, AttributeName, BlendFactor, BlendOp, BufferAccessBit,
BufferFlagBit, BufferUsageBit, ClearFlag, ColorMask, CommandBufferType, ComparisonFunc, CullMode, DescriptorType,
DynamicStateFlagBit, Filter, Format, FormatInfo, FormatInfos, FormatSize, FormatSurfaceSize, FormatType,
GetTypeSize, LoadOp, MAX_ATTACHMENTS, MemoryStatus, MemoryUsageBit, Obj, ObjectType, PipelineBindPoint, PolygonMode,
PrimitiveMode, QueueType, SampleCount, ShadeModel, ShaderStageFlagBit, StencilFace, StencilOp, StoreOp,
TextureFlagBit, TextureLayout, TextureType,
TextureUsageBit, Type, getTypedArrayConstructor } from './define';
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,
FormatSize,FormatSurfaceSize,GetTypeSize,getTypedArrayConstructor,MAX_ATTACHMENTS,
ObjectType,Obj,AttributeName,Type,Format,BufferUsageBit,MemoryUsageBit,BufferFlagBit,
BufferAccessBit,PrimitiveMode,PolygonMode,ShadeModel,CullMode,ComparisonFunc,StencilOp,BlendOp,
BlendFactor,ColorMask,Filter,Address,TextureType,TextureUsageBit,SampleCount,TextureFlagBit,ShaderStageFlagBit,
DescriptorType,CommandBufferType,LoadOp,StoreOp,TextureLayout,PipelineBindPoint,DynamicStateFlagBit,StencilFace,
QueueType,Rect,Viewport,Color,ClearFlag,Offset,Extent,TextureSubres,TextureCopy,BufferTextureCopy,FormatType,
FormatInfo,MemoryStatus,FormatInfos};
export const polyfillCC = { Device, Buffer, Texture, Sampler, Shader, InputAssembler, RenderPass, Framebuffer, PipelineState, CommandBuffer, Queue,
FormatSize, FormatSurfaceSize, GetTypeSize, getTypedArrayConstructor, MAX_ATTACHMENTS,
ObjectType, Obj, AttributeName, Type, Format, BufferUsageBit, MemoryUsageBit, BufferFlagBit,
BufferAccessBit, PrimitiveMode, PolygonMode, ShadeModel, CullMode, ComparisonFunc, StencilOp, BlendOp,
BlendFactor, ColorMask, Filter, Address, TextureType, TextureUsageBit, SampleCount, TextureFlagBit, ShaderStageFlagBit,
DescriptorType, CommandBufferType, LoadOp, StoreOp, TextureLayout, PipelineBindPoint, DynamicStateFlagBit, StencilFace,
QueueType, Rect, Viewport, Color, ClearFlag, Offset, Extent, TextureSubres, TextureCopy, BufferTextureCopy, FormatType,
FormatInfo, MemoryStatus, FormatInfos };
+4 -4
View File
@@ -4,12 +4,12 @@
*/
import { CommandBuffer } from './command-buffer';
import { Obj, ObjectType, QueueType } from './define';
import { Device } from './device';
import { Fence } from './fence';
import { Obj, ObjectType, QueueType } from './define';
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 (
public type: QueueType = QueueType.GRAPHICS,
@@ -41,12 +41,12 @@ export abstract class Queue extends Obj {
this._device = device;
}
public isAsync () { return this._isAsync; }
public abstract initialize (info: QueueInfo): boolean;
public abstract destroy (): void;
public isAsync () { return this._isAsync; }
/**
* @en Submit command buffers.
* @zh 提交命令缓冲数组。
+12 -12
View File
@@ -3,6 +3,8 @@
* @module gfx
*/
import { Device } from './device';
import { murmurhash2_32_gc } from '../utils/murmurhash2_gc';
import {
Format,
LoadOp,
@@ -12,15 +14,13 @@ import {
StoreOp,
TextureLayout,
} from './define';
import { Device } from './device';
import { murmurhash2_32_gc } from '../utils/murmurhash2_gc';
/**
* @en Color attachment.
* @zh GFX 颜色附件。
*/
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 (
public format: Format = Format.UNKNOWN,
@@ -37,7 +37,7 @@ export class ColorAttachment {
* @zh GFX 深度模板附件。
*/
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 (
public format: Format = Format.UNKNOWN,
@@ -52,7 +52,7 @@ export class DepthStencilAttachment {
}
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 (
public bindPoint: PipelineBindPoint = PipelineBindPoint.GRAPHICS,
@@ -65,7 +65,7 @@ export class SubPassInfo {
}
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 (
public colorAttachments: ColorAttachment[] = [],
@@ -86,9 +86,9 @@ export abstract class RenderPass extends Obj {
protected _depthStencilInfo: DepthStencilAttachment | null = null;
protected _subPasses : SubPassInfo[] = [];
protected _subPasses: SubPassInfo[] = [];
protected _hash: number = 0;
protected _hash = 0;
get colorAttachments () { return this._colorInfos; }
get depthStencilAttachment () { return this._depthStencilInfo; }
@@ -100,10 +100,6 @@ export abstract class RenderPass extends Obj {
this._device = device;
}
public abstract initialize (info: RenderPassInfo): boolean;
public abstract destroy (): void;
// Based on render pass compatibility
protected computeHash (): number {
let res = '';
@@ -143,4 +139,8 @@ export abstract class RenderPass extends Obj {
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
*/
import { Address, ComparisonFunc, Filter, Obj, ObjectType } from './define';
import { Color } from './define-class';
import { Device } from './device';
import { Address, ComparisonFunc, Filter, Obj, ObjectType } from './define';
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 (
public minFilter: Filter = Filter.LINEAR,
@@ -53,12 +53,12 @@ export abstract class Sampler extends Obj {
protected _addressU: Address = Address.WRAP;
protected _addressV: Address = Address.WRAP;
protected _addressW: Address = Address.WRAP;
protected _maxAnisotropy: number = 16;
protected _maxAnisotropy = 16;
protected _cmpFunc: ComparisonFunc = ComparisonFunc.NEVER;
protected _borderColor: Color = new Color();
protected _minLOD: number = 0;
protected _maxLOD: number = 0;
protected _mipLODBias: number = 0.0;
protected _minLOD = 0;
protected _maxLOD = 0;
protected _mipLODBias = 0.0;
constructor (device: Device) {
super(ObjectType.SAMPLER);
+9 -9
View File
@@ -3,9 +3,9 @@
* @module gfx
*/
import { Obj, ObjectType, ShaderStageFlagBit, Type } from './define';
import { Device } from './device';
import { Attribute } from './input-assembler';
import { Device } from './device';
import { Obj, ObjectType, ShaderStageFlagBit, Type } from './define';
export interface IShaderStage {
stage: ShaderStageFlagBit;
@@ -13,7 +13,7 @@ export interface 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 (
public stage: ShaderStageFlagBit = ShaderStageFlagBit.NONE,
@@ -32,7 +32,7 @@ export interface IUniform {
* @zh GFX uniform。
*/
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 (
public name: string = '',
@@ -46,7 +46,7 @@ export class Uniform implements IUniform {
* @zh GFX uniform 块。
*/
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 (
public set: number = -1,
@@ -62,7 +62,7 @@ export class UniformBlock {
* @zh GFX Uniform 采样器。
*/
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 (
public set: number = -1,
@@ -74,7 +74,7 @@ export class UniformSampler {
}
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 (
public name: string = '',
@@ -90,7 +90,7 @@ export class ShaderInfo {
* @zh GFX 着色器。
*/
export abstract class Shader extends Obj {
private static _shaderIdGen: number = 0;
private static _shaderIdGen = 0;
/**
* @en Get current shader id.
@@ -124,7 +124,7 @@ export abstract class Shader extends Obj {
protected _id: number;
protected _name: string = '';
protected _name = '';
protected _stages: ShaderStage[] = [];
+11 -11
View File
@@ -3,6 +3,7 @@
* @module gfx
*/
import { Device } from './device';
import {
Format,
Obj,
@@ -14,10 +15,9 @@ import {
TextureUsage,
TextureUsageBit,
} from './define';
import { Device } from './device';
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 (
public type: TextureType,
@@ -34,7 +34,7 @@ export class TextureInfo {
}
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 (
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;
}
@@ -158,15 +158,15 @@ export abstract class Texture extends Obj {
protected _type: TextureType = TextureType.TEX2D;
protected _usage: TextureUsage = TextureUsageBit.NONE;
protected _format: Format = Format.UNKNOWN;
protected _width: number = 0;
protected _height: number = 0;
protected _depth: number = 1;
protected _layerCount: number = 1;
protected _levelCount: number = 1;
protected _width = 0;
protected _height = 0;
protected _depth = 1;
protected _layerCount = 1;
protected _levelCount = 1;
protected _samples: SampleCount = SampleCount.X1;
protected _flags: TextureFlags = TextureFlagBit.NONE;
protected _isPowerOf2: boolean = false;
protected _size: number = 0;
protected _isPowerOf2 = false;
protected _size = 0;
protected _buffer: ArrayBuffer | null = null;
constructor (device: Device) {
+3 -3
View File
@@ -48,7 +48,7 @@ export class WebGLCommandBuffer extends CommandBuffer {
public cmdPackage: WebGLCmdPackage = new WebGLCmdPackage();
protected _webGLAllocator: WebGLCommandAllocator | null = null;
protected _isInRenderPass: boolean = false;
protected _isInRenderPass = false;
protected _curGPUPipelineState: IWebGLGPUPipelineState | null = null;
protected _curGPUInputAssembler: IWebGLGPUInputAssembler | null = null;
protected _curGPUDescriptorSets: IWebGLGPUDescriptorSet[] = [];
@@ -61,7 +61,7 @@ export class WebGLCommandBuffer extends CommandBuffer {
protected _curDepthBounds: IWebGLDepthBounds | null = null;
protected _curStencilWriteMask: IWebGLStencilWriteMask | null = null;
protected _curStencilCompareMask: IWebGLStencilCompareMask | null = null;
protected _isStateInvalied: boolean = false;
protected _isStateInvalied = false;
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) {
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
if (RUNTIME_BASED && !VIVO) {
// @ts-ignore
// @ts-expect-error
if (typeof loadRuntime !== 'function' || !loadRuntime() || typeof loadRuntime().getFeature !== 'function' || loadRuntime()
.getFeature('webgl.extensions.oes_vertex_array_object.revision') <= 0) {
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,
} from 'internal:constants';
// @ts-ignore
const _global = typeof window === 'undefined' ? global : window;
/**
+4 -4
View File
@@ -314,7 +314,7 @@ export class Color extends ValueType {
* @zh 用十六进制颜色字符串中构造颜色。
* @param hexString Hexadecimal color string.
*/
// tslint:disable-next-line: unified-signatures
constructor (hexString: string);
/**
@@ -466,8 +466,8 @@ export class Color extends ValueType {
(this.g < 16 ? prefix : '') + (this.g).toString(16),
(this.b < 16 ? prefix : '') + (this.b).toString(16),
];
let i = -1;
if ( fmt === '#rgb' ) {
const i = -1;
if (fmt === '#rgb') {
hex[0] = hex[0][0];
hex[1] = hex[1][0];
hex[2] = hex[2][0];
@@ -617,7 +617,7 @@ export class Color extends ValueType {
*/
public set(other: Color): 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 (r._val != null) {
this._val = r._val;
+7 -7
View File
@@ -40,7 +40,7 @@ import { legacyCC } from '../global-exports';
* @en Mathematical 3x3 matrix.
* @zh 表示三维(3x3)矩阵。
*/
// tslint:disable:one-variable-per-declaration
export class Mat3 extends ValueType {
public static IDENTITY = Object.freeze(new Mat3());
@@ -692,9 +692,9 @@ export class Mat3 extends ValueType {
m06?: number, m07?: number, m08?: number);
constructor (
m00: number | Mat3 = 1, m01: number = 0, m02: number = 0,
m03: number = 0, m04: number = 1, m05: number = 0,
m06: number = 0, m07: number = 0, m08: number = 1 ) {
m00: number | Mat3 = 1, m01 = 0, m02 = 0,
m03 = 0, m04 = 1, m05 = 0,
m06 = 0, m07 = 0, m08 = 1) {
super();
if (typeof m00 === 'object') {
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,
m06?: number, m07?: number, m08?: number);
public set (m00: number | Mat3 = 1, m01: number = 0, m02: number = 0,
m03: number = 0, m04: number = 1, m05: number = 0,
m06: number = 0, m07: number = 0, m08: number = 1 ) {
public set (m00: number | Mat3 = 1, m01 = 0, m02 = 0,
m03 = 0, m04 = 1, m05 = 0,
m06 = 0, m07 = 0, m08 = 1) {
if (typeof m00 === 'object') {
this.m00 = m00.m00; this.m01 = m00.m01; this.m02 = m00.m02;
this.m03 = m00.m03; this.m04 = m00.m04; this.m05 = m00.m05;
+1 -1
View File
@@ -48,7 +48,7 @@ export const preTransforms = Object.freeze([
* @en Mathematical 4x4 matrix.
* @zh 表示四维(4x4)矩阵。
*/
// tslint:disable:one-variable-per-declaration
export class Mat4 extends ValueType {
public static IDENTITY = Object.freeze(new Mat4());
+1 -1
View File
@@ -5,7 +5,7 @@
* @hidden
*/
// tslint:disable:no-shadowed-variable
function _compare (a, b) {
return a - b;

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