mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
Extract enum to avoid circular reference (#4298)
This commit is contained in:
committed by
Weiliang Wang
parent
efa0d249da
commit
9dc687bfde
@@ -12,7 +12,7 @@ import {
|
||||
IRaycastOptions, LockConstraintBase, PhysicsWorldBase,
|
||||
PointToPointConstraintBase, RigidBodyBase, ShapeBase, SphereShapeBase,
|
||||
} from './api';
|
||||
import { ERigidBodyType } from './physic-enum';
|
||||
import { ERigidBodyType, ETransformSource } from './physic-enum';
|
||||
import { RaycastResult } from './raycast-result';
|
||||
import { stringfyQuat, stringfyVec3 } from './util';
|
||||
|
||||
@@ -166,11 +166,6 @@ function fillRaycastResult (result: RaycastResult, cannonResult: CANNON.RaycastR
|
||||
);
|
||||
}
|
||||
|
||||
enum ETransformSource {
|
||||
Scene,
|
||||
Physics,
|
||||
}
|
||||
|
||||
export class CannonRigidBody implements RigidBodyBase {
|
||||
|
||||
get impl (): CANNON.Body {
|
||||
@@ -185,7 +180,7 @@ export class CannonRigidBody implements RigidBodyBase {
|
||||
private _onWorldPostStepListener: (event: CANNON.ICollisionEvent) => any;
|
||||
private _collisionCallbacks: ICollisionCallback[] = [];
|
||||
private _shapes: CannonShape[] = [];
|
||||
private _transformSource: ETransformSource = ETransformSource.Scene;
|
||||
private _transformSource: ETransformSource = ETransformSource.SCENE;
|
||||
private _userData: any;
|
||||
private _world: CannonWorld | null = null;
|
||||
private _name: string;
|
||||
@@ -377,7 +372,7 @@ export class CannonRigidBody implements RigidBodyBase {
|
||||
}
|
||||
|
||||
public isPhysicsManagedTransform (): boolean {
|
||||
return this._transformSource === ETransformSource.Physics;
|
||||
return this._transformSource === ETransformSource.PHYSIC;
|
||||
}
|
||||
|
||||
public getPosition (out: Vec3) {
|
||||
@@ -443,9 +438,9 @@ export class CannonRigidBody implements RigidBodyBase {
|
||||
private _onBodyTypeUpdated () {
|
||||
if (this._cannonBody) {
|
||||
if (this._cannonBody.type === CANNON.Body.STATIC) {
|
||||
this._transformSource = ETransformSource.Scene;
|
||||
this._transformSource = ETransformSource.SCENE;
|
||||
} else {
|
||||
this._transformSource = ETransformSource.Physics;
|
||||
this._transformSource = ETransformSource.PHYSIC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
import { GFXAddress, GFXFilter, GFXFormat } from '../gfx/define';
|
||||
|
||||
/**
|
||||
* The texture pixel format, default value is RGBA8888,
|
||||
* you should note that textures loaded by normal image files (png, jpg) can only support RGBA8888 format,
|
||||
* other formats are supported by compressed file types or raw data.
|
||||
* @enum {number}
|
||||
*/
|
||||
export enum PixelFormat {
|
||||
/**
|
||||
* 16-bit texture without Alpha channel
|
||||
*/
|
||||
RGB565 = GFXFormat.R5G6B5,
|
||||
/**
|
||||
* 16-bit textures: RGB5A1
|
||||
*/
|
||||
RGB5A1 = GFXFormat.RGB5A1,
|
||||
/**
|
||||
* 16-bit textures: RGBA4444
|
||||
*/
|
||||
RGBA4444 = GFXFormat.RGBA4,
|
||||
/**
|
||||
* 24-bit texture: RGB888
|
||||
*/
|
||||
RGB888 = GFXFormat.RGB8,
|
||||
/**
|
||||
* 32-bit texture: RGBA8888
|
||||
*/
|
||||
RGBA8888 = GFXFormat.RGBA8,
|
||||
/**
|
||||
* 32-bit float texture: RGBA32F
|
||||
*/
|
||||
RGBA32F = GFXFormat.RGBA32F,
|
||||
/**
|
||||
* 8-bit textures used as masks
|
||||
*/
|
||||
A8 = GFXFormat.A8,
|
||||
/**
|
||||
* 8-bit intensity texture
|
||||
*/
|
||||
I8 = GFXFormat.L8,
|
||||
/**
|
||||
* 16-bit textures used as masks
|
||||
*/
|
||||
AI8 = GFXFormat.LA8,
|
||||
/**
|
||||
* rgb 2 bpp pvrtc
|
||||
*/
|
||||
RGB_PVRTC_2BPPV1 = GFXFormat.PVRTC_RGB2,
|
||||
/**
|
||||
* rgba 2 bpp pvrtc
|
||||
*/
|
||||
RGBA_PVRTC_2BPPV1 = GFXFormat.PVRTC_RGBA2,
|
||||
/**
|
||||
* rgb 4 bpp pvrtc
|
||||
*/
|
||||
RGB_PVRTC_4BPPV1 = GFXFormat.PVRTC_RGB4,
|
||||
/**
|
||||
* rgba 4 bpp pvrtc
|
||||
*/
|
||||
RGBA_PVRTC_4BPPV1 = GFXFormat.PVRTC_RGBA4,
|
||||
/**
|
||||
* rgb etc1
|
||||
*/
|
||||
RGB_ETC1 = GFXFormat.ETC_RGB8,
|
||||
/**
|
||||
* rgb etc2
|
||||
*/
|
||||
RGB_ETC2 = GFXFormat.ETC2_RGB8,
|
||||
/**
|
||||
* rgba etc2
|
||||
*/
|
||||
RGBA_ETC2 = GFXFormat.ETC2_RGBA8,
|
||||
}
|
||||
|
||||
/**
|
||||
* The texture wrap mode.
|
||||
* @enum {number}
|
||||
*/
|
||||
export enum WrapMode {
|
||||
/**
|
||||
* Specifies that the repeat warp mode will be used.
|
||||
*/
|
||||
REPEAT = GFXAddress.WRAP,
|
||||
/**
|
||||
* Specifies that the clamp to edge warp mode will be used.
|
||||
*/
|
||||
CLAMP_TO_EDGE = GFXAddress.CLAMP,
|
||||
/**
|
||||
* Specifies that the mirrored repeat warp mode will be used.
|
||||
*/
|
||||
MIRRORED_REPEAT = GFXAddress.MIRROR,
|
||||
/**
|
||||
* Specifies that the clamp to border wrap mode will be used.
|
||||
*/
|
||||
CLAMP_TO_BORDER = GFXAddress.BORDER,
|
||||
}
|
||||
|
||||
/**
|
||||
* The texture filter mode
|
||||
* @enum {number}
|
||||
*/
|
||||
export enum Filter {
|
||||
NONE = GFXFilter.NONE,
|
||||
/**
|
||||
* Specifies linear filtering.
|
||||
*/
|
||||
LINEAR = GFXFilter.LINEAR,
|
||||
/**
|
||||
* Specifies nearest filtering.
|
||||
*/
|
||||
NEAREST = GFXFilter.POINT,
|
||||
}
|
||||
@@ -24,10 +24,11 @@
|
||||
****************************************************************************/
|
||||
// @ts-check
|
||||
import {ccclass, property} from '../core/data/class-decorator';
|
||||
// import {addon} from '../core/utils/js';
|
||||
import { Asset } from './asset';
|
||||
import { EventTargetFactory } from '../core/event/event-target-factory';
|
||||
import { GFXDevice, GFXFeature } from '../gfx/device';
|
||||
// import {addon} from '../core/utils/js';
|
||||
import { Asset } from './asset';
|
||||
import { PixelFormat } from './asset-enum';
|
||||
|
||||
export interface IMemoryImageSource {
|
||||
_data: ArrayBufferView | null;
|
||||
@@ -187,7 +188,7 @@ export class ImageAsset extends EventTargetFactory(Asset) {
|
||||
let format = this._format;
|
||||
let ext = '';
|
||||
const SupportTextureFormats = cc.macro.SUPPORT_TEXTURE_FORMATS as string[];
|
||||
const PixelFormat = cc.TextureBase.PixelFormat;
|
||||
// const PixelFormat = cc.TextureBase.PixelFormat;
|
||||
for (const extensionID of extensionIDs) {
|
||||
const extFormat = extensionID.split('@');
|
||||
|
||||
|
||||
@@ -27,131 +27,19 @@
|
||||
import {ccclass, property} from '../core/data/class-decorator';
|
||||
import { EventTargetFactory } from '../core/event/event-target-factory';
|
||||
import IDGenerator from '../core/utils/id-generator';
|
||||
import { GFXAddress, GFXBufferTextureCopy, GFXFilter, GFXFormat,
|
||||
GFXTextureFlagBit, GFXTextureType, GFXTextureUsageBit, GFXTextureViewType } from '../gfx/define';
|
||||
import { GFXBufferTextureCopy, GFXTextureFlagBit, GFXTextureType, GFXTextureUsageBit, GFXTextureViewType } from '../gfx/define';
|
||||
import { GFXDevice } from '../gfx/device';
|
||||
import { GFXTexture, IGFXTextureInfo } from '../gfx/texture';
|
||||
import { GFXTextureView, IGFXTextureViewInfo } from '../gfx/texture-view';
|
||||
import { SamplerInfoIndex } from '../renderer/core/sampler-lib';
|
||||
import { Asset } from './asset';
|
||||
import { Filter, PixelFormat, WrapMode } from './asset-enum';
|
||||
import { ImageAsset } from './image-asset';
|
||||
|
||||
const CHAR_CODE_1 = 49; // '1'
|
||||
|
||||
const idGenerator = new IDGenerator('Tex');
|
||||
|
||||
/**
|
||||
* The texture pixel format, default value is RGBA8888,
|
||||
* you should note that textures loaded by normal image files (png, jpg) can only support RGBA8888 format,
|
||||
* other formats are supported by compressed file types or raw data.
|
||||
* @enum {number}
|
||||
*/
|
||||
export enum PixelFormat {
|
||||
/**
|
||||
* 16-bit texture without Alpha channel
|
||||
*/
|
||||
RGB565 = GFXFormat.R5G6B5,
|
||||
/**
|
||||
* 16-bit textures: RGB5A1
|
||||
*/
|
||||
RGB5A1 = GFXFormat.RGB5A1,
|
||||
/**
|
||||
* 16-bit textures: RGBA4444
|
||||
*/
|
||||
RGBA4444 = GFXFormat.RGBA4,
|
||||
/**
|
||||
* 24-bit texture: RGB888
|
||||
*/
|
||||
RGB888 = GFXFormat.RGB8,
|
||||
/**
|
||||
* 32-bit texture: RGBA8888
|
||||
*/
|
||||
RGBA8888 = GFXFormat.RGBA8,
|
||||
/**
|
||||
* 32-bit float texture: RGBA32F
|
||||
*/
|
||||
RGBA32F = GFXFormat.RGBA32F,
|
||||
/**
|
||||
* 8-bit textures used as masks
|
||||
*/
|
||||
A8 = GFXFormat.A8,
|
||||
/**
|
||||
* 8-bit intensity texture
|
||||
*/
|
||||
I8 = GFXFormat.L8,
|
||||
/**
|
||||
* 16-bit textures used as masks
|
||||
*/
|
||||
AI8 = GFXFormat.LA8,
|
||||
/**
|
||||
* rgb 2 bpp pvrtc
|
||||
*/
|
||||
RGB_PVRTC_2BPPV1 = GFXFormat.PVRTC_RGB2,
|
||||
/**
|
||||
* rgba 2 bpp pvrtc
|
||||
*/
|
||||
RGBA_PVRTC_2BPPV1 = GFXFormat.PVRTC_RGBA2,
|
||||
/**
|
||||
* rgb 4 bpp pvrtc
|
||||
*/
|
||||
RGB_PVRTC_4BPPV1 = GFXFormat.PVRTC_RGB4,
|
||||
/**
|
||||
* rgba 4 bpp pvrtc
|
||||
*/
|
||||
RGBA_PVRTC_4BPPV1 = GFXFormat.PVRTC_RGBA4,
|
||||
/**
|
||||
* rgb etc1
|
||||
*/
|
||||
RGB_ETC1 = GFXFormat.ETC_RGB8,
|
||||
/**
|
||||
* rgb etc2
|
||||
*/
|
||||
RGB_ETC2 = GFXFormat.ETC2_RGB8,
|
||||
/**
|
||||
* rgba etc2
|
||||
*/
|
||||
RGBA_ETC2 = GFXFormat.ETC2_RGBA8,
|
||||
}
|
||||
|
||||
/**
|
||||
* The texture wrap mode.
|
||||
* @enum {number}
|
||||
*/
|
||||
export enum WrapMode {
|
||||
/**
|
||||
* Specifies that the repeat warp mode will be used.
|
||||
*/
|
||||
REPEAT = GFXAddress.WRAP,
|
||||
/**
|
||||
* Specifies that the clamp to edge warp mode will be used.
|
||||
*/
|
||||
CLAMP_TO_EDGE = GFXAddress.CLAMP,
|
||||
/**
|
||||
* Specifies that the mirrored repeat warp mode will be used.
|
||||
*/
|
||||
MIRRORED_REPEAT = GFXAddress.MIRROR,
|
||||
/**
|
||||
* Specifies that the clamp to border wrap mode will be used.
|
||||
*/
|
||||
CLAMP_TO_BORDER = GFXAddress.BORDER,
|
||||
}
|
||||
|
||||
/**
|
||||
* The texture filter mode
|
||||
* @enum {number}
|
||||
*/
|
||||
export enum Filter {
|
||||
NONE = GFXFilter.NONE,
|
||||
/**
|
||||
* Specifies linear filtering.
|
||||
*/
|
||||
LINEAR = GFXFilter.LINEAR,
|
||||
/**
|
||||
* Specifies nearest filtering.
|
||||
*/
|
||||
NEAREST = GFXFilter.POINT,
|
||||
}
|
||||
|
||||
@ccclass('cc.TextureBase')
|
||||
export class TextureBase extends EventTargetFactory(Asset) {
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
import Skeleton from '../../3d/assets/skeleton';
|
||||
import { Filter, PixelFormat, WrapMode } from '../../assets/asset-enum';
|
||||
import { Texture2D } from '../../assets/texture-2d';
|
||||
import { Filter, PixelFormat, WrapMode } from '../../assets/texture-base';
|
||||
import { mat4, vec3, vec4 } from '../../core/vmath';
|
||||
import { GFXBuffer } from '../../gfx/buffer';
|
||||
import { GFXBufferUsageBit, GFXMemoryUsageBit } from '../../gfx/define';
|
||||
|
||||
Reference in New Issue
Block a user